public ContactInfoWrapper UpdateContactInfo(int id, int contactid, ContactInfoType?infoType, string data, bool?isPrimary, string category) { if (id <= 0 || string.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contact = DaoFactory.ContactDao.GetByID(contactid); if (contact == null || !CRMSecurity.CanEdit(contact)) { throw new ItemNotFoundException(); } var contactInfo = DaoFactory.ContactInfoDao.GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!string.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) { contactInfo.Category = (int)Enum.Parse(categoryType, category); } contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) { contactInfo.IsPrimary = isPrimary.Value; } contactInfo.Data = data; if (contactInfo.InfoType == ContactInfoType.Address) { Address res; if (!Address.TryParse(contactInfo, out res)) { throw new ArgumentException(); } } DaoFactory.ContactInfoDao.Update(contactInfo); var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(Request, messageAction, MessageTarget.Create(contact.ID), contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return(contactInfoWrapper); }
public ContactInfoWrapper UpdateContactInfo(int id, int contactid, ContactInfoType?infoType, string data, bool?isPrimary, string category) { if (id <= 0 || string.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contact = DaoFactory.GetContactDao().GetByID(contactid); if (contact == null || !CRMSecurity.CanEdit(contact)) { throw new ItemNotFoundException(); } var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!string.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) { contactInfo.Category = (int)Enum.Parse(categoryType, category); } contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) { contactInfo.IsPrimary = isPrimary.Value; } contactInfo.Data = data; DaoFactory.GetContactInfoDao().Update(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(_context, messageAction, contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return(contactInfoWrapper); }
public ContactInfoWrapper UpdateContactInfo( int id, int contactid, ContactInfoType?infoType, String data, bool?isPrimary, String category) { if (id == 0 || String.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!String.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) { contactInfo.Category = (int)Enum.ToObject(categoryType, category); } contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) { contactInfo.IsPrimary = isPrimary.Value; } contactInfo.Data = data; DaoFactory.GetContactInfoDao().Update(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var contact = DaoFactory.GetContactDao().GetByID(contactInfo.ContactID); var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return(contactInfoWrapper); }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, String data, bool isPrimary, String category ) { if (String.IsNullOrEmpty(data) || contactid == 0) { throw new ArgumentException(); } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); if (contactInfo.InfoType == ContactInfoType.Email) { var contact = DaoFactory.GetContactDao().GetByID(contactInfo.ContactID); var userIds = CRMSecurity.GetAccessSubjectTo(contact).Keys.ToList(); var emails = new[] { contactInfo.Data }; DaoFactory.GetContactInfoDao().UpdateMailAggregator(emails, userIds); } var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
public ContactInfoWrapper UpdateContactInfo( int id, int contactid, ContactInfoType?infoType, String data, bool?isPrimary, String category) { if (id == 0 || String.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contactInfo = DaoFactory.GetContactInfoDao().GetByID(id); if (infoType != null) { var categoryType = ContactInfo.GetCategory(infoType.Value); if (!String.IsNullOrEmpty(category) && Enum.IsDefined(categoryType, category)) { contactInfo.Category = (int)Enum.ToObject(categoryType, category); } contactInfo.InfoType = infoType.Value; } contactInfo.ContactID = contactid; if (isPrimary != null) { contactInfo.IsPrimary = isPrimary.Value; } contactInfo.Data = data; DaoFactory.GetContactInfoDao().Update(contactInfo); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); return(contactInfoWrapper); }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, String data, bool isPrimary, String category ) { if (String.IsNullOrEmpty(data) || contactid == 0) { throw new ArgumentException(); } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; var contactInfoID = DaoFactory.GetContactInfoDao().Save(contactInfo); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
private String ExportContactsToCSV(IEnumerable <Contact> contacts, StringDictionary contactInfos) { var listItemDao = _daoFactory.GetListItemDao(); var tagDao = _daoFactory.GetTagDao(); var customFieldDao = _daoFactory.GetCustomFieldDao(); var contactDao = _daoFactory.GetContactDao(); var dataTable = new DataTable(); dataTable.Columns.AddRange(new[] { new DataColumn { Caption = CRMCommonResource.TypeCompanyOrPerson, ColumnName = "company/person" }, new DataColumn { Caption = CRMContactResource.FirstName, ColumnName = "firstname" }, new DataColumn { Caption = CRMContactResource.LastName, ColumnName = "lastname" }, new DataColumn { Caption = CRMContactResource.CompanyName, ColumnName = "companyname" }, new DataColumn { Caption = CRMContactResource.JobTitle, ColumnName = "jobtitle" }, new DataColumn { Caption = CRMContactResource.About, ColumnName = "about" }, new DataColumn { Caption = CRMContactResource.ContactStage, ColumnName = "contact_stage" }, new DataColumn { Caption = CRMContactResource.ContactType, ColumnName = "contact_type" }, new DataColumn { Caption = CRMContactResource.ContactTagList, ColumnName = "contact_tag_list" } }); foreach (ContactInfoType infoTypeEnum in Enum.GetValues(typeof(ContactInfoType))) { foreach (Enum categoryEnum in Enum.GetValues(ContactInfo.GetCategory(infoTypeEnum))) { var localTitle = String.Format("{1} ({0})", categoryEnum.ToLocalizedString().ToLower(), infoTypeEnum.ToLocalizedString()); if (infoTypeEnum == ContactInfoType.Address) { dataTable.Columns.AddRange((from AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart)) select new DataColumn { Caption = String.Format(localTitle + " {0}", addressPartEnum.ToLocalizedString().ToLower()), ColumnName = String.Format("contactInfo_{0}_{1}_{2}", (int)infoTypeEnum, categoryEnum, (int)addressPartEnum) }).ToArray()); } else { dataTable.Columns.Add(new DataColumn { Caption = localTitle, ColumnName = String.Format("contactInfo_{0}_{1}", (int)infoTypeEnum, categoryEnum) }); } } } var fieldsDescription = customFieldDao.GetFieldsDescription(EntityType.Company); customFieldDao.GetFieldsDescription(EntityType.Person).ForEach(item => { var alreadyContains = fieldsDescription.Any(field => field.ID == item.ID); if (!alreadyContains) { fieldsDescription.Add(item); } }); fieldsDescription.ForEach( item => { if (item.FieldType == CustomFieldType.Heading) { return; } dataTable.Columns.Add( new DataColumn { Caption = item.Label, ColumnName = "customField_" + item.ID } ); }); var customFieldEntity = new Dictionary <int, List <CustomField> >(); var entityFields = customFieldDao.GetEnityFields(EntityType.Company, 0, false); customFieldDao.GetEnityFields(EntityType.Person, 0, false).ForEach(item => { var alreadyContains = entityFields.Any(field => field.ID == item.ID && field.EntityID == item.EntityID); if (!alreadyContains) { entityFields.Add(item); } }); entityFields.ForEach( item => { if (!customFieldEntity.ContainsKey(item.EntityID)) { customFieldEntity.Add(item.EntityID, new List <CustomField> { item }); } else { customFieldEntity[item.EntityID].Add(item); } }); var tags = tagDao.GetEntitiesTags(EntityType.Contact); foreach (var contact in contacts) { Percentage += 1.0 * 100 / _totalCount; var isCompany = contact is Company; var compPersType = (isCompany) ? CRMContactResource.Company : CRMContactResource.Person; var contactTags = String.Empty; if (tags.ContainsKey(contact.ID)) { contactTags = String.Join(",", tags[contact.ID].ToArray()); } String firstName; String lastName; String companyName; String title; if (contact is Company) { firstName = String.Empty; lastName = String.Empty; title = String.Empty; companyName = ((Company)contact).CompanyName; } else { var people = (Person)contact; firstName = people.FirstName; lastName = people.LastName; title = people.JobTitle; companyName = String.Empty; if (people.CompanyID > 0) { var personCompany = contacts.SingleOrDefault(item => item.ID == people.CompanyID); if (personCompany == null) { personCompany = contactDao.GetByID(people.CompanyID); } if (personCompany != null) { companyName = personCompany.GetTitle(); } } } var contactStatus = String.Empty; if (contact.StatusID > 0) { var listItem = listItemDao.GetByID(contact.StatusID); if (listItem != null) { contactStatus = listItem.Title; } } var contactType = String.Empty; if (contact.ContactTypeID > 0) { var listItem = listItemDao.GetByID(contact.ContactTypeID); if (listItem != null) { contactType = listItem.Title; } } var dataRowItems = new List <String> { compPersType, firstName, lastName, companyName, title, contact.About, contactStatus, contactType, contactTags }; foreach (ContactInfoType infoTypeEnum in Enum.GetValues(typeof(ContactInfoType))) { foreach (Enum categoryEnum in Enum.GetValues(ContactInfo.GetCategory(infoTypeEnum))) { var contactInfoKey = String.Format("{0}_{1}_{2}", contact.ID, (int)infoTypeEnum, Convert.ToInt32(categoryEnum)); var columnValue = ""; if (contactInfos.ContainsKey(contactInfoKey)) { columnValue = contactInfos[contactInfoKey]; } if (infoTypeEnum == ContactInfoType.Address) { if (!String.IsNullOrEmpty(columnValue)) { var addresses = JArray.Parse(String.Concat("[", columnValue, "]")); dataRowItems.AddRange((from AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart)) select String.Join(",", addresses.Select(item => (String)item.SelectToken(addressPartEnum.ToString().ToLower())).ToArray())).ToArray()); } else { dataRowItems.AddRange(new[] { "", "", "", "", "" }); } } else { dataRowItems.Add(columnValue); } } } var dataRow = dataTable.Rows.Add(dataRowItems.ToArray()); if (customFieldEntity.ContainsKey(contact.ID)) { customFieldEntity[contact.ID].ForEach(item => dataRow["customField_" + item.ID] = item.Value); } } return(DataTableToCSV(dataTable)); }
protected void InitForContacts() { StartImportLabel = CRMContactResource.StartImport; ImportFromCSVStepOneHeaderLabel = CRMContactResource.ImportFromCSVStepOneHeader; ImportFromCSVStepTwoHeaderLabel = CRMContactResource.ImportFromCSVStepTwoHeader; ImportFromCSVStepOneDescriptionLabel = CRMContactResource.ImportFromCSVStepOneDescription; ImportFromCSVStepTwoDescriptionLabel = CRMContactResource.ImportFromCSVStepTwoDescription; ImportStartingPanelHeaderLabel = CRMContactResource.ImportStartingPanelHeader; ImportStartingPanelDescriptionLabel = CRMContactResource.ImportStartingPanelDescription; ImportStartingPanelButtonLabel = CRMContactResource.ImportStartingPanelButton; ImportImgSrc = WebImageSupplier.GetAbsoluteWebPath("import_contacts.png", ProductEntryPoint.ID); var columnSelectorData = new[] { new { name = String.Empty, title = CRMContactResource.NoMatchSelect, isHeader = false }, new { name = "-1", title = CRMContactResource.DoNotImportThisField, isHeader = false }, new { name = String.Empty, title = CRMContactResource.GeneralInformation, isHeader = true }, new { name = "firstName", title = CRMContactResource.FirstName, isHeader = false }, new { name = "lastName", title = CRMContactResource.LastName, isHeader = false }, new { name = "title", title = CRMContactResource.JobTitle, isHeader = false }, new { name = "companyName", title = CRMContactResource.CompanyName, isHeader = false }, new { name = "contactStage", title = CRMContactResource.ContactStage, isHeader = false }, new { name = "contactType", title = CRMContactResource.ContactType, isHeader = false }, new { name = "notes", title = CRMContactResource.About, isHeader = false } }.ToList(); foreach (ContactInfoType infoTypeEnum in Enum.GetValues(typeof(ContactInfoType))) { foreach (Enum categoryEnum in Enum.GetValues(ContactInfo.GetCategory(infoTypeEnum))) { var localName = String.Format("contactInfo_{0}_{1}", infoTypeEnum, Convert.ToInt32(categoryEnum)); var localTitle = String.Format("{1} ({0})", categoryEnum.ToLocalizedString().ToLower(), infoTypeEnum.ToLocalizedString()); if (infoTypeEnum == ContactInfoType.Address) { foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) { columnSelectorData.Add(new { name = String.Format(localName + "_{0}", addressPartEnum), title = String.Format(localTitle + " {0}", addressPartEnum.ToLocalizedString().ToLower()), isHeader = false }); } } else { columnSelectorData.Add(new { name = localName, title = localTitle, isHeader = false }); } } } var fieldsDescription = Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Company); Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Person).ForEach(item => { var alreadyContains = fieldsDescription.Any(field => field.ID == item.ID); if (!alreadyContains) { fieldsDescription.Add(item); } }); columnSelectorData.AddRange(fieldsDescription.FindAll(customField => customField.FieldType == CustomFieldType.TextField || customField.FieldType == CustomFieldType.TextArea || customField.FieldType == CustomFieldType.Heading) .ConvertAll(customField => new { name = "customField_" + customField.ID, title = customField.Label.HtmlEncode(), isHeader = customField.FieldType == CustomFieldType.Heading })); columnSelectorData.AddRange( new[] { new { name = String.Empty, title = CRMContactResource.ContactTags, isHeader = true }, new { name = "tag", title = CRMContactResource.ContactTagList, isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 1), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 2), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 3), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 4), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 5), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 6), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 7), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 8), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 9), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 10), isHeader = false }, }.ToList() ); Page.RegisterInlineScript(String.Format(" var columnSelectorData = {0}; ", JavaScriptSerializer.Serialize(columnSelectorData)), onReady: false); RegisterClientScriptHelper.DataUserSelectorListView(Page, "_ImportContactsManager", null, null, true); }
public void ProcessRequest(HttpContext context) { try { _context = context; SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); if (!CheckPermission()) { throw new Exception(CRMSettingResource.WebToLeadsForm_InvalidKeyException); } var productInfo = WebItemSecurity.GetSecurityInfo(ProductEntryPoint.ID.ToString()); if (!productInfo.Enabled) { throw new Exception(CRMCommonResource.CRMProductIsDisabled); } Contact contact; var fieldCollector = new NameValueCollection(); var addressTemplate = new JObject(); foreach (String addressPartName in Enum.GetNames(typeof(AddressPart))) { addressTemplate.Add(addressPartName.ToLower(), ""); } var addressTemplateStr = addressTemplate.ToString(); var isCompany = false; var isCompanyString = GetValue("is_company"); var firstName = GetValue("firstName"); var lastName = GetValue("lastName"); var companyName = GetValue("companyName"); if (!String.IsNullOrEmpty(isCompanyString)) { if (!Boolean.TryParse(isCompanyString, out isCompany)) { throw new ArgumentException(); } } else //old scheme { if (!(String.IsNullOrEmpty(firstName) || String.IsNullOrEmpty(lastName))) { isCompany = false; } else if (!String.IsNullOrEmpty(companyName)) { isCompany = true; } else { throw new ArgumentException(); } } if (isCompany) { contact = new Company(); ((Company)contact).CompanyName = companyName; fieldCollector.Add(CRMContactResource.CompanyName, companyName); } else { contact = new Person(); ((Person)contact).FirstName = firstName; ((Person)contact).LastName = lastName; ((Person)contact).JobTitle = GetValue("jobTitle"); fieldCollector.Add(CRMContactResource.FirstName, firstName); fieldCollector.Add(CRMContactResource.LastName, lastName); if (!String.IsNullOrEmpty(GetValue("jobTitle"))) { fieldCollector.Add(CRMContactResource.JobTitle, ((Person)contact).JobTitle); } } contact.About = GetValue("about"); if (!String.IsNullOrEmpty(contact.About)) { fieldCollector.Add(CRMContactResource.About, contact.About); } if (!String.IsNullOrEmpty(GetValue("is_shared"))) { contact.ShareType = Convert.ToBoolean(GetValue("is_shared")) ? ShareType.ReadWrite : ShareType.None; } else { contact.ShareType = (ShareType)(Convert.ToInt32(GetValue("share_type"))); } contact.ID = Global.DaoFactory.GetContactDao().SaveContact(contact); var messageAction = contact is Company ? MessageAction.CompanyCreatedWithWebForm : MessageAction.PersonCreatedWithWebForm; MessageService.Send(HttpContext.Current.Request, MessageInitiator.System, messageAction, contact.GetTitle()); var contactInfos = new List <ContactInfo>(); foreach (var key in _context.Request.Form.AllKeys) { if (key.StartsWith("customField_")) { var fieldID = Convert.ToInt32(key.Split(new[] { '_' })[1]); String fieldValue = GetValue(key); if (String.IsNullOrEmpty(fieldValue)) { continue; } var customField = Global.DaoFactory.GetCustomFieldDao().GetFieldDescription(fieldID); if (customField == null || !(customField.EntityType == EntityType.Contact || customField.EntityType == EntityType.Company && isCompany || customField.EntityType == EntityType.Person && !isCompany)) { continue; } if (customField.FieldType == CustomFieldType.CheckBox) { fieldValue = fieldValue == "on" || fieldValue == "true" ? "true" : "false"; } fieldCollector.Add(customField.Label, fieldValue); Global.DaoFactory.GetCustomFieldDao().SetFieldValue(isCompany ? EntityType.Company : EntityType.Person, contact.ID, fieldID, fieldValue); } else if (key.StartsWith("contactInfo_")) { var nameParts = key.Split(new[] { '_' }).Skip(1).ToList(); var contactInfoType = (ContactInfoType)Enum.Parse(typeof(ContactInfoType), nameParts[0]); var category = Convert.ToInt32(nameParts[1]); bool categoryIsExists = Enum.GetValues(ContactInfo.GetCategory(contactInfoType)).Cast <object>() .Any(categoryEnum => (int)categoryEnum == category); if (!categoryIsExists) { throw new ArgumentException(String.Format("Category for {0} not found", nameParts[0])); } if (contactInfoType == ContactInfoType.Address) { var addressPart = (AddressPart)Enum.Parse(typeof(AddressPart), nameParts[2]); var findedAddress = contactInfos.Find(item => (category == item.Category) && (item.InfoType == ContactInfoType.Address)); if (findedAddress == null) { findedAddress = new ContactInfo { Category = category, InfoType = contactInfoType, Data = addressTemplateStr, ContactID = contact.ID }; contactInfos.Add(findedAddress); } var addressParts = JObject.Parse(findedAddress.Data); addressParts[addressPart.ToString().ToLower()] = GetValue(key); findedAddress.Data = addressParts.ToString(); continue; } var fieldValue = GetValue(key); if (String.IsNullOrEmpty(fieldValue)) { continue; } contactInfos.Add(new ContactInfo { Category = category, InfoType = contactInfoType, Data = fieldValue, ContactID = contact.ID, IsPrimary = true }); } else if (String.Compare(key, "tag", true) == 0) { var tags = _context.Request.Form.GetValues("tag"); Global.DaoFactory.GetTagDao().SetTagToEntity(EntityType.Contact, contact.ID, tags); } } contactInfos.ForEach(item => fieldCollector[item.InfoType.ToLocalizedString()] = PrepareteDataToView(item.InfoType, item.Data)); Global.DaoFactory.GetContactInfoDao().SaveList(contactInfos); var notifyList = GetValue("notify_list"); if (!String.IsNullOrEmpty(notifyList)) { NotifyClient.Instance.SendAboutCreateNewContact( notifyList .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(item => new Guid(item)).ToList(), contact.ID, contact.GetTitle(), fieldCollector); } var managersList = GetValue("managers_list"); SetPermission(contact, managersList); if (contact is Person && !String.IsNullOrEmpty(companyName)) { AssignPersonToCompany((Person)contact, companyName, managersList); } if (contact is Company && !String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName)) { AssignCompanyToPerson((Company)contact, firstName, lastName, managersList); } SecurityContext.Logout(); var newURL = new UriBuilder(GetValue("return_url")).Uri.AbsoluteUri; context.Response.Buffer = true; context.Response.Status = "302 Object moved"; context.Response.AddHeader("Location", newURL); context.Response.Write("<HTML><Head>"); context.Response.Write(String.Format("<META HTTP-EQUIV=Refresh CONTENT=\"0;URL={0}\">", newURL)); context.Response.Write(String.Format("<Script>window.location='{0}';</Script>", newURL)); context.Response.Write("</Head>"); context.Response.Write("</HTML>"); } catch (Exception error) { LogManager.GetLogger("ASC.CRM").Error(error); context.Response.StatusCode = 400; context.Response.Write(HttpUtility.HtmlEncode(error.Message)); } }
public IEnumerable <String> GetContactInfoCategory(ContactInfoType infoType) { return(Enum.GetNames(ContactInfo.GetCategory(infoType)).ToItemList()); }
public ContactInfoWrapper CreateContactInfo(int contactid, ContactInfoType infoType, string data, bool isPrimary, string category) { if (string.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contact = DaoFactory.ContactDao.GetByID(contactid); if (contact == null) { throw new ItemNotFoundException(); } if (infoType == ContactInfoType.Twitter) { if (!CRMSecurity.CanAccessTo(contact)) { throw new ItemNotFoundException(); } } else { if (!CRMSecurity.CanEdit(contact)) { throw new ItemNotFoundException(); } } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; if (contactInfo.InfoType == ContactInfoType.Address) { Address res; if (!Address.TryParse(contactInfo, out res)) { throw new ArgumentException(); } } var contactInfoID = DaoFactory.ContactInfoDao.Save(contactInfo); var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; MessageService.Send(Request, messageAction, MessageTarget.Create(contact.ID), contact.GetTitle()); var contactInfoWrapper = ToContactInfoWrapper(contactInfo); contactInfoWrapper.ID = contactInfoID; return(contactInfoWrapper); }
protected void InitForContacts() { StartImportLabel = CRMContactResource.StartImport; ImportFromCSVStepOneHeaderLabel = CRMContactResource.ImportFromCSVStepOneHeader; ImportFromCSVStepTwoHeaderLabel = CRMContactResource.ImportFromCSVStepTwoHeader; ImportFromCSVStepOneDescriptionLabel = CRMContactResource.ImportFromCSVStepOneDescription; ImportFromCSVStepTwoDescriptionLabel = CRMContactResource.ImportFromCSVStepTwoDescription; ImportStartingPanelHeaderLabel = CRMContactResource.ImportStartingPanelHeader; ImportStartingPanelDescriptionLabel = CRMContactResource.ImportStartingPanelDescription; ImportStartingPanelButtonLabel = CRMContactResource.ImportStartingPanelButton; ImportImgSrc = WebImageSupplier.GetAbsoluteWebPath("import_contacts.png", ProductEntryPoint.ID); var columnSelectorData = new[] { new { name = String.Empty, title = CRMContactResource.NoMatchSelect, isHeader = false }, new { name = "-1", title = CRMContactResource.DoNotImportThisField, isHeader = false }, new { name = String.Empty, title = CRMContactResource.GeneralInformation, isHeader = true }, new { name = "firstName", title = CRMContactResource.FirstName, isHeader = false }, new { name = "lastName", title = CRMContactResource.LastName, isHeader = false }, new { name = "title", title = CRMContactResource.JobTitle, isHeader = false }, new { name = "companyName", title = CRMContactResource.CompanyName, isHeader = false }, new { name = "notes", title = CRMContactResource.About, isHeader = false } }.ToList(); foreach (ContactInfoType infoTypeEnum in Enum.GetValues(typeof(ContactInfoType))) { foreach (Enum categoryEnum in Enum.GetValues(ContactInfo.GetCategory(infoTypeEnum))) { var localName = String.Format("contactInfo_{0}_{1}", infoTypeEnum, Convert.ToInt32(categoryEnum)); var localTitle = String.Format("{1} ({0})", categoryEnum.ToLocalizedString().ToLower(), infoTypeEnum.ToLocalizedString()); if (infoTypeEnum == ContactInfoType.Address) { foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) { columnSelectorData.Add(new { name = String.Format(localName + "_{0}", addressPartEnum), title = String.Format(localTitle + " {0}", addressPartEnum.ToLocalizedString().ToLower()), isHeader = false }); } } else { columnSelectorData.Add(new { name = localName, title = localTitle, isHeader = false }); } } } columnSelectorData.AddRange(Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Contact).FindAll(customField => customField.FieldType == CustomFieldType.TextField || customField.FieldType == CustomFieldType.TextArea || customField.FieldType == CustomFieldType.Heading) .ConvertAll(customField => new { name = "customField_" + customField.ID, title = customField.Label.HtmlEncode(), isHeader = customField.FieldType == CustomFieldType.Heading })); columnSelectorData.AddRange( new[] { new { name = String.Empty, title = CRMContactResource.ContactTags, isHeader = true }, new { name = "tag", title = CRMContactResource.ContactTagList, isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 1), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 2), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 3), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 4), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 5), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 6), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 7), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 8), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 9), isHeader = false }, new { name = "tag", title = String.Format("{0} {1}", CRMContactResource.ContactTag, 10), isHeader = false }, }.ToList() ); Page.ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), String.Format(" var {0} = {1}; ", "columnSelectorData", JavaScriptSerializer.Serialize(columnSelectorData)), true); var privatePanel = (PrivatePanel)Page.LoadControl(PrivatePanel.Location); privatePanel.CheckBoxLabel = CRMContactResource.PrivatePanelCheckBoxLabelForContact; privatePanel.IsPrivateItem = false; var usersWhoHasAccess = new List <string> { CustomNamingPeople.Substitute <CRMCommonResource>("CurrentUser") }; privatePanel.UsersWhoHasAccess = usersWhoHasAccess; privatePanel.DisabledUsers = new List <Guid> { SecurityContext.CurrentAccount.ID }; privatePanel.HideNotifyPanel = true; _phPrivatePanel.Controls.Add(privatePanel); }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { using (var scope = DIHelper.Resolve()) { var daoFactory = scope.Resolve <DaoFactory>(); var columnSelectorData = new List <object>(10) { CsdConverter(string.Empty, CRMContactResource.NoMatchSelect), CsdConverter("-1", CRMContactResource.DoNotImportThisField), CsdDefaultConverter(string.Empty, CRMContactResource.GeneralInformation, true), CsdConverter("firstName", CRMContactResource.FirstName), CsdConverter("lastName", CRMContactResource.LastName), CsdConverter("title", CRMContactResource.JobTitle), CsdConverter("companyName", CRMContactResource.CompanyName), CsdConverter("contactStage", CRMContactResource.ContactStage), CsdConverter("contactType", CRMContactResource.ContactType), CsdConverter("notes", CRMContactResource.About) }; foreach (ContactInfoType infoTypeEnum in Enum.GetValues(typeof(ContactInfoType))) { foreach (Enum categoryEnum in Enum.GetValues(ContactInfo.GetCategory(infoTypeEnum))) { var localName = string.Format("contactInfo_{0}_{1}", infoTypeEnum, Convert.ToInt32(categoryEnum)); var localTitle = string.Format("{1} ({0})", categoryEnum.ToLocalizedString().ToLower(), infoTypeEnum.ToLocalizedString()); if (infoTypeEnum == ContactInfoType.Address) { foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) { var name = string.Format(localName + "_{0}", addressPartEnum); var title = string.Format(localTitle + " {0}", addressPartEnum.ToLocalizedString().ToLower()); columnSelectorData.Add(CsdConverter(name, title)); } } else { columnSelectorData.Add(CsdConverter(localName, localTitle)); } } } var fieldsDescription = daoFactory.CustomFieldDao.GetFieldsDescription(EntityType.Company); daoFactory.CustomFieldDao.GetFieldsDescription(EntityType.Person).ForEach(item => { var alreadyContains = fieldsDescription.Any(field => field.ID == item.ID); if (!alreadyContains) { fieldsDescription.Add(item); } }); columnSelectorData.AddRange(fieldsDescription.ConvertAll(CfConverter)); columnSelectorData.AddRange(GetList("tag", CRMContactResource.ContactTags, CRMContactResource.ContactTagList, CRMContactResource.ContactTag)); var tagList = daoFactory.TagDao.GetAllTags(EntityType.Contact).ToList(); return(new List <KeyValuePair <string, object> >(1) { RegisterObject( new { tagList, columnSelectorData }) }); } }
public IEnumerable <string> GetContactInfoCategory(ContactInfoType infoType) { return(Enum.GetNames(ContactInfo.GetCategory(infoType))); }
public ContactInfoDto CreateContactInfo( [FromRoute] int contactid, [FromBody] CreateContactInfoRequestDto inDto) { var data = inDto.Data; var infoType = inDto.InfoType; var category = inDto.Category; var isPrimary = inDto.IsPrimary; if (string.IsNullOrEmpty(data) || contactid <= 0) { throw new ArgumentException(); } var contact = _daoFactory.GetContactDao().GetByID(contactid); if (contact == null) { throw new ItemNotFoundException(); } if (infoType == ContactInfoType.Twitter) { if (!_crmSecurity.CanAccessTo(contact)) { throw new ItemNotFoundException(); } } else { if (!_crmSecurity.CanEdit(contact)) { throw new ItemNotFoundException(); } } var categoryType = ContactInfo.GetCategory(infoType); if (!Enum.IsDefined(categoryType, category)) { throw new ArgumentException(); } var contactInfo = new ContactInfo { Data = data, InfoType = infoType, ContactID = contactid, IsPrimary = isPrimary, Category = (int)Enum.Parse(categoryType, category) }; if (contactInfo.InfoType == ContactInfoType.Address) { Address res; if (!Address.TryParse(contactInfo, out res)) { throw new ArgumentException(); } } var contactInfoID = _daoFactory.GetContactInfoDao().Save(contactInfo); var messageAction = contact is Company ? MessageAction.CompanyUpdatedPrincipalInfo : MessageAction.PersonUpdatedPrincipalInfo; _messageService.Send(messageAction, _messageTarget.Create(contact.ID), contact.GetTitle()); var contactInfoDto = _mapper.Map <ContactInfoDto>(contactInfo); contactInfoDto.Id = contactInfoID; return(contactInfoDto); }
protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(ImportFromCSVView)); Page.ClientScript.RegisterClientScriptInclude(GetType(), "ajaxupload_script", WebPath.GetPath("js/ajaxupload.3.5.js")); var columnSelectorData = new[] { new { name = String.Empty, title = CRMContactResource.NoMatchSelect, isHeader = false }, new { name = "-1", title = CRMContactResource.DoNotImportThisField, isHeader = false }, new { name = String.Empty, title = CRMContactResource.GeneralInformation, isHeader = true }, new { name = "firstName", title = CRMContactResource.FirstName, isHeader = false }, new { name = "lastName", title = CRMContactResource.LastName, isHeader = false }, new { name = "title", title = CRMContactResource.JobTitle, isHeader = false }, new { name = "companyName", title = CRMContactResource.CompanyName, isHeader = false }, new { name = "notes", title = CRMContactResource.About, isHeader = false }, new { name = "tag", title = CRMContactResource.Tags, isHeader = false } }.ToList(); foreach (ContactInfoType infoTypeEnum in Enum.GetValues(typeof(ContactInfoType))) { foreach (Enum categoryEnum in Enum.GetValues(ContactInfo.GetCategory(infoTypeEnum))) { var localName = String.Format("contactInfo_{0}_{1}", infoTypeEnum, Convert.ToInt32(categoryEnum)); var localTitle = String.Format("{1} ({0})", categoryEnum.ToLocalizedString().ToLower(), infoTypeEnum.ToLocalizedString()); if (infoTypeEnum == ContactInfoType.Address) { foreach (AddressPart addressPartEnum in Enum.GetValues(typeof(AddressPart))) { columnSelectorData.Add(new { name = String.Format(localName + "_{0}", addressPartEnum), title = String.Format(localTitle + " {0}", addressPartEnum.ToLocalizedString().ToLower()), isHeader = false }); } } else { columnSelectorData.Add(new { name = localName, title = localTitle, isHeader = false }); } } } columnSelectorData.AddRange(Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Contact).FindAll(customField => customField.FieldType == CustomFieldType.TextField || customField.FieldType == CustomFieldType.TextArea || customField.FieldType == CustomFieldType.Heading) .ConvertAll(customField => new { name = "customField_" + customField.ID, title = customField.Label.HtmlEncode(), isHeader = customField.FieldType == CustomFieldType.Heading })); Page.ClientScript.RegisterClientScriptBlock(GetType(), Guid.NewGuid().ToString(), String.Format(" var {0} = {1}; ", "columnSelectorData", JavaScriptSerializer.Serialize(columnSelectorData)), true); var privatePanel = (PrivatePanel)Page.LoadControl(PrivatePanel.Location); privatePanel.CheckBoxLabel = CRMContactResource.PrivatePanelCheckBoxLabelForContact; privatePanel.IsPrivateItem = false; var usersWhoHasAccess = new List <string> { CustomNamingPeople.Substitute <CRMCommonResource>("CurrentUser").HtmlEncode() }; privatePanel.UsersWhoHasAccess = usersWhoHasAccess; privatePanel.DisabledUsers = new List <Guid> { SecurityContext.CurrentAccount.ID }; privatePanel.HideNotifyPanel = true; _phPrivatePanel.Controls.Add(privatePanel); }