示例#1
0
        public JobsProvider(ICommandJobBase <T> commandJob, IProccessErrorHandler <T> errorHandler, string conn, IOrganizationService crmService)
        {
            if (String.IsNullOrEmpty(conn))
            {
                connectionString = ConfigurationManager.AppSettings[JobUtilHelper.JobProviderConnectionString];
            }
            else
            {
                connectionString = conn;
            }

            JobUtilHelper.InitConnectionString(connectionString);

            if (crmService == null)
            {
                LoadCrmService();
            }
            else
            {
                service = crmService;
            }

            commandJobHandler             = commandJob;
            _errorHandler                 = errorHandler;
            commandJobHandler.JobProvider = this;
            runningJob = new RunningJob();
        }
示例#2
0
        private void InsertRecordJob(T job, CofigurationJob configJob, RunningJob runnerjob)
        {
            var xmlObject = SerializeToXml(job);
            var fullname  = typeof(T).FullName;
            var jobid     = JobUtilHelper.InsertRecordJob(xmlObject, fullname, commandJobHandler.CofigurationJob, runnerjob);

            if (runningJob.JobId == null)
            {
                runningJob.JobId = jobid;
            }
        }
示例#3
0
 public static void UpdateJobHistory(RunningJob runningJob, bool?isGetDataComplete = null)
 {
     using (var connection = GetSqlConnection(GetConectionString()))
     {
         var command = new SqlCommand(@"dbo.GS_UpdateJobHistory", connection);
         command.Parameters.AddWithValue("@id", runningJob.ID);
         command.Parameters.AddWithValue("@total", runningJob.Total);
         command.Parameters.AddWithValue("@noupdate", runningJob.NoUpdate);
         command.Parameters.AddWithValue("@update", runningJob.Update);
         command.Parameters.AddWithValue("@insert", runningJob.Insert);
         command.Parameters.AddWithValue("@success", runningJob.Success);
         command.Parameters.AddWithValue("@failed", runningJob.Failed);
         command.Parameters.AddWithValue("@IsGetDataComplete", isGetDataComplete);
         command.CommandType = System.Data.CommandType.StoredProcedure;
         connection.Open();
         command.ExecuteNonQuery();
     }
 }
示例#4
0
 public static Guid InsertRecordJob(string xmlObject, string fullname,
                                    CofigurationJob configJob, RunningJob runnerjob)
 {
     using (var connection = GetSqlConnection(GetConectionString()))
     {
         var command = new SqlCommand(@"dbo.GS_InsertRecordJob", connection);
         command.Parameters.AddWithValue("@jobName", JobUtilHelper.GetFullJobNameByCofigurationJob(configJob));
         command.Parameters.AddWithValue("@MaxRetries", configJob.MaxRetries);
         command.Parameters.AddWithValue("@ModelXml", xmlObject);
         command.Parameters.AddWithValue("@ModelTypeXml", fullname);
         command.Parameters.AddWithValue("@historyId", runnerjob.ID);
         command.CommandType = System.Data.CommandType.StoredProcedure;
         connection.Open();
         var jobid = (Guid)command.ExecuteScalar();
         return(jobid);
         //if (runningJob.JobId == null)
         //    runningJob.JobId = (Guid)command.ExecuteScalar();
         //else
         //    command.ExecuteNonQuery();
     }
 }
 public static void UpdateJobHistory(RunningJob runningJob, bool? isGetDataComplete = null)
 {
     using (var connection = GetSqlConnection(GetConectionString()))
     {
         var command = new SqlCommand(@"dbo.GS_UpdateJobHistory", connection);
         command.Parameters.AddWithValue("@id", runningJob.ID);
         command.Parameters.AddWithValue("@total", runningJob.Total);
         command.Parameters.AddWithValue("@noupdate", runningJob.NoUpdate);
         command.Parameters.AddWithValue("@update", runningJob.Update);
         command.Parameters.AddWithValue("@insert", runningJob.Insert);
         command.Parameters.AddWithValue("@success", runningJob.Success);
         command.Parameters.AddWithValue("@failed", runningJob.Failed);
         command.Parameters.AddWithValue("@IsGetDataComplete", isGetDataComplete);
         command.CommandType = System.Data.CommandType.StoredProcedure;
         connection.Open();
         command.ExecuteNonQuery();
     }
 }
 public static Guid InsertRecordJob(string xmlObject, string fullname,
     CofigurationJob configJob, RunningJob runnerjob)
 {
     using (var connection = GetSqlConnection(GetConectionString()))
     {
         var command = new SqlCommand(@"dbo.GS_InsertRecordJob", connection);
         command.Parameters.AddWithValue("@jobName", JobUtilHelper.GetFullJobNameByCofigurationJob(configJob));
         command.Parameters.AddWithValue("@MaxRetries", configJob.MaxRetries);
         command.Parameters.AddWithValue("@ModelXml", xmlObject);
         command.Parameters.AddWithValue("@ModelTypeXml", fullname);
         command.Parameters.AddWithValue("@historyId", runnerjob.ID);
         command.CommandType = System.Data.CommandType.StoredProcedure;
         connection.Open();
         var jobid = (Guid)command.ExecuteScalar();
         return jobid;
         //if (runningJob.JobId == null)
         //    runningJob.JobId = (Guid)command.ExecuteScalar();
         //else
         //    command.ExecuteNonQuery();
     }
 }