Beispiel #1
0
        public static List <CallTrackingPhone> GetCallTrackingPhones(this SqlDataReader dataReader)
        {
            List <CallTrackingPhone> result = new List <CallTrackingPhone>();

            while (dataReader.Read())
            {
                CallTrackingPhone callTrackingPhone = new CallTrackingPhone()
                {
                    CommunityId      = dataReader.GetValue <long?>("CommunityId"),
                    ServiceId        = dataReader.GetValue <long?>("ServiceId"),
                    CommunityName    = dataReader.GetValue <string>("Name"),
                    MarchexAccountId = dataReader.GetValueOrDefault <string>("MARCHEX_AccountId"),
                    Id                      = dataReader.GetValue <long?>("PhoneId"),
                    PhoneType               = (CallTrackingPhoneType)dataReader.GetValue <int>("PhoneTypeId"),
                    Phone                   = DataReaderHelper.ClearPhone(dataReader.GetValue <string>("Phone")),
                    ListingPhone            = DataReaderHelper.ClearPhone(dataReader.GetValue <string>("ListingPhone")),
                    PhoneExtension          = dataReader.GetValue <string>("PhoneExtension"),
                    CampaignId              = dataReader.GetValue <string>("CampaignId"),
                    ProvisionPhone          = dataReader.GetValue <string>("ProvisionPhone"),
                    ProvisionPhoneExtension = dataReader.GetValue <string>("ProvisionPhoneExtension"),
                    StartDate               = dataReader.GetValue <DateTime?>("StartDate"),
                    EndDate                 = dataReader.GetValue <DateTime?>("ExpirationDate"),
                    DisconnectDate          = dataReader.GetValue <DateTime?>("DisconnectDate"),
                    ReconnectDate           = dataReader.GetValue <DateTime?>("ReconnectDate"),
                    IsClickToCall           = dataReader.GetValue <bool>("IsClickToCall"),
                    IsWhisper               = dataReader.GetValue <bool>("IsWhisper"),
                    IsCallReview            = dataReader.GetValue <bool>("IsCallReview"),
                    IsDisconnected          = dataReader.GetValue <bool>("IsDisconnected")
                };
                result.Add(callTrackingPhone);
            }
            return(result);
        }
Beispiel #2
0
        public static Tuple <List <Phone>, List <CallTrackingPhone> > GetPhones(this SqlDataReader reader)
        {
            List <Phone>             phones                       = new List <Phone>();
            List <CallTrackingPhone> callTrackingPhones           = new List <CallTrackingPhone>();
            Tuple <List <Phone>, List <CallTrackingPhone> > tuple = new Tuple <List <Phone>, List <CallTrackingPhone> >(phones, callTrackingPhones);

            while (reader.Read())
            {
                bool?isActive = reader.GetNullableValue <bool>("IsActive");
                if (!isActive.HasValue || !isActive.Value)
                {
                    continue;
                }
                string provisionPhone = reader["ProvisionPhone"].ToString();
                if (!string.IsNullOrEmpty(provisionPhone))
                {
                    CallTrackingPhone phone = new CallTrackingPhone()
                    {
                        Id             = new long?((long)reader["PhoneId"]),
                        CommunityId    = reader.GetNullableValue <long>("CommunityId"),
                        ServiceId      = reader.GetNullableValue <long>("ServiceId"),
                        PhoneType      = (CallTrackingPhoneType)((int)reader["PhoneTypeId"]),
                        Phone          = DataReaderHelper.ClearPhone(reader["Phone"].ToString()),
                        ListingPhone   = DataReaderHelper.ClearPhone(reader["ListingPhone"].ToString()),
                        ProvisionPhone = provisionPhone,
                        StartDate      = reader.GetNullableValue <DateTime>("StartDate"),
                        EndDate        = reader.GetNullableValue <DateTime>("ExpirationDate"),
                        IsClickToCall  = reader.GetNullableValue <bool>("IsClickToCall").FromNullable(),
                        IsWhisper      = reader.GetNullableValue <bool>("IsWhisper").FromNullable(),
                        IsCallReview   = reader.GetNullableValue <bool>("IsCallReview").FromNullable(),
                        IsDisconnected = reader.GetNullableValue <bool>("IsDisconnected").FromNullable(),
                        CampaignId     = reader["CampaignId"].ToString(),
                        DisconnectDate = reader.GetNullableValue <DateTime>("DisconnectDate"),
                        ReconnectDate  = reader.GetNullableValue <DateTime>("ReconnectDate")
                    };
                    callTrackingPhones.Add(phone);
                }
                else
                {
                    Phone item = new Phone()
                    {
                        Id          = new long?((long)reader["PhoneId"]),
                        CommunityId = reader.GetNullableValue <long>("CommunityId"),
                        ServiceId   = reader.GetNullableValue <long>("ServiceId"),
                        PhoneTypeId = new long?((long)((int)reader["PhoneTypeId"])),
                        Number      = reader["Phone"].ToString(),
                        Sequence    = (int)reader["Sequence"]
                    };
                    phones.Add(item);
                }
            }
            return(tuple);
        }
        internal static CallTrackingPhoneForGridVm MapToCallTrackingPhoneForGridVm(this CallTrackingPhone callTrackingPhone)
        {
            CallTrackingPhoneForGridVm callTrackingPhoneForGridVm = new CallTrackingPhoneForGridVm();
            long?communityId = callTrackingPhone.CommunityId;

            callTrackingPhoneForGridVm.CommunityId    = (communityId.HasValue ? communityId : callTrackingPhone.ServiceId);
            callTrackingPhoneForGridVm.CommunityName  = callTrackingPhone.CommunityName;
            callTrackingPhoneForGridVm.PhoneType      = callTrackingPhone.PhoneType.GetEnumLocalizedValue <CallTrackingPhoneType>();
            callTrackingPhoneForGridVm.Phone          = callTrackingPhone.Phone;
            callTrackingPhoneForGridVm.ProvisionPhone = callTrackingPhone.ProvisionPhone;
            callTrackingPhoneForGridVm.IsWhisper      = callTrackingPhone.IsWhisper;
            callTrackingPhoneForGridVm.IsCallReview   = callTrackingPhone.IsCallReview;
            callTrackingPhoneForGridVm.DisconnectDate = callTrackingPhone.DisconnectDate;
            callTrackingPhoneForGridVm.StartDate      = callTrackingPhone.StartDate;
            callTrackingPhoneForGridVm.EndDate        = callTrackingPhone.EndDate;
            return(callTrackingPhoneForGridVm);
        }
 internal static CallTrackingPhoneVm MapToCallTrackingPhoneVm(this CallTrackingPhone callTrackingPhone)
 {
     return(new CallTrackingPhoneVm()
     {
         Id = callTrackingPhone.Id,
         CampaignId = callTrackingPhone.CampaignId,
         PhoneType = new CallTrackingPhoneType?(callTrackingPhone.PhoneType),
         Phone = callTrackingPhone.Phone,
         ListingPhone = callTrackingPhone.ListingPhone,
         OldPhone = callTrackingPhone.Phone,
         ProvisionPhone = callTrackingPhone.ProvisionPhone,
         IsWhisper = callTrackingPhone.IsWhisper,
         IsCallReview = callTrackingPhone.IsCallReview,
         StartDate = callTrackingPhone.StartDate,
         EndDate = callTrackingPhone.EndDate,
         IsDisconnected = callTrackingPhone.IsDisconnected,
         DisconnectDate = callTrackingPhone.DisconnectDate,
         ReconnectDate = callTrackingPhone.ReconnectDate
     });
 }
Beispiel #5
0
        public CallTrackingPhone ToEntity()
        {
            DateTime?         reconnectDate;
            CallTrackingPhone callTrackingPhone = new CallTrackingPhone()
            {
                Id             = this.Id,
                CampaignId     = this.CampaignId,
                IsDisconnected = this.IsDisconnected,
                PhoneType      = (this.PhoneType.HasValue ? this.PhoneType.Value : CallTrackingPhoneType.ProvisionOnline),
                Phone          = this.Phone,
                ListingPhone   = this.ListingPhone,
                OldPhone       = this.OldPhone,
                ProvisionPhone = this.ProvisionPhone,
                IsWhisper      = this.IsWhisper,
                IsCallReview   = this.IsCallReview,
                IsChanged      = this.IsChanged,
                StartDate      = this.StartDate,
                EndDate        = this.EndDate
            };

            if (callTrackingPhone.IsDisconnected)
            {
                reconnectDate = null;
                callTrackingPhone.ReconnectDate = reconnectDate;
                CallTrackingPhone nullable = callTrackingPhone;
                reconnectDate           = this.DisconnectDate;
                nullable.DisconnectDate = new DateTime?((reconnectDate.HasValue ? reconnectDate.GetValueOrDefault() : DateTime.Now));
            }
            else
            {
                reconnectDate = null;
                callTrackingPhone.DisconnectDate = reconnectDate;
                CallTrackingPhone nullable1 = callTrackingPhone;
                reconnectDate           = this.ReconnectDate;
                nullable1.ReconnectDate = new DateTime?((reconnectDate.HasValue ? reconnectDate.GetValueOrDefault() : DateTime.Now));
            }
            return(callTrackingPhone);
        }
Beispiel #6
0
 public static string GetDisplayPhone(Community community)
 {
     if (community != null)
     {
         if (community.CallTrackingPhones != null)
         {
             CallTrackingPhone callTrackingPhone = community.CallTrackingPhones.FirstOrDefault <CallTrackingPhone>((CallTrackingPhone x) => {
                 if (x.PhoneType == CallTrackingPhoneType.ProvisionOnlineAndPrintAd && !x.IsDisconnected)
                 {
                     DateTime?startDate = x.StartDate;
                     DateTime now       = DateTime.Now;
                     if ((startDate.HasValue ? startDate.GetValueOrDefault() < now : false))
                     {
                         startDate = x.EndDate;
                         now       = DateTime.Now;
                         if (!startDate.HasValue)
                         {
                             return(false);
                         }
                         return(startDate.GetValueOrDefault() > now);
                     }
                 }
                 return(false);
             });
             if (callTrackingPhone != null)
             {
                 return(callTrackingPhone.ProvisionPhone);
             }
             callTrackingPhone = community.CallTrackingPhones.FirstOrDefault <CallTrackingPhone>((CallTrackingPhone x) => {
                 if (x.PhoneType == CallTrackingPhoneType.ProvisionOnline && !x.IsDisconnected)
                 {
                     DateTime?startDate = x.StartDate;
                     DateTime now       = DateTime.Now;
                     if ((startDate.HasValue ? startDate.GetValueOrDefault() < now : false))
                     {
                         startDate = x.EndDate;
                         now       = DateTime.Now;
                         if (!startDate.HasValue)
                         {
                             return(false);
                         }
                         return(startDate.GetValueOrDefault() > now);
                     }
                 }
                 return(false);
             });
             if (callTrackingPhone != null)
             {
                 return(callTrackingPhone.ProvisionPhone);
             }
             callTrackingPhone = community.CallTrackingPhones.FirstOrDefault <CallTrackingPhone>((CallTrackingPhone x) => {
                 if (x.PhoneType == CallTrackingPhoneType.ProvisionPrintAd && !x.IsDisconnected)
                 {
                     DateTime?startDate = x.StartDate;
                     DateTime now       = DateTime.Now;
                     if ((startDate.HasValue ? startDate.GetValueOrDefault() < now : false))
                     {
                         startDate = x.EndDate;
                         now       = DateTime.Now;
                         if (!startDate.HasValue)
                         {
                             return(false);
                         }
                         return(startDate.GetValueOrDefault() > now);
                     }
                 }
                 return(false);
             });
             if (callTrackingPhone != null)
             {
                 return(callTrackingPhone.ProvisionPhone);
             }
         }
         if (community.Phones != null)
         {
             Phone phone = community.Phones.FirstOrDefault <Phone>((Phone p) => {
                 long?phoneTypeId = p.PhoneTypeId;
                 long?communityListingPhoneTypeId = ConfigurationManager.Instance.CommunityListingPhoneTypeId;
                 return(phoneTypeId.GetValueOrDefault() == communityListingPhoneTypeId.GetValueOrDefault() & phoneTypeId.HasValue == communityListingPhoneTypeId.HasValue);
             });
             if (phone != null)
             {
                 return(phone.Number);
             }
             phone = community.Phones.FirstOrDefault <Phone>();
             if (phone != null)
             {
                 return(phone.Number);
             }
         }
     }
     return(string.Empty);
 }