Exemplo n.º 1
0
        public static DataSet populate(DataSet ds, IDataReader rs, int beginRow, int endRow, string dbCharset, ArrayList fieldText, bool type_forward_only, bool isEncoding, RecordCheck oRecordCheck)
        {
            bool flag;

            if (rs == null)
            {
                return(null);
            }
            if (beginRow > 0)
            {
                for (int j = 0; j < beginRow; j++)
                {
                    rs.Read();
                }
            }
            DataTable schemaTable = rs.GetSchemaTable();

            if (ds == null)
            {
                ds = new DataSet();
            }
            for (int i = 0; i < schemaTable.Rows.Count; i++)
            {
                if ((fieldText != null) && (fieldText.Count > i))
                {
                    ds.addColumn((string)fieldText[i]);
                }
                else
                {
                    ds.addColumn(Convert.ToString(schemaTable.Rows[(i + 1) - 1]["ColumnName"]));
                }
            }
            int num2 = beginRow;

            if (!(flag = dbCharset == null))
            {
                flag = "GBK".ToUpper().Equals(dbCharset.ToUpper());
            }
            if (!flag)
            {
                flag = !isEncoding;
            }
            oRecordCheck.init(rs);
            while (rs.Read())
            {
                if ((endRow > 0) && (num2 > endRow))
                {
                    return(ds);
                }
                if (oRecordCheck.isRecordCanShow(SQLTool.getStr(rs, rs.FieldCount - 1)))
                {
                    Row row = ds.addRow();
                    for (int k = 1; k <= ds.ColumnCount; k++)
                    {
                        object data = rs.GetValue(k - 1);
                        if (data == DBNull.Value)
                        {
                            data = null;
                        }
                        if (((data != null) && (data is string)) && !flag)
                        {
                            try
                            {
                                data = Encoding.GetEncoding("GBK").GetString(Encoding.GetEncoding(dbCharset).GetBytes((string)data));
                            }
                            catch (Exception exception)
                            {
                                throw new ReportError(new StringBuilder("数据编码:").Append(dbCharset).Append(" 不正确,请检查数据源的数据编码配置").ToString().ToString(), exception);
                            }
                        }
                        row.setData(k, data);
                    }
                }
                num2++;
            }
            return(ds);
        }
Exemplo n.º 2
0
        public string sqltoxml()
        {
            string str    = this.xmlDocument_0.DocumentElement.ChildNodes.Item(0).InnerText;
            string strsql = this.xmlDocument_0.DocumentElement.ChildNodes.Item(1).InnerText;
            //this.xmlDocument_0.DocumentElement.ChildNodes[2].InnerText;
            string str3 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(3).InnerText;
            string str4 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(4).InnerText;
            string str5 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(5).InnerText;
            string str6 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(6).InnerText;

            str4 = str4.ToUpper();
            int           num     = int.Parse(str);
            int           num2    = int.Parse(str3);
            StringBuilder builder = new StringBuilder();

            try
            {
                int index = 0;
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                Logger.debug("dropdownlist的SQL语句:" + strsql);
                IDataReader ds    = this.runProc(this.dboperator_0, strsql);
                RecordCheck check = new RecordCheck(this.connectionConfig_0.getDBOperator(), this.httpRequest_0, this.httpSessionState_0);
                check.init(ds);
                string str8 = "";
                for (int i = 0; i < ds.FieldCount; i++)
                {
                    str8 = str8 + ds.GetName(i) + ",";
                }
                if (str8 != "")
                {
                    str8 = str8.Substring(0, str8.Length - 1);
                }
                builder.Append("<root>");
                int num6 = 0;
                int num9 = 0;
                int num5 = 0;
                int num7 = 0;
                int num8 = ds.FieldCount;
                if (str4 == "TRUE")
                {
                    num8++;
                }
                while (ds.Read())
                {
                    if (str6.Equals("是") && (num9 == 0))
                    {
                        builder.Append("<tr height='16'>");
                        index = 0;
                        while (index < num8)
                        {
                            builder.Append("<td align='center' style='font-weight:bold ; cursor:hand ;' >...+...</td>");
                            index++;
                        }
                        builder.Append("</tr>");
                        num9 = 1;
                    }
                    if (str5.Equals("是") && (num7 == 0))
                    {
                        builder.Append("<tr height='16'>");
                        index = 0;
                        while (index < num8)
                        {
                            builder.Append("<td></td>");
                            index++;
                        }
                        builder.Append("</tr>");
                        num7 = 1;
                    }
                    if (check.isRecordCanShow(SQLTool.getStr(ds, (int)(ds.FieldCount - 1), this.string_0)))
                    {
                        if (((num6 >= ((num - 1) * num2)) && (num6 < (num * num2))) || (num2 == -1))
                        {
                            builder.Append("<tr>");
                            for (index = 0; index < ds.FieldCount; index++)
                            {
                                string str9 = SQLTool.getStr(ds, index, this.string_0);
                                if (str9 == null)
                                {
                                    str9 = "";
                                }
                                builder.Append("<td>" + str9 + "</td>");
                            }
                            if (str4 != "TRUE")
                            {
                                builder.Append("</tr>");
                            }
                            else
                            {
                                builder.Append("<td style='width:20px'><input type='checkbox'></input></td></tr>");
                            }
                        }
                        num6++;
                    }
                }
                num6--;
                if (num6 > 0)
                {
                    if ((num6 % num2) > 0)
                    {
                        num5 = (num6 / num2) + 1;
                    }
                    else
                    {
                        num5 = num6 / num2;
                    }
                }
                builder.Append(string.Concat(new object[] { "<pagenumber>", num5, "</pagenumber><intpage>", num, "</intpage><fields>", str8, "</fields></root>" }));
                ds.Close();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(builder.ToString());
        }
Exemplo n.º 3
0
        public string fillcombox()
        {
            string        strsql  = this.xmlDocument_0.DocumentElement.ChildNodes.Item(0).InnerText;
            StringBuilder builder = new StringBuilder();
            int           num     = 1;

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                Logger.debug("combobox的SQL语句:" + strsql);
                IDataReader ds    = this.runProc(this.dboperator_0, strsql);
                RecordCheck check = new RecordCheck(this.connectionConfig_0.getDBOperator(), this.httpRequest_0, this.httpSessionState_0);
                check.init(ds);
                num = ds.FieldCount;
                string str2 = "";
                while (ds.Read())
                {
                    if (check.isRecordCanShow(SQLTool.getStr(ds, (int)(ds.FieldCount - 1), this.string_0)))
                    {
                        if (num <= 1)
                        {
                            str2 = SQLTool.getStr(ds, 0, this.string_0);
                            if (str2 == null)
                            {
                                str2 = "";
                            }
                            builder.Append("<option value='" + str2);
                            builder.Append("' >" + str2 + "</option>");
                        }
                        else
                        {
                            str2 = SQLTool.getStr(ds, 0, this.string_0);
                            if (str2 == null)
                            {
                                str2 = "";
                            }
                            builder.Append("<option value='" + str2);
                            str2 = SQLTool.getStr(ds, 1, this.string_0);
                            if (str2 == null)
                            {
                                str2 = "";
                            }
                            builder.Append("' >" + str2 + "</option>");
                        }
                    }
                }
                ds.Close();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(builder.ToString());
        }
Exemplo n.º 4
0
        public string fc_select()
        {
            string        strsql  = this.xmlDocument_0.DocumentElement.ChildNodes.Item(0).InnerText;
            string        str2    = this.xmlDocument_0.DocumentElement.ChildNodes.Item(1).InnerText;
            string        str3    = this.xmlDocument_0.DocumentElement.ChildNodes.Item(2).InnerText;
            int           num     = int.Parse(str2);
            int           num2    = int.Parse(str3);
            StringBuilder builder = new StringBuilder("<root>");
            int           num3    = 1;

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                IDataReader ds    = this.runProc(this.dboperator_0, strsql);
                RecordCheck check = new RecordCheck(this.connectionConfig_0.getDBOperator(), this.httpRequest_0, this.httpSessionState_0);
                check.init(ds);
                while (ds.Read())
                {
                    if (check.isRecordCanShow(SQLTool.getStr(ds, (int)(ds.FieldCount - 1), this.string_0)))
                    {
                        if (((num3 > ((num - 1) * num2)) && (num3 <= (num * num2))) || (num2 == -1))
                        {
                            builder.Append("<record>");
                            for (int i = 0; i < ds.FieldCount; i++)
                            {
                                string str4 = ds.GetName(i).ToString();
                                if (str4 != null)
                                {
                                    string str5 = SQLTool.getStr(ds, i, this.string_0);
                                    if (str5 == null)
                                    {
                                        str5 = "";
                                    }
                                    str5 = StringTools.repxml(str5);
                                    if (str4.Trim().Length == 0)
                                    {
                                        str4 = "fc";
                                    }
                                    builder.Append("<" + str4 + ">" + str5 + "</" + str4 + ">");
                                }
                                else
                                {
                                    builder.Append("<fcnull></fcnull>");
                                }
                            }
                            builder.Append("</record>");
                        }
                        num3++;
                    }
                }
                num3--;
                if (num3 > 0)
                {
                    builder.Append("<pages>" + num3 + "</pages>");
                }
                builder.Append("</root>");
                ds.Close();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(builder.ToString());
        }
Exemplo n.º 5
0
        public string dataset_select()
        {
            string strsql = this.xmlDocument_0.DocumentElement.ChildNodes.Item(0).InnerText;
            int    num    = int.Parse(this.xmlDocument_0.DocumentElement.ChildNodes.Item(1).InnerText);
            int    num2   = int.Parse(this.xmlDocument_0.DocumentElement.ChildNodes.Item(2).InnerText);
            string str4   = "";

            try
            {
                str4 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(3).InnerText;
            }
            catch (Exception exception3)
            {
                Console.WriteLine(exception3.Message);
            }
            string str15 = "";

            try
            {
                str15 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(4).InnerText;
            }
            catch (Exception exception2)
            {
                Console.WriteLine(exception2.Message);
            }
            string[] strArray2 = null;
            if (!str4.Equals(""))
            {
                strArray2 = str4.Split(new char[] { ',' });
            }
            StringBuilder builder2 = new StringBuilder();

            builder2.Append("<root>");
            string      str7  = "";
            string      name  = "";
            int         index = 1;
            int         num5  = 1;
            int         num4  = 1;
            bool        flag  = false;
            DBOperator  oDb   = null;
            IDataReader rs    = null;

            try
            {
                oDb = this.connectionConfig_0.getDBOperator();
                oDb.Open();
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                Logger.debug("dataset的SQL语句:" + strsql);
                IDataReader ds    = this.runProc(this.dboperator_0, strsql);
                RecordCheck check = new RecordCheck(this.connectionConfig_0.getDBOperator(), this.httpRequest_0, this.httpSessionState_0);
                check.init(ds);
                StringBuilder builder = new StringBuilder();
                index = 0;
                while (index < ds.FieldCount)
                {
                    name = ds.GetName(index);
                    string str12 = null;
                    string str13 = null;
                    string str14 = null;
                    if (str15 != "")
                    {
                        try
                        {
                            try
                            {
                                rs = this.runProc(oDb, str15.Replace("GET_FIELD_NAME_FLAG", name.ToUpper()));
                                if (!rs.Read())
                                {
                                    flag = true;
                                }
                                else
                                {
                                    str12 = SQLTool.getStr(rs, 0, this.string_0);
                                    if (str12 == null)
                                    {
                                        str12 = name;
                                    }
                                    str13 = SQLTool.getStr(rs, 1, this.string_0);
                                    str14 = SQLTool.getStr(rs, 2, this.string_0);
                                }
                            }
                            catch (Exception)
                            {
                                flag = true;
                            }
                            goto Label_0251;
                        }
                        finally
                        {
                            try
                            {
                                rs.Close();
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                    flag = true;
Label_0251:
                    if (flag)
                    {
                        str12 = name;
                        str13 = "15";
                        str14 = "0";
                    }
                    name = name.ToLower();
                    string str11 = name;
                    builder.Append("<field><fieldname>" + name + "</fieldname>");
                    name = cn.com.fcsoft.util.Tools.getDsType(Convert.ToString(ds.GetFieldType(index)));
                    builder.Append("<datatype>" + name + "</datatype><displaylabel>" + str12 + "</displaylabel><size>" + str13 + "</size><precision>" + str14 + "</precision><fieldkind>数据项</fieldkind><defaultvalue></defaultvalue><displayformat></displayformat><isnull>否</isnull><iskey>否</iskey><valid>否</valid><procvalid>否</procvalid><link>否</link><target>_blank</target><href></href><visible>" + this.method_0(strArray2, str11) + "</visible><primarykey>否</primarykey></field>");
                    index++;
                }
                while (ds.Read())
                {
                    if (check.isRecordCanShow(SQLTool.getStr(ds, (int)(ds.FieldCount - 1), this.string_0)))
                    {
                        if (((num4 > ((num - 1) * num2)) && (num4 <= (num * num2))) || (num2 == -1))
                        {
                            builder2.Append("<tr>");
                            num5 = ds.FieldCount;
                            for (index = 0; index < num5; index++)
                            {
                                if (ds.GetName(index) != null)
                                {
                                    string str8 = SQLTool.getStr(ds, index, this.string_0);
                                    if (str8 == null)
                                    {
                                        str8 = "";
                                    }
                                    builder2.Append("<td>" + StringTools.repxml(str8) + "</td>");
                                }
                                else
                                {
                                    builder2.Append("<fcnull></fcnull>");
                                }
                            }
                            builder2.Append("</tr>");
                        }
                        num4++;
                    }
                }
                num4--;
                if (num4 >= 0)
                {
                    builder2.Append("<set><pages>" + num4 + "</pages><fields>");
                    builder2.Append(builder);
                    builder2.Append("</fields></set>");
                }
                builder2.Append("</root>");
                ds.Close();
                this.dboperator_0.Close();
                oDb.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
                try
                {
                    oDb.Close();
                }
                catch (Exception)
                {
                }
            }
            string str5 = builder2.ToString();

            if (str5 == "<root>")
            {
                str5 = str7;
            }
            return(str5);
        }
Exemplo n.º 6
0
        public string dataset_fields1(string strsql, int iPageNo, int iPageSize, XmlNode oFields, bool isExport, XmlNode oFieldAll)
        {
            string[] strArray = new string[oFields.ChildNodes.Count];
            object[] objArray = new object[oFields.ChildNodes.Count];
            for (int i = 0; i < oFields.ChildNodes.Count; i++)
            {
                strArray[i] = oFields.ChildNodes.Item(i).ChildNodes.Item(0).InnerText;
                if (oFields.ChildNodes.Item(i).ChildNodes.Count > 1)
                {
                    string str6 = Escape.unescape(oFields.ChildNodes.Item(i).ChildNodes.Item(1).InnerText);
                    objArray[i] = this.sqlToHashtable(str6);
                }
            }
            StringBuilder builder = new StringBuilder(1000);

            if (!isExport)
            {
                builder.Append("<root>");
            }
            int num2 = 1;

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                Logger.debug("数据集的SQL语句:" + strsql);
                IDataReader ds    = this.runProc(this.dboperator_0, strsql);
                RecordCheck check = new RecordCheck(this.connectionConfig_0.getDBOperator(), this.httpRequest_0, this.httpSessionState_0);
                check.init(ds);
                string str    = "";
                string str2   = "";
                int    num3   = ds.FieldCount;
                int    length = strArray.Length;
                bool   flag   = false;
                for (int j = 0; j < length; j++)
                {
                    flag = false;
                    int num7 = 0;
                    while (num7 < num3)
                    {
                        if (strArray[j].ToLower() == ds.GetName(num7).ToLower())
                        {
                            goto Label_018E;
                        }
                        num7++;
                    }
                    goto Label_021E;
Label_018E:
                    flag = true;
                    string str4 = ds.GetDataTypeName(num7).ToLower();
                    if (((oFieldAll == null) || (oFieldAll.ChildNodes.Item(j).ChildNodes.Item(1).InnerText != "图象")) && (str4 != "image"))
                    {
                        if ((str4 == "clob") && isExport)
                        {
                            str2 = str2 + strArray[j] + ",";
                        }
                    }
                    else if (!isExport)
                    {
                        flag = false;
                    }
                    else
                    {
                        str = str + strArray[j] + ",";
                    }
Label_021E:
                    if (!flag)
                    {
                        strArray[j] = "";
                    }
                }
                while (ds.Read())
                {
                    if (check.isRecordCanShow(SQLTool.getStr(ds, (int)(ds.FieldCount - 1), this.string_0)))
                    {
                        if (((num2 > ((iPageNo - 1) * iPageSize)) && (num2 <= (iPageNo * iPageSize))) || (iPageSize == -1))
                        {
                            builder.Append("<tr>");
                            for (int k = 0; k < strArray.Length; k++)
                            {
                                string str3 = "";
                                if (strArray[k] == "")
                                {
                                    str3 = "";
                                }
                                else if ((isExport && (str.Length > 0)) && (str.IndexOf(strArray[k] + ",") >= 0))
                                {
                                    object obj2 = ds.GetValue(k);
                                    if ((obj2 != DBNull.Value) && (obj2 is Array))
                                    {
                                        byte[] bb = (byte[])obj2;
                                        str3 = Base64.byteArrayToBase64(bb);
                                    }
                                }
                                else
                                {
                                    str3 = SQLTool.getStr(ds, strArray[k], this.string_0);
                                    if (objArray[k] != null)
                                    {
                                        Hashtable hashtable = (Hashtable)objArray[k];
                                        if (((str3 != null) && (str3.Length > 0)) && hashtable.ContainsKey(str3.Trim()))
                                        {
                                            str3 = (string)hashtable[(str3.Trim())];
                                        }
                                    }
                                }
                                if (str3 == null)
                                {
                                    str3 = "";
                                }
                                builder.Append("<td>" + StringTools.repxml(str3) + "</td>");
                            }
                            builder.Append("</tr>");
                        }
                        num2++;
                    }
                }
                num2--;
                if ((num2 >= 0) && !isExport)
                {
                    builder.Append("<set><pages>" + num2 + "</pages><fields></fields></set>");
                }
                if (!isExport)
                {
                    builder.Append("</root>");
                }
                ds.Close();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(builder.ToString());
        }