Пример #1
0
        public string DownloadGuiSettigs()
        {
            string result;

            try
            {
                lock (RequestProcessor.SyncLoadGuiSettings)
                {
                    using (AvtoritetEntities ae = new AvtoritetEntities())
                    {
                        SettingUpdate updateFlag = ae.SettingUpdate.FirstOrDefault <SettingUpdate>();
                        string        settings   = string.Empty;
                        string        baseDir    = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        string        root       = System.IO.Path.Combine(baseDir, ResourceManager.Root);
                        string        path       = string.Join("\\", new string[]
                        {
                            root,
                            "settingui.zip"
                        });
                        if (updateFlag != null && (!updateFlag.Update || !System.IO.File.Exists(path)))
                        {
                            settings = RequestProcessor.ReadConfigToString();
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }
                            System.IO.File.WriteAllText(path, settings, System.Text.Encoding.Unicode);
                            updateFlag.Update = true;
                            ae.SaveChanges();
                        }
                        else if (System.IO.File.Exists(path))
                        {
                            settings = System.IO.File.ReadAllText(path, System.Text.Encoding.Unicode);
                        }
                        else
                        {
                            settings = null;
                        }
                        result = settings;
                    }
                }
            }
            catch (System.Exception ex)
            {
                ErrorLogHelper.AddErrorInLog("DownloadGuiSettigs()", ex.Message + "|" + ex.StackTrace);
                result = string.Format("[{0}] {1} / {2}", System.DateTime.Now, ex.Message, ex.StackTrace);
            }
            return(result);
        }
Пример #2
0
 public System.IO.Stream DownloadSettings()
 {
     System.IO.Stream result;
     try
     {
         lock (RequestProcessor.SyncLoadSettings)
         {
             string settings = this.settingsZipper.CreateZipFromSettings(RequestProcessor.ReadConfigToString());
             result = System.IO.File.OpenRead(settings);
         }
     }
     catch (System.Exception ex)
     {
         ErrorLogHelper.AddErrorInLog("DownloadSettings()", ex.Message + "|" + ex.StackTrace);
         ConsoleHelper.Error(string.Format("{0} || {1} || {2}", ex.Message, ex.StackTrace, ex.Data));
         result = null;
     }
     return(result);
 }
Пример #3
0
        public bool IsServiceAvailable()
        {
            bool result;

            try
            {
                CookieContainer            cookieContainer = new CookieContainer();
                IRequestHandler            requestHandler  = RequestHandlerFactory.Create("http://www.partslink24.com/", string.Empty, string.Empty, null);
                Task <HttpResponseMessage> responseMessage = requestHandler.GetSessionAsync("http://www.partslink24.com/", cookieContainer);
                string content = responseMessage.Result.Content.ReadAsStringAsync().Result;
                result = (!content.Contains("maintenance_general") && int.Parse(RequestProcessor.GetConfig("Partslink")) > 0);
            }
            catch (System.Exception ex)
            {
                ErrorLogHelper.AddErrorInLog("IsServiceAvailable()", ex.Message + "|" + ex.StackTrace);
                ConsoleHelper.Error(string.Format("{0} || {1} || {2}", ex.Message, ex.StackTrace, ex.Data));
                result = false;
            }
            return(result);
        }
Пример #4
0
 public RequestProcessor()
 {
     RequestProcessor.SetupServicePointManager();
     this.settingsZipper = new SettingsZipper();
 }