Beispiel #1
0
        public void AddSMSToQueThread()
        {
            int LoopTimeInMiliSecound = SMS.Default.ProccessTimeLoop;

            while (isRun)
            {
                isRun = false;
                if (MSMProccess.MT_PROC_QUE.Count < 100)
                {
                    DataTable tbl = SMS_MTDB_SQL.GetMTByStatus(false);
                    EnQueue(tbl);
                }

                isRun = true;
                Thread.Sleep(LoopTimeInMiliSecound); //1000 * 60 * 60 = 1h
            }
        }
Beispiel #2
0
        private void EnQueue(DataTable tbl)
        {
            int step = 1;

            if (tbl != null && tbl.Rows.Count > 0 && MSMProccess.MT_PROC_QUE.Count < 100)
            {
                _logger.Info(" ");
                _logger.Info(" ");
                _logger.Info(" ");
                _logger.Info(string.Format("MT_PROC_QUE count: {0}", MSMProccess.MT_PROC_QUE.Count));
                _logger.Info(string.Format("******step: {0} at {1}", step++, DateTime.Now));
                _logger.Info(string.Format("******Number of User: {0}", tbl.Rows.Count));

                //Get list of MT id
                string lstId = "0";
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    lstId += "," + Convert.ToString(tbl.Rows[i]["ID"]);
                }
                SMS_MTDB_SQL.MTUpdateByListId(lstId);

                foreach (DataRow row in tbl.Rows)
                {
                    try
                    {
                        ViSport_S2_Registered_UsersInfo info = initInfo(row);
                        MSMProccess.MT_PROC_QUE.Enqueue(info);
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("error! {0}", ex.Message + " -- " + ex.StackTrace) + Environment.NewLine);
                    }
                }
            }

            ViSport_S2_SMS_MTController.UpdateStatus(0); //UPDATE JobStatus Sau Khi Gui MT Xong;
        }
Beispiel #3
0
        public static void SentMtInfo(ViSport_S2_Registered_UsersInfo info)
        {
            DataTable dt = ViSport_S2_SMS_MTController.GetMtContent(info.Sub_Code.ToUpper());

            if (dt != null && dt.Rows.Count > 0)
            {
                //if(!string.IsNullOrEmpty(dt.Rows[0]["MT"].ToString()))
                //{
                try
                {
                    int    hour = ConvertUtility.ToInt32(dt.Rows[0]["Hour"].ToString());
                    string day  = dt.Rows[0]["Day"].ToString();

                    //DataTable dtMt = ViSport_S2_SMS_MTController.CheckAlreadySendMt(info.User_ID,hour,day,info.Sub_Code);
                    //_logger.Info("Tham So Check CheckAlreadySendMt : " + info.User_ID + "| hour : " + hour + "| day : " + day);

                    //if (dtMt != null && dtMt.Rows[0]["RETURN_ID"].ToString() == "1")
                    //{
                    //    _logger.Info("Da gui MT cho so : " + info.User_ID + "| hour : " + hour + "| day : " + day);
                    //}
                    //else
                    //{
                    //string message = dt.Rows[0]["MT"].ToString(); //Message lay tu DB;

                    //string messageKd = UnicodeUtility.UnicodeToKoDau(message); //Loai bo dau;


                    #region Gui MT cho khach hang

                    var objSentMt = new ServiceProviderService();

                    string serviceId   = info.Service_ID;
                    string commandCode = info.Command_Code;
                    string requestId   = info.Request_ID;

                    //for (int i = 0; i < 3;i++ )
                    //{
                    const int mtOrder   = 1;
                    string    mtContent = string.Empty;

                    if (!string.IsNullOrEmpty(dt.Rows[0]["MT1"].ToString()))
                    {
                        mtContent = dt.Rows[0]["MT1"].ToString();
                    }
                    else if (!string.IsNullOrEmpty(dt.Rows[0]["MT2"].ToString()))
                    {
                        mtContent = dt.Rows[0]["MT2"].ToString();
                    }
                    else if (!string.IsNullOrEmpty(dt.Rows[0]["MT3"].ToString()))
                    {
                        mtContent = dt.Rows[0]["MT3"].ToString();
                    }

                    //if(i==0)
                    //{
                    //    mtOrder = 1;
                    //    mtContent = dt.Rows[0]["MT1"].ToString();
                    //}
                    //else if(i == 1)
                    //{
                    //    mtOrder = 2;
                    //    mtContent = dt.Rows[0]["MT2"].ToString();
                    //}
                    //else
                    //{
                    //    mtOrder = 3;
                    //    mtContent = dt.Rows[0]["MT3"].ToString();
                    //}

                    DataTable dtMt = ViSport_S2_SMS_MTController.CheckAlreadySendMt(info.User_ID, hour, day, info.Sub_Code, mtOrder);
                    _logger.Info("Tham So Check CheckAlreadySendMt : " + info.User_ID + " | hour : " + hour + " | day : " + day + " | sub_code :" + info.Sub_Code + " | mt_order :" + mtOrder);

                    if (dtMt != null && dtMt.Rows.Count > 0)
                    {
                        _logger.Info("Da gui MT cho so : " + info.User_ID + " | hour : " + hour + " | day : " + day + " | sub_code :" + info.Sub_Code + " | mt_order :" + mtOrder);
                    }
                    else
                    {
                        _logger.Info(string.Format("Started Send MT User_ID= {0}, Request_ID = {1}, ID = {2}, Message = {3}", info.User_ID, info.Request_ID, info.ID, mtContent));

                        if (!string.IsNullOrEmpty(mtContent))
                        {
                            int sentMt = objSentMt.sendMT(info.User_ID, mtContent, serviceId, commandCode, "1", requestId, "1", "1", "0", "0");
                            _logger.Info("SentMt return: " + sentMt);
                        }

                        #region Log Sms MT

                        var objMt = new ViSport_S2_SMS_MTInfo();
                        objMt.User_ID       = info.User_ID;
                        objMt.Message       = mtContent;
                        objMt.Service_ID    = serviceId;
                        objMt.Command_Code  = commandCode;
                        objMt.Sub_Code      = info.Sub_Code;
                        objMt.Message_Type  = 1;
                        objMt.Request_ID    = requestId;
                        objMt.Total_Message = 1;
                        objMt.Message_Index = 0;
                        objMt.IsMore        = 0;
                        objMt.Content_Type  = 0;
                        objMt.ServiceType   = 0;
                        objMt.ResponseTime  = DateTime.Now;
                        objMt.isLock        = false;
                        objMt.PartnerID     = "Xzone";
                        objMt.Operator      = "ViSport_MT";

                        objMt.MtOrder = mtOrder;

                        ViSport_S2_SMS_MTController.InsertMtSpamSmsUser(objMt);

                        #endregion
                    }

                    //}

                    #endregion
                    //}
                }
                catch (TimeoutException e)
                {
                    _logger.Error(string.Concat("mySendMT - ", e.StackTrace));
                    _logger.Error(string.Concat("mySendMT - ", e.Message));
                    MT_PROC_QUE.Enqueue(info);
                }
                catch (Exception ex)
                {
                    //neu phat sinh loi he thong thi Update Islock = 0, de lan sau co the charge lai
                    _logger.Info(string.Format("ERROR!Sending to {0} is error, Request_ID = {1}, Error mess = {2}", info.User_ID, info.Request_ID, ex.Message) + Environment.NewLine);
                    SMS_MTDB_SQL.MTUpdateFail(info.ID);
                }
                //}
            }

            Thread.Sleep(100);
        }