コード例 #1
0
        public void Save(string TaskPath)
        {
            // Making directories
            if (!IOHelper.CheckDirectoryExists(TaskPath))
            {
                IOHelper.CreateDirectory(TaskPath);
            }

            // Saving
            IniWorker ini = new IniWorker(IO.Path.Combine(TaskPath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);
            ini.IniWriteValue("General", "StartTime", this.StartTime.ToString());
            ini.IniWriteValue("General", "State", this.State.ToString());

            if (this.Executor == null)
            {
                throw new Exception("Empty executor!");
            }

            ini.IniWriteValue("General", "Executor", this.Executor.Name);

            // Saving Settings
            this.Executor.Save(TaskPath);
        }
コード例 #2
0
ファイル: WorkSpace.cs プロジェクト: UmaxSoftWorks/UDS2
        /// <summary>
        /// Saves WorkSpace to the specified directory
        /// </summary>
        /// <param name="WorkSpacePath">Path to the directory where WorkSpace will be saved.</param>
        public void Save(string WorkSpacePath)
        {
            Logger.Instanse.Append(string.Format("WorkSpace: {0}. Saving...", this.Name), LogMessageType.Info);
            try
            {
                if (!IOHelper.CheckDirectoryExists(WorkSpacePath))
                {
                    IOHelper.CreateDirectory(WorkSpacePath);
                }

                // Saving ini
                IniWorker ini = new IniWorker(IO.Path.Combine(WorkSpacePath, "details.ini"));
                ini.IniWriteValue("General", "ID", this.ID.ToString());
                ini.IniWriteValue("General", "Name", this.Name);

                this.SaveTasks(IO.Path.Combine(WorkSpacePath, "Tasks"));
                this.SaveImages(IO.Path.Combine(WorkSpacePath, "Images"));
                this.SaveKeywords(IO.Path.Combine(WorkSpacePath, "Keywords"));
                this.SaveTexts(IO.Path.Combine(WorkSpacePath, "Text"));
                this.SavePresets(IO.Path.Combine(WorkSpacePath, "Presets"));
                this.SaveTemplates(IO.Path.Combine(WorkSpacePath, "Templates"));

                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Saved.", this.Name), LogMessageType.Info);
            }
            catch (Exception ex)
            {
                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Failed to save.", this.Name), LogMessageType.Info);
                if (Options.Instanse.LogDebugMode)
                {
                    Logger.Instanse.Append(ex);
                }
            }
        }
コード例 #3
0
ファイル: WorkSpace.cs プロジェクト: UmaxSoftWorks/UDS2
        /// <summary>
        /// Delete WorkSpace
        /// </summary>
        public void Delete()
        {
            Logger.Instanse.Append(string.Format("WorkSpace: {0}. Deleting...", this.Name), LogMessageType.Info);
            try
            {
                this.DeleteImages();
                this.DeleteKeywords();
                this.DeleteTemplates();
                this.DeleteTexts();
                this.DeletePresets();
                this.DeleteTasks();

                IO.Directory.Delete(this.Path, true);
                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Deleted.", this.Name), LogMessageType.Info);
            }
            catch (Exception ex)
            {
                Logger.Instanse.Append(string.Format("WorkSpace: {0}. Failed to delete.", this.Name), LogMessageType.Info);
                if (Options.Instanse.LogDebugMode)
                {
                    Logger.Instanse.Append(ex);
                }
            }

            // Events
            this.Tasks.CountChanged     -= this.Changed;
            this.Images.CountChanged    -= this.Changed;
            this.Keywords.CountChanged  -= this.Changed;
            this.Text.CountChanged      -= this.Changed;
            this.Presets.CountChanged   -= this.Changed;
            this.Templates.CountChanged -= this.Changed;

            this.Tasks.ItemAdded     -= this.TasksAdded;
            this.Images.ItemAdded    -= this.ImagesAdded;
            this.Keywords.ItemAdded  -= this.KeywordsAdded;
            this.Text.ItemAdded      -= this.TextAdded;
            this.Presets.ItemAdded   -= this.PresetsAdded;
            this.Templates.ItemAdded -= this.TemplatesAdded;

            this.Tasks.ItemRemoved     -= this.TasksRemoved;
            this.Images.ItemRemoved    -= this.ImagesRemoved;
            this.Keywords.ItemRemoved  -= this.KeywordsRemoved;
            this.Text.ItemRemoved      -= this.TextRemoved;
            this.Presets.ItemRemoved   -= this.PresetsRemoved;
            this.Templates.ItemRemoved -= this.TemplatesRemoved;

            // Deleting
            if (IOHelper.CheckDirectoryExists(this.Path))
            {
                try
                {
                    IO.Directory.Delete(this.Path, true);
                }
                catch (Exception) { }
            }
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        public void Delete()
        {
            if (IO.File.Exists(IO.Path.Combine(this.Path, "text.txt")))
            {
                IO.File.Delete(IO.Path.Combine(this.Path, "text.txt"));
            }

            if (IOHelper.CheckDirectoryExists(this.Path))
            {
                try
                {
                    IO.Directory.Delete(this.Path, true);
                }
                catch (Exception) { }
            }
        }
コード例 #6
0
        public void Save(string TextPath)
        {
            // Saving details
            if (!IOHelper.CheckDirectoryExists(TextPath))
            {
                IOHelper.CreateDirectory(TextPath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(TextPath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);

            // Saving Items
            IO.File.WriteAllText(IO.Path.Combine(TextPath, "text.txt"), this.Content, Encoding.UTF8);
        }
コード例 #7
0
        public void Delete()
        {
            if (this.IsActive())
            {
                Core.Instanse.Manager.Stop(this);
            }

            // Deleting
            if (IOHelper.CheckDirectoryExists(this.Path))
            {
                try
                {
                    IO.Directory.Delete(this.Path, true);
                }
                catch (Exception) { }
            }
        }
コード例 #8
0
ファイル: KeyWord.cs プロジェクト: UmaxSoftWorks/UDS2
        /// <summary>
        /// Saves keywords to specified directory
        /// </summary>
        /// <param name="KeyWordPath">Path to directory, where keywords will be saved</param>
        public void Save(string KeyWordPath)
        {
            // Saving details
            if (!IOHelper.CheckDirectoryExists(KeyWordPath))
            {
                IOHelper.CreateDirectory(KeyWordPath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(KeyWordPath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);

            // Saving
            IO.File.WriteAllLines(IO.Path.Combine(KeyWordPath, "keywords.txt"), this.Items, Encoding.UTF8);
        }
コード例 #9
0
        public void Save(string TemplatePath)
        {
            // Saving details
            if (!IOHelper.CheckDirectoryExists(TemplatePath))
            {
                IOHelper.CreateDirectory(TemplatePath);
            }

            // Saving ini
            IniWorker ini = new IniWorker(IO.Path.Combine(TemplatePath, "details.ini"));

            ini.IniWriteValue("General", "ID", this.ID.ToString());
            ini.IniWriteValue("General", "Name", this.Name);
            ini.IniWriteValue("General", "Encoding", Encoding.EncodingName);

            // Saving Items
            this.Export(IO.Path.Combine(TemplatePath, "Files"));
        }
コード例 #10
0
        public void Delete()
        {
            for (int i = 0; i < this.Items.Count; i++)
            {
                if (this.Items[i].Path.ToLower().StartsWith(this.Path.ToLower()))
                {
                    this.Items[i].Delete();
                }
            }

            if (IOHelper.CheckDirectoryExists(this.Path))
            {
                try
                {
                    IO.Directory.Delete(this.Path, true);
                }
                catch (Exception) { }
            }
        }
コード例 #11
0
        public void Export(string TemplatePath)
        {
            if (!IOHelper.CheckDirectoryExists(TemplatePath))
            {
                IOHelper.CreateDirectory(TemplatePath);
            }

            string[] details = new string[this.Items.Count];
            for (int i = 0; i < this.Items.Count; i++)
            {
                if (this.Items[i].Path.ToLower().StartsWith("http"))
                {
                    details[i] = this.Items[i].Type.ToString() + "=" + this.Items[i].Path;
                    continue;
                }

                string itemPath = string.Empty;
                if (!string.IsNullOrEmpty(this.Path))
                {
                    if (!this.Items[i].Path.ToLower().StartsWith(this.Path))
                    {
                        itemPath = IO.Path.Combine(TemplatePath, IO.Path.IsPathRooted(this.Items[i].Path)
                                                                     ? this.Items[i].Path.Substring(
                                                       this.Items[i].Path.LastIndexOf(@"\") + 1)
                                                                     : this.Items[i].Path);
                    }
                }
                else
                {
                    itemPath = IO.Path.Combine(TemplatePath, this.Items[i].Path.Substring(this.Items[i].Path.LastIndexOf(@"\") + 1));
                }

                details[i] = this.Items[i].Type.ToString() + "=" +
                             itemPath.Substring(TemplatePath.Length).Trim(new char[] { '\\' });
                (this.Items[i] as File).Save(itemPath, Encoding);
            }

            // Saving info.ini
            string iniPath = IO.Path.Combine(TemplatePath, "details.ini");

            IO.File.WriteAllLines(iniPath, details, Encoding.UTF8);
        }
コード例 #12
0
ファイル: WorkSpace.cs プロジェクト: UmaxSoftWorks/UDS2
 protected void LoadTemplates(string TemplatesPath)
 {
     if (IOHelper.CheckDirectoryExists(TemplatesPath))
     {
         string[] directories = IO.Directory.GetDirectories(TemplatesPath, "*", IO.SearchOption.TopDirectoryOnly);
         for (int i = 0; i < directories.Length; i++)
         {
             try
             {
                 this.Templates.Add(new Template(directories[i]));
                 Logger.Instanse.Append(string.Format("WorkSpace: {0}. Template loaded {1}.", this.Name, directories[i]), LogMessageType.Info);
             }
             catch (Exception ex)
             {
                 Logger.Instanse.Append(string.Format("WorkSpace: {0}. Failed to load Template {1}.", this.Name, directories[i]), LogMessageType.Info);
                 if (Options.Instanse.LogDebugMode)
                 {
                     Logger.Instanse.Append(ex);
                 }
             }
         }
     }
 }