Example #1
0
        public static void RegisterFromXsd(XmlDocument doc)
        {
            XSDParser     parser = new XSDParser();
            DataSetConfig config = parser.LoadFromXsd(doc);

            Register(config.NameSpace, config);
        }
Example #2
0
 public static bool GetConfig(string nameSpace, out DataSetConfig config)
 {
     if (nameSpace != null)
     {
         return(registeredConfig.TryGetValue(nameSpace, out config));
     }
     else
     {
         config = null;
         return(false);
     }
 }
Example #3
0
        public virtual DataSet getDataSet(Env env)
        {
            DataSetConfig config     = (DataSetConfig)this.hashtable_0["dsc"];
            Part          part       = new Part(config.SQL);
            string        s          = part["names"];
            string        str3       = part["types"];
            ArgToken      token      = new ArgToken(part["data"], '\n');
            ArgToken      token2     = new ArgToken(s, '\t');
            ArgToken      token3     = new ArgToken(str3, '\t');
            int           initColCap = token2.countTokens();
            int           initRowCap = token.countTokens();
            DataSet       set        = new DataSet(initRowCap, initColCap);

            int[] numArray = new int[initColCap];
            int   index    = 0;

            while (true)
            {
                if (index >= initColCap)
                {
                    break;
                }
                string colName = token2.nextToken();
                set.addColumn(colName);
                numArray[index] = 6;
                try
                {
                    numArray[index] = int.Parse(token3.nextToken());
                }
                catch (Exception)
                {
                    numArray[index] = 6;
                }
                index++;
            }
            for (int i = 0; i < initRowCap; i++)
            {
                Row      row    = set.addRow();
                ArgToken token4 = new ArgToken(token.nextToken(), '\t');
                for (int j = 0; j < initColCap; j++)
                {
                    string val = Escape.removeEscAndQuote(token4.nextToken());
                    row.setData((int)(j + 1), ArgDataType.getProperData(numArray[j], val));
                }
            }
            return(set);
        }
Example #4
0
        private Config()
        {
            String path = Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);

            this.configFileName = path + "\\" + appId + "\\config.xml";

            DisksDB.Utils.Utils.CreateFolders(this.configFileName);

            try
            {
                dataSet.ReadXml(this.configFileName);
            }
            catch (Exception)
            {
                dataSet = new DataSetConfig();

                this.configFileExists = false;
            }
        }
Example #5
0
        public virtual DataSetHelper setDataSetConfigs(Env env, DataSetHelper dss)
        {
            if (env.Request != null)
            {
                //env.Request.get_Item("e_setdataset");
            }
            else
            {
                env.getParameter("e_setdataset");
            }
            DataSetConfig config = dss["ds1"];

            config.SQL = "select * from e_group";
            dss.put(config);
            DataSetConfig config2 = new DataSetConfig {
                Name = "ds2",
                SQL  = "select * from e_group where sdw=?"
            };

            config2.addSQLArgument("北京方成公司", 6);
            dss.put(config2);
            return(dss);
        }
 public ActionResult PullData(DataSetConfig model)
 {
     //hey if you have ratio details?? split this shit into a few DBPulls and return a list, else return one graph
     return Json(DbFetch.PullGraphData(model), JsonRequestBehavior.AllowGet);
 }
Example #7
0
 public ElementConfig(string name, string renderName, bool optional,
                      AttributeConfig[] attributes, ElementConfig[] nestedElements, bool isContainer, DataSetConfig dataSetConfig) : base(name, renderName, optional)
     => (Attributes, NestedElements, IsContainer, DataSetConfig) = (attributes, nestedElements, isContainer, dataSetConfig);
Example #8
0
        public virtual DataSet getDataSet(Env env)
        {
            DataSet       set3;
            DataSetConfig config     = (DataSetConfig)this.hashtable_0["dsc"];
            CellExt1      cs         = (CellExt1)this.hashtable_0["ecs"];
            string        name       = config.Name;
            IDbCommand    pst        = null;
            IDataReader   rs         = null;
            IDbConnection connection = null;

            try
            {
                bool   flag;
                bool   flag2;
                string dataSourceName = config.DataSourceName;
                if (dataSourceName != null)
                {
                    connection = env.getConnection(dataSourceName);
                    if (connection == null)
                    {
                        connection = env.getConnection();
                    }
                }
                else
                {
                    connection     = env.getConnection();
                    dataSourceName = "";
                }
                if ((connection == null) || (connection.State == null))
                {
                    return(null);
                }
                if ((dataSourceName != null) && (dataSourceName.Trim().Length != 0))
                {
                    flag = env.getIsEncoding(dataSourceName);
                }
                else
                {
                    flag = env.getIsEncoding();
                }
                string dbCharset = env.getDBCharset(dataSourceName);
                if ((dbCharset == null) || (dbCharset.Trim().Length == 0))
                {
                    dbCharset = env.getDBCharset();
                }
                string str = MacroCalc.replaceMacros(config.SQL, env.MacrosMap);
                if ((dataSourceName != null) && (dataSourceName.Trim().Length != 0))
                {
                    flag2 = env.getNeedTransSQLcode(dataSourceName);
                }
                else
                {
                    flag2 = env.getNeedTransSQLcode();
                }
                if (flag2)
                {
                    str = Encoding.GetEncoding(dbCharset).GetString(Encoding.Default.GetBytes(str));
                }
                string[] sqlArguments     = config.SqlArguments;
                string[] sqlArgumentsName = config.SqlArgumentsName;
                int[]    argumentTypes    = config.ArgumentTypes;
                object[] objArray         = null;
                if (sqlArguments != null)
                {
                    objArray = new object[sqlArguments.Length];
                    int num7 = 0;
                    for (int i = 0; i < sqlArguments.Length; i++)
                    {
                        num7 = ExpString.indexOf(str, "?", num7 + 1, 18);
                        if ((sqlArguments[i] != null) && sqlArguments[i].ToLower().Equals("@@result"))
                        {
                            objArray[i] = "@@result";
                        }
                        else
                        {
                            objArray[i] = ConvertTool.getValue(new ExpParse(cs, sqlArguments[i]).calculate());
                            if ((objArray[i] != null) && (objArray[i] is ArrayList))
                            {
                                objArray[i] = ((ArrayList)objArray[i]).ToArray();
                                if (((((object[])objArray[i]).Length > 0) && (((object[])objArray[i])[0] is string)) && flag2)
                                {
                                    for (int j = 0; j < ((object[])objArray[i]).Length; j++)
                                    {
                                        ((object[])objArray[i])[j] = Convert.ToString(Encoding.GetEncoding(dbCharset).GetBytes((string)((object[])objArray[i])[0]));
                                    }
                                }
                            }
                            else if ((objArray[i] is string) && flag2)
                            {
                                objArray[i] = Convert.ToString(Encoding.GetEncoding(dbCharset).GetBytes((string)objArray[i]));
                            }
                            if ((objArray[i] != null) && objArray[i].GetType().IsArray)
                            {
                                int           length  = ((object[])objArray[i]).Length;
                                StringBuilder builder = new StringBuilder(2 * length);
                                for (int k = 0; k < length; k++)
                                {
                                    builder.Append("?,");
                                }
                                if ((builder.Length > 0) && (builder[builder.Length - 1] == ','))
                                {
                                    builder.Remove(builder.Length - 1, 1);
                                }
                                if (builder.Length > 1)
                                {
                                    str = new StringBuilder(str.Substring(0, num7).ToString().ToString()).Append(builder.ToString()).Append(str.Substring(num7 + 1)).ToString().ToString();
                                }
                                num7 += builder.Length;
                            }
                        }
                    }
                }
                Logger.debug("下面开始打出sql");
                int num6 = 0;
                if ((3 != config.SQLType) || (connection is OleDbConnection))
                {
                    try
                    {
                        Logger.debug(new StringBuilder(name.ToString().ToString()).Append("=").Append(str).ToString().ToString());
                        pst = SupportClass.TransactionManager.manager.PrepareStatement(connection, str);
                        goto Label_0472;
                    }
                    catch (Exception exception3)
                    {
                        throw new ReportError(new StringBuilder("数据集").Append(name).Append(" sql异常:").Append(exception3.Message).ToString().ToString(), exception3);
                    }
                }
                try
                {
                    pst = SupportClass.TransactionManager.manager.PrepareCall(connection, str);
                }
                catch (Exception exception4)
                {
                    throw new ReportError(new StringBuilder("数据集").Append(name).Append(" sql异常:").Append(exception4.Message).ToString().ToString(), exception4);
                }
Label_0472:
                if ((objArray == null) || (objArray.Length <= 0))
                {
                    goto Label_06A2;
                }
                int index = 0;
                int num3  = 0;
Label_048F:
                if (num3 >= objArray.Length)
                {
                    goto Label_06A2;
                }
                index++;
                if ((sqlArguments[num3] == null) || !sqlArguments[num3].ToLower().Equals("@@result"))
                {
                    goto Label_050E;
                }
                if (!(pst is OracleCommand))
                {
                    goto Label_0698;
                }
                try
                {
                    OracleParameter parameter = new OracleParameter();
                    parameter.ParameterName = (sqlArgumentsName[num3]);
                    parameter.OracleType    = (OracleType)(5);
                    parameter.Direction     = (ParameterDirection)(2);
                    pst.Parameters.Add(parameter);
                    goto Label_0698;
                }
                catch (Exception)
                {
                    goto Label_0698;
                }
Label_0504:
                num6 = index;
                goto Label_068D;
Label_050E:
                try
                {
                    if ((objArray[num3] != null) && objArray[num3].GetType().IsArray)
                    {
                        string msg = new StringBuilder("第").Append(num3).Append("个参数组: ").ToString().ToString();
                        for (int m = 0; m < ((object[])objArray[num3]).Length; m++)
                        {
                            msg = (msg.ToString() + ((object[])objArray[num3])[m].ToString()).ToString().ToString() + ",";
                            SQLTool.setObject(pst, index, ((object[])objArray[num3])[m], argumentTypes[num3], sqlArgumentsName[num3]);
                            index++;
                        }
                        Logger.debug(msg);
                        index--;
                    }
                    else
                    {
                        Logger.debug(new StringBuilder("第").Append(num3).Append("个参数: ").Append(objArray[num3]).ToString().ToString());
                        if ((6 == argumentTypes[num3]) && (objArray[num3] == null))
                        {
                            objArray[num3] = "";
                        }
                        SQLTool.setObject(pst, index, objArray[num3], argumentTypes[num3], sqlArgumentsName[num3]);
                    }
                }
                catch (Exception exception2)
                {
                    throw new ReportError(new StringBuilder("数据集").Append(name).Append("的sql第").Append(num3 + 1).Append("个参数异常:").Append(exception2.Message).ToString().ToString(), exception2);
                }
Label_068D:
                num3++;
                goto Label_048F;
Label_0698:
                if (num6 == 0)
                {
                    goto Label_0504;
                }
                goto Label_068D;
Label_06A2:
                try
                {
                    rs = pst.ExecuteReader();
                }
                catch (Exception exception)
                {
                    throw new ReportError(new StringBuilder("数据集").Append(name).Append("的 sql异常:").Append(exception.Message).ToString().ToString(), exception);
                }
                string beginRow = config.BeginRow;
                string endRow   = config.EndRow;
                if (((beginRow == null) || (beginRow.Trim().Length == 0)) || beginRow.Trim().ToUpper().Equals("null".ToUpper()))
                {
                    beginRow = "0";
                }
                if (((endRow == null) || (endRow.Trim().Length == 0)) || endRow.Trim().ToUpper().Equals("null".ToUpper()))
                {
                    endRow = "0";
                }
                beginRow = MacroCalc.replaceMacros(beginRow, env.MacrosMap);
                endRow   = MacroCalc.replaceMacros(endRow, env.MacrosMap);
                int num  = 0;
                int num2 = 0;
                try
                {
                    object obj2 = ConvertTool.getValue(new ExpParse(env, beginRow).calculate());
                    object obj3 = ConvertTool.getValue(new ExpParse(env, endRow).calculate());
                    if ((obj2 is int) && (obj3 is int))
                    {
                        num  = (int)obj2;
                        num2 = (int)obj3;
                    }
                }
                catch (Exception)
                {
                    throw new ReportError("数据集的起始行或者结束行设置有误。");
                }
                ArrayList   fieldText    = config.getFieldTextList();
                RecordCheck oRecordCheck = new RecordCheck(new ConnectionConfig().getDBOperator(), env.Request, env.Session);
                DataSet     set          = DataSetTool.populate(null, rs, num, num2, dbCharset, fieldText, false, flag, oRecordCheck);
                if ((config.IndexCols != null) && (config.IndexCols.Length > 0))
                {
                    set.createIndex(config.IndexCols, config.IndexSorted);
                }
                set3 = set;
            }
            catch (ReportError error)
            {
                throw error;
            }
            catch (Exception exception5)
            {
                throw new ReportError(exception5.Message, exception5);
            }
            finally
            {
                try
                {
                    if (rs != null)
                    {
                        rs.Close();
                    }
                    if (pst != null)
                    {
                        pst.Dispose();
                    }
                }
                catch (Exception exception6)
                {
                    throw new ReportError(exception6.Message, exception6);
                }
            }
            return(set3);
        }
Example #9
0
 public static void Register(string nameSpace, DataSetConfig config)
 {
     registeredConfig.Add(nameSpace, config);
     datasets.AddRange(config.Datasets);
 }