public TargetContact SaveRecord([FromBody] TargetContact contactData) { HttpContext.Response.Headers["Content-Encoding"] = "identity"; HttpContext.Response.Headers["Transfer-Encoding"] = "identity"; if (contactData.Id == 0) { contactData = db.TargetContacts.Add(contactData).Entity; } else { db.TargetContacts.Update(contactData); } var lead = db.BusinessLeads.Where(x => x.Id == contactData.LeadId).Include(x => x.PrimaryContacts).FirstOrDefault(); if (lead == null) { throw new System.Exception("Unable to find parent record."); } lead.PrimaryContacts.Append(contactData); db.SaveChanges(); return(contactData); }
protected void Page_Load(object sender, EventArgs e) { Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "ajaxupload_script", WebPath.GetPath("js/ajaxupload.3.5.js")); Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "contact_placeholder_script", WebPath.GetPath("js/jquery.watermarkinput.js")); var country = new List <string> { CRMJSResource.ChooseCountry }; var additionalCountries = new List <string> { CRMCommonResource.Country_Gambia, CRMCommonResource.Country_Ghana, CRMCommonResource.Country_RepublicOfCyprus, CRMCommonResource.Country_SierraLeone, CRMCommonResource.Country_Tanzania, CRMCommonResource.Country_Zambia, }; var standardCountries = Global.GetCountryList(); standardCountries.AddRange(additionalCountries); country.AddRange(standardCountries.OrderBy(c => c)); contactCountry.DataSource = country; contactCountry.Name = "contactInfo_Address_" + (int)ContactInfoBaseCategory.Work + "_" + AddressPart.Country; contactCountry.DataBind(); ContactInfoTypes = (from ContactInfoType item in Enum.GetValues(typeof(ContactInfoType)) where (item != ContactInfoType.Address && item != ContactInfoType.Email && item != ContactInfoType.Phone) select item).ToList(); List <CustomField> data; var networks = new List <ContactInfo>(); saveContactButton.Text = SaveContactButtonText; saveContactButton.OnClientClick = String.Format("return ASC.CRM.ContactActionView.submitForm('{0}');", saveContactButton.UniqueID); saveAndCreateContactButton.Text = SaveAndCreateContactButtonText; saveAndCreateContactButton.OnClientClick = String.Format("return ASC.CRM.ContactActionView.submitForm('{0}');", saveAndCreateContactButton.UniqueID); if (TargetContact == null) { if (UrlParameters.Type != "people") { data = Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Company); ExecAssignedContactsView(0); } else { data = Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Person); } var URLEmail = UrlParameters.Email; if (!String.IsNullOrEmpty(URLEmail)) { networks.Add(new ContactInfo() { Category = (int)ContactInfoBaseCategory.Work, ContactID = 0, Data = URLEmail.HtmlEncode(), ID = 0, InfoType = ContactInfoType.Email, IsPrimary = true }); } } else { if (TargetContact is Person) { data = Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Person, TargetContact.ID, true); } else { data = Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Company, TargetContact.ID, true); } if (TargetContact is Company) { deleteContactButton.Text = CRMContactResource.DeleteThisCompany; deleteContactButton.OnClientClick = String.Format("return ASC.CRM.ContactActionView.confirmForDelete(1, '{0}');", TargetContact.GetTitle().ReplaceSingleQuote().HtmlEncode()); ExecAssignedContactsView(TargetContact.ID); } else { deleteContactButton.Text = CRMContactResource.DeleteThisPerson; deleteContactButton.OnClientClick = String.Format("return ASC.CRM.ContactActionView.confirmForDelete(0, '{0}');", TargetContact.GetTitle().ReplaceSingleQuote().HtmlEncode()); } networks = Global.DaoFactory.GetContactInfoDao().GetList(TargetContact.ID, null, null, null).ConvertAll( n => new ContactInfo() { Category = n.Category, ContactID = n.ContactID, Data = n.Data.HtmlEncode(), ID = n.ID, InfoType = n.InfoType, IsPrimary = n.IsPrimary }); } String json; using (var stream = new MemoryStream()) { var serializer = new DataContractJsonSerializer(data.GetType()); serializer.WriteObject(stream, data); json = Encoding.UTF8.GetString(stream.ToArray()); } var script = String.Format( @"<script type='text/javascript'> var customFieldList = {0}; var contactNetworks = {1}; </script>", json, JavaScriptSerializer.Serialize(networks)); Page.ClientScript.RegisterStartupScript(typeof(ContactDetailsView), Guid.NewGuid().ToString(), script); if (TargetContact == null || TargetContact is Person) { InitContactSelectorAndCancelButton(); } else { cancelButton.Attributes.Add("href", String.Format("default.aspx?{0}={1}", UrlConstant.ID, TargetContact.ID)); } InitPrivatePanel(); if (TargetContact != null) { HavePermission = CRMSecurity.IsAdmin || TargetContact.CreateBy == SecurityContext.CurrentAccount.ID; } else { HavePermission = true; } }
private async void start() { Thread.CurrentThread.Name = "Sending " + SourceFile.Name; Running = true; try { Client = new TcpClient(); if (!SourceFile.Exists) { throw new FileNotFoundException("File does not exist"); } if (await TargetContact.Ping() < 0) { throw new UnaccesableRemoteClientException(TargetContact.IP); } status("Connecting to " + TargetContact.IP + "..."); // Gets free port Port = port(TargetContact.IP); if (Port == -1) { throw new IPBannedException(TargetContact); } await Dispatcher.BeginInvoke(new Action(setBasicLabelsWithPort)); // Connect status("Connecting to " + TargetContact.IP + ":" + Port.ToString() + "..."); await Dispatcher.BeginInvoke(new Action(() => StopButton.IsEnabled = false)); await Dispatcher.BeginInvoke(new Action(() => DeleteButton.IsEnabled = false)); Client.Connect(TargetContact.IP, Port); status("Sending basic informations..."); Client.Client.Send(Helpers.GetBytes(SourceFile.Name, sizeof(char) * 128)); Client.Client.Send(BitConverter.GetBytes(SourceFile.Length)); Client.Client.Send(Helpers.GetBytes(SenderName, sizeof(char) * 128)); await Dispatcher.BeginInvoke(new Action(() => StopButton.IsEnabled = true)); status("Waiting for opposite side..."); byte[] continueBuffer = new byte[sizeof(bool)]; Client.Client.Receive(continueBuffer); if (!BitConverter.ToBoolean(continueBuffer, 0)) { throw new SendingRefusedException("Opposite side declined receiving this file"); } FileStream stream = File.OpenRead(SourceFile.FullName); status("Sending data..."); Stopwatch totalWatch = Stopwatch.StartNew(); Stopwatch secondWatch = Stopwatch.StartNew(); long size = SourceFile.Length; int sentBytes; byte[] sentData = new byte[PacketSize]; long totalSentBytes = 0; long lastSecondBytes = 0; while ((sentBytes = stream.Read(sentData, 0, sentData.Length)) > 0) { // Send data Client.Client.Send(sentData); totalSentBytes += sentBytes; lastSecondBytes += sentBytes; Dispatcher.Invoke(() => updateProgress(totalSentBytes, size)); if (secondWatch.ElapsedMilliseconds > 1000) { // Runned every second if (!Running) { throw new InterruptedByUserException(); } secondWatch.Restart(); Dispatcher.Invoke(() => updateSpeedAndTime(totalWatch.Elapsed.TotalMilliseconds, totalSentBytes, size, lastSecondBytes)); lastSecondBytes = 0; } } totalWatch.Stop(); secondWatch.Stop(); // Gets information from receiver if it wants MD5 sum verification byte[] verifyMD5Buffer = new byte[sizeof(bool)]; Client.Client.Receive(verifyMD5Buffer); if (BitConverter.ToBoolean(verifyMD5Buffer, 0)) { status("Generating MD5 sum..."); using (stream = File.OpenRead(SourceFile.FullName)) { using (MD5 md5 = MD5.Create()) { byte[] md5Hash = md5.ComputeHash(stream); status("Sending MD5 sum..."); Client.Client.Send(md5Hash); } } } successfullyCompleted(); } catch (SocketException e) { status("Sending was refused by opposite side"); Console.WriteLine(e.Message); } catch (InterruptedByUserException e) { status(e.Message); Console.WriteLine(e.Message); } catch (SendingRefusedException e) { status(e.Message); Console.WriteLine(e.Message); } catch (FileNotFoundException e) { status("Source file does not exist"); Console.WriteLine(e.Message); } catch (UnaccesableRemoteClientException e) { status(e.Message); Console.WriteLine(e.Message); } catch (IPBannedException e) { status(e.Message); Console.WriteLine(e.Message); } finally { Completed(this); Stop(); Client.Close(); Dispatcher.Invoke(new Action(() => DeleteButton.IsEnabled = true)); if (Done) { Dispatcher.Invoke(new Action(() => StartButton.IsEnabled = false)); } } }
protected void Page_Load(object sender, EventArgs e) { MobileVer = ASC.Web.Core.Mobile.MobileDetector.IsRequestMatchesMobile(this.Context); Utility.RegisterTypeForAjax(GetType()); Utility.RegisterTypeForAjax(typeof(AjaxProHelper)); _mergePanelPopup.Options.IsPopup = true; List <CustomField> data; if (TargetContact is Company) { data = Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Company, Convert.ToInt32(UrlParameters.ID), false); } else { data = Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Person, Convert.ToInt32(UrlParameters.ID), false); } var networks = Global.DaoFactory.GetContactInfoDao().GetList(TargetContact.ID, null, null, null).ConvertAll( n => new { Data = n.Data.HtmlEncode(), InfoType = n.InfoType, IsPrimary = n.IsPrimary, CategoryName = n.CategoryToString(), InfoTypeLocalName = n.InfoType.ToLocalizedString() }); InitTagControl(); ExecHistoryView(TargetContact.ID); ExecTasksView(); ExecFilesView(); ExecDealsView(TargetContact.ID); if (TargetContact is Company) { ExecPeopleContainerView(TargetContact.ID); } else { ContactsTab.Visible = false; } ContactsToMerge = Global.DaoFactory.GetContactDao().GetContactsByPrefix(TargetContact.GetTitle(), 0, 0, 30).Where(n => n.ID != TargetContact.ID).ToList(); InitMergeSelector(); String json; using (var stream = new MemoryStream()) { var serializer = new DataContractJsonSerializer(data.GetType()); serializer.WriteObject(stream, data); json = Encoding.UTF8.GetString(stream.ToArray()); } var listItems = Global.DaoFactory.GetListItemDao().GetItems(ListType.ContactStatus); var script = String.Format( @"<script type='text/javascript'> var customFieldList = {0}; var contactNetworks = {1}; var sliderListItems = {2}; var imgExst = {3}; </script>", json, JavaScriptSerializer.Serialize(networks), JavaScriptSerializer.Serialize(new { ID = TargetContact.ID, Status = TargetContact.StatusID, PositionsCount = listItems.Count, Items = listItems }), JavaScriptSerializer.Serialize(FileUtility.ImageExts) ); Page.ClientScript.RegisterStartupScript(typeof(ContactDetailsView), Guid.NewGuid().ToString(), script); _ctrlLoadPhotoContainer.Options.IsPopup = true; _ctrlImgDefaultAvatarSmall.ImageUrl = ContactPhotoManager.GetMediumSizePhoto(0, (TargetContact is Company)); }