private void SaveConfig() { if (string.IsNullOrEmpty(this.mFullPath)) { return; } if (!File.Exists(this.mFullPath)) { return; } CXmlConfig xc = new CXmlConfig(CCommon.Const.ConfigXmlFullPath); xc.SaveSetting("FullPath", this.mFullPath); }
public SvcBackup() { InitializeComponent(); this.tmr = new Timer(); CXmlConfig xc = GetXmlConfig(); //60 = 1분 int Interval = CFindRep.IfNotNumberThen(xc.GetSetting("IntervalMinutes", 60), 60); this.tmr.Interval = Interval * 1000; //this.tmr.Interval = 15000; this.tmr.Enabled = true; this.tmr.Elapsed += new ElapsedEventHandler(tmr_Elapsed); //처음엔 무조건 실행 //tmr_Elapsed(this.tmr, null); }
private void RestoreConfig() { CXmlConfig xc = new CXmlConfig(CCommon.Const.ConfigXmlFullPath); string FullPath = xc.GetSetting("FullPath", ""); if (FullPath == "") { return; } if (!File.Exists(FullPath)) { return; } this.mFullPath = FullPath; sttlblFullPath.Text = this.mFullPath; DataTable dt = GetTable(); dt.Rows.Clear(); dt.ReadXml(this.mFullPath); }
//========================================= private bool IsValidForShow(out SInfo InfoIs, out string ErrMsgIs) { InfoIs = new SInfo(); ErrMsgIs = ""; CXmlConfig xc = new CXmlConfig(CCommon.Const.ConfigXmlFullPath); InfoIs.FullPath = xc.GetSetting("FullPath", ""); if (InfoIs.FullPath == "") { ErrMsgIs = "Config not saved."; return(false); } if (!File.Exists(InfoIs.FullPath)) { ErrMsgIs = InfoIs.FullPath + " file not exists."; return(false); } return(true); }
void tmr_Elapsed(object sender, ElapsedEventArgs e) { const char Delim = '─'; if (this.mRunning) { return; } else { this.mRunning = true; } string LogFullPath = GetLogFullPath(); string LogFolderForSync = Path.GetDirectoryName(LogFullPath); try { CXmlConfig xc = GetXmlConfig(); string[] aRootPathSrc = xc.GetSetting("RootPathSrc", "").Split(Delim); string[] aFtpHost = xc.GetSetting("FtpHost", "").Split(Delim); string[] aFtpId = xc.GetSetting("FtpId", "").Split(Delim); string[] aFtpPassword = xc.GetSetting("FtpPassword", "").Split(Delim); for (int i = 0; i < aFtpPassword.Length; i++) { aFtpPassword[i] = CEncrypt.DecryptPassword(aFtpPassword[i]); } string[] aFtpFolder = xc.GetSetting("FtpFolder", "").Split(Delim); string[] aSyncType = xc.GetSetting("SyncType", "").Split(Delim); string[] aMinifyJs = xc.GetSetting("MinifyJs", "").Split(Delim); string[] aFileNameToAppendParam = xc.GetSetting("FileNameToAppendParam", "").Split(Delim); string[] asDateTimeAfter = xc.GetSetting("DateTimeAfter", "").Split(Delim); DateTime[] aDateTimeAfter = new DateTime[asDateTimeAfter.Length]; for (int i = 0; i < asDateTimeAfter.Length; i++) { aDateTimeAfter[i] = CFindRep.IfNotDateTimeThen19000101(asDateTimeAfter[i]); } for (int i = 0; i < aRootPathSrc.Length; i++) { CFtpInfoSync[] aFtpInfo = new CFtpInfoSync[] { new CFtpInfoSync() { Host = aFtpHost[i], UserId = aFtpId[i], Password = aFtpPassword[i], Folder = aFtpFolder[i] } }; CSyncFile sf = new CSyncFile(aRootPathSrc[i], aFtpInfo, CEnum.GetValueByName <SyncTypes>(aSyncType[i]), (aMinifyJs[i] == "1"), aFileNameToAppendParam, aDateTimeAfter[i], LogFolderForSync); sf.DisallowedFolder = new string[] { LogFolderForSync }; sf.CopyAll(); aDateTimeAfter[i] = DateTime.Now; } for (int i = 0; i < aDateTimeAfter.Length; i++) { asDateTimeAfter[i] = aDateTimeAfter[i].ToString(CConst.Format_yyyy_MM_dd_HH_mm_ss); } xc.SaveSetting("DateTimeAfter", string.Join(Delim.ToString(), asDateTimeAfter)); } catch (Exception ex) { CFile.AppendTextToFile(LogFullPath, "Error " + DateTime.Now.ToString() + "\r\n" + ex.Message + "\r\n" + ex.StackTrace + "\r\n" + ex.Source); } this.mRunning = false; }