コード例 #1
0
        public void Initialize(int id, string name, string source, string destination, string extensionRegex, string nameRegex,
                               string attributeMatch, string format, string perform, int fileType, bool enabled)
        {
            try {
                ID             = id;
                Name           = name;
                Source         = new DirectoryInfo(source);
                Destination    = new DirectoryInfo(destination);
                ExtensionRegex = new Regex(extensionRegex);
                NameRegex      = new Regex(nameRegex);
                Format         = format;
                perform        = perform.ToLower();
                FileTypeIndex  = fileType;
                Enabled        = enabled;
                switch (perform)
                {
                case "copy":
                    PerformType = PerformTaskType.Copy;
                    break;

                case "move":
                    PerformType = PerformTaskType.Move;
                    break;

                case "rename":
                    PerformType = PerformTaskType.Rename;
                    break;

                case "delete":
                    PerformType = PerformTaskType.Delete;
                    break;

                default:
                    PerformType = PerformTaskType.Copy;
                    break;
                }
                if (attributeMatch.Length > 0)
                {
                    AttributeMatchList = new List <FileTag>();
                    List <string> AttributeGroups = new List <string>(attributeMatch.Split('|'));
                    string[]      AttributeField;
                    foreach (string AttributeGroup in AttributeGroups)
                    {
                        if (AttributeGroup.Length > 0)
                        {
                            AttributeField = AttributeGroup.Split('?');
                            if (AttributeField.Length == 2)
                            {
                                AttributeMatchList.Add(new FileTag(AttributeField[0], AttributeField[1]));
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Log.Write("Task::Initialize() Error -> " + ex.Message);
            }
        }