Ejemplo n.º 1
0
        // Updating the buffer stock in the inventory catelogue table
        private static void UpdatingBufferStock()
        {
            using (SA45Team12AD context = new SA45Team12AD())
            {
                List <InventoryCatalogue> i = context.InventoryCatalogues.ToList();

                foreach (var item in i)
                {
                    bool canContinue = true;

                    // Gotta check if BFSProportion is zero  --  If it is, set bool to false
                    if (item.BFSProportion == 0 || item.BFSProportion == null)
                    {
                        canContinue = false;
                    }

                    if (canContinue)
                    {
                        PurchasingLogic.SetProportionalBFS(item.ItemID, (int)item.BFSProportion);
                    }
                    // Will not update those that have 0, i.e those that are manually set by the user.
                }
            }
        }
Ejemplo n.º 2
0
        // End of business day method
        public static void BeginEndOfDayProcesses(object sender, System.Timers.ElapsedEventArgs e)
        {
            // These lines of code will ensure that the reorder table is cleared at the end of each working day (about 6pm).
            DayOfWeek dayTodae = DateTime.Now.DayOfWeek;

            // Start message
            UpdateAutomationLog(DateTime.Now + ": Checking the day.", 1);


            // Checking for the right day aka weekday
            if (!dayTodae.Equals(DayOfWeek.Saturday) || !dayTodae.Equals(DayOfWeek.Sunday))
            {
                UpdateAutomationLog(DateTime.Now + ": EOD processes will begin as today is a weekday.", 1);

                // Init all req attrs
                bool isOverride  = false;
                bool rightHour   = false;
                bool rightMinute = false;
                bool rightSecond = false;
                int  hour;
                int  minute;
                int  second;
                int  targetHour   = 17;         // Change this to manually set our hour [For testing purposes - Default should be 17]
                int  targetMinute = 59;         // Change this to manually set our minute [For testing purposes - Default should be 59]


                // Checking for the right hour
                do
                {
                    hour = DateTime.Now.Hour;      // Retrieving current hour

                    if (hour == targetHour)
                    {
                        rightHour = true;
                        UpdateAutomationLog("Hour Checked: " + hour, 1);
                    }
                    else if (hour < targetHour)
                    {
                        Thread.Sleep(1 * 60 * 60 * 1000);  // Will sleep for 1hr before checking again
                    }
                    else
                    {
                        isOverride = true;
                        rightHour  = true;
                        UpdateAutomationLog(DateTime.Now + ": Unable to proceed as current time is beyond 6pm.", 1);
                    }
                } while (!rightHour);


                if (!isOverride)   // If it is not after 6.00pm (aka more than target hour)
                {
                    // Checking for the right minute
                    do
                    {
                        minute = DateTime.Now.Minute;    // Retrieving current minute

                        if (minute == targetMinute)
                        {
                            rightMinute = true;
                            UpdateAutomationLog("Minute Checked: " + minute, 1);
                        }
                        else
                        {
                            Thread.Sleep(10000);  // Wait 10s before checking again
                        }
                    } while (!rightMinute);

                    // Checking for the right second
                    do
                    {
                        second = DateTime.Now.Second;    // Retrieving current second

                        if (second == 59)
                        {
                            rightSecond = true;
                            Thread.Sleep(1000);   // Adds another milliseconds to make it a full minute.
                            UpdateAutomationLog("Second Checked: " + second, 1);
                        }
                    } while (!rightSecond);

                    if (rightHour && rightMinute && rightSecond)
                    {
                        // Performing our clearing code here
                        var temp = PurchasingLogic.PopulateReorderTable();

                        if (temp != null && temp.Count > 0)
                        {
                            string s = PurchasingLogic.CreateMultiplePO(temp);
                        }

                        UpdateAutomationLog(DateTime.Now + ": EOD processes successfully completed.", 1);
                    }
                }
                else
                {
                    UpdateAutomationLog(DateTime.Now + ": EOD processes will now stop as now is beyond the intended scheduled time.", 1);
                }
            }
            else
            {
                UpdateAutomationLog(DateTime.Now + ": Today is a " + dayTodae + ". Since it is a weekend, EOD processes will not be carried out.", 1);
            }
        }