Beispiel #1
0
        static void Main(string[] args)
        {
            Http_Download_Routine _wrapper = new Http_Download_Routine();

            try
            {
                if (_wrapper.CheckInstance())
                {
                    Console.Title    = "ArcMarine HTTP processor";
                    _wrapper.LogText = "================" + DateTime.Now.ToString() + "================";
                    _wrapper.LogText = "ArcMarine HTTP processor started";
                    _wrapper.Initialise();
                    _wrapper.ProcessLinkFiles();
                    _wrapper.ProcessQuote();
                    _wrapper.LogText = "ArcMarine HTTP processor stopped";
                    _wrapper.LogText = "====================================================";
                    _wrapper.LogText = "";
                }
                else
                {
                    string strlogpath = AppDomain.CurrentDomain.BaseDirectory + "Log";
                    string strlogfile = @"Log_" + DateTime.Now.ToString("ddMMyyyy") + ".txt";
                    int    iCounter   = 0;
                    if (File.Exists(strlogpath + "\\" + strlogfile))
                    {
                        string[] ArrLogLines = File.ReadAllLines(strlogpath + "\\" + strlogfile);
                        if (ArrLogLines.Length > 15)
                        {
                            for (int i = (ArrLogLines.Length - 1); i > (ArrLogLines.Length - 15); i--)
                            {
                                if (ArrLogLines[i].Contains("Application is already running"))
                                {
                                    iCounter++;
                                }
                            }
                        }
                    }
                    if (iCounter > 5)
                    {
                        _wrapper.LogText = "Killing Process.";
                        _wrapper.KillProcess();
                    }
                }
            }
            catch (Exception ex)
            {
                _wrapper.LogText = "ERROR : " + ex.Message;
            }
            finally
            {
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Http_Download_Routine _wrapper = new Http_Download_Routine();

            _wrapper.LogText = "================" + DateTime.Now.ToString() + "================";
            _wrapper.LogText = "Bernhard Schulte RFQ Download HTTP processor started";
            _wrapper.Initialise();
            string AppsettingsConfig = AppDomain.CurrentDomain.BaseDirectory + "Appsettings.xml";

            ReadConfig(AppsettingsConfig, _wrapper);
            _wrapper.LogText = "Bernhard Schulte RFQ Download HTTP processor stopped";
            _wrapper.LogText = "====================================================";
        }
Beispiel #3
0
        public static bool ProcessUser(Http_Download_Routine _wrapper)
        {
            bool _result = true;

            _wrapper.LoadAppsettings();
            _wrapper.LogText = "Process started for " + _wrapper.Userid;
            if (_wrapper.DoLogin("div", "id", "supplierName"))
            {
                foreach (string sAction in _wrapper.Actions)
                {
                    try
                    {
                        switch (sAction.ToUpper())
                        {
                        case "RFQ": _wrapper.ProcessRFQ();   // testing 19/11/2019
                            break;

                        case "QUOTE": _wrapper.ProcessQuote(); break;    //added by Kalpita on 18/11/2019
                        }
                    }
                    catch (Exception ex)
                    {
                        _wrapper.LogText = "Exception while processing " + sAction.ToUpper() + " : " + ex.GetBaseException().ToString();
                    }
                }
                if (_wrapper.LogOut())
                {
                    _wrapper.LogText = "User " + _wrapper.Userid + " logged out successfully.";
                    _result          = true;
                }
                else
                {
                    // string sAudit = "Unable to log out User " + _wrapper.Userid + ". Multi login process stopped.";
                    string sAudit = "Unable to Logout" + _wrapper.Userid;//added by Kalpita on 18/10/2019
                    _wrapper.LogText = sAudit;

                    string filename = _wrapper.PrintScreenPath + "\\BernhardSchulte_LoginOutFailed_" + DateTime.Now.ToString("ddMMyyyHHmmssfff") + ".png";
                    if (!_wrapper.PrintScreen(filename))
                    {
                        filename = "";
                    }
                    _wrapper.CreateAuditFile(filename, "BernhardSchulte_HTTP_Downloader", "", "Error", "LeS-1015:" + sAudit, _wrapper.buyer_Link_code, _wrapper.SupplierCode, _wrapper.AuditPath);
                    _result = false;
                }
            }
            return(_result);
        }
Beispiel #4
0
        public static void ReadConfig(string sConfigFile, Http_Download_Routine _wrapper)
        {
            XmlDocument configFile = new XmlDocument();

            configFile.Load(sConfigFile);
            XmlElement  userSetting;
            XmlNodeList xmlAppSettings = configFile.SelectNodes("//APPSETTINGS");

            try
            {
                if (xmlAppSettings != null)
                {
                    foreach (XmlNode _appSetting in xmlAppSettings)
                    {
                        _wrapper.dctAppSettings.Clear();
                        XmlNodeList _childAppsettings = _appSetting.ChildNodes;
                        foreach (XmlNode _UserSetting in _childAppsettings)
                        {
                            userSetting = (XmlElement)_UserSetting;
                            _wrapper.dctAppSettings.Add(userSetting.Name, userSetting.InnerText);
                        }
                        if (!ProcessUser(_wrapper))
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //string sAuditMesage = "Exception while processing RFQ download" + e.GetBaseException().ToString();
                string sAuditMesage = "Parameters not configured" + e.GetBaseException().ToString();//added by Kalpita on 18/10/2019
                _wrapper.LogText = sAuditMesage;
                string filename = _wrapper.PrintScreenPath + "\\BernhardSchulte_Exception_" + DateTime.Now.ToString("ddMMyyyHHmmssfff") + ".png";
                if (!_wrapper.PrintScreen(filename))
                {
                    filename = "";
                }
                _wrapper.CreateAuditFile(filename, "BernhardSchulte_HTTP_Downloader", "", "Error", "LeS-1004:" + sAuditMesage, _wrapper.buyer_Link_code, _wrapper.SupplierCode, _wrapper.AuditPath);
            }
        }