예제 #1
0
 static void Main(string[] args)
 {
     try
     {
         //RouteTelcoProvider routeProvider = new RouteTelcoProvider();
         //var model= routeProvider.getRoute(1, false);
         Console.WriteLine("Run Test...");
         Console.WriteLine("Send...");
         //SMSProcess.ServiceVNet.smsapiClient client = new SMSProcess.ServiceVNet.smsapiClient();
         // long result = client.Sent(username, password, src, "84924841036", "From Feb 7, 2017, your account numbers will be changed to 2313111. Thank you for your trust and support for VietinBank");
         //  client.Close();
         //string result = ConnectSOUTHtelecom.SendSMSBrandName("84924841036", "So du tai khoan cua ban la 12.213.123 VND", "VietinBank");
         int result = ConnectVNTP.SendSMS("841297327617", "From Feb 7, 2017, your account numbers will be changed to 2313111. Thank you for your trust and support for VietinBank");
         Console.WriteLine("result: " + result);
     }
     catch (Exception ex)
     {
     }
     Console.ReadLine();
 }
예제 #2
0
        public string SendSMS(object obj, bool IsBackup, EncryptAndDecrypt ead, SubTelcoProvider stProvider, RouteTelcoProvider routeProvider)
        {
            try
            {
                QueueService model   = (QueueService)obj;
                string       content = model.Content;
                if (model.ProcessingCode.Equals(ConfigType.QueueService_ProcessingCode_OTP))
                {
                    content = ead.Decrypt(content);
                }
                var modeltelco = stProvider.getSubTelcoByDest(model.Receiver);
                if (modeltelco == null)
                {
                    return(503 + ":NONE_TELCO");
                }
                else
                {
                    // CHECK TELCO
                    Telco telco = modeltelco.Telco;

                    // GET ROUTE
                    int    route      = routeProvider.getRoute(telco.Id, IsBackup);
                    int    result     = 0;
                    string code_Route = "";
                    if (route == ConfigType.ROUTE_VNET)
                    {
                        result = ConnectVNet.SendSMS(validatePhone(model.Receiver), content);
                        if (result == 0)
                        {
                            code_Route = "VNET";
                            //string log = string.Format("SendSMS: {0} -> {1} | {2}", model.Receiver, model.Content, code_Route);
                            //logger.Info(log + " - " + model.ProcessingCode);
                            return(result + ":" + code_Route);
                        }
                        else if (!IsBackup)
                        {
                            return(SendSMS(obj, true, ead, stProvider, routeProvider));
                        }
                        else
                        {
                            return(501 + ":" + code_Route);
                        }
                    }
                    else if (route == ConfigType.ROUTE_VNTP)
                    {
                        result = ConnectVNTP.SendSMS(validatePhone(model.Receiver), content);
                        if (result == 0)
                        {
                            code_Route = "VNTP";
                            return(result + ":" + code_Route);
                        }
                        else if (!IsBackup)
                        {
                            return(SendSMS(obj, true, ead, stProvider, routeProvider));
                        }
                        else
                        {
                            return(501 + ":" + code_Route);
                        }
                    }
                    else if (route == ConfigType.ROUTE_SOUTHtelecom)
                    {
                        string str_result = ConnectSOUTHtelecom.SendSMSBrandName(validatePhone(model.Receiver), content, "VietinBank");

                        if (result == 0)
                        {
                            code_Route = "SOUTHtelecom";
                            return(result + ":" + code_Route);
                        }
                        else if (!IsBackup)
                        {
                            return(SendSMS(obj, true, ead, stProvider, routeProvider));
                        }
                        else
                        {
                            return(501 + ":" + code_Route);
                        }
                    }
                    else
                    {
                        code_Route = "NONE_ROUTE";
                        //string log = string.Format("SendSMS: {0} -> {1} | {2}", model.Receiver, model.Content, code_Route);
                        //logger.Info(log + " - " + model.ProcessingCode);
                        return(502 + ":" + code_Route);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(555 + ":SendSMS_EX_ERROR");
            }
        }