Пример #1
0
        //public static int DoUpdrade()
        //{
        //    var dc = new ManagementContext();
        //    var coms = dc.Communications;
        //    foreach (var mem in coms)
        //    {
        //        if (mem.CommunicationType.CommunicationTypeId == 3)
        //        {
        //            mem.CommunicationTypeEnum = (byte)CommunicationTypeEnum.Website;
        //        }
        //        else
        //            mem.CommunicationTypeEnum = (byte)CommunicationTypeEnum.PhoneNumber;
        //        mem.ContactCard = mem.ContactCard;
        //        mem.CommunicationType = mem.CommunicationType;

        //    }
        //  int   c = dc.SaveChanges();
        //  return c;
        //}

        public static string GetCarrierEmailAddress(MobileServiceProvider provider)
        {
            switch (provider)
            {
                case MobileServiceProvider.Alltel:
                    return "@mms.alltelwireless.com";
                case MobileServiceProvider.ATT_MMS:
                    return "@mms.att.net";
                case MobileServiceProvider.ATT_SMS:
                case MobileServiceProvider.Straight_Talk_ATT:
                    return "@txt.att.net";
                case MobileServiceProvider.Bell_Canada:
                    return "@txt.bellmobility.ca";
                case MobileServiceProvider.Fido_Canada:
                    return "@sms.fido.ca";
                case MobileServiceProvider.MetroPCS:
                    return "@mymetropcs.com";
                case MobileServiceProvider.Nextel:
                    return "@messaging.nextel.com";
                case MobileServiceProvider.Qwest:
                    return "@qwestmp.com";

                //case MobileServiceProvider.Rogers_Canada:
                //    return "@mms.rogers.com";
                case MobileServiceProvider.Sprint_MMS:
                    return "@pm.sprint.com";
                case MobileServiceProvider.Sprint_SMS:
                    return "@messaging.sprintpcs.com";
                case MobileServiceProvider.T_Mobile:
                    return "@tmomail.net";
                case MobileServiceProvider.Verizon_MMS:
                    return "@vzwpix.com";
                case MobileServiceProvider.Verizon_SMS:
                case MobileServiceProvider.Straight_Talk_Verizon:
                    return "@vtext.com";
                case MobileServiceProvider.Virgin_Mobile_USA:
                    return "@vmpix.com";
                case MobileServiceProvider.Orange_UK:
                    return "@orange.net";
                case MobileServiceProvider.China_Mobile:
                    return "@139.com";
                case MobileServiceProvider.Cricket:
                    return "@mms.mycricket.com";
                case MobileServiceProvider.WIND:
                    return "@txt.windmobile.ca";
                case MobileServiceProvider.US_Cellular:
                    return "@mms.uscc.net";
                case MobileServiceProvider.Nextech:
                    return "@sms.ntwls.net";
                case MobileServiceProvider.Telus_MMS:
                    return "@mms.telusmobility.com";
                case MobileServiceProvider.Telus_SMS:
                    return "@msg.telus.com";
                default:
                    return String.Empty;
            }
        }
 public static bool UpdatePhoneNumberToCard(string phone, DataModels.ContactCard.ContactCard card, string verificationCode, MobileServiceProvider carrier = MobileServiceProvider.None, bool isVerified = false)
 {
     try
     {
         int phoneType = Convert.ToInt32(CommunicationTypeEnum.PhoneNumber);
         if (card.Communications.Where(x => x.IsDefault == true).Where(x => x.CommunicationTypeEnum == (byte)CommunicationTypeEnum.PhoneNumber).FirstOrDefault() == null)
         {
             Communication c = new Communication();
             c.IsDefault = true;
             UpdatePhoneNumberToCard(phone, c, verificationCode, carrier, isVerified);
             card.Communications.Add(c);
         }
         else
         {
             UpdatePhoneNumberToCard(phone, card.Communications.Where(x => x.IsDefault == true).Where(x => x.CommunicationTypeEnum == (byte)CommunicationTypeEnum.PhoneNumber).FirstOrDefault(), verificationCode, carrier, isVerified);
         }
         return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
        public static bool VerifiySMSCarrierCode(long number, MobileServiceProvider provider, string code, Guid memberId)
        {
            try
            {
                var mem = MemberCache.GetMemberDisplay(memberId);
                if (mem.SMSVerificationNum == code)
                {
                    string body = "You are now Verified to receive RDNation text messages.";


                    var emailData = new Dictionary<string, string> { { "body", body } };

                    EmailServer.EmailServer.SendEmail(ServerConfig.DEFAULT_EMAIL_MESSAGES, "RDNation", ServerConfig.TEXT_MESSAGE_EMAIL, mem.PhoneNumber, emailData, EmailServer.EmailServerLayoutsEnum.TextMessage, DataModels.EmailServer.Enums.EmailPriority.Important);

                    var dc = new ManagementContext();
                    var memDb = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();

                    ContactCard.ContactCardFactory.UpdatePhoneNumberToCard(mem.PhoneNumber, memDb.ContactCard, mem.SMSVerificationNum, mem.Carrier, true);
                    int c = dc.SaveChanges();

                    return true;
                }
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }
 public static bool UpdatePhoneNumberToCard(string phone, DataModels.ContactCard.Communication phoneNumber, string verificationCode, MobileServiceProvider carrier = MobileServiceProvider.None, bool isVerified = false)
 {
     try
     {
         ManagementContext dc = new ManagementContext();
         phoneNumber.Data = phone;
         if (!String.IsNullOrEmpty(verificationCode))
             phoneNumber.SMSVerificationCode = verificationCode;
         if (carrier != MobileServiceProvider.None)
             phoneNumber.CarrierType = (byte)carrier;
         if (isVerified)
             phoneNumber.IsCarrierVerified = isVerified;
         phoneNumber.CommunicationTypeEnum = (byte)CommunicationTypeEnum.PhoneNumber;
         return true;
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return false;
 }
        /// <summary>
        /// sends user text message to verify account
        /// </summary>
        /// <param name="number"></param>
        /// <param name="provider"></param>
        /// <param name="memberId"></param>
        /// <returns></returns>
        public static bool VerifiySMSCarrier(long number, MobileServiceProvider provider, Guid memberId)
        {
            try
            {
                var mem = MemberCache.GetMemberDisplay(memberId);
                if (String.IsNullOrEmpty(mem.SMSVerificationNum))
                {
                    Random rand = new Random();
                    mem.SMSVerificationNum = rand.Next(10000, 99999).ToString();
                }
                mem.PhoneNumber = number.ToString();
                mem.Carrier = provider;
                string body = "Your Code: " + mem.SMSVerificationNum + " (If sent to you in error, our apologies, please ignore.)";

                var emailData = new Dictionary<string, string> { { "body", body } };

                EmailServer.EmailServer.SendEmail(ServerConfig.DEFAULT_EMAIL_MESSAGES, "RDNation", ServerConfig.TEXT_MESSAGE_EMAIL, mem.PhoneNumber, emailData, EmailServer.EmailServerLayoutsEnum.TextMessage, DataModels.EmailServer.Enums.EmailPriority.Important);
                var dc = new ManagementContext();
                var memDb = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();

                ContactCard.ContactCardFactory.UpdatePhoneNumberToCard(mem.PhoneNumber, memDb.ContactCard, mem.SMSVerificationNum, mem.Carrier);
                int c = dc.SaveChanges();

                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }