コード例 #1
0
        private async void ExecuteWizardFinishingAsync(object sender, FinishingEventArgs e)
        {
            try
            {
                // The values indicated in the wizard are loaded
                List <Aliquo.Core.Models.DataField> result = (List <Aliquo.Core.Models.DataField>)e.Result;
                string emailTo = Aliquo.Core.Data.FindField(result, "Email").Value.ToString();
                string subject = Aliquo.Core.Data.FindField(result, "Subject").Value.ToString();
                string message = Aliquo.Core.Data.FindField(result, "Message").Value.ToString();

                List <long> listId = new List <long> {
                    idNote
                };
                string file = await this.Host.Management.CreatePdfDocumentAsync(7, listId);

                // We prepare the sending object of e-mail
                Aliquo.Core.Tools.SendEmail email = new Aliquo.Core.Tools.SendEmail();
                email.AddConfig(configEmail);
                email.ToAdd(emailTo);
                email.Subject = subject;
                email.Body    = message;
                email.AttachmentsAdd(file, "order.pdf");

                Exception exceptionResult = null;
                if (email.Send(ref exceptionResult))
                {
                    // We notify the user that the e-mail was sent
                    this.Host.Management.Views.ShowNotification(new Aliquo.Core.Models.Notification
                    {
                        HideStyle = Aliquo.Core.NotificationHideStyle.AutoClose,
                        Title     = PlugInTitle,
                        Message   = String.Format("The e-mail was sent to {0}", emailTo)
                    });
                }
                else
                {
                    // In case of error it is shown
                    Message.Show(exceptionResult.Message, PlugInTitle, MessageImage.Error);
                }
            }
            catch (HandledException ex)
            {
                throw new HandledException(ex.Message, ex);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
コード例 #2
0
        private async void ExecuteWizardFinishingAsync(object sender, FinishingEventArgs e)
        {
            try
            {
                // The values indicated in the wizard are loaded
                List <Aliquo.Core.Models.DataField> result = (List <Aliquo.Core.Models.DataField>)e.Result;
                string   customerCode = Aliquo.Core.Data.FindField(result, "CustomerCode").Value.ToString();
                DateTime dateNote     = Aliquo.Core.Convert.ValueToDate(Aliquo.Core.Data.FindField(result, "DateNote").Value);
                string   productCode  = Aliquo.Core.Data.FindField(result, "ProductCode").Value.ToString();

                // We create the model to store the data
                Aliquo.Core.Models.Note note = new Aliquo.Core.Models.Note();

                // The collection starts
                note.Lines = new List <Aliquo.Core.Models.Line>();

                // This is the basic information to create a note
                note.Type         = Aliquo.Core.NoteType.SalesOrder;
                note.PropertyCode = customerCode;
                note.Date         = dateNote;

                Aliquo.Core.Models.Line line = new Aliquo.Core.Models.Line
                {
                    Type     = Aliquo.Core.LineType.Product,
                    Code     = productCode,
                    Quantity = 1
                };

                // The line is assigned to the model list
                note.Lines.Add(line);

                // Call the function to create the note
                long id = await Host.Documents.SetNoteAsync(note);

                // Update the list
                this.View.Refresh();
            }
            catch (HandledException ex)
            {
                throw new HandledException(ex.Message, ex);
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }