|
At the moment I have the following classes :
Record ( which is the superclass )
- MessageHeaderRecord ( the superclass for the next classes ) :
- InfosRecord ( the class for the I tag
representing the informations from text )
- CommentRecord
- OrderRecord
- ResultsRecord
- TerminatorRecord
For each of this classes I have a corresponding class (MessageHeaderRecordFields ,...) in which I created the fields to put the infos from the file.
So far so good ...
MessageHeaderRecord beeing the superclass for the rest of classes I put inside of it a generic List :
private List m_Infos = new List()
internal List Infos
{
get
{
return m_Infos;
}
}
and the constructor is
internal MessageHeaderRecord()
{
RecordType = RecordType.MessageHeaderRecord;
m_Fields = new MessageHeaderRecordFields(); //
}
I did this because I want to access the objects as follows :
Message MyMessage = new Message();
MyMessage.Infos[3].Fields.SequenceNumber = "1";
MyMessage.Infos[3].Fields.InfoName.LastName = "John";
// Create a new info
int nInfoIndex = MyMessage.AddNewInformation(); (*1)
// Set the info specific data such as name, age, etc. for the info we just addded
MyMessage.Infos[nInfoIndex].Fields.InfoName.LastName = "John";
// Add an order record for this patient
int nOrderIndex = MyMessage.Infos[nInfoIndex].AddNewOrder(); (*2)
// Set the order specific information for the new order
MyMessage.Infos[nInfoIndex].Orders[nOrderIndex].Fields.OrderID = "11";
// Add a comment to this order
MyMessage.Infos[nInfoIndex].Orders[nOrderIndex].AddNewComment(); (*3)
// Set the text for the new comment
MyMessage.Infos[nInfoIndex].Orders [nOrderIndex].Commment.Fields.CommentText = "I am a comment.";
// Add a Result to this order
nResultIndex = MyMessage.Infos[nInfoIndex].Orders[nOrderIndex].AddNewResult();
// Set the new result's data
MyMessage.Infos[nPatientIndex].Orders[nOrderIndex].Results[nResultIndex].Fields.SequenceNumber = "333"; (*4)
So my problems redefined would be
(*1) - In which class to put the AddNewInformation() method
(*2) - In which class to put the Orders List and where to put the AddNewOrder() method
(*3) - In which class to put the Comment List and where to put the AddNewComment() method
(*4) - Same with Results List and AddNewResults() method
Please help me with this issues because I really cant figure them out.
Thank you in advance
|
|
|
|
|
Maybe I'm getting this wrong, but from what I understood, all the Add* methods are a bit reduntant if you don't do any special initialization inside them. For example in *1:
<br />
int nInfoIndex = MyMessage.AddNewInformation(); (*1)<br />
MyMessage.Infos[nInfoIndex].Fields.InfoName.LastName = "John";<br />
Could just be done like:
<br />
Info information = new Info (firstName, lastName, ...);<br />
MyMessage.Infos.Add (Info);<br />
While this doesn't retrieve the index so you can change afterwards, you can setup the class beforehand and then add it.
This can be used for all the other questions as far I understand.
If this wasn't what you were asking, then my apoligies.
Bruno Sousa
Software Consultant
http://www.luasys.com
|
|
|
|
|
Hey, simple question really.. i guess it could be done either way but i'm just wondering what the BEST way to do this is.
Basically the problem is very simple. all i want to do is pass a string from one application to another... just one direction. I'm wondering what the quickest and best way to go about this is. Should i just open up a TCP connection using windows sockets and pass it that way or should i try using remoting?
I'm sure the solution is simple but i don't want to do anything overkill just to pass a string
Thanks!
|
|
|
|
|
Socket. Anything else would be overkill in your case.
Best,
Jun
|
|
|
|
|
a web service would take about 3 minutes to create and publish
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
I have a Blob field in a table in oracle database. Some times i need
to put null values into this field
This is what iam doing in my C# Code
byte[] blobTest = new byte[0];
string insert = "INSERT INTO exampel VALUES(:test)";
OracleParameter test = new OracleParameter();
test.OracleType = OracleType.Blob;
test.ParameterName = "test";
test.Value = blobTest;
con.Open();
cmd = new OracleCommand(insert, con);
cmd.Parameters.Add(test);
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
Its throwing up an error ORA-01459 invalid length for variable
if i change
byte[] blobTest = new byte[1]; in the above code its working.
Basically how do i pass in a null value for a blob field in oracle database.
Thanks
kal
|
|
|
|
|
Could you please replace these lines below
<br />
test.OracleType = OracleType.Blob;<br />
test.ParameterName = "test";<br />
test.Value = blobTest;<br />
with these lines
<br />
test.OracleType = OracleType.Blob;<br />
test.IsNullable = true;<br />
test.ParameterName = "test";<br />
test.Value = null;<br />
i haven't done anything in oracle yet but it sounds related to your problem ;D
and instead of setting the value to a bytearray consisting of one byte,
you should try to put a c# null value on it because the developers probably
implemented a c# null to oracle null conversion ;D
|
|
|
|
|
Hi, I develop an ERP from my company and now I've got a strange error:
"Assembly.createInstance contructor not found"
the error occurs in the code below:
<br />
Assembly asmForm;<br />
asmForm = Assembly.LoadFrom(MyLib.dll);
<br />
myOther Other = new myOther();<br />
<br />
Other.Name = "Walter";<br />
<br />
Form obj; <br />
obj = (Form)asmForm.CreateInstance("cForms.frmClass",<br />
true,<br />
BindingFlags.Public | BindingFlags.CreateInstance,<br />
null,<br />
new object[] { (Other) },<br />
System.Globalization.CultureInfo.CurrentCulture,<br />
null);<br />
<br />
((Form)obj).Show();<br />
Form will be load Dynamic
<br />
namespace cForms<br />
{<br />
public partial class frmClass : Form <br />
{<br />
<br />
public frmLista(myOther Other)<br />
{<br />
} <br />
Other Class
<br />
namespace cForms<br />
{<br />
public class myOther<br />
{<br />
public string Name;<br />
}<br />
}<br /> e;
}
}
-- modified at 14:09 Wednesday 30th August, 2006 e;
}
}
|
|
|
|
|
Hello,
I think you just have to add a default constructor to your class.
Walter O Dias wrote: I've got a strange error:
"Assembly.createInstance contructor not found"
Hope that means "constructor".
If yes, you just add.
namespace cForms<br />
{<br />
public partial class frmClass : Form <br />
{<br />
<br />
public frmClass()<br />
{<br />
}<br />
<br />
public frmLista(myOther Other)<br />
{<br />
}
Hope thats it!
All the best,
Martin
|
|
|
|
|
I put but, same error occurs.
Now I try to use Generics (Activator.CreateInstance<>) work fine, but i not have the implementation with parameters!
|
|
|
|
|
Hey,
I have a hashtable containing 100 images. When I try to serialize this down a network stream I get a 'Internal GDI+ error". The code looks something like this:
<br />
BinaryFormatter bf = new BinaryFormatter();<br />
bf.serialize(_Stream,_Images);<br />
Any ideas?
Many Thanks
Tom
|
|
|
|
|
Hi ALl,
I have developed a control library, and am running into some problems with serialization. When trying to serialize one of my controls, the serializer complains when it runs into something like the following:
[Serializable]
public class Control
{
public ContextMenu {get{...} set{...}}
}
So, the ContextMenu class is not serializable. If I try something like this:
[Serializable]
public class Control
{
[NonSerialized]
public ContextMenu {get{...} set{...}}
}
I will get another error that the NonSerialized attribute is only for fields or something. Apparently this only works for simple types, ie int's, strings? Is there another attribute to tell it to ignore a certain property when serializing?
Thanks in advance
|
|
|
|
|
Hi all,
First of all, please look at the following image:
http://img171.imageshack.us/img171/6038/graphne9.jpg[^]
I'm currently working on a reporting system for our web stats system.
Code:
Pen Black = new Pen(Brushes.Black, 1);<br />
Pen Gray = new Pen(Brushes.LightGray, 1);<br />
Bitmap b = new Bitmap(parentWidth,parentHeight);<br />
Graphics g = Graphics.FromImage(b);<br />
<br />
g = GenerateBG(g, parentWidth, parentHeight);
<br />
int width = parentWidth - 50;
int height = parentHeight - 50;
<br />
int spacer_width = width/7;
int spacer_height = 0;<br />
<br />
int maxCount = 0;<br />
<br />
ArrayList Data = new ArrayList();<br />
<br />
<br />
<br />
for(int i = -6; i < 1; i++)<br />
{<br />
DateTime date = DateTime.Now.AddDays(i);<br />
string toWrite = date.Day.ToString() + "/" + date.Month.ToString();<br />
g.DrawString(toWrite, new Font("Verdana", 7), Brushes.Black, ((i+7)*spacer_width), parentHeight -20);<br />
object[] dateData = dal.getStatsForDate(date.Date);<br />
if(dateData.Length > maxCount)<br />
maxCount = dateData.Length;<br />
Data.Add(dateData);<br />
}<br />
<br />
spacer_height = (height/maxCount);
<br />
int tempHeight = parentHeight;
<br />
int modCheck = Isqrt(maxCount);
<br />
for(int i = 0; i < maxCount; i++)<br />
{<br />
if((i%modCheck)==0)
{<br />
g.DrawLine(Gray, 50, tempHeight-25, width+25, tempHeight-25);
g.DrawString(i.ToString(),new Font("Verdana", 7), Brushes.Black, 5, tempHeight-32);
}<br />
tempHeight = (tempHeight-spacer_height);
}<br />
<br />
g.DrawLine(Black, 50, 25, 50, parentHeight-25);
g.DrawLine(Black, 50, parentHeight - 25, parentWidth-25, parentHeight-25);
Now if you look at the image and the code, i've got something wrong and I can't figure where.
Basically, I have calculated the distance between each number/guide line by deviding the height by the maximum number which will be shown.
For some strange reason, it is not using the whole height of the grid.
Anyone have any idea why?
|
|
|
|
|
could you check the maxCount variable for its value? it seems like its value is too big.. like 2 times bigger than it should be...
On the other hand i don't know the value of ParentHeight so it could be possible that you're calculating with a wrong value all the time...
what exactly is that "dal" object you're using? What exactly does the getStatsForDate method and are you sure its outpu is correct?
|
|
|
|
|
maxCount will currently read 90.
parentHeight = 200
parentWidth = 700
dal is my data access layer, and getStatsForDate will take a date, and get all records in the database against this date.
maxCount will start off life as zero, and each time I loop through the dates, and retrieve the
data via getStatsForDate, I check the length to see how many rows were returned. If the amount of rows returned is more then the current value of maxCount, maxCount will change to the amount of rows.
Thanks for replying.
|
|
|
|
|
I think I may have sorted it.
rather then using the maxCount to calculate the space between lines etc, I have got the square root of the maxCount and devided that by the height.
Regardless of the maxCount value, it seems to be sticking in the correct place.
Thanks
|
|
|
|
|
Okay, i think i know the error now. You want the value 81 to be on the top of the graphic (almost y = 0??). if so, the problem is the height calculation.
add 2 variables
int dlHeight =
int dsHeight =
just replace this piece of code
<br />
spacer_height = (height/maxCount);
<br />
int tempHeight = parentHeight;
<br />
int modCheck = Isqrt(maxCount);
<br />
for(int i = 0; i < maxCount; i++)<br />
{<br />
if((i%modCheck)==0)
{<br />
g.DrawLine(Gray, 50, tempHeight-25, width+25, tempHeight-25);
g.DrawString(i.ToString(),new Font("Verdana", 7), Brushes.Black, 5, tempHeight-32);
}<br />
tempHeight = (tempHeight-spacer_height);
}<br />
with this one
<br />
int tempHeight = parentHeight;
<br />
int sqrtMaxCount = Isqrt(maxCount);<br />
int rowHeight = height / sqrtMaxCount;<br />
<br />
for(int i = 0; i < sqrtMaxCount; i++)<br />
{<br />
g.DrawLine(Gray, 50, tempHeight-rowHeight, width+25, tempHeight-rowHeight);<br />
g.DrawString(i.ToString(),new Font("Verdana", 7), Brushes.Black, 5, tempHeight-rowHeight-7); <br />
<br />
tempHeight -= rowHeight;
}<br />
in case you haven't found it out yourself yet
I hope i didnt miss anything - currently i'm too lazy to write it myself but if it doesn't work i'll give it a try
*edit* i forgot to change the condition for the for-loop... that would have turned out bad!
|
|
|
|
|
I have recently determined that it would be really convenient to add a button to the ControlBox in a 2.0 app. is there a way to add a button next to the minimize, maximize and close buttons up in the controlbox?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
I've never seen something like this (except for this "minimize to tray" button) and guess its not possible via managed code. You probable have to use the windows api to do it (if it's even possible).
|
|
|
|
|
Hi All,
I can allocate 400 Mb of memory in 2 steps:
int[] values1 = new int[1024*1024*200];
int[] values2 = new int[1024*1024*200];
However I can not allocate this amount of memory in one step:
int[] values1 = new int[1024*1024*400];
This is because of OutOfMemoryException.
I also mention that I can easily allocate 800 Mb of memory in my C++ application.
What could be wrong in .NET memory allocation?
Thanks,
Pawel
|
|
|
|
|
i'm not sure if i am right but:
an int32 wont hold more than about 4.000.000.000 (somewhere "near" that)
1024*1024*200 will result more than 20.000.000.000 so you should try to use
1. unsigned variables
2. bigger variables
the last time i had to use 64-bit variables, they were no operators for multiplications and division available so you will have to "work around".
|
|
|
|
|
mikone wrote: 1024*1024*200 will result more than 20.000.000.000
;P
|
|
|
|
|
uhh yeah, excuse me. i was at work so my brain was kinda turned off
so yeah, that definitely would fit an 32-bit integer (200.000.000)
next time i should use a calculator just to make sure such an emberassing thing doesn't happen again (but as i already said: i was at work, you can't blame me )
|
|
|
|
|
I put the wrong code in the post. This is what I was thinking about:
it works:
int[] values1 = new int[1024*1024*50]
int[] values2 = new int[1024*1024*50]
it gives OutOfMemoryException:
int[] values1 = new int[1024*1024*100]
There is enough free memory to allocate even 1Gb, but the problem for .NET is that there is no continous area of the memory which size is 400Mb. This is why I can allocate two times 200Mb but I can not allocate 400 Mb once. The question is: Can it be avoided somehow?
pawelpus
|
|
|
|
|
there is another answer to this question already - i will sum it up:
you're creating an array of integers whichs elements are 4 byte big. thats why you should change it to
<br />
byte[] values = new byte[1024*1024*100];<br />
|
|
|
|