private void ExcuteRecords() { Console.WriteLine("ExcuteRecords start "); if (this.RunningJob.JobId == null) { throw new ArgumentException("Running job must contain JobId"); } bool hasmore; int pageNumber = 1; do { //this.connectionString var getRecordsById = GetRecordsById(pageNumber, commandJobHandler.CofigurationJob.RowspPage, out hasmore); pageNumber += 1; //1 מוכן לטעינה //2 בתהליך //3 הסתיים //4 נכשל Console.WriteLine("ExcuteRecords before foreach "); foreach (var record in getRecordsById) { Console.WriteLine("ExcuteRecords foreach : " + runningJob.Total.ToString()); int status = 0; string action = ""; try { runningJob.Total++; UpdateOnProgressRow(record); Console.WriteLine("ExcuteRecords foreach after UpdateOnProgressRow "); ResultJob returnValues = commandJobHandler.Execute(record.JobRecord, _errorHandler.WriteLog); action = returnValues.ToString(); Console.WriteLine("ExcuteRecords foreach after returnValues "); if (returnValues.HasFlag(ResultJob.Insert)) { runningJob.Insert++; } if (returnValues.HasFlag(ResultJob.Update)) { runningJob.Update++; } if (returnValues.HasFlag(ResultJob.NoUpdate)) { runningJob.NoUpdate++; } if (returnValues.HasFlag(ResultJob.Failed) || returnValues.HasFlag(ResultJob.FailedRetry)) { runningJob.Failed++; } else { runningJob.Success++; } if (returnValues.HasFlag(ResultJob.FailedRetry)) { status = (int)StatusRecord.Failed; } else { status = (int)StatusRecord.Finish; } Console.WriteLine("ExcuteRecords foreach finish"); } catch (FaultException <OrganizationServiceFault> fex) { if (_errorHandler != null) { _errorHandler.WriteLog(record.JobRecord, fex.StackTrace + "_" + fex.Message, EventLogEntryType.Error); } runningJob.Failed++; HandleFualtException(fex, ref status); Console.WriteLine("Error: " + fex.Message + Environment.NewLine + fex.InnerException); } catch (Exception e) { if (_errorHandler != null) { _errorHandler.WriteLog(record.JobRecord, e.StackTrace + "_ex_" + e.ToString(), EventLogEntryType.Error); } runningJob.Failed++; HandleUnHandeledExc(e, ref status); Console.WriteLine("Error: " + e.Message + Environment.NewLine + e.InnerException); } finally { UpdateRow(record, status, action); } Console.WriteLine("ResultJob.Insert " + ResultJob.Insert); Console.WriteLine("ResultJob.Update " + ResultJob.Update); } }while (hasmore == true); JobUtilHelper.UpdateBulkUpdate(runningJob.JobId.Value); Console.WriteLine("ExcuteRecords end "); }