static public Guid SubmitSelfie(ISelfie capturedselfie) { IAppConfig ac = GetAppConfig(); Lead theLead = new Lead { Subject = "Event Encounter with " + capturedselfie.Firstname + " " + capturedselfie.Lastname, FirstName = capturedselfie.Firstname, LastName = capturedselfie.Lastname, EMailAddress1 = capturedselfie.Email, Telephone1 = capturedselfie.Phone, Description = capturedselfie.Regarding }; _serviceProxy = GetServiceProxy(ac); try { using (_serviceProxy) { _serviceProxy.EnableProxyTypes(); _service = GetService(ac); _service = (IOrganizationService)_serviceProxy; _orgContext = new OrganizationServiceContext(_service); theLead.Id = _service.Create(theLead); capturedselfie.Leadid = theLead.Id; AttachImage(_serviceProxy, capturedselfie); } } catch (Exception) { throw; } return(theLead.Id); }
static void Main() { IAppConfig ac = GetAppConfig(); ISelfie selfie = new ISelfie(); Program._service = GetService(ac); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Capture()); }
private void ButtonSubmit_Click(object sender, EventArgs e) { this.labelBanner.Visible = false; this.toolStripStatusLabelNotConnect.Text = "Build the Selfie"; ISelfie selfie = new ISelfie(); selfie.Firstname = this.textBoxFirstName.Text; selfie.Lastname = this.textBoxLastName.Text; selfie.Email = this.textBoxEmail.Text; selfie.Phone = this.textBoxPhone.Text; selfie.Regarding = this.richTextBoxRegarding.Text; selfie.Bitmap = new Bitmap(pictureBoxSelfie.Image); this.toolStripStatusLabelNotConnect.Text = "Connecting"; selfie.Leadid = Program.SubmitSelfie(selfie); this.toolStripStatusLabelNotConnect.Text = selfie.Leadid.ToString(); this.labelBanner.Text = "Submitted"; this.labelBanner.Visible = false; }
static public void AttachImage(OrganizationServiceProxy serviceProxy, ISelfie selfie) { string entitytype = "lead"; Annotation a = new Annotation { Subject = "Event Encounter: " + selfie.Email, FileName = "SELFIE_" + selfie.Email + "_.jpeg", MimeType = "image/jpeg", ObjectId = new EntityReference(entitytype, selfie.Leadid), NoteText = "Event Encounter: " + selfie.Email }; using (var ms = new MemoryStream()) { using (var bitmap = new Bitmap(selfie.Bitmap)) { bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); var bitmap64 = Convert.ToBase64String(ms.GetBuffer()); a.DocumentBody = bitmap64; } } serviceProxy.Create(a); }