Example #1
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;
        }
Example #2
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;
        }
Example #3
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;
        }
Example #4
0
 private void ConnectionPreview(QlikViewReport report)
 {
     if (report != null)
         this._qlikViewConnector.Preview(report.Connection);
 }
Example #5
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;
            }
        }
Example #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);
     }
 }
Example #7
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);
        }