public LogMsgData[] IsValid(DataSheetInfo sInfo, int index)
        {
            List <LogMsgData> result = new List <LogMsgData>();
            DataFieldInfo     dfi    = sInfo.GetFieldInfo(index);
            int len = 0;

            if (!int.TryParse(dfi.validationValue, out len))
            {
                return(null);
            }
            int count = sInfo.GetContentCount();

            for (int i = 0; i < count; i++)
            {
                object data = sInfo.GetContentValue(i, index);
                if (data != null && (dfi.type == DataFieldType.Int || dfi.type == DataFieldType.Float || dfi.type == DataFieldType.Double || dfi.type == DataFieldType.Long))
                {
                }
            }

            if (result.Count > 0)
            {
                return(result.ToArray());
            }
            else
            {
                return(null);
            }
        }
        public LogMsgData[] IsValid(DataSheetInfo sInfo, int index)
        {
            List <LogMsgData> result = new List <LogMsgData>();
            DataFieldInfo     dfi    = sInfo.GetFieldInfo(index);
            int count = sInfo.GetContentCount();
            Dictionary <string, bool> cacheData = new Dictionary <string, bool>();

            for (int i = 0; i < count; i++)
            {
                object data = sInfo.GetContentValue(i, index);
                if (data == null)
                {
                    result.Add(new ErrorLogData1(LogConst.E_DataValidation_Null, "" + index));
                }
            }

            if (result.Count > 0)
            {
                return(result.ToArray());
            }
            else
            {
                return(null);
            }
        }
        public LogMsgData[] IsValid(DataSheetInfo sInfo, int index)
        {
            List <LogMsgData> result = new List <LogMsgData>();
            DataFieldInfo     dfi    = sInfo.GetFieldInfo(index);
            int len = 0;

            if (!int.TryParse(dfi.validationValue, out len))
            {
                return(null);
            }
            int count = sInfo.GetContentCount();

            for (int i = 0; i < count; i++)
            {
                object data = sInfo.GetContentValue(i, index);
                if (data != null && (dfi.type == DataFieldType.String || dfi.type == DataFieldType.Stringt || dfi.type == DataFieldType.Res))
                {
                    string value = (string)data;
                    if (value.Length > len)
                    {
                        result.Add(new ErrorLogData3(LogConst.E_DataValidation_StrLen, "" + index, "" + len, value));
                    }
                }
            }

            if (result.Count > 0)
            {
                return(result.ToArray());
            }
            else
            {
                return(null);
            }
        }
        public LogMsgData[] IsValid(DataSheetInfo sInfo, int index)
        {
            List <LogMsgData> result = new List <LogMsgData>();
            DataFieldInfo     dfi    = sInfo.GetFieldInfo(index);
            int count = sInfo.GetContentCount();
            Dictionary <string, bool> cacheData = new Dictionary <string, bool>();

            for (int i = 0; i < count; i++)
            {
                object data = sInfo.GetContentValue(i, index);
                if (data != null)
                {
                    string validaStr = null;
                    if (dfi.type == DataFieldType.Dic)
                    {
                        Dictionary <string, string> dicData = (Dictionary <string, string>)data;
                        List <string> tempStrs = new List <string>();
                        foreach (KeyValuePair <string, string> kvp in dicData)
                        {
                            string t = kvp.Key + ":" + (kvp.Value == null ? "null" : kvp.Value);
                            tempStrs.Add(t);
                        }
                        tempStrs.Sort();
                        validaStr = string.Join(",", tempStrs.ToArray());
                    }
                    else if (dfi.type == DataFieldType.Array)
                    {
                        List <string> arrData = (List <string>)data;
                        arrData.Sort();
                        validaStr = string.Join(",", arrData.ToArray());
                    }
                    else
                    {
                        validaStr = (string)data;
                    }
                    if (cacheData.ContainsKey(validaStr))
                    {
                        result.Add(new ErrorLogData2(LogConst.E_DataValidation_Repeat, "" + index, validaStr));
                    }
                    else
                    {
                        cacheData.Add(validaStr, true);
                    }
                }
            }
            if (result.Count > 0)
            {
                return(result.ToArray());
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        private void CreateSummary()
        {
            summary.count        = dataSheet.GetContentCount();
            summary.subformCount = (int)Math.Ceiling(((float)summary.count) / exportConfig.subform);

            summary.textPath = dataSheet.Name + "Text";
            summary.strPath  = dataSheet.Name + "Str";

            for (int i = 0; i < dataSheet.GetFieldCount(); i++)
            {
                DataFieldInfo dfInfo = dataSheet.GetFieldInfo(i);
                if (dfInfo.type == DataFieldType.Stringt)
                {
                    summary.textFields.Add(dfInfo.name);
                }
                else if (dfInfo.type == DataFieldType.String || dfInfo.type == DataFieldType.Res)
                {
                    summary.strFields.Add(dfInfo.name);
                }
            }

            int index = 1;

            while (true)
            {
                DataToOptimizeLuaSummary.SubformDataOfSummary subformData = new DataToOptimizeLuaSummary.SubformDataOfSummary();
                subformData.path  = string.Format("{0}/{0}_{1}", dataSheet.Name, index);
                subformData.minID = int.Parse((string)dataSheet.GetContentValue((index - 1) * exportConfig.subform, 0));
                int maxIndex = index * exportConfig.subform - 1;
                if (maxIndex >= dataSheet.GetContentCount())
                {
                    maxIndex = dataSheet.GetContentCount() - 1;
                }
                subformData.maxID = int.Parse((string)dataSheet.GetContentValue(maxIndex, 0));

                summary.subforms.Add(subformData);

                if (maxIndex == dataSheet.GetContentCount() - 1)
                {
                    break;
                }

                index++;
            }

            for (int i = 1; i < dataSheet.GetFieldCount(); i++)
            {
                DataFieldInfo dfInfo = dataSheet.GetFieldInfo(i);
                if (dfInfo.type == DataFieldType.Array || dfInfo.type == DataFieldType.Dic)
                {
                    continue;
                }
                Dictionary <string, int> totalCount = new Dictionary <string, int>();
                for (int j = 0; j < dataSheet.GetContentCount(); j++)
                {
                    string data = (string)dataSheet.GetContentValue(j, i, true);
                    if (!string.IsNullOrEmpty(data))
                    {
                        if (dfInfo.type == DataFieldType.Stringt)
                        {
                            data = "" + text.AddText(data);
                        }
                        else if (dfInfo.type == DataFieldType.String || dfInfo.type == DataFieldType.Res)
                        {
                            data = "" + str.AddText(data);
                        }

                        if (totalCount.ContainsKey(data))
                        {
                            totalCount[data]++;
                        }
                        else
                        {
                            totalCount.Add(data, 1);
                        }
                    }
                }
                string maxValue = null;
                int    maxCount = 0;
                foreach (KeyValuePair <string, int> kvp in totalCount)
                {
                    if (kvp.Value > maxCount)
                    {
                        maxValue = kvp.Key;
                        maxCount = kvp.Value;
                    }
                }

                if (maxValue != null && maxCount > 1)
                {
                    summary.defaultDic.Add(dfInfo, maxValue);
                }
            }
        }