|
no PRE tags ==> no help
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I've had success having an individual (one at a time) to perform reading serial number from the file and increment by one and save the new number in this .log file.
However is that I'm trying to determine the best approach for each process to wait for the file access while one of the process is using the file. Once the file is ready for read/write, then the other process can use the file.
Sample code for each process (pretty much the same for the 4 processes:
--------
private void RunProcess1()
{
while (fileHandle != IntPtr.Zero)
{
lblStatus1.BackColor = Color.Yellow;
lblStatus1.Text = "Awaiting Accessing Serial file...";
Application.DoEvents();
for (int m = 0; m < 100000; m++)
Application.DoEvents();
}
//do
//{
try
{
lblStatus1.BackColor = Color.Magenta;
lblStatus1.Text = "Accessing Serial file";
Application.DoEvents();
FileStream filestream = new FileStream("serial.log", FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
fileHandle = filestream.Handle;
StreamReader tr = new StreamReader(filestream);
count = Convert.ToInt32(tr.ReadLine(), 10);
lblSerial1.Text = count.ToString();
tr.Close();
lblStatus1.BackColor = Color.Lime;
lblStatus1.Text = "Saving Serial file";
Application.DoEvents();
filestream = new FileStream("serial.log", FileMode.Create, FileAccess.Write, FileShare.None);
StreamWriter sw = new StreamWriter(filestream);
sw.Write(++count);
sw.Flush();
lblStatus1.BackColor = Color.Green;
for (int m = 0; m < 1000000; m++)
Application.DoEvents();
sw.Close();
lblStatus1.BackColor = defaultBackground;
lblStatus1.Text = "Success!";
Application.DoEvents();
//timer1.Start();
fileHandle = IntPtr.Zero;
}
catch (Exception err)
{
//timer1.Stop();
//proc1Success = false;
}
//} while (proc1Success == false);
}
|
|
|
|
|
I did not get into your code as I think you have a design problem, 2 issues.
Why are you logging to a text file and wanting database functionality. Why not use a database as a log destination.
Why are you waiting for the file to be released. Stick a queue in front of the write and have your methods load the queue (this is only required b/c you are using a text file).
|
|
|
|
|
Hi,
While adding the project output to the setup project, I got the following message.
"The following files may have dependencies that cannot be determined automatically. Please confirm that all dependencies have been added to the project
c:\program files\ultra office control\officectrl.ocx"
Please guide me to solve this issue.
Thanks in advance..
|
|
|
|
|
It says that this setup deployment creation cannot confirm that file: officectrl.ocx doesn't have other dependancy. I suggest contact them or ignore this message and try install in clean os or In virtual machine such as VirtualBox
|
|
|
|
|
I ignored the message and installed the setup in my system itself. It opened the exe but unable to perform the operation, which uses Officectrl.ocx.
|
|
|
|
|
Did you registerd ocx by using RegSvr32.exe?
Try installing the controler on test server. If you bought it, try looking into their documentation or email them
|
|
|
|
|
Hi,
In windows form application I added one button "Draw Shape" and four radio button "Line, Circle, Rectangle, Triangle"
I have an abstract class Shape i inherited that Abstract class and created four class
Line, Circle, Rectangle, Triangle
On clicking the button "Draw shape" i need to draw the selected shape on the page.
Eg: In the case of circle i have function Draw()
From the main form i am calling Draw() function of the Circle class
In the Draw() function i am Drawing the circle
override public void Draw()
{
Graphics mg = CreateGraphics();
mg.DrawArc(new Pen(COLOR, THICKNESS), 100, 100, 45, 40, 0, 360);
}
I tryed like this.. But getting error How can i resolve this issue?
How can i paint the Form class from my class Circle?
Please Help me.
Regards,
Ratheesh.
|
|
|
|
|
ratheeshnair123 wrote: getting error
That is zero information. Be specific if you want specific help.
ratheeshnair123 wrote: Graphics mg = CreateGraphics();
Unless you are doing highly advanced stuff, this is bound to be wrong, unnecessary and a big waste.
Here is one of my standard texts, I suggest you read it carefully:
there are several steps to correctly draw something; it does not matter how complex the paint job is: from a single line, to a complex drawing, or a real work of art.
To make sure it all becomes visible on the screen and gets repainted automatically when moving, resizing, minimizing/maximizing/restoring or uncovering your Form, one should follow these steps:
1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a Form itself. I prefer to add a Panel to a Form, then draw on the Panel. And I do not like PictureBoxes, they are pretty useless.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of your drawing. For a rectangle that could be top and left coordinate, and width+height, or just a Rectangle. etc. For a complex drawing, it could be a List of objects that derive of a common type, each having its own PaintMe() method.
3.
create a Paint handler (either add your own paint handler to the Paint event, or override the OnPaint method) for that Panel, and do all your drawing in there, using the Graphics object inside the PaintEventArgs, and your variables. Do not call CreateGraphics!
4.
if and when you want to change things, modify the variables and call Panel.Invalidate() or one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler of a Windows.Forms.Timer which ticks on the GUI thread, so you are allowed to call Invalidate() from there too.
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
C# example:
private Panel panel;
private bool paintRectFlag=true;
private Rectangle rect=new Rectangle(20, 20, 300, 200);
private Pen rectPen=Pens.Black;
public Form1() {
InitializeComponents();
panel=new Panel();
panel.Bounds=new Rectangle(…);
panel.Paint+=panelPaintHandler;
Controls.Add(panel);
}
protected void panelPaintHandler(object sender, PaintEventArgs e) {
Graphics g=e.Graphics;
if (paintRectFlag) g.DrawRectangle(rectPen, rect);
}
protected void buttonClickHandler(object sender, EventArgs e) {
paintRectFlag=!paintRectFlag;
panel.Invalidate();
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
if i have this code:
interface AInterface
{
double GetNum{ get;}
}
public class A:AInterface
{
int x;
virtual public double GetNum{
get
{
return x*10;
}
}
}
public class B:A ,AInterface
{
int y;
override public double GetNum{
get
{
return y*base.GetNum;
}
}
The problem is that if i will write this code:
B b = new B();
b.x =2;
b.y=5;
print ( B.GetNum.ToString);
I Have a problem when B call base.GetNum because it calling to him self.
What can i do to solve this problem?
Thanks for all of your help.
|
|
|
|
|
Remove AInterface from class B? It already inherits AInterface anyway
|
|
|
|
|
If you were to fix a dozen or so syntax errors and to run the code, you would get 100, as it should be.
The type of b is B, and the base of B is A.
BTW: don't use verbs in property names, they don't belong; they do in method names, not in property names.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hello All ,
i have doubt new operator will create an object on heap .
So when i declare int as int x = new int();
will these be stored in Heap or stack ? Since value type are stored on stack but at same time new wil store it on heap ?
So got confused . Please do clarify it.
|
|
|
|
|
Hi,
MSDN says "The new operator is also used to invoke the default constructor for value types."
Inside a method:
int x; allocates an int on stack and does not initialize it.
int x=5; allocates an int on stack and sets it to 5;
int x=new int(); allocates an int on stack and sets it to 0;
and int x=new int(5); does not compile.
new allocates on a heap for reference types only.
It suffices to read a book, to read MSDN, or to search (google) for such information.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
In reality it does not matter. The beauty of C# is that the compiler/CLR does so much of the work for you that you need not generally be concerned where the actual objects are stored.
|
|
|
|
|
Items on the stack vanish when the method exits, at no cost. Objects on a heap need time and cycles to get collected, so it may be relevant.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks I had not considered the finer implications of the question.
|
|
|
|
|
Hi dear friends,
from last few days i am digging my head like anything for loading rss feed(its nothing but a xml file) in to mozilla browser.
i am succesfully load that and displayed in IE but unable to load it in mozzlia.here the link for rss feed is-"
http://www.ed.gov/rss/edgov.xml[^]
plz help me out.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml" ><br />
<head><br />
<title>Untitled Page</title><br />
<script type="text/javascript"><br />
if(navigator.appName == "Netscape")<br />
{<br />
alert("You're using a Netscape browser.")<br />
function loadXML()<br />
{<br />
<br />
var xmlDoc = document.implementation.createDocument("", "", null) <br />
xmlDoc.load("http://www.ed.gov/rss/edgov.xml");<br />
xmlDoc.onload = readXML;<br />
<br />
alert("hi")<br />
document.getElementById("title").innerHTML= xmlDoc.getElementsByTagName("title")[2].firstChild.nodeValue<br />
document.getElementById("description").innerHTML= xmlDoc.getElementsByTagName("description")[2].firstChild.nodeValue<br />
<br />
document.getElementById("title1").innerHTML= xmlDoc.getElementsByTagName("title")[3].firstChild.nodeValue<br />
document.getElementById("description1").innerHTML= xmlDoc.getElementsByTagName("description")[3].firstChild.nodeValue<br />
<br />
document.getElementById("title2").innerHTML= xmlDoc.getElementsByTagName("title")[4].firstChild.nodeValue<br />
document.getElementById("description2").innerHTML= xmlDoc.getElementsByTagName("description")[4].firstChild.nodeValue<br />
<br />
document.getElementById("title3").innerHTML= xmlDoc.getElementsByTagName("title")[4].firstChild.nodeValue<br />
document.getElementById("description3").innerHTML= xmlDoc.getElementsByTagName("description")[4].firstChild.nodeValue<br />
<br />
document.getElementById("title4").innerHTML= xmlDoc.getElementsByTagName("title")[5].firstChild.nodeValue<br />
document.getElementById("description4").innerHTML= xmlDoc.getElementsByTagName("description")[5].firstChild.nodeValue<br />
<br />
document.getElementById("title5").innerHTML= xmlDoc.getElementsByTagName("title")[6].firstChild.nodeValue<br />
document.getElementById("description5").innerHTML= xmlDoc.getElementsByTagName("description")[6].firstChild.nodeValue<br />
<br />
<br />
}<br />
<br />
<br />
<br />
<br />
}<br />
if(navigator.appName == "Microsoft Internet Explorer")<br />
{<br />
var xmlDoc<br />
function loadXML()<br />
{<br />
if (window.ActiveXObject)<br />
{<br />
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");<br />
xmlDoc.async=false;<br />
xmlDoc.load("http://www.ed.gov/rss/edgov.xml");<br />
xmlObj=xmlDoc.documentElement; <br />
<br />
if (xmlDoc.readyState != 4) <br />
{ <br />
return false; <br />
} <br />
<br />
document.getElementById("title").innerHTML= xmlDoc.getElementsByTagName("title")[2].firstChild.nodeValue<br />
document.getElementById("description").innerHTML= xmlDoc.getElementsByTagName("description")[2].firstChild.nodeValue<br />
<br />
document.getElementById("title1").innerHTML= xmlDoc.getElementsByTagName("title")[3].firstChild.nodeValue<br />
document.getElementById("description1").innerHTML= xmlDoc.getElementsByTagName("description")[3].firstChild.nodeValue<br />
<br />
document.getElementById("title2").innerHTML= xmlDoc.getElementsByTagName("title")[4].firstChild.nodeValue<br />
document.getElementById("description2").innerHTML= xmlDoc.getElementsByTagName("description")[4].firstChild.nodeValue<br />
<br />
document.getElementById("title3").innerHTML= xmlDoc.getElementsByTagName("title")[4].firstChild.nodeValue<br />
document.getElementById("description3").innerHTML= xmlDoc.getElementsByTagName("description")[4].firstChild.nodeValue<br />
<br />
document.getElementById("title4").innerHTML= xmlDoc.getElementsByTagName("title")[5].firstChild.nodeValue<br />
document.getElementById("description4").innerHTML= xmlDoc.getElementsByTagName("description")[5].firstChild.nodeValue<br />
<br />
document.getElementById("title5").innerHTML= xmlDoc.getElementsByTagName("title")[6].firstChild.nodeValue<br />
document.getElementById("description5").innerHTML= xmlDoc.getElementsByTagName("description")[6].firstChild.nodeValue<br />
<br />
}<br />
}<br />
<br />
<br />
}<br />
</script><br />
</head><br />
<body onload="loadXML()"><br />
<table width="100%" ><br />
<tr><br />
<td ><br />
<marquee onmouseover="if(this.stop)this.stop()" onmouseout="if(this.start)this.start()"><br />
<label id="title"> </label> - <label id="description"></label>;<br />
<label id="title1"></label> - <label id="description1"></label>; <br />
<label id="title2"></label> - <label id="description2"></label>; <br />
<label id="title3"></label> - <label id="description3"></label>;<br />
<label id="title4"></label> - <label id="description4"></label>;<br />
<label id="title5"></label> - <label id="description5"></label>;<br />
</marquee><br />
</td><br />
</tr><br />
</table><br />
</body><br />
</html><br />
|
|
|
|
|
Try a web forum - clickity[^] - if you want a reply.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I have used emgu cv to create a face detection program and i followed the code according to this website
http://friism.com/webcam-face-detection-in-c-using-emgu-cv
what i would like to know is there any codes that can count the number of faces in the picture or the number of rectangles that appear during face detection so that i will be able to know the number of people present in the picture
|
|
|
|
|
You stand a better chance of a valid reply on the emgu cv site here[^].
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Hi All,
I have table, named tblTasks, with columns Id, Name, StartDate, EndDate etc. I want to convert this table in to xml fromat via nHibernate.
<Task>
<Id> </Id>
<Name> </Name>
<StartDate> </StartDate>
<EndDate> </EndDate>
</Task>
I am using NHibernate dll version 2.1.0.
Pls help me.
Thanks in advance
|
|
|
|
|
NHibernate has its own forums, you could try asking here[^].
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi all,
I've been given source code for a program that created a form post from values within an excel document, however I keep getting the following errors:
Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)'
I've had a root through the MSDN site, and cant seem to work out whats wrong:
private void btnBatchExecute_Click(object sender, System.EventArgs e)
{
Excel.Application xlApp;
Excel.Workbook xlWorkbook;
Excel.Worksheet xlWorkSheet;
Excel.Range xlRange;
string method;
string postString;
string[] values;
string returnString;
XmlDocument xDoc = new XmlDocument();
try
{
xlApp = new Excel.ApplicationClass();
xlApp.Visible = true;
string thisFileName = txtFileName.Text;
xlWorkbook = xlApp.Workbooks.Open(thisFileName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
xlWorkSheet = (Excel.Worksheet)xlWorkbook.ActiveSheet;
for(int i = 5;;i++)
{
xlRange = xlWorkSheet.get_Range(xlWorkSheet.Cells[i,2],xlWorkSheet.Cells[i,52]);
values = ConvertToStringArray((System.Array)xlRange.Cells.Value);
if(values[0]=="") break;
postString = "ESERIES_FORM_ID=AUTHENTICATE_3&CTRL_TYPEINDICATOR=C&CTRL_SEARCHCONSENT=Y&CTRL_CHANNEL=I&CTRL_CALLTYPE=I";
postString+="&NAME_TITLE="+values[0];
postString+="&NAME_FORENAME="+values[1];
postString+="&NAME_INITIALS="+values[2];
postString+="&NAME_SURNAME="+values[3];
postString+="&NAME_SUFFIX="+values[4];
postString+="&NAME_DATEOFBIRTH_DD="+("0"+values[5]).Substring(("0"+values[5]).Length-2);
postString+="&NAME_DATEOFBIRTH_MM="+("0"+values[6]).Substring(("0"+values[6]).Length-2);
postString+="&NAME_DATEOFBIRTH_CCYY="+values[7];
if(values[8]!="")
{
postString+="&NAME_TITLE="+values[8];
postString+="&NAME_FORENAME="+values[9];
postString+="&NAME_INITIALS="+values[10];
postString+="&NAME_SURNAME="+values[11];
postString+="&NAME_SUFFIX="+values[12];
postString+="&NAME_DATEOFBIRTH_DD="+("0"+values[5]).Substring(("0"+values[5]).Length-2);
postString+="&NAME_DATEOFBIRTH_MM="+("0"+values[6]).Substring(("0"+values[6]).Length-2);
postString+="&NAME_DATEOFBIRTH_CCYY="+values[7];
}
postString+="&ADDR_FLAT="+values[15];
postString+="&ADDR_HOUSENAME="+values[14];
postString+="&ADDR_HOUSENUMBER="+values[13];
postString+="&ADDR_STREET="+values[16];
postString+="&ADDR_DISTRICT="+values[17];
postString+="&ADDR_TOWN="+values[18];
postString+="&ADDR_COUNTY="+values[19];
postString+="&ADDR_POSTCODE="+values[20];
postString+="&RESY_DATEFROM_CCYY="+values[28];
postString+="&RESY_DATEFROM_MM="+("0"+values[27]).Substring(("0"+values[27]).Length-2);
postString+="&RESY_DATEFROM_DD="+("0"+values[26]).Substring(("0"+values[26]).Length-2);
postString+="&RESY_DATETO_CCYY="+values[31];
postString+="&RESY_DATETO_MM="+("0"+values[30]).Substring(("0"+values[30]).Length-2);
postString+="&RESY_DATETO_DD="+("0"+values[29]).Substring(("0"+values[29]).Length-2);
postString+="&RESY_DATEFROM_CCYY="+values[28];
postString+="&RESY_DATEFROM_MM="+("0"+values[27]).Substring(("0"+values[27]).Length-2);
postString+="&RESY_DATEFROM_DD="+("0"+values[26]).Substring(("0"+values[26]).Length-2);
postString+="&RESY_DATETO_CCYY="+values[31];
postString+="&RESY_DATETO_MM="+("0"+values[30]).Substring(("0"+values[30]).Length-2);
postString+="&RESY_DATETO_DD="+("0"+values[29]).Substring(("0"+values[29]).Length-2);
if(values[39]!="")
{
postString+="&ADDR_FLAT="+values[34];
postString+="&ADDR_HOUSENAME="+values[33];
postString+="&ADDR_HOUSENUMBER="+values[32];
postString+="&ADDR_STREET="+values[35];
postString+="&ADDR_DISTRICT="+values[36];
postString+="&ADDR_TOWN="+values[37];
postString+="&ADDR_COUNTY="+values[38];
postString+="&ADDR_POSTCODE="+values[39];
postString+="&RESY_DATEFROM_CCYY="+values[47];
postString+="&RESY_DATEFROM_MM="+("0"+values[46]).Substring(("0"+values[46]).Length-2);
postString+="&RESY_DATEFROM_DD="+("0"+values[45]).Substring(("0"+values[45]).Length-2);
postString+="&RESY_DATETO_CCYY="+values[50];
postString+="&RESY_DATETO_MM="+("0"+values[49]).Substring(("0"+values[49]).Length-2);
postString+="&RESY_DATETO_DD="+("0"+values[48]).Substring(("0"+values[48]).Length-2);
postString+="&RESY_DATEFROM_CCYY="+values[47];
postString+="&RESY_DATEFROM_MM="+("0"+values[46]).Substring(("0"+values[46]).Length-2);
postString+="&RESY_DATEFROM_DD="+("0"+values[45]).Substring(("0"+values[45]).Length-2);
postString+="&RESY_DATETO_CCYY="+values[50];
postString+="&RESY_DATETO_MM="+("0"+values[49]).Substring(("0"+values[49]).Length-2);
postString+="&RESY_DATETO_DD="+("0"+values[48]).Substring(("0"+values[48]).Length-2);
}
txtReturn.Lines = values;
if (rdoPost.Checked == true)
method = "POST";
else
method = "GET";
returnString = webRequest(txtAddress.Text, method, "HTML", postString);
txtReturn.Text = returnString;
txtReturn.Refresh();
returnString = Regex.Replace(returnString,@"&[^(amp;)]","&");
xDoc.LoadXml(returnString);
if(xDoc.SelectNodes("//ERR1").Count>0)
{
xlRange = xlWorkSheet.get_Range(xlWorkSheet.Cells[i,68],xlWorkSheet.Cells[i,68]);
xlRange.Value="Error! - " + xDoc.SelectSingleNode("//ERR1").InnerText;
}
else
{
int cellPos;
if("CHAM"==xDoc.SelectSingleNode("//AU3E/TEST_GROUP").InnerText)
{
cellPos=54;
}
else
{
cellPos=61;
}
xlRange = xlWorkSheet.get_Range(xlWorkSheet.Cells[i,cellPos],xlWorkSheet.Cells[i,cellPos++]);
xlRange.Value=xDoc.SelectSingleNode("//AU3E/AUTH_INDEX").InnerText;
xlRange = xlWorkSheet.get_Range(xlWorkSheet.Cells[i,cellPos],xlWorkSheet.Cells[i,cellPos++]);
xlRange.Value=xDoc.SelectSingleNode("//AU3E/PST_OUTCOME").InnerText;
if("0"==xDoc.SelectSingleNode("//AU3E/POLICY_RULE_COUNT").InnerText)
{
xlRange = xlWorkSheet.get_Range(xlWorkSheet.Cells[i,cellPos],xlWorkSheet.Cells[i,cellPos++]);
xlRange.Value="No Rules Hit!";
}
else
{
int counter=1;
foreach(XmlNode node in xDoc.SelectNodes("//AU3E/POLICYRULES/POLICY_RULE"))
{
xlRange = xlWorkSheet.get_Range(xlWorkSheet.Cells[i,cellPos],xlWorkSheet.Cells[i,cellPos++]);
xlRange.Value=node.InnerText;
if(counter++>5)break;
}
}
}
}
xlApp.Quit();
}
catch( Exception ex )
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat( errorMessage, ex.Message );
errorMessage = String.Concat( errorMessage, " Line: " );
errorMessage = String.Concat( errorMessage, ex.Source );
MessageBox.Show( errorMessage, "Error" );
}
}
Any Ideas?
|
|
|
|
|