Esempio n. 1
0
        public static dynamic GetReturnObj(ISampleBaseInfo baseinfo)
        {
            using (SunginDataContext sc = new SunginDataContext())
            {
                IProofing pr = sc.Proofings.SingleOrDefault(p => p.StyleId == baseinfo.StyleId);
                if (pr == null)
                {
                    pr = new Proofing();
                }
                IProductionRecord pd = sc.ProductionRecords.SingleOrDefault(p => p.StyleId == baseinfo.StyleId);
                if (pd == null)
                {
                    pd = new ProductionRecord();
                }
                var    Files     = sc.StyleFiles.Where(p => !p.IsDelete && p.StyleId == baseinfo.StyleId).Select(p => new { p.DisplayName, p.FileName, p.FileType }).ToList();
                var    FirstPic  = Files.FirstOrDefault(p => p.FileType == FileType.Pic);
                var    StockData = sc.GarmentStocks.Where(p => !p.IsDelete && p.StyleId == baseinfo.StyleId).Select(p => new { size = p.Size, color = p.Color, num = p.Num }).ToList();
                string Pic       = FirstPic != null ? FirstPic.FileName : "";

                return(new
                {
                    baseinfo.Id,
                    baseinfo.StyleId,
                    baseinfo.StyleNo,
                    baseinfo.Color,
                    baseinfo.Weight,
                    baseinfo.Gauge,
                    baseinfo.Size,
                    baseinfo.Kinds,
                    baseinfo.CanLendOut,
                    baseinfo.HaveStock,
                    User = baseinfo.CreateUser,
                    baseinfo.State,
                    baseinfo.CostPrice,
                    baseinfo.FactoryPrice,
                    baseinfo.SalePrice,
                    baseinfo.DiscountPrice,
                    baseinfo.Counts,
                    StateText = baseinfo.State.ToString(),
                    StyleTag = JsonHelper.ToObj(baseinfo.StyleTag),
                    Material = JsonHelper.ToObj(baseinfo.Material),
                    CreateDate = baseinfo.CreateDate != null?baseinfo.CreateDate.Value.Date.ToShortDateString() : "",
                                     pr.ProofingCompany,
                                     pr.ProgamPeople,
                                     pr.TechnologyPeople,
                                     baseinfo.DeptName,
                                     pr.WeaveTime,
                                     pr.LinkTime,
                                     ProofingDate = pr.ProofingDate != null?pr.ProofingDate.Value.Date.ToShortDateString() : "",
                                                        pd.ClientName,
                                                        pd.ProductFactory,
                                                        pd.ProductNum,
                                                        pd.Price,
                                                        ProductDate = pd.ProductDate != null?pd.ProductDate.Value.ToShortDateString() : "",
                                                                          StockData,
                                                                          Pic,
                                                                          Files
                });
            }
        }
Esempio n. 2
0
 public bool LoadSampleById(string styleId)
 {
     try
     {
         using (SunginDataContext sc = new SunginDataContext())
         {
             BaseInfo     = sc.SampleBaseInfos.SingleOrDefault(p => p.StyleId == styleId);
             ProofingInfo = sc.Proofings.SingleOrDefault(p => p.StyleId == styleId);
             if (ProofingInfo == null)
             {
                 ProofingInfo = new Proofing();
             }
             ProductInfo = sc.ProductionRecords.SingleOrDefault(p => p.StyleId == styleId);
             if (ProductInfo == null)
             {
                 ProductInfo = new ProductionRecord();
             }
             StockList   = sc.GarmentStocks.Where(p => p.StyleId == styleId).ToList();
             Files       = sc.StyleFiles.Where(p => p.StyleId == BaseInfo.StyleId).ToList();
             IsNewSample = false;
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 3
0
 public IHttpActionResult GetRecentProducts(int MachineId)
 {
     try
     {
         List <ProductionRecord> Records = new List <ProductionRecord>();
         using (OracleConnection Con = new Oracle.ManagedDataAccess.Client.OracleConnection(Static.Secrets.ApiConnectionString))
         {
             using (var reader = Utilities.GetRecentProductData(MachineId, Con))
             {
                 while (reader.Read())
                 {
                     ProductionRecord pr = new ProductionRecord();
                     pr.ProductId     = Convert.ToInt32(reader["PRODUCT_ID"].ToString());
                     pr.ProductNumber = reader["PRODUCT_NR"].ToString();
                     pr.StartedOn     = Convert.ToDateTime(reader["STARTED_DATE"].ToString());
                     pr.FinishedOn    = Convert.ToDateTime(reader["FINISHED_DATE"].ToString());
                     pr.Quantity      = Convert.ToDouble(reader["QUANTITY"].ToString());
                     pr.QuantityKg    = Convert.ToDouble(reader["QUANTITY_KG"].ToString());
                     Records.Add(pr);
                 }
             }
             return(Ok(Records));
         }
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
        public void ModulePropertySet()
        {
            IModuleRecord moduleRecord = new ProductionRecord(location, recordId);

            Assert.That(moduleRecord, Is.Not.Null);
            Assert.That(moduleRecord.Location, Is.EqualTo(location));
            Assert.That(moduleRecord.Module, Is.EqualTo(module));
            Assert.That(moduleRecord.RecordId, Is.EqualTo(recordId));
        }
Esempio n. 5
0
        public string GetTaskSummary(string startDate, string endDate, string machineNo, string machineGroup, string machineModel, string pdLine)
        {
            TaskSummary summary = new TaskSummary();

            summary.StartTime = string.IsNullOrEmpty(startDate) ? DateTime.Now.Date : Convert.ToDateTime(startDate).Date;
            summary.EndTime   = string.IsNullOrEmpty(endDate) ? DateTime.Now.Date : Convert.ToDateTime(endDate).Date;

            var result = _context.JobTasks.Include(c => c.JobEntity)
                         .Include(c => c.Machine)
                         .Include(c => c.JobEntity)
                         .Where(x => x.StartDate.Date >= summary.StartTime.Date &&
                                x.StartDate.Date <= summary.EndTime.Date &&
                                x.ReleaseFlag &&
                                (string.IsNullOrEmpty(x.MachineNoReady) ? x.MachineNo : x.MachineNoReady) == machineNo)
                         .OrderBy(o => o.Priority)
                         .ThenBy(o => o.StartDate)
                         .ToList();

            machineGroup = machineGroup.Replace("- Optional -", string.Empty);
            pdLine       = pdLine.Replace("- Optional -", string.Empty);

            if (!string.IsNullOrEmpty(machineGroup))
            {
                result = result.Where(x => x.Machine.MacGroup == machineGroup).ToList();
            }
            if (!string.IsNullOrEmpty(machineModel))
            {
                result = result.Where(x => x.Machine.MachineModel == machineModel).ToList();
            }
            if (!string.IsNullOrEmpty(pdLine))
            {
                result = result.Where(x => x.Machine.ProductionLine == pdLine).ToList();
            }

            //Summaries
            summary.TasksAll = result;

            int i = 1;

            foreach (var item in summary.TasksAll.Where(x => !x.McFinishFlag && !x.CancelFlag).OrderBy(o => o.Priority).ToList())
            {
                TasksQueuing task = new TasksQueuing();
                task.Seq          = i;
                task.PartNumber   = item.JobEntity.PrimaryItemCode;
                task.MachineCode  = item.Machine.MachineCode;
                task.JobNumber    = item.JobEntity.JobEntityName;
                task.TableNumber  = item.TableNumber;
                task.DueDate      = item.DueDate;
                task.RequiredDate = item.EndDate.ToString("dd/MM/yyyy HH:mm");
                if (item.StartFlag)
                {
                    task.ProductionStatus = "Inprogress";
                }
                else
                {
                    task.ProductionStatus = "Pending";
                }

                summary.TasksQueuing.Add(task);
                i++;
            }

            foreach (var item in summary.TasksAll.Where(x => x.StartFlag && x.McFinishFlag && !x.CancelFlag).OrderBy(o => o.DueDate).ToList())
            {
                ProductionRecord rec = new ProductionRecord();
                rec.PartNumber  = item.JobEntity.PrimaryItemCode;
                rec.MachineNo   = item.Machine.MachineCode;
                rec.JobNumber   = item.JobEntity.JobEntityName;
                rec.TableNumber = item.TableNumber;
                rec.DueDate     = item.DueDate;
                rec.NcFile      = item.NcFile;

                var      logs       = _context.TaskTransactionLogs.Where(x => x.TaskId == item.Id).ToList();
                DateTime startTime  = logs.Where(x => x.ActionName == "START").FirstOrDefault().ActionTimeStamp;
                DateTime finishTime = logs.Where(x => x.ActionName == "MC_FINISH").FirstOrDefault().ActionTimeStamp;

                rec.StartTime     = startTime.ToString("dd/MM/yyyy HH:mm");
                rec.FinishTime    = finishTime.ToString("dd/MM/yyyy HH:mm");
                rec.MachineTimeHr = (finishTime - startTime).TotalHours.ToString("#0.00");

                summary.TasksRecord.Add(rec);
                i++;
            }

            return(JsonConvert.SerializeObject(summary, new JsonSerializerSettings()
            {
                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
                Formatting = Formatting.Indented
            }));
        }