예제 #1
0
        string execProcOnServer(ProcSql proc)
        {
            string result = String.Empty;

            if (proc.InPar != "")
            {
                string[] inParSql = new string[2];
                inParSql[0] = proc.InPar;
                if (proc.InPar.ToLower() == "ip")
                {
                    inParSql[1] = Scan.GetLocalIPAddress();
                }
                result = SQLFunction.ExecuteProc(proc.SpName, proc.OutPar, inParSql);
            }
            else
            {
                result = SQLFunction.ExecuteProc(proc.SpName, proc.OutPar);
            }
            return(result);
        }
예제 #2
0
 private static void writeToSql(DataTable resultTable, string xlsPach, DataTable table, string[] fields)
 {
     DataRow[] rows = new DataRow[table.Rows.Count];
     for (int count = 0; count < table.Rows.Count; count++)
     {
         DataRow newRow = resultTable.NewRow();
         for (int iField = 0; iField < fields.Length; iField++)
         {
             if (fields[iField] != "")
             {
                 if (table.Rows[count][fields[iField]] != DBNull.Value)
                 {
                     newRow[iField] = table.Rows[count][fields[iField]].ToString();
                 }
             }
         }
         newRow["fname"] = xlsPach;
         newRow["id"]    = count;
         rows[count]     = newRow;
     }
     SQLFunction.BulkWrite("__ukrSib", rows);
 }
예제 #3
0
        public static DataTable GetResultTable(string tableName)
        {
            DataTable tShema = SQLFunction.getShema(tableName);
            DataTable tTypes = SQLFunction.getSQLTypes();

            DataRow[] rType;
            DataTable tInVal = new DataTable();

            foreach (DataRow row in tShema.Rows)
            {
                string sqlType = row["Data_Type"].ToString();
                string sqlName = row["Column_Name"].ToString();

                rType = tTypes.Select(String.Format("sqlType = '{0}'", sqlName));
                if (rType.Length == 0)
                {
                    rType = tTypes.Select(String.Format("sqlType = '{0}'", sqlType));
                }
                tInVal.Columns.Add(row["Column_Name"].ToString(), Type.GetType(String.Format("System.{0}", rType[0]["csType"])));
            }
            return(tInVal);
        }
예제 #4
0
 public void InsertToServer()
 {
     SQLFunction.BulkWrite(SQLTableName, RowsSql);
 }
예제 #5
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
                    );
            }
        }
예제 #6
0
 public bool initSQLResult()
 {
     InSqlTable = SQLFunction.GetResultTable(SQLTableName);
     return(InSqlTable != null);
 }
예제 #7
0
        public void dropTemplate()
        {
            string query = $@"IF OBJECT_ID('tempdb..{tableName}') IS NOT NULL   DROP TABLE {tableName}";

            SQLFunction.ExecuteNonQuery(query, false, conn);
        }
예제 #8
0
 public void createTempTable()
 {
     SQLFunction.ExecuteNonQuery(createTableSctipt, false, conn);
 }
예제 #9
0
 DataTable getType()
 {
     return(SQLFunction.ExecuteSQL("select csType, sqlType from[matchTmpType] "));
 }