private static ContactWrapper GetContactWithFotos(ContactWrapper contact) { contact.SmallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(contact.ID, contact.IsCompany); contact.MediumFotoUrl = ContactPhotoManager.GetMediumSizePhoto(contact.ID, contact.IsCompany); return(contact); }
public string FindLinkedInProfiles(string firstName, string lastName) { //Process authorization if (!ProcessAuthorization(HttpContext.Current)) { AccessDenied(HttpContext.Current); return(null); } var provider = LinkedInApiHelper.GetLinkedInDataProviderForCurrentUser(); if (provider == null) { throw new SocialMediaAccountNotFound(SocialMediaResource.SocialMediaAccountNotFoundLinkedIn); } var users = provider.FindUsers(firstName, lastName); foreach (var user in users) { if (String.IsNullOrEmpty(user.ImageUrl)) { user.ImageUrl = ContactPhotoManager.GetMediumSizePhoto(0, false); } } string result = JsonConvert.SerializeObject(users); return(result); }
private void ResponceContactPhotoUrl(HttpContext context) { var contactId = Convert.ToInt32(context.Request["cid"]); var isCompany = Convert.ToBoolean(context.Request["isc"]); var photoSize = Convert.ToInt32(context.Request["ps"]); String photoUrl = String.Empty; switch (photoSize) { case 1: photoUrl = ContactPhotoManager.GetSmallSizePhoto(contactId, isCompany); break; case 2: photoUrl = ContactPhotoManager.GetMediumSizePhoto(contactId, isCompany); break; case 3: photoUrl = ContactPhotoManager.GetBigSizePhoto(contactId, isCompany); break; default: throw new Exception(CRMErrorsResource.ContactPhotoSizeUnknown); } context.Response.Clear(); context.Response.Write(photoUrl); context.Response.End(); }
protected string GetContactImgSrc(int contactID) { if (contactID > 0) { var contact = Global.DaoFactory.GetContactDao().GetByID(contactID); return(ContactPhotoManager.GetSmallSizePhoto(contactID, contact is Company)); } return(WebImageSupplier.GetAbsoluteWebPath("blank.gif")); }
public IEnumerable <VoipCallWrapper> GetCalls(string callType, ApiDateTime from, ApiDateTime to, Guid?agent, int?client, int?contactID) { var voipDao = DaoFactory.VoipDao; var filter = new VoipCallFilter { Type = callType, FromDate = from != null ? from.UtcTime : (DateTime?)null, ToDate = to != null?to.UtcTime.AddDays(1).AddMilliseconds(-1) : (DateTime?)null, Agent = agent, Client = client, ContactID = contactID, SortBy = _context.SortBy, SortOrder = !_context.SortDescending, SearchText = _context.FilterValue, Offset = _context.StartIndex, Max = _context.Count, }; _context.SetDataPaginated(); _context.SetDataFiltered(); _context.SetDataSorted(); _context.TotalCount = voipDao.GetCallsCount(filter); var defaultSmallPhoto = ContactPhotoManager.GetSmallSizePhoto(-1, false); var calls = voipDao.GetCalls(filter).Select( r => { ContactWrapper contact; if (r.ContactId != 0) { contact = r.ContactIsCompany ? (ContactWrapper) new CompanyWrapper(r.ContactId) { DisplayName = r.ContactTitle } : new PersonWrapper(r.ContactId) { DisplayName = r.ContactTitle }; contact.SmallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(contact.ID, contact.IsCompany); } else { contact = new PersonWrapper(-1) { SmallFotoUrl = defaultSmallPhoto }; } return(new VoipCallWrapper(r, contact)); }).ToList(); return(calls); }
private string UploadAvatar(int contactID, string imageUrl, bool uploadOnly) { if (contactID != 0) { return(ContactPhotoManager.UploadPhoto(imageUrl, contactID, uploadOnly)); } else { var tmpDirName = Guid.NewGuid().ToString(); return(ContactPhotoManager.UploadPhoto(imageUrl, tmpDirName)); } }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { return(new List <KeyValuePair <string, object> >(1) { RegisterObject(new { SmallSizePhotoCompany = ContactPhotoManager.GetSmallSizePhoto(0, true), SmallSizePhoto = ContactPhotoManager.GetSmallSizePhoto(0, false), MediumSizePhotoCompany = ContactPhotoManager.GetMediumSizePhoto(0, true), MediumSizePhoto = ContactPhotoManager.GetMediumSizePhoto(0, false), }) }); }
public ContactBaseWrapper(Contact contact) : base(contact.ID) { DisplayName = contact.GetTitle(); IsPrivate = CRMSecurity.IsPrivate(contact); if (IsPrivate) { AccessList = CRMSecurity.GetAccessSubjectTo(contact) .Select(item => EmployeeWraper.Get(item.Key)); } SmallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(contact.ID, contact is Company); IsCompany = contact is Company; CanEdit = CRMSecurity.CanEdit(contact); }
public string DeleteContactAvatar(int contactID) { try { var contact = Global.DaoFactory.GetContactDao().GetByID(contactID); ContactPhotoManager.DeletePhoto(contactID); return(ContactPhotoManager.GetBigSizePhoto(contactID, contact is Company)); } catch (Exception ex) { throw ProcessError(ex, "SaveUserAvatarFromSocialNetwork"); } }
private void RegisterScript() { var sb = new StringBuilder(); sb.Append(@" var hash = window.location.hash; hash = hash.charAt(0) == '#' ? hash.substring(1) : hash; if (!hash) { window.location.hash = 'profile'; }" ); sb.AppendFormat(@" ASC.CRM.DealTabView.initTab({0},{1},""{2}"",""{3}""); ASC.CRM.ListTaskView.initTab({0},""{4}"",0,{1},{5},{6},""{7}""); ASC.CRM.ContactDetailsView.init({8},{9},""{10}"",""{11}"", {13}, {14}, {15}, {17}); ASC.CRM.SocialMedia.init(""{16}""); ASC.CRM.ContactDetailsView.checkSocialMediaError(); {12}", TargetContact.ID, Global.EntryCountOnPage, System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator, WebImageSupplier.GetAbsoluteWebPath("empty_screen_deals.png", ProductEntryPoint.ID), EntityType.Contact.ToString().ToLower(), Global.VisiblePageCount, (int)HistoryCategorySystem.TaskClosed, WebImageSupplier.GetAbsoluteWebPath("empty_screen_tasks.png", ProductEntryPoint.ID), (TargetContact is Company).ToString().ToLower(), CanCreateProjects.ToString().ToLower(), WebImageSupplier.GetAbsoluteWebPath("empty_screen_company_participants.png", ProductEntryPoint.ID), WebImageSupplier.GetAbsoluteWebPath("empty_screen_projects.png", ProductEntryPoint.ID), ShowEventLinkToPanel ? "" : "jq('#eventLinkToPanel').hide();", (TargetContact is Company).ToString().ToLower(), WebItemSecurity.IsAvailableForUser(WebItemManager.ProjectsProductID.ToString(), SecurityContext.CurrentAccount.ID).ToString().ToLower(), (!string.IsNullOrEmpty(KeyStorage.Get(SocialMediaConstants.ConfigKeyTwitterDefaultAccessToken))).ToString().ToLower(), ContactPhotoManager.GetBigSizePhoto(0, TargetContact is Company), TargetContact.IsShared.ToString().ToLower() ); Page.RegisterInlineScript(sb.ToString()); }
public String ContactsToJSON(List <Contact> contacts) { var result = new List <Object>(); foreach (var contact in contacts) { if (contact is Company) { result.Add(new { id = contact.ID, title = contact.GetTitle().HtmlEncode(), img = ContactPhotoManager.GetSmallSizePhoto(contact.ID, true), parentID = 0, parentTitle = "", parentImg = "" }); } else { var people = (Person)contact; var title = ""; var img = ""; if (people.CompanyID != 0) { title = Global.DaoFactory.GetContactDao().GetByID(people.CompanyID).GetTitle(); img = ContactPhotoManager.GetSmallSizePhoto(people.CompanyID, true); } result.Add(new { id = contact.ID, title = contact.GetTitle().HtmlEncode(), img = ContactPhotoManager.GetSmallSizePhoto(contact.ID, false), parentID = people.CompanyID, parentTitle = title.HtmlEncode(), parentImg = img }); } } return(JsonConvert.SerializeObject(result)); }
private void RegisterScript() { var sb = new StringBuilder(); sb.AppendFormat(@" ASC.CRM.ContactFullCardView.init({0},'{1}',{2},{3},{4},{5},""{6}"",""{7}"",{8});", TargetContact.ID, TargetContact.GetTitle().HtmlEncode().ReplaceSingleQuote(), (TargetContact is Company).ToString().ToLower(), TargetContact is Person ? ((Person)TargetContact).CompanyID : 0, Global.TenantSettings.ChangeContactStatusGroupAuto != null ? Global.TenantSettings.ChangeContactStatusGroupAuto.ToString().ToLower() : "null", Global.TenantSettings.AddTagToContactGroupAuto != null ? Global.TenantSettings.AddTagToContactGroupAuto.ToString().ToLower() : "null", Studio.Core.FileSizeComment.GetFileImageSizeNote(CRMContactResource.ContactPhotoInfo, true), ContactPhotoManager.GetMediumSizePhoto(0, (TargetContact is Company)), CRMSecurity.IsAdmin.ToString().ToLower() ); Page.RegisterInlineScript(sb.ToString()); }
public string DeleteContactAvatar(int contactId, bool uploadOnly, string type) { bool isCompany; if (contactId != 0) { var contact = Global.DaoFactory.GetContactDao().GetByID(contactId); isCompany = contact is Company; } else { isCompany = type != "people"; } if (!uploadOnly) { ContactPhotoManager.DeletePhoto(contactId); return(ContactPhotoManager.GetBigSizePhoto(0, isCompany)); } return(""); }
private void ResponceContactPhotoUrl(HttpContext context) { var contactId = Convert.ToInt32(context.Request["cid"]); var isCompany = Convert.ToBoolean(context.Request["isc"]); var photoSize = Convert.ToInt32(context.Request["ps"]); String photoUrl = String.Empty; switch (photoSize) { case 1: photoUrl = ContactPhotoManager.GetSmallSizePhoto(contactId, isCompany); break; case 2: photoUrl = ContactPhotoManager.GetMediumSizePhoto(contactId, isCompany); break; case 3: photoUrl = ContactPhotoManager.GetBigSizePhoto(contactId, isCompany); break; default: throw new Exception(CRMErrorsResource.ContactPhotoSizeUnknown); } context.Response.Clear(); context.Response.Write(photoUrl); try { context.Response.Flush(); context.Response.SuppressContent = true; context.ApplicationInstance.CompleteRequest(); } catch (HttpException ex) { LogManager.GetLogger("ASC").Error("ResponceContactPhotoUrl", ex); } }
public void ProcessRequest(HttpContext context) { try { var contactId = Convert.ToInt32(context.Request.QueryString["cid"]); var photoSize = Convert.ToInt32(context.Request.QueryString["ps"]); string photoUrl; switch (photoSize) { case 1: photoUrl = ContactPhotoManager.GetSmallSizePhoto(contactId); break; case 2: photoUrl = ContactPhotoManager.GetMediumSizePhoto(contactId); break; case 3: photoUrl = ContactPhotoManager.GetBigSizePhoto(contactId); break; default: throw new HttpException("Unknown photo size"); } context.Response.Clear(); context.Response.Write(photoUrl); } catch (Exception) { context.Response.Redirect("404.html"); } finally { context.Response.End(); } }
public IEnumerable <VoipCallWrapper> GetMissedCalls() { var voipDao = DaoFactory.VoipDao; var defaultSmallPhoto = ContactPhotoManager.GetSmallSizePhoto(-1, false); var calls = voipDao.GetMissedCalls(SecurityContext.CurrentAccount.ID, 10, DateTime.UtcNow.AddDays(-7)).Select( r => { ContactWrapper contact; if (r.ContactId != 0) { contact = r.ContactIsCompany ? (ContactWrapper) new CompanyWrapper(r.ContactId) { DisplayName = r.ContactTitle } : new PersonWrapper(r.ContactId) { DisplayName = r.ContactTitle }; contact.SmallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(contact.ID, contact.IsCompany); } else { contact = new PersonWrapper(-1) { SmallFotoUrl = defaultSmallPhoto }; } return(new VoipCallWrapper(r, contact)); }).ToList(); _context.SetDataPaginated(); _context.SetDataFiltered(); _context.SetDataSorted(); _context.TotalCount = calls.Count; return(calls); }
public String AddNewContact(bool isCompany, string companyName, string firstName, string lastName) { if (isCompany) { var company = new Company { CompanyName = companyName.Trim() }; company.ID = Global.DaoFactory.GetContactDao().SaveContact(company); CRMSecurity.MakePublic(company); return(JsonConvert.SerializeObject(new { id = company.ID, title = company.GetTitle().HtmlEncode(), img = ContactPhotoManager.GetSmallSizePhoto(company.ID, true) })); } else { var contact = new Person { FirstName = firstName.Trim(), LastName = lastName.Trim() }; contact.ID = Global.DaoFactory.GetContactDao().SaveContact(contact); CRMSecurity.MakePublic(contact); return(JsonConvert.SerializeObject(new { id = contact.ID, title = contact.GetTitle().HtmlEncode(), img = ContactPhotoManager.GetSmallSizePhoto(contact.ID, false) })); } }
public String ChangeContactPhoto(int contactid, HttpPostedFileBase photo) { if (contactid == 0) { throw new ArgumentException(); } if (!(photo.ContentType.StartsWith("image/") && photo.ContentLength > 0)) { return(String.Empty); } if (!photo.InputStream.CanRead) { return(String.Empty); } var buffer = new byte[photo.ContentLength]; photo.InputStream.Read(buffer, 0, buffer.Length); return(ContactPhotoManager.UploadPhoto(buffer, contactid)); }
private void RegisterScript() { var sb = new StringBuilder(); sb.AppendFormat(@"ASC.CRM.ContactActionView.init(""{0}"",{1},{2},{3},{4},{5},""{6}"",""{7}""); ASC.CRM.SocialMedia.init(""{8}""); ASC.CRM.SocialMedia.emptyPeopleLogo = '{9}';", DateTimeExtension.DateMaskForJQuery, TargetContact != null ? TargetContact.ID : 0, TargetContact != null ? TargetContact.ContactTypeID : 0, TargetContact != null ? TargetContact.IsShared.ToString().ToLower() : false.ToString().ToLower(), TargetContact != null && TargetContact is Person || TargetContact == null && UrlParameters.Type == "people" ? (int)ContactSelectorTypeEnum.Companies : (int)ContactSelectorTypeEnum.PersonsWithoutCompany, CRMSecurity.IsAdmin.ToString().ToLower(), Studio.Core.FileSizeComment.GetFileImageSizeNote(CRMContactResource.ContactPhotoInfo, true), ContactPhotoManager.GetMediumSizePhoto(0, UrlParameters.Type != "people"), ContactPhotoManager.GetBigSizePhoto(0, UrlParameters.Type != "people"), WebImageSupplier.GetAbsoluteWebPath("empty_people_logo_40_40.png", ProductEntryPoint.ID) ); Page.RegisterInlineScript(sb.ToString()); }
public VoIPController(CrmSecurity crmSecurity, DaoFactory daoFactory, Global global, ContactPhotoManager contactPhotoManager, StorageFactory storageFactory, CommonLinkUtility commonLinkUtility, SecurityContext securityContext, TenantUtil tenantUtil, VoipEngine voipEngine, ApiContext apiContext, SignalrServiceClient signalrServiceClient, IMapper mapper) : base(daoFactory, crmSecurity, mapper) { _global = global; _contactPhotoManager = contactPhotoManager; _storageFactory = storageFactory; _commonLinkUtility = commonLinkUtility; _securityContext = securityContext; _tenantUtil = tenantUtil; _voipEngine = voipEngine; _apiContext = apiContext; _signalrServiceClient = signalrServiceClient; }
public void ProcessRequest(HttpContext context) { var log = LogManager.GetLogger("ASC.Mail.ContactPhotoHandler"); try { if (!SecurityContext.IsAuthenticated) { throw new HttpException(403, "Access denied."); } var contactId = Convert.ToInt32(context.Request.QueryString["cid"]); var photoSize = Convert.ToInt32(context.Request.QueryString["ps"]); string photoUrl; switch (photoSize) { case 1: photoUrl = ContactPhotoManager.GetSmallSizePhoto(contactId); break; case 2: photoUrl = ContactPhotoManager.GetMediumSizePhoto(contactId); break; case 3: photoUrl = ContactPhotoManager.GetBigSizePhoto(contactId); break; default: throw new HttpException("Unknown photo size"); } context.Response.Clear(); context.Response.Write(photoUrl); } catch (HttpException he) { log.Error("ContactPhoto handler failed", he); context.Response.StatusCode = he.GetHttpCode(); context.Response.Write(he.Message != null ? HttpUtility.HtmlEncode(he.Message) : MailApiErrorsResource.ErrorInternalServer); } catch (Exception ex) { log.Error("ContactPhoto handler failed", ex); context.Response.StatusCode = 404; context.Response.Redirect("404.html"); } finally { try { context.Response.Flush(); context.Response.SuppressContent = true; context.ApplicationInstance.CompleteRequest(); } catch (HttpException ex) { LogManager.GetLogger("ASC").Error("ResponceContactPhotoUrl", ex); } } }
protected string GetContactImgSrc() { return(SelectedContact != null?ContactPhotoManager.GetSmallSizePhoto(SelectedContact.ID, SelectedContact is Company) : WebImageSupplier.GetAbsoluteWebPath("blank.gif")); }
private string SaveAvatar(int contactID, string imageUrl) { return(ContactPhotoManager.UploadPhoto(imageUrl, contactID)); }
public async System.Threading.Tasks.Task Invoke(HttpContext context, CrmSecurity crmSecurity, SetupInfo setupInfo, FileSizeComment fileSizeComment, ContactPhotoManager contactPhotoManager, OrganisationLogoManager organisationLogoManager) { context.Request.EnableBuffering(); if (!crmSecurity.IsAdmin) { throw crmSecurity.CreateSecurityException(); } var fileUploadResult = new FileUploadResult(); if (context.Request.Form.Files.Count == 0) { await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } var fileName = context.Request.Form.Files[0].FileName; var contentLength = context.Request.Form.Files[0].Length; if (String.IsNullOrEmpty(fileName) || contentLength == 0) { throw new InvalidOperationException(CRMErrorsResource.InvalidFile); } if (0 < setupInfo.MaxImageUploadSize && setupInfo.MaxImageUploadSize < contentLength) { fileUploadResult.Success = false; fileUploadResult.Message = fileSizeComment.GetFileImageSizeNote(CRMCommonResource.ErrorMessage_UploadFileSize, false).HtmlEncode(); await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } if (FileUtility.GetFileTypeByFileName(fileName) != FileType.Image) { fileUploadResult.Success = false; fileUploadResult.Message = CRMJSResource.ErrorMessage_NotImageSupportFormat.HtmlEncode(); await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } try { var imageData = Global.ToByteArray(context.Request.Form.Files[0].OpenReadStream()); var imageFormat = contactPhotoManager.CheckImgFormat(imageData); var photoUri = organisationLogoManager.UploadLogo(imageData, imageFormat); fileUploadResult.Success = true; fileUploadResult.Data = photoUri; await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } catch (Exception exception) { fileUploadResult.Success = false; fileUploadResult.Message = exception.Message.HtmlEncode(); await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } }
protected string GetContactsByPrefixJSON(EntityType targetEntityType, int targetEntityID, string prefix) { var allContacts = new List <Contact>(); var findedContacts = new List <Contact>(); switch (targetEntityType) { case EntityType.Opportunity: allContacts = Global.DaoFactory.GetContactDao().GetContacts(Global.DaoFactory.GetDealDao().GetMembers(targetEntityID)); break; case EntityType.Case: allContacts = Global.DaoFactory.GetContactDao().GetContacts(Global.DaoFactory.GetCasesDao().GetMembers(targetEntityID)); break; } foreach (var c in allContacts) { if (c is Person) { var people = (Person)c; if (UserFormatter.GetUserName(people.FirstName, people.LastName).IndexOf(prefix) != -1) { findedContacts.Add(c); } } else { var company = (Company)c; if (company.CompanyName.IndexOf(prefix) != -1) { findedContacts.Add(c); } } } return(JavaScriptSerializer.Serialize(findedContacts.ConvertAll(contact => { var displayTitle = String.Empty; var imgPath = String.Empty; if (contact is Person) { var people = (Person)contact; imgPath = ContactPhotoManager.GetSmallSizePhoto(people.ID, false);; displayTitle = UserFormatter.GetUserName(people.FirstName, people.LastName); } else { var company = (Company)contact; imgPath = ContactPhotoManager.GetSmallSizePhoto(company.ID, true); displayTitle = company.CompanyName; } return new { id = contact.ID, title = displayTitle, img = imgPath }; } ))); }
public async System.Threading.Tasks.Task Invoke(HttpContext context, SetupInfo setupInfo, CrmSecurity crmSecurity, FileSizeComment fileSizeComment, WebItemSecurity webItemSecurity, MessageTarget messageTarget, MessageService messageService, DaoFactory daoFactory, ContactPhotoManager contactPhotoManager) { if (!webItemSecurity.IsAvailableForMe(ProductEntryPoint.ID)) { throw crmSecurity.CreateSecurityException(); } context.Request.EnableBuffering(); var contactId = Convert.ToInt32(context.Request.Form["contactID"]); Contact contact = null; if (contactId != 0) { contact = daoFactory.GetContactDao().GetByID(contactId); if (!crmSecurity.CanEdit(contact)) { throw crmSecurity.CreateSecurityException(); } } var fileUploadResult = new FileUploadResult(); if (context.Request.Form.Files.Count == 0) { await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } var fileName = context.Request.Form.Files[0].FileName; var contentLength = context.Request.Form.Files[0].Length; if (String.IsNullOrEmpty(fileName) || contentLength == 0) { throw new InvalidOperationException(CRMErrorsResource.InvalidFile); } if (0 < setupInfo.MaxImageUploadSize && setupInfo.MaxImageUploadSize < contentLength) { fileUploadResult.Success = false; fileUploadResult.Message = fileSizeComment.GetFileImageSizeNote(CRMCommonResource.ErrorMessage_UploadFileSize, false).HtmlEncode(); await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } if (FileUtility.GetFileTypeByFileName(fileName) != FileType.Image) { fileUploadResult.Success = false; fileUploadResult.Message = CRMJSResource.ErrorMessage_NotImageSupportFormat.HtmlEncode(); await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } var uploadOnly = Convert.ToBoolean(context.Request.Form["uploadOnly"]); var tmpDirName = Convert.ToString(context.Request.Form["tmpDirName"]); try { ContactPhotoManager.PhotoData photoData; if (contactId != 0) { photoData = contactPhotoManager.UploadPhoto(context.Request.Form.Files[0].OpenReadStream(), contactId, uploadOnly); } else { if (String.IsNullOrEmpty(tmpDirName) || tmpDirName == "null") { tmpDirName = Guid.NewGuid().ToString(); } photoData = contactPhotoManager.UploadPhotoToTemp(context.Request.Form.Files[0].OpenReadStream(), tmpDirName); } fileUploadResult.Success = true; fileUploadResult.Data = photoData; } catch (Exception e) { fileUploadResult.Success = false; fileUploadResult.Message = e.Message.HtmlEncode(); await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); } if (contact != null) { var messageAction = contact is Company ? MessageAction.CompanyUpdatedPhoto : MessageAction.PersonUpdatedPhoto; messageService.Send(messageAction, messageTarget.Create(contact.ID), contact.GetTitle()); } await context.Response.WriteAsync(JsonSerializer.Serialize(fileUploadResult)); }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { var imgs = new Dictionary <string, string> { { "empty_screen_filter", WebImageSupplier.GetAbsoluteWebPath("empty_screen_filter.png") }, { "empty_screen_tasks", WebImageSupplier.GetAbsoluteWebPath("empty_screen_tasks.png", ProductEntryPoint.ID) }, { "empty_screen_deals", WebImageSupplier.GetAbsoluteWebPath("empty_screen_deals.png", ProductEntryPoint.ID) }, { "empty_screen_cases", WebImageSupplier.GetAbsoluteWebPath("empty_screen_cases.png", ProductEntryPoint.ID) }, { "empty_screen_invoices", WebImageSupplier.GetAbsoluteWebPath("empty_screen_invoices.png", ProductEntryPoint.ID) }, { "empty_screen_products_services", WebImageSupplier.GetAbsoluteWebPath("empty_screen_products_services.png", ProductEntryPoint.ID) }, { "empty_screen_taxes", WebImageSupplier.GetAbsoluteWebPath("empty_screen_taxes.png", ProductEntryPoint.ID) }, { "empty_screen_persons", WebImageSupplier.GetAbsoluteWebPath("empty_screen_persons.png", ProductEntryPoint.ID) }, { "empty_screen_phones", WebImageSupplier.GetAbsoluteWebPath("empty_screen_phones.png", ProductEntryPoint.ID) }, { "empty_screen_voip_settings", WebImageSupplier.GetAbsoluteWebPath("empty_screen_voip_settings.png", ProductEntryPoint.ID) }, { "empty_people_logo_40_40", WebImageSupplier.GetAbsoluteWebPath("empty_people_logo_40_40.png", ProductEntryPoint.ID) }, { "empty_screen_opportunity_participants", WebImageSupplier.GetAbsoluteWebPath("empty_screen_opportunity_participants.png", ProductEntryPoint.ID) }, { "empty_screen_company_participants", WebImageSupplier.GetAbsoluteWebPath("empty_screen_company_participants.png", ProductEntryPoint.ID) }, { "empty_screen_case_participants", WebImageSupplier.GetAbsoluteWebPath("empty_screen_case_participants.png", ProductEntryPoint.ID) }, { "empty_screen_projects", WebImageSupplier.GetAbsoluteWebPath("empty_screen_projects.png", ProductEntryPoint.ID) }, { "empty_screen_userfields", WebImageSupplier.GetAbsoluteWebPath("empty_screen_userfields.png", ProductEntryPoint.ID) }, { "empty_screen_tags", WebImageSupplier.GetAbsoluteWebPath("empty_screen_tags.png", ProductEntryPoint.ID) }, { "empty_screen_twitter", WebImageSupplier.GetAbsoluteWebPath("empty_screen_twitter.png", ProductEntryPoint.ID) } }; return(new List <KeyValuePair <string, object> >(1) { RegisterObject( new { MediumSizePhotoCompany = ContactPhotoManager.GetMediumSizePhoto(0, true), MediumSizePhoto = ContactPhotoManager.GetMediumSizePhoto(0, false), SmallSizePhotoCompany = ContactPhotoManager.GetSmallSizePhoto(0, true), SmallSizePhoto = ContactPhotoManager.GetSmallSizePhoto(0, false), ProfileRemoved = Constants.LostUser.DisplayUserName(), System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator, KeyCodeCurrencyDecimalSeparator = (int)System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator[0], Global.VisiblePageCount, DefaultEntryCountOnPage = Global.EntryCountOnPage, Global.DefaultCustomFieldSize, Global.DefaultCustomFieldRows, Global.DefaultCustomFieldCols, Global.MaxCustomFieldSize, Global.MaxCustomFieldRows, Global.MaxCustomFieldCols, Global.MaxHistoryEventCharacters, Global.MaxInvoiceItemPrice, Global.CanDownloadInvoices, IsCRMAdmin = CRMSecurity.IsAdmin, EmptyScrImgs = imgs, ImageWebPath = WebImageSupplier.GetImageFolderAbsoluteWebPath(ProductEntryPoint.ID), ContactSelectorTypeEnum = new Dictionary <string, int> { { "All", (int)ContactSelectorTypeEnum.All }, { "Companies", (int)ContactSelectorTypeEnum.Companies }, { "CompaniesAndPersonsWithoutCompany", (int)ContactSelectorTypeEnum.CompaniesAndPersonsWithoutCompany }, { "Persons", (int)ContactSelectorTypeEnum.Persons }, { "PersonsWithoutCompany", (int)ContactSelectorTypeEnum.PersonsWithoutCompany } }, HistoryCategorySystem = new Dictionary <string, int> { { "TaskClosed", (int)HistoryCategorySystem.TaskClosed }, { "FilesUpload", (int)HistoryCategorySystem.FilesUpload }, { "MailMessage", (int)HistoryCategorySystem.MailMessage } }, DefaultContactPhoto = new Dictionary <string, string> { { "CompanyBigSizePhoto", ContactPhotoManager.GetBigSizePhoto(0, true) }, { "PersonBigSizePhoto", ContactPhotoManager.GetBigSizePhoto(0, false) }, { "CompanyMediumSizePhoto", ContactPhotoManager.GetMediumSizePhoto(0, true) }, { "PersonMediumSizePhoto", ContactPhotoManager.GetMediumSizePhoto(0, false) } }, CookieKeyForPagination = new Dictionary <string, string> { { "contacts", "contactPageNumber" }, { "tasks", "taskPageNumber" }, { "deals", "dealPageNumber" }, { "cases", "casesPageNumber" }, { "invoices", "invoicePageNumber" }, { "invoiceitems", "invoiceItemsPageNumber" } }, CanCreateProjects = Global.CanCreateProjects() }) }); }
protected void Page_Load(object sender, EventArgs e) { MobileVer = ASC.Web.Core.Mobile.MobileDetector.IsRequestMatchesMobile(this.Context); if (UrlParameters.Action != "export") { InitEmptyScreenControls(); Utility.RegisterTypeForAjax(typeof(AjaxProHelper)); if (EntityID == 0 && CurrentContact == null)//the main page with tasks { RegisterClientScriptForFilter(); GetDataFromCookie(); } else // the tab with tasks { if (CurrentContact != null) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "8adeda71-2ad7-43b7-9939-f69c776dfbc0", "contactForInitTaskActionPanel = " + JavaScriptSerializer.Serialize(new { id = CurrentContact.ID, displayName = CurrentContact.GetTitle().HtmlEncode(), smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(CurrentContact.ID, CurrentContact is Company) }) + "; ", true); } if (UserList != null && UserList.Count > 0) { _taskActionView.UserList = UserList; } } } else // export to csv { if (!CRMSecurity.IsAdmin) { Response.Redirect(PathProvider.StartURL()); } var tasks = GetTasksByFilter(); if (UrlParameters.View != "editor") { Response.Clear(); Response.ContentType = "text/csv; charset=utf-8"; Response.ContentEncoding = Encoding.UTF8; Response.Charset = Encoding.UTF8.WebName; var fileName = "tasks.csv"; Response.AppendHeader("Content-Disposition", String.Format("attachment; filename={0}", fileName)); Response.Write(ExportToCSV.ExportTasksToCSV(tasks, false)); Response.End(); } else { var fileUrl = ExportToCSV.ExportTasksToCSV(tasks, true); Response.Redirect(fileUrl); } } }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { yield return(RegisterObject("ProfileRemoved", ASC.Core.Users.Constants.LostUser.DisplayUserName())); yield return(RegisterObject("CurrencyDecimalSeparator", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator)); yield return(RegisterObject("KeyCodeCurrencyDecimalSeparator", (int)System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator[0])); yield return(RegisterObject("VisiblePageCount", Global.VisiblePageCount)); yield return(RegisterObject("DefaultEntryCountOnPage", Global.EntryCountOnPage)); yield return(RegisterObject("DefaultCustomFieldSize", Global.DefaultCustomFieldSize)); yield return(RegisterObject("DefaultCustomFieldRows", Global.DefaultCustomFieldRows)); yield return(RegisterObject("DefaultCustomFieldCols", Global.DefaultCustomFieldCols)); yield return(RegisterObject("MaxCustomFieldSize", Global.MaxCustomFieldSize)); yield return(RegisterObject("MaxCustomFieldRows", Global.MaxCustomFieldRows)); yield return(RegisterObject("MaxCustomFieldCols", Global.MaxCustomFieldCols)); yield return(RegisterObject("IsCRMAdmin", CRMSecurity.IsAdmin)); var imgs = new Dictionary <string, string> { { "empty_screen_filter", WebImageSupplier.GetAbsoluteWebPath("empty_screen_filter.png") }, { "empty_screen_tasks", WebImageSupplier.GetAbsoluteWebPath("empty_screen_tasks.png", ProductEntryPoint.ID) }, { "empty_screen_deals", WebImageSupplier.GetAbsoluteWebPath("empty_screen_deals.png", ProductEntryPoint.ID) }, { "empty_screen_cases", WebImageSupplier.GetAbsoluteWebPath("empty_screen_cases.png", ProductEntryPoint.ID) }, { "empty_screen_invoices", WebImageSupplier.GetAbsoluteWebPath("empty_screen_invoices.png", ProductEntryPoint.ID) }, { "empty_screen_products_services", WebImageSupplier.GetAbsoluteWebPath("empty_screen_products_services.png", ProductEntryPoint.ID) }, { "empty_screen_taxes", WebImageSupplier.GetAbsoluteWebPath("empty_screen_taxes.png", ProductEntryPoint.ID) }, { "empty_screen_persons", WebImageSupplier.GetAbsoluteWebPath("empty_screen_persons.png", ProductEntryPoint.ID) }, { "empty_people_logo_40_40", WebImageSupplier.GetAbsoluteWebPath("empty_people_logo_40_40.png", ProductEntryPoint.ID) }, { "empty_screen_opportunity_participants", WebImageSupplier.GetAbsoluteWebPath("empty_screen_opportunity_participants.png", ProductEntryPoint.ID) }, { "empty_screen_company_participants", WebImageSupplier.GetAbsoluteWebPath("empty_screen_company_participants.png", ProductEntryPoint.ID) }, { "empty_screen_case_participants", WebImageSupplier.GetAbsoluteWebPath("empty_screen_case_participants.png", ProductEntryPoint.ID) }, { "empty_screen_projects", WebImageSupplier.GetAbsoluteWebPath("empty_screen_projects.png", ProductEntryPoint.ID) }, { "empty_screen_userfields", WebImageSupplier.GetAbsoluteWebPath("empty_screen_userfields.png", ProductEntryPoint.ID) }, { "empty_screen_tags", WebImageSupplier.GetAbsoluteWebPath("empty_screen_tags.png", ProductEntryPoint.ID) } }; yield return(RegisterObject("EmptyScrImgs", imgs)); yield return(RegisterObject("ContactSelectorTypeEnum", new Dictionary <string, int> { { "All", (int)ContactSelectorTypeEnum.All }, { "Companies", (int)ContactSelectorTypeEnum.Companies }, { "CompaniesAndPersonsWithoutCompany", (int)ContactSelectorTypeEnum.CompaniesAndPersonsWithoutCompany }, { "Persons", (int)ContactSelectorTypeEnum.Persons }, { "PersonsWithoutCompany", (int)ContactSelectorTypeEnum.PersonsWithoutCompany } })); yield return(RegisterObject("HistoryCategorySystem", new Dictionary <string, int> { { "TaskClosed", (int)HistoryCategorySystem.TaskClosed }, { "FilesUpload", (int)HistoryCategorySystem.FilesUpload }, { "MailMessage", (int)HistoryCategorySystem.MailMessage } })); yield return(RegisterObject("DefaultContactPhoto", new Dictionary <string, string> { { "CompanyBigSizePhoto", ContactPhotoManager.GetBigSizePhoto(0, true) }, { "PersonBigSizePhoto", ContactPhotoManager.GetBigSizePhoto(0, false) }, { "CompanyMediumSizePhoto", ContactPhotoManager.GetMediumSizePhoto(0, true) }, { "PersonMediumSizePhoto", ContactPhotoManager.GetMediumSizePhoto(0, false) } })); yield return(RegisterObject("CookieKeyForPagination", new Dictionary <string, string> { { "contacts", "contactPageNumber" }, { "tasks", "taskPageNumber" }, { "deals", "dealPageNumber" }, { "cases", "casesPageNumber" }, { "invoices", "invoicePageNumber" }, { "invoiceitems", "invoiceItemsPageNumber" } })); yield return(RegisterObject("CanCreateProjects", Global.CanCreateProjects())); }
protected void SaveOrUpdateContact(object sender, CommandEventArgs e) { try { var dao = Global.DaoFactory; Contact contact; List <Contact> contactsForSetManager = new List <Contact>(); var typeAddedContact = Request["typeAddedContact"]; #region Rights part #1 ShareType shareType = ShareType.None;// 0 - NotShared, 1 - ReadWriting, 2 - Reading if (!String.IsNullOrEmpty(Request["isPublicContact"])) { try { shareType = (ShareType)(Convert.ToInt32(Request["isPublicContact"])); } catch (Exception) { throw new ArgumentException(); } } #endregion #region BaseInfo var companyID = 0; if (!String.IsNullOrEmpty(Request["baseInfo_compID"])) { companyID = Convert.ToInt32(Request["baseInfo_compID"]); } else if (!String.IsNullOrEmpty(Request["baseInfo_compName"])) { var peopleCompany = new Company { CompanyName = Request["baseInfo_compName"].Trim(), ShareType = shareType }; peopleCompany.ID = dao.GetContactDao().SaveContact(peopleCompany); companyID = peopleCompany.ID; contactsForSetManager.Add(peopleCompany); } if (typeAddedContact.Equals("people")) { contact = new Person { FirstName = Request["baseInfo_firstName"].Trim(), LastName = Request["baseInfo_lastName"].Trim(), JobTitle = Request["baseInfo_personPosition"].Trim(), CompanyID = companyID }; } else { contact = new Company { CompanyName = Request["baseInfo_companyName"].Trim() }; } contact.About = !String.IsNullOrEmpty(Request["baseInfo_contactOverview"]) ? Request["baseInfo_contactOverview"].Trim() : null; contact.ShareType = shareType; #endregion #region ContactType and Currency contact.ContactTypeID = Convert.ToInt32(Request["baseInfo_contactType"]); if (contact.ContactTypeID != 0) { var listItem = dao.GetListItemDao().GetByID(contact.ContactTypeID); if (listItem == null) { throw new Exception(CRMErrorsResource.ContactTypeNotFound); } } contact.Currency = Convert.ToString(Request["baseInfo_currency"]); if (!String.IsNullOrEmpty(contact.Currency)) { var currency = CurrencyProvider.Get(contact.Currency); if (currency == null) { throw new Exception(CRMErrorsResource.CurrencyNotFound); } } #endregion #region Base Operation Of Save/Update if (TargetContact != null) { contact.ID = TargetContact.ID; contact.StatusID = TargetContact.StatusID; dao.GetContactDao().UpdateContact(contact); var messageAction = contact is Company ? MessageAction.CompanyUpdated : MessageAction.PersonUpdated; MessageService.Send(HttpContext.Current.Request, messageAction, contact.GetTitle()); contact = dao.GetContactDao().GetByID(contact.ID); } else { contact.ID = dao.GetContactDao().SaveContact(contact); var messageAction = contact is Company ? MessageAction.CompanyCreated : MessageAction.PersonCreated; MessageService.Send(HttpContext.Current.Request, messageAction, contact.GetTitle()); contact = dao.GetContactDao().GetByID(contact.ID); } contactsForSetManager.Add(contact); #endregion #region persons for company if (contact is Company) { var assignedContactsIDs = new List <int>(); if (!String.IsNullOrEmpty(Request["baseInfo_assignedNewContactsIDs"])) { try { var assignedContactsObjs = JArray.Parse(Request["baseInfo_assignedNewContactsIDs"]); var newAssignedContacts = new List <Contact>(); var recordIndex = 0; foreach (var assignedContactsObj in assignedContactsObjs) { newAssignedContacts.Add(new Person { ID = recordIndex, ShareType = shareType, CompanyID = contact.ID, FirstName = assignedContactsObj.Value <String>("FirstName"), LastName = assignedContactsObj.Value <String>("LastName") }); recordIndex++; } dao.GetContactDao().SaveContactList(newAssignedContacts); if (newAssignedContacts.Count != 0) { contactsForSetManager.AddRange(newAssignedContacts); assignedContactsIDs.AddRange(newAssignedContacts.Select(c => c.ID).ToList()); } } catch (Exception ex) { log4net.LogManager.GetLogger("ASC.CRM").Error(ex); } } if (!String.IsNullOrEmpty(Request["baseInfo_assignedContactsIDs"])) { assignedContactsIDs.AddRange(Request["baseInfo_assignedContactsIDs"].Split(',').Select(item => Convert.ToInt32(item)).ToList()); } if (TargetContact != null && !CRMSecurity.IsAdmin) { var restrictedMembers = dao.GetContactDao().GetRestrictedMembers(contact.ID); assignedContactsIDs.AddRange(restrictedMembers.Select(m => m.ID).ToList()); } dao.GetContactDao().SetMembers(contact.ID, assignedContactsIDs.ToArray()); } #endregion #region tags var assignedTags = Request["baseInfo_assignedTags"]; if (assignedTags != null) { var oldTagList = dao.GetTagDao().GetEntityTags(EntityType.Contact, contact.ID); foreach (var tag in oldTagList) { dao.GetTagDao().DeleteTagFromEntity(EntityType.Contact, contact.ID, tag); } if (assignedTags != string.Empty) { var tagListInfo = JObject.Parse(assignedTags)["tagListInfo"].ToArray(); var newTagList = tagListInfo.Select(t => t.ToString()).ToArray(); dao.GetTagDao().SetTagToEntity(EntityType.Contact, contact.ID, newTagList); } } #endregion #region contact infos (addresses, mailes, phones etc.) var contactInfos = new List <ContactInfo>(); var addressList = new Dictionary <int, ContactInfo>(); var addressTemplate = new JObject(); foreach (String addressPartName in Enum.GetNames(typeof(AddressPart))) { addressTemplate.Add(addressPartName.ToLower(), ""); } var addressTemplateStr = addressTemplate.ToString(); foreach (var item in Request.Form.AllKeys) { if (item.StartsWith("customField_")) { int fieldID = Convert.ToInt32(item.Split('_')[1]); String fieldValue = Request.Form[item].Trim(); if (contact is Person) { if (!String.IsNullOrEmpty(fieldValue)) { dao.GetCustomFieldDao().SetFieldValue(EntityType.Person, contact.ID, fieldID, ""); } dao.GetCustomFieldDao().SetFieldValue(EntityType.Person, contact.ID, fieldID, fieldValue); } else { if (!String.IsNullOrEmpty(fieldValue)) { dao.GetCustomFieldDao().SetFieldValue(EntityType.Company, contact.ID, fieldID, ""); } dao.GetCustomFieldDao().SetFieldValue(EntityType.Company, contact.ID, fieldID, fieldValue); } } else if (item.StartsWith("contactInfo_")) { var nameParts = item.Split('_').Skip(1).ToList(); var contactInfoType = (ContactInfoType)Enum.Parse(typeof(ContactInfoType), nameParts[0]); var category = Convert.ToInt32(nameParts[2]); if (contactInfoType == ContactInfoType.Address) { var index = Convert.ToInt32(nameParts[1]); var addressPart = (AddressPart)Enum.Parse(typeof(AddressPart), nameParts[3]); var isPrimaryAddress = Convert.ToInt32(nameParts[4]) == 1; var dataValues = Request.Form.GetValues(item).Select(n => n.Trim()).ToList(); if (!addressList.ContainsKey(index)) { var newAddress = new ContactInfo { Category = category, InfoType = contactInfoType, Data = addressTemplateStr, IsPrimary = isPrimaryAddress, ContactID = contact.ID }; addressList.Add(index, newAddress); } foreach (var data in dataValues) { var addressParts = JObject.Parse(addressList[index].Data); addressParts[addressPart.ToString().ToLower()] = data; addressList[index].Data = addressParts.ToString(); } continue; } var isPrimary = Convert.ToInt32(nameParts[3]) == 1; if (Request.Form.GetValues(item) != null) { var dataValues = Request.Form.GetValues(item).Where(n => !string.IsNullOrEmpty(n.Trim())).ToList(); contactInfos.AddRange(dataValues.Select(dataValue => new ContactInfo { Category = category, InfoType = contactInfoType, Data = dataValue.Trim(), IsPrimary = isPrimary, ContactID = contact.ID })); } } } if (addressList.Count > 0) { contactInfos.AddRange(addressList.Values.ToList()); } dao.GetContactInfoDao().DeleteByContact(contact.ID); dao.GetContactInfoDao().SaveList(contactInfos); #endregion #region Photo var photoPath = Request["uploadPhotoPath"]; if (!String.IsNullOrEmpty(photoPath)) { if (photoPath != "null") { if (photoPath.StartsWith(PathProvider.BaseAbsolutePath)) { var tmpDirName = photoPath.Substring(0, photoPath.LastIndexOf('/')); ContactPhotoManager.TryUploadPhotoFromTmp(contact.ID, TargetContact == null, tmpDirName); } else { ContactPhotoManager.UploadPhoto(photoPath, contact.ID); } } } else if (TargetContact != null) { ContactPhotoManager.DeletePhoto(TargetContact.ID); } #endregion #region Rights part #2 SetContactManager(contactsForSetManager); #endregion #region Link with mail message int result; var linkMessageId = int.TryParse(Request["linkMessageId"], out result) ? result : 0; if (linkMessageId > 0) { try { LinkWithMessage(linkMessageId, contact.ID); } catch (Exception ex) { log4net.LogManager.GetLogger("ASC.CRM").Error(ex); } } #endregion Response.Redirect(String.Compare(e.CommandArgument.ToString(), "0", true) == 0 ? String.Format("default.aspx?id={0}{1}", contact.ID, contact is Company ? "" : String.Format("&{0}=people", UrlConstant.Type)) : String.Format("default.aspx?action=manage{0}", contact is Company ? "" : String.Format("&{0}=people", UrlConstant.Type)), false); Context.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { log4net.LogManager.GetLogger("ASC.CRM").Error(ex); var cookie = HttpContext.Current.Request.Cookies.Get(ErrorCookieKey); if (cookie == null) { cookie = new HttpCookie(ErrorCookieKey) { Value = ex.Message }; HttpContext.Current.Response.Cookies.Add(cookie); } } }