Exemplo n.º 1
0
        public IActionResult ExecuteSystemJob(Guid SystemJobId)
        {
            SystemJob systemJob = systemJobService.ReturnSingleSystemJob(SystemJobId);

            systemJobService.ExecuteSystemJob(systemJob);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public IActionResult Create(Property Property)
        {
            //Create a shell property attributes record
            Guid PropertyAttributeId            = Guid.NewGuid();
            PropertyAttribute propertyAttribute = new PropertyAttribute()
            {
                Id = PropertyAttributeId
            };

            propertyAttributeService.CreatePropertyAttribute(propertyAttribute);
            propertyAttributeService.SaveChanges();

            //Create the property
            Property.Id = Guid.NewGuid();
            Property.PropertyAttributes = propertyAttributeService.ReturnSinglePropertyAttribute(PropertyAttributeId);
            propertyService.CreateProperty(Property);
            propertyService.SaveChanges();

            //Update the property status
            SystemJob job = systemJobService.ReturnSingleSystemJob("Calculate property status");

            systemJobService.ExecuteSystemJob(job);

            return(RedirectToAction("SetInitialValues", "PropertyAttribute", new { PropertyAttributeId = PropertyAttributeId, PropertyId = Property.Id }));
        }
Exemplo n.º 3
0
        public void ExecuteSystemJob(SystemJob SystemJob)
        {
            var storedProcedure = SystemJob.StoredProcedure;

            db.Database.ExecuteSqlRaw("EXEC {0}", storedProcedure);
            SystemJob.LastRan = DateTime.Now;
            db.SystemJobs.Update(SystemJob);
            db.SaveChanges();
        }
Exemplo n.º 4
0
 private static JobWorker createJobWorker(SystemJob job)
 {
     if (job.JobType == JobType.ProductFileUpload)
     {
         return(new ProductFileUploadWorker(job));
     }
     else if (job.JobType == JobType.AmazonGetInfo)
     {
         return(new AmazonGetInfoWorker(job));
     }
     else if (job.JobType == JobType.BulkDeleteProduct || job.JobType == JobType.BulkDeleteVendorProduct)
     {
         return(new BulkDeleteWorker(job));
     }
     else if (job.JobType == JobType.KitFileUpload)
     {
         return(new KitFileUploadWorker(job));
     }
     else if (job.JobType == JobType.ShadowFileUpload)
     {
         return(new ShadowFileUploadWorker(job));
     }
     else if (job.JobType == JobType.BlacklistedSkuUpload)
     {
         return(new BlacklistedSKUFileUploadWorker(job));
     }
     else if (job.JobType == JobType.BulkeBaySuggestedCategories)
     {
         return(new eBaySuggestedCategoriesWorker(job));
     }
     else if (job.JobType == JobType.VendorProductFileUpload)
     {
         return(new VendorProductFileUploadWorker(job));
     }
     else if (job.JobType == JobType.ShippingRateFileUpload)
     {
         return(new ShippingRateFileUploadWorker(job));
     }
     else if (job.JobType == JobType.VendorInventoryFileUpload)
     {
         return(new VendorInventoryFileUploadWorker(job));
     }
     else if (job.JobType == JobType.eBayProductsReListing)
     {
         return(new eBayProductsReListingWorker(job));
     }
     else if (job.JobType == JobType.eBayProductsEndItem)
     {
         return(new eBayProductsEndItemWorker(job));
     }
     else
     {
         throw new ArgumentException("Unknown job type: " + job.JobType);
     }
 }
Exemplo n.º 5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            inputDeps = new SystemJob()
            {
                Ecb = m_EntityCommandBuffer.CreateCommandBuffer().ToConcurrent(),
                AbilityIdentifier = AbilityIdentifier
            }.Schedule(this, inputDeps);
            m_EntityCommandBuffer.AddJobHandleForProducer(inputDeps);

            return(inputDeps);
        }
        public VendorInventoryFileUploadWorker(SystemJob job)
            : base(job)
        {
            _service = new VendorProductService(new ImageHelper(new PersistenceHelper()), new LogService());
            string[] supportiveParameterArray = job.SupportiveParameters.Split('&');

            supportiveParameters = new Dictionary <string, string>();

            foreach (var item in supportiveParameterArray)
            {
                string[] arrayParamValues = item.Split('=');
                supportiveParameters.Add(arrayParamValues[0], arrayParamValues[1]);
            }
        }
        private void AddJob(IScheduler scheduler, SystemJob jobItem, Func <Type, IJobActivity> getJob)
        {
            var jobKey = new JobKey(jobItem.SystemJobId, jobItem.JobClassType);
            var type   = Type.GetType(jobItem.JobClassType, true);

            // Define the Job to be scheduled
            var quartzJobDetail = JobBuilder.Create(typeof(QuartzJob))
                                  .WithIdentity(jobKey)
                                  .RequestRecovery()
                                  .Build();

            Func <IJobActivity> jobActivityConstructor = () => getJob(type);

            Func <DateTime, Action <string> > getAudit = startDateTime =>
                                                         message => _schedulerDbTools.CreateSystemJobLogEntry(
                jobItem.SystemJobId, startDateTime, DateTime.Now, message,
                Thread.CurrentThread.Name, null, jobItem.AllowMultipleInstances);

            var section = ConfigurationManager.GetSection("traceContextConfiguration") ?? new TraceContextConfigurationSection();
            ITraceContextConfigurator config = (TraceContextConfigurationSection)section;
            var contextName   = new ContextName(type.FullName, "");
            var configuration = config.GetDefault(contextName.Service, contextName.Method);
            var traceSource   = new TraceSource("VirtoCommerce.ScheduleService.Trace");
            var traceContext  = new TraceContext(configuration, contextName, Guid.NewGuid(), traceSource);

            quartzJobDetail.JobDataMap.Add("realization", jobActivityConstructor);
            quartzJobDetail.JobDataMap.Add("getAudit", getAudit);
            quartzJobDetail.JobDataMap.Add("context", traceContext);
            quartzJobDetail.JobDataMap.Add("parameters", jobItem.JobParameters.ToDictionary(pk => pk.Name.ToLowerInvariant(), pv => pv.Value));

            // Associate a trigger with the Job
            var trigger = TriggerBuilder.Create()
                          .WithIdentity(jobItem.SystemJobId, jobItem.JobClassType)
                          .WithSimpleSchedule(x =>
            {
                x.WithInterval(TimeSpan.FromSeconds(jobItem.Period));
                x.RepeatForever();
            })
                          .StartAt(DateTime.UtcNow)
                          .WithPriority(jobItem.Priority)
                          .Build();

            // Validate that the job doesn't already exists
            if (scheduler.CheckExists(jobKey))
            {
                scheduler.DeleteJob(jobKey);
            }
            scheduler.ScheduleJob(quartzJobDetail, trigger);
        }
Exemplo n.º 8
0
        public JobWorker(SystemJob job)
        {
            _systemJob            = job;
            _logger               = new LoggerRepository();
            _jobRepository        = new SystemJobRepository();
            _resultFileDirecctory = ConfigurationManager.AppSettings["SystemJobsResultFileRoot"].ToString();

            // init the Background Worker
            _bw                            = new BackgroundWorker();
            _bw.DoWork                    += new DoWorkEventHandler(bw_DoWork);
            _bw.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
            _bw.ProgressChanged           += new ProgressChangedEventHandler(bw_ProgressChanged);
            _bw.WorkerReportsProgress      = true;
            _bw.WorkerSupportsCancellation = true;
        }
Exemplo n.º 9
0
 public BulkDeleteWorker(SystemJob job)
     : base(job)
 {
     if (job.JobType == JobType.BulkDeleteProduct)
     {
         _deleteManager = new ProductDeleteManager(_logger);
     }
     else if (job.JobType == JobType.BulkDeleteVendorProduct)
     {
         _deleteManager = new VendorProductDeleteManager(_logger);
     }
     else
     {
         throw new ArgumentException("Invalid job type for delete worker: " + job.JobType);
     }
 }
Exemplo n.º 10
0
        protected override JobHandle OnUpdate(JobHandle inputDependencies)
        {
            var damageReceivers = GetComponentDataFromEntity <DamageIn>();
            var damageDealers   = GetComponentDataFromEntity <DamageOut>();

            var systemJob = new SystemJob()
            {
                CommandBuffer   = _collisionBarrierSystem.CreateCommandBuffer().ToConcurrent(),
                DamageReceivers = damageReceivers,
                DamageDealers   = damageDealers
            };

            inputDependencies = systemJob.Schedule(
                _stepPhysicsWorld.Simulation,
                ref _buildPhysicsWorldSystem.PhysicsWorld,
                inputDependencies);

            _collisionBarrierSystem.AddJobHandleForProducer(inputDependencies);

            return(inputDependencies);
        }
Exemplo n.º 11
0
 public CreateSystemJobViewModel(IViewModelsFactory <ISystemJobOverviewStepViewModel> overviewVmFactory, IViewModelsFactory <ISystemJobParametersStepViewModel> parametersVmFactory, SystemJob item)
 {
     RegisterStep(overviewVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", item)));
     RegisterStep(parametersVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", item)));
 }
 public BlacklistedSKUFileUploadWorker(SystemJob job)
     : base(job)
 {
     _repository = new ProductRepository(_logger);
 }
        //private readonly VendorProductUploadResult _uploadResult;

        public ShippingRateFileUploadWorker(SystemJob job) : base(job)
        {
            _repository = new ShippingRateRepository(_logger);
            _service    = new ShippingRateService();
            //_uploadResult = new VendorProductUploadResult();
        }
Exemplo n.º 14
0
 protected override JobHandle OnUpdate(JobHandle inputDeps)
 {
     inputDeps = new SystemJob().Schedule(this, inputDeps);
     return(inputDeps);
 }
Exemplo n.º 15
0
 public BigCommerceSuggestedCategoriesWorker(SystemJob job) : base(job)
 {
 }
Exemplo n.º 16
0
 public ProductFileUploadWorker(SystemJob job)
     : base(job)
 {
 }
Exemplo n.º 17
0
 public SystemJobParametersStepViewModel(IRepositoryFactory <IAppConfigRepository> repositoryFactory, IAppConfigEntityFactory entityFactory, IViewModelsFactory <IAddParameterViewModel> vmFactory, SystemJob item)
     : base(repositoryFactory, entityFactory, vmFactory, item)
 {
 }
Exemplo n.º 18
0
        private void WaitForSystemJob(Guid systemJobId, int pollingInterval, int pollingTimeout, bool throwsException, int waitedFor = 0)
        {
            Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name);

            if (Guid.Empty.Equals(systemJobId))
            {
                throw new ArgumentNullException(nameof(systemJobId));
            }
            if (pollingInterval < 1)
            {
                throw new PlatformException("Interval must be 1 second or more.");
            }
            pollingInterval *= 1000; pollingTimeout *= 1000; bool inProgress = true;

            while (inProgress)
            {
                try
                {
                    OrganizationServiceContext.ClearChanges();

                    SystemJob systemJob = CrmService.GetSystemJob(systemJobId);

                    if (systemJob == null)
                    {
                        throw new PlatformException("The requested job doesn't exist.");
                    }

                    switch (systemJob.StatusReason)
                    {
                    case SystemJobStatusReason.Succeeded:
                        inProgress = false;
                        break;

                    case SystemJobStatusReason.Canceling:
                    case SystemJobStatusReason.Canceled:
                    case SystemJobStatusReason.Failed:
                    case SystemJobStatusReason.Pausing:
                        if (throwsException)
                        {
                            throw new PlatformException(string.Format(CultureInfo.InvariantCulture, "The requested job failed. {0} {1}", systemJob.StatusReason, systemJob.Message));
                        }
                        inProgress = false;
                        break;
                    }
                }
                catch (MessageSecurityException ex)
                {
                    Logger.Warn(CultureInfo.InvariantCulture, "Oups ... a security exception occurred, we will try to reconnect.");
                    Logger.Warn(ex.Message);

                    Connection.SetOrganizationService();

                    OrganizationServiceContext.Dispose();
                    OrganizationServiceContext = new CrmServiceContext(Connection.OrganizationService);

                    CrmService.Dispose();
                    CrmService = new CrmService(OrganizationServiceContext, Connection);

                    WaitForSystemJob(systemJobId, pollingInterval / 1000, pollingTimeout / 1000, throwsException, waitedFor);
                    break;
                }
                catch (FaultException <OrganizationServiceFault> ex)
                {
                    if (ex.Detail != null && ex.Detail.ErrorCode == -2147020463)
                    {
                        Logger.Warn(CultureInfo.InvariantCulture, "Oups ... another solution is currently installing, we will retry in a minute.");
                        Logger.Warn(ex.Detail.Message);

                        Thread.Sleep(60000); WaitForSystemJob(systemJobId, pollingInterval, pollingTimeout, throwsException);
                    }
                    else
                    {
                        throw;
                    }
                }

                if (waitedFor > pollingTimeout)
                {
                    if (throwsException)
                    {
                        throw new TimeoutException(string.Format(CultureInfo.InvariantCulture, "The system job {0} timed out.", systemJobId));
                    }
                    inProgress = false;
                }

                Logger.Info(CultureInfo.InvariantCulture, "The system job is running for {0} seconds.", waitedFor / 1000);
                Thread.Sleep(pollingInterval); waitedFor += pollingInterval;
            }

            Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name);
        }
 public eBayProductsReListingWorker(SystemJob job) : base(job)
 {
     _repo    = new ProductRepository();
     _service = new ProductService(new ImageHelper(new PersistenceHelper()), new LogService());
 }
Exemplo n.º 20
0
 public VendorProductFileUploadWorker(SystemJob job) : base(job)
 {
     _repository   = new VendorProductRepository(_logger);
     _service      = new VendorProductService(new ImageHelper(new PersistenceHelper()), new LogService());
     _uploadResult = new VendorProductUploadResult();
 }
 public eBaySuggestedCategoriesWorker(SystemJob job)
     : base(job)
 {
     _systemJobDirectory = ConfigurationManager.AppSettings["SystemJobsRoot"].ToString();
 }
Exemplo n.º 22
0
        private void WaitForImportJob(Guid importJobId, Guid systemJobId, int pollingInterval, int pollingTimeout, bool throwsException, int waitedFor = 0)
        {
            Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name);

            if (Guid.Empty.Equals(systemJobId))
            {
                throw new ArgumentNullException(nameof(systemJobId));
            }
            if (pollingInterval < 1)
            {
                throw new PlatformException("Interval must be 1 second or more.");
            }
            pollingInterval *= 1000; pollingTimeout *= 1000; bool inProgress = true;

            while (inProgress)
            {
                try
                {
                    OrganizationServiceContext.ClearChanges();

                    SystemJob systemJob = CrmService.GetSystemJob(systemJobId);

                    if (systemJob == null)
                    {
                        throw new PlatformException("The requested job doesn't exist.");
                    }

                    switch (systemJob.StatusReason)
                    {
                    case SystemJobStatusReason.Succeeded:
                        inProgress = false;
                        break;

                    case SystemJobStatusReason.Canceling:
                    case SystemJobStatusReason.Canceled:
                    case SystemJobStatusReason.Failed:
                    case SystemJobStatusReason.Pausing:
                        if (throwsException)
                        {
                            throw new PlatformException(string.Format(CultureInfo.InvariantCulture, "The requested job failed. {0} {1}", systemJob.StatusReason, systemJob.Message));
                        }
                        inProgress = false;
                        break;
                    }

                    ImportJob importJob = CrmService.GetImportJob(importJobId);

                    if (importJob != null && importJob.Progress != null)
                    {
                        int progress = Convert.ToInt32(importJob.Progress.GetValueOrDefault(0));
                        Logger.Info(CultureInfo.InvariantCulture, "Importing solution ... progress: {0}%", progress);
                        if (progress >= 100)
                        {
                            if (!string.IsNullOrWhiteSpace(importJob.Data))
                            {
                                IEnumerable <ImportJobResult> importJobResults = ParseImportJobXmlData(importJob.Data);

                                int warningCount = 0; int errorCount = 0; int fatalErrorCount = 0;

                                foreach (ImportJobResult importJobResult in importJobResults)
                                {
                                    string name      = GetNameText(importJobResult);
                                    string processed = GetProcessedText(importJobResult);
                                    string result    = GetResultText(importJobResult);

                                    switch (importJobResult.Result)
                                    {
                                    case ImportJobStatus.Warning:
                                        Logger.Warn(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", importJobResult.ElementName, name, processed, result);
                                        warningCount++;
                                        break;

                                    case ImportJobStatus.Error:
                                        Logger.Error(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", importJobResult.ElementName, name, processed, result);
                                        if (importJobResult.ErrorCode != "0")
                                        {
                                            errorCount++;
                                        }
                                        break;

                                    case ImportJobStatus.Failure:
                                        Logger.Fatal(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", importJobResult.ElementName, name, processed, result);
                                        if (importJobResult.ErrorCode != "0")
                                        {
                                            fatalErrorCount++;
                                        }
                                        break;

                                    default:
                                        Logger.Info(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", importJobResult.ElementName, name, processed, result);
                                        break;
                                    }
                                }

                                if (errorCount > 0 || fatalErrorCount > 0)
                                {
                                    throw new PlatformException("One or more error(s) occurred whilst importing the solution.");
                                }
                            }

                            inProgress = false;
                        }
                    }
                }
                catch (MessageSecurityException ex)
                {
                    Logger.Warn(CultureInfo.InvariantCulture, "Oups ... a security exception occurred, we will try to reconnect.");
                    Logger.Warn(ex.Message);

                    Connection.SetOrganizationService();

                    OrganizationServiceContext.Dispose();
                    OrganizationServiceContext = new CrmServiceContext(Connection.OrganizationService);

                    CrmService.Dispose();
                    CrmService = new CrmService(OrganizationServiceContext, Connection);

                    WaitForImportJob(importJobId, systemJobId, pollingInterval / 1000, pollingTimeout / 1000, throwsException, waitedFor);
                    break;
                }
                catch (FaultException <OrganizationServiceFault> ex)
                {
                    if (ex.Detail != null && ex.Detail.ErrorCode == -2147020463)
                    {
                        Logger.Warn(CultureInfo.InvariantCulture, "Oups ... another solution is currently installing, we will retry in a minute.");
                        Logger.Warn(ex.Detail.Message);

                        Thread.Sleep(60000); WaitForImportJob(importJobId, systemJobId, pollingInterval, pollingTimeout, throwsException);
                    }
                    else
                    {
                        throw;
                    }
                }

                if (waitedFor > pollingTimeout)
                {
                    if (throwsException)
                    {
                        throw new TimeoutException(string.Format(CultureInfo.InvariantCulture, "The system job {0} timed out.", systemJobId));
                    }
                    inProgress = false;
                }

                Thread.Sleep(pollingInterval); waitedFor += pollingInterval;
            }

            Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name);
        }
 public eBayProductsEndItemWorker(SystemJob job) : base(job)
 {
     _repo = new ProductRepository();
 }
Exemplo n.º 24
0
 public KitFileUploadWorker(SystemJob job)
     : base(job)
 {
     _connectionString = ConfigurationManager.ConnectionStrings["InventoryConnection"].ConnectionString;
 }
Exemplo n.º 25
0
 public AmazonGetInfoWorker(SystemJob job)
     : base(job)
 {
     _repository = new ProductRepository(_logger);
 }