示例#1
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);
            }
        }