Ejemplo n.º 1
0
        public int ExecRowDataInterface(string iYmd, int itxr_user)
        {
            Biz_Bsc_Interface_Datasource objDS = new Biz_Bsc_Interface_Datasource();

            DataSet rDs      = null;
            DataSet dsDicode = base.GetAllList("", "", "PULL", itxr_user);
            string  sRtnMsg  = "";
            bool    bisSucc  = false;
            int     iAffRow  = 0;
            int     iGetRow  = 0;


            if (dsDicode.Tables.Count > 0)
            {
                int iRow = dsDicode.Tables[0].Rows.Count;
                for (int i = 0; i < iRow; i++)
                {
                    base.ISource_Id = int.Parse(dsDicode.Tables[0].Rows[i]["SOURCE_ID"].ToString());
                    Object objCon = objDS.GetConnection(base.ISource_Id, out bisSucc, out sRtnMsg);
                    base.IDicode = dsDicode.Tables[0].Rows[i]["DICODE"].ToString();

                    string sQry = dsDicode.Tables[0].Rows[i]["QUERY"].ToString();
                    sQry = sQry.Replace(QueryOperator.ParamCurrYmd, "'" + iYmd + "'");
                    sQry = sQry.Replace(QueryOperator.ParamPrevYmd, "'" + iYmd + "'");

                    rDs = new DataSet();
                    if (bisSucc)
                    {
                        if (objCon.GetType() == typeof(SqlConnection))
                        {
                            SqlConnection  conn = (SqlConnection)objCon;
                            SqlCommand     cmmd = new SqlCommand(sQry, conn);
                            SqlDataAdapter dadt = new SqlDataAdapter(cmmd);
                            iAffRow = dadt.Fill(rDs);

                            if (conn.State == ConnectionState.Open)
                            {
                                conn.Close();
                                conn.Dispose();
                            }
                        }
                        else if (objCon.GetType() == typeof(OracleConnection))
                        {
                            OracleConnection  conn = (OracleConnection)objCon;
                            OracleCommand     cmmd = new OracleCommand(sQry, conn);
                            OracleDataAdapter dadt = new OracleDataAdapter(cmmd);
                            iAffRow = dadt.Fill(rDs);

                            if (conn.State == ConnectionState.Open)
                            {
                                conn.Close();
                                conn.Dispose();
                            }
                        }
                        else if (objCon.GetType() == typeof(OleDbConnection))
                        {
                            OleDbConnection  conn = (OleDbConnection)objCon;
                            OleDbCommand     cmmd = new OleDbCommand(sQry, conn);
                            OleDbDataAdapter dadt = new OleDbDataAdapter(cmmd);
                            iAffRow = dadt.Fill(rDs);

                            if (conn.State == ConnectionState.Open)
                            {
                                conn.Close();
                                conn.Dispose();
                            }
                        }
                    }
                    else
                    {
                        return(0);
                    }



                    sQry = this.GetRowDataQuery(base.IDicode, iYmd, rDs, itxr_user);
                    //iGetRow += base.DbAgentObj.ExecuteNonQuery(sQry);
                    string[] arrQuery = sQry.Split(';');

                    IDbConnection dbcon = DbAgentHelper.CreateDbConnection();
                    dbcon.Open();
                    IDbTransaction trx = dbcon.BeginTransaction();
                    try
                    {
                        for (int k = 0; k < arrQuery.Length; k++)
                        {
                            if (arrQuery[k].Length > 0)
                            {
                                iGetRow += DbAgentObj.ExecuteNonQuery(arrQuery[k]);
                            }
                        }

                        trx.Commit();
                    }
                    catch (Exception ex)
                    {
                        trx.Rollback();
                        iGetRow = 0;
                    }
                    finally
                    {
                        dbcon.Close();
                    }
                }
            }

            return(iGetRow);
        }
Ejemplo n.º 2
0
        public DataTable GetOrginalInterfaceData(object dicode, object diname, int itxr_user, string iYmd)
        {
            Biz_Bsc_Interface_Datasource objDS = new Biz_Bsc_Interface_Datasource();

            DataSet rDs      = new DataSet();
            DataSet dsDicode = base.GetAllList(dicode.ToString(), "", "PULL", itxr_user);
            string  sRtnMsg  = "";
            bool    bisSucc  = false;
            int     iAffRow  = 0;


            if (dsDicode.Tables.Count > 0)
            {
                Object objCon = objDS.GetConnection(int.Parse(dsDicode.Tables[0].Rows[0]["SOURCE_ID"].ToString()), out bisSucc, out sRtnMsg);

                string sQry = dsDicode.Tables[0].Rows[0]["QUERY"].ToString();
                sQry = sQry.Replace(QueryOperator.ParamCurrYmd, "'" + iYmd + "'");
                sQry = sQry.Replace(QueryOperator.ParamPrevYmd, "'" + iYmd + "'");

                if (bisSucc)
                {
                    if (objCon.GetType() == typeof(SqlConnection))
                    {
                        SqlConnection  conn = (SqlConnection)objCon;
                        SqlCommand     cmmd = new SqlCommand(sQry, conn);
                        SqlDataAdapter dadt = new SqlDataAdapter(cmmd);
                        iAffRow = dadt.Fill(rDs);

                        if (conn.State == ConnectionState.Open)
                        {
                            conn.Close();
                            conn.Dispose();
                        }
                    }
                    else if (objCon.GetType() == typeof(OracleConnection))
                    {
                        OracleConnection  conn = (OracleConnection)objCon;
                        OracleCommand     cmmd = new OracleCommand(sQry, conn);
                        OracleDataAdapter dadt = new OracleDataAdapter(cmmd);
                        iAffRow = dadt.Fill(rDs);

                        if (conn.State == ConnectionState.Open)
                        {
                            conn.Close();
                            conn.Dispose();
                        }
                    }
                    else if (objCon.GetType() == typeof(OleDbConnection))
                    {
                        OleDbConnection  conn = (OleDbConnection)objCon;
                        OleDbCommand     cmmd = new OleDbCommand(sQry, conn);
                        OleDbDataAdapter dadt = new OleDbDataAdapter(cmmd);
                        iAffRow = dadt.Fill(rDs);

                        if (conn.State == ConnectionState.Open)
                        {
                            conn.Close();
                            conn.Dispose();
                        }
                    }
                }
            }
            return(rDs.Tables[0]);
        }
Ejemplo n.º 3
0
        public DataTable GetDataResult(string idicode, string sPreYMD, string sCurYMD, int itxr_user)
        {
            Biz_Bsc_Interface_Dicode objBSC = new Biz_Bsc_Interface_Dicode(idicode, itxr_user);
            string sQry       = objBSC.IQuery;
            int    isource_id = objBSC.ISource_Id;
            bool   bisSucc    = false;
            string sRtnMsg    = "";
            int    iAffRow    = 0;

            sQry = sQry.Replace(QueryOperator.ParamCurrYmd, "'" + sCurYMD + "'");
            sQry = sQry.Replace(QueryOperator.ParamPrevYmd, "'" + sPreYMD + "'");

            DataSet rDs = new DataSet();
            Biz_Bsc_Interface_Datasource objDS = new Biz_Bsc_Interface_Datasource();
            Object objCon = objDS.GetConnection(isource_id, out bisSucc, out sRtnMsg);

            if (bisSucc && sQry.Trim().Length > 0)
            {
                if (objCon.GetType() == typeof(SqlConnection))
                {
                    SqlConnection  conn = (SqlConnection)objCon;
                    SqlCommand     cmmd = new SqlCommand(sQry, conn);
                    SqlDataAdapter dadt = new SqlDataAdapter(cmmd);
                    iAffRow = dadt.Fill(rDs);

                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn.Dispose();
                    }
                }
                else if (objCon.GetType() == typeof(OracleConnection))
                {
                    OracleConnection  conn = (OracleConnection)objCon;
                    OracleCommand     cmmd = new OracleCommand(sQry, conn);
                    OracleDataAdapter dadt = new OracleDataAdapter(cmmd);
                    iAffRow = dadt.Fill(rDs);

                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn.Dispose();
                    }
                }
                else if (objCon.GetType() == typeof(OleDbConnection))
                {
                    OleDbConnection  conn = (OleDbConnection)objCon;
                    OleDbCommand     cmmd = new OleDbCommand(sQry, conn);
                    OleDbDataAdapter dadt = new OleDbDataAdapter(cmmd);
                    iAffRow = dadt.Fill(rDs);

                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                        conn.Dispose();
                    }
                }

                if (rDs.Tables.Count > 0)
                {
                    return(rDs.Tables[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }