コード例 #1
0
ファイル: Hospital.cs プロジェクト: hoangtung56pm/ViSport_4.0
    private static List <Service_Info> PopulateObjectsFromReader(IDataReader dataReader)
    {
        List <Service_Info> list = new List <Service_Info>();

        while (dataReader.Read())
        {
            Service_Info service = new Service_Info();
            service.ID             = ConvertUtility.ToInt32(dataReader["ID"]);
            service.Service_Name   = ConvertUtility.ToString(dataReader["Service_Name"]);
            service.Service_Code   = ConvertUtility.ToString(dataReader["Service_Code"]);
            service.Service_Type   = ConvertUtility.ToInt32(dataReader["Service_Type"]);
            service.TimesMT        = ConvertUtility.ToString(dataReader["TimesMT"]);
            service.TimesAlert     = ConvertUtility.ToString(dataReader["TimesAlert"]);
            service.WelcomeMT      = ConvertUtility.ToString(dataReader["WelcomeMT"]);
            service.DailyMT        = ConvertUtility.ToString(dataReader["DailyMT"]);
            service.WaitingMT      = ConvertUtility.ToString(dataReader["WaitingMT"]);
            service.CronTime       = ConvertUtility.ToString(dataReader["CronTime"]);
            service.Status         = ConvertUtility.ToInt32(dataReader["Status"]);
            service.TimelineFirst  = ConvertUtility.ToInt32(dataReader["TimelineFirst"]);
            service.TimelineSecond = ConvertUtility.ToInt32(dataReader["TimelineSecond"]);
            service.CreatedDate    = ConvertUtility.ToDateTime(dataReader["CreatedDate"]);
            service.CreatedBy      = ConvertUtility.ToInt32(dataReader["CreatedBy"]);
            service.ModifiedDate   = ConvertUtility.ToDateTime(dataReader["ModifiedDate"]);
            service.ModifiedBy     = ConvertUtility.ToInt32(dataReader["ModifiedBy"]);
            list.Add(service);
        }

        return(list);
    }
コード例 #2
0
        public string SyncSubscriptionData(string ShortCode, string CommandCode, string UserID, string Message, string RequestID, string ServiceID, string RefID, string UpdateType, string UpdateDescription)
        {
            try
            {
                if (Message.StartsWith("HD", StringComparison.OrdinalIgnoreCase)) // HD|HDSD
                {
                    Service_Info service = Controller.Visport_Subscription_Services_GetByID(ConvertUtility.ToInt32(ServiceID));
                    string       mt      = service.Right_Syntax_MT.Replace("Shortcode", ShortCode);
                    Controller.SendMT(UserID, mt, ShortCode, CommandCode, service.Service_Type, service.ID, MESSAGE_TYPE.NoCharge, RequestID, 1, 1, 0, CONTENT_TYPE.Text);
                }
                else if (Message.StartsWith("KT", StringComparison.OrdinalIgnoreCase)) // KTDV|KT DV
                {
                    DataTable dt = SqlHelper.ExecuteDataset(Common.ConnectionString, "Visport_GetRegisteredServices", UserID).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        string srvInfoFormat = "Quy khach dang su dung dich vu {0} tren dau so 979. Phi dich vu: {1} dong/{2} ngay. Quy khach da dang ky dich vu vao ngay {3} qua {4}. De huy dich vu, vui long soan: {5} gui 979.  De biet them ve cac dich vu khac, soan tin: HDSD gui 949 .Tran trong cam on.";
                        string srvInfo       = "";
                        foreach (DataRow dr in dt.Rows)
                        {
                            srvInfo = String.Format(srvInfoFormat, dr["Product_Name"], dr["Charging_Price"], dr["PeriodLength"], dr["RegisteredTime"], dr["Registration_Channel"], dr["Cancel_Syntax"]);
                            Controller.SendMT(UserID, srvInfo, ShortCode, CommandCode, 1001, 1, MESSAGE_TYPE.NoCharge, RequestID, 1, 1, 0, CONTENT_TYPE.Text);
                        }
                    }
                    else
                    {
                        string mt = "Quy khach khong su dung dich vu nao tren dau so nay. Tran trong cam on";
                        Controller.SendMT(UserID, mt, ShortCode, CommandCode, 1001, 1, MESSAGE_TYPE.NoCharge, RequestID, 1, 1, 0, CONTENT_TYPE.Text);
                    }
                }
                else if (Message.StartsWith("HUY", StringComparison.OrdinalIgnoreCase)) // HUY TBDV
                {
                    DataTable dt = SqlHelper.ExecuteDataset(Common.ConnectionString, "Visport_GetRegisteredServices", UserID).Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            Controller.Visport_Deactivate_Users(ConvertUtility.ToInt32(dr["ID"]), "HUY TBDV");
                        }

                        string mt = "Quy khach da huy thanh cong toan bo dich vu da dang ky tren dau so 979. Tran trong cam on";
                        Controller.SendMT(UserID, mt, ShortCode, CommandCode, 1001, 1, MESSAGE_TYPE.NoCharge, RequestID, 1, 1, 0, CONTENT_TYPE.Text);
                    }
                    else
                    {
                        string mt = "Quy khach khong su dung dich vu nao tren dau so nay. Tran trong cam on";
                        Controller.SendMT(UserID, mt, ShortCode, CommandCode, 1001, 1, MESSAGE_TYPE.NoCharge, RequestID, 1, 1, 0, CONTENT_TYPE.Text);
                    }
                }

                return("-1|User Guide");
            }
            catch (Exception ex)
            {
                return("0|" + ex.Message);
            }
        }
コード例 #3
0
        public static Service_Info Visport_Subscription_Services_GetByID(int service_ID)
        {
            Service_Info  retVal = null;
            SqlConnection dbConn = new SqlConnection(ConnectionString);

            SqlCommand dbCmd = new SqlCommand("Visport_Subscription_Services_GetByID", dbConn);

            dbCmd.CommandType = CommandType.StoredProcedure;
            dbCmd.Parameters.AddWithValue("@ID", service_ID);

            try
            {
                dbConn.Open();
                SqlDataReader dr = dbCmd.ExecuteReader();
                if (dr.Read())
                {
                    retVal                    = new Service_Info();
                    retVal.ID                 = ConvertUtility.ToInt32(dr["ID"]);
                    retVal.Service_Name       = ConvertUtility.ToString(dr["Service_Name"]);
                    retVal.Service_ID         = ConvertUtility.ToString(dr["Service_ID"]);
                    retVal.Service_Type       = ConvertUtility.ToInt32(dr["Service_Type"]);
                    retVal.Service_Code       = ConvertUtility.ToString(dr["Service_Code"]);
                    retVal.Register_Syntax    = ConvertUtility.ToString(dr["Register_Syntax"]);
                    retVal.Right_Syntax_MT    = ConvertUtility.ToString(dr["Right_Syntax_MT"]);
                    retVal.Wrong_Syntax_MT    = ConvertUtility.ToString(dr["Wrong_Syntax_MT"]);
                    retVal.Double_Register_MT = ConvertUtility.ToString(dr["Double_Register_MT"]);
                    retVal.Cancel_Syntax      = ConvertUtility.ToString(dr["Cancel_Syntax"]);
                    retVal.Cancel_MT          = ConvertUtility.ToString(dr["Cancel_MT"]);
                    retVal.RefID              = ConvertUtility.ToString(dr["RefID"]);
                    retVal.PeriodLength       = ConvertUtility.ToInt32(dr["PeriodLength"]);
                    retVal.NoChargeLength     = ConvertUtility.ToInt32(dr["NoChargeLength"]);
                    retVal.Description        = ConvertUtility.ToString(dr["Description"]);
                    retVal.Charging_Price     = ConvertUtility.ToInt32(dr["Charging_Price"]);
                    retVal.OutOf_Money_MT     = ConvertUtility.ToString(dr["OutOf_Money_MT"]);
                    retVal.Rules              = ConvertUtility.ToString(dr["Rules"]);
                    retVal.Process_WS_Url     = ConvertUtility.ToString(dr["Process_WS_Url"]);
                    retVal.Status             = ConvertUtility.ToInt32(dr["Status"]);
                    retVal.Created_By         = ConvertUtility.ToInt32(dr["Created_By"]);
                    retVal.Created_Date       = ConvertUtility.ToDateTime(dr["Created_Date"]);
                    retVal.Modified_By        = ConvertUtility.ToInt32(dr["Modified_By"]);;
                    retVal.Modified_Date      = ConvertUtility.ToDateTime(dr["Modified_Date"]);;
                    retVal.HandlerEndpoint    = ConvertUtility.ToString(dr["HandlerEndpoint"]);
                }

                dr.Close();
            }
            finally
            {
                dbConn.Close();
            }
            return(retVal);
        }
コード例 #4
0
        private static List <Service_Info> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <Service_Info> list = new List <Service_Info>();

            while (dataReader.Read())
            {
                Service_Info service = new Service_Info();
                service.ID                 = ConvertUtility.ToInt32(dataReader["ID"]);
                service.Service_Name       = ConvertUtility.ToString(dataReader["Service_Name"]);
                service.Service_ID         = ConvertUtility.ToString(dataReader["Service_ID"]);
                service.Product_Name       = ConvertUtility.ToString(dataReader["Product_Name"]);
                service.Service_Code       = ConvertUtility.ToString(dataReader["Service_Code"]);
                service.Service_Type       = ConvertUtility.ToInt32(dataReader["Service_Type"]);
                service.Register_Syntax    = ConvertUtility.ToString(dataReader["Register_Syntax"]);
                service.Right_Syntax_MT    = ConvertUtility.ToString(dataReader["Right_Syntax_MT"]);
                service.Wrong_Syntax_MT    = ConvertUtility.ToString(dataReader["Wrong_Syntax_MT"]);
                service.Double_Register_MT = ConvertUtility.ToString(dataReader["Double_Register_MT"]);
                service.Cancel_Syntax      = ConvertUtility.ToString(dataReader["Cancel_Syntax"]);
                service.Cancel_MT          = ConvertUtility.ToString(dataReader["Cancel_MT"]);
                service.RefID              = ConvertUtility.ToString(dataReader["RefID"]);
                service.PeriodLength       = ConvertUtility.ToInt32(dataReader["PeriodLength"]);
                service.NoChargeLength     = ConvertUtility.ToInt32(dataReader["NoChargeLength"]);
                service.Description        = ConvertUtility.ToString(dataReader["Description"]);
                service.Charging_Price     = ConvertUtility.ToInt32(dataReader["Charging_Price"]);
                service.OutOf_Money_MT     = ConvertUtility.ToString(dataReader["OutOf_Money_MT"]);
                service.Rules              = ConvertUtility.ToString(dataReader["Rules"]);
                service.Process_WS_Url     = ConvertUtility.ToString(dataReader["Process_WS_Url"]);
                service.Status             = ConvertUtility.ToInt32(dataReader["Status"]);
                service.Created_By         = ConvertUtility.ToInt32(dataReader["Created_By"]);
                service.Modified_By        = ConvertUtility.ToInt32(dataReader["Modified_By"]);
                service.Created_Date       = ConvertUtility.ToDateTime(dataReader["Created_Date"]);
                service.Modified_Date      = ConvertUtility.ToDateTime(dataReader["Modified_Date"]);
                service.HandlerEndpoint    = ConvertUtility.ToString(dataReader["HandlerEndpoint"]);

                list.Add(service);
            }

            return(list);
        }
コード例 #5
0
        public int ProcessMO(String Command_Code, String Service_ID, String User_ID, String Message, String Request_ID, String Channel)
        {
            int retval = PROCESSMO_RESULT.UNKNOWN;

            try
            {
                #region Check blacklist
                int q = Controller.CheckBlacklist(User_ID);
                if (q > 0)
                {
                    retval = PROCESSMO_RESULT.BLACK_LIST;
                    return(retval);
                }
                if (!Common.filterMsisdn(User_ID))
                {
                    retval = PROCESSMO_RESULT.BLACK_LIST;
                    return(retval);
                }
                #endregion
                #region Check Syntax
                string mo = Common.Normalize(Message).ToUpper();
                Command_Code = Command_Code.ToUpper();
                User_ID      = Common.GetNormalPhonenumber(User_ID);
                Service_Info matchService   = null;
                bool         isSubscription = false;


                List <Service_Info> listService = Controller.Visport_Subscription_Services_ListAll();
                foreach (Service_Info s2Service in listService)
                {
                    if (Common.IsRightSyntax(s2Service.Register_Syntax, mo))
                    {
                        matchService   = s2Service;
                        isSubscription = true;
                        break;
                    }
                    else if (Common.IsRightSyntax(s2Service.Cancel_Syntax, mo))
                    {
                        matchService   = s2Service;
                        isSubscription = false;
                        break;
                    }
                }
                string mt = "";
                if (matchService == null) // => Sai cú pháp
                {
                    mt = "Tin nhan cua quy khach sai cu phap. De duoc huong dan su dung dich vu, soan tin: HD gui 979. Tran trong cam on";
                    Visport_MO moInfo = new Visport_MO();
                    moInfo.User_ID      = User_ID;
                    moInfo.Request_ID   = Request_ID;
                    moInfo.Service_ID   = Service_ID;
                    moInfo.Command_Code = Command_Code;
                    moInfo.Message      = Message.Replace("'", " ");
                    moInfo.Partner_ID   = "";
                    moInfo.ServiceType  = 0;
                    moInfo.ServiceId    = 0;
                    moInfo.Channel      = Channel;
                    int rtMO = Controller.Visport_MO_Insert(moInfo);
                    Controller.SendMT(User_ID, mt, Service_ID, Command_Code, 0, 0, MESSAGE_TYPE.Refund, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                    logger.ErrorFormat("*** Process MO [Short_Code:{0}], [Command_Code:{1}], [User_ID:{2}], [Request_ID:{3}], [Message:{4}], [Channel:{6}]: [MTLs:{5}]"
                                       , Service_ID
                                       , Command_Code
                                       , User_ID
                                       , Request_ID
                                       , Message
                                       , mt
                                       , Channel);

                    retval = PROCESSMO_RESULT.WRONGSYNTAX;
                }
                else
                {
                    Visport_MO moInfo = new Visport_MO();
                    moInfo.User_ID      = User_ID;
                    moInfo.Request_ID   = Request_ID;
                    moInfo.Service_ID   = Service_ID;
                    moInfo.Command_Code = Command_Code;
                    moInfo.Message      = Message.Replace("'", " ");
                    moInfo.Partner_ID   = "";
                    moInfo.ServiceType  = matchService.Service_Type;
                    moInfo.ServiceId    = matchService.ID;
                    moInfo.Channel      = Channel;
                    int            rtMO           = Controller.Visport_MO_Insert(moInfo);
                    ServiceHandler handler        = null;
                    string         handleResponse = "";
                    if (isSubscription)
                    {
                        #region Xử lý đăng ký
                        List <Visport_Registered_Users> listUsers          = Controller.Visport_GetUser_Info(User_ID, matchService.ID);
                        List <Visport_Registered_Users> lstCheckFisrtRegis = Controller.Visport_CheckFirst_Regis(User_ID, matchService.ID);
                        if (listUsers.Count > 0)
                        {
                            mt = matchService.Double_Register_MT;
                            Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Charge, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);

                            retval = PROCESSMO_RESULT.DOUBLE_REGISTER;
                        }
                        else
                        {
                            handler = new ServiceHandler(matchService.HandlerEndpoint);
                            try
                            {
                                handleResponse = handler.SyncSubscriptionData(Service_ID, Command_Code, User_ID, Message, Request_ID, matchService.ID.ToString(), matchService.RefID, "1", "Subscription");
                                //handleResponse = "1";
                            }
                            catch (Exception ex)
                            {
                                handleResponse = "0|" + ex.Message;
                            }
                            if (handleResponse.StartsWith("1|"))
                            {
                                if (lstCheckFisrtRegis.Count > 0)
                                {
                                    //Update Status Registered_Users
                                    Visport_Registered_Users user = new Visport_Registered_Users();
                                    user.User_ID             = User_ID;
                                    user.Request_ID          = Request_ID;
                                    user.Service_ID          = matchService.ID;
                                    user.Short_Code          = Service_ID;
                                    user.Command_Code        = Command_Code;
                                    user.Service_Type        = matchService.Service_Type;
                                    user.Status              = Convert.ToInt32(USER_STATUS.ACTIVE);
                                    user.RegistrationChannel = Channel;
                                    user.PeriodLength        = matchService.PeriodLength;
                                    user.NoChargeLength      = matchService.NoChargeLength;
                                    user.ChargedFee          = matchService.Charging_Price;
                                    int rtvalue = Controller.Visport_Registered_Users_Update(user);
                                    if (rtvalue > 0)
                                    {
                                        mt = matchService.Right_Syntax_MT;
                                        Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Charge, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                        retval = PROCESSMO_RESULT.REGISTER_SUCCESSFULLY;
                                    }
                                    else
                                    {
                                        mt = "He thong dang ban. De duoc ho tro xin lien he 19001255. Cam on quy khach.";
                                        Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Refund, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                        retval = PROCESSMO_RESULT.SYSTEM_BUSY;
                                    }
                                }
                                else
                                {
                                    //Insert DB Registered_Users
                                    Visport_Registered_Users user = new Visport_Registered_Users();
                                    user.User_ID             = User_ID;
                                    user.Request_ID          = Request_ID;
                                    user.Service_ID          = matchService.ID;
                                    user.Short_Code          = Service_ID;
                                    user.Command_Code        = Command_Code;
                                    user.Service_Type        = matchService.Service_Type;
                                    user.Status              = Convert.ToInt32(USER_STATUS.ACTIVE);
                                    user.RegistrationChannel = Channel;
                                    user.PeriodLength        = matchService.PeriodLength;
                                    user.ChargedFee          = matchService.Charging_Price;
                                    int rtvalue = Controller.Visport_Registered_Users_Insert(user);
                                    if (rtvalue > 0)
                                    {
                                        mt = matchService.Right_Syntax_MT;
                                        Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Charge, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                        retval = PROCESSMO_RESULT.REGISTER_SUCCESSFULLY;
                                    }
                                    else
                                    {
                                        mt = "He thong dang ban. De duoc ho tro xin lien he 19001255. Cam on quy khach.";
                                        Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Refund, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                        retval = PROCESSMO_RESULT.SYSTEM_BUSY;
                                    }
                                }
                            }
                            else if (handleResponse.StartsWith("0|"))
                            {
                                mt = "He thong dang ban. De duoc ho tro xin lien he 19001255. Cam on quy khach.";
                                Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Refund, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                retval = PROCESSMO_RESULT.SYSTEM_BUSY;
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        #region Xử lý hủy
                        List <Visport_Registered_Users> listUser = Controller.Visport_GetUser_Info(User_ID, matchService.ID);
                        if (listUser.Count > 0)
                        {
                            handler = new ServiceHandler(matchService.HandlerEndpoint);
                            try
                            {
                                handleResponse = handler.SyncSubscriptionData(Service_ID, Command_Code, User_ID, Message, Request_ID, matchService.ID.ToString(), matchService.RefID, "0", "Unsubscription");
                                //handleResponse = "1";
                            }
                            catch (Exception ex)
                            {
                                handleResponse = "0|" + ex.Message;
                            }

                            if (handleResponse.StartsWith("1|"))
                            {
                                Controller.Visport_Deactivate_Users(listUser[0].ID, "From user by SMS");
                                mt = matchService.Cancel_MT;
                                Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Charge, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                retval = PROCESSMO_RESULT.CANCEL_SUCCESSFULLY;
                            }
                            else if (handleResponse.StartsWith("0|"))
                            {
                                mt = "He thong dang ban. De duoc ho tro xin lien he 19001255. Cam on quy khach.";
                                Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Refund, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                                retval = PROCESSMO_RESULT.SYSTEM_BUSY;
                            }
                        }
                        else
                        {
                            mt = "Ban khong dang ki dich vu nay.De duoc ho tro xin lien he 19001255. Cam on quy khach!";
                            Controller.SendMT(User_ID, mt, Service_ID, Command_Code, matchService.Service_Type, matchService.ID, MESSAGE_TYPE.Charge, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                            retval = PROCESSMO_RESULT.NOT_EXISTS;
                        }
                        #endregion
                    }

                    logger.InfoFormat("*** Visport Process MO [Short_Code:{0}], [Command_Code:{1}], [User_ID:{2}], [Request_ID:{3}], [Message:{4}], [Channel:{8}]: [HandlerEndpoint:{5}], [HandlerResponse:{6}], [MTLs:{7}]"
                                      , Service_ID
                                      , Command_Code
                                      , User_ID
                                      , Request_ID
                                      , Message
                                      , matchService.HandlerEndpoint
                                      , handleResponse
                                      , mt
                                      , Channel);
                }

                #endregion
            }
            catch (Exception ex)
            {
                retval = PROCESSMO_RESULT.EXCEPTION;

                string mt = "He thong dang ban. Quy khach vui long quay lai sau it phut.";
                Controller.SendMT(User_ID, mt, Service_ID, Command_Code, 0, 0, MESSAGE_TYPE.Refund, Request_ID, 1, 1, 0, CONTENT_TYPE.Text);
                logger.ErrorFormat(String.Format("*** Error Process MO [Short_Code:{0}], [Command_Code:{1}], [User_ID:{2}], [Request_ID:{3}], [Message:{4}], [Channel:{5}]: [Exception:{6}]"
                                                 , Service_ID
                                                 , Command_Code
                                                 , User_ID
                                                 , Request_ID
                                                 , Message
                                                 , Channel
                                                 , ex));
            }
            return(retval);
        }
コード例 #6
0
ファイル: Hospital.cs プロジェクト: hoangtung56pm/ViSport_4.0
    private string ExcecuteRequestMoHospital(string User_ID, string Service_ID, string Command_Code, string Message, string Request_ID)
    {
        //string responseValue = "1";
        string returnValue = "0";

        //Message = Message.ToUpper();
        //string subcode = "";
        string mo = Normalize(Message).ToUpper();

        Command_Code = Command_Code.ToUpper();
        User_ID      = GetNormalPhonenumber(User_ID);
        Service_Info matchService = null;
        string       subcode      = "";
        string       mt           = "";
        int          msgType      = (int)Constant.MessageType.NoCharge;

        if (Message.Trim().Length > Command_Code.Trim().Length)
        {
            subcode = Message.ToUpper().Substring(Command_Code.Length).Replace(" ", "");
        }
        try
        {
            //log.Debug(" ");
            //log.Debug(" ");
            //log.Debug("-------------------- Hospital Service mo  -------------------------");
            //log.Debug("User_ID: " + User_ID);
            //log.Debug("Service_ID: " + Service_ID);
            //log.Debug("Command_Code: " + Command_Code);
            //log.Debug("Message: " + Message.ToUpper());
            //log.Debug("Request_ID: " + Request_ID);
            //log.Debug(" ");
            //log.Debug(" ");

            #region Log MO Message Into Database (SMS_MO_Log)

            var moInfo = new SMS_MOInfo();

            moInfo.User_ID      = User_ID;
            moInfo.Service_ID   = Service_ID;
            moInfo.Command_Code = Command_Code;
            moInfo.Message      = Message;
            moInfo.Request_ID   = Request_ID;
            moInfo.Operator     = DBController.GetTelco(User_ID);
            InsertMo(moInfo);

            #endregion
            #region Process
            List <Service_Info> listService = Services_ListAll();
            foreach (Service_Info s2Service in listService)
            {
                if (IsRightSyntax(s2Service.Service_Code, Command_Code))
                {
                    matchService = s2Service;
                    break;
                }
            }

            if (matchService == null) // => Sai cú pháp
            {
                mt = "Tin nhan cua quy khach sai cu phap. Tran trong cam on";
                //gửi MT
            }
            else
            {
                // xử lý nó thôi
                // check subcode phải dạng 010517 or 01052017
                int ck_ngay, ck_thang, ck_nam;
                int ngay  = ck_ngay = DateTime.Now.Day;
                int thang = ck_thang = DateTime.Now.Month;
                int nam   = ck_nam = DateTime.Now.Year;
                if (subcode.Length == 6 || subcode.Length == 8)
                {
                    ngay  = ConvertUtility.ToInt32(subcode.Substring(0, 2));
                    thang = ConvertUtility.ToInt32(subcode.Substring(2, 2));
                    nam   = subcode.Length == 6 ? ConvertUtility.ToInt32("20" + subcode.Substring(4, 2)) : ConvertUtility.ToInt32(subcode.Substring(4, 4));
                    DateTime AlertDate    = new DateTime(nam, thang, ngay);
                    DateTime ck_AlertDate = new DateTime(ck_nam, ck_thang, ck_ngay);
                    if (AlertDate >= ck_AlertDate)
                    {
                        try
                        {
                            Hospital_User_insert(User_ID, Command_Code, matchService.ID, matchService.Service_Type, AlertDate);
                            Hospital_UserLog_insert(User_ID, Command_Code, matchService.ID, matchService.Service_Type, AlertDate);
                            mt          = matchService.WelcomeMT;
                            msgType     = (int)Constant.MessageType.Charge;
                            returnValue = "1";
                        }
                        catch (Exception ex)
                        {
                            mt = "He thong dang ban. De duoc ho tro xin lien he 19001255. Cam on quy khach.";
                        }
                    }
                    else
                    {
                        //ngay hẹn phải lớn hơn hoặc bằng ngày hiện tại
                        mt = "Ngay hen tai kham phai sau ngay hien tai, vui long kiem tra lai. DTHT 19001255";
                    }
                }
                else
                {
                    //sai định dạng thời gian
                    mt = "Ban da nhan sai dinh dang ngay. DTHT 19001255";
                }
            }
            #endregion
        }
        catch (Exception ex)
        {
            log.Debug("--------------- Hospital Service mo ----------------------");
            log.Debug("Get Error : " + ex.Message + ", returnValue: " + returnValue);
            mt = "He thong dang ban. De duoc ho tro xin lien he 19001255. Cam on quy khach.";
        }
        //send MT to MT queue
        DBController.Send(User_ID, mt, "8779", Command_Code, msgType.ToString(), DateTime.Now.Ticks.ToString(), "1", "1", "0", ((int)Constant.ContentType.Text).ToString());

        return(returnValue);
    }
コード例 #7
0
        public string SynchronizeUser(string Shortcode, string RequestID, string Msisdn, string Commandcode, string Message, int ServiceID, int SyncType, string content, int chargedDay)
        {
            string retVal = "0|Unidentified";

            try
            {
                logger.Debug("Msisdn :" + Msisdn + "=ServiceID=" + ServiceID);
                if (ServiceID > 0)
                {
                    string id = SqlHelper.ExecuteScalar(ConnectionString, "Visport_GetByUserAndServiceId_Active", Msisdn, ServiceID).ToString();
                    List <Visport_Registered_Users> lstCheckFisrtRegis = Controller.Visport_CheckFirst_Regis(Msisdn, ServiceID);
                    int uId = ConvertUtility.ToInt32(id);

                    //  Add
                    if (SyncType == 1)
                    {
                        if (uId > 0)
                        {
                            retVal = "0|User already existed";
                        }
                        else
                        {
                            Service_Info service = Controller.Visport_Subscription_Services_GetByID(ServiceID);
                            if (service != null)
                            {
                                Visport_Registered_Users user = new Visport_Registered_Users();
                                user.User_ID        = Msisdn;
                                user.Request_ID     = RequestID;
                                user.Service_ID     = service.ID;
                                user.Short_Code     = Shortcode;
                                user.Command_Code   = Commandcode;
                                user.Reference_ID   = service.RefID;
                                user.Service_Type   = service.Service_Type;
                                user.Charging_Count = service.NoChargeLength;

                                user.PeriodLength   = service.PeriodLength;
                                user.NoChargeLength = service.NoChargeLength;

                                user.Status = 1;
                                user.RegistrationChannel = "wap";
                                user.CountTo_Cancel      = service.PeriodLength + chargedDay;
                                if (lstCheckFisrtRegis.Count > 0)
                                {
                                    int rtvalue = Controller.Visport_Registered_Users_Update_Tool(user);
                                }
                                else
                                {
                                    int rtvalue = Controller.Visport_Registered_Users_Insert_Tool(user);
                                }
                                //S2_Registered_Users_DB.Insert(user);
                                //S2_Registered_Users_DB.InsertImport(user, chargedDay);

                                #region INSERT INTO MT_LOG
                                Controller.SendMT(Msisdn, content, Shortcode, Commandcode, service.Service_Type, service.ID, MESSAGE_TYPE.Charge, RequestID, 1, 1, 0, CONTENT_TYPE.Text);

                                #endregion
                            }

                            retVal = "1";
                        }
                    }
                    else if (SyncType == 0) // Delete
                    {
                        if (uId > 0)
                        {
                            Controller.Visport_Deactivate_Users(uId, "");

                            retVal = "1";
                        }
                        else
                        {
                            retVal = "0|not exists";
                        }
                    }
                }
                else
                {
                    retVal = "0|not exists";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                retVal = "0|" + ex.Message;
            }

            return(retVal);
        }