Ejemplo n.º 1
0
        private void RunScheduledReports(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            if (reportsInProcess)
            {
                return;
            }

            reportsInProcess = true;

            try
            {
                string schedulingLogs = "";
                using (CustomWebClient client = new CustomWebClient())
                {
                    if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass))
                    {
                        NetworkCredential credentials = new NetworkCredential(user, pass);
                        client.UseDefaultCredentials = false;
                        client.Credentials           = credentials;
                    }
                    else
                    {
                        client.UseDefaultCredentials = true;
                    }
                    string url = string.Format("{0}?run_scheduled_reports={1}{2}{3}{4}",
                                               rsPath,
                                               timePeriod,
                                               string.IsNullOrEmpty(ssl) ? "" : ("&ssl=" + ssl),
                                               string.IsNullOrEmpty(tenants) ? "" : ("&tenants=" + tenants),
                                               string.IsNullOrEmpty(izUser) ? "" : "&izUser="******"" : "&izPassword="******"<br>", Environment.NewLine).Replace("<br/>", Environment.NewLine);
                    networkStream.Close();
                }
                EventLog.WriteEntry(ServiceName, "Scheduling operation succeeded. Log which can be parsed: " + schedulingLogs, EventLogEntryType.Information);
            }
            catch (Exception e)
            {
                EventLog.WriteEntry(ServiceName, "Scheduling operation failed: " + e.Message, EventLogEntryType.Error);
            }

            reportsInProcess = false;
        }
Ejemplo n.º 2
0
        private void RunScheduledReports(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            timer.Stop();
            string executeResult;

            try
            {
                string schedulingLogs = "";
                using (CustomWebClient client = new CustomWebClient())
                {
                    if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass))
                    {
                        NetworkCredential credentials = new NetworkCredential(user, pass);
                        client.UseDefaultCredentials = false;
                        client.Credentials           = credentials;
                    }
                    else
                    {
                        client.UseDefaultCredentials = true;
                    }
                    string url = string.Format("{0}?run_scheduled_reports={1}{2}{3}{4}",
                                               rsPath,
                                               timePeriod,
                                               string.IsNullOrEmpty(tenants) ? "" : ("&tenants=" + tenants),
                                               string.IsNullOrEmpty(izUser) ? "" : "&izUser="******"" : "&izPassword="******"<br>", Environment.NewLine).Replace("<br/>", Environment.NewLine);
                    networkStream.Close();
                }
                executeResult = "Scheduling operation succeeded. Log which can be parsed: " + schedulingLogs;
            }
            catch (Exception e)
            {
                executeResult = "Scheduling operation failed: " + e.Message;
            }
            Log(executeResult);
            timer.Start();
        }