Ejemplo n.º 1
0
 public void Balance_Simpay(long providerID, decimal balance)
 {
     Helpers.Connection.sConnectionStringDatabase = "Data Source=192.168.1.11,1433;Initial Catalog=SYSTEMWARNING;Connect Timeout=200;User id=sa;Password=@sp123456";
     WarningLibrary.SystemWarning sw = new WarningLibrary.SystemWarning();
     //sw.Balance_Simpay(providerID, balance);
 }
Ejemplo n.º 2
0
        public void Balance_Simpay(long providerID, decimal balance)
        {
            Helpers.Connection.sConnectionStringDatabase = ConfigurationManager.ConnectionStrings["sConnectionString_SystemWarning"].ConnectionString;
            WarningLibrary.SystemWarning sw = new WarningLibrary.SystemWarning();

            //list chua KQ check Rules
            List <LOGSEND> result = sw.Balance_Simpay(providerID, balance);
            //dataset chua Logsend
            DataSet dsLogSend = new DataSet();
            //bien thong tin message
            Int64   intLOGSEND_AUTOID  = 0;
            Int64   intRULE_AUTOID     = 0;
            Int64   intACTION_AUTOID   = 0;
            Int64   intUSERSEND_AUTOID = 0;
            Boolean blExist            = false;

            //bien thoi gian
            DateTime dtNow;
            DateTime dtRULE_CREATEDATE;
            TimeSpan tsDiff;
            Int64    intDiff;
            //config dang Giay
            Int64 intInterval = Convert.ToInt64(ConfigurationManager.AppSettings["interval"]);

            //kiem tra trung message
            if (result.Count() > 0)
            {
                //kiem tra tung message
                foreach (LOGSEND log in result)
                {
                    dsLogSend.Clear();
                    Helpers.Connection.sConnectionStringDatabase = ConfigurationManager.ConnectionStrings["sConnectionString_SystemWarning"].ConnectionString;
                    dsLogSend = DataOut.SW_LOGSEND_Select_All();

                    //neu dsLogSend co message - set tung message trong Logsend
                    if (dsLogSend.Tables[0].Rows.Count > 0)
                    {
                        blExist = false;
                        //kiem tra ton tai message
                        for (int i = 0; i < dsLogSend.Tables[0].Rows.Count; i++)
                        {
                            //lay thong tin message
                            intLOGSEND_AUTOID  = Convert.ToInt64(dsLogSend.Tables[0].Rows[i][LOGSEND.COLUMN_LOGSEND_AUTOID].ToString().Trim());
                            intRULE_AUTOID     = Convert.ToInt64(dsLogSend.Tables[0].Rows[i][LOGSEND.COLUMN_RULE_AUTOID].ToString().Trim());
                            intACTION_AUTOID   = Convert.ToInt64(dsLogSend.Tables[0].Rows[i][LOGSEND.COLUMN_ACTION_AUTOID].ToString().Trim());
                            intUSERSEND_AUTOID = Convert.ToInt64(dsLogSend.Tables[0].Rows[i][LOGSEND.COLUMN_USERSEND_AUTOID].ToString().Trim());
                            //truong hop ton tai message (cung [RULE_AUTOID], [ACTION_AUTOID], [USERSEND_AUTOID])
                            if (log.RULE_AUTOID == intRULE_AUTOID && log.ACTION_AUTOID == intACTION_AUTOID && log.USERSEND_AUTOID == intUSERSEND_AUTOID)
                            {
                                blExist = true;
                                break;
                            }
                            else
                            {
                                blExist = false;
                            }
                        }
                        //truong hop ton tai message
                        if (blExist)
                        {
                            dtNow             = DateTime.Now;
                            dtRULE_CREATEDATE = Convert.ToDateTime(DataOut.SW_LOGSEND_SelectByID(intLOGSEND_AUTOID).Tables[0].Rows[0][LOGSEND.COLUMN_RULE_CREATEDATE].ToString().Trim());
                            tsDiff            = dtNow - dtRULE_CREATEDATE;
                            intDiff           = (tsDiff.Days * 24 * 60 * 60) + (tsDiff.Hours * 60 * 60) + (tsDiff.Minutes * 60) + tsDiff.Seconds;

                            //truong hop <= config
                            if (intDiff <= intInterval)
                            {
                                //cap nhat thoi gian message
                                //DataIn.SW_LOGSEND_UpdateByID(intLOGSEND_AUTOID);
                            }
                            else
                            {
                                //cap nhat thoi gian message
                                DataIn.SW_LOGSEND_UpdateByID(intLOGSEND_AUTOID);
                                //thuc hien gui
                                Balance_Simpay_Insert_Send(log, balance);
                            }
                        }
                        //truong hop khong ton tai message
                        else
                        {
                            //insert Logsend
                            DataIn.SW_LOGSEND_Insert(log);
                            //thuc hien gui
                            Balance_Simpay_Insert_Send(log, balance);
                        }
                    }
                    //neu dsLogSend khong co message - insert va gui luon
                    else
                    {
                        //insert Logsend
                        DataIn.SW_LOGSEND_Insert(log);
                        //thuc hien gui
                        Balance_Simpay_Insert_Send(log, balance);
                    }
                }
            }
        }