Beispiel #1
0
        public void InitWPIFeeds(int serverId)
        {
            var wpiSettings = SystemController.GetSystemSettings(SystemSettings.WPI_SETTINGS);


            List <string> feeds = new List <string>();

            // Microsoft feed
            string mainFeedUrl = wpiSettings[SystemSettings.WPI_MAIN_FEED_KEY];

            if (string.IsNullOrEmpty(mainFeedUrl))
            {
                mainFeedUrl = WebPlatformInstaller.MAIN_FEED_URL;
            }
            feeds.Add(mainFeedUrl);

            // Zoo Feed
            feeds.Add(WebPlatformInstaller.ZOO_FEED);


            // additional feeds
            string additionalFeeds = wpiSettings[SystemSettings.FEED_ULS_KEY];

            if (!string.IsNullOrEmpty(additionalFeeds))
            {
                feeds.AddRange(additionalFeeds.Split(';'));
            }

            OperatingSystemController.InitWPIFeeds(serverId, string.Join(";", feeds));
        }
Beispiel #2
0
 public int SetSystemSettings(string settingsName, SystemSettings settings)
 {
     return(SystemController.SetSystemSettings(
                settingsName,
                settings
                ));
 }
Beispiel #3
0
        public static bool CheckIsTwilioEnabled()
        {
            var settings = SystemController.GetSystemSettingsActive(SystemSettings.TWILIO_SETTINGS, false);

            return(settings != null &&
                   !string.IsNullOrEmpty(settings.GetValueOrDefault(SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty)) &&
                   !string.IsNullOrEmpty(settings.GetValueOrDefault(SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty)) &&
                   !string.IsNullOrEmpty(settings.GetValueOrDefault(SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty)));
        }
Beispiel #4
0
 public int SetupControlPanelAccounts(string passwordA, string passwordB, string ip)
 {
     return(SystemController.SetupControlPanelAccounts(passwordA, passwordB, ip));
 }
Beispiel #5
0
 public bool GetSystemSetupMode()
 {
     return(SystemController.GetSystemSetupMode());
 }
Beispiel #6
0
 public bool CheckIsTwilioEnabled()
 {
     return(SystemController.CheckIsTwilioEnabled());
 }
Beispiel #7
0
 public SystemSettings GetSystemSettingsActive(string settingsName, bool decrypt)
 {
     return(SystemController.GetSystemSettingsActive(settingsName, decrypt));
 }
Beispiel #8
0
 public SystemSettings GetSystemSettings(string settingsName)
 {
     return(SystemController.GetSystemSettings(settingsName));
 }
 public DataSet GetThemeSetting(int ThemeID, string SettingsName)
 {
     return(SystemController.GetThemeSetting(ThemeID, SettingsName));
 }
 public DataSet GetThemeSettings(int ThemeID)
 {
     return(SystemController.GetThemeSettings(ThemeID));
 }
 public DataSet GetThemes()
 {
     return(SystemController.GetThemes());
 }
Beispiel #12
0
        public static int SendMessage(string from, string to, string bcc, string subject, string body,
                                      MailPriority priority, bool isHtml, Attachment[] attachments)
        {
            // Command line argument must the the SMTP host.
            SmtpClient client = new SmtpClient();

            // load SMTP client settings
            SystemSettings settings = SystemController.GetSystemSettingsInternal(
                SystemSettings.SMTP_SETTINGS,
                true
                );

            client.Host = settings["SmtpServer"];
            client.Port = settings.GetInt("SmtpPort");
            if (!String.IsNullOrEmpty(settings["SmtpUsername"]))
            {
                client.Credentials = new NetworkCredential(
                    settings["SmtpUsername"],
                    settings["SmtpPassword"]
                    );
            }

            if (!String.IsNullOrEmpty(settings["SmtpEnableSsl"]))
            {
                client.EnableSsl = Utils.ParseBool(settings["SmtpEnableSsl"], false);
            }

            // create message
            MailMessage message = new MailMessage(from, to);

            message.Body            = body;
            message.BodyEncoding    = System.Text.Encoding.UTF8;
            message.IsBodyHtml      = isHtml;
            message.Subject         = subject;
            message.SubjectEncoding = System.Text.Encoding.UTF8;
            if (!String.IsNullOrEmpty(bcc))
            {
                message.Bcc.Add(bcc);
            }
            message.Priority = priority;

            if (attachments != null)
            {
                foreach (Attachment current in attachments)
                {
                    message.Attachments.Add(current);
                }
            }

            // send message
            try
            {
                client.Send(message);

                return(0);
            }
            catch (SmtpException ex)
            {
                switch (ex.StatusCode)
                {
                case SmtpStatusCode.BadCommandSequence: return(BusinessErrorCodes.SMTP_BAD_COMMAND_SEQUENCE);

                case SmtpStatusCode.CannotVerifyUserWillAttemptDelivery: return(BusinessErrorCodes.SMTP_CANNOT_VERIFY_USER_WILL_ATTEMPT_DELIVERY);

                case SmtpStatusCode.ClientNotPermitted: return(BusinessErrorCodes.SMTP_CLIENT_NOT_PERMITTED);

                case SmtpStatusCode.CommandNotImplemented: return(BusinessErrorCodes.SMTP_COMMAND_NOT_IMPLEMENTED);

                case SmtpStatusCode.CommandParameterNotImplemented: return(BusinessErrorCodes.SMTP_COMMAND_PARAMETER_NOT_IMPLEMENTED);

                case SmtpStatusCode.CommandUnrecognized: return(BusinessErrorCodes.SMTP_COMMAND_UNRECOGNIZED);

                case SmtpStatusCode.ExceededStorageAllocation: return(BusinessErrorCodes.SMTP_EXCEEDED_STORAGE_ALLOCATION);

                case SmtpStatusCode.GeneralFailure: return(BusinessErrorCodes.SMTP_GENERAL_FAILURE);

                case SmtpStatusCode.InsufficientStorage: return(BusinessErrorCodes.SMTP_INSUFFICIENT_STORAGE);

                case SmtpStatusCode.LocalErrorInProcessing: return(BusinessErrorCodes.SMTP_LOCAL_ERROR_IN_PROCESSING);

                case SmtpStatusCode.MailboxBusy: return(BusinessErrorCodes.SMTP_MAILBOX_BUSY);

                case SmtpStatusCode.MailboxNameNotAllowed: return(BusinessErrorCodes.SMTP_MAILBOX_NAME_NOTALLOWED);

                case SmtpStatusCode.MailboxUnavailable: return(BusinessErrorCodes.SMTP_MAILBOX_UNAVAILABLE);

                case SmtpStatusCode.MustIssueStartTlsFirst: return(BusinessErrorCodes.SMTP_MUST_ISSUE_START_TLS_FIRST);

                case SmtpStatusCode.ServiceClosingTransmissionChannel: return(BusinessErrorCodes.SMTP_SERVICE_CLOSING_TRANSMISSION_CHANNEL);

                case SmtpStatusCode.ServiceNotAvailable: return(BusinessErrorCodes.SMTP_SERVICE_NOT_AVAILABLE);

                case SmtpStatusCode.SyntaxError: return(BusinessErrorCodes.SMTP_SYNTAX_ERROR);

                case SmtpStatusCode.TransactionFailed: return(BusinessErrorCodes.SMTP_TRANSACTION_FAILED);

                case SmtpStatusCode.UserNotLocalTryAlternatePath: return(BusinessErrorCodes.SMTP_USER_NOT_LOCAL_TRY_ALTERNATE_PATH);

                case SmtpStatusCode.UserNotLocalWillForward: return(BusinessErrorCodes.SMTP_USER_NOT_LOCAL_WILL_FORWARD);

                default: return(BusinessErrorCodes.SMTP_UNKNOWN_ERROR);
                }
            }
            finally
            {
                // Clean up.
                message.Dispose();
            }
        }
 public static SystemSettings GetFileManagerSettings()
 {
     return(SystemController.GetSystemSettingsInternal(SystemSettings.FILEMANAGER_SETTINGS, false));
 }
        public override void DoWork()
        {
            BackgroundTask topTask = TaskManager.TopTask;

            // get input parameters
            string mailTo           = (string)topTask.GetParamValue("MAIL_TO");
            int    auditLogSeverity = Utils.ParseInt((string)topTask.GetParamValue("AUDIT_LOG_SEVERITY"), -1);
            string auditLogSource   = (string)topTask.GetParamValue("AUDIT_LOG_SOURCE");
            string auditLogTask     = (string)topTask.GetParamValue("AUDIT_LOG_TASK");
            string auditLogDate     = (string)topTask.GetParamValue("AUDIT_LOG_DATE");
            int    showExecutionLog = Utils.ParseInt((string)topTask.GetParamValue("SHOW_EXECUTION_LOG"), 0);

            // check input parameters
            if (String.IsNullOrEmpty(mailTo))
            {
                TaskManager.WriteWarning("Specify 'Mail To' task parameter");
                return;
            }

            string         mailFrom = null;
            SystemSettings settings = SystemController.GetSystemSettingsInternal(SystemSettings.SMTP_SETTINGS, false);

            if (settings != null)
            {
                mailFrom = settings["SmtpUsername"];
            }
            if (String.IsNullOrEmpty(mailFrom))
            {
                TaskManager.WriteWarning("You need to configure SMTP settings first");
                return;
            }

            DateTime logStart, logEnd;

            switch (auditLogDate)
            {
            case "today":
                logStart = DateTime.Now;
                logEnd   = DateTime.Now;
                break;

            case "yesterday":
                logStart = DateTime.Now.AddDays(-1);
                logEnd   = DateTime.Now.AddDays(-1);
                break;

            case "schedule":
            default:
                logEnd = DateTime.Now;
                ScheduleInfo schedule = SchedulerController.GetSchedule(topTask.ScheduleId);
                switch (schedule.ScheduleTypeId)
                {
                case "Daily":
                    logStart = DateTime.Now.AddDays(-1);
                    break;

                case "Weekly":
                    logStart = DateTime.Now.AddDays(-7);
                    break;

                case "Monthly":
                    logStart = DateTime.Now.AddMonths(-1);
                    break;

                case "Interval":
                    logStart = DateTime.Now.AddSeconds(-schedule.Interval);
                    break;

                case "OneTime":
                default:
                    logStart = DateTime.Now;
                    break;
                }
                break;
            }

            string mailSubject = "Audit Log Report (" + logStart.ToString("MMM dd, yyyy") + " - " + logEnd.ToString("MMM dd, yyyy") + ")";

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html><head><style>");
            sb.AppendLine("table, th, td { border: 1px solid black; border-collapse: collapse; }");
            sb.AppendLine("th, td { padding: 5px; }");
            sb.AppendLine("th { text-align: left; }");
            sb.AppendLine("</style></head><body>");
            sb.AppendLine("<h2>" + mailSubject + "</h2>");
            sb.AppendFormat("<h3>Source: {0}, Task: {1}, Severity: {2}</h3>", String.IsNullOrEmpty(auditLogSource) ? "All" : auditLogSource,
                            String.IsNullOrEmpty(auditLogTask) ? "All" : auditLogTask, GetAuditLogRecordSeverityName(auditLogSeverity));

            DataTable logs = AuditLog.GetAuditLogRecordsPaged(topTask.EffectiveUserId, 0, 0, null, logStart, logEnd,
                                                              auditLogSeverity, auditLogSource, auditLogTask, "", 0, Int32.MaxValue).Tables[1];

            sb.AppendLine("<p>");
            if (logs.Rows.Count == 0)
            {
                sb.AppendLine("Audit Log is empty.");
            }
            else
            {
                sb.AppendLine("<table>");
                sb.Append("<tr><th>Started</th><th>Finished</th><th>Severity</th><th>Username</th><th>Source</th><th>Task</th><th>Item-Name</th>");
                if (showExecutionLog == 1)
                {
                    sb.AppendLine("<th>Execution-Log</th></tr>");
                }
                else
                {
                    sb.AppendLine("</tr>");
                }
                foreach (DataRow log in logs.Rows)
                {
                    sb.AppendLine("<tr>");
                    // Started
                    sb.AppendFormat("<td>{0}</td>", log["StartDate"].ToString());
                    // Finished
                    sb.AppendFormat("<td>{0}</td>", log["FinishDate"].ToString());
                    // Severity
                    sb.AppendFormat("<td>{0}</td>", GetAuditLogRecordSeverityName((int)log["SeverityID"]));
                    // Username
                    sb.AppendFormat("<td>{0}</td>", log["Username"]);
                    // Source
                    sb.AppendFormat("<td>{0}</td>", log["SourceName"]);
                    // Task
                    sb.AppendFormat("<td>{0}</td>", log["TaskName"]);
                    // Item-Name
                    sb.AppendFormat("<td>{0}</td>", log["ItemName"]);
                    // Execution-Log
                    if (showExecutionLog == 1)
                    {
                        string executionLog = FormatPlainTextExecutionLog(log["ExecutionLog"].ToString());
                        sb.AppendFormat("<td>{0}</td>", executionLog);
                    }
                    sb.AppendLine("</tr>");
                }
                sb.AppendLine("</table>");
            }
            sb.AppendLine("</p></body></html>");

            // send mail message
            int res = MailHelper.SendMessage(mailFrom, mailTo, mailSubject, sb.ToString(), true);

            if (res != 0)
            {
                TaskManager.WriteError("SMTP Error. Code: " + res.ToString());
            }
        }