Exemplo n.º 1
0
        /// <summary>
        /// The passed data source should not have an already existing transaction because
        /// we create our own transaction.
        /// </summary>
        /// <param name="pickslipId"></param>
        /// <param name="ds"></param>
        public static void DeleteBoxesForPickslipGroup(int pickslipId, OracleDataSource ds)
        {
            const string QUERY_BOX    = @"
delete from <proxy />box b where b.ia_id is null and b.pickslip_id = :pickslip_id
                ";
            const string QUERY_BOXDET = @"
delete from <proxy />boxdet bd 
where bd.ucc128_id in(
    select b.ucc128_id from <proxy />box b where b.ia_id is null and b.pickslip_id = :pickslip_id
)
                ";

            ds.DeleteParameters.Clear();
            ds.DeleteParameters.Add("pickslip_id", DbType.Int32, pickslipId.ToString());
            ds.SysContext.ModuleName = "BoxCreator.DeleteBoxes";
            try
            {
                ds.BeginTransaction();
                ds.DeleteSql = QUERY_BOXDET;

                int i = ds.Delete();

                ds.DeleteSql = QUERY_BOX;
                i            = ds.Delete();
                ds.CommitTransaction();
            }
            catch (Exception)
            {
                ds.RollBackTransaction();
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 单DML语句操作
        /// </summary>
        /// <param name="id">SQL语句ID编号</param>
        /// <param name="obj">输入输出对象</param>
        /// <returns></returns>
        public string execDml(string id, Object obj)
        {
            resultSql = "";
            if (id == "")
            {
                throw new Exception("参数不全");
            }
            if (obj == null)
            {
                throw new Exception("参数不全");
            }
            daoStruct = parseDao.ObtainConfig(id);
            if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
            {
                throw new Exception("配置参数不全");
            }
            string sql = "";

            sql       = setSql(obj, daoStruct.SqlStr);
            resultSql = sql;
            //记录SQL
            if (daoStruct.IsLog)
            {
                WriteLogin.writeDBLog(daoStruct.Desc, resultSql);
            }
            if (sql.Length <= 0)
            {
                throw new Exception("构造SQL语句出错");
            }
            IDataSource dataSource = null;

            switch (daoStruct.DbType)
            {
            case "oracle":
                dataSource = new OracleDataSource(daoStruct);
                break;

            case "mysql":
                dataSource = new MySqlDataSource(daoStruct);
                break;

            case "sql":
                dataSource = new SqlDataSource(daoStruct);
                break;

            case "access":
                dataSource = new AccessDataSource(daoStruct);
                break;

            case "sqllite":
                dataSource = new SqlLiteDataSource(daoStruct);
                break;
            }
            if (dataSource != null)
            {
                dataSource.SingleExecute(sql);
            }

            return("");
        }
Exemplo n.º 3
0
        public static DropDownItem[] GetReasonCodes(string connectString, string providerName, string reasonType)
        {
            const string strQuery = @"
                SELECT reason.reason_code AS reason_code,
                       reason.description AS description
               FROM tab_reason reason WHERE 1 = 1 <if c=""$reasonType = 'Pickslip'""> AND reason.pickslip_cancel_flag = 'Y'</if>";

            using (OracleDataSource ds = new OracleDataSource())
            {
                ds.ConnectionString      = connectString;
                ds.SelectSql             = strQuery;
                ds.ProviderName          = providerName;
                ds.SysContext.ModuleName = "Retrieving reason codes";
                ds.SelectParameters.Add("reasonType", reasonType);
                ds.SelectSql = strQuery;
                //ds.CancelSelectOnValidationFailure = false;
                return((from object row in ds.Select(DataSourceSelectArguments.Empty)
                        select new DropDownItem()
                {
                    Text = string.Format("{0}: {1}", DataBinder.Eval(row, "reason_code"),
                                         DataBinder.Eval(row, "description")),
                    Value = DataBinder.Eval(row, "reason_code", "{0}"),
                }).ToArray());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This function will insert the created boxes of this pickslip group in database by using the box object.
        /// It is managing the transaction so that all boxes of a pickslip will be created or none.
        /// </summary>
        /// <param name="ds"></param>
        internal void InsertBoxesInDb(OracleDataSource ds)
        {
            int seq = this.SequenceInPs;
            //selecting the distinct pickslips to set the picking status
            var q1 = (from ps in this._skuList
                      select ps.PickslipId).Distinct();

            ds.BeginTransaction();
            try
            {
                foreach (Box box in this.Boxes)
                {
                    ++seq;
                    box.InsertInDb(ds, this.VwhId, seq, this.PickslipPrefix);
                }
                //Setting the picking status for the pickslips for which we have created the box
                foreach (var ps in q1)
                {
                    this.SetPickslipStatus(ds, Convert.ToInt32(ps));
                }

                ds.CommitTransaction();
            }
            catch (Exception)
            {
                ds.RollBackTransaction();
                throw;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Prepare DML
        /// </summary>
        /// <param name="ids">SQL语句ID编号</param>
        /// <param name="objs">输入对象</param>
        /// <returns></returns>
        public string execPrepare(string id, Object obj)
        {
            try
            {
                resultSql = "";
                if (id == null)
                {
                    throw new Exception("参数不全");
                }
                if (obj == null)
                {
                    throw new Exception("参数不全");
                }
                daoStruct = parseDao.ObtainConfig(id);
                if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
                {
                    throw new Exception("配置参数不全");
                }
                string sql = daoStruct.SqlStr;
                resultSql = sql;
                if (daoStruct.IsLog)
                {
                    WriteLogin.writeDBLog(daoStruct.Desc, sql);
                }
                List <DTOClass> dtolist = setDto(obj);
                if (sql.Length <= 0)
                {
                    throw new Exception("构造SQL语句出错");
                }
                IDataSource dataSource = null;
                switch (daoStruct.DbType)
                {
                case "oracle":
                    dataSource = new OracleDataSource(daoStruct);
                    break;

                case "mysql":
                    dataSource = new MySqlDataSource(daoStruct);
                    break;

                case "sql":
                    dataSource = new SqlDataSource(daoStruct);
                    break;

                case "access":
                    dataSource = new AccessDataSource(daoStruct);
                    break;

                case "sqllite":
                    dataSource = new SqlLiteDataSource(daoStruct);
                    break;
                }
                dataSource.PrepareExcute(sql, dtolist);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            return("");
        }
Exemplo n.º 6
0
        /// <summary>
        /// If you are calling from a webmethod then pass storesWhat = CTN for getting carton area, SKU for getting SKU areas.
        /// If you want to select all areas pass empty string.
        /// Pass usableInventory as "true" if you want to select only usable inventory areas otherwise pass empty.
        /// </summary>
        /// <param name="connectString"></param>
        /// <param name="providerName"></param>
        /// <param name="storesWhat"></param>
        /// <param name="usableInventory"></param>
        /// <returns></returns>
        public static DropDownItem[] GetAreas(string connectString, string providerName, string storesWhat, string usableInventory)
        {
            string strQuery = @"
select inventory_storage_area,
    short_name || ':' || description as description,
    stores_what
from tab_inventory_area
where 1 = 1
<if>AND stores_what = :stores_what</if>
<if c='$unusable_inventory'>AND unusable_inventory IS NULL</if>
order by short_name,warehouse_location_id
";

            using (OracleDataSource ds = new OracleDataSource())
            {
                ds.ConnectionString      = connectString;
                ds.SelectSql             = strQuery;
                ds.ProviderName          = providerName;
                ds.SysContext.ModuleName = "Selecting Areas";
                //ds.CancelSelectOnValidationFailure = false;
                ds.SelectParameters.Add("stores_what", DbType.String, storesWhat);
                ds.SelectParameters.Add("unusable_inventory", DbType.String, usableInventory);

                var query = from object row in ds.Select(DataSourceSelectArguments.Empty)
                            select new DropDownItem()
                {
                    Text        = string.Format("{0}", DataBinder.Eval(row, "description")),
                    Value       = DataBinder.Eval(row, "inventory_storage_area", "{0}"),
                    OptionGroup = DataBinder.Eval(row, "stores_what", "{0}")
                };

                return(query.ToArray());
            }
        }
Exemplo n.º 7
0
        private void btnAbstractExample_Click(object sender, RoutedEventArgs e)
        {
            MsSqlDataSource  msDataSource     = new MsSqlDataSource("ms sql environment");
            OracleDataSource oracleDataSource = new OracleDataSource("oracle sql environment");

            msDataSource.OpenAndReturnConnection();
            oracleDataSource.OpenAndReturnConnection();
        }
Exemplo n.º 8
0
 /// <summary>
 /// This will set the picking_status of the pickslip group to PENDING
 /// </summary>
 /// <param name="ds"></param>
 /// <param name="pickslipId">Set the status for passed pickslip id</param>
 private void SetPickslipStatus(OracleDataSource ds, int pickslipId)
 {
     ds.UpdateSql = @"update <proxy />ps set picking_status = 'PENDING' where pickslip_id = :pickslip_id";
     ds.UpdateParameters.Clear();
     ds.UpdateParameters.Add("pickslip_id", DbType.Int32, pickslipId.ToString());
     try
     {
         ds.Update();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// 获得数据,只有数据列少时用他
        /// </summary>
        /// <param name="id"></param>
        /// <param name="objs"></param>
        /// <returns></returns>
        public IDataReader getDataRead(string id, Object objs)
        {
            resultSql = "";
            daoStruct = parseDao.ObtainConfig(id);
            if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
            {
                throw new Exception("配置参数不全");
            }
            string sql = setSql(objs, daoStruct.SqlStr);

            resultSql = sql;
            if (sql.Length <= 0)
            {
                throw new Exception("构造SQL语句出错");
            }
            IDataSource   dataSource = null;
            List <Object> objlist    = new List <Object>();

            switch (daoStruct.DbType)
            {
            case "oracle":
                dataSource = new OracleDataSource(daoStruct);
                break;

            case "mysql":
                dataSource = new MySqlDataSource(daoStruct);
                break;

            case "sql":
                dataSource = new SqlDataSource(daoStruct);
                break;

            case "access":
                dataSource = new AccessDataSource(daoStruct);
                break;

            case "sqllite":
                dataSource = new SqlLiteDataSource(daoStruct);
                break;
            }
            if (dataSource != null)
            {
                return(dataSource.GetDataRead(sql));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 10
0
        public static DropDownItem[] GetLabels(string connectString, string providerName, bool labelGroup)
        {
            string QUERY;

            if (labelGroup)
            {
                QUERY = @"
select tsl.label_id as label_id,
       MAX(twl.warehouse_location_id) as max_warehouse_location_id,
       MAX(twl.description) as building_description,
       COUNT(DISTINCT twl.warehouse_location_id) as count_warehouse_location_id,
       MAX(tsl.description) as label_description
  from <proxy />tab_style_label tsl
  left outer join <proxy />tab_label_group tlg on tsl.label_id = tlg.label_id
  left outer join <proxy />tab_warehouse_location twl on tlg.label_group =
                                                twl.label_group
 group by tsl.label_id
 order by tsl.label_id
";
            }

            else
            {
                QUERY = @"select tsl.label_id as label_id,      
      tsl.description as label_description
  from <proxy />tab_style_label tsl
 order by tsl.label_id";
            }


            using (OracleDataSource ds = new OracleDataSource())
            {
                ds.ConnectionString      = connectString;
                ds.SelectSql             = QUERY;
                ds.ProviderName          = providerName;
                ds.SysContext.ModuleName = "Reteriving labels";
                //ds.CancelSelectOnValidationFailure = false;
                var query = from object row in ds.Select(DataSourceSelectArguments.Empty)
                            select new DropDownItem()
                {
                    Text = string.Format("{0}: {1}", DataBinder.Eval(row, "label_id"),
                                         DataBinder.Eval(row, "label_description")),
                    Value = DataBinder.Eval(row, "label_id", "{0}")
                };

                return(query.ToArray());
            }
        }
Exemplo n.º 11
0
        public static DropDownItem[] GetBuildings(string connectString, string providerName)
        {
            const string strQuery = "select warehouse_location_id, description AS description from <proxy/>tab_warehouse_location order by 1";

            using (OracleDataSource ds = new OracleDataSource())
            {
                ds.ProviderName          = providerName;
                ds.SysContext.ModuleName = "Retrieving Buildings";
                ds.ConnectionString      = connectString;
                ds.SelectSql             = strQuery;
                //ds.CancelSelectOnValidationFailure = false;

                return((from object row in ds.Select(DataSourceSelectArguments.Empty)
                        select new DropDownItem()
                {
                    Text = string.Format("{0}: {1}", DataBinder.Eval(row, "warehouse_location_id"),
                                         DataBinder.Eval(row, "description")),
                    Value = DataBinder.Eval(row, "warehouse_location_id", "{0}"),
                }).ToArray());
            }
        }
Exemplo n.º 12
0
        public static DropDownItem[] GetCustomerType(string connectString, string providerName)
        {
            const string QUERY = @"
        select tct.customer_type, tct.description from tab_customer_type tct order by tct.description
";

            using (OracleDataSource ds = new OracleDataSource())
            {
                ds.ConnectionString      = connectString;
                ds.SelectSql             = QUERY;
                ds.ProviderName          = providerName;
                ds.SysContext.ModuleName = "Customer Type";
                //ds.CancelSelectOnValidationFailure = false;
                return((from object row in ds.Select(DataSourceSelectArguments.Empty)
                        select new DropDownItem()
                {
                    Text = string.Format("{0}: {1}", DataBinder.Eval(row, "customer_type"),
                                         DataBinder.Eval(row, "description")),
                    Value = DataBinder.Eval(row, "customer_type", "{0}")
                }).ToArray());
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Sharad 23 Aug 2011: Retrieving dates for +/- 2 years
        /// </summary>
        static BusinessDateTextBox()
        {
            __monthStartDates = new List <DateTime>(24);
            const string QUERY = @"
SELECT t.month_start_date as month_start_date
FROM tab_fdc_calendar t
where t.fiscal_year &lt;= (:curYear + 2) and t.fiscal_year &gt;= (:curYear - 2)
ORDER BY t.month_start_date DESC
";

            using (OracleDataSource ds = new OracleDataSource(ConfigurationManager.ConnectionStrings["dcmslive"]))
            {
                ds.SelectSql = QUERY;
                ds.SelectParameters.Add("curYear", TypeCode.Int32, DateTime.Today.Year.ToString());
                ds.SysContext.ModuleName = "Month Start Date";

                foreach (var row in ds.Select(DataSourceSelectArguments.Empty))
                {
                    __monthStartDates.Add(Convert.ToDateTime(DataBinder.Eval(row, "month_start_date")));
                }
            }
        }
Exemplo n.º 14
0
        public void disposeConn(string id)
        {
            try
            {
                daoStruct = parseDao.ObtainConfig(id);
                IDataSource dataSource;
                switch (daoStruct.DbType)
                {
                case "oracle":
                    dataSource = new OracleDataSource(daoStruct);
                    dataSource.DisposeConn();
                    break;

                case "mysql":
                    dataSource = new MySqlDataSource(daoStruct);
                    dataSource.DisposeConn();
                    break;

                case "sql":
                    dataSource = new SqlDataSource(daoStruct);
                    dataSource.DisposeConn();
                    break;

                case "access":
                    dataSource = new AccessDataSource(daoStruct);
                    dataSource.DisposeConn();
                    break;

                case "sqllite":
                    dataSource = new SqlLiteDataSource(daoStruct);
                    dataSource.DisposeConn();
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 查询数据根据SQL语句
        /// </summary>
        /// <param name="id">SQL编号</param>
        /// <param name="sql">SQL语句</param>
        /// <returns>数据结果</returns>
        public DataSet getDataSet(string id, string sql)
        {
            resultSql = sql;
            DataSet     rtnDataSet = new DataSet();
            IDataSource dataSource = null;

            daoStruct = parseDao.ObtainConfig(id);
            switch (daoStruct.DbType)
            {
            case "oracle":
                dataSource = new OracleDataSource(daoStruct);
                break;

            case "mysql":
                dataSource = new MySqlDataSource(daoStruct);
                break;

            case "sql":
                dataSource = new SqlDataSource(daoStruct);
                break;

            case "access":
                dataSource = new AccessDataSource(daoStruct);
                break;

            case "sqllite":
                dataSource = new SqlLiteDataSource(daoStruct);
                break;
            }
            if (dataSource != null)
            {
                return(dataSource.SelectExecute(sql));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 备份数据库
        /// </summary>
        /// <param name="path"></param>
        /// <param name="database"></param>
        public void BackupData(string id, string path, string database)
        {
            daoStruct = parseDao.ObtainConfig(id);
            string      backupsql  = "";
            IDataSource dataSource = null;

            switch (daoStruct.DbType)
            {
            case "oracle":
                dataSource = new OracleDataSource(daoStruct);
                break;

            case "sql":
                backupsql  = "BACKUP DATABASE [" + database + "] TO DISK =N'" + path + "' WITH NOFORMAT, INIT, NAME=N'" + database + "-完整 数据库 备份', SKIP, NOREWIND, NOUNLOAD,  STATS = 10";
                dataSource = new SqlDataSource(daoStruct);
                break;

            case "mysql":
                dataSource = new MySqlDataSource(daoStruct);
                break;
            }
            dataSource.Backup(backupsql);
        }
Exemplo n.º 17
0
        /// <summary>
        /// This is static to make it possible to call from a web service
        /// </summary>
        /// <param name="connectString"></param>
        /// <param name="providerName"></param>
        /// <param name="printerType"></param>
        /// <returns></returns>
        public static DropDownItem[] GetPrinters(string connectString, string providerName, string printerType)
        {
            const string strQuery = @"
select
    tabprinter.name AS name,
    tabprinter.description AS description,
<if c='$printer_type'>
printer_type As printer_type
</if>
<else>
NULL as printer_type
</else>
from <proxy />tab_printer tabprinter 
where 1 = 1
<if c='$printer_type'>
AND upper(printer_type) = upper(:printer_type)
</if>
order by lower(name)";

            using (OracleDataSource ds = new OracleDataSource())
            {
                ds.ProviderName          = providerName;
                ds.ConnectionString      = connectString;
                ds.SelectSql             = strQuery;
                ds.SysContext.ModuleName = "Retrieving printers";
                //ds.CancelSelectOnValidationFailure = false;
                ds.SelectParameters.Add("printer_type", DbType.String, printerType);
                return((from object row in ds.Select(DataSourceSelectArguments.Empty)
                        select new DropDownItem()
                {
                    Text = string.Format("{0}: {1}", DataBinder.Eval(row, "name"),
                                         DataBinder.Eval(row, "description")),
                    Value = DataBinder.Eval(row, "name", "{0}"),
                    OptionGroup = DataBinder.Eval(row, "printer_type", "{0}")
                }).ToArray());
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Insert entries in box (one per pickslip) and boxdet
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="vwhId"></param>
        /// <param name="seq"></param>
        /// <param name="pickslipPrefix"></param>
        public void InsertInDb(OracleDataSource ds, string vwhId, int seq, string pickslipPrefix)
        {
            //TODO: MIN_PIECES_PER_BOX_5

            const string QUERY_BOX    = @"
INSERT INTO <proxy />box
  (pickslip_id,
   ucc128_id,
   case_id,
   sequence_in_ps,
   min_pieces_per_box,
   vwh_id)
VALUES
  (:PICKSLIP_ID,
   NVL(:ucc128_id, <proxy />GET_UCC128_ID),
   :CASE_ID,
   :sequence_in_ps,
   NULL,
   :vwh_id)
RETURNING ucc128_id INTO :ucc128_id
";
            const string QUERY_BOXDET = @"
INSERT INTO <proxy />BOXDET boxdet
  (boxdet.ucc128_id,
   boxdet.pickslip_id,
   boxdet.upc_code,
   boxdet.barcode,
   boxdet.expected_pieces)
VALUES
  (:ucc128_id, :PICKSLIP_ID, :upc_code, :barcode, :expected_pieces)

";

            ds.InsertParameters.Clear();
            ds.InsertParameters.Add("CASE_ID", DbType.String, this.Case.CaseId);
            ds.InsertParameters.Add("sequence_in_ps", DbType.Int32, seq.ToString());
            ds.InsertParameters.Add("vwh_id", DbType.String, vwhId);
            ds.InsertParameters.Add("pickslip_prefix", DbType.String, pickslipPrefix);
            ds.InsertParameters.Add("ucc128_id", DbType.String, string.Empty);

            // Value updated in loop
            ds.InsertParameters.Add("PICKSLIP_ID", DbType.Int32, string.Empty);

            // Additional BoxDet parameters
            ds.InsertParameters.Add("upc_code", DbType.String, string.Empty);
            ds.InsertParameters.Add("barcode", DbType.String, string.Empty);
            ds.InsertParameters.Add("expected_pieces", DbType.Int32, string.Empty);

            var pickslipGroup = from sku in this.AllSku
                                group sku by sku.PickslipId into g
                                select g;

            foreach (var pickslip in pickslipGroup)
            {
                ds.InsertSql = QUERY_BOX;
                ds.InsertParameters["PICKSLIP_ID"].DefaultValue = pickslip.Key.ToString();
                ds.InsertParameters["ucc128_id"].Direction      = ParameterDirection.InputOutput;
                ds.InsertParameters["ucc128_id"].Size           = 255;
                int i = ds.Insert();
                if (i != 1)
                {
                    throw new InvalidOperationException("Row not inserted");
                }
                ds.InsertParameters["ucc128_id"].DefaultValue = ds.OutValues["ucc128_id"].ToString();
                ds.InsertSql = QUERY_BOXDET;
                ds.InsertParameters["ucc128_id"].Direction = ParameterDirection.Input;
                foreach (var sku in pickslip)
                {
                    ds.InsertParameters["upc_code"].DefaultValue        = sku.UpcCode;
                    ds.InsertParameters["barcode"].DefaultValue         = sku.PickslipBarCode;
                    ds.InsertParameters["expected_pieces"].DefaultValue = sku.OrderedPieces.ToString();
                    i = ds.Insert();
                    if (i != 1)
                    {
                        throw new InvalidOperationException("Row not inserted");
                    }
                }
            }
            return;
        }
Exemplo n.º 19
0
 /// <summary>
 /// Constructor of this class BoxConstraint and setting the customer_id and datatsource to its private members.
 /// </summary>
 /// <param name="ds">This datasource will be used for whoel box creation process</param>
 /// <param name="customerId">We will know for which customer these constraints are.</param>
 public CustomerConstraints(OracleDataSource ds, string customerId)
 {
     _ds         = ds;
     _customerId = customerId;
 }
Exemplo n.º 20
0
    private IEnumerable <ReportStat> GetReportStats()
    {
        ReportStat[] statistics;
        try
        {
            statistics = (ReportStat[])Cache["ReportStatData"];
        }
        catch (InvalidCastException)
        {
            // This happens when default.aspx page is recompiled. Just Ignore the cache
            statistics = null;
        }

        if (statistics != null)
        {
            return(statistics);
        }

        using (OracleDataSource dsHits = new OracleDataSource())
        {
            dsHits.SelectSql             = @"
select t.report_id as report_id,
       MIN(t.query_seconds) as min_query_seconds,
       MAX(t.query_seconds) as max_query_seconds,
       ROUND(AVG(t.query_seconds), 4) as avg_query_seconds,
       MAX(t.hit_index) as hit_count
  from xreporter_report_hits t
  where t.application_name = :application_name
 group by t.report_id
";
            dsHits.SysContext.ModuleName = "DCMS Live 2009 Home";
            dsHits.ConnectionString      = ConfigurationManager.ConnectionStrings["DCMSLIVE"].ConnectionString;
            dsHits.ProviderName          = ConfigurationManager.ConnectionStrings["DCMSLIVE"].ProviderName;
            Parameter appName = new Parameter("application_name", DbType.String);
            appName.DefaultValue = ProfileManager.Provider.ApplicationName;
            dsHits.SelectParameters.Add(appName);
            try
            {
                statistics =
                    (from object stat in dsHits.Select(DataSourceSelectArguments.Empty)
                     select new ReportStat(DataBinder.Eval(stat, "report_id", "{0}"))
                {
                    MinQuerySeconds = DataBinder.Eval(stat, "min_query_seconds"),
                    MaxQuerySeconds = DataBinder.Eval(stat, "max_query_seconds"),
                    AverageQuerySeconds = DataBinder.Eval(stat, "avg_query_seconds"),
                    HitCount = DataBinder.Eval(stat, "hit_count")
                }).ToArray();
                Cache.Insert("ReportStatData", statistics, null, DateTime.UtcNow.AddHours(1),
                             System.Web.Caching.Cache.NoSlidingExpiration);
                __statUpdateTime = DateTime.Now;
            }
            catch (DbException ex)
            {
                Trace.Warn(ex.ToString());
                // Empty array
                statistics = new ReportStat[0];
                mvStats.ActiveViewIndex = 1;
                lblError.Text           = ex.Message;
            }
        }
        return(statistics);
    }
Exemplo n.º 21
0
        /// <summary>
        /// 多DML语句操作
        /// </summary>
        /// <param name="ids">SQL语句ID编号列表</param>
        /// <param name="objs">输入输出对象列表</param>
        /// <returns></returns>
        public string execTranctionDml(List <string> ids, List <Object> objs)
        {
            resultSql = "";
            List <string> idlist = new List <string>();

            idlist = ids;
            List <Object> objectlist = new List <Object>();

            objectlist = objs;
            if (idlist.Count <= 0)
            {
                throw new Exception("缺少参数");
            }
            if (idlist.Count != objectlist.Count)
            {
                throw new Exception("参数数量不一致");
            }
            List <string> sqls = new List <string>();

            for (int i = 0; i < idlist.Count; i++)
            {
                daoStruct = parseDao.ObtainConfig(idlist[i]);
                if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
                {
                    throw new Exception("配置参数不全");
                }
                string sql = "";
                sql = setSql(objectlist[i], daoStruct.SqlStr);
                if (sql.Length <= 0)
                {
                    throw new Exception("构造SQL语句出错");
                }
                sqls.Add(sql);
                if (resultSql != "")
                {
                    resultSql += "\r\n";
                }
                resultSql += sql;
            }
            if (daoStruct.IsLog)
            {
                WriteLogin.writeDBLog(daoStruct.Desc, resultSql);
            }
            IDataSource dataSource = null;

            switch (daoStruct.DbType)
            {
            case "oracle":
                dataSource = new OracleDataSource(daoStruct);
                break;

            case "mysql":
                dataSource = new MySqlDataSource(daoStruct);
                break;

            case "sql":
                dataSource = new SqlDataSource(daoStruct);
                break;

            case "access":
                dataSource = new AccessDataSource(daoStruct);
                break;

            case "sqllite":
                dataSource = new SqlLiteDataSource(daoStruct);
                break;
            }
            dataSource.TranctionExcute(sqls);
            //记录SQL

            return("");
        }
Exemplo n.º 22
0
        /// <summary>
        /// Prepare DML
        /// </summary>
        /// <param name="ids">SQL语句ID编号</param>
        /// <param name="objs">输入对象</param>
        /// <returns></returns>
        public string execPrepare(List <string> ids, List <Object> objs)
        {
            try
            {
                resultSql = "";
                List <string> idlist = new List <string>();
                idlist = ids;
                List <Object> objectlist = new List <Object>();
                objectlist = objs;
                if (idlist.Count <= 0)
                {
                    throw new Exception("缺少参数");
                }
                if (idlist.Count != objectlist.Count)
                {
                    throw new Exception("参数数量不一致");
                }
                List <string>           sqls     = new List <string>();
                List <List <DTOClass> > dtolists = new List <List <DTOClass> >();
                for (int i = 0; i < idlist.Count; i++)
                {
                    daoStruct = parseDao.ObtainConfig(idlist[i]);
                    if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
                    {
                        throw new Exception("配置参数不全");
                    }
                    string          sql     = daoStruct.SqlStr;
                    List <DTOClass> dtolist = setDto(objectlist[i]);
                    if (sql.Length <= 0)
                    {
                        throw new Exception("构造SQL语句出错");
                    }
                    sqls.Add(sql);
                    dtolists.Add(dtolist);
                    if (resultSql != "")
                    {
                        resultSql += "\r\n";
                    }
                    resultSql += sql;
                }
                if (daoStruct.IsLog)
                {
                    WriteLogin.writeDBLog(daoStruct.Desc, resultSql);
                }
                IDataSource dataSource = null;
                switch (daoStruct.DbType)
                {
                case "oracle":
                    dataSource = new OracleDataSource(daoStruct);
                    break;

                case "mysql":
                    dataSource = new MySqlDataSource(daoStruct);
                    break;

                case "sql":
                    dataSource = new SqlDataSource(daoStruct);
                    break;

                case "access":
                    dataSource = new AccessDataSource(daoStruct);
                    break;

                case "sqllite":
                    dataSource = new SqlLiteDataSource(daoStruct);
                    break;
                }
                dataSource.PrepareExcute(sqls, dtolists);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            return("");
        }