Ejemplo n.º 1
0
 /// <summary>
 /// Insert or update Transaction for send SMS
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public bool TRANSACTION_InsertUpdate(Librarys.CRM.TRANSACTION obj)
 {
     Helpers.Connection.sConnectionStringDatabase = ConfigurationManager.ConnectionStrings["sConnectionString_Crm"].ConnectionString;
     return(FundManagementLib.FundManagementLib.TransactionInsertUpdate(obj));
 }
Ejemplo n.º 2
0
        private void Balance_Simpay_Insert_Send(LOGSEND log, decimal balance)
        {
            //thoi gian he thong
            string strNow      = string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);
            string strNowTitle = string.Format("{0:yyyy-MM-dd}", DateTime.Now);

            //lay title Email la ruleName
            Helpers.Connection.sConnectionStringDatabase = ConfigurationManager.ConnectionStrings["sConnectionString_SystemWarning"].ConnectionString;
            string titleEmail = DataOut.SW_RULES_SelectByID(log.RULE_AUTOID).Tables[0].Rows[0][RULE.COLUMN_RULE_NAME].ToString().Trim();

            titleEmail += " " + strNowTitle;

            //lay noi dung gui la gia tri cua cac conditions
            string  strContentSend = null;
            DataSet dsContent      = new DataSet();

            dsContent = DataOut.SW_RULEDETAIL_BALANCESSIMPAY_All(log.RULE_AUTOID);

            for (int i = 0; i < dsContent.Tables[0].Rows.Count; i++)
            {
                //chi lay cac conditions da Active
                if (Convert.ToBoolean(dsContent.Tables[0].Rows[i][RULEDETAIL.COLUMN_RULEDETAIL_ISACTIVE].ToString().Trim()) == true)
                {
                    //truong hop condition "so du tai khoan"
                    if (Convert.ToInt64(dsContent.Tables[0].Rows[i][RULEDETAIL.COLUMN_CONDITION_AUTOID].ToString().Trim()) == 3)
                    {
                        strContentSend += (dsContent.Tables[0].Rows[i]["CONDITION_NAME"].ToString().Trim()) + ": " + balance.ToString("#,##0 VNĐ") + " " + (dsContent.Tables[0].Rows[i]["KEY_NOTE2"].ToString().Trim())
                                          + " " + Convert.ToDecimal(dsContent.Tables[0].Rows[i]["KEYVALUE"].ToString().Trim()).ToString("#,##0 VNĐ") + "; ";
                    }
                    //truong hop condition "nha cung cap"
                    else if (Convert.ToInt64(dsContent.Tables[0].Rows[i][RULEDETAIL.COLUMN_CONDITION_AUTOID].ToString().Trim()) == 2)
                    {
                        strContentSend += (dsContent.Tables[0].Rows[i]["CONDITION_NAME"].ToString().Trim()) + ": " + (dsContent.Tables[0].Rows[i]["KEYVALUE"].ToString().Trim()) + "; ";
                    }
                    //truong hop condition "thoi diem"
                    else if (Convert.ToInt64(dsContent.Tables[0].Rows[i][RULEDETAIL.COLUMN_CONDITION_AUTOID].ToString().Trim()) == 4)
                    {
                        //truong hop la ngay co dinh
                        if (Convert.ToInt64(dsContent.Tables[0].Rows[i][RULEDETAIL.COLUMN_RULEDETAIL_TYPE].ToString().Trim()) == 3)
                        {
                            strContentSend += (dsContent.Tables[0].Rows[i]["CONDITION_NAME"].ToString().Trim()) + ": " + (dsContent.Tables[0].Rows[i]["KEYVALUE"].ToString().Trim()) + "; ";
                        }
                        //truong hop chon thu
                        else
                        {
                            strContentSend += (dsContent.Tables[0].Rows[i]["CONDITION_NAME"].ToString().Trim()) + ": " + (dsContent.Tables[0].Rows[i]["CONDITIONDETAIL_VALUE"].ToString().Trim()) + "; ";
                        }
                    }
                }
            }


            //send message
            Helpers.Connection.sConnectionStringDatabase = ConfigurationManager.ConnectionStrings["sConnectionString_Crm"].ConnectionString;
            //SMS
            if (log.ACTION_AUTOID == 1)
            {
                //insert vao DB SMS
                Librarys.CRM.TRANSACTION trans = new Librarys.CRM.TRANSACTION();
                trans.RECEIVEACCOUNT = log.USERSEND_HANDPHONE;
                trans.FROMACCOUNT    = "";
                trans.LASTUPDATE     = DateTime.Now;
                trans.CODE           = 1;
                trans.STATUS         = 1;
                trans.VALUE          = Protect.RemoveVNString(strContentSend).Trim();
                trans.TRANSTYPECODE  = 4;
                trans.RECEIVEID      = DateTime.Now.Ticks.ToString();
                trans.COMSIMID       = 0;
                DataIn.CRM_TRANSACTION_InsertUpdate(trans);
            }
            //EMAIL
            else if (log.ACTION_AUTOID == 2)
            {
                //insert vao DB EMAIL
                Librarys.CRM.TRANSACTION trans = new Librarys.CRM.TRANSACTION();
                trans.RECEIVEACCOUNT = log.USERSEND_EMAIL;
                trans.FROMACCOUNT    = "*****@*****.**";
                trans.LASTUPDATE     = DateTime.Now;
                trans.CODE           = 1;
                trans.STATUS         = 1;
                trans.VALUE          = string.Format("{0}##{1}", titleEmail, strNow + "; " + strContentSend);
                trans.TRANSTYPECODE  = 10;
                trans.RECEIVEID      = "<" + Guid.NewGuid().ToString() + "@simpay.com.vn>";
                trans.COMSIMID       = 0;
                DataIn.CRM_TRANSACTION_InsertUpdate(trans);
            }
        }