public ContactInfoWrapper(ContactInfo contactInfo)
     : base(contactInfo.ID)
 {
     InfoType     = contactInfo.InfoType;
     Category     = contactInfo.Category;
     CategoryName = contactInfo.CategoryToString();
     Data         = contactInfo.Data;
     IsPrimary    = contactInfo.IsPrimary;
     ID           = contactInfo.ID;
 }
        public Address(ContactInfo contactInfo)
        {
            if (contactInfo.InfoType != ContactInfoType.Address)
            {
                throw new ArgumentException();
            }

            City         = JObject.Parse(contactInfo.Data)["city"].Value <String>();
            Country      = JObject.Parse(contactInfo.Data)["country"].Value <String>();
            State        = JObject.Parse(contactInfo.Data)["state"].Value <String>();
            Street       = JObject.Parse(contactInfo.Data)["street"].Value <String>();
            Zip          = JObject.Parse(contactInfo.Data)["zip"].Value <String>();
            Category     = contactInfo.Category;
            CategoryName = contactInfo.CategoryToString();
            IsPrimary    = contactInfo.IsPrimary;
        }
示例#3
0
        public Address(ContactInfo contactInfo)
        {
            if (contactInfo.InfoType != ContactInfoType.Address)
            {
                throw new ArgumentException();
            }

            var jsonElement = JsonDocument.Parse(contactInfo.Data).RootElement;

            City         = jsonElement.GetProperty("city").GetString();
            Country      = jsonElement.GetProperty("country").GetString();
            State        = jsonElement.GetProperty("state").GetString();
            Street       = jsonElement.GetProperty("street").GetString();
            Zip          = jsonElement.GetProperty("zip").GetString();
            Category     = contactInfo.Category;
            CategoryName = contactInfo.CategoryToString();
            IsPrimary    = contactInfo.IsPrimary;
        }
        public static bool TryParse(ContactInfo contactInfo, out Address res)
        {
            if (contactInfo.InfoType != ContactInfoType.Address)
            {
                res = null;
                return(false);
            }

            try
            {
                res              = Newtonsoft.Json.JsonConvert.DeserializeObject <Address>(contactInfo.Data);
                res.Category     = contactInfo.Category;
                res.CategoryName = contactInfo.CategoryToString();
                res.IsPrimary    = contactInfo.IsPrimary;
                return(true);
            }
            catch (Exception)
            {
                res = null;
                return(false);
            }
        }
示例#5
0
 public Address(ContactInfo contactInfo)
 {
     if (contactInfo.InfoType != ContactInfoType.Address)
     {
         throw new ArgumentException();
     }
     try
     {
         var jResult = JObject.Parse(contactInfo.Data);
         City         = jResult["city"].Value <String>();
         Country      = jResult["country"].Value <String>();
         State        = jResult["state"].Value <String>();
         Street       = jResult["street"].Value <String>();
         Zip          = jResult["zip"].Value <String>();
         Category     = contactInfo.Category;
         CategoryName = contactInfo.CategoryToString();
         IsPrimary    = contactInfo.IsPrimary;
     }
     catch (Exception ex)
     {
         LogManager.GetLogger("ASC.Api").Error(ex);
     }
 }
        protected String RenderContactInfo(ContactInfo contactInfo)
        {
            switch (contactInfo.InfoType)
            {
            case ContactInfoType.Email:
                return(String.Format("<a class='crm-email linkMedium' href='mailto:{0}'>{0}</a><span class='textMediumDescribe'> ({1})</span>", contactInfo.Data.HtmlEncode(), contactInfo.CategoryToString()));

            case ContactInfoType.Phone:
                return(String.Format("<div class='crm-phone'>{0}<span class='textMediumDescribe'> ({1})</span></div>", contactInfo.Data.HtmlEncode(), contactInfo.CategoryToString()));

            //case ContactInfoType.Website:
            //    return String.Format("<a class='crm-website' href='${0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.Skype:
            //    return String.Format("<div class='crm-skype'>{0}<span class='textSmallDescribe'> ({1})</span></div>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.Twitter:
            //    return String.Format("<a class='crm-twitter' href='http://twitter.com/{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.LinkedIn:
            //    return String.Format("<a class='crm-linkedin' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.Facebook:
            //    return String.Format("<a class='crm-facebook' href='http://facebook.com/{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.LiveJournal:
            //    return String.Format("<a class='rm-livejournal' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.MySpace:
            //    return String.Format("<a class='crm-myspace' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.GMail:
            //    return String.Format("<a class='crm-gmail' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.Blogger:
            //    return String.Format("<a class='crm-blogger' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.Yahoo:
            //    return String.Format("<a class='crm-yahoo' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.MSN:
            //    return String.Format("<a class='crm-msn' href='{0}' target='_blank'>${0}</a><span class='textSmallDescribe'> ({1})</span>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.ICQ:
            //    return String.Format("<div class='crm-icq'>{0}<span class='textSmallDescribe'> ({1})</span></div>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.Jabber:
            //    return String.Format("<div class='crm-jabber'>{0}<span class='textSmallDescribe'> ({1})</span></div>", contactInfo.Data, contactInfo.CategoryToString());
            //case ContactInfoType.AIM:
            //    return String.Format("<div class='crm-aim'>{0}<span class='textSmallDescribe'> ({1})</span></div>", contactInfo.Data, contactInfo.CategoryToString());
            case ContactInfoType.Address:
                var address = JObject.Parse(contactInfo.Data);

                var street  = address[AddressPart.Street.ToString().ToLower()].ToString().HtmlEncode();
                var city    = address[AddressPart.City.ToString().ToLower()].ToString().HtmlEncode();
                var state   = address[AddressPart.State.ToString().ToLower()].ToString().HtmlEncode();
                var country = address[AddressPart.Country.ToString().ToLower()].ToString().HtmlEncode();
                var zip     = address[AddressPart.Zip.ToString().ToLower()].ToString().HtmlEncode();

                var text = street;
                var tmp  = String.IsNullOrEmpty(city) ? "" : city + ", ";

                if (!String.IsNullOrEmpty(state))
                {
                    tmp += state + ", ";
                }
                if (!String.IsNullOrEmpty(zip))
                {
                    tmp += zip;
                }
                tmp = tmp.Trim().TrimEnd(',');
                if (!String.IsNullOrEmpty(tmp))
                {
                    text = !String.IsNullOrEmpty(text) ? text + ",<br/>" + tmp : tmp;
                }
                text = !String.IsNullOrEmpty(text) && !String.IsNullOrEmpty(country) ? text + ",<br/>" + country : text;

                var href = "";
                if (!String.IsNullOrEmpty(street))
                {
                    href += street + ", ";
                }
                if (!String.IsNullOrEmpty(city))
                {
                    href += city + ", ";
                }
                if (!String.IsNullOrEmpty(state))
                {
                    href += state + ", ";
                }
                if (!String.IsNullOrEmpty(zip))
                {
                    href += zip + ", ";
                }
                if (!String.IsNullOrEmpty(country))
                {
                    href += country + ", ";
                }
                href = href.Trim().TrimEnd(',');

                return(String.Format("<div class='crm-address'>{0}"
                                     + "<span class='textMediumDescribe'> ({2})</span><br/>"
                                     + "<a class='linkMedium' style='text-decoration: underline;' href='http://maps.google.com/maps?q={1}' target='_blank'>"
                                     + CRMContactResource.ShowOnMap + "</a>"
                                     + "</div>", text, href, contactInfo.CategoryToString()));

            default:
                return(contactInfo.Data);
            }
        }