Esempio n. 1
0
        private void SendMail()
        {
            try
            {
                var sb = new StringBuilder();
                sb.AppendLine(BugReportResources.MessageToUser);
                sb.AppendLine("1. ");
                sb.AppendLine("2. ");
                sb.AppendLine("... ");
                sb.AppendLine(Environment.NewLine);
                sb.AppendLine(string.Format("{{cut {0}}}", BugReportResources.TechnicalInfo));
                sb.AppendLine(BugReportResources.Separator01);  //"---------------------------------------------------------"
                sb.AppendLine(BugReportResources.DontEditThis); //"Внимание! Не редактируйте информацию, приведенную ниже."
                sb.AppendLine(BugReportResources.Separator01);

                sb.AppendLine(string.Format("{0, -27}{1}", BugReportResources.Version, AssemblyAttributeAccessors.GetAssemblyFileVersion(Assembly.GetEntryAssembly())));

                sb.AppendLine(string.Format("{0, -24}{1}", BugReportResources.DotNetVersion, Environment.Version));

                sb.AppendLine(string.Format("{0, -24}{1}", BugReportResources.User, string.Concat(Environment.UserDomainName, "\\", Environment.UserName)));

                var machineName = Environment.MachineName;
                var client      = WMSEnvironment.Instance.ClientCode;
                if (string.IsNullOrEmpty(client))
                {
                    client = machineName;
                }
                if (client != machineName)
                {
                    sb.AppendLine(string.Format("{0, -24}{1}", BugReportResources.TerminalServer, machineName));
                }
                sb.AppendLine(string.Format("{0, -35}{1}", BugReportResources.ComputerName, Environment.MachineName));

                sb.AppendLine(string.Format("{0, -40}{1}", BugReportResources.OsVersion, Environment.OSVersion.VersionString));

                sb.AppendLine(string.Format("{0, -30}{1}", BugReportResources.Time, DateTime.Now));

                sb.AppendLine(string.Empty);
                if (SelectedItem != null)
                {
                    sb.AppendLine(string.Format("{0}: {1}", BugReportResources.MandantCode, SelectedItem.MandantCode));
                }

                if (StaticAdditionalParams.Count > 0)
                {
                    foreach (var param in StaticAdditionalParams)
                    {
                        sb.AppendLine(string.Format("{0}: {1}", param.Key, param.Value));
                    }
                }

                if ((CurrentAdditionalParams != null) && (CurrentAdditionalParams.Count > 0))
                {
                    sb.AppendLine(string.Empty);
                    foreach (var param in CurrentAdditionalParams)
                    {
                        sb.AppendLine(string.Format("{0}: {1}", param.Key, param.Value));
                    }
                }
                sb.AppendLine(string.Empty);
                sb.AppendLine(BugReportResources.ExceptionMessage).AppendLine(Message ?? string.Empty);
                sb.AppendLine(string.Format("{0}:{1}{2}", BugReportResources.Exception, Environment.NewLine, Exception));
                sb.AppendLine("{cut}");

                Mapi.SendMail(
                    HelpServiceMail,
                    string.Empty,
                    string.Format(ErrorMessageSubjectTemplate, AssemblyAttributeAccessors.AssemblyProduct),
                    sb.ToString(),
                    Attachments,
                    true);
            }
            catch (Exception ex)
            {
                Close();
                //ShowError("Невозможно отправить письмо в службу технической поддержки", ex, false);
                ShowError(message: BugReportResources.UnableSendEmailToSupport, ex: ex, additionalParams: null,
                          attachments: null, isBtnSandMailEnable: false,
                          mandantCode: SelectedItem == null ? null : SelectedItem.MandantCode);
            }
        }