Пример #1
0
        public void runExecution(byte session, string tableName)
        {
            var  taskList    = new List <Task>();
            var  listList    = automaticRejectionsObjectList.SplitOnAmountOfLists(session);
            byte realSession = Conversions.ToByte(session - 1);

            for (byte i = 0, loopTo = realSession; i <= loopTo; i++)
            {
                byte q = i; // multithreading issue solver
                taskList.Add(Task.Run(() => runSapSession(q, (List <RejectionsSapOrderProperty>)listList.ElementAtOrDefault(q), tableName)));
            }

            try {
                Task.WaitAll(taskList.ToArray());
            } catch (AggregateException ae) {
                foreach (var innerX in ae.InnerExceptions)
                {
                    GlobalErrorHandler.handle(salesOrg, isReleaseRejections ? "Release Rejections" : "After Release Rejections", innerX);
                }
            }

            while (realSession > 0)
            {
                var sap = Create.sapLib(realSession);
                sap.closeSessionWindow();
                realSession -= 1;
            }
        }
Пример #2
0
        public void runRejectionsInVA02(string email, IDBServerConnector dbServer, IMailUtil mu)
        {
            string tableName  = "RejectionsLog";
            int    orderCount = automaticRejectionsObjectList.Count;

            try {
                switch (orderCount)
                {
                case 1: {
                    // 1 session
                    runExecution(1, tableName);
                    break;
                }

                case int _ when orderCount < 5: {
                    // 2 sessions
                    runExecution(2, tableName);
                    break;
                }

                case int _ when orderCount > 4: {
                    // 3 sessions
                    runExecution(3, tableName);
                    break;
                }
                }
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "After release rejections", ex);
                sendFailedRejections(salesOrg, email, dbServer, mu);
            }
        }
Пример #3
0
        public async Task <IActionResult> ListUrl(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req)
        {
            _logger.LogInformation($"HTTP trigger function processed a request for {nameof(ListUrl)}.");

            return(await GlobalErrorHandler.HandleExceptionAsync(async() => await ListUrlAction(req), _logger));
        }
Пример #4
0
        public async Task <IActionResult> RedirectUrl(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "UrlRedirect/{shortUrl}")] HttpRequest req,
            string shortUrl)
        {
            _logger.LogInformation($"HTTP trigger function processed a request for {nameof(RedirectUrl)} with parameter '{shortUrl}'.");

            return(await GlobalErrorHandler.HandleExceptionAsync(async() => await RedirectUrlAction(req, shortUrl), _logger));
        }
Пример #5
0
        static void Main(string[] args)
        {
            bool   newMutexCreated = false;
            string mutexName       = "Local\\" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            Mutex  mutex           = null;

            try
            {
                mutex = new Mutex(false, mutexName, out newMutexCreated);
            }
            catch
            {
            }

            if (newMutexCreated)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GlobalErrorHandler.Initialize();
                Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

                NonAdminComRegistration.Register <ImageChatNodeProtocol>();
                ImageChatNodeProtocol.RegisterTemporary();

                var win = new MainWindow(args);

                Application.Run(win);

                ImageChatNodeProtocol.Unregister();
                NonAdminComRegistration.Unregister <ImageChatNodeProtocol>();
            }
            else
            {
                Process[] currentProcesses = (from p in Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName)
                                              where p.Id != Process.GetCurrentProcess().Id
                                              select p).ToArray();
                if (currentProcesses.Length > 0)
                {
                    IntPtr mainWindowHandle         = currentProcesses[0].MainWindowHandle;
                    InstanceManagementClient client = new InstanceManagementClient(currentProcesses[0].Id);
                    if (mainWindowHandle != IntPtr.Zero)
                    {
                        UnsafeNativeMethods.ShowWindow(mainWindowHandle, 9); //SW_RESTORE=9
                        UnsafeNativeMethods.UpdateWindow(mainWindowHandle);
                    }
                    client.InvokeParameter(args);
                }
            }
        }
Пример #6
0
        public static void Main(string[] args)
        {
            //Controller.executeRDDTask("ES01");

            string salesOrg = "es01";

            //IServerLogger log = Create.serverLogger(138);
            //log.start();

            try {
                Controller.executeRDDTask(salesOrg);
                //log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "RDD", ex);
                //log.finish("error");
            }
        }
Пример #7
0
        public static void Main(string[] args)
        {
            string salesOrg = args[0];
            //string salesOrg = "RU01";

            var log = Create.serverLogger(139);

            log.start();

            try {
                Controller.executeCustomerMissingReport(salesOrg);
                log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "Missing Customers Report", ex);
                log.finish("error");
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            //Controller.executeDeliveryBlocks("ES01");

            string salesOrg = args[0];

            IServerLogger log = Create.serverLogger(161);

            log.start(salesOrg);

            try {
                Controller.executeDeliveryBlocks(salesOrg);
                log.finish(salesOrg);
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "Delivery Blocks", ex);
                log.finish(salesOrg + " Error");
            }
        }
Пример #9
0
        public static void Main(string[] args)
        {
            string salesOrg = args[0];

            //string salesOrg = "FR01";

            IServerLogger log = Create.serverLogger(157);

            log.start();

            try {
                Controller.executeDistressReport(salesOrg);
                log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "Distress", ex);
                log.finish("error");
            }
        }
Пример #10
0
        public static void Main(string[] args)
        {
            Controller.executeMissingCMIRReport("DE01");

            string salesOrg = args[0];

            var log = Create.serverLogger(140);

            log.start();

            try {
                Controller.executeMissingCMIRReport(salesOrg);
                log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, "Missing CMIR Report", ex);
                log.finish("error");
            }
        }
        public static bool HostIMS(IMainWindow mainWindow)
        {
            try
            {
                InstanceManagementService svc = new InstanceManagementService(mainWindow);
                Uri         uri  = new Uri("net.pipe://localhost/JinxBot-" + Process.GetCurrentProcess().Id.ToString());
                ServiceHost host = new ServiceHost(svc, uri);
                host.AddServiceEndpoint(typeof(IJinxBotSingleInstanceService), new NetNamedPipeBinding(), uri);
                host.Open(TimeSpan.MaxValue);
                return(true);
            }
            catch (Exception ex)
            {
#if DEBUG
                GlobalErrorHandler.ReportException(ex);
#endif
                return(false);
            }
        }
Пример #12
0
        /// <summary>
        /// Создать или обновить таблицы.
        /// </summary>
        protected override async ValueTask <Nothing> CreateOrUpgradeTables()
        {
            await base.CreateOrUpgradeTables();

            await EnsureTable(BlobsTableName, 1, InitializeBlobsTable, null);
            await EnsureTable(ReferencesTableName, 1, InitializeReferencesTable, null);

            _filestreamFolder = await CreateFilestreamTable();

            try
            {
                await DoDeleteAllUncompletedBlobs();
            }
            catch (Exception e)
            {
                GlobalErrorHandler?.SignalError(e);
            }
            return(Nothing.Value);
        }
Пример #13
0
        public static void Main(string[] args)
        {
            //TODO: Add ship to & sold to name for the email report

            //Controller.executeRejections("ZA01", true);

            string salesOrg  = args[0];
            bool   isRelease = (args[1] == "Release");

            IServerLogger log = Create.serverLogger(147);

            log.start();

            try {
                Controller.executeRejections(salesOrg, isRelease);
                log.finish("success");
            } catch (Exception ex) {
                GlobalErrorHandler.handle(salesOrg, isRelease ? "Release Rejections" : "After Release Rejections", ex);
                log.finish("error");
            }
        }
Пример #14
0
        void client_EventExceptionThrown(object sender, EventExceptionEventArgs e)
        {
            try
            {
                GlobalErrorHandler.ReportEventException(m_jbClient.Settings.ProfileName, e);
            }
            catch (System.ComponentModel.Win32Exception w3e)
            {
                Debug.WriteLine(w3e.ToString(), "Not understood exception");
            }
            string assemblyFullName = e.FaultingMethod.Method.DeclaringType.Assembly.FullName;

            if (m_assemblyNamesToErrors.ContainsKey(assemblyFullName))
            {
                m_assemblyNamesToErrors[assemblyFullName]++;
            }
            else
            {
                m_assemblyNamesToErrors.Add(assemblyFullName, 1);
            }
        }
Пример #15
0
        private static void runAll(string[] SOs)
        {
            if (DateAndTime.Weekday(DateTime.Today, FirstDayOfWeek.Monday) != 7)
            {
                foreach (var so in SOs)
                {
                    try {
                        Controller.executeWE05(Strings.Left(so, 2));
                        Controller.executeZV04HN(so);
                    } catch (Exception ex) {
                        GlobalErrorHandler.handle(so, "SOAR", ex);
                    }
                }
            }

            try {
                Controller.executeZV04HN("EG01");
                Controller.executeZV04HN("EG02");
                Controller.executeZV04HN("SA01");
            } catch (Exception ex) {
                GlobalErrorHandler.handle("EGandSA", "SOAR", ex);
            }
        }
Пример #16
0
        public static void executeSwitchTask(string salesOrg)
        {
            #region properties
            string id       = $"{DateTime.Now} {Environment.MachineName}";
            var    dbServer = Create.dbServer();
            var    sap      = Create.sapLib();
            //var mu = Create.mailUtil();
            var    dcServer = new DataCollectorServer(dbServer);
            var    dcSap    = new DataCollectorSap(sap, Create.exportParses());
            var    distList = new DistributionListCalculator(dbServer);
            var    dc       = new DataCollectorServiceSwitches(dcServer, dcSap);
            var    executor = new SwitchesTaskExecutor(salesOrg, id);
            string email    = distList.getDistList(salesOrg, "switches");
            #endregion

            //executor.startLogs(salesOrg);

            if (!executor.calculateSwitches(dcServer, dcSap))
            {
                //  mu.mailSimple(email, $"{salesOrg} No manual or automatic switches {DateTime.Now}", $"Hello<br><br>There are no orders in ZV04I<br><br>Kind Regards<br>IDA");
                //executor.endLogs(salesOrg, "Manual Switches", "empty list");
                //executor.endLogs(salesOrg, "Automatic Switches", "empty list");
                return;
            }

            if (executor.switchList.Count > 0)
            {
                executor.populateSwitchesLog(dbServer);
            }
            if (executor.ManualSwitchesList.Count > 0)
            {
                // mu.mailSimple(email, $"{salesOrg} Manual Switches {DateTime.Now}", $"Hello<br><br>{mu.listToHTMLtable(executor.ManualSwitchesList)}<br><br>Kind Regards<br>IDA");
                executor.endLogs(salesOrg, "Manual Switches", "success");
            }
            else
            {
                //mu.mailSimple(email, $"{salesOrg} No Manual Switches {DateTime.Now}", $"Hello<br><br>There are no manual switches for you to action<br><br>Kind Regards<br>IDA");
                executor.endLogs(salesOrg, "Manual Switches", "empty list");
            }

            if (executor.AutomaticSwitchesList.Count > 0)
            {
                //mu.mailSimple(email, $"{salesOrg} Automatic Switches {DateTime.Now}", $"Hello<br><br>{mu.listToHTMLtable(executor.AutomaticSwitchesList)}<br><br>Kind Regards<br>IDA");
                executor.createAutomaticSwitchObjectList();

                try {
                    executor.runSwitchesInVA02();
                    executor.endLogs(salesOrg, "Automatic Switches", "success");
                    // executor.sendFailedSwitches(salesOrg, email, dbServer, mu);
                    //executor.sendReplacedCMIRs(salesOrg, email, mu, dbServer);
                } catch (Exception ex) {
                    GlobalErrorHandler.handle(salesOrg, "Automatic Switches", ex);
                    // executor.sendFailedSwitches(salesOrg, email + ";[email protected]", dbServer, mu);
                }
            }
            else
            {
                //mu.mailSimple(email, $"{salesOrg} No Automatic Switches {DateTime.Now}", $"Hello<br><br>There are no automatic switches for IDA to action<br><br>Kind Regards<br>IDA");
                executor.endLogs(salesOrg, "Automatic Switches", "empty list");
            }
        }
Пример #17
0
 void Application_Error(object sender, EventArgs e)
 {
     GlobalErrorHandler.HandleError(((HttpApplication)sender).Context, Server.GetLastError(), new ErrorController());
 }
Пример #18
0
 static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     GlobalErrorHandler.ReportException(e.Exception);
 }
Пример #19
0
        public void Test_ContinueNextShouldReturnTrue()
        {
            var handler = new GlobalErrorHandler(logger.Object);

            Assert.True(handler.ContinueNext(null));
        }
Пример #20
0
        public void Test_ApplicationEventIsError()
        {
            var handler = new GlobalErrorHandler(logger.Object);

            Assert.Equal(DynamicHttpHandlerEvent.Error, handler.ApplicationEvent);
        }
Пример #21
0
        public void Test_PathIsNull()
        {
            var handler = new GlobalErrorHandler(logger.Object);

            Assert.Null(handler.Path);
        }
Пример #22
0
        public void Test_IsEnabledShouldReturnTrue()
        {
            var handler = new GlobalErrorHandler(logger.Object);

            Assert.True(handler.IsEnabled(null));
        }