Exemple #1
0
        /// <summary>
        /// Formats the specified address in multi line format. Do not pass null for any parameters.
        /// </summary>
        public static string GetAddressWithNewLines(string deliveryAddress, string city, string stateAbbreviation, string zipCode, string addOnCode)
        {
            // The add on code means nothing without the ZIP Code.
            if (zipCode.Length == 0)
            {
                addOnCode = "";
            }

            return(StringTools.ConcatenateWithDelimiter(Environment.NewLine,
                                                        deliveryAddress,
                                                        StringTools.ConcatenateWithDelimiter(" ",
                                                                                             StringTools.ConcatenateWithDelimiter(", ", city, stateAbbreviation),
                                                                                             StringTools.ConcatenateWithDelimiter("-", zipCode, addOnCode))));
        }
        internal static void SendHealthCheckEmail(string appFullName)
        {
            var message = new EmailMessage();

            var body           = new StringBuilder();
            var tenGibibytes   = 10 * Math.Pow(1024, 3);
            var freeSpaceIsLow = false;

            foreach (var driveInfo in DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed))
            {
                var bytesFree = driveInfo.TotalFreeSpace;
                freeSpaceIsLow = freeSpaceIsLow || bytesFree < tenGibibytes;
                body.AppendLine("{0} free on {1} drive.".FormatWith(FormattingMethods.GetFormattedBytes(bytesFree), driveInfo.Name));
            }

            message.Subject  = StringTools.ConcatenateWithDelimiter(" ", "Health check", freeSpaceIsLow ? "and WARNING" : "", "from " + appFullName);
            message.BodyHtml = body.ToString().GetTextAsEncodedHtml();
            EmailStatics.SendDeveloperNotificationEmail(message);
        }
 /// <summary>
 /// Creates an exception with the specified messages.
 /// </summary>
 public MultiMessageApplicationException(params string[] messages) : base(StringTools.ConcatenateWithDelimiter(Environment.NewLine, messages))
 {
     this.messages = messages;
 }