Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }