protected void Load(string WorkSpacePath) { try { // Load ini IniWorker ini = new IniWorker(IO.Path.Combine(WorkSpacePath, "details.ini")); this.ID = int.Parse(ini.IniReadValue("General", "ID")); this.Name = ini.IniReadValue("General", "Name"); Logger.Instanse.Append(string.Format("WorkSpace: {0}. Loading...", this.Name), LogMessageType.Info); } catch (Exception ex) { Logger.Instanse.Append(string.Format("WorkSpace: Failed to load {0}.", WorkSpacePath), LogMessageType.Info); if (Options.Instanse.LogDebugMode) { Logger.Instanse.Append(ex); } return; } this.LoadKeywords(IO.Path.Combine(WorkSpacePath, "Keywords")); this.LoadImages(IO.Path.Combine(WorkSpacePath, "Images")); this.LoadTexts(IO.Path.Combine(WorkSpacePath, "Text")); this.LoadPresets(IO.Path.Combine(WorkSpacePath, "Presets")); this.LoadTemplates(IO.Path.Combine(WorkSpacePath, "Templates")); this.LoadTasks(IO.Path.Combine(WorkSpacePath, "Tasks")); }
protected void Load(string TaskPath) { if (!IOHelper.CheckDirectoryExists(TaskPath)) { throw new Exception("Path not found!"); } if (!IO.File.Exists(IO.Path.Combine(TaskPath, "details.ini"))) { throw new Exception("Ini path not found!"); } // Loading ini IniWorker ini = new IniWorker(IO.Path.Combine(TaskPath, "details.ini")); this.ID = int.Parse(ini.IniReadValue("General", "ID")); this.Name = ini.IniReadValue("General", "Name"); this.StartTime = DateTime.Parse(ini.IniReadValue("General", "StartTime")); string executorName = ini.IniReadValue("General", "Executor"); // Loading executor for (int i = 0; i < Core.Instanse.Tasks.Executors.Count; i++) { if (Core.Instanse.Tasks.Executors[i].Name == executorName) { this.Executor = Core.Instanse.Tasks.Executors[i].NewInstance() as ITaskExecutor; if (this.Executor == null) { continue; } // Out data into Executor ITaskExecutorHelper.Fill(this.Executor); this.Executor.Load(TaskPath); } } if (this.Executor == null) { throw new Exception("Task Executor not found!"); } try { this.State = (TaskStateType)Enum.Parse(typeof(TaskStateType), ini.IniReadValue("General", "State"), true); if (this.IsNewable()) { this.State = TaskStateType.New; } } catch (Exception) { this.State = TaskStateType.New; } }
protected void Load(string TextPath) { // Loading ini IniWorker ini = new IniWorker(IO.Path.Combine(TextPath, "details.ini")); this.ID = int.Parse(ini.IniReadValue("General", "ID")); this.Name = ini.IniReadValue("General", "Name"); // Loading Items this.Content = IO.File.Exists(IO.Path.Combine(TextPath, "text.txt")) ? IO.File.ReadAllText(IO.Path.Combine(TextPath, "text.txt"), Encoding.UTF8) : string.Empty; }
protected void Load(string KeyWordPath) { // Loading ini IniWorker ini = new IniWorker(IO.Path.Combine(KeyWordPath, "details.ini")); this.ID = int.Parse(ini.IniReadValue("General", "ID")); this.Name = ini.IniReadValue("General", "Name"); // Loading Items this.Items = IO.File.Exists(IO.Path.Combine(KeyWordPath, "keywords.txt")) ? IO.File.ReadAllLines(IO.Path.Combine(KeyWordPath, "keywords.txt"), Encoding.UTF8) : new string[0]; }
protected GuiOptions() { // Loading Options if (File.Exists(Path.Combine(Application.StartupPath, "GUI.ini"))) { IniWorker ini = new IniWorker(Path.Combine(Application.StartupPath, "GUI.ini")); try { // General string iniGroup = "General"; try { this.Language = (LanguageType)Enum.Parse(typeof(LanguageType), ini.IniReadValue(iniGroup, "Language"), true); } catch (Exception) { this.Language = LanguageType.English; } if (!this.NoFxCheck) { this.NoFxCheck = bool.Parse(ini.IniReadValue(iniGroup, "NoFxCheck")); } } catch (Exception) { this.ApplyDefaultOptions(); } } else { this.ApplyDefaultOptions(); } }
protected void Load(string ImagePath) { // Loading ini IniWorker ini = new IniWorker(IO.Path.Combine(ImagePath, "details.ini")); this.ID = int.Parse(ini.IniReadValue("General", "ID")); this.Name = ini.IniReadValue("General", "Name"); // Loading Items string imageDirectory = IO.Path.Combine(ImagePath, "Images"); if (!IO.Directory.Exists(imageDirectory)) { return; } if (!IO.File.Exists(IO.Path.Combine(imageDirectory, "details.ini"))) { return; } string[] images = IO.File.ReadAllLines(IO.Path.Combine(imageDirectory, "details.ini"), Encoding.UTF8); for (int i = 0; i < images.Length; i++) { try { if (!images[i].ToLower().StartsWith("http")) { if (!IO.Path.IsPathRooted(images[i])) { images[i] = IO.Path.Combine(imageDirectory, images[i]); } if (!IO.File.Exists(images[i])) { continue; } } this.Items.Add(new File(FileType.Image, images[i])); } catch (Exception) { } } }
protected void Load(string TemplatePath) { // Loading ini IniWorker ini = new IniWorker(IO.Path.Combine(this.Path, "details.ini")); this.ID = int.Parse(ini.IniReadValue("General", "ID")); this.Name = ini.IniReadValue("General", "Name"); try { Encoding = Encoding.GetEncoding(ini.IniReadValue("General", "Encoding")); } catch (Exception) { Encoding = Encoding.Default; } // Loading Items this.Import(IO.Path.Combine(this.Path, "Files"), this.Encoding); }
public void Update() { try { IniWorker ini; // Core string iniPath = Path.Combine(Application.StartupPath, "Core.ini"); string iniGroup = "General"; if (File.Exists(iniPath)) { ini = new IniWorker(iniPath); // Language this.Language = (LanguageType)Enum.Parse(typeof(LanguageType), ini.IniReadValue(iniGroup, "Language"), true); // Reading maintenance time } // GUI iniPath = Path.Combine(Application.StartupPath, "GUI.ini"); if (File.Exists(iniPath)) { ini = new IniWorker(iniPath); iniGroup = "Monitor"; // Reading if Monitor allowed this.Allowed = bool.Parse(ini.IniReadValue(iniGroup, "Monitor")); // Monitor notifications this.Notifications = bool.Parse(ini.IniReadValue(iniGroup, "Notifications")); this.NotificationsTime = int.Parse(ini.IniReadValue(iniGroup, "Time")); // Reading log settings this.Log = bool.Parse(ini.IniReadValue(iniGroup, "Log")); this.LogFileName = ini.IniReadValue(iniGroup, "LogFileName"); if (this.LogFileName == string.Empty) { this.LogFileName = "Monitor [Date].log"; } this.LogDirectory = ini.IniReadValue(iniGroup, "LogDirectory"); this.UpdateLog = bool.Parse(ini.IniReadValue(iniGroup, "UpdateLog")); this.UpdateLogFileName = ini.IniReadValue(iniGroup, "UpdateLogFileName"); if (this.UpdateLogFileName == string.Empty) { this.UpdateLogFileName = "Update [Date].log"; } this.UpdateLogDirectory = ini.IniReadValue(iniGroup, "UpdateLogDirectory"); } else { this.ApplyDefaultOptions(); } } catch (Exception) { this.ApplyDefaultOptions(); } }
protected GuiOptions() { // Loading Options if (File.Exists(Path.Combine(Application.StartupPath, "GUI.ini"))) { IniWorker ini = new IniWorker(Path.Combine(Application.StartupPath, "GUI.ini")); try { string iniGroup = "General"; // General if (!this.NoFxCheck) { this.NoFxCheck = bool.Parse(ini.IniReadValue(iniGroup, "NoFxCheck")); } // Appearance iniGroup = "Appearance"; this.Appearance = (AppearanceType)Enum.Parse(typeof(AppearanceType), ini.IniReadValue(iniGroup, "Appearance"), true); this.AppearanceNews = bool.Parse(ini.IniReadValue(iniGroup, "News")); this.AppearanceGeneral = bool.Parse(ini.IniReadValue(iniGroup, "General")); this.AppearanceLargeCalendar = bool.Parse(ini.IniReadValue(iniGroup, "LargeCalendar")); // Manager iniGroup = "Manager"; this.Manager = bool.Parse(ini.IniReadValue(iniGroup, "Manager")); this.ManagerPin = bool.Parse(ini.IniReadValue(iniGroup, "PinToDesktop")); this.ManagerLocation = (ManagerLocationType)Enum.Parse(typeof(ManagerLocationType), ini.IniReadValue(iniGroup, "Location"), true); // Tray Window iniGroup = "Tray"; this.TrayWindowPinned = bool.Parse(ini.IniReadValue(iniGroup, "TrayWindowPinned")); this.TrayWindowOpacity = int.Parse(ini.IniReadValue(iniGroup, "TrayWindowOpacity")); // StartUp iniGroup = "StartUp"; if (!this.MinimizedStart) { this.MinimizedStart = bool.Parse(ini.IniReadValue(iniGroup, "MinimizedStart")); } this.AutoStart = bool.Parse(ini.IniReadValue(iniGroup, "AutoStart")); // Notifications iniGroup = "Notifications"; this.Notifications = bool.Parse(ini.IniReadValue(iniGroup, "Notifications")); this.NotificationsTime = int.Parse(ini.IniReadValue(iniGroup, "Time")); this.NotificationsAtTaskStarted = bool.Parse(ini.IniReadValue(iniGroup, "TaskStarted")); this.NotificationsAtTaskFailed = bool.Parse(ini.IniReadValue(iniGroup, "TaskFailed")); this.NotificationsAtTaskFinished = bool.Parse(ini.IniReadValue(iniGroup, "TaskFinished")); this.NotificationsAtNoTask = bool.Parse(ini.IniReadValue(iniGroup, "NoTask")); this.PlaySounds = bool.Parse(ini.IniReadValue(iniGroup, "Sounds")); this.PlaySoundsTime = int.Parse(ini.IniReadValue(iniGroup, "SoundsTime")); this.PlaySoundsAtTaskStarted = bool.Parse(ini.IniReadValue(iniGroup, "SoundsTaskStarted")); this.PlaySoundsAtTaskStartedFile = ini.IniReadValue(iniGroup, "SoundsTaskStartedFile"); this.PlaySoundsAtTaskFailed = bool.Parse(ini.IniReadValue(iniGroup, "SoundsTaskFailed")); this.PlaySoundsAtTaskFailedFile = ini.IniReadValue(iniGroup, "SoundsTaskFailedFile"); this.PlaySoundsAtTaskFinished = bool.Parse(ini.IniReadValue(iniGroup, "SoundsTaskFinished")); this.PlaySoundsAtTaskFinishedFile = ini.IniReadValue(iniGroup, "SoundsTaskFinishedFile"); this.PlaySoundsAtNoTask = bool.Parse(ini.IniReadValue(iniGroup, "SoundsNoTask")); this.PlaySoundsAtNoTaskFile = ini.IniReadValue(iniGroup, "SoundsNoTaskFile"); // Updates iniGroup = "Updates"; this.UpdateCheckAtStartup = bool.Parse(ini.IniReadValue(iniGroup, "AtStartup")); this.UpdateCheckWhileRunning = bool.Parse(ini.IniReadValue(iniGroup, "WhileRunning")); this.UpdateCheckWhileRunningPeriod = int.Parse(ini.IniReadValue(iniGroup, "WhileRunningPeriod")); // Monitor iniGroup = "Monitor"; this.Monitor = bool.Parse(ini.IniReadValue(iniGroup, "Monitor")); this.MonitorNotifications = bool.Parse(ini.IniReadValue(iniGroup, "Notifications")); this.MonitorNotificationsTime = int.Parse(ini.IniReadValue(iniGroup, "NotificationsTime")); this.MonitorLog = bool.Parse(ini.IniReadValue(iniGroup, "Log")); this.MonitorLogFileName = ini.IniReadValue(iniGroup, "LogFileName"); if (this.MonitorLogFileName == string.Empty) { this.MonitorLogFileName = "Monitor [Date].log"; } this.MonitorLogDirectory = ini.IniReadValue(iniGroup, "LogDirectory"); this.MonitorUpdateLog = bool.Parse(ini.IniReadValue(iniGroup, "UpdateLog")); this.MonitorUpdateLogFileName = ini.IniReadValue(iniGroup, "UpdateLogFileName"); if (this.MonitorUpdateLogFileName == string.Empty) { this.MonitorUpdateLogFileName = "Update [Date].log"; } this.MonitorUpdateLogDirectory = ini.IniReadValue(iniGroup, "UpdateLogDirectory"); // Reporting iniGroup = "Reporting"; this.Report = bool.Parse(ini.IniReadValue(iniGroup, "Report")); this.ReportRnD = bool.Parse(ini.IniReadValue(iniGroup, "ReportRnD")); this.ReportTo = ini.IniReadValue(iniGroup, "To"); this.ReportFrom = ini.IniReadValue(iniGroup, "From"); this.ReportSubject = ini.IniReadValue(iniGroup, "Subject"); this.ReportMessage = ini.IniReadValue(iniGroup, "Message"); this.ReportHost = ini.IniReadValue(iniGroup, "Host"); this.ReportPort = int.Parse(ini.IniReadValue(iniGroup, "Port")); this.ReportLogin = ini.IniReadValue(iniGroup, "Login"); this.ReportPassword = ini.IniReadValue(iniGroup, "Password"); this.ReportAttachments = bool.Parse(ini.IniReadValue(iniGroup, "Attachments")); } catch (Exception) { this.ApplyDefaultOptions(); } } else { this.ApplyDefaultOptions(); } }
protected Options() { Logger.Instanse.Append("Options: Loading...", LogMessageType.Info); this.Plugins = new List <string>(); // Loading Options if (File.Exists(Path.Combine(Core.MainPath, "Core.ini"))) { Logger.Instanse.Append("Options: Applying...", LogMessageType.Info); IniWorker ini = new IniWorker(Path.Combine(Core.MainPath, "Core.ini")); try { // General string iniGroup = "General"; try { this.Language = (LanguageType)Enum.Parse(typeof(LanguageType), ini.IniReadValue(iniGroup, "Language"), true); } catch (Exception) { this.Language = LanguageType.English; } this.MaximumConcurentTasks = int.Parse(ini.IniReadValue(iniGroup, "MaximumConcurentTasks")); this.TimeoutEnabled = bool.Parse(ini.IniReadValue(iniGroup, "TimeoutEnabled")); this.Timeout = int.Parse(ini.IniReadValue(iniGroup, "Timeout")); // Plugins iniGroup = "Plugins"; this.PluginsEnabled = bool.Parse(ini.IniReadValue(iniGroup, "Enabled")); this.Plugins = ini.IniReadValue(iniGroup, "Plugins").Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList(); // Log iniGroup = "Log"; this.LogSave = bool.Parse(ini.IniReadValue(iniGroup, "Log")); this.LogMaxSize = int.Parse(ini.IniReadValue(iniGroup, "MaxSize")); this.LogFileName = ini.IniReadValue(iniGroup, "FileName"); if (this.LogFileName == string.Empty) { this.LogFileName = "Log [Date].log"; } this.LogDirectory = ini.IniReadValue(iniGroup, "Directory"); this.LogDebugMode = bool.Parse(ini.IniReadValue(iniGroup, "DebugMode")); // Web UI // Maintenance Logger.Instanse.Append("Options: Applied.", LogMessageType.Info); } catch (Exception) { Logger.Instanse.Append("Options: Failed to load.", LogMessageType.Info); this.ApplyDefaultOptions(); } Logger.Instanse.Append("Options: Loaded.", LogMessageType.Info); } else { this.ApplyDefaultOptions(); } Logger.Instanse.UseOptions = true; }