Beispiel #1
0
        public string Matching(DataTable table)
        {
            xlsTable = table;
            AllFound = true;
            DataColumnCollection columns = xlsTable.Columns;

            var fieldMultiply = FindAll(x => (x.Attr == attrName.Myltiply) & x.IsActive);

            string tableRows = string.Empty;

            foreach (FieldMultiply field in fieldMultiply)
            {
                string error = field.initFilds();
                if (error == String.Empty)
                {
                    Func <ValidData, ValidValue> valFunc = null;

                    setValidator(out valFunc, field.Type.Name, "String");
                    field.Validator = valFunc;

                    setValidator(out valFunc, field.Type2.Name, "String");
                    field.Validator1 = valFunc;

                    field.SetTableFields(table.Columns);
                    tableRows += htmlTableRow(field.FullName, field.ResTableFields.Length);
                }
                else
                {
                    tableRows += htmlTableRow(field.FullName, field.ResTableFields.Length);
                }
            }

            string message = string.Empty;

            if (tableRows != string.Empty)
            {
                message += $"{htmlH2("Повторы")} <table>{tableRows}</table>";
            }

            tableRows = string.Empty;

            foreach (FieldXls field in this.FindAll(x => (x.Attr == attrName.Field) & x.IsActive))
            {
                if (columns.Contains(field.XlsName))
                {
                    string reportValidation = setValidator(field, columns[field.XlsName].DataType.Name);
                    if (reportValidation != String.Empty)
                    {
                        tableRows  += htmlTableRow(true, "(-)", field.XlsName, field.ResName, $"--!!!-- convert error {reportValidation}");
                        field.Exist = false;
                        AllFound    = false;
                    }
                    else
                    {
                        tableRows  += htmlTableRow("(+)", field.XlsName, field.ResName, field.Validator.Method.Name);
                        field.Exist = true;
                    }
                }
                else
                {
                    tableRows += htmlTableRow(true, "(-)", field.XlsName, field.ResName, "поле не найдено!");
                    AllFound   = false;
                }
            }

            if (tableRows != string.Empty)
            {
                message += $"{htmlH2("Поля")} <table>{tableRows}</table>";
            }

            tableRows = string.Empty;

            foreach (FieldBase field in this.FindAll(x => (x.Attr == attrName.Const) & x.IsActive))
            {
                string reportValidation = setValidator(field, dataType.String.ToString());
                if (reportValidation != String.Empty)
                {
                    tableRows += htmlTableRow(field.ResName, reportValidation);
                }
                else
                {
                    string reportInit = field.InitValue();
                    if (reportInit == String.Empty)
                    {
                        tableRows  += htmlTableRow(field.ResName, field.Validator.Method.Name, field.Value);
                        field.Exist = true;
                    }
                    else
                    {
                        tableRows += htmlTableRow(field.ResName, field.Validator.Method.Name, $"((!!!)convert error {reportInit})");
                        AllFound   = false;
                    }
                }
            }

            if (tableRows != string.Empty)
            {
                message += $"{htmlH2("Константы")} <table>{tableRows}</table>";
            }

            tableRows = string.Empty;

            foreach (FieldFunc fieldFunc in this.FindAll(x => (x.Attr == attrName.Func) && x.IsActive))
            {
                fieldFunc.initSQLParameter(this);

                ArrayList paramGroups = new ArrayList(new ParamGroup[]  {
                    fieldFunc.ParamsField,
                    fieldFunc.ParamsIn,
                    fieldFunc.ParamsOut
                });

                string[] groupName = new string[] { "ParamsField", "ParamsIn", "ParamsOut" };

                //foreach (ParamGroup paramGroup in paramGpoups)
                for (int i = 0; i < paramGroups.Count; i++)
                {
                    ParamGroup paramGroup = (ParamGroup)paramGroups[i];

                    if (paramGroup == null)
                    {
                        tableRows += $"<h3 class = \"alert\">- {groupName[i]} </h3>";
                        AllFound   = false;
                    }
                    else
                    {
                        string alert = (!paramGroup.AllFound) ? "class = \"alert\"" : "";

                        tableRows += $"<h3 {alert} > {paramGroup.GroupName}  {paramGroup.msgError}</h3>";

                        if (!paramGroup.AllFound)
                        {
                            AllFound = false;
                        }

                        string funcRows = string.Empty;

                        if (paramGroup.Count > 0)
                        {
                            funcRows = $"<tr><th>{string.Join("</th><th>",paramGroup[0].fieldNames())}</th></tr>";
                            foreach (ParamBase param in paramGroup)
                            {
                                bool error = (param.Error != null);
                                funcRows += htmlTableRow(error, param.fieldValues());
                            }
                            tableRows += $"<table>{funcRows}</table>";
                        }
                    }
                }
            }

            if (tableRows != string.Empty)
            {
                message += $"{htmlH2("Функции")} {tableRows}";
            }

            tableRows = string.Empty;

            foreach (FieldAnswer field in this.FindAll(x => ((x.Attr == attrName.Answer) && x.IsActive)))
            {
                if (field.Param == null)
                {
                    tableRows += htmlTableRow(true, field.ResName, "-");
                    AllFound   = false;
                }
                else
                {
                    tableRows += htmlTableRow(field.ResName, "+");
                }
            }

            if (tableRows != string.Empty)
            {
                message += $"{htmlH2("Ответ сервера")} <table>{tableRows}</table>";
            }

            return(message);
        }
Beispiel #2
0
        public void initSQLParameter(List <FieldBase> fields) //parseSQLParameter
        {
            if (FunctionName == "")
            {
                return;
            }

            string[] nameSplit = xlsName.Split('(');

            var fieldSystem = Scan.FindAll(x => (x.Attr == attrName.System));

            FieldSystem field = null;

            if (fieldSystem != null)
            {
                field = (FieldSystem)fieldSystem.Find(x => ((FieldSystem)x).isShema & (((FieldSystem)x).funcName == FunctionName));
            }

            DataTable impStructure = null;

            if (field != null)
            {
                string[] shema = field.XlsName.Split('(');
                impStructure = getShema();

                for (int i = 0; i < Enum.GetNames(typeof(GroupNames)).Length; i++)
                {
                    string fieldName = ((GroupNames)i).ToString();
                    if (i == 0)
                    {
                        DataRow row = impStructure.Rows.Add();
                        row[fieldName] = tabName;
                    }
                    else
                    {
                        impStructure.Rows[0][fieldName] = shema[i].Split(')')[0];
                    }
                }
            }
            else
            {
                impStructure = SQLFunction.getFuncDescription(FunctionName);
            }

            if (impStructure.Rows.Count == 0)
            {
                return;
            }
            SQLTableName = impStructure.Rows[0][SqlParam[GroupNames.inTable]].ToString(); // impStructure[1][index].Trim();

            if (impStructure.Columns.Contains(SqlParam[GroupNames.tabFields]))
            {
                ParamsField = new ParamGroup(
                    impStructure.Rows[0][SqlParam[GroupNames.tabFields]].ToString(),
                    nameSplit[1].Trim(),
                    GroupNames.tabFields,
                    Scan.FindAll(x => ((x.Attr == attrName.Field) || (x.Attr == attrName.Const) || (x.Attr == attrName.Myltiply)) && x.IsActive),
                    this
                    );
            }

            if (impStructure.Columns.Contains(SqlParam[GroupNames.inPar]))
            {
                ParamsIn = new ParamGroup(
                    impStructure.Rows[0][SqlParam[GroupNames.inPar]].ToString(),
                    nameSplit[2].Trim(),
                    GroupNames.inPar,
                    Scan.FindAll(x => ((x.Attr == attrName.Field) || (x.Attr == attrName.Const)) && x.IsActive),
                    this
                    );
            }

            if (impStructure.Columns.Contains(SqlParam[GroupNames.outPar]))
            {
                ParamsOut = new ParamGroup(
                    impStructure.Rows[0][SqlParam[GroupNames.outPar]].ToString(),
                    nameSplit[3].Trim(),
                    GroupNames.outPar,
                    Scan.FindAll(x => (x.Attr == attrName.Answer) && x.IsActive),
                    this
                    );
            }
        }