/// <summary>
        /// Converts the Model's Message object in a local DisplayedMessage object
        /// </summary>
        /// <param name="message">The message to convert</param>
        /// <param name="messageType">The message to convert</param>
        /// <returns>DisplayedMessage version of the message</returns>
        private DisplayedMessage ModelMessageToDisplayedMessage(Message message, MessageRecipientsTypes messageType)
        {
            // Make sure input is correct
            if (message == null)
            {
                throw new ArgumentNullException("Arguement 'message' cannot be null!");
            }

            DisplayedMessage displayedMessage = new DisplayedMessage();

            // Get the name of the sender (unless it is an automatic message)
            if (message.senderID != null)
            {
                displayedMessage.SenderName = message.SenderPerson.firstName + " " + message.SenderPerson.lastName;
            }
            else
            {
                displayedMessage.SenderName = "הודעה אוטומטית";
            }

            displayedMessage.RecipientName   = GetRecipientName(message, messageType);
            displayedMessage.Title           = message.title;
            displayedMessage.MessageDateTime = message.date;
            displayedMessage.Details         = message.data;

            return(displayedMessage);
        }
Ejemplo n.º 2
0
        public CmdOutput Report(CmdInput ci)
        {
            var options = ci.options as Email_Report_Options;

            try
            {
                List <Attachment> attachments = new List <Attachment>();
                string            prefix      = Guid.NewGuid().ToString().Substring(0, 8);
                string            body        = DisplayedMessage.GetMessage(new DisplayedMessageOption()
                {
                    SkipHead           = 1,
                    RemoveTail         = 1,
                    IncludeStatusImage = false,
                    IncludeTaskName    = options.IncludeTaskName,
                    IncludeTimeStamp   = options.IncludeTimeStamp,
                    IncludeCmd         = options.IncludeCmd
                }, true, prefix, attachments);
                List <string> to = options.To.Split(';').ToList();
                EmailUtil.SendEmail(to, options.Subject, body, options.STMP, options.Port, options.User, options.Password, options.From, null, "HTML", null, attachments);
            }
            catch (Exception ex)
            {
                return(new CmdOutput(false, CmdRunState.EXITWITHERROR, ci.MessageId, ex.Message));
            }
            return(new CmdOutput(true, CmdRunState.FINISHED, ci.MessageId, "Sent report successfully"));
        }
Ejemplo n.º 3
0
        public CmdOutput Save(CmdInput ci)
        {
            var    options = ci.options as Command_Save_Options;
            string prefix  = "cmdhistory";
            string suffix  = "txt";

            if (options.IncludeOutput)
            {
                prefix = "cmdwithoutput";
                suffix = "html";
            }
            StringBuilder sb = new StringBuilder();

            if (options.IncludeOutput)
            {
                sb.Append(DisplayedMessage.GetMessage(new DisplayedMessageOption()
                {
                    RemoveTail = 1
                }));
            }
            else
            {
                foreach (var c in GlobalSettings.CmdHistory)
                {
                    sb.AppendLine(c);
                }
            }

            var f = Common.CommFuns.SaveStringToFile(sb.ToString(), prefix, suffix);

            if (options.ViewOutput)
            {
                System.Diagnostics.Process.Start(f);
            }
            return(new CmdOutput(true, CmdRunState.FINISHED, ci.MessageId, $"Saved as {f}"));
        }
Ejemplo n.º 4
0
 public static string GetMessage()
 {
     return(DisplayedMessage.GetMessage(new DisplayedMessageOption()));
 }