Exemplo n.º 1
0
        public void FillResult()
        {
            string activeField = Scan.ACTIVE_FIELD;

            ExecServerFunc();
            onInitProgressBar?.Invoke(ResSqlTable.Rows.Count);

            DataRowCollection rows = Scan.ResTable.Rows;

            FieldBase clear = this.Scan.Find(x => (x.Attr == attrName.System) && (x.ResName == "CLEAR_ROWS") && x.IsActive);

            DataColumnCollection resColumns = Scan.ResTable.Columns;

            resColumns.Add(activeField, typeof(Boolean));
            if (clear != null)
            {
                //Scan.ResTable.Columns.Add(activeField, typeof(Boolean));
                resColumns[activeField].DefaultValue = false;
            }
            else
            {
                resColumns[activeField].DefaultValue = true;
            }



            foreach (DataRow row in ResSqlTable.Rows)
            {
                //row[activeField] = true;
                SqlCurrentRow = row;
                int rowId = (int)SqlCurrentRow["ROW_ID"];
                if (rows.Count > rowId)
                {
                    ResCurrentRow = rows[rowId];
                }
                else
                {
                    DataRow newRow = Scan.ResTable.NewRow();
                    if (Scan.ResTable.Columns.Contains("ROW_ID"))
                    {
                        newRow["ROW_ID"] = rowId + 1;
                    }
                    ResCurrentRow = newRow;
                    rows.Add(newRow);
                }
                //if (clear != null)
                //    ResCurrentRow[activeField] = true;
                ResCurrentRow[activeField] = true;
                foreach (ParamBase param in ParamsOut)
                {
                    param.InitField();
                }
                onStepProgressBar?.Invoke();
            }
            if (clear != null)
            {
                var rowsDelete = Scan.ResTable.Select(String.Format("{0} is null", activeField));
                foreach (var rowDel in rowsDelete)
                {
                    rowDel.Delete();
                }
                //Scan.ResTable.Columns.Remove(activeField);
            }
            onHideProgressBar?.Invoke();
        }
Exemplo n.º 2
0
//        public ParamGroup(string sqlParam, string tmplParam,

        public ParamGroup(string sqlParam, string tmplPatam,
                          GroupNames paramGroup, List <FieldBase> fields, FieldFunc ownField)
        {
            string[] sqlArray   = sqlParam.Split(')')[0].Split(new Char[] { ' ', ',' });
            string[] paramArray = tmplPatam.Split(new Char[] { ' ', ',', ')' });
            GroupName = paramGroup.ToString();

            for (int i = 0; i < sqlArray.Length; i++)
            {
                if (i >= paramArray.Length)
                {
                    msgError += String.Format(";missed param. {0}", sqlArray[i]);
                    if (GroupNames.outPar != paramGroup)
                    {
                        AllFound = false;
                    }
                    break;
                }

                string resName = paramArray[i];
                if (paramGroup == GroupNames.outPar)
                {
                    resName = String.Format("{0}.{1}", ownField.ResName, resName);
                }
                FieldBase field = fields.Find(x => (x.ResName == resName) & (x.Attr != attrName.Myltiply));
                if (field == null)
                {
                    var multyFiels = fields.FindAll(x => x.Attr == attrName.Myltiply);
                    field = multyFiels.Find(x => (x as FieldMultiply).NameVal1 == resName | (x as FieldMultiply).NameVal2 == resName);
                }
                bool isSystem = !paramArray[i].Any(Char.IsLower);
                if ((field == null) && !isSystem)
                {
                    msgError += String.Format(";missed field {0}", paramArray[i]);
                    if (GroupNames.outPar != paramGroup)
                    {
                        AllFound = false;
                    }
                    continue;
                }

                ParamBase newParam = null;
                switch (paramGroup)
                {
                case GroupNames.outPar:
                    newParam = new ParamAnswer(paramArray[i], sqlArray[i], ownField, field);
                    break;

                default:
                    if (isSystem)
                    {
                        newParam = new ParamSys(paramArray[i], sqlArray[i], ownField);
                    }
                    else
                    {
                        newParam = new ParamToSql(paramArray[i], sqlArray[i], ownField, field);
                    }
                    break;
                }
                if (newParam != null)
                {
                    Add(newParam);
                }
            }
            if ((paramGroup != GroupNames.outPar) && AllFound)
            {
                foreach (ParamBase param in this)
                {
                    if (!param.XlsExist)
                    {
                        AllFound = false;
                        break;
                    }
                }
            }
        }