Welcome

I'm a student and this blogg has been created to keep information on a daily to weekly basis about my project that i am doing to get my Bachelor of Information Technology. This is based on my progress, and a place to put all of my information, not entirely a proper blogg. Though sometimes i feel like i'll be talking to myself... Any ways, enjoy and feel free to comment. If your wondering what this project is and dont want to read every single post, just go to the Proposal link, or any of the "posts worth looking at" below.

Tuesday, May 20, 2008

20/5 Passing Lists & Interface

_________________________________________________________
Start 9.00 a.m.
_________________________________________________________


ahhhh so early. Just carrying on with same stuff as yesterday.

I got the passing of the arrays back working :D thanks to an awesome cheeky mohnkey. I asked what he normally does as i had read alot of people just apss back a dataset, and he said to pass back an array of the class, and just .ToArray the list.

[WebMethod]
public clsClientAddress[] getClientAddressList()
{
dbConnection lcConnection = new dbConnection();
lcConnection.getClientAddressList();
List lcClientAddressList = Global.clientAddressList;
return lcClientAddressList.ToArray();
}


So by passing the list converted to an array we can then grab it by assigning the result to an array of objects. What i was doing wrong from lack of knowledge was getting the data type of the array i was assigning it to wrong. After a bit of playing around i guess this and it worked so huray.

protected void btnGo_Click(object sender, EventArgs e)
{
serviceMain.serviceMain myService = new serviceMain.serviceMain();
object[] lcArray = myService.getClientList();
}


What my goal now is, to get the arrays back and pass the values into the dictionarys of the client. Once i have done this i can fill my data grids with data and work on the editing and deleting.

************************************************************************
Break 11.15 a.m. - 11.45 a.m.
************************************************************************

_________________________________________________________
Class 2.00 p.m. - 6 p.m. - going to study for project management and go to class.
_________________________________________________________


Having break in class... what better time to blogg. Today i had an issue with everytime i grabbed the list it would get bigger and bigger. Now in the application start on the service under the global class it makes a new list, SO theoretically everytime it starts it should create a new list? Well it was re-adding items from the database to the list and making the list large with duplicates, I found this out by stepping through and seeing that the list wasnt clearing. I'm not exactly sure how the application start works, so i thought i'd be safe and clear the lists before filling them again.

dbConnection lcConnection = new dbConnection();
Global.clientAddressList.Clear();
lcConnection.getClientAddressList();
List lcClientAddressList = Global.clientAddressList;
return lcClientAddressList.ToArray();

So that will do for now, in future the logic and process of how this works will change, as is it will all be called differently, but was probly a problem i was going to face either way.

************************************************************************
Break 6.00 p.m. 10.30 p.m.
************************************************************************


Having a problem now with using the array that i get back from service what i'm trying to do:

Dictionary lcClientList = Global.clientList; object[] lcArray; lcArray = myService.getClientList();
int length = lcArray.Length;
for (int i = 0; i <>
{
clsClient lcClient = (clsClient)lcArray[i];
string lcClientID = lcClient.propertyClientID;
lcClientList.Add(lcClientID, lcClient);
}
I'm tryign to assign the array object to a clsClient, but i think its some how more difficult than just doing this. Below is a picture of the error i'm getting and also shows the object i get back. This is really noob but after spending ages trying to firgure out how, i dont know if/how i can just grab out the field of that array item, probly simple, but hey it eludes me. If i can just grab the data from this object then i dont have to worry about all this converting crap and can just using the fields. SIGH.

_________________________________________________________
Finish 12.15 p.m. 7 hours
_________________________________________________________

Will figure it out tomorow... if i dont soon i am screwed ^^. Perhaps below answers my question. http://www.themssforum.com/Csharp/property-array/. Either way i have to figure out how to get to fields, or fix the error i have... which is the lesser of the two evils... I shall sleep on it.

No comments: