예제 #1
0
        public void RetrieveData(int year, int period, int system, string byUser, SqlInfoMessageEventHandler infoMessageHandler = null)
        {
            SqlConnection conn = new SqlConnection(AppConfig.ConnectionString);

            conn.FireInfoMessageEventOnUserErrors = true; // This flag allow receive message realtime.

            SqlData db = new SqlData(conn);

            try
            {
                db.BeginTrans();

                conn.InfoMessage += infoMessageHandler;
                StoreProcedure.sp_ACS310_Process_RetrieveData(db, year, period, system, byUser);

                conn.InfoMessage -= infoMessageHandler;
                StoreProcedure.sp_ACS310_Update_ProcessControl(db, year, period, byUser);

                db.CommitTrans();
            }
            catch (Exception ex)
            {
                if (db.HasTransaction)
                {
                    db.RollbackTrans();
                }

                throw;
            }
            finally
            {
                db.Close();
            }
        }
예제 #2
0
        public ACS320_Process CalculateData(int year, int period, string byUser, SqlInfoMessageEventHandler infoMessageHandler = null)
        {
            SqlConnection conn = new SqlConnection(AppConfig.ConnectionString);

            conn.FireInfoMessageEventOnUserErrors = true; // This flag allow receive message realtime.

            SqlData db = new SqlData(conn);

            try
            {
                db.BeginTrans();

                //#####################
                //# Process Calcualte
                //#  While processing, reponse progress periodically.
                //#####################
                conn.InfoMessage += infoMessageHandler;
                ACS320_Process result = StoreProcedure.sp_ACS320_Process_CalculateData(db, year, period, byUser);

                //#####################
                //# Update Calculation Status
                //#####################
                conn.InfoMessage -= infoMessageHandler;
                StoreProcedure.sp_ACS320_Update_ProcessControl(db, year, period, byUser);

                db.CommitTrans();

                return(result);
            }
            catch (Exception ex)
            {
                if (db.HasTransaction)
                {
                    db.RollbackTrans();
                }

                throw;
            }
            finally
            {
                db.Close();
            }
        }