Пример #1
0
        public static DayTotals LoadDay(string shift, int month, int day, int year)
        {
            string        path_     = shift == "Day" ? $@"{Global.Strings.DayShiftDirectory}Totals/" : $@"{Global.Strings.SwingShiftDirectory}Totals/";
            DayTotals     dt        = new DayTotals();
            XmlSerializer formatter = new XmlSerializer(dt.GetType());
            FileStream    file      = new FileStream($@"{path_}{month}-{day}-{year}.xml", FileMode.Open);

            byte[] buffer = new byte[file.Length];
            file.Read(buffer, 0, (int)file.Length);
            MemoryStream stream = new MemoryStream(buffer);

            dt = (DayTotals)formatter.Deserialize(stream);
            file.Close();
            file.Dispose();
            return(dt);
        }
Пример #2
0
 public static void SaveToday(DateTime dateTime, string shift)
 {
     if (shift == "Day")
     {
         string        path      = $@"{Global.Strings.DayShiftDirectory}Totals/{dateTime.Month}-{dateTime.Day}-{dateTime.Year}.xml";
         FileStream    outFile   = File.Create(path);
         DayTotals     dt        = BuildTotalsData(dateTime);
         XmlSerializer formatter = new XmlSerializer(dt.GetType());
         formatter.Serialize(outFile, dt);
         outFile.Close();
         outFile.Dispose();
     }
     if (shift == "Swing")
     {
         string        path      = $@"{Global.Strings.SwingShiftDirectory}Totals/{dateTime.Month}-{dateTime.Day}-{dateTime.Year}.xml";
         FileStream    outFile   = File.Create(path);
         DayTotals     dt        = BuildTotalsData(dateTime);
         XmlSerializer formatter = new XmlSerializer(dt.GetType());
         formatter.Serialize(outFile, dt);
         outFile.Close();
         outFile.Dispose();
     }
 }
Пример #3
0
        public static List <DayTotals> LoadMonth(string shift, int monthNumber, int yearNumber)
        {
            string           path_ = shift == "Day" ? $@"{Global.Strings.DayShiftDirectory}Totals/" : $@"{Global.Strings.SwingShiftDirectory}Totals/";
            List <DayTotals> dtL   = new List <DayTotals>();

            for (int i = 1; i < 32; i++)
            {
                if (File.Exists($@"{path_}{monthNumber}-{i}-{yearNumber}.xml"))
                {
                    DayTotals     dt        = new DayTotals();
                    XmlSerializer formatter = new XmlSerializer(dt.GetType());
                    FileStream    file      = new FileStream($@"{path_}{monthNumber}-{i}-{yearNumber}.xml", FileMode.Open);
                    byte[]        buffer    = new byte[file.Length];
                    file.Read(buffer, 0, (int)file.Length);
                    MemoryStream stream = new MemoryStream(buffer);
                    dt = (DayTotals)formatter.Deserialize(stream);
                    dtL.Add(dt);
                    file.Close();
                    file.Dispose();
                }
            }
            return(dtL);
        }
Пример #4
0
                // build day file path
                public static void LoadMP()
                {
                    System.Threading.Thread.Sleep(Ints.RTLoadSeed);
                    string path_ = Strings.Shift == "Day" ? $@"{Global.Strings.DayShiftDirectory}Totals/" : $@"{Global.Strings.SwingShiftDirectory}Totals/";

                    if (File.Exists($@"{path_}{Other.CurrentDate.Month}-{Other.CurrentDate.Day}-{Other.CurrentDate.Year}.xml"))
                    {
                        Random r        = new Random();
                        string tempFile = $"{r.Next(9999)}.xml";
                        File.Copy($@"{path_}{Other.CurrentDate.Month}-{Other.CurrentDate.Day}-{Other.CurrentDate.Year}.xml", $@"{tempFile}");
                        DayTotals     dt        = new DayTotals();
                        XmlSerializer formatter = new XmlSerializer(dt.GetType());
                        FileStream    file      = new FileStream($@"{tempFile}", FileMode.Open);
                        byte[]        buffer    = new byte[file.Length];
                        file.Read(buffer, 0, (int)file.Length);
                        MemoryStream stream = new MemoryStream(buffer);
                        dt           = (DayTotals)formatter.Deserialize(stream);
                        Dec.ManPower = dt.Manpower;
                        file.Close();
                        File.Delete($@"{tempFile}");
                        file.Dispose();
                        Forms.ClockOut.SetMP();
                    }
                }
Пример #5
0
        private static DayTotals BuildTotalsData(DateTime dateTime)
        {
            //create new day totals
            DayTotals dt = new DayTotals();

            //LINQ querry for all area trays
            var APLTrays     = from Tray in Global.Enumerables.Data where Tray.Area == "APL" select Tray;
            var DAYTONATrays = from Tray in Global.Enumerables.Data where Tray.Area == "DAYTONA" select Tray;
            var ANCATrays    = from Tray in Global.Enumerables.Data where Tray.Area == "ANCA" select Tray;
            var LSSMTrays    = from Tray in Global.Enumerables.Data where Tray.Area == "LSSM" select Tray;
            var ACETrays     = from Tray in Global.Enumerables.Data where Tray.Area == "ACE" select Tray;
            var RADIUSTrays  = from Tray in Global.Enumerables.Data where Tray.Area == "RADIUS" select Tray;
            var EDMTrays     = from Tray in Global.Enumerables.Data where Tray.Area == "EDM" select Tray;

            //get all area workers
            #region APL

            // iterate over each tray in area
            foreach (Tray t in APLTrays)
            {
                // if initials not in area workers
                if (!dt.APLWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.APLWorkers.Add(t.RanBy);
                }
            }
            #endregion
            #region DAYTONA

            // iterate over each tray in area
            foreach (Tray t in DAYTONATrays)
            {
                // if initials not in area workers
                if (!dt.DAYTONAWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.DAYTONAWorkers.Add(t.RanBy);
                }
            }
            #endregion
            #region ANCA

            // iterate over each tray in area
            foreach (Tray t in ANCATrays)
            {
                // if initials not in area workers
                if (!dt.ANCAWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.ANCAWorkers.Add(t.RanBy);
                }
            }
            #endregion
            #region LSSM

            // iterate over each tray in area
            foreach (Tray t in LSSMTrays)
            {
                // if initials not in area workers
                if (!dt.LSSMWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.LSSMWorkers.Add(t.RanBy);
                }
            }
            #endregion
            #region ACE

            // iterate over each tray in area
            foreach (Tray t in ACETrays)
            {
                // if initials not in area workers
                if (!dt.ACEWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.ACEWorkers.Add(t.RanBy);
                }
            }
            #endregion
            #region EDM

            // iterate over each tray in area
            foreach (Tray t in EDMTrays)
            {
                // if initials not in area workers
                if (!dt.EDMWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.EDMWorkers.Add(t.RanBy);
                }
            }
            #endregion
            #region RADIUS

            // iterate over each tray in area
            foreach (Tray t in RADIUSTrays)
            {
                // if initials not in area workers
                if (!dt.RADIUSWorkers.Contains(t.RanBy))
                {
                    // add to area workers
                    dt.RADIUSWorkers.Add(t.RanBy);
                }
            }
            #endregion

            dt.APLTotals     = Global.Enumerables.APLTotals[0];
            dt.DAYTONATotals = Global.Enumerables.DAYTONATotals[0];
            dt.ANCATotals    = Global.Enumerables.ANCATotals[0];
            dt.LSSMTotals    = Global.Enumerables.LSSMTotals[0];
            dt.ACETotals     = Global.Enumerables.ACETotals[0];
            dt.RADIUSTotals  = Global.Enumerables.RADIUSTotals[0];
            dt.EDMTotals     = Global.Enumerables.EDMTotals[0];
            dt.ShiftTotals   = Global.Enumerables.TotalsAndBlockTotals[0];
            dt.Manpower      = Global.Dec.ManPower;
            dt.Date          = dateTime.Date;

            return(dt);
        }