Esempio n. 1
0
        private static string GetPostMessage(IPostToDownload_v1 post, string message, string file = null, string downloadLink = null, bool formated = true)
        {
            int messageLength   = 50;
            int printTypeLength = 25;

            if (!formated)
            {
                messageLength   = 0;
                printTypeLength = 0;
            }

            //string formatMessage;
            //if (formated)
            //    formatMessage = "{0,-50}";
            //else
            //    formatMessage = "{0}";
            //string formatPrintType;
            //if (formated)
            //    formatPrintType = "{0,-25}";
            //else
            //    formatPrintType = "{0}";

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0:dd-MM-yyyy HH:mm:ss}", DateTime.Now);
            sb.Append(" - ");
            //sb.AppendFormat("{0,-50}", message);
            sb.Append(message.PadRight(messageLength));
            sb.Append(" - ");
            if (post != null)
            {
                //sb.AppendFormat("{0,-25} - ", post.GetPrintType());
                sb.Append(post.GetPrintType().ToString().PadRight(printTypeLength));
                sb.Append(" - ");
                sb.AppendFormat("\"{0}\"", post.GetTitle());
            }
            else
            {
                sb.Append("(post is null)");
            }
            if (file != null)
            {
                sb.AppendFormat(" - \"{0}\"", file);
            }
            if (post != null)
            {
                sb.AppendFormat(" - \"{0}\"", post.GetDataHttpRequest().Url);
            }
            if (downloadLink != null)
            {
                sb.AppendFormat(" - link \"{0}\"", downloadLink);
            }
            return(sb.ToString());
        }