Beispiel #1
0
        public static void RunUnenforcedWorksOrders(List <THAS_CONNECT_GetCompletedWorksorders_Result> untriedWOs, int woCounter, thas01Entities thas01)
        {
            var thousCounter  = 0;
            var deadlockCount = 0;

            Logger.Log("Start Time: " + DateTime.Now);

            foreach (var wo in untriedWOs)
            {
                try
                {
                    woCounter++;
                    if (woCounter % 1000 == 0)
                    {
                        thousCounter += 1;
                        Logger.Log("Processed : " + thousCounter + "k records. Deadlock Count: " + deadlockCount + ". Time is now: " + DateTime.Now);
                    }
                }
                catch (Exception)
                {
                    deadlockCount++;
                }

                var origWOCostStatus = wo.WorksOrderCostStatusCode;
                var count            = 1;

                thas01.CostCompletedWO_CostWorksOrder(wo.WorksOrderNumber, "/A", 1);

                var thisWO = thas01.THAS_CONNECT_GetSingleWorksOrder(wo.WorksOrderNumber).First();

                //if (thisWO.WorksOrderStatusCode == 5)
                //{
                //    //Must have costed successfully
                //    Logger.Log(thisWO.WorksOrderNumber + " Has Been Costed Successfully. Works Order Cost Status: " + thisWO.WorksOrderCostStatusCode);
                //    count++;
                //}
                //else if (thisWO.WorksOrderCostStatusCode == 2)
                //{
                //    Logger.Log(thisWO.WorksOrderNumber + " Has Failed To Be Costed...");
                //    count++;
                //}
                while (thisWO.WorksOrderCostStatusCode == origWOCostStatus && count < 10)
                {
                    //Still ongoing
                    Logger.Log(thisWO.WorksOrderNumber + " Is Still Processing... Check " + count);
                    count++;
                }
            }
        }
Beispiel #2
0
        public static void RunErrorWorksOrders(List <THAS_CONNECT_GetCompletedWorksorders_Result> errorWOs, int woCounter, int woSuccessCounter, int woFailCounter, thas01Entities thas01)
        {
            foreach (var wo in errorWOs)
            {
                Logger.Log("WO Count: " + woCounter);
                woCounter++;

                var count = 1;
                Logger.Log("Attempting to Cost " + wo.WorksOrderNumber + "...");

                //prepare works order
                var woFromDb  = thas01.WorksOrders.Where(x => x.WorksOrderNumber == wo.WorksOrderNumber).First();
                var wotFromDb = thas01.WorksOrderTransfers.Where(x => x.WorksOrderNumber == wo.WorksOrderNumber).First();

                woFromDb.WorksOrderCostStatusCode  = 1;
                wotFromDb.WorksOrderCostStatusCode = 1;
                thas01.SaveChanges();

                //end works order preparation

                thas01.CostCompletedWO_CostWorksOrder(wo.WorksOrderNumber, "/A", 1);

                Logger.Log("Stored Procedure Finished Running...");


                var thisWO = thas01.THAS_CONNECT_GetSingleWorksOrder(wo.WorksOrderNumber).First();

                if (thisWO.WorksOrderStatusCode == 5)
                {
                    //Must have costed successfully
                    Logger.Log(thisWO.WorksOrderNumber + " Has Been Costed Successfully. Works Order Cost Status: " + thisWO.WorksOrderCostStatusCode + ". WO Success Count: " + woSuccessCounter);
                    woSuccessCounter++;
                }
                else if (thisWO.WorksOrderCostStatusCode == 2)
                {
                    Logger.Log(thisWO.WorksOrderNumber + " Has Failed To Be Costed..." + " WO Fail Count: " + woFailCounter);
                    woFailCounter++;
                }
                while (thisWO.WorksOrderCostStatusCode == 1 && count < 10)
                {
                    //Still ongoing
                    Logger.Log(thisWO.WorksOrderNumber + " Is Still Processing... Check " + count);
                    count++;
                }
            }
        }
Beispiel #3
0
        public static void RunEnforcedWorksOrders(List <THAS_CONNECT_GetCompletedWorksorders_Result> enforcedWOs, int woCounter, thas01Entities thas01)
        {
            var deadlockCount = 0;
            var thousCounter  = 0;

            Logger.Log("Start Time: " + DateTime.Now);

            foreach (var wo in enforcedWOs)
            {
                try
                {
                    woCounter++;
                    if (woCounter % 1000 == 0)
                    {
                        thousCounter += 1;
                        Logger.Log("Processed : " + thousCounter + "k records. Time is now: " + DateTime.Now);
                    }

                    var count = 1;

                    ////prepare works order
                    //var woFromDb = thas01.WorksOrders.Where(x => x.WorksOrderNumber == wo.WorksOrderNumber).First();
                    //var wotFromDb = thas01.WorksOrderTransfers.Where(x => x.WorksOrderNumber == wo.WorksOrderNumber).First();

                    //woFromDb.WorksOrderCostStatusCode = 3;
                    //wotFromDb.WorksOrderCostStatusCode = 3;
                    //wotFromDb.IsEnforced = true;
                    //thas01.SaveChanges();

                    //end works order preparation

                    thas01.CostCompletedWO_CostWorksOrder(wo.WorksOrderNumber, "/A", 1);

                    //Logger.Log("Stored Procedure Finished Running...");

                    var thisWO = thas01.THAS_CONNECT_GetSingleWorksOrder(wo.WorksOrderNumber).First();

                    //if (thisWO.WorksOrderStatusCode == 5)
                    //{
                    //    //Must have costed successfully
                    //    Logger.Log(thisWO.WorksOrderNumber + " Has Been Costed Successfully. Works Order Cost Status: " + thisWO.WorksOrderCostStatusCode + ". WO Success Count: " + woSuccessCounter);
                    //    woSuccessCounter++;
                    //}
                    //else if (thisWO.WorksOrderCostStatusCode == 2)
                    //{
                    //    Logger.Log(thisWO.WorksOrderNumber + " Has Failed To Be Costed..." + " WO Fail Count: " + woFailCounter);
                    //    woFailCounter++;
                    //}
                    while (thisWO.WorksOrderCostStatusCode == 1 && count < 10)
                    {
                        //Still ongoing
                        Logger.Log(thisWO.WorksOrderNumber + " Is Still Processing... Check " + count);
                        count++;
                    }
                }
                catch (Exception)
                {
                    deadlockCount++;
                }
            }
        }