예제 #1
0
        private void WriteReport(SensorReport seRe)
        {
            seRe.Name = Txb_ReportName.Text;
            string[] words = Txb_SensorId.Text.Split(',');
            seRe.SensorId      = Convert.ToInt32(words[words.Length - 1]);
            seRe.SensorName    = Txb_SensorId.Text;
            seRe.ScriptName    = Cb_ScriptNames.SelectedItem.ToString();
            seRe.TemplateName  = Cb_TemplteNames.SelectedItem.ToString();
            seRe.Average       = (int)Cb_Average.SelectedValue;
            seRe.ClientAddress = Txb_ClientAddress.Text;
            seRe.ClientInfo    = Txb_ClientInfo.Text;
            seRe.HeaderText    = Txb_BillingHeader.Text;
            seRe.FooterText    = Txb_BillingFooter.Text;
            // Percentile
            seRe.HasPercentile = Cb_UsePercentile.Checked;
            seRe.Percentile    = (int)Nud_PercentilePercent.Value;
            seRe.PercentileAvg = (int)Nud_PercentileAvg.Value * 60;

            if (Rb_PercentileContinuous.Checked)
            {
                seRe.PercentileMethod = true;
            }
            else
            {
                seRe.PercentileMethod = false;
            }
        }
예제 #2
0
 public ReportDialog(int editId)
 {
     InitializeComponent();
     IsInEditMode = true;
     EditId = editId;
     report = Settings.Instance.ServerSettings.Server[Settings.Instance.SelectedServer].Groups[Settings.Instance.SelectedGroup].Reports[editId];
     errProv = new ErrorProvider(this);
 }
예제 #3
0
 public ReportDialog(int editId)
 {
     InitializeComponent();
     IsInEditMode = true;
     EditId       = editId;
     report       = Settings.Instance.ServerSettings.Server[Settings.Instance.SelectedServer].Groups[Settings.Instance.SelectedGroup].Reports[editId];
     errProv      = new ErrorProvider(this);
 }
예제 #4
0
        private void run(int reportId)
        {
            string         url = HttpClient.GetUrlFromIp(Settings.Instance.ServerSettings.Server[ServerId].Address, Settings.Instance.ServerSettings.Server[ServerId].Port, Settings.Instance.ServerSettings.Server[ServerId].UseSsl);
            PrtgApiManager api = new PrtgApiManager(url, Settings.Instance.ServerSettings.Server[ServerId].Username, Settings.Instance.ServerSettings.Server[ServerId].Password, true);

            SetStatusText("Receiving data from the PRTG server...");
            SensorReport report          = Settings.Instance.ServerSettings.Server[ServerId].Groups[GroupId].Reports[reportId];
            string       tmpChannelsFile = HttpClient.GetHttpStream(api.GetSensorChannelNames(report.SensorId), "api_channels.xml");
            string       tmpDataFile     = HttpClient.GetHttpStream(api.GetHistoricSensorData(report.SensorId, report.Average.ToString(), StartDate, EndDate));
            string       chartPath       = HttpClient.GetHttpStream(api.GetSensorGraph(report.SensorId, report.Average.ToString(), StartDate, EndDate, 850, 270), "chart.png");
            string       percentileTmp   = string.Empty;

            if (report.HasPercentile)
            {
                percentileTmp = HttpClient.GetHttpStream(api.GetPercentile(report.SensorId, StartDate, EndDate, report.Percentile, report.PercentileMethod, report.PercentileAvg), "percentile.xml");
            }
            SensorData sensor = null;

            if (!bw.CancellationPending)
            {
                SetStatusText("Parsing data...");
                SensorDataXmlParser parser = new SensorDataXmlParser(report.SensorId);
                sensor = parser.parse(tmpChannelsFile, tmpDataFile);
                if (report.HasPercentile)
                {
                    parser.ParsePercentile(percentileTmp);
                }
                sensor.chartPath = chartPath;
            }
            if (!bw.CancellationPending)
            {
                SetStatusText("Running script...");
                if (sensor != null)
                {
                    ScriptEngine scr = new ScriptEngine(sensor, report.ScriptName, report.TemplateName, reportId, StartDate, EndDate);
                    scr.RunScript();
                    if (scr.error)
                    {
                        bw.CancelAsync();
                    }
                }
            }
            if (!bw.CancellationPending)
            {
                SetStatusText("Creating output...");
                Settings.Instance.ServerSettings.Server[ServerId].Groups[GroupId].Reports[reportId].LastRun = DateTime.Now;
            }
        }
예제 #5
0
 private void Btn_Ok_Click(object sender, EventArgs e)
 {
     if (CheckFields())
     {
         SensorReport seRe;
         if (IsInEditMode)
         {
             seRe = report;
             WriteReport(seRe);
         }
         else
         {
             seRe = new SensorReport();
             WriteReport(seRe);
             Settings.Instance.ServerSettings.Server[Settings.Instance.SelectedServer].Groups[Settings.Instance.SelectedGroup].Reports.Add(seRe);
         }
         this.DialogResult = DialogResult.OK;
     }
 }
예제 #6
0
 private void Btn_Ok_Click(object sender, EventArgs e)
 {
     if (CheckFields())
     {
         SensorReport seRe;
         if (IsInEditMode)
         {
             seRe = report;
             WriteReport(seRe);
         }
         else
         {
             seRe = new SensorReport();
             WriteReport(seRe);
             Settings.Instance.ServerSettings.Server[Settings.Instance.SelectedServer].Groups[Settings.Instance.SelectedGroup].Reports.Add(seRe);
         }
         this.DialogResult = DialogResult.OK;
     }
 }
예제 #7
0
 private void WriteReport(SensorReport seRe)
 {
     seRe.Name = Txb_ReportName.Text;
     string[] words = Txb_SensorId.Text.Split(',');
     seRe.SensorId = Convert.ToInt32(words[words.Length - 1]);
     seRe.SensorName = Txb_SensorId.Text;
     seRe.ScriptName = Cb_ScriptNames.SelectedItem.ToString();
     seRe.TemplateName = Cb_TemplteNames.SelectedItem.ToString();
     seRe.Average = (int)Cb_Average.SelectedValue;
     seRe.ClientAddress = Txb_ClientAddress.Text;
     seRe.ClientInfo = Txb_ClientInfo.Text;
     seRe.HeaderText = Txb_BillingHeader.Text;
     seRe.FooterText = Txb_BillingFooter.Text;
     // Percentile
     seRe.HasPercentile = Cb_UsePercentile.Checked;
     seRe.Percentile = (int)Nud_PercentilePercent.Value;
     seRe.PercentileAvg = (int)Nud_PercentileAvg.Value*60;
     
     if (Rb_PercentileContinuous.Checked)
     {
         seRe.PercentileMethod = true;
     }
     else
     {
         seRe.PercentileMethod = false;
     }
 }