Пример #1
0
        public void loadF741(string path, out Dictionary <String, F741> hF741)
        {
            hF741 = new Dictionary <string, F741>();
            String[] lines = File.ReadAllLines(path);
            String   key;
            Int32    recordCount = 0;

            foreach (String item in lines)
            {
                recordCount++;
                F741 f = new F741();
                if (Array.FindAll(notValidString, x => x == item).Count() == 0)
                {
                    f   = defineF741Layout(item);
                    key = f.BldngGl + f.MntcWork + f.MntcLabel;
                    if (!hF741.ContainsKey(key))
                    {
                        hF741.Add(key, f);
                    }
                    else
                    {
                        if (Int32.Parse(hF741[key].LastDone) >= Int32.Parse(f.LastDone))
                        {
                            Console.WriteLine("F741 Contains" + key);
                        }
                        else
                        {
                            hF741[key] = f;
                        }
                    }
                }
            }
            Console.WriteLine("F741 Contains {0} records", recordCount);
        }
Пример #2
0
        private F741 defineF741Layout(String record)
        {
            F741 f741 = new F741();

            f741.BldngGl     = record.Substring(0, 5);
            f741.MntcWork    = record.Substring(5, 3);
            f741.MntcLabel   = record.Substring(8, 2);
            f741.LastHistory = record.Substring(10, 6);
            DateTime       x;
            CultureInfo    culture = CultureInfo.InvariantCulture;
            DateTimeStyles ds;

            String[] str = { "yyyyMMdd" };
            ds = DateTimeStyles.None;
            if (record.Substring(16, 6).Trim().Equals(String.Empty))
            {
                f741.LastDone = record.Substring(16, 6);
            }
            else if (DateTime.TryParseExact(record.Substring(16, 6) + "01", str, culture, ds, out x))
            {
                f741.LastDone = record.Substring(16, 6);
            }
            else
            {
                MessageBox.Show("Error : " + record);
            }
            f741.NextPlan        = record.Substring(22, 6);
            f741.TextRemarks     = record.Substring(28, 120);
            f741.WorkStatus      = record.Substring(148, 1);
            f741.LastDateInspect = record.Substring(149, 6);
            return(f741);
        }
Пример #3
0
        private String formatF741Object(F741 f741)
        {
            String line =
                f741.BldngGl.PadRight(5) +
                f741.MntcWork.PadRight(3) +
                f741.MntcLabel.PadRight(2) +
                f741.LastHistory.PadRight(6) +
                f741.LastDone.PadRight(6) +
                f741.NextPlan.PadRight(6) +
                f741.TextRemarks.PadRight(120) +
                f741.WorkStatus.PadRight(1) +
                f741.LastDateInspect.PadRight(6);

            return(line);
        }
        public void CritNonCritEscalatorWorks(XSSFSheet sheet, List <F820> F820s, out List <F741> F741s)
        {
            F741s = new List <F741>();
            F741 f741;
            Cell cell = null;

            String[] workArray;
            foreach (Row row in sheet)
            {
                f741 = new F741();
                cell = row.getCell(2);
                if (String.IsNullOrEmpty(cell.ToString()))
                {
                    continue;
                }
                f741.BldngGl = cell.ToString().Trim();
                cell         = row.getCell(9); //Last Done Date
                lastDone     = cell.ToString().Trim();

                DateTime.TryParse(lastDone, out result);
                if (result == null)
                {
                    lastDone = "000101";
                }
                else
                {
                    if ((!lastDone.Equals("/") && !String.IsNullOrEmpty(lastDone)) &&
                        result.Year.ToString("0000") == "0001")
                    {
                        continue;
                    }
                    lastDone = result.Year.ToString("0000") + result.Month.ToString("00");
                }
                f741.WorkStatus = "A";
                if (lastDone.Equals("000101"))
                {
                    f741.WorkStatus = "Q";
                }
                f741.LastDone = lastDone;
                cell          = row.getCell(13); //Text Remarks
                if (String.IsNullOrEmpty(cell.ToString()))
                {
                    f741.TextRemarks = String.Empty;
                }
                else
                {
                    if (cell.ToString().Trim().Length >= 118)
                    {
                        f741.TextRemarks = cell.ToString().Trim().Substring(0, 115);
                    }
                    else
                    {
                        f741.TextRemarks = cell.ToString().Trim();
                    }
                }
                cell      = row.getCell(8); //ESC - Work
                workArray = cell.ToString().Split(new char[] { '-' });
                label     = workArray[0].ToString().Substring(5, 2);
                works     = "ESC - " + workArray[1].ToString().Trim();

                cell = row.getCell(14); //Last Date Inspect
                if (!String.IsNullOrEmpty(cell.ToString()))
                {
                    dateInspect = cell.ToString().Trim();
                    DateTime.TryParse(dateInspect, out result);
                    if (result == null)
                    {
                        dateInspect = "";
                    }
                    else
                    {
                        dateInspect = result.Year.ToString("0000") + result.Month.ToString("00");
                    }
                }
                else
                {
                    dateInspect = "";
                }
                f741.LastDateInspect = dateInspect;

                F820 f820 = F820s.Find(x => x.Description.Trim().Equals(works));
                workCode         = f820.MntcWork;
                f741.MntcWork    = workCode;
                f741.MntcLabel   = label;
                f741.LastHistory = "";
                f741.NextPlan    = "";
                F741s.Add(f741);
                //Test
            }
        }
Пример #5
0
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            if (lstOldF741.Count == 0 ||
                lstF820.Count == 0 ||
                lstNewF741.Count == 0 ||
                lstTurnOnDate.Count == 0)
            {
                MessageBox.Show("Please load input files.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            gbProgrss.Visibility = Visibility.Visible;
            pb1.Maximum          = lstOldF741.Count;
            Object        countLock = new Object();
            String        key;
            F741          outF741 = null, newF741;
            List <F741>   lstOutputF741 = new List <F741>();
            List <F741>   lstWriteF741  = new List <F741>();
            Int32         tmpNextSched;
            List <String> liftWorks = new List <String> {
                "10A", "100", "101", "102", "103",
                "104", "105", "106", "109", "110", "111"
            };
            String keyTurnedOn = "";

            foreach (F741 f741 in lstOldF741)
            {
                ExcelUtilities.App.DoEvents();

                //pb1.Dispatcher.Invoke(DispatcherPriority.Normal,
                //     new Action(() =>
                //     {
                //         ExcelUtilities.App.DoEvents();
                //         pb1.Value++;
                //         gbProgrss.Header = String.Format("Processing {0} of {1}", pb1.Value, pb1.Maximum);
                //     }));
                //ExcelUtilities.App.DoEvents();
                pb1.Value++;
                gbProgrss.Header = String.Format("Processing {0} of {1}", pb1.Value, pb1.Maximum);
                key = f741.BldngGl + f741.MntcWork + f741.MntcLabel;
                F741 value;

                if (hNewF741.TryGetValue(key, out value))
                {
                    newF741 = value;
                }
                else
                {
                    newF741 = null;
                }

                if (newF741 != null)
                {
                    if (liftWorks.Contains(newF741.MntcWork))
                    {
                        keyTurnedOn = f741.BldngGl + f741.MntcLabel;
                        outF741     = activateLift(keyTurnedOn, f741, newF741);
                        //Lift
                    }
                    else
                    {
                        //Non Lift
                        if (!f741.LastDone.Trim().Equals(""))
                        {
                            if (f741.LastDone.Trim().Equals(""))
                            {
                                f741.LastDone = "000101";
                            }
                            if (Int32.Parse(newF741.LastDone.Substring(0, 4)) >= Int32.Parse(f741.LastDone.Substring(0, 4)))
                            {
                                if (newF741.LastDone == "000101")
                                {
                                    outF741            = newF741;
                                    outF741.WorkStatus = "Q";
                                }
                                else
                                {
                                    outF741 = newF741;
                                    F820 f820 = lstF820.Find(x => x.MntcWork == outF741.MntcWork);
                                    tmpNextSched = Int32.Parse(newF741.LastDone) +
                                                   (Int32.Parse(f820.CycleYear) * 100);
                                    outF741.LastHistory = f741.LastDone.ToString();
                                    outF741.NextPlan    = tmpNextSched.ToString("000000");
                                }
                            }
                            else if (newF741.LastDone == "000101")
                            {
                                outF741            = newF741;
                                outF741.WorkStatus = "Q";
                            }
                            else if (Int32.Parse(newF741.LastDone.Substring(0, 4)) <= Int32.Parse(f741.LastDone.Substring(0, 4)))
                            {
                                outF741 = newF741;
                                outF741.LastDateInspect = "      ";
                            }
                        }
                        else
                        {
                            outF741 = f741;
                            outF741.LastDateInspect = "";
                        }
                    }
                }
                else
                {
                    outF741 = f741;
                    outF741.LastDateInspect = "      ";
                }
                lstOutputF741.Add(outF741);
            }

            maxBatteryDate(lstOutputF741, out lstWriteF741);
            WriteFiles writeFiles = new WriteFiles();

            writeFiles.WriteF741(lstWriteF741, txtOutput.Text, pb1);
        }
Пример #6
0
        private F741 activateLift(String key, F741 f741, F741 newF741)
        {
            F741   liftF741 = new F741();
            F741   value;
            F741   f7, f7Old;
            Int32  tmpSched   = 0;
            String keyOldF741 = f741.BldngGl + "10A" + f741.MntcLabel;

            if (hTurnOnDate.TryGetValue(key, out value))
            {
                f7 = value;
            }
            else
            {
                f7 = null;
            }
            if (hOldF741.TryGetValue(keyOldF741, out value))
            {
                f7Old = value;
            }
            else
            {
                f7Old = null;
            }

            if (f7 == null)
            {
                if (newF741.LastDone.Trim().Equals("000101") && !(newF741.MntcWork.Trim().Equals("104")))
                {
                    liftF741             = newF741;
                    liftF741.LastHistory = f741.LastDone;
                    liftF741.WorkStatus  = "Q";
                }
                else if (Int32.Parse(newF741.LastDone.Substring(0, 4)) > Int32.Parse(f741.LastDone.Substring(0, 4)))
                {
                    if (Int32.Parse(newF741.LastDone.Substring(0, 6)) > Int32.Parse(dtpUpdate.Text))
                    {
                        liftF741 = f741;
                    }
                    else
                    {
                        liftF741 = newF741;
                        F820 f820 = lstF820.Find(f8 => f8.MntcWork == liftF741.MntcWork);
                        tmpSched             = Int32.Parse(newF741.LastDone) + (Int32.Parse(f820.CycleYear) * 100);
                        liftF741.LastHistory = f741.LastDone.ToString();
                        liftF741.NextPlan    = tmpSched.ToString("000000");
                    }
                }
                else
                {
                    liftF741 = f741;
                }
            }
            else if (f7 != null && f7Old == null)
            {
                liftF741 = f741;
            }
            else if (f7 != null && f7Old != null)
            {
                if (!f7.LastDone.Trim().Equals("000101"))
                {
                    if (newF741.LastDone.Trim().Equals("000101") && !newF741.LastDone.Trim().Equals("104"))
                    {
                        liftF741             = newF741;
                        liftF741.LastHistory = f741.LastDone;
                        liftF741.WorkStatus  = "Q";
                    }
                    else if (Int32.Parse(f7.LastDone.Substring(0, 4)) > Int32.Parse(f741.LastDone.Substring(0, 4)))
                    {
                        if (Int32.Parse(f7.LastDone.Substring(0, 6)) > Int32.Parse(dtpUpdate.Text))
                        {
                            liftF741 = f741;
                        }
                        else
                        {
                            liftF741             = new F741();
                            liftF741.BldngGl     = f7.BldngGl;
                            liftF741.WorkStatus  = "A";
                            liftF741.TextRemarks = f7.TextRemarks;
                            liftF741.MntcLabel   = f7.MntcLabel;
                            liftF741.MntcWork    = f7.MntcWork;
                            F820 f820 = lstF820.Find(f8 => f8.MntcWork == liftF741.MntcWork);
                            tmpSched             = Int32.Parse(f7.LastDone) + (Int32.Parse(f820.CycleYear) * 100);
                            liftF741.LastDone    = f7.LastDone;
                            liftF741.LastHistory = f741.LastDone.ToString();
                            liftF741.NextPlan    = tmpSched.ToString("000000");
                        }
                    }
                    else if (Int32.Parse(newF741.LastDone.Substring(0, 4)) > Int32.Parse(f741.LastDone.Substring(0, 4)))
                    {
                        if (Int32.Parse(newF741.LastDone.Substring(0, 6)) > Int32.Parse(dtpUpdate.Text))
                        {
                            liftF741 = f741;
                        }
                        else
                        {
                            liftF741 = newF741;
                            F820 f820 = lstF820.Find(f8 => f8.MntcWork == liftF741.MntcWork);
                            tmpSched             = Int32.Parse(newF741.LastDone) + (Int32.Parse(f820.CycleYear) * 100);
                            liftF741.LastHistory = f741.LastDone.ToString();
                            liftF741.NextPlan    = tmpSched.ToString("000000");
                        }
                    }
                }
                else
                {
                    liftF741 = newF741;
                }
            }
            return(liftF741);
        }