Esempio n. 1
0
        public static ReportDataSet GetReportDataset(int pViewid, int pCustomerId, eViewType pViewType, int pAccountId = 0, string pDatabaseConnection = "")
        {
            /**
             * reason for this is that web portal calls does not recognize user session instance.
             * so we needed to override the connection string to accept both web portal and application level.
             */
            if (string.IsNullOrEmpty(pDatabaseConnection))
                pDatabaseConnection = UserSession.ProviderConnection;

            else {
                pDatabaseConnection = pDatabaseConnection.Replace(""", "'");
                pDatabaseConnection = pDatabaseConnection.Replace("metadata=res://*/BrightPlatform.csdl|res://*/BrightPlatform.ssdl|res://*/BrightPlatform.msl;provider=System.Data.SqlClient;provider connection string=", "");
                pDatabaseConnection = pDatabaseConnection.Replace("\"", "");
            }

            ReportDataSet adt = new ReportDataSet();

            accountTableAdapter ata = new accountTableAdapter();
            contactTableAdapter cta = new contactTableAdapter();
            customersTableAdapter _taCustomer = new customersTableAdapter();

            ata.Connection = new System.Data.SqlClient.SqlConnection(pDatabaseConnection);
            cta.Connection = new System.Data.SqlClient.SqlConnection(pDatabaseConnection);
            _taCustomer.Connection = new System.Data.SqlClient.SqlConnection(pDatabaseConnection);

            if (pViewType == eViewType.AccountsContactsWithDialogData) {
                ata.Fill(adt.account, pViewid, pAccountId);
                cta.Fill(adt.contact, pViewid, pAccountId);
            }
            else if (pViewType == eViewType.AccountsContactsWithCallAttempts) {
                ata.FillByGetReportAccountDataWithCallAttempts(adt.account, pViewid, pAccountId);
                cta.FillByGetReportContactDataWithCallAttempts(adt.contact, pViewid, pAccountId);
            }

            _taCustomer.Fill(adt.customers, pCustomerId);
            return adt;
        }
Esempio n. 2
0
        public static ReportDataSet GetSampleData()
        {
            ReportDataSet dset = new ReportDataSet();
            //dset.account.AddaccountRow(
            //    1,
            //    "Micron",
            //    "1234",
            //    "sample address",
            //    "sample street address",
            //    "4444",
            //    "Italy",
            //    "Sicily",
            //    "Sample Municipality",
            //    "Sample City",
            //    "223132",
            //    "334433",
            //    "www.micron.com",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None"
            //    );
            //dset.account.AddaccountRow(
            //    2,
            //    "IBM",
            //    "1234",
            //    "sample address",
            //    "sample street address",
            //    "4444",
            //    "france",
            //    "paris",
            //    "Sample Municipality",
            //    "Sample City",
            //    "223132",
            //    "334433",
            //    "www.ibm.com",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None",
            //    "None"
            //    );
            //dset.accountdialog.AddaccountdialogRow(1,dset.account[0], "Textbox", "Question Number 1 Account 1", "Answer Number 1 Account 1", "Allan K",  "02-02-2011");
            //dset.accountdialog.AddaccountdialogRow(2, dset.account[0], "Dropbox", "Question Number 2 Account 1", "Answer Number 2 Account 1", "Dolphy", "02-02-2011");
            //dset.accountdialog.AddaccountdialogRow(3, dset.account[0], "Multiple Choice", "Question Number 3 Account 1", "Answer Number 3 Account 1", "Raymart", "02-02-2011");
            //dset.accountdialog.AddaccountdialogRow(4, dset.account[1], "Textbox", "Question Number 1 Account 2", "Answer Number 1 Account 2", "Claudine", "02-02-2011");
            //dset.accountdialog.AddaccountdialogRow(5, dset.account[1], "Dropbox", "Question Number 2 Account 2", "Answer Number 2 Account 2", "Corona", "02-02-2011");
            //dset.accountdialog.AddaccountdialogRow(6, dset.account[1], "Multiple Choice", "Question Number 3 Account 1", "Answer Number 3 Account 2", "Enrile", "02-02-2011");
            //dset.accountdialog.AddaccountdialogRow(7, dset.account[1], "Multiple Choice", "Question Number 4 Account 1", "Answer Number 3 Account 2", "Justine B", "02-02-2011");

            //dset.contact.AddcontactRow(1, dset.account[0], "None", "allan", "firstcontact", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //"None", "None", "None", "None", "None","None");
            //dset.contact.AddcontactRow(2, dset.account[0], "None", "peter", "secondcontact", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //"None", "None", "None", "None", "None", "None");
            //dset.contact.AddcontactRow(3, dset.account[0], "None", "gowing", "secondcontact", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //"None", "None", "None", "None", "None", "None");
            //dset.contact.AddcontactRow(4, dset.account[1], "None", "bernard", "firstcontact", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //"None", "None", "None", "None", "None", "None");
            //dset.contact.AddcontactRow(5, dset.account[1], "None", "lany", "secondcontact", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //    "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None", "None",
            //"None", "None", "None", "None", "None", "None");

            //dset.contactdialog.AddcontactdialogRow(1, dset.contact[0], "Textbox", "Question 1 Contact 1 Account 1", "Answer 1 Contact 1 Account 1", "James P.", "02-04-2011");
            //dset.contactdialog.AddcontactdialogRow(2, dset.contact[0], "Smarttext", "Question 2 Contact 1 Account 1", "Answer 2 Contact 1 Account 1", "James P.", "02-04-2011");
            //dset.contactdialog.AddcontactdialogRow(3, dset.contact[0], "MultipleChoice", "Question 3 Contact 1 Account 1", "Answer 3 Contact 1 Account 1", "James P.", "02-04-2011");
            //dset.contactdialog.AddcontactdialogRow(4, dset.contact[0], "Dropbox", "Question 4 Contact 1 Account 1", "Answer 4 Contact 1 Account 1", "James P.", "02-04-2011");

            //dset.contactdialog.AddcontactdialogRow(5, dset.contact[1], "Smarttext", "Question 1 Contact 1 Account 1", "Answer 2 Contact 1 Account 1", "James P.", "02-04-2011");
            //dset.contactdialog.AddcontactdialogRow(6, dset.contact[1], "MultipleChoice", "Question 2 Contact 1 Account 1", "Answer 3 Contact 1 Account 1", "James P.", "02-04-2011");

            //dset.contactdialog.AddcontactdialogRow(7, dset.contact[4], "Textbox", "Question 1 Contact 1 Account 1", "Answer 1 Contact 1 Account 1", "James P.", "02-04-2011");
            //dset.contactdialog.AddcontactdialogRow(8, dset.contact[4], "Smarttext", "Question 2 Contact 1 Account 1", "Answer 2 Contact 1 Account 1", "James P.", "02-04-2011");
            //dset.contactdialog.AddcontactdialogRow(9, dset.contact[4], "MultipleChoice", "Question 3 Contact 1 Account 1", "Answer 3 Contact 1 Account 1", "James P.", "02-04-2011");
            return dset;
        }
Esempio n. 3
0
            private string ShowReportPagePreview(ReportDataSet pReportDataSet, bool pCreateFile = false)
            {
                m_ReportPageTemplateProperty.StatisticsDataSource = new DataTable();
                if (m_CallingEnvironment != eCallingEnvironment.BrightSales_SendEmail)
                    m_ReportPageTemplateProperty.StatisticsDataSource = this.GetFilteredData();

                string template = m_eftConfigData.report_layout_config;
                if (string.IsNullOrEmpty(template))
                    template = BrightVision.Reporting.Business.FacadeReportTemplate.GetDefaultReportLayout();

                XtraReportDefaultTemplate _report = new XtraReportDefaultTemplate(template, m_ReportPageTemplateProperty) {
                    DataSource = pReportDataSet
                };

                /**
                 * return the file name created if has any,
                 * else just show report and return empty string.
                 */
                if (pCreateFile) {
                    string _FileName = String.Format(@"{0}\Report_{1}_{2}.pdf",
                        m_ReportsPath,
                        DateTime.Now.ToString("yyyy-MM-dd"),
                        Guid.NewGuid().ToString()
                    );

                    XtraReportDefaultTemplate _TemplatePdf = _report;
                    PdfExportOptions pdfOptions = _TemplatePdf.ExportOptions.Pdf;
                    pdfOptions.Compressed = true;
                    pdfOptions.ImageQuality = PdfJpegImageQuality.Low;
                    _TemplatePdf.DataSource = pReportDataSet;
                    _TemplatePdf.ExportToPdf(_FileName);

                    return _FileName;
                }
                else
                    _report.ShowPreview();

                return string.Empty;
            }
Esempio n. 4
0
            private void PopulateContactStatic(ref ReportDataSet dataset, DataTable datasource)
            {
                //var config = XElement.Parse(XmlConfig);

                var config = XElement.Parse(m_eftConfigData.xml_config);
                for (int rowCount = 0; rowCount < datasource.Rows.Count; rowCount++) {
                    int accountid = int.Parse(datasource.Rows[rowCount]["accountid"].ToString());
                    if (m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail && (accountid != m_AccountId && m_AccountId > 0))
                        continue;

                    //string _ContactName = string.Empty;
                    //if (datasource.Columns.Contains("Contact Firstname") && datasource.Columns.Contains("Contact Lastname"))
                    //    _ContactName = string.Format("{0}{1}", datasource.Rows[rowCount]["Contact Firstname"].ToString(), datasource.Rows[rowCount]["Contact Lastname"].ToString());
                    //else if (datasource.Columns.Contains("Contact  Firstname") && datasource.Columns.Contains("Contact  Lastname"))
                    //    _ContactName = string.Format("{0}{1}", datasource.Rows[rowCount]["Contact  Firstname"].ToString(), datasource.Rows[rowCount]["Contact  Lastname"].ToString());

                    //if (string.IsNullOrEmpty(_ContactName))
                    //    continue;

                    for (int colCount = 0; colCount < datasource.Columns.Count; colCount++) {
                        string colName = datasource.Columns[colCount].ColumnName;
                        if (colName == "accountid" || colName == "contactid")
                            continue;

                        // get the source base on the column name
                        // the columnname is the display name in the xml_config
                        var filter = string.Format("item[display_name='{0}']", colName);
                        var item = config.XPathSelectElement(filter);
                        var xsource = item.XPathSelectElements("source").FirstOrDefault();
                        var xfieldName = item.XPathSelectElements("field_name").FirstOrDefault();
                        string source = string.Empty;
                        string fieldName = string.Empty;

                        if (xsource != null && xfieldName != null) {
                            source = xsource.Value;
                            fieldName = xfieldName.Value;
                        }
                        else
                            continue;

                        // AccountMerge and Dialog Account Level source is added to accountstatic table
                        if (source == "General" && (fieldName == "DialogCreatedBy" ||
                            fieldName == "DialogCreatedDate" || fieldName == "DialogStatus" ||
                            fieldName == "ContactLastChanged" || fieldName == "ContactStatusLastChanged" ||
                            fieldName == "ContactSubCampaignCallAttempts")) {
                                int contactid = int.Parse(datasource.Rows[rowCount]["contactid"].ToString());
                                DataRow[] existColName = dataset.contactstatic.Select(string.Format("contactid={0} and name='{1}'", contactid, colName));
                                if (existColName.Count() < 1) {
                                    var newContactStatic = dataset.contactstatic.NewcontactstaticRow();
                                    newContactStatic.contactid = contactid;
                                    newContactStatic.name = colName;
                                    newContactStatic.value = datasource.Rows[rowCount][colCount].ToString();
                                    dataset.contactstatic.AddcontactstaticRow(newContactStatic);
                                }
                        }
                    }
                }
            }
Esempio n. 5
0
            private void ReportPagePreview()
            {
                try {
                    this.GetReportPageBaseData();

                    /**
                     * DAN: https://brightvision.jira.com/browse/PLATFORM-2457
                     * Implement to sort report when grid has been sorted out
                     */
                    string sortExpression = GetSortExpression(gridView1);
                    if (!string.IsNullOrEmpty(sortExpression)) {
                        string[] arrSortEx = sortExpression.Split('|');
                        string tableFieldName = GetTableFieldName(arrSortEx[0]);

                        if (!string.IsNullOrEmpty(tableFieldName)) {
                            string tableName = tableFieldName.Split('|')[0];
                            string fieldName = tableFieldName.Split('|')[1];
                            ReportDataSet reportDatasetTemp = new ReportDataSet() {
                                EnforceConstraints = false
                            };
                            /*var sortedRows = (from myRow in getReportDataSet.Tables["account"].AsEnumerable()
                                                orderby myRow["company_name"] descending
                                                select myRow).ToArray();*/
                            //DAN: Copy to DataTable first as it causes error during linq when original table has been filter/deleted rows.
                            DataTable dt = m_ReportPageDataSet.Tables[tableName].DefaultView.ToTable();
                            var sortedRows = (from myRow in dt.AsEnumerable()
                                                orderby myRow[fieldName] ascending
                                                select myRow).ToArray();

                            if (arrSortEx[1] == "DESC") {
                                sortedRows = (from myRow in dt.AsEnumerable()
                                                orderby myRow[fieldName] descending
                                                select myRow).ToArray();
                            }

                            DataTable sortedCompany = sortedRows.CopyToDataTable();
                            foreach (DataRow dr in sortedCompany.Rows)
                                reportDatasetTemp.Tables[tableName].Rows.Add(dr.ItemArray);

                            //reportDatasetTemp.Tables["account"].Rows.Add(dr.ItemArray);

                            for (int i = 1; i < m_ReportPageDataSet.Tables.Count; i++) {
                                dt.Clear();
                                dt.Dispose();
                                dt = null;
                                dt = new DataTable();
                                dt = m_ReportPageDataSet.Tables[i].DefaultView.ToTable();

                                sortedRows = (from myRow in dt.AsEnumerable()
                                                select myRow).ToArray();

                                if (sortedRows.Count() == 0)
                                    continue;

                                sortedCompany = sortedRows.CopyToDataTable();
                                foreach (DataRow dr in sortedCompany.Rows)
                                    reportDatasetTemp.Tables[i].Rows.Add(dr.ItemArray);
                            }
                            reportDatasetTemp.EnforceConstraints = true;

                            this.ShowReportPagePreview(reportDatasetTemp);
                            //m_ReportPageTemplateProperty.StatisticsDataSource = this.GetFilteredData();
                            //string template = m_eftConfigData.report_layout_config;
                            //if (string.IsNullOrEmpty(template))
                            //    template = BrightVision.Reporting.Business.FacadeReportTemplate.GetDefaultReportLayout();

                            //XtraReportDefaultTemplate _report = new XtraReportDefaultTemplate(template, m_ReportPageTemplateProperty) { DataSource = reportDatasetTemp };
                            //_report.ShowPreview();
                        }
                        else {
                            this.ShowReportPagePreview(m_ReportPageDataSet);
                            //m_ReportPageTemplateProperty.StatisticsDataSource = this.GetFilteredData();
                            //string template = m_eftConfigData.report_layout_config;
                            //if (string.IsNullOrEmpty(template))
                            //    template = new XtraReportDefaultTemplate().ToString();

                            //XtraReportDefaultTemplate _report = new XtraReportDefaultTemplate(template, m_ReportPageTemplateProperty) { DataSource = m_ReportPageDataSet };
                            //_report.ShowPreview();
                        }
                    }

                    else {
                        this.ShowReportPagePreview(m_ReportPageDataSet);
                        //m_ReportPageTemplateProperty.StatisticsDataSource = this.GetFilteredData();
                        //string template = m_eftConfigData.report_layout_config;
                        //if (string.IsNullOrEmpty(template))
                        //    template = BrightVision.Reporting.Business.FacadeReportTemplate.GetDefaultReportLayout();

                        //XtraReportDefaultTemplate _report = new XtraReportDefaultTemplate(template, m_ReportPageTemplateProperty) {
                        //    DataSource = m_ReportPageDataSet
                        //};

                        //_report.ShowPreview();
                    }
                }
                catch (Exception ex) {
                    if (m_IsWebPortalCall)
                        throw ex;

                    BrightVision.Common.UI.NotificationDialog.Error("Reports", ex.Message);
                }
            }
Esempio n. 6
0
            private void PopulateClientInfo(ref ReportDataSet reportDataset)
            {
                string customerName = string.Empty;
                string campaignName = string.Empty;
                string efeSubCampaignName = string.Empty;
                string _efeSubCampaignListname = string.Empty;

                if (m_AccountId < 1) {
                    XElement xmlConfigWithData = XElement.Parse(XmlConfigData);

                    /**
                     * [@jeff 06.26.2012]: https://brightvision.jira.com/browse/PLATFORM-1527
                     * added validation for null objects.
                     */

                    if (xmlConfigWithData.XPathSelectElement("relation/customer") != null &&
                        xmlConfigWithData.XPathSelectElement("relation/customer").Attribute("name").Value != null)
                        customerName = xmlConfigWithData.XPathSelectElement("relation/customer").Attribute("name").Value;

                    if (xmlConfigWithData.XPathSelectElement("relation/campaign") != null &&
                        xmlConfigWithData.XPathSelectElement("relation/campaign").Attribute("name").Value != null)
                        campaignName = xmlConfigWithData.XPathSelectElement("relation/campaign").Attribute("name").Value;

                    if (xmlConfigWithData.XPathSelectElement("relation/subcampaign") != null &&
                        xmlConfigWithData.XPathSelectElement("relation/subcampaign").Attribute("name").Value != null)
                        efeSubCampaignName = xmlConfigWithData.XPathSelectElement("relation/subcampaign").Attribute("name").Value;

                    if (xmlConfigWithData.XPathSelectElement("relation/dialog") != null &&
                        xmlConfigWithData.XPathSelectElement("relation/dialog").Attribute("list_source_name").Value != null)
                        _efeSubCampaignListname = xmlConfigWithData.XPathSelectElement("relation/dialog").Attribute("list_source_name").Value;
                }
                else {
                    customerName = m_eftCustomer.customer_name;
                    campaignName = m_eftCampaign.campaign_name;
                    efeSubCampaignName = m_eftSubCampaign.title;
                    if (m_eftSubCampaignAccountList != null)
                        _efeSubCampaignListname = m_eftSubCampaignAccountList.list_source;
                }

                string _CurrentUser = string.Empty;
                if (m_IsWebPortalCall)
                    _CurrentUser = m_WebPortalRequester;
                else
                    _CurrentUser = UserSession.CurrentUser.UserFullName;

                reportDataset.clientinfo.Rows.Add(
                    customerName,
                    campaignName,
                    efeSubCampaignName,
                    _CurrentUser,
                    DateTime.Now.ToShortDateString(),
                    m_eftConfigData.name,
                    _efeSubCampaignListname
                );
            }
Esempio n. 7
0
            private void PopulateContactDynamic(ref ReportDataSet dataset, DataTable datasource, TemplateProperty templateData)
            {
                var config = XElement.Parse(m_eftConfigData.xml_config);
                for (int rowCount = 0; rowCount < datasource.Rows.Count; rowCount++) {
                    int accountid = int.Parse(datasource.Rows[rowCount]["accountid"].ToString());
                    if (m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail && (accountid != m_AccountId && m_AccountId > 0))
                        continue;

                    //string _ContactName = string.Empty;
                    //if (datasource.Columns.Contains("Contact Firstname") && datasource.Columns.Contains("Contact Lastname"))
                    //    _ContactName = string.Format("{0}{1}", datasource.Rows[rowCount]["Contact Firstname"].ToString(), datasource.Rows[rowCount]["Contact Lastname"].ToString());
                    //else if (datasource.Columns.Contains("Contact  Firstname") && datasource.Columns.Contains("Contact  Lastname"))
                    //    _ContactName = string.Format("{0}{1}", datasource.Rows[rowCount]["Contact  Firstname"].ToString(), datasource.Rows[rowCount]["Contact  Lastname"].ToString());

                    //if (string.IsNullOrEmpty(_ContactName))
                    //    continue;

                    for (int colCount = 0; colCount < datasource.Columns.Count; colCount++) {
                        string colName = datasource.Columns[colCount].ColumnName;
                        if (colName == "accountid" || colName == "contactid")
                            continue;

                        if (colName.Contains("\r") || colName.Contains("\n"))
                            throw new Exception(string.Format("Column{0}contains a next line character.{1}Please kindly remove this on configuration.", colName, Environment.NewLine));

                        // get the source base on the column name
                        // the columnname is the display name in the xml_config
                        var filter = string.Format("item[display_name='{0}']", colName);
                        var item = config.XPathSelectElement(filter);
                        var xsource = item.XPathSelectElements("source").FirstOrDefault();

                        string source = string.Empty;
                        if (xsource != null)
                            source = xsource.Value;
                        else {
                            var lbl = item.XPathSelectElement("label_name");
                            if (lbl.Value == "EMPTY") continue;
                            var mergeitem = item.XPathSelectElements("merge_data").First();
                            var innerItem = XElement.Parse(mergeitem.Value);
                            var mergeContactItem = innerItem.XPathSelectElements("item[source='Contact' or source='Dialog Contact Level']");
                            if (mergeContactItem.Count() > 0)
                                source = "ContactMerge";
                        }

                        int contactid = int.Parse(datasource.Rows[rowCount]["contactid"].ToString()); ;
                        var datarowDynamic = dataset.contactdynamic.Select(string.Format("contactid={0} and name='{1}'", contactid, colName));

                        //AccountMerge and Dialog Account Level source is added to accountdynamic table
                        if (datarowDynamic.Count() == 0 && (source == "ContactMerge" || source == "Dialog Contact Level")) {
                            var newContactDynamic = dataset.contactdynamic.NewcontactdynamicRow();
                            newContactDynamic.contactid = int.Parse(datasource.Rows[rowCount]["contactid"].ToString());
                            newContactDynamic.name = colName;
                            newContactDynamic.value = datasource.Rows[rowCount][colCount].ToString();

                            if (templateData.IsEmptyDynamicValueVisible)
                                dataset.contactdynamic.AddcontactdynamicRow(newContactDynamic);
                            else if (!templateData.IsEmptyDynamicValueVisible && !string.IsNullOrWhiteSpace(newContactDynamic.value))
                                dataset.contactdynamic.AddcontactdynamicRow(newContactDynamic);
                        }
                    }
                }
            }
Esempio n. 8
0
            private void PopulateAccountDynamic(ref ReportDataSet dataset, DataTable datasource, TemplateProperty templateData)
            {
                var config = XElement.Parse(m_eftConfigData.xml_config);
                for (int rowCount = 0; rowCount < datasource.Rows.Count; rowCount++) {
                    int accountid = int.Parse(datasource.Rows[rowCount]["accountid"].ToString());
                    if (m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail && (accountid != m_AccountId && m_AccountId > 0))
                        continue;

                    for (int colCount = 0; colCount < datasource.Columns.Count; colCount++) {
                        string colName = datasource.Columns[colCount].ColumnName;
                        if (colName == "accountid" || colName == "contactid")
                            continue;

                        // get the source base on the column name
                        // the columnname is the display name in the xml_config
                        var filter = string.Format("item[display_name='{0}']", colName);
                        var item = config.XPathSelectElement(filter);
                        var xsource = item.XPathSelectElements("source").FirstOrDefault();

                        string source = string.Empty;
                        if (xsource != null)
                            source = xsource.Value;
                        else {
                            var lbl = item.XPathSelectElement("label_name");
                            if (lbl.Value == "EMPTY") continue;
                            var mergeitem = item.XPathSelectElements("merge_data").First();
                            var innerItem = XElement.Parse(mergeitem.Value);
                            var mergeContactItem = innerItem.XPathSelectElements("//item[source='Contact' or source='Dialog Contact Level']");
                            if (mergeContactItem.Count() == 0)
                                source = "AccountMerge";
                        }

                        var datarowDynamic = dataset.accountdynamic.Select(string.Format("accountid={0} and name='{1}'", accountid, colName));

                        //AccountMerge and Dialog Account Level source is added to accountdynamic table
                        if (datarowDynamic.Count() == 0 && (source == "AccountMerge" || source == "Dialog Account Level")) {
                            var newAccountDynamic = dataset.accountdynamic.NewaccountdynamicRow();
                            newAccountDynamic.accountid = accountid;
                            newAccountDynamic.name = colName;
                            newAccountDynamic.value = datasource.Rows[rowCount][colCount].ToString();
                            if (templateData.IsEmptyDynamicValueVisible)
                                dataset.accountdynamic.AddaccountdynamicRow(newAccountDynamic);
                            else if (!templateData.IsEmptyDynamicValueVisible && !string.IsNullOrWhiteSpace(newAccountDynamic.value))
                                dataset.accountdynamic.AddaccountdynamicRow(newAccountDynamic);
                        }
                    }
                }
            }
Esempio n. 9
0
            private void GetReportPageBaseData()
            {
                m_IsEmpty = false;
                if (this.gridView1.DataRowCount == null || this.gridView1.DataRowCount < 1) {
                    BrightVision.Common.UI.NotificationDialog.Information("Reports", "No data to preview.");
                    m_IsEmpty = true;
                    return;
                }

                using (BrightPlatformEntities _efDbModel = new BrightPlatformEntities(m_DatabaseConnection) { CommandTimeout = 0 }) {
                    m_eftConfigData = _efDbModel.view_configuration.FirstOrDefault(i => i.id == m_ViewConfigId);
                    m_eftSubCampaign = _efDbModel.subcampaigns.FirstOrDefault(i => i.id == m_eftConfigData.subcampaign_id);
                    m_eftCampaign = _efDbModel.campaigns.FirstOrDefault(i => i.id == m_eftSubCampaign.campaign_id);
                    m_eftCustomer = _efDbModel.customers.FirstOrDefault(i => i.id == m_eftCampaign.customer_id);
                    _efDbModel.Detach(m_eftConfigData);
                    _efDbModel.Detach(m_eftSubCampaign);
                    _efDbModel.Detach(m_eftCampaign);
                    _efDbModel.Detach(m_eftCustomer);
                    _efDbModel.FIUpdateContactTitles();

                    /**
                     * if send email, get data for sub_campaign_account_list and final_list.
                     */
                    if (m_CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail && m_AccountId > 0) {
                        m_eftFinalList = _efDbModel.final_lists.FirstOrDefault(i => i.sub_campaign_id == m_eftSubCampaign.id);
                        if (m_eftFinalList != null) {
                            _efDbModel.Detach(m_eftFinalList);
                            m_eftSubCampaignAccountList = _efDbModel.sub_campaign_account_lists.FirstOrDefault(i =>
                                i.final_list_id == m_eftFinalList.id &&
                                i.account_id == m_AccountId
                            );
                                _efDbModel.Detach(m_eftSubCampaignAccountList);
                        }
                    }
                }

                if (m_eftConfigData == null || m_eftConfigData.report_layout_config == null) {
                    WaitDialog.Close();
                    if (m_IsWebPortalCall)
                        throw new Exception("No layout available for the selected view.");

                    BrightVision.Common.UI.NotificationDialog.Information("Reports", "No layout available for this view.");
                    return;
                }

                if (string.IsNullOrEmpty(m_eftConfigData.report_data_config)) {
                    WaitDialog.Close();
                    if (m_IsWebPortalCall)
                        throw new Exception("No parameter layout has been set for this report.");

                    BrightVision.Common.UI.NotificationDialog.Information("Reports", "No parameter layout has been set for this report.");
                    return;
                }

                m_ReportPageTemplateProperty = SerializeUtility.DeserializeFromXml<TemplateProperty>(m_eftConfigData.report_data_config);
                m_ReportPageDataSet = this.GetReportDataSet(m_ReportPageTemplateProperty);

                /**
                 * if has sort info, then apply.
                 */
                #region Sorting Logic
                if (!string.IsNullOrEmpty(m_GridSortInfo)) {
                    string sortExpression = this.GetSortExpression(gridView1);
                    if (!string.IsNullOrEmpty(sortExpression)) {
                        string[] _SortInfoCollection = sortExpression.Split(';');

                        ReportDataSet _rdsTemporary = (ReportDataSet)m_ReportPageDataSet.Clone();
                        DataSet _dsSortedData = new DataSet();
                        Dictionary<string, List<string>> _TableSortRules = new Dictionary<string, List<string>>();

                        /**
                         * group all sort rules by table.
                         */
                        foreach (string _SortInfo in _SortInfoCollection) {
                            string[] _item = _SortInfo.Split('|');
                            string _FieldNameInfo = this.GetTableFieldName(_item[0].ToString());
                            if (!string.IsNullOrEmpty(_FieldNameInfo)) {
                                string[] _val = _FieldNameInfo.Split('|');
                                string _TableName = _val[0];
                                string _FieldName = _val[1];

                                /**
                                 * create new table sort rule.
                                 * else, update existing table sort rule.
                                 *
                                 * format:
                                 * <column_name1>|<sort_rule1>;<column_name2>|<sort_rule2>; and so on ...
                                 *
                                 * this would later be processed by splitting the sort rules by semicolon(;),
                                 * then split by bar(|).
                                 */
                                string _ColumnName = m_ReportPageDataSet.Tables[_TableName].Columns[_FieldName].ColumnName;
                                string _SortOrder = _item[1].ToString();
                                if (!_TableSortRules.ContainsKey(_TableName))
                                    _TableSortRules.Add(_TableName, new List<string>());

                                _TableSortRules[_TableName].Add(string.Format("{0} {1}", _ColumnName, _SortOrder));
                            }
                        }

                        /**
                         * set the sorting rules from KeyValuePair<string, List<string>> from _TableSortRules
                         * string = table name
                         * List<string> = sort rules
                         */
                        foreach (KeyValuePair<string, List<string>> _pair in _TableSortRules) {
                            DataTable _dtToSort = m_ReportPageDataSet.Tables[_pair.Key];
                            _dtToSort.DefaultView.Sort = string.Join(",", _TableSortRules[_pair.Key].ToArray());
                            _dsSortedData.Tables.Add(_dtToSort.DefaultView.ToTable());
                        }

                        /**
                         * copy all tables to the temporary report data set.
                         * then overwrite the original report data set with the
                         * temporary report dataset, since it contains the sorted
                         * tables that the report needs.
                         *
                         * order of the tables, according to relationship:
                         * 1. account
                         * 2. accountdynamic
                         * 3. accountstatic
                         * 4. contact
                         * 5. contactdynamic
                         * 6. contactstatic
                         * 7. clientinfo
                         * 8. customers
                         */
                        if (_dsSortedData.Tables["account"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["account"].Rows, "account");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["account"].Rows, "account");

                        if (_dsSortedData.Tables["accountdynamic"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["accountdynamic"].Rows, "accountdynamic");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["accountdynamic"].Rows, "accountdynamic");

                        if (_dsSortedData.Tables["accountstatic"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["accountstatic"].Rows, "accountstatic");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["accountstatic"].Rows, "accountstatic");

                        if (_dsSortedData.Tables["contact"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["contact"].Rows, "contact");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["contact"].Rows, "contact");

                        if (_dsSortedData.Tables["contactdynamic"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["contactdynamic"].Rows, "contactdynamic");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["contactdynamic"].Rows, "contactdynamic");

                        if (_dsSortedData.Tables["contactstatic"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["contactstatic"].Rows, "contactstatic");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["contactstatic"].Rows, "contactstatic");

                        if (_dsSortedData.Tables["clientinfo"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["clientinfo"].Rows, "clientinfo");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["clientinfo"].Rows, "clientinfo");

                        if (_dsSortedData.Tables["customers"] != null)
                            this.CopyTableRows(ref _rdsTemporary, _dsSortedData.Tables["customers"].Rows, "customers");
                        else
                            this.CopyTableRows(ref _rdsTemporary, m_ReportPageDataSet.Tables["customers"].Rows, "customers");

                        m_ReportPageDataSet = null;
                        m_ReportPageDataSet = _rdsTemporary;
                    }
                }
                #endregion
            }
Esempio n. 10
0
            private ReportDataSet GetReportDataSet(TemplateProperty pTemplateData)
            {
                ReportDataSet _drData = new ReportDataSet();
                DataTable _dtFilterdData = new DataTable();

                _dtFilterdData = this.GetFilteredData();

                /**
                 * This process will set the account and contact table
                 */
                if (m_ViewType == eDisplayMode.AccountsContacts_WithDialogData)
                    _drData = ReportDataSet.GetReportDataset(m_ViewConfigId, m_CustomerId, ReportDataSet.eViewType.AccountsContactsWithDialogData, m_AccountId, m_DatabaseConnection);
                else if (m_ViewType == eDisplayMode.AccountsContacts_WithCallAttempts)
                    _drData = ReportDataSet.GetReportDataset(m_ViewConfigId, m_CustomerId, ReportDataSet.eViewType.AccountsContactsWithCallAttempts, m_AccountId, m_DatabaseConnection);

                /**
                 * this will remove the account or contact which is not present in the display view grid
                 */
                _drData = this.FilterByGridData(_drData);

                PopulateClientInfo(ref _drData);
                PopulateAccountDynamic(ref _drData, _dtFilterdData, pTemplateData);
                PopulateContactDynamic(ref _drData, _dtFilterdData, pTemplateData);
                PopulateAccountStatic(ref _drData, _dtFilterdData);
                PopulateContactStatic(ref _drData, _dtFilterdData);

                /**
                 * remove derived contacts.
                 * -> temporary contacts added for viewing records.
                 * -> contacts with empty first name and last name.
                 */
                //for (int i = 0; i < _drData.Tables["contact"].Rows.Count; i++) {
                //    if (string.IsNullOrEmpty(_drData.Tables["contact"].Rows[i]["first_name"].ToString()) &&
                //        string.IsNullOrEmpty(_drData.Tables["contact"].Rows[i]["last_name"].ToString()))
                //        _drData.Tables["contact"].Rows[i].Delete();
                //}

                return _drData;
            }
Esempio n. 11
0
            private ReportDataSet FilterByGridData(ReportDataSet reportDataset)
            {
                int rowCount = this.gridView1.DataRowCount;
                string accountFilter = string.Empty;
                string contactFilter = string.Empty;
                List<int> listAccount = new List<int>();
                List<int> listContact = new List<int>();

                #region get the filter of account and contact
                for (int cnt = 0; cnt < rowCount; cnt++) {
                    var rowview = this.gridView1.GetRow(cnt) as DataRowView;
                    int accountId = int.Parse(rowview.Row["accountid"].ToString());
                    int contactid = int.Parse(rowview.Row["contactid"].ToString());
                    if (listAccount.Where(param => param == accountId).Count() == 0)
                        listAccount.Add(accountId);
                    if (listContact.Where(param => param == contactid).Count() == 0)
                        listContact.Add(contactid);
                }

                foreach (var ac in listAccount)
                    accountFilter += ac + ",";

                foreach (var c in listContact)
                    contactFilter += c + ",";
                #endregion

                if (accountFilter != string.Empty) {
                    accountFilter = accountFilter.Substring(0, accountFilter.Length - 1);
                    var toDeleteAccount = reportDataset.account.Select(String.Format("account_id NOT IN ({0})", accountFilter));
                    foreach (var tmp in toDeleteAccount)
                        tmp.Delete();
                }
                if (contactFilter != string.Empty) {
                    contactFilter = contactFilter.Substring(0, contactFilter.Length - 1);
                    var toDeleteContact = reportDataset.contact.Select(String.Format("contact_id NOT IN ({0})", contactFilter));
                    foreach (var tmp in toDeleteContact)
                        tmp.Delete();
                }

                return reportDataset;
            }
Esempio n. 12
0
 private void CopyTableRows(ref ReportDataSet pDestination, DataRowCollection pSource, string pTableName)
 {
     DataRow _row = null;
     foreach (DataRow _drow in pSource) {
         _row = pDestination.Tables[pTableName].NewRow();
         _row = _drow;
         pDestination.Tables[pTableName].ImportRow(_drow);
     }
 }