Exemplo n.º 1
0
        public static JobItem addJobItem(JobItem jobItem)
        {
            var latestUIN = ArticleService.getArticleCount((int)jobItem.ArticleId);


            var context = Context.sharedInstance;

            jobItem.IsDeleted = false;
            jobItem.CreatedAt = DateTime.Now;
            context.JobItems.Add(jobItem);
            context.SaveChanges();

            jobItem = Context.sharedInstance.JobItems.Find(jobItem.Id);



            for (int i = 0; i < jobItem.Quantity; i++)
            {
                ItemService.addItem(new Item()
                {
                    JobItemId = jobItem.Id, UIN = jobItem.Article.Prefix + "-" + (latestUIN + 1 + i).ToString()
                });
            }

            return(jobItem);
        }
Exemplo n.º 2
0
        public async Task <JobItemDto> AddOrUpdateItemAsync(JobItemDto item)
        {
            if (item == null)
            {
                throw new ArgumentException("Job item is invalid!");
            }

            JobItem jobItemEntity = null;

            if (item.JobItemId <= 0)
            {
                jobItemEntity = this.mapper.Map <JobItem>(item);
                this.context.Add(jobItemEntity);
            }
            else
            {
                jobItemEntity = await this.context.JobItems.FindAsync(item.JobItemId);

                if (jobItemEntity == null)
                {
                    throw new ArgumentException("Job item was not found!");
                }

                this.mapper.Map(item, jobItemEntity);
                this.context.Update(jobItemEntity);
            }

            await this.context.SaveChangesAsync();

            return(await this.GetItemAsync(jobItemEntity.JobItemId));
        }
Exemplo n.º 3
0
        // Manage JobItems
        public async Task <JobItem> AddJobItemAsync(JobItem jobItem)
        {
            _context.JobItems.Add(jobItem);
            await _context.SaveChangesAsync();

            return(jobItem);
        }
        /// <summary>
        /// 补单并关闭任务
        /// </summary>
        /// <param name="tnum"></param>
        /// <returns></returns>
        public JsonResult RepairCloseJob(int Id)
        {
            JsonResult JR = new JsonResult()
            {
                ContentType = "text/html"
            };

            if (Id.IsNullOrEmpty())
            {
                JR.Data = new { error = 1, info = "参数有误" };
                return(JR);
            }
            JobItem JobItem = Entity.JobItem.FirstOrNew(o => o.Id == Id);

            JobItem.State    = 2;
            JobItem.RunState = 2;
            Entity.SaveChanges();
            //查询订单状态
            JobItem = JobItem.PayQuery(Entity);
            if (JobItem.State != 3)
            {
                JR.Data = new { error = 1, info = "当前订单补单失败!" };
                return(JR);
            }
            JR = CloseJob(JobItem.TNum);
            return(JR);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 报告processor的处理进度。
 /// </summary>
 /// <param name="jobItem"></param>
 /// <param name="processingInfo"></param>
 /// <param name="e"></param>
 /// <returns>如果处理顺利完成,返回true;如果被用户中止或中途出错,返回false。</returns>
 private bool ProcessingReport(JobItem jobItem, IMediaProcessingInfo processingInfo, DoWorkEventArgs e)
 {
     while (true)
     {
         if (this.backgroundWorker.CancellationPending)
         {
             jobItem.QuitProcessing();
             this.SetJobEventAndReportProgress(jobItem, JobEvent.QuitAllProcessing);
             return(false);
         }
         if (processingInfo.HasExited)
         {
             if (processingInfo.Progress != 100)
             {
                 this.SetJobEventAndReportProgress(jobItem, JobEvent.Error);
                 MessageBox.Show("发生了一个错误。编码器/混流器未完成工作就退出了。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return(false);
             }
             this.SynchReportProgress(jobItem);
             return(true);
         }
         this.SynchReportProgress(jobItem);
         Thread.Sleep(500);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="video"></param>
 /// <param name="audio"></param>
 /// <param name="dstFile"></param>
 /// <param name="e"></param>
 /// <returns>如果混流顺利完成,返回true;如果被用户中止或在过程中出错,返回false。</returns>
 private bool Mux(JobItem jobItem, DoWorkEventArgs e)
 {
     try
     {
         jobItem.Event = JobEvent.Muxing;
         jobItem.ProcessMuxing();
         return(this.ProcessingReport(jobItem, jobItem.MuxingInfo, e));
     }
     catch (FormatNotSupportedException)
     {
         MessageBox.Show("合成MP4失败。可能源媒体流中有不支持的格式。", "合成失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.SetJobEventAndReportProgress(jobItem, JobEvent.Error);
         return(false);
     }
     catch (FFmpegBugException)
     {
         MessageBox.Show("合成MP4失败。这是由于FFmpeg的一些Bug, 对某些流无法使用复制。", "合成失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.SetJobEventAndReportProgress(jobItem, JobEvent.Error);
         return(false);
     }
     finally
     {
         if ((jobItem.JobConfig.AudioMode == StreamProcessMode.Encode) && !MyIO.IsSameFile(jobItem.MuxingInfo.AudioFile, jobItem.DestFile))
         {
             File.Delete(jobItem.MuxingInfo.AudioFile);
         }
     }
 }
Exemplo n.º 7
0
 public static bool StartBackgroundJob(JobItem jobItem)
 {
     try
     {
         if (string.IsNullOrEmpty(jobItem.Data))
         {
             return(true);
         }
         using (var connection = JobStorage.Current.GetConnection())
         {
             var hashKey = Utility.MD5(jobItem.JobName + ".runtime");
             using (var tran = connection.CreateWriteTransaction())
             {
                 tran.SetRangeInHash(hashKey, new List <KeyValuePair <string, string> >
                 {
                     new KeyValuePair <string, string>("Data", jobItem.Data)
                 });
                 tran.Commit();
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         // Logger.ErrorException("HttpJobDispatcher.StartBackgroudJob", ex);
         return(false);
     }
 }
Exemplo n.º 8
0
        private string GetDescription(JobItem jobItem, Currency currency, decimal carriage)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("{0}, Serial No: {1}", GetInstrumentDescription(jobItem.Instrument), jobItem.SerialNo);
            if (carriage > 0)
            {
                var currencySymbol = String.Empty;
                switch (currency.Name)
                {
                case "GBP":
                    currencySymbol = "£";
                    break;

                case "USD":
                    currencySymbol = "$";
                    break;

                default:
                    currencySymbol = currency.Name;
                    break;
                }
                sb.AppendFormat(" (includes {0}{1} for carriage)", currencySymbol, String.Format("{0:0.00}", carriage));
            }
            return(sb.ToString());
        }
        public void Should_store_date()
        {
            #region arrange data

            var mockData = new Mock <IDataRepository>();
            mockData.Setup(m => m.StoreData(It.IsAny <JobItem>(), It.IsAny <DataBlockType>(), It.IsAny <string>())).Returns(Guid.Empty);

            ServiceLocator.RegisterForDependency(mockData.Object);

            const string testUrl  = "url";
            const string testData = "text";
            var          jobItem  = new JobItem
            {
                Url = new UrlItem
                {
                    Url = testUrl
                }
            };

            #endregion

            new PipelineRoutines().StoreData(new ParsedContentData(jobItem, DataBlockType.Link, testData));

            mockData.Verify(m => m.StoreData(
                                It.Is <JobItem>(job => job == jobItem),
                                It.Is <DataBlockType>(dataType => dataType == DataBlockType.Link),
                                It.Is <string>(s => s == testData))
                            , Times.Once);
        }
        public void Should_download_content()
        {
            #region arrange data

            var          mockClient  = new Mock <ICrawlerWebClient>();
            const string testUrl     = "url";
            const string testContent = "text";
            mockClient.Setup(m => m.Download(It.IsAny <string>())).Returns(testContent);

            ServiceLocator.RegisterForDependency(mockClient.Object);

            var jobItem = new JobItem
            {
                Url = new UrlItem
                {
                    Url = testUrl
                }
            };

            #endregion

            var actual = new PipelineRoutines().DownloadContent(jobItem);

            Assert.NotNull(actual);
            Assert.Equal(testContent, actual.Content);
            Assert.Equal(jobItem, actual.Job);
            Assert.Equal(testUrl, actual.Job.Url.Url);
        }
Exemplo n.º 11
0
        private void ShowItems_click(object sender, RoutedEventArgs e)
        {
            JobItem   jobItem  = ((JobItem)dg_ShowItems.SelectedItem);
            ItemsShow itemshow = new ItemsShow((int)jobItem.Id, true);

            itemshow.Show();
        }
Exemplo n.º 12
0
        public Task <JobSchedule> CalculateSchedules(JobItem JobInfoItem)
        {
            CurrentJobItem = JobInfoItem;

            TimeSpan delta               = JobInfoItem.DeliveryDate.Subtract(DateTime.Now);
            Double   totalHours          = delta.Days * 10 + delta.Hours;
            Double   totalDesign         = totalHours * 0.2;
            Double   totalProduction     = totalHours * 0.5;
            Double   totalTransportation = totalHours * 0.2;
            Double   totalReview         = totalHours * 0.1;

            JobSchedule           = new JobSchedule();
            JobSchedule.JobItemId = JobInfoItem.JobID;
            JobSchedule.JobName   = JobInfoItem.JobName;

            JobSchedule.DesignItem            = this.CreateScheduleItem(totalDesign, Enumerations.Department.Design);
            JobSchedule.ProductionItem        = CreateScheduleItem(totalProduction, Enumerations.Department.Production);
            JobSchedule.TransportationItem    = CreateScheduleItem(totalTransportation, Enumerations.Department.Transportation);
            JobSchedule.ReviewItem            = CreateScheduleItem(totalReview, Enumerations.Department.FinalReview);
            JobSchedule.ProjectManagementItem = CreateScheduleItem(totalHours, Enumerations.Department.ProjectManagement);

            string crank = JsonConvert.SerializeObject(JobSchedule);

            return(Task.FromResult(JobSchedule));
        }
Exemplo n.º 13
0
        public async Task <JobItem> UpdateJobItemAsync(JobItem jobItem)
        {
            _context.Entry(jobItem).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(jobItem);
        }
Exemplo n.º 14
0
        public void UpdateJobItem(JobItem jobItemParam)
        {
            var jobItem = _context.JobItems.Find(jobItemParam.Id);

            if (jobItem == null)
            {
                throw new AppException("Job item not found");
            }

            var job = GetById(jobItem.JobId);

            if (job == null)
            {
                throw new AppException("Job not found");
            }

            if (string.IsNullOrWhiteSpace(jobItemParam.Name))
            {
                throw new AppException("Name is empty");
            }

            jobItem.Name     = jobItemParam.Name;
            jobItem.Quantity = jobItemParam.Quantity;
            jobItem.Sell     = jobItemParam.Sell;
            jobItem.Profit   = jobItem.Sell - jobItem.Buy;
            _context.SaveChanges();

            Recalculate(job);
        }
Exemplo n.º 15
0
        public void Execute(int id)
        {
            JobItem jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var taskresult = this.PreviousTaskResult.TaskData;
                _searvice.InsertPriceReport();
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess = true,
                    TaskData  = taskresult
                };
                jobItem.Status      = true;
                jobItem.Description = "Process Price Report Successful";
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "Process Price Report Task Failed"
                };
                jobItem.Status      = false;
                jobItem.Description = string.Format("Error: {0} Inner Exception: {1} Error Message: {2}", _taskResult.ErrorMessage, ex.InnerException == null ? "" : ex.InnerException.ToString(), ex.Message);
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            }
        }
Exemplo n.º 16
0
 private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     this.workingJobItem = null;
     if (e.Result != null)
     {
         JobItem previousJobItem = (JobItem)e.Result;
         // 对于全部处理完成的情形,可能有条目的移动使部分条目为“等待”的状态。
         if (previousJobItem.Event == JobEvent.AllDone || previousJobItem.Event == JobEvent.QuitAllProcessing)
         {
             previousJobItem.Event = JobEvent.None;
             foreach (JobItem jobItem in this.workingJobItems)
             {
                 if (jobItem.State == JobState.Waiting)
                 {
                     jobItem.State = JobState.NotProccessed;
                 }
             }
             this.workingJobItems.Clear();
             // 根据当前所选条目的JobState决定是否启用编辑按钮
             this.JobItemListViewItemSelectionChanged(null, null);
             // 当关闭程序时,如果worker正在运行,设此旗标为true并取消worker的运行,在此退出程序
             if (this.formClosing)
             {
                 this.SaveJobItemsAndProfiles();
                 this.Close();
             }
         }
         else
         {
             this.workingJobItem = this.workingJobItems[this.workingJobItems.IndexOf(previousJobItem) + 1];
             this.backgroundWorker.RunWorkerAsync(this.workingJobItem);
         }
     }
 }
Exemplo n.º 17
0
        public void Execute(int id)
        {
            JobItem jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var taskresult = this.PreviousTaskResult.TaskData;
                _service.PopulateVID(taskresult.FilePath);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess = true,
                };
                jobItem.Status      = true;
                jobItem.Description = "VID Bulk Insert Successful";
                jobItem.EndDate     = DateTime.UtcNow;
                _service.JobItemLog(jobItem);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "VID Bulk Insert Failed"
                };
                jobItem.Status      = false;
                jobItem.Description = _taskResult.ErrorMessage;
                jobItem.EndDate     = DateTime.UtcNow;
                _service.JobItemLog(jobItem);
            }
        }
Exemplo n.º 18
0
        public void SaveJob(JobItem job)
        {
            var result = new JobItem();

            try
            {
                _logger.LogTrace("Saving the Job", job);
                if (!string.IsNullOrEmpty(job.Id))
                {
                    Expression <Func <JobItem, bool> > expr = (x => x.Id == job.Id);
                    if (_jobRepository.Exists(expr))
                    {
                        result = _jobRepository.Update(job);
                    }
                    else
                    {
                        result = _jobRepository.Add(job);
                    }
                }
                else
                {
                    result = _jobRepository.Add(job);
                }

                JobCreatedIntegrationEvent test = new JobCreatedIntegrationEvent("test");
                _eventBus.Publish(test);


                _logger.LogTrace("Item Saved & event publised. event:", test);
            }
            catch (Exception ex)
            {
                _logger.LogError("Unable to save the ", ex);
            }
        }
Exemplo n.º 19
0
        public static AspectResultSet buildAspectResultSet(string strCountry, JobItem ji, int intSection)
        {
            //build aspects for a job, in a section
            DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("ASPECT_DETAILS_" + strCountry, "select * from tblaspects" + strCountry);
            DataRow [] drsAspects = dtAspects.Select("OccNumber=" + ji.JobRef);
            AspectResultSet ars= new AspectResultSet();
            if (drsAspects.Length > 0)
            {
                string strAspectList ="";
                switch (intSection)
                {
                    case 1: strAspectList = drsAspects[0]["Central"].ToString(); break;
                    case 2: strAspectList = drsAspects[0]["Secondary"].ToString(); break;
                    case 3: strAspectList = drsAspects[0]["Other"].ToString(); break;
                };

                for (int i = 0; i < strAspectList.Length; i = i + 3)
                {
                    AspectResult ar = new AspectResult();
                    ar.AspectRef = Convert.ToInt16(strAspectList.Substring(i, 3).ToString());
                    ars.Add(ar);//mrm added
                };

            };
            return (ars);
        }
        public void Execute(int id)
        {
            FTPUtils utils   = null;
            JobItem  jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var ftpConfig = _searvice.GetFtpConfig(FtpConfigurationType.PipelineOrder);
                utils = new FTPUtils(ftpConfig);
                utils.DownloadFile();
                if (utils.DownloadFileName == null)
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess    = false,
                        ErrorMessage = "Pipe Line Order Download Failed as file is not exists"
                    };
                    jobItem.Status      = false;
                    jobItem.Description = _taskResult.ErrorMessage;
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
                else
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess = true,
                        TaskData  = new dlxTaskData()
                        {
                            FilePath = utils.DownloadFileName
                        }
                    };
                    jobItem.Status      = true;
                    jobItem.Description = "Pipe Line Order Download Successful";
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "Pipe Line Order Download Failed",
                    TaskData     = new dlxTaskData()
                    {
                        FilePath = utils.DownloadFileName
                    }
                };
                jobItem.Status = false;
                //jobItem.Description = _taskResult.ErrorMessage;
                jobItem.Description = string.Format("Error: {0} Inner Exception: {1} Error Message: {2}", _taskResult.ErrorMessage, ex.InnerException == null ? "" : ex.InnerException.ToString(), ex.Message);
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            }
        }
        public Guid StoreData(JobItem jobItem, DataBlockType blockType, string data)
        {
            var url = string.Empty;

            try
            {
                using (var ctx = CreateContext())
                {
                    var urlItem = ctx.UrlItems.Single(u => u.Id == jobItem.Url.Id);
                    url = urlItem.Url;
                    var dataBlock = new DataBlock
                    {
                        Data = data,
                        Date = jobItem.DateStart,
                        Url  = urlItem,
                        Type = blockType
                    };
                    ctx.DataBlocks.Add(dataBlock);

                    ctx.Commit();

                    _logger.DataStored(jobItem);
                    return(dataBlock.Id);
                }
            }
            catch (Exception err)
            {
                _logger.LogError(url, err);
                throw;
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// Uploads and submits a job
 /// </summary>
 /// <param name="job">Meta data information about the job</param>
 /// <param name="jobDataPath">Local path to the zip file containing the job</param>
 /// <returns></returns>
 public string SubmitJob(JobItem job, string jobDataPath)
 {
     _storage.UploadBlob(Path.GetFileName(jobDataPath), jobDataPath);
     job.FileName = Path.GetFileName(jobDataPath);
     _storage.WriteJob(job);
     return(job.RowKey);
 }
        /// <summary>
        /// 保存任务执行时间
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="RunTime"></param>
        public void SetTimeSave(int Id, DateTime RunTime)
        {
            JobItem JobItem = Entity.JobItem.FirstOrDefault(n => n.Id == Id);

            JobItem.RunTime = RunTime;
            Entity.SaveChanges();
            Response.Write("OK");
        }
Exemplo n.º 24
0
 protected string GetJobItemReference(JobItem jobItem)
 {
     if (jobItem == null)
     {
         return(string.Empty);
     }
     return(string.Format("{0}/{1}", jobItem.Job.JobNo, jobItem.ItemNo));
 }
Exemplo n.º 25
0
 public void RemoveJob(JobItem job)
 {
     if (PlayerManager.instance.playerJobList.Contains(job))
     {
         PlayerManager.instance.playerJobList.Remove(job);
     }
     updateJobSlots();
 }
Exemplo n.º 26
0
        public void RecalculateExpenseForItem(JobItem jobItem)
        {
            jobItem.Buy    = jobItem.Expenses.Where(e => e.Paid).Sum(e => e.Value);
            jobItem.Profit = jobItem.Sell - jobItem.Buy;
            _context.SaveChanges();
            Job job = GetById(jobItem.JobId);

            Recalculate(job);
        }
Exemplo n.º 27
0
 public JobItem Add(JobItem entity)
 {
     if (string.IsNullOrEmpty(entity.Id))
     {
         entity.Id = Guid.NewGuid().ToString();
     }
     _repository.Add(entity);
     return(this.GetById(entity.Id));
 }
        public void Given_work_item()
        {
            var definition = JobFactory.Interval("Foo1", () =>
            {
                return(Task.Factory.StartNew(() => Console.WriteLine("Foo1")));
            }, TimeSpan.FromMinutes(10));

            _item = new JobItem(new DefaultSchedulerContext(), definition, null);
        }
Exemplo n.º 29
0
        public JobDetailPage()
        {
            InitializeComponent();

            var item = new JobItem();

            viewModel      = new JobDetailViewModel(item);
            BindingContext = viewModel;
        }
Exemplo n.º 30
0
 /// <summary>
 /// 向GUI线程报告进度,在GUI线程处理完成前阻塞当前线程。
 /// </summary>
 /// <param name="jobItem"></param>
 private void SynchReportProgress(JobItem jobItem)
 {
     this.workerReporting = true;
     this.backgroundWorker.ReportProgress(0, jobItem);
     while (this.workerReporting)
     {
         Thread.Sleep(1);
     }
 }
        public void Execute(int id)
        {
            FTPUtils utils   = null;
            JobItem  jobItem = new JobItem();

            jobItem.StartDate = DateTime.UtcNow;
            jobItem.JobId     = id;
            jobItem.TaskName  = Name;
            try
            {
                var taskresult = this.PreviousTaskResult.TaskData;

                var ftpConfig = _searvice.GetFtpConfig(FtpConfigurationType.Announcement);
                utils = new FTPUtils(ftpConfig);
                bool success = utils.Archive(new FileInfo(taskresult.FilePath).Name);

                if (!success)
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess    = false,
                        ErrorMessage = "Announcement Archive Failed."
                    };
                    jobItem.Status      = false;
                    jobItem.Description = _taskResult.ErrorMessage;
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
                else
                {
                    _taskResult = new dlxTaskResult()
                    {
                        IsSuccess = true
                                    //TaskData = new dlxTaskData() { FilePath = utils.DownloadFileName }
                    };
                    jobItem.Status      = true;
                    jobItem.Description = "Announcement Archive Successful";
                    jobItem.EndDate     = DateTime.UtcNow;
                    _searvice.JobItemLog(jobItem);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                _taskResult = new dlxTaskResult()
                {
                    IsSuccess    = false,
                    ErrorMessage = "Announcement Archive Failed"
                };
                jobItem.Status = false;
                //jobItem.Description = _taskResult.ErrorMessage;
                jobItem.Description = string.Format("Error: {0} Inner Exception: {1} Error Message: {2}", _taskResult.ErrorMessage, ex.InnerException == null ? "" : ex.InnerException.ToString(), ex.Message);
                jobItem.EndDate     = DateTime.UtcNow;
                _searvice.JobItemLog(jobItem);
            };
        }
Exemplo n.º 32
0
 public DataTable PopulateSkillData(Int16 iSection)
 {
     string strCountry = LoginInfo["Country"].ToString();
     JobItem ji = new JobItem();
     ji.JobRef = iJobref;
     //get AspectResultSet for either Core(section=1), Secondary(2) or Other(3)
     SkillsResultSet srs = CCLib.MatchingObject.CCobject.buildSkillsResultSet(strCountry, ji, iSection);
     return srs.GetAsDataTable();
 }
Exemplo n.º 33
0
 public JobItemViewModel(JobItem jobItem)
 {
     this.jobItem = jobItem;
 }
Exemplo n.º 34
0
        public static SkillsResultSet buildSkillsResultSet(string strCountry, JobItem ji, int intSection)
        {
            //build Desirable/Essential skills

            SkillsResultSet ds = new SkillsResultSet();

            DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("ASPECT_DETAILS_" + strCountry, "select * from tblaspects" + strCountry);
            DataRow[] drsAspects = dtAspects.Select("OccNumber=" + ji.JobRef);
            if (drsAspects.Length > 0)
            {
                string strAspectList = "";
                switch (intSection)
                {
                    case 1: strAspectList = drsAspects[0]["EssentialSkills"].ToString(); break;
                    case 2: strAspectList = drsAspects[0]["DesirableSkills"].ToString(); break;

                };

                for (int i = 0; i < strAspectList.Length; i = i + 3)
                {
                    SkillsResult sr = new SkillsResult();
                    sr.SkillsRef = Convert.ToInt16(strAspectList.Substring(i, 3).ToString());
                    ds.Add(sr);
                };

            };
            return (ds);
        }
Exemplo n.º 35
0
        public static DataTable createComments(int intJobRef, string strSuffixCode, string strCountry,  AspectResultSet aspectResultSet, HealthResultSet healthResultSet, LevelResultSet levelResultSet, SkillsResultSet skillsResultSet)
        {
            string asComment = "";
            string geComment = "";
               // string htComment = "";
            string lvComment = "";
            string skcomment = "";

            int i,x,cd,sd,od,cdnm,sdnm,slvm,clvm;
            int tmpcat,cscomm,sscomm;
            string strTemp;
            string aspecttblname = strCountry;

            DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("MM_ALL_JOBS_" + strSuffixCode, "SELECT tblAspects" + aspecttblname + ".OccNumber, Central, Secondary, ID, Other, Education, EssentialSkills, DesirableSkills, OccName FROM Jobinfo" + strSuffixCode + " INNER JOIN tblAspects" + aspecttblname + " ON Jobinfo" + strSuffixCode + ".OccNumber = tblAspects" + aspecttblname + ".OccNumber order by OccName");
            bool [] levelvals= new bool[MaxNoOfLevels+1];
            bool [] healthvals= new bool[MaxNoOfHealth+1];
            int [] aspectres= new int[MaxNoOfAspects+1] ;
            CreateFastClientArrays(aspectResultSet, levelResultSet, healthResultSet, healthvals, levelvals, aspectres);
            DataRow[] dr = dtAspects.Select("occnumber=" + intJobRef);
            //jm 02/11/2006 - added catch here..
            if (dr.Length > 0)
            {
            DataRow rt = dr[0]; //should probably catch this

            //score job
            JobItem ji = new JobItem();
            ji.Score = ScoreArticle(rt, healthvals, levelvals, aspectres, ref ji.MatchCat, ref ji.MatchMore);
            ji.JobRef = Convert.ToInt16(rt["OccNumber"].ToString());
            ji.JobTitle = rt["OccName"].ToString();

            //prepare general comment
            tmpcat = ji.MatchCat / 100;
            if ((ji.MatchMore) && (tmpcat != 7)) { geComment = geComment + "00"; };
            cscomm = 0;
            sscomm = 0;
            cd = 0;
            cdnm = 0;
            clvm = 0;
            sd = 0;
            sdnm = 0;
            slvm = 0;
            od = 0;
            // check for unanswered core and secondry and store dislikes and LVM counts
            strTemp = rt["Central"].ToString();

            for (i = 0; (i + 1) < strTemp.Length; i = i + 3)
            {
                x = aspectres[Convert.ToInt16(strTemp.Substring(i, 3))];
                switch (x)
                {
                    case 0: cscomm = cscomm + 1; break;
                    case 1: cd = cd + 1; break;
                    case 2: cd = cd + 1; break;
                    case 3: cdnm = cdnm + 1; break;
                    case 5: clvm = clvm + 1; break;
                    case 6: clvm = clvm + 1; break;
                }

            }

            strTemp = rt["Secondary"].ToString();

            for (i = 0; (i + 1) < strTemp.Length; i = i + 3)
            {
                x = aspectres[Convert.ToInt16(strTemp.Substring(i, 3))];
                switch (x)
                {
                    case 0: sscomm = sscomm + 1; break;
                    case 1: sd = sd + 1; break;
                    case 2: sd = sd + 1; break;
                    case 3: sdnm = sdnm + 1; break;
                    case 5: slvm = slvm + 1; break;
                    case 6: slvm = slvm + 1; break;
                }

            }

            strTemp = rt["Other"].ToString();

            for (i = 0; (i + 1) < strTemp.Length; i = i + 3)
            {
                x = aspectres[Convert.ToInt16(strTemp.Substring(i, 3))];
                switch (x)
                {
                    case 1: od = od + 1; break;
                    case 2: od = od + 1; break;
                }

            }

            //if unaswered core or secondry then return appropriate comment
            if (cscomm > 1) { geComment = geComment + "07"; }
            else if (cscomm == 1) { geComment = geComment + "08"; }
            else if (sscomm > 1) { geComment = geComment + "09"; }
            else if (sscomm == 1) { geComment = geComment + "10"; };
            if (!ji.MatchMore)
            {
                switch (tmpcat)
                {
                    case 1: geComment = geComment + "01"; break;
                    case 2: geComment = geComment + "02"; break;
                    case 3: geComment = geComment + "03"; break;
                    case 4: geComment = geComment + "04"; break;
                    case 5: geComment = geComment + "04"; break;
                    case 6: geComment = geComment + "05"; break;
                    case 7: geComment = geComment + "05"; break;
                    case 8: geComment = geComment + "06"; break;
                };
            };

            //end of general comment
            //aspect comment
            asComment = "";
            tmpcat = (ji.MatchCat % 100);
            if (ji.MatchMore)
            {
                asComment = "00";
                // return positive comments
                if (clvm == 1) { asComment = asComment + "10"; };
                if (clvm > 1) { asComment = asComment + "11"; };
                if (slvm == 1) { asComment = asComment + "12"; };
                if (slvm > 1) { asComment = asComment + "13"; };
            }
            else
            {
                switch (tmpcat)
                {
                    case 1: asComment = "01"; break;
                    case 2: asComment = "02"; break;
                    case 3: asComment = "03"; break;
                    case 4: asComment = "04"; break;
                    case 5: asComment = "05"; break;
                }
                //return negative comments
                if (cd > 1) { asComment = asComment + "01"; };
                if (cd == 1) { asComment = asComment + "02"; };
                if (cdnm > 1) { asComment = asComment + "03"; };
                if (cdnm == 1) { asComment = asComment + "04"; };
                if (sd > 1) { asComment = asComment + "05"; };
                if (sd == 1) { asComment = asComment + "06"; };
                if (sdnm > 3) { asComment = asComment + "07"; };
                if (od > 1) { asComment = asComment + "08"; };
                if (od == 1) { asComment = asComment + "09"; };
            };
            //end of aspect comments
            //start of level comments
            lvComment = "";
            int iLvlCount = 0;
            foreach (LevelResult lr in levelResultSet)
            {
                iLvlCount = (lr.LevelResponse == true) ? iLvlCount + 1 : iLvlCount;
            }
            if (iLvlCount == 0) { lvComment = "07"; }//mrm changed to use flags not levelResultSet.Count
            else
            {
                bool accept = true;      //if all levels are selected
                for (i = 1; i <= 5; i++) { if (levelvals[i] == false) { accept = false; };};
                if (accept == true) { lvComment = "06"; }
                else                  //else calc comments
                {
                    //mrm need to look at flags if (levelResultSet.Count > 1) { lvComment = "00"; };
                    if (iLvlCount > 1) { lvComment = "00"; };
                    x = 0;
                    for (i = 1; i <= 5; i++)
                    {

                        if (levelvals[i] == true) { x = i; };
                    }//get highest level
                    switch (rt["Education"].ToString().Substring(x - 1, 1))//mrm 19/4/2006 bug fix - was x
                    {
                        case "+": lvComment = lvComment + "01"; break;
                        case "A": lvComment = lvComment + "02"; break;
                        case "N": lvComment = lvComment + "03"; break;
                        case "B": lvComment = lvComment + "04"; break;
                        case "-": lvComment = lvComment + "05"; break;
                    }

                }
            };
            //end of level comments
            //skills comment

            int e1 = 0;
            int e2 = 0;
            int e3 = 0;
            int e4 = 0;
            int e5 = 0;
            int e0 = 0;
            int d1 = 0;
            int d2 = 0;
            int d3 = 0;
            int d4 = 0;
            int d5 = 0;
            int d0 = 0;
            if (rt["EssentialSkills"].ToString().Length > 0)
            {
                for (i = 0; i < rt["EssentialSkills"].ToString().Length; i = i + 3)
                {
                    SkillsResult skillsResult = skillsResultSet.Find(
                                                          delegate(SkillsResult sr)
                                                          {
                                                              return sr.SkillsRef == Convert.ToInt32(rt["EssentialSkills"].ToString().Substring(i, 3));
                                                          }
                                                          );
                    if (skillsResult != null)
                    {
                        switch (skillsResult.SkillsResponse)
                        {
                            case 0: e0 = e0 + 1; break;
                            case 1: e1 = e1 + 1; break;
                            case 2: e2 = e2 + 1; break;
                            case 3: e3 = e3 + 1; break;
                            case 4: e4 = e4 + 1; break;
                            case 5: e5 = e5 + 1; break;
                            default: e0 = e0 + 1; break;
                        }
                    }
                    else { e0 = e0 + 1; };
                }
            }
            if (rt["DesirableSkills"].ToString().Length > 0)
            {
                for (i = 0; i < rt["DesirableSkills"].ToString().Length; i = i + 3)
                {
                    SkillsResult skillsResult = skillsResultSet.Find(
                                                          delegate(SkillsResult sr)
                                                          {
                                                              return sr.SkillsRef == Convert.ToInt32(rt["DesirableSkills"].ToString().Substring(i, 3));
                                                          }
                                                          );
                    if (skillsResult != null)
                    {
                        switch (skillsResult.SkillsResponse)
                        {
                            case 0: d0 = d0 + 1; break;
                            case 1: d1 = d1 + 1; break;
                            case 2: d2 = d2 + 1; break;
                            case 3: d3 = d3 + 1; break;
                            case 4: d4 = d4 + 1; break;
                            case 5: d5 = d5 + 1; break;
                            default: d0 = d0 + 1; break;
                        }
                    }
                    else { d0 = d0 + 1; };
                }
            }
            // get skills cat
            JobList jl = new JobList();
            jl.Add(ji);
            getSkillsCategories(strCountry, jl, skillsResultSet);

            skcomment = "0" + ji.SkillsCat.ToString() + '0' + ji.SkillsCat.ToString();
            if (e2 == 1) { skcomment = skcomment + "01"; };
            if (e2 == 2) { skcomment = skcomment + "02"; };
            if (e2 == 3) { skcomment = skcomment + "03"; };
            if (e2 >= 4) { skcomment = skcomment + "04"; };
            if (e1 == 1) { skcomment = skcomment + "05"; };
            if (e1 == 2) { skcomment = skcomment + "06"; };
            if (e1 == 3) { skcomment = skcomment + "07"; };
            if (e1 == 4) { skcomment = skcomment + "08"; };
            if (e1 > 4) { skcomment = skcomment + "09"; };
            if (d2 == 1) { skcomment = skcomment + "10"; };
            if (d2 == 2) { skcomment = skcomment + "11"; };
            if (d2 == 3) { skcomment = skcomment + "12"; };
            if (d2 == 4) { skcomment = skcomment + "13"; };
            if (d2 == 5) { skcomment = skcomment + "14"; };
            if (d2 > 5) { skcomment = skcomment + "15"; };
            if (d1 == 1) { skcomment = skcomment + "16"; };
            if (d1 == 2) { skcomment = skcomment + "17"; };
            if (d1 == 3) { skcomment = skcomment + "18"; };
            if (d1 == 4) { skcomment = skcomment + "19"; };
            if (d1 == 5) { skcomment = skcomment + "20"; };
            if (d1 > 5) { skcomment = skcomment + "21"; };

            if (skcomment == "") { skcomment = "00"; };

            //end skills comment
            DataTable dt = new DataTable();
            dt.Columns.Add("General", typeof(string));
            dt.Columns.Add("Aspect", typeof(string));
            dt.Columns.Add("Level", typeof(string));
            dt.Columns.Add("Skill", typeof(string));
            dt.Rows.Add();
            dt.Rows[0]["General"] = geComment;
            dt.Rows[0]["Aspect"] = asComment;
            dt.Rows[0]["Level"] = lvComment;
            dt.Rows[0]["Skill"] = skcomment;
            return (dt);
            }
            else
            {
            //we didn't find the job aspects
            DataTable dt = new DataTable();
            return (dt);

            }
        }
Exemplo n.º 36
0
 public static JobList buildJobList(string strSuffixCode, string strCountry, AspectResultSet aspectResultSet, HealthResultSet healthResultSet, LevelResultSet levelResultSet)
 {
     //do a match
     JobList jl = new JobList();
     JobItem ji;
     string aspecttblname=strCountry;
     //mrm 15/8/2006 change SQL to exclude Talent jobs
     DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("MM_ALL_JOBST_" + strSuffixCode, "SELECT tblAspects" + aspecttblname + ".OccNumber, Central, Secondary, ID, Other, Education, EssentialSkills, DesirableSkills, Talent, OccName FROM Jobinfo" + strSuffixCode + " INNER JOIN tblAspects" + aspecttblname + " ON Jobinfo" + strSuffixCode + ".OccNumber = tblAspects" + aspecttblname + ".OccNumber WHERE (Talent IS NULL) or (Talent=0) ORDER BY OccName");
     bool [] levelvals= new bool[MaxNoOfLevels+1];
     bool [] healthvals= new bool[MaxNoOfHealth+1];
     int [] aspectres= new int[MaxNoOfAspects+1] ;
     CreateFastClientArrays(aspectResultSet, levelResultSet, healthResultSet, healthvals, levelvals, aspectres);
     foreach (DataRow rt in dtAspects.Rows)
     {
         ji = new JobItem();
         ji.Score = ScoreArticle(rt,healthvals,levelvals,aspectres,ref ji.MatchCat,ref ji.MatchMore);
         ji.JobRef = Convert.ToInt16(rt["OccNumber"].ToString());
         ji.JobTitle = rt["OccName"].ToString();// +ji.MatchCat.ToString();
         //JM 20/04/2006 don't add jobs where they are a poor match
         if (((int)ji.MatchCat/100)<6)
         {
             jl.Add(ji);
         };
     };
     jl.Sort(delegate (JobItem x, JobItem y){return Comparer.Default.Compare(y.Score,x.Score);});
     // we only want the top 40
     if (jl.Count > 40)
     {
         jl.RemoveRange(40, jl.Count - 40);
     };
     //prepare rank
     int i = 1;
     foreach (JobItem ji1 in jl)
     {
         ji1.Rank = i;
         i++;
     };
     return (jl);
 }
Exemplo n.º 37
0
        public static JobList buildJobList(string strSuffixCode, string strCountry, AspectResultSet aspectResultSet, HealthResultSet healthResultSet, LevelResultSet levelResultSet, string strClusterCode, string strCluster)
        {
            //do a match, but only include those inside a cluster
            JobList jl = new JobList();
            JobItem ji;
            string aspecttblname = strCountry;

            //mrm 15/8/2006 change SQL to exclude Talent jobs
            DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("MM_ALL_JOBST_" + strSuffixCode, "SELECT tblAspects" + aspecttblname + ".OccNumber, Central, Secondary, ID, Other, Education, EssentialSkills, DesirableSkills, Talent, OccName FROM Jobinfo" + strSuffixCode + " INNER JOIN tblAspects" + aspecttblname + " ON Jobinfo" + strSuffixCode + ".OccNumber = tblAspects" + aspecttblname + ".OccNumber WHERE (Talent IS NULL) or (Talent=0) ORDER BY OccName");
            bool[] levelvals = new bool[MaxNoOfLevels + 1];
            bool[] healthvals = new bool[MaxNoOfHealth + 1];
            int[] aspectres = new int[MaxNoOfAspects + 1];
            CreateFastClientArrays(aspectResultSet, levelResultSet, healthResultSet, healthvals, levelvals, aspectres);
            //set up arrays for fast matching
            foreach (DataRow rt in dtAspects.Rows)
            {
                ji = new JobItem();
                ji.Score = ScoreArticle(rt, healthvals, levelvals, aspectres, ref ji.MatchCat, ref ji.MatchMore);
                //get job score
                ji.JobRef = Convert.ToInt16(rt["OccNumber"].ToString());
                ji.JobTitle = rt["OccName"].ToString();
                if (((int)ji.MatchCat / 100) < 6)
                {
                    jl.Add(ji);
                };

            };
            //sort the list by score
            jl.Sort(delegate(JobItem x, JobItem y) { return Comparer.Default.Compare(y.Score, x.Score); });
            // we only want the top 40
            if (jl.Count > 40)
            {
                jl.RemoveRange(40, jl.Count - 40);
            };
            //prepare rank
            int i = 1;
            foreach (JobItem ji1 in jl)
            {
                ji1.Rank = i;
                i++;
            };
            //now we check against the clusters table
            //next section is more or less lifted from cluster.aspx
            DataTable dtCluster = CCLib.Cache.GetCachedDataTable("Cluster" + strSuffixCode , "select * from Clusters" + strSuffixCode + "_View");
            DataRow[] drsClusterCodes;
            string strClusterType = strCluster;
            string strSQL=strClusterType+"= '"+strClusterCode.Replace("'","''")+"' or "+strClusterType+" like '"+strClusterCode.Replace("'","''")+",%' or "+strClusterType+" like '%,"+strClusterCode.Replace("'","''")+"' or "+strClusterType+" like '%,"+strClusterCode.Replace("'","''")+",%'";
            drsClusterCodes = dtCluster.Select(strSQL);
            //yuk!! sequential search - need to check for better way
            JobList jlResultList = new JobList();
            JobItem jitmp;
            foreach (DataRow dr in drsClusterCodes)
            {
                int strOccNumber = (int)dr["OccNumber"]; //copy into local variable to keep things quick
                jitmp = jl.Find(delegate(JobItem ji1) { return ji1.JobRef == strOccNumber; });
                if (jitmp!=null) {jlResultList.Add(jitmp);};
            }
            jlResultList.Sort(delegate(JobItem x, JobItem y) { return Comparer.Default.Compare(y.Score, x.Score); });

            return (jlResultList);
        }
Exemplo n.º 38
0
        public static void StartTaskScheduler(Guid id)
        {
            if (scheduler != null)
            {
                scheduler.Stop();
                scheduler = null;
            }

            scheduler = new JobScheduler();
            scheduler.TimerInterval = 60000;//30 phút
            string status = string.Empty;
            JobItem task = new JobItem();
            var service = new BaseService();
            var lstObj = new List<object>();
            List<Sys_AutoBackup> listAutoBackup = new List<Sys_AutoBackup>();
            var lstAutoBackup = service.GetById<Sys_AutoBackup>(id, ref status);
            listAutoBackup.Add(lstAutoBackup);
            foreach (var autoBackup in listAutoBackup)
            {
                scheduler.TaskItems.Add(new JobItem
                {
                    Interval = autoBackup.TimeWaiting == null ? 0 : autoBackup.TimeWaiting.Value,
                    DateExpired = autoBackup.DateExpired,
                    DateStart = autoBackup.DateStart.Value,
                    Description = autoBackup.Description,
                    IsActivate = autoBackup.IsActivate == null ? false : autoBackup.IsActivate.Value,
                    LastStart = autoBackup.LastStart,
                    JobArgs = autoBackup.AutoBackupName
                    + "|" + autoBackup.ProcedureName
                    + "|" + autoBackup.Email,
                    JobType = autoBackup.AutoBackupName,
                    JobItemType = typeof(Task_AutoBackup),
                    Type = (SchedulerType)Enum.Parse(typeof(SchedulerType), autoBackup.Type.ToString()),

                });
            }
            scheduler.Start();
        }
Exemplo n.º 39
0
        public static JobList buildJobList( string strSuffixCode, string strCountry)
        {
            // build all jobs
            JobList jl = new JobList();
            JobItem ji;
            string aspecttblname = strCountry;

            DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("MM_ALL_JOBS_" + strSuffixCode, "SELECT tblAspects" + aspecttblname + ".OccNumber, Central, Secondary, ID, Other, Education, EssentialSkills, DesirableSkills, OccName FROM Jobinfo" + strSuffixCode + " INNER JOIN tblAspects" + aspecttblname + " ON Jobinfo" + strSuffixCode + ".OccNumber = tblAspects" + aspecttblname + ".OccNumber order by OccName");
            foreach (DataRow rt in dtAspects.Rows)
            {
                    ji = new JobItem();
                    ji.JobRef = Convert.ToInt16(rt["OccNumber"].ToString());
                    ji.JobTitle = rt["OccName"].ToString();
                    jl.Add(ji);
            };
            //prepare rank
            int i = 1;
            foreach (JobItem ji1 in jl)
            {
                ji1.Rank = i;
                i++;
            };

            return (jl);
        }