示例#1
0
        /// <summary>
        /// 分析Rar文件,并将Config解析为Rule与时间参数
        /// </summary>
        /// <param name="theRarFile">rar文件的地址</param>
        /// <param name="fromDay">开始时间</param>
        /// <param name="toDay">结合时间</param>
        /// <param name="directory">解压缩的文件夹</param>
        /// <param name="needClean">分析结束是否需要清理解压缩的文件夹</param>
        /// <param name="remainRarFile">分析结束是否需要保留Rar文件</param>
        /// <returns>迁移规则</returns>
        public static TransferRule AnalyseRarData(string theRarFile, out DateTime?fromDay, out DateTime?toDay, string directory, bool needClean, bool remainRarFile)
        {
            //解压缩
            CommandRunner.AssertIsRarFile(theRarFile);
            CommandRunner.UnRarFileToDirectory(theRarFile, DiskOperations.CorrectDirectory(directory), true);

            //分析config文件
            string ruleString;
            Dictionary <string, string> theRuleStrings = new Dictionary <string, string>();

            theRuleStrings.Add(ReadConfig(DiskOperations.CorrectDirectory(directory), out ruleString, out fromDay, out toDay), ruleString);
            List <TransferRule> allTransferRule = RuleConverter.Convert(theRuleStrings);

            if (allTransferRule.Count != 1)
            {
                throw new ApplicationException(Utility._Error_AnalyseRarData_Error);
            }

            if (needClean)
            {
                CommandRunner.CleanUpDirectory(DiskOperations.CorrectDirectory(directory));
            }
            if (!remainRarFile)
            {
                CommandRunner.DeleteFile(theRarFile);
            }

            return(allTransferRule[0]);
        }
示例#2
0
 public static void ResetAllRules()
 {
     StaticConfigTable.ResetConfigs();
     StaticConfigTable.ReadToTable();
     _AllTransferRules = RuleConverter.Convert(StaticConfigTable.TranferRule);
 }