Example #1
0
        public static async void ShowErrorMsg(ErrorCodes errorCode, string host)
        {
            var lastErrors = await BasePage.session.GetErrors(errorCode);

            string errMsg = UtilDisplay.GetFormattedErrorCode(errorCode, lastErrors);
            string hyperlink;

            if (host != null && host.Contains("gmail"))
            {
                hyperlink = "https://www.uniconta.com/unipedia-global/gmail-settings-to-send-mail-in-uniconta/";
            }
            else if (BasePage.session.User._Language == (byte)Uniconta.Common.Language.da)
            {
                hyperlink = "https://www.uniconta.com/da/unipedia/mail_server/";
            }
            else
            {
                hyperlink = "https://www.uniconta.com/unipedia-global/mail-server-set-up/";
            }
#if !SILVERLIGHT
            UnicontaHyperLinkMessageBox.Show(errMsg, hyperlink,
                                             lastErrors != null && lastErrors.Length > 0 ? Uniconta.ClientTools.Localization.lookup("Error") : Uniconta.ClientTools.Localization.lookup("Message"));
#else
            errMsg = string.Concat(errMsg, "\r\n", hyperlink);
            UnicontaMessageBox.Show(errMsg, lastErrors != null && lastErrors.Length > 0 ? Uniconta.ClientTools.Localization.lookup("Error") :
                                    Uniconta.ClientTools.Localization.lookup("Message"), MessageBoxButton.OK);
#endif
        }
Example #2
0
        void SendInvoice(IEnumerable <CreditorInvoiceLocal> invoiceEmails)
        {
            int icount = invoiceEmails.Count();

            UnicontaClient.Pages.CWSendInvoice cwSendInvoice = new UnicontaClient.Pages.CWSendInvoice();
#if !SILVERLIGHT
            cwSendInvoice.DialogTableId = 2000000063;
#endif
            cwSendInvoice.Closed += async delegate
            {
                if (cwSendInvoice.DialogResult == true)
                {
                    busyIndicator.IsBusy      = true;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    InvoiceAPI    Invapi = new InvoiceAPI(api);
                    List <string> errors = new List <string>();

                    var sendInBackgroundOnly = CWSendInvoice.sendInBackgroundOnly;
                    foreach (var inv in invoiceEmails)
                    {
                        var errorCode = await Invapi.SendInvoice(inv, cwSendInvoice.Emails, cwSendInvoice.sendOnlyToThisEmail, sendInBackgroundOnly);

                        sendInBackgroundOnly = true;
                        if (errorCode != ErrorCodes.Succes)
                        {
                            var standardError = await api.session.GetErrors(errorCode);

                            var stformattedErr = UtilDisplay.GetFormattedErrorCode(errorCode, standardError);
                            var errorStr       = string.Format("{0}({1}): \n{2}", Uniconta.ClientTools.Localization.lookup("InvoiceNumber"), inv.InvoiceNum,
                                                               Uniconta.ClientTools.Localization.lookup(stformattedErr));
                            errors.Add(errorStr);
                        }
                    }

                    busyIndicator.IsBusy = false;
                    if (errors.Count == 0)
                    {
                        UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("SendEmailMsgOBJ"), icount == 1 ? Uniconta.ClientTools.Localization.lookup("Invoice") :
                                                              Uniconta.ClientTools.Localization.lookup("Invoices")), Uniconta.ClientTools.Localization.lookup("Message"));
                    }
                    else
                    {
                        CWErrorBox errorDialog = new CWErrorBox(errors.ToArray(), true);
                        errorDialog.Show();
                    }
                }
            };
            cwSendInvoice.Show();
        }