|
The issue comes while generating heavy report after increasing packet size and connection timeout.
microsoft told that it is a bug in the product, for that we need to make hotfixing on our server. I there any another solution to do that if hotfixing is not possible
|
|
|
|
|
I've hit a road block and can't figure out why I am getting this response back. It appears that it connects to the server but it returns:
"System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server server2.domain.local failed with the following error message: An invalid argument was supplied".
I enabled everything I thought on the remote computer:
winrm set winrm/config/service/auth @{Basic="true"}
winrm set winrm/config/service @{AllowUnencrypted="true"}
winrm set winrm/config/client @{TrustedHosts="*"}
I'm trying to remote powershell so I can run Citrix powershell commands from another computer and here is what I have:
try
{
XenDesktop7 xd = new XenDesktop7("http://server2.domain.local:5985/wsman", @"DOMAIN\Administrator", "#######");
string[] blah = xd.GetCatalogs();
foreach (var b in blah)
{
Console.WriteLine(b);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
public CitrixPowershell(string uri, string username, string password)
{
this._connection = GetConnection(uri, username, password);
PSSnapInException snapinException;
_runspace = RunspaceFactory.CreateRunspace(_connection);
_runspace.Open();
_runspace.RunspaceConfiguration.AddPSSnapIn("Citrix.*.Admin.V*", out snapinException);
_powershell = PowerShell.Create();
_powershell.Runspace = _runspace;
}
private WSManConnectionInfo GetConnection(string uri, string username, string password)
{
SecureString pwd = new SecureString();
foreach (char x in password)
pwd.AppendChar(x);
PSCredential ps = new PSCredential(username, pwd);
WSManConnectionInfo wsinfo = new WSManConnectionInfo(false, "server2.domain.local", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.PowerShell", ps);
wsinfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
wsinfo.ProxyAuthentication = AuthenticationMechanism.Negotiate;
return wsinfo;
}
|
|
|
|
|
JD86 wrote: failed with the following error message: An invalid argument was supplied". Somewhere in your application there is a line of code that has a bad parameter. Identify that and you are on your way to a solution.
|
|
|
|
|
|
JD86 wrote: this should be working. Maybe so, but you still need to do some debugging to find out why it isn't.
|
|
|
|
|
Well it turns out the code actually does work. I'm not able to get it to work running it from my Server 2012 R2 lab server but from my 2008 R2 lab server it runs fine. I'll have to do some more investigating but at least I know the code is right!
Thanks!
|
|
|
|
|
How can I create a nested TreeView for Windows 8.1 app , data will be bind at runtime using C#? There is no Treeview Control in Windows 8.1 Development.
|
|
|
|
|
Bhola S. Parit wrote: There is no Treeview Control in Windows 8.1 Development I'm not sure if this will meet your needs, but: [^].
And, when use the term "nested," what does that mean: isn't a TreeView an example of a structure designed to express "nesting" already ?
I don't work with XAML or RT, but I know one developer who uses the GroupedGridView to represent hierarchy: [^].
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
hi
i have Datagridview
and i want to print this
so
my language is Right to left
i use Printducument but is dosnt work
please help me
tanx
-----------------
class PrintDGV
{
private static StringFormat StrFormat;
private static StringFormat StrFormatComboBox;
private static Button CellButton;
private static CheckBox CellCheckBox;
private static ComboBox CellComboBox;
private static int TotalWidth;
private static int RowPos;
private static bool NewPage;
private static int PageNo;
private static ArrayList Columnlefts = new ArrayList();
private static ArrayList ColumnWidths = new ArrayList();
private static ArrayList ColumnTypes = new ArrayList();
private static int CellHeight;
private static int RowsPerPage;
private static System.Drawing.Printing.PrintDocument printDoc =
new System.Drawing.Printing.PrintDocument();
private static string PrintTitle = "";
private static DataGridView dgv;
private static List<string> SelectedColumns = new List<string>();
private static List<string> AvailableColumns = new List<string>();
private static bool PrintAllRows = true;
private static bool FitToPageWidth = true;
private static int HeaderHeight = 0;
public static void Print_DataGridView(DataGridView dgv1)
{
PrintPreviewDialog ppvw;
try
{
dgv = dgv1;
AvailableColumns.Clear();
foreach (DataGridViewColumn c in dgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
FrmPrintOptions dlg = new FrmPrintOptions(AvailableColumns);
if (dlg.ShowDialog() != DialogResult.OK) return;
PrintTitle = dlg.PrintTitle;
PrintAllRows = dlg.PrintAllRows;
FitToPageWidth = dlg.FitToPageWidth;
SelectedColumns = dlg.GetSelectedColumns();
RowsPerPage = 0;
ppvw = new PrintPreviewDialog();
ppvw.Document = printDoc;
printDoc.BeginPrint +=new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
if (ppvw.ShowDialog() != DialogResult.OK)
{
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
return;
}
printDoc.Print();
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
}
}
private static void PrintDoc_BeginPrint(object sender,
System.Drawing.Printing.PrintEventArgs e)
{
try
{
StrFormat = new StringFormat();
StrFormat.Alignment = StringAlignment.Near;
StrFormat.LineAlignment = StringAlignment.Center;
StrFormat.Trimming = StringTrimming.EllipsisCharacter;
StrFormatComboBox = new StringFormat();
StrFormatComboBox.LineAlignment = StringAlignment.Center;
StrFormatComboBox.FormatFlags = StringFormatFlags.NoWrap;
StrFormatComboBox.Trimming = StringTrimming.EllipsisCharacter;
Columnlefts.Clear();
ColumnWidths.Clear();
ColumnTypes.Clear();
CellHeight = 0;
RowsPerPage = 0;
CellButton = new Button();
CellCheckBox = new CheckBox();
CellComboBox = new ComboBox();
TotalWidth = 0;
foreach (DataGridViewColumn GridCol in dgv.Columns)
{
if (!GridCol.Visible) continue;
if (!PrintDGV.SelectedColumns.Contains(GridCol.HeaderText)) continue;
TotalWidth += GridCol.Width;
}
PageNo = 1;
NewPage = true;
RowPos = 0;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private static void PrintDoc_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
int tmpWidth, i;
int tmpTop = e.MarginBounds.Top;
int tmpleft = e.MarginBounds.Left;
try
{
if (PageNo == 1)
{
foreach (DataGridViewColumn GridCol in dgv.Columns)
{
if (!GridCol.Visible) continue;
if (!PrintDGV.SelectedColumns.Contains(GridCol.HeaderText)) continue;
if (FitToPageWidth)
tmpWidth = (int)(Math.Floor((double)((double)GridCol.Width /
(double)TotalWidth * (double)TotalWidth *
((double)e.MarginBounds.Width / (double)TotalWidth))));
else
tmpWidth = GridCol.Width;
HeaderHeight = (int)(e.Graphics.MeasureString(GridCol.HeaderText,
GridCol.InheritedStyle.Font, tmpWidth).Height) + 11;
Columnlefts.Add(tmpleft);
ColumnWidths.Add(tmpWidth);
ColumnTypes.Add(GridCol.GetType());
tmpleft += tmpWidth;
}
}
while (RowPos <= dgv.Rows.Count - 1)
{
DataGridViewRow GridRow = dgv.Rows[RowPos];
if (GridRow.IsNewRow || (!PrintAllRows && !GridRow.Selected))
{
RowPos++;
continue;
}
CellHeight = GridRow.Height;
if (tmpTop + CellHeight >= e.MarginBounds.Height + e.MarginBounds.Top)
{
DrawFooter(e, RowsPerPage);
NewPage = true;
PageNo++;
e.HasMorePages = true;
return;
}
else
{
if (NewPage)
{
e.Graphics.DrawString(PrintTitle, new Font(dgv.Font, FontStyle.Bold),
Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top -
e.Graphics.MeasureString(PrintTitle, new Font(dgv.Font,
FontStyle.Bold), e.MarginBounds.Width).Height - 13);
String s = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString();
e.Graphics.DrawString(s, new Font(dgv.Font, FontStyle.Bold),
Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
e.Graphics.MeasureString(s, new Font(dgv.Font,
FontStyle.Bold), e.MarginBounds.Width).Width), e.MarginBounds.Top -
e.Graphics.MeasureString(PrintTitle, new Font(new Font(dgv.Font,
FontStyle.Bold), FontStyle.Bold), e.MarginBounds.Width).Height - 13);
tmpTop = e.MarginBounds.Top;
i = 0;
foreach (DataGridViewColumn GridCol in dgv.Columns)
{
if (!GridCol.Visible) continue;
if (!PrintDGV.SelectedColumns.Contains(GridCol.HeaderText))
continue;
e.Graphics.FillRectangle(new SolidBrush(Color.LightGray),
new Rectangle((int) Columnlefts[i], tmpTop,
(int)ColumnWidths[i], HeaderHeight));
e.Graphics.DrawRectangle(Pens.Black,
new Rectangle((int) Columnlefts[i], tmpTop,
(int)ColumnWidths[i], HeaderHeight));
e.Graphics.DrawString(GridCol.HeaderText, GridCol.InheritedStyle.Font,
new SolidBrush(GridCol.InheritedStyle.ForeColor),
new RectangleF((int)Columnlefts[i], tmpTop,
(int)ColumnWidths[i], HeaderHeight), StrFormat);
i++;
}
NewPage = false;
tmpTop += HeaderHeight;
}
i = 0;
foreach (DataGridViewCell Cel in GridRow.Cells)
{
if (!Cel.OwningColumn.Visible) continue;
if (!SelectedColumns.Contains(Cel.OwningColumn.HeaderText))
continue;
if (((Type) ColumnTypes[i]).Name == "DataGridViewTextBoxColumn" ||
((Type) ColumnTypes[i]).Name == "DataGridViewLinkColumn")
{
e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font,
new SolidBrush(Cel.InheritedStyle.ForeColor),
new RectangleF((int)Columnlefts[i], (float)tmpTop,
(int)ColumnWidths[i], (float)CellHeight), StrFormat);
}
else if (((Type) ColumnTypes[i]).Name == "DataGridViewButtonColumn")
{
CellButton.Text = Cel.Value.ToString();
CellButton.Size = new Size((int)ColumnWidths[i], CellHeight);
Bitmap bmp =new Bitmap(CellButton.Width, CellButton.Height);
CellButton.DrawToBitmap(bmp, new Rectangle(0, 0,
bmp.Width, bmp.Height));
e.Graphics.DrawImage(bmp, new Point((int)Columnlefts[i], tmpTop));
}
else if (((Type) ColumnTypes[i]).Name == "DataGridViewCheckBoxColumn")
{
CellCheckBox.Size = new Size(14, 14);
CellCheckBox.Checked = (bool)Cel.Value;
Bitmap bmp = new Bitmap((int)ColumnWidths[i], CellHeight);
Graphics tmpGraphics = Graphics.FromImage(bmp);
tmpGraphics.FillRectangle(Brushes.White, new Rectangle(0, 0,
bmp.Width, bmp.Height));
CellCheckBox.DrawToBitmap(bmp,
new Rectangle((int)((bmp.Width - CellCheckBox.Width) / 2),
(int)((bmp.Height - CellCheckBox.Height) / 2),
CellCheckBox.Width, CellCheckBox.Height));
e.Graphics.DrawImage(bmp, new Point((int)Columnlefts[i], tmpTop));
}
else if (((Type) ColumnTypes[i]).Name == "DataGridViewComboBoxColumn")
{
CellComboBox.Size = new Size((int)ColumnWidths[i], CellHeight);
Bitmap bmp = new Bitmap(CellComboBox.Width, CellComboBox.Height);
CellComboBox.DrawToBitmap(bmp, new Rectangle(0, 0,
bmp.Width, bmp.Height));
e.Graphics.DrawImage(bmp, new Point((int)Columnlefts[i], tmpTop));
e.Graphics.DrawString(Cel.Value.ToString(), Cel.InheritedStyle.Font,
new SolidBrush(Cel.InheritedStyle.ForeColor),
new RectangleF((int)Columnlefts[i] + 1, tmpTop, (int)ColumnWidths[i]
- 16, CellHeight), StrFormatComboBox);
}
else if (((Type) ColumnTypes[i]).Name == "DataGridViewImageColumn")
{
Rectangle CelSize = new Rectangle((int)Columnlefts[i],
tmpTop, (int)ColumnWidths[i], CellHeight);
Size ImgSize = ((Image)(Cel.FormattedValue)).Size;
e.Graphics.DrawImage((Image)Cel.FormattedValue,
new Rectangle((int)Columnlefts[i] + (int)((CelSize.Width - ImgSize.Width) / 2),
tmpTop + (int)((CelSize.Height - ImgSize.Height) / 2),
((Image)(Cel.FormattedValue)).Width, ((Image)(Cel.FormattedValue)).Height));
}
e.Graphics.DrawRectangle(Pens.Black, new Rectangle((int)Columnlefts[i],
tmpTop, (int)ColumnWidths[i], CellHeight));
i++;
}
tmpTop += CellHeight;
}
RowPos++;
if (PageNo == 1) RowsPerPage++;
}
if (RowsPerPage == 0) return;
DrawFooter(e, RowsPerPage);
e.HasMorePages = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private static void DrawFooter(System.Drawing.Printing.PrintPageEventArgs e,
int RowsPerPage)
{
double cnt = 0;
if (PrintAllRows)
{
if (dgv.Rows[dgv.Rows.Count - 1].IsNewRow)
cnt = dgv.Rows.Count - 2;
else
cnt = dgv.Rows.Count - 1;
}
else
cnt = dgv.SelectedRows.Count;
string PageNum = PageNo.ToString() + " of " +
Math.Ceiling((double)(cnt / RowsPerPage)).ToString();
e.Graphics.DrawString(PageNum, dgv.Font, Brushes.Black,
e.MarginBounds.Left + (e.MarginBounds.Width -
e.Graphics.MeasureString(PageNum, dgv.Font,
e.MarginBounds.Width).Width) / 2, e.MarginBounds.Top +
e.MarginBounds.Height + 31);
}
}
|
|
|
|
|
|
Where is the problem?
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
"It doesn't work" does not really help. As is, I'd be guessing that the order in which the columns are drawn are the opposite of what you want to achieve. That's simple; reverse the loop that does the drawing.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I have Cisco PBX outputing date in NTP format like this:
09:47:55.999 BAH Sun Dec 7 2014
10:06:58.245 BAH Sun Dec 7 2014
11:21:18.723 BAH Sun Dec 7 2014
I want to know how can I convert it to UTC format in order to save it to MySQL database datetime field?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
Assuming the format you want is ISO 8601 [^]:
09:47:55.999 BAH Sun Dec 7 2014
Should be transformed into: YYYY-MM-DDThh:mm:ss.sTZD
2014-12-07T09:47:55.999+03:00
?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Sir,I want use datagridview with tab control.plz send me link where i can understand,how can i use tabcontrol with datagridview.
thanks
|
|
|
|
|
Hi,
Check my Article which is realted to adding controls to Datagridview.You can use the same functionality add tab control
DataGridView Helper Class[^]
|
|
|
|
|
Hi guys!
When i create my project, i want to display a single page in a c# WinForms, same as a website, when i click on an item of navibar, other page will display. I have already tried to search but i can't find out.
Like this <a href="http://paulstovell.com/blog/wpf-navigation"></a>
Can you point me control or library extended in c# to do that, not MDI form?
Thanks!
|
|
|
|
|
Where are your 'pages' coming from and how are you switching between them?
|
|
|
|
|
|
Presumably, by calling some methods, or setting some properties in the tab control. Your question is far from clear.
|
|
|
|
|
Hello Everyone,
I have run into a coding problem that has been driving me crazy for two days. I am running a console project from within my C# project using Process.Start() and trying to read the output into a string in my project. I have tried everything that I have found on the internet over the last two days and nothing works. Always returning an empty string. I have tried both synchronous and asynchronous methods and everything in between ie reading standarderror as well as standoutput. The exe that is being called is codegen.exe which is the compiled binary for creating a song fingerprint in Echoprint.
I can run this from a code prompt and it works perfectly every time outputting a fingerprint string. I am running windows 7 / VS2013 Express. The funny thing is, I have the source code for the codegen.exe and the data being output to the console is using nothing other than printf statements so there is nothing surprising going on there.
I did try doing a simple call to cmd.exe with "dir" argument and it responds correctly and fills my string with its output.
I am hoping that someone can suggest something that I have not yet tried, however I have tried all the different examples from MSDN as well as the internet.
Perhaps some one has had a similar issue and can offer some suggestions or point me in a different direction.
Any help would be appreciated.
Ray H
modified 8-Dec-14 11:21am.
|
|
|
|
|
I have never used EchoPrint, or launched a Console Application using Process.Start from within a WinForms project, so what follows may be irrelevant, or useless, but, given the fact you've done thorough searching, and haven't come up with anything, and on the odd chance it may be helpful, I'll put it out here.
If I find out this is not relevant, I'll remove this message, and my "feelings" will not be "hurt"
Is it possible that if you launch a Console from a C# project using the 'AllocConsole API, you can then, somehow, get that Console running codegen.exe ... so you would, then, be able to interact ?
Your C# project is WinForms, or WPF, or C++ ?
The 'AllocConsole API works for me (only tested in .NET 4.5) to enable two-way interaction between a Win Form and a Console it launches:
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool AllocConsole();
private void button1_Click(object sender, EventArgs e)
{
AllocConsole();
MessageBox.Show(ConsoleWriteAndReadLine(new string[]{"arg 1","arg 2","arg 3"}));
}
private string ConsoleWriteAndReadLine(string[] values)
{
Console.WriteLine("Command line = {0}", Environment.CommandLine);
for (int i = 0; i < values.Length; i++)
{
Console.WriteLine("argument{0} = {1}", i + 1, values[i]);
}
Console.Write("? ");
return Console.ReadLine();
} Perhaps the techniques shown in this CodeProject article would be helpful: [^] ?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Thanks Bill,
The project is a WinForms project and this is a code snippet from MSDN on how to do exactly what I want to do. But it never works.
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
|
|
|
|
|
This is the latest iteration that I tried which I found on the web.
using (var process = new Process())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "Codegen.exe";
process.StartInfo.Arguments = open.FileName + " 10 30";
process.Start();
//Thread.Sleep(100);
using (Task processWaiter = Task.Factory.StartNew(() => process.WaitForExit()))
using (Task<string> outputReader = Task.Factory.StartNew(() => process.StandardOutput.ReadToEnd()))
using (Task<string> errorReader = Task.Factory.StartNew(() => process.StandardError.ReadToEnd()))
{
Task.WaitAll(processWaiter, outputReader, errorReader);
standardOutput = outputReader.Result;
standardError = errorReader.Result;
}
|
|
|
|
|