public void Save() { Byte[] bytes = this.db.ObjectToBlob(); string x = FormatterMg.XMLSerObjectToString(this.db); FileInfo xf = new FileInfo(this.fileDbPath); xf.Save(x, Encoding.UTF8); string basePath = Path.GetDirectoryName(this.fileDbPath); string backupPath = Path.Combine(basePath,"db_backup"); string zipFileName = "db_" + DateTime.Now.ToString("yyyy_MMdd_HHmm") + "_.zip"; string zipFileFullpath = Path.Combine(backupPath, zipFileName); if (!Directory.Exists(backupPath)) Directory.CreateDirectory(backupPath); ZipFile zip = new ZipFile(zipFileFullpath, true); zip.AddFile(this.fileDbPath); zip.Dispose(); }
private void InnerStart() { cbb_http_web_server config = null; try { config = MainConfig.Instance.cbb_http_web_server; } catch (Exception exp) { var settingFile = new FileInfo(DirectoryHelper.CombineWithCurrentExeDir("default_settings.ini")); settingFile.Save(WebServerConfig.Properties.Resources.settings); Process.Start(settingFile.FullName); var ErrorFile = new FileInfo(DirectoryHelper.CombineWithCurrentExeDir("settings_error.log")); ErrorFile.Save(exp.GetDetailErrorText()); Process.Start(ErrorFile.FullName); Environment.Exit(-1); } if (config.IsConsoleLogEnabled) mainLogger.AddLogger(new ConsoleLog()); if (config.IsHtmlLogEnabled) mainLogger.AddLogger(new HtmlFileLog(DirectoryHelper.CombineWithCurrentExeDir("LogData"), "WebServer")); try { IniFile_Ex inifile = IniFile_Ex.ParseIniFile(DirectoryHelper.CombineWithCurrentExeDir("settings.ini")); UnityContainer container = new UnityContainer(); container.RegisterInstance<ILog>(mainLogger); container.RegisterType<MainConfig>(new ContainerControlledLifetimeManager()); container.RegisterType<CacheMgr>(new ContainerControlledLifetimeManager()); container.RegisterType<ResourceAssemblyMgr>(new ContainerControlledLifetimeManager()); container.RegisterType<StatusMgr>(new ContainerControlledLifetimeManager()); container.RegisterInstance(typeof(IniFile_Ex), inifile); container.RegisterInstance(MainConfig.Instance); container.RegisterInstance<IUnityContainer>(container); container.RegisterType<ProductRepository, FileProductRepository>(); httpWebserver = container.Resolve<HttpWebServer>(); httpWebserver.Start(); } catch (NotFreePortException exp) { mainLogger.LogMessage(exp.GetDetailErrorText(), LogType.Error, "WebServerStarter"); } catch (Exception exp) { mainLogger.LogMessage(exp.GetDetailErrorText(true), LogType.Error, "WebServerStarter"); } }
public void OnAgentAdded(AddAgentPayLoad payload) { agentList.Add(new Agent() { Name = payload.AgentName, QQNumberOrEmail = payload.AgentQQOrEmail }); string x = FormatterMg.XMLSerObjectToString(agentList); FileInfo xf = new FileInfo(FilePath); xf.Save(x, Encoding.UTF8); }