private void OnReceiveFileSync(EventBroker.EventID id, EventBroker.EventParam param) { if (param == null) { return; } if (param.ParamString != null) { if (param.ParamInt == 0) { notiftyBalloonTip(param.ParamString + " Error", 1000, "File Sync"); } else if (param.ParamInt == 1) { notiftyBalloonTip(param.ParamString + " OK", 2000, "File Sync"); } else if (param.ParamInt == 2) { notiftyBalloonTip(param.ParamString, 1000, "Service"); } else { notiftyBalloonTip(param.ParamString, 1000, "Renaissance Cloud"); } } }
private void OnTimer(EventBroker.EventID id, EventBroker.EventParam param) { if (param == null) { return; } FileTransfer ft = param.ParamObj as FileTransfer; ft.FileSync(); }
private void OnStartProgram(EventBroker.EventID id, EventBroker.EventParam param) { SystemLog.Output(SystemLog.MSG_TYPE.Nor, "Schedule Process", "System Start"); foreach (var fte in m_fileTransfer) { FileTransfer ft = fte.Value.ParamObj as FileTransfer; FileSchedule.ScheduleProperty sp = ft.Property; if (sp.PCTurnOn == true) { ft.FileSync(); } } }
public ScheduleProcess() { m_observerTimer = new EventBroker.EventObserver(OnTimer); EventBroker.AddObserver(EventBroker.EventID.etFileTimer, m_observerTimer); m_observerStart = new EventBroker.EventObserver(OnStartProgram); EventBroker.AddObserver(EventBroker.EventID.etStartProgram, m_observerStart); m_observerCheckDate = new EventBroker.EventObserver(OnCheckDate); EventBroker.AddObserver(EventBroker.EventID.etCheckDate, m_observerCheckDate); m_checkDateParam = new EventBroker.EventParam(this, 0); m_currentDate = DateTime.Now; }
private void Window_Loaded(object sender, RoutedEventArgs e) { System.Windows.Forms.ContextMenu menu = new System.Windows.Forms.ContextMenu(); System.Windows.Forms.MenuItem itemConfig = new System.Windows.Forms.MenuItem(); itemConfig.Index = 0; itemConfig.Text = "Config"; itemConfig.Click += ItemConfig_Click; menu.MenuItems.Add(itemConfig); System.Windows.Forms.MenuItem itemSchedule = new System.Windows.Forms.MenuItem(); itemSchedule.Index = 1; itemSchedule.Text = "Schedule"; itemSchedule.Click += ItemSchedule_Click; menu.MenuItems.Add(itemSchedule); System.Windows.Forms.MenuItem itemLog = new System.Windows.Forms.MenuItem(); itemLog.Index = 2; itemLog.Text = "LogView"; itemLog.Click += (object send, EventArgs args) => { this.Show(); this.WindowState = WindowState.Normal; this.ShowInTaskbar = true; }; menu.MenuItems.Add(itemLog); System.Windows.Forms.MenuItem itemExit = new System.Windows.Forms.MenuItem(); itemExit.Index = 4; itemExit.Text = "Cloud End"; itemExit.Click += ItemExit_Click1; menu.MenuItems.Add(itemExit); m_notify = new System.Windows.Forms.NotifyIcon(); m_notify.Icon = Properties.Resources.Butterfree_icon; m_notify.Visible = true; m_notify.DoubleClick += (object send, EventArgs args) => { this.Show(); this.WindowState = WindowState.Normal; this.ShowInTaskbar = true; }; m_notify.ContextMenu = menu; Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string str = string.Format("Start Cloud v{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); m_notify.Text = "Fs Transfer"; notiftyBalloonTip(str, 1000); this.WindowState = WindowState.Minimized; if (m_timerEvent == null) { m_timerEvent = new EventBroker.EventParam(this, 0); EventBroker.AddTimeEvent(EventBroker.EventID.etUpdateMe, m_timerEvent, 3960000, true);//66분에 한번씩 //EventBroker.AddTimeEvent(EventBroker.EventID.etUpdateMe, m_timerEvent, 20000, true);//66분에 한번씩 } }
private void OnCheckDate(EventBroker.EventID id, EventBroker.EventParam param) { if (m_currentDate.Day != DateTime.Now.Day) { m_currentDate = DateTime.Now; SystemLog.Output(SystemLog.MSG_TYPE.Nor, "Schedule Process", "System Date Change"); foreach (var fte in m_fileTransfer) { FileTransfer ft = fte.Value.ParamObj as FileTransfer; FileSchedule.ScheduleProperty sp = ft.Property; if (sp.PCDateChanges == true) { ft.FileSync(); } } } }
private void OnReceiveLog(EventBroker.EventID id, EventBroker.EventParam param) { if (param == null) { return; } SystemLog.MSG_TYPE type = (SystemLog.MSG_TYPE)param.ParamInt; if (type == SystemLog.MSG_TYPE.Err) { Output(param.ParamString, Brushes.Yellow); } else if (type == SystemLog.MSG_TYPE.War) { Output(param.ParamString, Brushes.YellowGreen); } else { Output(param.ParamString, Brushes.LightGray); } }
public void ServiceStart() { if (m_isRun) { ServiceStop(); } SystemLog.Output(SystemLog.MSG_TYPE.Nor, "Schedule Process", "Service Start"); foreach (var sch in m_schedule) { try { SystemLog.Output(SystemLog.MSG_TYPE.Nor, "Schedule Process", "Start : {0}", sch.Key); FileTransfer ft = new FileTransfer(sch.Value); EventBroker.EventParam eParam = new EventBroker.EventParam(this, 0, sch.Key, ft); m_fileTransfer.Add(sch.Key, eParam); if (sch.Value.PCTurnOn == true && m_isFirstStart == true) { EventBroker.AddTimeEvent(EventBroker.EventID.etStartProgram, eParam, sch.Value.DelayTimeMinute * 60000, false); } if (sch.Value.RepeateTime == true) { EventBroker.AddTimeEvent(EventBroker.EventID.etFileTimer, eParam, sch.Value.RepeatTimeMinute * 60000, true); } } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "Schedule Process", "Service Start : " + ex.Message); } } EventBroker.AddTimeEvent(EventBroker.EventID.etCheckDate, m_checkDateParam, 60000, true); EventBroker.AsyncSend(EventBroker.EventID.etFileSync, new EventBroker.EventParam(this, 2, "Start")); m_isFirstStart = true; m_isRun = true; }
private void OnReceiveUpdateMe(EventBroker.EventID id, EventBroker.EventParam param) { if (param == null || m_disableProgramUpdate) { return; } try { PropertiesSystem prop = PropertiesSetting.DefaultSetting.Property; if (prop == null) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "RCloud Auto update", "ProperiesSystem null"); return; } if (prop.UpdateEnable) { IFileService server = null; try { if (prop.UpdateDrvieType == DriveType.FTP) { server = new ServiceFtp(prop.UpdateFtpUser, prop.UpdateFtpPw, 5000, prop.UpdateFtpUri); } else { server = new ServiceDisk(prop.UpdateDiskUri); } } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "RCloud Auto update", "Connection Server fail, " + ex.Message); return; } List <FileInfo> info = null; try { info = server.GetFileList(null, "zip"); if (info == null) { return; } } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "RCloud Auto update", "Get File List fail, " + ex.Message); return; } try { foreach (FileInfo fo in info) { string str = fo.Name.ToUpper(); if (fo.Name == null) { continue; } if (str.IndexOf("RCLOUD ") == 0) { string[] strArray = str.Split(' '); if (strArray.Length == 2) { string[] verArray = strArray[1].Split('.'); if (verArray.Length == 3) { try { int major = Convert.ToInt32(verArray[0]); int minor = Convert.ToInt32(verArray[1]); int build = Convert.ToInt32(verArray[2]); Version ver = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; if (major != ver.Major || minor != ver.Minor || build != ver.Build) { string currentPath = AppDomain.CurrentDomain.BaseDirectory; SystemLog.Output(SystemLog.MSG_TYPE.Nor, "RCloud Auto update", "Update Start"); int indexRemove = currentPath.LastIndexOf(@"\"); if (indexRemove > 1 && (indexRemove + 1) >= currentPath.Length) { currentPath = currentPath.Substring(0, indexRemove); } string tempPath = currentPath + "\\UpdateTemp"; if (UpdateMeDownload(server, fo, tempPath) == true) { UpdateMeFileChange(currentPath, tempPath); } } } catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "RCloud Auto update", "file update check fail, " + ex.Message); } } break; } } } }catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "RCloud Auto update", "iterator, " + ex.Message); } } }catch (Exception ex) { SystemLog.Output(SystemLog.MSG_TYPE.Err, "RCloud Auto update", "Error, " + ex.Message); } }