Exemplo n.º 1
0
 public JobHelper(JobHeader job)
 {
     log      = new Scribe(System.Web.HttpContext.Current.Server.MapPath("~/logs"), "JobHelper_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".log");
     dbServer = WebConfigurationManager.AppSettings.Get("DBServer");
     dbName   = WebConfigurationManager.AppSettings.Get("DBName");
     this.Job = job;
 }
Exemplo n.º 2
0
            public void ShouldReturnGuid()
            {
                JobData data = Jobs.TickTockData;

                JobHeader header = repository.New(data);

                header.Identifier.Should().NotBeEmpty();
            }
Exemplo n.º 3
0
 public JobDataHandler(JobHeader job, string dbServer, string dbName) : base(dbServer)
 {
     this.log                  = new Scribe(System.Web.HttpContext.Current.Server.MapPath("~/logs"), "JobDataHandler_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".log");
     this.dbServer             = dbServer;
     this.dbName               = dbName;
     this.dataConnectionString = GetDataConnectionString();
     this.Job                  = job;
 }
Exemplo n.º 4
0
            public void ShouldReturnFirstVersion()
            {
                JobData data = Jobs.TickTockData;

                JobHeader header = repository.New(data);

                header.Version.Should().Be(1);
            }
Exemplo n.º 5
0
        public void UpdatingJobShouldReturnNextVersion()
        {
            JobData   data    = Jobs.TickTockData;
            JobHeader created = repository.New(data);

            JobData   upgrade = Jobs.TickTockDataV2;
            JobHeader header  = repository.Update(created.Identifier, upgrade);

            header.Version.Should().Be(created.Version + 1);
        }
Exemplo n.º 6
0
            private new JobHeader Add(JobData data)
            {
                JobHeader header = new JobHeader
                {
                    Identifier = Guid.NewGuid(),
                    Version    = 1
                };

                items[header] = data;
                return(header);
            }
Exemplo n.º 7
0
        private new JobExecution Add(JobHeader job)
        {
            JobExecution execution = new JobExecution
            {
                Identifier = Guid.NewGuid(),
                Job        = job,
            };

            items.Add(execution);
            return(execution);
        }
Exemplo n.º 8
0
        public void RequestingAddedJobShouldReturnItsIdentifier()
        {
            JobData   data    = Jobs.TickTockData;
            JobHeader created = repository.New(data);

            Job job = repository.Single(with =>
            {
                with.Identifier = created.Identifier;
            });

            job.Header.Identifier.Should().Be(created.Identifier);
        }
Exemplo n.º 9
0
        public void RequestingJobByNotUpgradedVersionShouldReturnNull()
        {
            JobData   data    = Jobs.TickTockData;
            JobHeader created = repository.New(data);

            Job job = repository.Single(with =>
            {
                with.Identifier = created.Identifier;
                with.Version    = created.Version + 1;
            });

            job.Should().BeNull();
        }
Exemplo n.º 10
0
    // Shows the elements of a JobHeader
    public String printJobHeader(JobHeader header)
    {
        String Output = " User " + header.jobParam.user
                        + "  JobID: " + header.jobId
                        + "  State: " + header.state.ToString()
                        + "  Progress: " + header.progress
                        + "  Rate: " + header.rate
                        + "  Prio: " + header.jobParam.prio
                        + header.jobParam.user
                        + "  Title: " + header.jobParam.title;

        return(Output);
    }
Exemplo n.º 11
0
        public void RequestingAddedJobShouldReturnItsData()
        {
            JobData   initial = Jobs.TickTockData;
            JobHeader created = repository.New(initial);

            Job job = repository.Single(with =>
            {
                with.Identifier = created.Identifier;
            });

            job.Extract(data =>
            {
                data.ShouldBeEquivalentTo(initial);
            });
        }
Exemplo n.º 12
0
        public void RequestingUpgradedJobByVersionShouldReturnRequestedVersion()
        {
            JobData   initial = Jobs.TickTockData;
            JobHeader created = repository.New(initial);

            JobData   upgrade = Jobs.TickTockDataV2;
            JobHeader header  = repository.Update(created.Identifier, upgrade);

            Job job = repository.Single(with =>
            {
                with.Identifier = created.Identifier;
                with.Version    = created.Version;
            });

            job.Extract(data =>
            {
                data.ShouldBeEquivalentTo(initial);
            });
        }
Exemplo n.º 13
0
        public async Task <Job> RequestNewJobAsync(TInput input, CancellationToken cancel)
        {
            var identifier = CreateJobIdentifier(Guid.NewGuid().ToString("N"));
            var header     = new JobHeader(identifier)
            {
                State   = JobState.Created,
                Created = DateTimeOffset.UtcNow
            };
            var job = new Job(header)
            {
                Input = _inputSerializer.Serialize(input)
            };
            await _repository.CreateAsync(job, cancel);

            using var publisher = _queue.GetPublisher(CreatePublisherConfiguration());
            await publisher.EnqueueAsync(job, cancel);

            return(job);
        }
Exemplo n.º 14
0
        public Response HandlePostJob(dynamic model)
        {
            JobData data = new JobData
            {
                Name        = model.name,
                Description = model.description,
                Executable  = model.executable,
                Arguments   = model.arguments,
                Blob        = model.blob
            };

            JobHeader header     = jobs.New(data);
            Guid      identifier = header.Identifier;

            return(Response.AsJson(new
            {
                id = identifier.ToHex()
            }));
        }
Exemplo n.º 15
0
        public bool LoadJobHeader(int jobID)
        {
            log.WriteLogEntry("Begin LoadJobHeader...");
            bool   result    = false;
            string cmdString = string.Format(@"select * from {0}.dbo.job_header where job_id = @jobID", dbName);

            log.WriteLogEntry("SQL command string: " + cmdString);
            using (SqlConnection conn = new SqlConnection(dataConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(cmdString, conn))
                {
                    cmd.Parameters.AddWithValue("@jobID", jobID);
                    try
                    {
                        conn.Open();
                        using (SqlDataReader rdr = cmd.ExecuteReader())
                        {
                            if (rdr.Read())
                            {
                                Job                = new JobHeader(jobID);
                                Job.TemplateID     = (int)rdr["template_id"];
                                Job.FormDataID     = (int)rdr["data_id"];
                                Job.JobDescription = rdr["job_description"].ToString();
                                var entryDate = rdr["entry_dt"];
                                if (entryDate != DBNull.Value)
                                {
                                    Job.EntryDate = DateTime.Parse(entryDate.ToString());
                                }
                                var completeDate = rdr["complete_dt"];
                                if (completeDate != DBNull.Value)
                                {
                                    Job.CompleteDate = DateTime.Parse(completeDate.ToString());
                                }
                                var duration = rdr["duration"];
                                if (duration != DBNull.Value)
                                {
                                    Job.Duration = (int)duration;
                                }
                                var jobPriority = rdr["job_priority"];
                                if (jobPriority != DBNull.Value)
                                {
                                    Job.JobPriority = (int)jobPriority;
                                }
                                var jobWeight = rdr["job_weight"];
                                if (jobWeight != DBNull.Value)
                                {
                                    Job.JobWeight = (int)jobWeight;
                                }
                                Job.JobType = rdr["job_type"].ToString();
                                log.WriteLogEntry("Job header retrieved " + jobID + " " + Job.JobDescription);
                                result = true;
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        result = false;
                        log.WriteLogEntry("SQL error " + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        result = false;
                        log.WriteLogEntry("General program error " + ex.Message);
                    }
                }
            }
            log.WriteLogEntry("End LoadJobHeader.");
            return(result);
        }
Exemplo n.º 16
0
 public void Job(JobHeader header, JobData data)
 {
     items[header] = data;
 }
Exemplo n.º 17
0
        private static void CreateOtherJobs()
        {
            const int MaxLength = 50;

            foreach (var item in JobXRefList.Where(x => x.OriginalJob.StartsWith("G") || x.OriginalJob.StartsWith("M") || x.OriginalJob.StartsWith("P") ||
                                                   x.OriginalJob.StartsWith("T") || x.OriginalJob.StartsWith("V")).OrderBy(x => x.OriginalJob))
            {
                var jobinfo = SageJobHeaders.FirstOrDefault(x => x.JobNo == item.OriginalJob);
                if (jobinfo == null)
                {
                    ErrorList += String.Format("Job Header not found for Job: {0}", item.OriginalJob);
                    ErrorList += Environment.NewLine;
                }
                var custinfo = currentCustomers.FirstOrDefault(x => x.CustID == jobinfo.CustomerNo);
                if (custinfo == null)
                {
                    MissingCustomers += String.Format("Customer {0} for Job {1} was not found in Epicor", jobinfo.CustomerNo, item.OriginalJob);
                    MissingCustomers += Environment.NewLine;

                    custinfo = new DMT05CustomerVUKMasterLoad
                    {
                    };
                }

                var partnum = jobinfo.JobDesc;
                if (partnum.Length > MaxLength)
                {
                    partnum = partnum.Substring(0, MaxLength);
                }
                var jobhead = new JobHeader
                {
                    Company         = CompanyID,
                    JobEngineered   = true,
                    JobFirm         = true,
                    JobReleased     = true,
                    JobNum          = item.NewJob,
                    PartNum         = partnum,
                    Plant           = "MfgSys",
                    CustID          = jobinfo.CustomerNo,
                    PartDescription = partnum,
                    ProdQty         = 1,
                    ReqDueDate      = jobinfo.ContractDate,
                    StartDate       = jobinfo.ContractDate,
                    SyncReqBy       = false,
                };

                if (String.IsNullOrEmpty(jobhead.ReqDueDate))
                {
                    jobhead.ReqDueDate = "01/01/2019";
                }
                JobHeaders.Add(jobhead);

                var op1 = new JobOperation
                {
                    Company          = CompanyID,
                    AssemblySeq      = 0,
                    OpCode           = item.OpCode,
                    OpComplete       = false,
                    OprSeq           = 10,
                    ProdStandard     = 0,
                    QtyCompleted     = 0,
                    StdFormat        = "HP",
                    LaborEntryMethod = "T",
                    JobNum           = jobhead.JobNum,
                    SchedRelation    = "FS",
                    Plant            = "MfgSys",
                    AutoReceive      = true,
                    FinalOpr         = true,
                };

                JobOperations.Add(op1);

                //int mtlseq = 10;

                var camtl = new JobMaterial
                {
                    Company = jobhead.Company,
                    JobNum  = jobhead.JobNum,
                    //Plant = jobhead.Plant,
                    IssuedComplete = true,
                    PartNum        = "CostAdjustment",
                    Description    = "CostAdjustment",
                    //MaterialMtlCost = 0,
                    MtlSeq           = 5,
                    QtyPer           = 1,
                    AssemblySeq      = 0,
                    FixedQty         = true,
                    RelatedOperation = 10
                                       //RequiredQty = 1
                };

                JobMaterials.Add(camtl);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Creates a new ModJob for the specific header.
 /// </summary>
 /// <param name="jobHeader">Header this job is for</param>
 /// <param name="mod">Mod object this job is for. This object is not saved and is only used to pull the path in and other necessary variables.</param>
 public ModJob(JobHeader jobHeader, Mod mod = null)
 {
     this.Header = jobHeader;
 }