Exemple #1
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            report = this.ViewModel.ReportItem as QlikViewReport;

            this.comboBoxConnection.SelectedValue = report.Connection;
            this.comboBoxReportType.SelectedValue = report.ReportType;

            if (report.Filter == null)
            {
                this.comboBoxFilter.SelectedIndex = 0;
            }
            else
            {
                this.comboBoxFilter.SelectedValue = report.Filter;
            }

            if (this.ViewModel.IsNew)
            {
                this.gridName.Visibility        = System.Windows.Visibility.Visible;
                this.stackNewActions.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                this.gridName.Visibility        = System.Windows.Visibility.Collapsed;
                this.stackNewActions.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Exemple #2
0
 private void ConnectionPreview(QlikViewReport report)
 {
     if (report != null)
     {
         this._qlikViewConnector.Preview(report.Connection);
     }
 }
Exemple #3
0
 private void btnDeleteReport_Click(object sender, EventArgs e)
 {
     if (this.dataGridViewReports.CurrentRow != null)
     {
         QlikViewReport report = this.dataGridViewReports.CurrentRow.DataBoundItem as QlikViewReport;
         this._reports.Remove(report.Name);
         this.RefreshGridView();
     }
 }
Exemple #4
0
        public void ReportAdd(QlikViewReport report)
        {
            ReportTask task = this.ReportItem as ReportTask;

            if (task.Reports.ContainsKey(report.Name))
            {
                MessageBox.Show("The same name report exists, cannot add.");
                return;
            }
            task.Reports.Add(report.Name, report);
        }
Exemple #5
0
        private void btnAddReport_Click(object sender, EventArgs e)
        {
            if (this.comboBoxReports.Items.Count > 0)
            {
                QlikViewReport report = ReportConfig.QvReportManager.ItemCollection[this.comboBoxReports.SelectedItem.ToString()];

                if (!this._reports.ContainsKey(report.Name))
                {
                    this._reports.Add(report.Name, report);
                }

                this.RefreshGridView();
            }
        }
Exemple #6
0
 public void ReportDelete(QlikViewReport report)
 {
     if (report == null)
     {
         MessageBox.Show("Please select an report.");
         return;
     }
     if (MessageBox.Show("Do you want to delete the report " + report.Name, "Delete", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         ReportTask task = this.ReportItem as ReportTask;
         task.Reports.Remove(report.Name);
         this.ReportList.Add(report);
     }
 }
Exemple #7
0
        public bool RunReport(QlikViewReport report, SmtpServer smtpServer)
        {
            string outputFile;

            if (!Directory.Exists("ReportRunTest"))
            {
                Directory.CreateDirectory("ReportRunTest");
            }
            var error = this.ExportReport(report, "ReportRunTest", out outputFile);

            if (error.HasError)
            {
                return(false);
            }

            return(true);
        }
Exemple #8
0
        protected void ExportReport(IReportItem reportItem)
        {
            if (this.ExportReportRunning != null)
            {
                this.ExportReportRunning(this, new EventArgs());
            }

            IError         error  = new QvError();
            QlikViewReport report = null;

            try
            {
                report = reportItem as QlikViewReport;
                ExportEngine engine = new ExportEngine(QlikViewConnectorProxy.Instance);
                engine.Logger = new QVConfigLog();
                bool succeed = engine.RunReport(report, ReportConfig.SmtpServerManager.SmtpServer);

                if (succeed)
                {
                    error.HasError = false;
                }
                else
                {
                    error.ErrorMessage.Append(string.Format("Export Report {0} failed.", report.Name));
                    error.HasError = true;
                }
            }
            catch (Exception ex)
            {
                if (error == null)
                {
                    error = new QvError();
                }
                error.ErrorMessage.Append(ex.StackTrace);
                error.HasError = true;
            }

            if (this.ExportReportCompleted != null)
            {
                this.ExportReportCompleted(error);
            }
        }
Exemple #9
0
        private string GetHtml(QlikViewReport report, string fileName)
        {
            string html = string.Empty;

            if (report.ReportType == Common.ReportType.Excel && report.IsEmbeddedInMail)
            {
                string fileName1 = fileName.Replace(".xls", ".html").Replace(".jpg", ".html");
                this._qlikViewConnector.ExportHtml(report.QlikViewExportObjectId, fileName1);
                using (StreamReader sr = new StreamReader(fileName1))
                {
                    html = sr.ReadToEnd();
                }
            }
            else if (report.ReportType == Common.ReportType.JPG)
            {
                html = string.Format("<img id=\"{0}\" src=\"cid:{1}\">", "Picture_" + report.Name + "_" + DateTime.Today.ToString("yyyMMdd"), report.Name + "_" + DateTime.Today.ToString("yyyMMdd"));
            }

            return(html);
        }
Exemple #10
0
        protected override bool OnQvItemAdd(IReportItem qvItem)
        {
            try
            {
                QlikViewReport report = qvItem as QlikViewReport;

                if (string.IsNullOrWhiteSpace(report.Name) || string.IsNullOrWhiteSpace(report.OutputFielName) || report.Connection == null)
                {
                    MessageBox.Show("Name, OutputFielName and connection are required.");
                    return(false);
                }

                ReportConfig.QvReportManager.AddItem(qvItem);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }

            return(true);
        }
Exemple #11
0
        private IError ExportReport(QlikViewReport report, string outputFolder, out string outputFile)
        {
            IError error = new QvError();

            outputFile = string.Empty;

            this._qlikViewConnector.SetConnection(report.Connection);

            this.Logger.Message("Verify the connection....");
            bool verified = this._qlikViewConnector.VerifyConnection();

            if (verified)
            {
                if (report.Filter != null)
                {
                    this.Logger.Message("Setting Filter: [" + report.Filter.Name + "] Fields:[" + string.Join(",", report.Filter.Fields.Keys.ToArray()) + "]");
                }
                this._qlikViewConnector.SetFilter(report.Filter);

                if (report.EnableDynamicNaming)
                {
                    if (report.ReportType == Common.ReportType.CSV)
                    {
                        outputFile = outputFolder + @"\" + report.OutputFielName.Replace(".", "_" + DateTime.Now.ToString("yyyyMMdd") + ".");
                    }
                    else
                    {
                        outputFile = outputFolder + @"\" + report.OutputFielName.Replace(".", "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".");
                    }
                }
                else
                {
                    outputFile = outputFolder + @"\" + report.OutputFielName;
                }

                this.Logger.Message("Export filename: " + outputFile);

                //export file
                int returnCode = -1;
                if (report.ReportType == Common.ReportType.Excel)
                {
                    returnCode = this._qlikViewConnector.ExportExcel(report.QlikViewExportObjectId, outputFile);
                }
                else if (report.ReportType == Common.ReportType.Html)
                {
                    returnCode = this._qlikViewConnector.ExportHtml(report.QlikViewExportObjectId, outputFile);
                }
                else if (report.ReportType == Common.ReportType.JPG)
                {
                    returnCode = this._qlikViewConnector.ExportJPG(report.QlikViewExportObjectId, outputFile);
                }
                else if (report.ReportType == Common.ReportType.CSV)
                {
                    if (File.Exists(outputFile))
                    {
                        File.Delete(outputFile);
                    }
                    returnCode = this._qlikViewConnector.ExportCSV(report.QlikViewExportObjectId, outputFile);
                }

                this.Logger.Message(string.Format("Export return code [{0}]", returnCode));

                //Check the file if exported
                if (!File.Exists(outputFile))
                {
                    //export again
                    this.Logger.Error(string.Format("The file {0} is not exported at the first time.", outputFile));
                }

                if (returnCode > -1)
                {
                    error.HasError = false;
                }
                else
                {
                    error.HasError = true;
                }
            }
            else
            {
                this.Logger.Error(string.Format("Veriy the connection {0} failed. Can not open the document. The report can not be exported.", report.Name));
                error.HasError = true;
            }

            return(error);
        }