WebClient gives empty response?
Hello,
I wonder why I get an empty response from the below URL?
When open the URL in chrome, there is a JSON response.
[code]WebClient client = new WebClient();
client.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2");
Stream data = client.OpenRead("https://api.coinsecure.in/v1/exchange/ticker");
StreamReader reader = new StreamReader(data);
String responseBody = reader.ReadToEnd();
data.Close(); reader.Close();
MessageBox.Show(responseBody);[/code]
amp synchronize() crash
how to change array_view to array for this code
[code]void Zoom(Picture *source, Picture *destination)
{
int rows = destination->Rows;
int cols = destination->Cols;
int centerx = source->CenterX;
int centery = source->CenterY;
int radius = source->Radius;
float xrate = (float)rows / (float)radius / 2;
float yrate = (float)cols / (float)radius / 2;
unsigned int * src = (unsigned int *)source->Data;
unsigned int *dest = (unsigned int *)destination->Data;
array_view<const unsigned int, 2> SV(source->Rows,source->Cols,src);
array_view<unsigned int, 2> DV(rows,cols,dest);
DV.discard_data();
parallel_for_each(DV.extent, [=](index<2> idx) restrict(amp)
{
int x = idx[0], y = idx[1];
int xx = x / xrate + centerx - radius;
int yy = y / yrate + centery - radius;
DV[idx] = SV(xx,yy);
});
DV.synchronize();
concurrency::amp_uninitialize();
}[/code]
thumbnailPhoto not getting in case of Global Catalog
I have created a AD forest that search for a user across all domains in the forest using its global catalog connection string.
I am trying to get thumbnailPhoto of AD user using c# code. But I did not get thumbnailPhoto property in result object even though it exist in AD.
I had verified the thumbnailPhoto prop in AD using powershell. Also I have verified it by getting using LDAP connection string. It both case I got the byte array.
Below is the code to get user and its properties and _configuration.GlobalCatalog returns the Global catalog connections string which is in format (GC://domain-name).
[code]public Task<ProfileImage> GetProfileImageByEmail(string email)
{
var filterQuery = ("mail=" + email);
return Task.FromResult(GetProfileImageFromAD(filterQuery));
}
private ProfileImage GetProfileImageFromAD(string filterQuery)
{
var result = GetADUserDetails(filterQuery);
if (result == null)
return null;
if (result.Properties.Contains("thumbnailPhoto"))
{
var imageBytes = result.Properties["thumbnailPhoto"][0] as byte[];
if (imageBytes != null)
{
return new ProfileImage
{
Content = new MemoryStream(imageBytes),
ContentType = "image/jpeg"
};
}
}
return null;
}
private SearchResult GetADUserDetails(string filterQuery)
{
using (var userBinding = new DirectoryEntry(_configuration.GlobalCatalog))
{
using (DirectorySearcher adSearch = new DirectorySearcher(userBinding))
{
adSearch.ReferralChasing = ReferralChasingOption.All;
adSearch.Filter = filterQuery;
adSearch.PropertiesToLoad.Add("mail");
adSearch.PropertiesToLoad.Add("sn");
adSearch.PropertiesToLoad.Add("givenName");
adSearch.PropertiesToLoad.Add("thumbnailPhoto");
return adSearch.FindOne();
}
}
}[/code]
WebBrowser Point Zoom
Hello, im using click.point to click in webbrowser control.
I've added zoom out (i need it for i can see all elements) my problem is if i keep the zoom at 100 works fine if i put zoom to 25 dont work.
Zoom code:
[code]Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As EventArgs) Handles WebBrowser1.DocumentCompleted
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, 25, IntPtr.Zero)
Catch ex As Exception
MsgBox("Error:" & ex.Message)
End Try
End Sub[/code]
Im getting point position with this:
[code] Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim WebLoc As Point = PointToScreen(WebBrowser1.Location)
Dim WebCurPos As Point = New Point(Cursor.Position.X - WebLoc.X, Cursor.Position.Y - WebLoc.Y)
With WebCurPos
If .X < 0 Or .Y < 0 Or .X > WebBrowser1.Width Or .Y > WebBrowser1.Height Then
'Debug.WriteLine("Mouse position outside of webbrowser!")
Else
Label1.Text = (WebCurPos.ToString)
End If
End With
End Sub[/code]
If i use zoom code to reduce to 25 the click not work if i use it with 100 works.
I think i need to divide my code of getting point but i dont know how.
PrintPreviewDialog
On the following page,
[img]
https://social.msdn.microsoft.com/Forums/getfile/1011324[/img]
How can I fix this error on this page?
my code;
[code] private void btnPrint_Click(object _sender, EventArgs args)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = printdocument;
ppd.ClientSize = new Size(900, 600);
ppd.ShowIcon = true;
ppd.Icon = new Icon(Assembly.GetEntryAssembly().GetManifestResourceStream("Konak.Desktop.Images.SBCM.ICO"));
ppd.StartPosition = FormStartPosition.CenterScreen;
ppd.Document.DocumentName = "Transfer Islem Bilgileri";
this.printdocument.PrintPage += (s, a) => { printdocument_PrintPage(s, a); };
ppd.ShowDialog();
}
private void printdocument_PrintPage(object S, PrintPageEventArgs a)
{
float leftMargin = a.MarginBounds.Left;
float topMargin = a.MarginBounds.Top;
int count = 0;
List<string> lst = new List<string>();
for (int i = 0; i < listboxInfoList.Items.Count; i++)
{
a.Graphics.DrawString(listboxInfoList.Items[i].ToString(), this.Font, Brushes.Black, leftMargin, topMargin + count * this.Font.GetHeight(a.Graphics), new StringFormat());
lst.Add(listboxInfoList.Items[i].ToString());
count++;
}
if (!(count >= lst.Count - 1))
{
a.HasMorePages = true;
}
else
{
a.HasMorePages = false;
}
}[/code]
When I try to set Active Directory user properties, throw exception
It`s a good day to die....
I`m trying to make & modify windows application about AD group and users.
This application works like this.
Users choose property and mapping it from source data(DB or Excel files...)
And press sync start button, that properties put into the AD User.
But When I set AD user`s properties, it throws exception like this in DirectoryEntry.CommitChanges(); block.
The directory
service cannot perform the requested operation on the RDN attribute of an object.
Sadly I`m a newbie of Active Directory, I don`t know how to solve it... Please help me.
Code is below.
[code]void CreateADUser(string ppk,string pk,DataRow row)
{
string pass = GetPass(pk,row,LogSections.AD);
DirectoryEntry addept = adm.FindOU(ppk);
string sOU = adm.GetPrincipalPath(addept);
var aduser = adm.CreateNewUser(sOU, pk, pass, pk, null, null, adm.sDomain);
SetAdUserProperties(pk, pass, row);
MoveUser(ppk,pk);
}
void SetAdUserProperties(string pk,string pass,DataRow row)
{
if (row == null) return;
List<ADMapping> MappingPatterns = GetAdMappings(Words.User,false);
var colnames = Tool.GetColNames(row);
var aduser = adm.GetUser(pk);
var de=aduser.GetUnderlyingObject() as DirectoryEntry;
foreach (var ADMap in MappingPatterns)
{
string val = ADMap.Mapping;
val=Util.ReplaceColPattern(val, row);
SetProperty(de, ADMap.CN, val);
}
if (!string.IsNullOrWhiteSpace(pass))
{
var UserPkColumn = AppConfigHelper.GetAppString(Words.SourceUserPKColumn);
UserPkColumn = Util.GetActualColName(UserPkColumn);
aduser.SetPassword(pass);
QueryHelper.Update(QueryHelper.ConnectionString, Words.ShadowUserTable
,new SqlParameter[] { new SqlParameter("@passwd", pass) }
, new SqlParameter("@"+UserPkColumn,pk));
}
aduser.Save();
}
public void SetProperty(DirectoryEntry oDE, string sPropertyName, object sPropertyValue)
{
if (sPropertyValue != null && !string.IsNullOrWhiteSpace(sPropertyValue.ToString()))
{
if (oDE.Properties.Contains(sPropertyName))
{
oDE.Properties[sPropertyName].Value = sPropertyValue;
}
else
{
oDE.Properties[sPropertyName].Add(sPropertyValue);
}
try
{
oDE.CommitChanges(); //exception here.
oDE.Close();
}
catch (Exception)
{
}
}
}[/code]
Database server MS Access mdb and accdb
I have a program that I am trying to upgrade and using Crystal Reports. The database for the report is MS access 2010 (.accdb).
When I start the program it is looking for the prior MS Access database .mdb and I can not log on to the correct database.
I understand from my research that this was a problem with VS 2008. There must be a solution someware.
Database server MS Access mdb and accdb
I have a program that I am trying to upgrade and using Crystal Reports. The database for the report is MS access 2010 (.accdb).
When I start the program it is looking for the prior MS Access database .mdb and I can not log on to the correct database.
I understand from my research that this was a problem with VS 2008. There must be a solution someware.
No value given for one or more required parameters. WHILE FILLING DATATABLE
i create a datatable in dataset in degine mode with union query.
query as below
SELECT DateofPickup AS Mdate, Name, Address, PhoneNo, SerialNo, DateofVist, ItemName, DateofPickup, TotalQty, Rateof, OpeningB, Dateofretrun, Retrun, Balance,
TotalDay, NULL AS adv
FROM Report
UNION ALL
SELECT Dateofpay AS Mdate, Name, Address, PhoneNo, SerialNno AS SerialNo, DateofVist, NULL AS ItemName, Dateofpay AS DateofPickup, NULL AS TotalQty, NULL
AS Rateof, NULL AS OpeningB, NULL AS Dateofretrun, NULL AS Retrun, NULL AS Balance, NULL AS TotalDay, Adv
FROM PaymentDetail
when i try to fill this datatable with where condation on page load event then it show error (No value given for one or more required parameters.) without where condation its work fine. code as below.
Dim report As New CrystalReport1
OpenConnect()
Cmd.CommandText = "Select * from RFinal where serialno='" & Form4.SerialNoTextBox.Text & "'"
da.SelectCommand = Cmd
da.Fill(ds, "rfinal")---------error occur here No value given for one or more required parameters
report.SetDataSource(ds)
CrystalReportViewer1.ReportSource = report
dt.Clear()
da.Dispose()
conn.Close()
End Sub
i also try it with parameter
Cmd.CommandText = "Select * from RFinal where serialno=@a"
Cmd.Parameters.AddWithValue("@a", Form4.SerialNoTextBox.Text)
da.SelectCommand = Cmd
da.Fill(ds, "rfinal")---------error occur here No value given for one or more required parameters
report.SetDataSource(ds)