コード例 #1
0
ファイル: AutoScheule.cs プロジェクト: greatboxS/EKB_API
 private static Schedule GetOrderInformation(DataRow _row)
 {
     try
     {
         object PO_Cell = _row[(int)ColumnMapping.C_PO];
         if (PO_Cell != null)
         {
             string po = PO_Cell.ToString();
             if (po != "")
             {
                 Schedule PO = new Schedule
                 {
                     PoNumber      = ExcelHandle.Excel_GetCellText(_row, (int)ColumnMapping.C_PO),
                     Model         = ExcelHandle.Excel_GetCellText(_row, (int)ColumnMapping.C_MODEL_NO),
                     ModelName     = ExcelHandle.Excel_GetCellText(_row, (int)ColumnMapping.C_MODEL_NAME),
                     Article       = ExcelHandle.Excel_GetCellText(_row, (int)ColumnMapping.C_ARTICLE),
                     CuttingDate   = ExcelHandle.Excel_GetCellText(_row, (int)ColumnMapping.C_CUTTING_DATE),
                     StitchindDate = ExcelHandle.Excel_GetCellText(_row, (int)ColumnMapping.C_STITCHING_DATE),
                     Quantity      = ExcelHandle.Excel_GetCellNumber(_row, (int)ColumnMapping.C_QUANTITY),
                 };
                 return(PO);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
     return(null);
 }
コード例 #2
0
ファイル: AutoScheule.cs プロジェクト: greatboxS/EKB_API
        private void UpdateScheduleFile(FileInfo _lastFile, ScheduleClass _scheduleClass)
        {
            try
            {
                Random rd    = new Random();
                int    rdNum = rd.Next();

                //string newPath = $"C:\\Users\\kha.le\\Desktop\\{rdNum}.xlsm";
                string newPath = $"E:\\{rdNum}.xlsm";

                File.Copy(_lastFile.FullName, newPath);
                DataTable scheduleTb = ExcelHandle.ReadExcelTable(newPath, 0);
                Console.WriteLine("Reading file finished");
                File.Delete(newPath);
                if (scheduleTb == null)
                {
                    Console.WriteLine("Can't read the file");
                    return;
                }

                if (!IScheduleQuery.DeleteAllSchedule(_scheduleClass))
                {
                    return;
                }

                ProductionLine Line = new ProductionLine();
                foreach (DataRow row in scheduleTb.Rows)
                {
                    object Firstcell = row[(int)ColumnMapping.C_CFD];
                    object Pocell    = row[(int)ColumnMapping.C_PO];

                    string temp = Pocell != null?Pocell.ToString().Trim() : "";

                    if (Firstcell != null && temp == "")
                    {
                        if (Firstcell.ToString() != "")
                        {
                            string s = Firstcell.ToString().ToUpper().Replace(" ", "").Trim();
                            try
                            {
                                Line = IBuidingQuery.GetProductionLineByName(s);
                                Console.WriteLine($"Production Line: {Line.LineName}");
                            }
                            catch
                            {
                                Line = null;
                            }
                        }
                    }

                    if (Line == null)
                    {
                        continue;
                    }

                    Schedule PO = GetOrderInformation(row);

                    if (PO == null)
                    {
                        continue;
                    }

                    PO.Building_Id       = Line.Building_Id;
                    PO.ProductionLine_Id = Line.id;
                    PO.ScheduleClass_Id  = _scheduleClass.id;

                    if (IScheduleQuery.GetSchedule(PO) != null)
                    {
                        continue;
                    }

                    IScheduleQuery.AddNewScheule(PO);

                    Console.WriteLine($"Add new PO, ID: {PO.id}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());;
            }
        }