예제 #1
0
        public override bool runCmd(CommandConfig cfg)
        {
            string destPath = Path.Combine(cfg.CheckPath, dir.Replace("%gamedir%", cfg.GameDir));

            string[] files = Directory.GetFiles(destPath, file,
                                                onlyTop ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories);
            if (notExist)
            {
                if (files.Length > 0)
                {
                    logText("错误:" + files[0] + " 不应该存在!");
                }
            }
            else
            {
                if (files.Length == 0)
                {
                    logText("错误:" + dir + "/" + file + " 找不到!");
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #2
0
        public override bool runCmd(CommandConfig cfg)
        {
            string destPath = Path.Combine(cfg.CheckPath, dir.Replace("%gamedir%", cfg.GameDir));

            if (!Directory.Exists(destPath))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + destPath + " 不存在!");
                return(false);
            }

            string[] files = Directory.GetFiles(destPath, file,
                                                onlyTop ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories);
            foreach (string filePath in files)
            {
                string subPath = filePath;
                if (subPath.StartsWith(destPath))
                {
                    subPath = subPath.Substring(destPath.Length);
                }
                if (onlyFileName)
                {
                    subPath = Path.GetFileName(subPath);
                }
                if (onlyExtension)
                {
                    subPath = Path.GetExtension(subPath);
                }
                if (onlyAsc)
                {
                    char[] nameArr = subPath.ToCharArray();
                    foreach (char ch in nameArr)
                    {
                        if (ch < 0 || ch > 127)
                        {
                            logText("错误:" + filePath + "," + subPath + " 包含中文字符!");
                            return(false);
                        }
                    }
                }
                if (onlyLower)
                {
                    if (!subPath.Equals(subPath.ToLower()))
                    {
                        logText("错误:" + filePath + "," + subPath + " 包含大写!");
                        return(false);
                    }
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #3
0
        public override bool runCmd(CommandConfig cfg)
        {
            string destFile = Path.Combine(cfg.CheckPath, sourceFile.Replace("%gamedir%", cfg.GameDir));

            if (!File.Exists(destFile))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + Name + "," + destFile + " 文件不存在");
                return(false);
            }

            XmlDocument xd = new XmlDocument();

            xd.Load(destFile);

            XmlNode dictNode = xd.SelectSingleNode("plist/dict");
            bool    readKey  = true;

            for (int i = 0; i < dictNode.ChildNodes.Count; i++)
            {
                XmlNode childNode = dictNode.ChildNodes[i];
                if (childNode.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (readKey)
                {
                    if (!childNode.Name.Equals("key"))
                    {
                        logText("错误:" + Name + "," + sourceFile + "," + childNode.OuterXml);
                        return(false);
                    }
                    readKey = false;
                    continue;
                }
                else
                {
                    if (!childNode.Name.Equals("string"))
                    {
                        logText("错误:" + Name + "," + sourceFile + "," + childNode.OuterXml);
                        return(false);
                    }
                    readKey = true;
                    continue;
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #4
0
        public override bool runCmd(CommandConfig cfg)
        {
            string destPath = Path.Combine(cfg.CheckPath, dir.Replace("%gamedir%", cfg.GameDir));

            string[] files = Directory.GetFiles(destPath, file, SearchOption.AllDirectories);

            ScriptRoot root = new ScriptRoot();

            foreach (string filePath in files)
            {
                bool eexFileOk = true;
                try
                {
                    using (FileStream fs = new FileStream(filePath, FileMode.Open))
                    {
                        byte[] buffer  = new byte[fs.Length];
                        int    readLen = fs.Read(buffer, 0, buffer.Length);
                        fs.Close();
                        if (readLen == buffer.Length)
                        {
                            eexFileOk = root.loadReader(new EexBinaryReader(buffer, EexBinaryReader.ENCODING_UTF8));
                        }
                        else
                        {
                            eexFileOk = false;
                        }
                    }
                }
                catch (Exception)
                {
                    eexFileOk = false;
                }
                if (!eexFileOk)
                {
                    logText("错误:" + filePath + " 格式不对!");
                    return(false);
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #5
0
        public override bool runCmd(CommandConfig cfg)
        {
            if (cfg.JsonFiles.ContainsKey(Name))
            {
                logText("错误:" + Name + " 重复加载");
                return(false);
            }

            string destFile = Path.Combine(cfg.CheckPath, Src.Replace("%gamedir%", cfg.GameDir));

            if (!File.Exists(destFile))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + Name + "," + destFile + " 文件不存在");
                return(false);
            }

            String text = "";

            using (StreamReader sr = new StreamReader(destFile, Encoding.UTF8))
            {
                text = sr.ReadToEnd();
            }

            try
            {
                JArray obj = JArray.Parse(text);
                cfg.JsonFiles[Name] = obj;
            }
            catch (Exception)
            {
                logText("错误:" + Name + "," + destFile + " 文件解析 json 失败");
                return(false);
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #6
0
        public bool runCmd(CommandConfig cfg)
        {
            bool result = true;

            for (int i = 0; i < cmdList.Count; i++)
            {
                CmdBase cb = cmdList[i];
                if (needRun(cb))
                {
                    if (!cb.runCmd(cfg))
                    {
                        result = false;
                    }
                }
            }

            logText(DateTime.Now.ToString() + " 检查完毕");

            return(result);
        }
예제 #7
0
        public override bool runCmd(CommandConfig cfg)
        {
            if (!cfg.JsonFiles.ContainsKey(Name))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + Name + " 不存在");
                return(false);
            }

            JArray jarr = cfg.JsonFiles[Name] as JArray;

            if (jarr == null)
            {
                logText("错误:" + Name + " 类型不对");
                return(false);
            }

            foreach (String col in Columns)
            {
                for (int i = 0; i < jarr.Count; i++)
                {
                    JObject obj = (JObject)jarr[i];
                    if (obj[col] == null)
                    {
                        if (optionalFile)
                        {
                            continue;
                        }
                        logText("错误:" + Name + "," + col + " 不存在");
                        return(false);
                    }
                    switch (DataType)
                    {
                    case ColumnType.TypeInteger:
                    {
                        if (obj[col].Type != JTokenType.Integer)
                        {
                            logText("错误:" + Name + "," + col + " 类型不对:" + obj.ToString());
                            return(false);
                        }
                        int intValue = obj[col].ToObject <int>();
                        if (maxValue != null)
                        {
                            if (intValue > maxValue)
                            {
                                logText("错误:" + Name + "," + col + " 值太大:" + obj.ToString());
                                return(false);
                            }
                        }
                        if (valueContain.Count > 0)
                        {
                            if (!valueContain.ContainsKey(intValue))
                            {
                                logText("错误:" + Name + "," + col + " 超出指定范围:" + obj.ToString());
                                return(false);
                            }
                        }
                    }
                    break;

                    case ColumnType.TypeString:
                        if (obj[col].Type != JTokenType.String)
                        {
                            logText("错误:" + Name + "," + col + " 类型不对:" + obj.ToString());
                            return(false);
                        }
                        break;

                    case ColumnType.TypeIntegerAnd:
                    {
                        if (obj[col].Type != JTokenType.String)
                        {
                            logText("错误:" + Name + "," + col + " 类型不对:" + obj.ToString());
                            return(false);
                        }
                        string colV = obj[col].ToObject <string>();
                        if (colV.EndsWith("&"))
                        {
                            colV = colV.Substring(0, colV.Length - 1);
                        }
                        if (ignoreEmpty && String.IsNullOrEmpty(colV))
                        {
                        }
                        else
                        {
                            string[] strArr = colV.Split('&');
                            foreach (string strItem in strArr)
                            {
                                int temp = 0;
                                if (!int.TryParse(strItem, out temp))
                                {
                                    logText("错误:" + Name + "," + col + " 类型不对:" + obj.ToString());
                                    return(false);
                                }
                                if (maxValue != null)
                                {
                                    if (temp > maxValue)
                                    {
                                        logText("错误:" + Name + "," + col + " 值太大:" + obj.ToString());
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    break;

                    default:
                        logText("错误:" + Name + "," + col + " 类型不对:" + obj.ToString());
                        return(false);
                    }
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #8
0
        public override bool runCmd(CommandConfig cfg)
        {
            if (!cfg.JsonFiles.ContainsKey(Name))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + Name + " 不存在");
                return(false);
            }

            JArray jarr = cfg.JsonFiles[Name] as JArray;

            if (jarr == null)
            {
                logText("错误:" + Name + " 类型不对");
                return(false);
            }

            if (DataType == ColumnType.TypeInteger)
            {
                foreach (String col in Columns)
                {
                    Dictionary <int, object> colContainer = new Dictionary <int, object>();

                    for (int i = 0; i < jarr.Count; i++)
                    {
                        JObject obj = (JObject)jarr[i];

                        if (obj[col] == null)
                        {
                            logText("错误:" + Name + "," + col + " 不存在");
                            return(false);
                        }

                        int v = obj[col].ToObject <int>();
                        if (colContainer.ContainsKey(v))
                        {
                            logText("错误:" + Name + "," + col + " 值重复:" + obj.ToString());
                            return(false);
                        }
                        colContainer.Add(v, obj);
                    }
                }
            }
            else if (DataType == ColumnType.TypeString)
            {
                foreach (String col in Columns)
                {
                    Dictionary <string, object> colContainer = new Dictionary <string, object>();

                    for (int i = 0; i < jarr.Count; i++)
                    {
                        JObject obj = (JObject)jarr[i];

                        if (obj[col] == null)
                        {
                            logText("错误:" + Name + "," + col + " 不存在");
                            return(false);
                        }

                        string v = obj[col].ToObject <string>();
                        if (colContainer.ContainsKey(v))
                        {
                            logText("错误:" + Name + "," + col + " 值重复:" + obj.ToString());
                            return(false);
                        }
                        colContainer.Add(v, obj);
                    }
                }
            }
            else if (DataType == ColumnType.TypeMix)
            {
                Dictionary <string, object> colContainer = new Dictionary <string, object>();

                for (int i = 0; i < jarr.Count; i++)
                {
                    JObject       obj = (JObject)jarr[i];
                    StringBuilder sb  = new StringBuilder();

                    foreach (String col in Columns)
                    {
                        if (obj[col] == null)
                        {
                            logText("错误:" + Name + "," + col + " 不存在");
                            return(false);
                        }

                        if (obj[col].Type == JTokenType.Integer)
                        {
                            sb.Append(obj[col].ToObject <int>());
                        }
                        else
                        {
                            sb.Append(obj[col].ToObject <string>());
                        }
                        sb.Append(',');
                    }

                    string v = sb.ToString();
                    if (colContainer.ContainsKey(v))
                    {
                        logText("错误:" + Name + ":" + columnSrc + " 值重复:" + obj.ToString());
                        return(false);
                    }
                    colContainer.Add(v, obj);
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #9
0
        public override bool runCmd(CommandConfig cfg)
        {
            if (!cfg.JsonFiles.ContainsKey(Name))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + Name + " 不存在");
                return(false);
            }

            JArray jarr = cfg.JsonFiles[Name] as JArray;

            if (jarr == null)
            {
                logText("错误:" + Name + " 类型不对");
                return(false);
            }

            if (dataType == ColumnType.TypeNone)
            {
                string destPath = Path.Combine(cfg.CheckPath, dir.Replace("%gamedir%", cfg.GameDir));

                string[] files = file.Split(';');
                foreach (string item in files)
                {
                    string destFile = Path.Combine(destPath, item);
                    if (!File.Exists(destFile))
                    {
                        logText("错误:" + Name + "," + destFile + " 不存在!:");
                        return(false);
                    }
                }
            }
            else if (dataType == ColumnType.TypeInteger)
            {
                string col = column;

                string destPath = Path.Combine(cfg.CheckPath, dir.Replace("%gamedir%", cfg.GameDir));

                for (int i = 0; i < jarr.Count; i++)
                {
                    JObject obj = (JObject)jarr[i];
                    int     v   = obj[col].ToObject <int>();
                    if (ignoreValue.ContainsKey(v))
                    {
                        continue;
                    }
                    string destFile = Path.Combine(destPath, expression.ComputeInt(v));
                    if (!File.Exists(destFile))
                    {
                        logText("错误:" + Name + "," + destFile + " 不存在!:" + obj.ToString());
                        return(false);
                    }
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #10
0
        public override bool runCmd(CommandConfig cfg)
        {
            if (!cfg.JsonFiles.ContainsKey(Name))
            {
                if (optionalFile)
                {
                    return(true);
                }
                logText("错误:" + Name + " 不存在");
                return(false);
            }
            JArray jarr = cfg.JsonFiles[Name] as JArray;

            if (jarr == null)
            {
                logText("错误:" + Name + " 类型不对");
                return(false);
            }

            if (!cfg.JsonFiles.ContainsKey(foreign.Table))
            {
                logText("错误:" + Name + "," + foreign.Table + " 不存在");
                return(false);
            }
            JArray foreignarr = cfg.JsonFiles[foreign.Table] as JArray;

            if (jarr == null)
            {
                logText("错误:" + Name + "," + foreign.Table + " 类型不对");
                return(false);
            }

            if (dataType == ColumnType.TypeInteger)
            {
                Dictionary <int, object> foreignValue = new Dictionary <int, object>();
                for (int i = 0; i < foreignarr.Count; i++)
                {
                    JObject item = (JObject)foreignarr[i];

                    if (item[foreign.Column] == null)
                    {
                        logText("错误:" + Name + "," + foreign.ToString() + " 不存在");
                        return(false);
                    }

                    int v = item[foreign.Column].ToObject <int>();
                    foreignValue[v] = item;
                }

                for (int i = 0; i < jarr.Count; i++)
                {
                    JObject item = (JObject)jarr[i];

                    if (item[column] == null)
                    {
                        if (optionalFile)
                        {
                            continue;
                        }
                        logText("错误:" + Name + "," + column + " 不存在");
                        return(false);
                    }

                    int v = item[column].ToObject <int>();
                    if (v == 0 && ignoreZero)
                    {
                        continue;
                    }
                    if (ignoreValue.ContainsKey(v))
                    {
                        continue;
                    }
                    if (!foreignValue.ContainsKey(v))
                    {
                        logText("错误:" + Name + "," + column + "=" + v + ",不存在:" + item.ToString());
                        return(false);
                    }
                }
            }
            else if (dataType == ColumnType.TypeIntegerAnd)
            {
                Dictionary <int, object> foreignValue = new Dictionary <int, object>();
                for (int i = 0; i < foreignarr.Count; i++)
                {
                    JObject item = (JObject)foreignarr[i];

                    if (item[foreign.Column] == null)
                    {
                        logText("错误:" + Name + "," + foreign.ToString() + " 不存在");
                        return(false);
                    }

                    int v = item[foreign.Column].ToObject <int>();
                    foreignValue[v] = item;
                }

                for (int i = 0; i < jarr.Count; i++)
                {
                    JObject item = (JObject)jarr[i];

                    if (item[column] == null)
                    {
                        logText("错误:" + Name + "," + column + " 不存在");
                        return(false);
                    }

                    string colValue = item[column].ToObject <string>();
                    if (colValue.EndsWith("&"))
                    {
                        colValue = colValue.Substring(0, colValue.Length - 1);
                    }
                    if (String.IsNullOrEmpty(colValue))
                    {
                        if (ignoreEmpty)
                        {
                            continue;
                        }
                        logText("错误:" + Name + "," + column + " 为空");
                        return(false);
                    }
                    else
                    {
                        string[] strArr = colValue.Split('&');
                        foreach (string strItem in strArr)
                        {
                            int iItem = int.Parse(strItem);
                            if (iItem == 0 && ignoreZero)
                            {
                                continue;
                            }
                            if (iItem >= valueJudge)
                            {
                                iItem = iItem + valueAdd;
                            }
                            if (!foreignValue.ContainsKey(iItem))
                            {
                                logText("错误:" + Name + "," + column + "=" + iItem + ",不存在:" + item.ToString());
                                return(false);
                            }
                        }
                    }
                }
            }

            if (cfg.ShowAllLog)
            {
                logText(ToString() + " 完毕");
            }
            return(true);
        }
예제 #11
0
파일: CmdBase.cs 프로젝트: droidsde/game
 public abstract bool runCmd(CommandConfig cfg);