Alternatives?

:D:D

so rather :
Code:
                foreach (AfricaStuff item in africaStuff )
                {
                    dataContext.AfricaStuff.InsertOnSubmit(item);
                }
                dataContext.SubmitChanges();

Probably a good idea to add a counter to that loop and when it hits a certain value you do the submit. E.g:

Code:
var bulksize = 1000;
var count = 0;
for(var x in list)
{
     doInsertThingy();
     count++;
     if(count % bulksize == 0)
         doSumbitThingy()
}

doSubmitThingyAgain()

...or something like that.
 
So I'm joining this late, skimmed over most of it.

As suggested, add logging on every line and see where it bombs?

Are you sure those services are returning data to save?

If the app just bombs - check the windows event log. Should be an error there. If this is the case, my money is on NullRefException :twisted:
 
As suggested, add logging on every line and see where it bombs?

Are you sure those services are returning data to save?

Logging was added to the retrieval.
Stops when it gets too
"Start Saving Data" :D

No error at all. This is QA and Prod (50% of the time).
Dev doesn't get the Africa Stuff at all.

As for config and usernames. Usernames and config strings are put in the WebConfig of the service. Each service is on a different port on the same box.

hmm.. think I might need to move to another server :)
 
Logging was added to the retrieval.
Stops when it gets too
"Start Saving Data" :D

No error at all. This is QA and Prod (50% of the time).
Dev doesn't get the Africa Stuff at all.

As for config and usernames. Usernames and config strings are put in the WebConfig of the service. Each service is on a different port on the same box.

hmm.. think I might need to move to another server :)
And where exactly is "Start Saving Data" in the code? Did I miss it?
 
Removed it but it's where the SubmitChanges() method begins in the service

Can you maybe change SubmitChanges to SaveChanges which returns and int (number of rows) you can check. Maybe it will throw you exception you are looking for.

Other than that, what happens when you debug? Does it just stop the app without any error at all? Are you VERY sure there are no errors logged in the event log?
 
Can you maybe change SubmitChanges to SaveChanges which returns and int (number of rows) you can check. Maybe it will throw you exception you are looking for.

Other than that, what happens when you debug? Does it just stop the app without any error at all? Are you VERY sure there are no errors logged in the event log?

Guess we gonna need to rewrite it in go:P
 
Still working through this.
Can't attach to the w3 process to debug properly on a POC box.
Code working sporatically but never when it actually needs to run.

Code :

Code:
public void SaveStuffs(List<AfricaStuff> africastuff)
        {
            try
            {
                WriteLog(string.Format("Count of stuff: {0}", africastuff.Count.ToString()));
                WriteLog("Starting save");
                AfricaStuffDataContext dataContext = new AfricaStuffDataContext (ConnectionString);

                foreach (AfricaStuff item in africastuff)
                {
                    dataContext.AfricaStufft.InsertOnSubmit(item);
                }
                dataContext.SubmitChanges();
                WriteLog("Successfully Saved");
            }
            catch (Exception ex)
            {
                WriteLog(ex.Message);
            }
        }

Log file :
Code:
Count of stuff: 695
Starting save
Successfully Saved
 
Last edited:
Still working through this.
Can't attach to the w3 process to debug properly on a POC box.
Code working sporatically but never when it actually needs to run.

Code :

Code:
public void SaveStuffs(List<AfricaStuff> africastuff)
        {
            try
            {
                WriteLog(string.Format("Count of stuff: {0}", africastuff.Count.ToString()));
                WriteLog("Starting save");
                AfricaStuffDataContext dataContext = new AfricaStuffDataContext (ConnectionString);

                foreach (AfricaStuff item in africastuff)
                {
                    dataContext.AfricaStufft.InsertOnSubmit(item);
                }
                dataContext.SubmitChanges();
                WriteLog("Successfully Saved");
            }
            catch (Exception ex)
            {
                WriteLog(ex.Message);
            }
        }

Log file :
Code:
Count of stuff: 695
Starting save
Successfully Saved

Have you done what Hamster said? Where do you sit Hamster and I will come fix your code :P
 
:D:D Will PM you the location :p
No errors when debugging. Windows Event Log is empty as well.

Code:
int rows = dataContext.[B]SaveChanges[/B]()
WriteLog("Yes, I saved this many items: " + rows );
 
To me, it seems that the parameter you passing in could be dodgy. You need to put more logging into this app also.

From your code you posted in the main method, where is the part that de-serializes the data?
Code:
static void Main(string[] args)
        {
            ChannelFactory<IAfricaStuff> channelFactory;
            IAfricaStuff client;

            try
            {

                //create the binding
                var binding = new WSHttpBinding();
                //configure the binding
                binding.Security.Mode = SecurityMode.Message;
                binding.MaxReceivedMessageSize = 2147483647;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.SendTimeout = new TimeSpan(0, 10, 0);
                binding.CloseTimeout = new TimeSpan(0, 10, 0);
                binding.OpenTimeout = new TimeSpan(0, 10, 0);
                binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                var endpointAddress = new EndpointAddress("http://localhost:54358/AfricaStuff.svc");
                channelFactory = new ChannelFactory<IAfricaStuff>(binding, endpointAddress);
                
                client = channelFactory.CreateChannel();
                [B]//De-serialize list of africa stuff?[/B]
                [B]var result = client.SaveStuff(); //Where are you passing in the data?[/B]
                //create the channel
                channelFactory.Close();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

I think it would be a lot easier to debug and help if you give more info on the code and where this data is mapped from?

Can you log the data being passed in before you do the call to savestuff()?
 
To me, it seems that the parameter you passing in could be dodgy. You need to put more logging into this app also.

From your code you posted in the main method, where is the part that de-serializes the data?
Code:
static void Main(string[] args)
        {
            ChannelFactory<IAfricaStuff> channelFactory;
            IAfricaStuff client;

            try
            {

                //create the binding
                var binding = new WSHttpBinding();
                //configure the binding
                binding.Security.Mode = SecurityMode.Message;
                binding.MaxReceivedMessageSize = 2147483647;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.SendTimeout = new TimeSpan(0, 10, 0);
                binding.CloseTimeout = new TimeSpan(0, 10, 0);
                binding.OpenTimeout = new TimeSpan(0, 10, 0);
                binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                var endpointAddress = new EndpointAddress("http://localhost:54358/AfricaStuff.svc");
                channelFactory = new ChannelFactory<IAfricaStuff>(binding, endpointAddress);
                
                client = channelFactory.CreateChannel();
                [B]//De-serialize list of africa stuff?[/B]
                [B]var result = client.SaveStuff(); //Where are you passing in the data?[/B]
                //create the channel
                channelFactory.Close();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

I think it would be a lot easier to debug and help if you give more info on the code and where this data is mapped from?

Can you log the data being passed in before you do the call to savestuff()?

The datacontext is reading from a table by the looks of things, thus no parameter is required.
 
Top
Sign up to the MyBroadband newsletter
X