Exemplo n.º 1
0
        public TemplateProperty GetSamplePropertyTemplate()
        {
            var template = new TemplateProperty();
            template.IsFooterVisible = true;
            template.IsPageNumberVisible = true;
            template.IsEmptyDynamicValueVisible = false;
            template.DynamicProperty = new List<TemplateDynamicData>();
            template.DynamicProperty.Add(
                new TemplateDynamicData
                {
                    Type = TemplateDynamicType.TextField,
                }
            );
            template.DynamicProperty.Add(
                new TemplateDynamicData
                {
                    Type = TemplateDynamicType.PageBreak,

                }
            );
            template.DynamicProperty.Add(
                new TemplateDynamicData
                {
                    Type = TemplateDynamicType.Statistics,
                    Statistics = new StatisticsTemplate { }
                }
            );
            return template;
        }
Exemplo n.º 2
0
 public void Add(TemplateProperty template)
 {
     _template = template;
     foreach (var property in template.DynamicProperty)
     {
         if (property.Type == TemplateDynamicType.TextField)
         {
             AddTextfield(property);
         }
         else if (property.Type == TemplateDynamicType.PageBreak)
         {
             AddPageBreak(property);
         }
         else if (property.Type == TemplateDynamicType.Statistics)
         {
             AddStatistics(property);
         }
     }
 }
Exemplo n.º 3
0
 private List<XRControl> CreateXRControlList(TemplateProperty template, ReportHeaderBand band, float initialYPosition, float xPosition)
 {
     var controlList = new List<XRControl>();
     if (template.DynamicProperty == null)
         return controlList;
     var _TemplateProperty = from property in template.DynamicProperty orderby property.Order select property;
     foreach (var property in _TemplateProperty)
     {
         if (!property.IsVisible)
             continue;
         float yPosition = GetNextPosition(controlList, initialYPosition);
         if (property.Type == TemplateDynamicType.TextField)
         {
             controlList.Add(AddTextfield(property, yPosition, xPosition));
         }
         else if (property.Type == TemplateDynamicType.PageBreak)
         {
             controlList.Add(AddPageBreak(property, yPosition));
         }
         else if (property.Type == TemplateDynamicType.Statistics)
         {
             if (string.IsNullOrEmpty(property.Statistics.ColumnName) ||
                 template.StatisticsDataSource.Columns[property.Statistics.ColumnName] == null)
                 continue;
             controlList.Add(AddStatistics(template, property, yPosition, xPosition));
         }
     }
     return controlList;
 }
Exemplo n.º 4
0
        private XRControl AddStatistics(TemplateProperty template, TemplateDynamicData property, float yPosition, float xPosition)
        {
            var chart1 = new XRChart();
            var pieSeriesView1 = new DevExpress.XtraCharts.PieSeriesView();
            pieSeriesView1.RuntimeExploding = false;
            chart1.BorderColor = Color.Black;
            chart1.Borders = DevExpress.XtraPrinting.BorderSide.None;
            chart1.LocationFloat = new DevExpress.Utils.PointFloat(xPosition, yPosition);
            chart1.Name = "xrChart1" + Guid.NewGuid();

            //chart1.Titles.Add(new DevExpress.XtraCharts.ChartTitle { Text= });
            var series1 = new DevExpress.XtraCharts.Series();
            chart1.Series.Add(series1);

            series1.View = pieSeriesView1;

            var pieSeriesLabel1 = series1.Label as DevExpress.XtraCharts.PieSeriesLabel;
            pieSeriesLabel1.LineVisible = true;
            pieSeriesLabel1.Position = DevExpress.XtraCharts.PieSeriesLabelPosition.TwoColumns;
            chart1.Legend.AlignmentHorizontal = DevExpress.XtraCharts.LegendAlignmentHorizontal.LeftOutside;
            chart1.Legend.AlignmentVertical = DevExpress.XtraCharts.LegendAlignmentVertical.Top;

            //this is the label with lines connected to the pie chart
            var piePointOptions1 = pieSeriesLabel1.PointOptions as DevExpress.XtraCharts.PiePointOptions;
            piePointOptions1.PointView = DevExpress.XtraCharts.PointView.Values;
            piePointOptions1.PercentOptions.ValueAsPercent = false;
            piePointOptions1.ValueNumericOptions.Format = DevExpress.XtraCharts.NumericFormat.Number;
            piePointOptions1.ValueNumericOptions.Precision = 0;

            // this is the label with the name and value
            var piePointOptions2 = series1.LegendPointOptions as DevExpress.XtraCharts.PiePointOptions;
            piePointOptions2.PointView = DevExpress.XtraCharts.PointView.ArgumentAndValues;
            piePointOptions2.ValueNumericOptions.Format = DevExpress.XtraCharts.NumericFormat.Percent;
            piePointOptions2.ValueNumericOptions.Precision = 0;
            piePointOptions2.PercentOptions.ValueAsPercent = true;
            piePointOptions2.Pattern = "{V} : {A} ";

            //sorting by argument or by value
            PercentageValueSortingOption sortby = property.Statistics.PercentageValueSortBy;
            if (sortby == null ||
                sortby == PercentageValueSortingOption.PercentageDescending)
            {
                series1.SeriesPointsSorting = DevExpress.XtraCharts.SortingMode.Descending;
                series1.SeriesPointsSortingKey = DevExpress.XtraCharts.SeriesPointKey.Value_1;
            }
            else if (sortby == PercentageValueSortingOption.PercentageAscending)
            {
                series1.SeriesPointsSorting = DevExpress.XtraCharts.SortingMode.Ascending;
                series1.SeriesPointsSortingKey = DevExpress.XtraCharts.SeriesPointKey.Value_1;
            }
            else if (sortby == PercentageValueSortingOption.ValueDescending)
            {
                series1.SeriesPointsSorting = DevExpress.XtraCharts.SortingMode.Descending;
                series1.SeriesPointsSortingKey = DevExpress.XtraCharts.SeriesPointKey.Argument;
            }
            else if (sortby == PercentageValueSortingOption.ValueAscending)
            {
                series1.SeriesPointsSorting = DevExpress.XtraCharts.SortingMode.Ascending;
                series1.SeriesPointsSortingKey = DevExpress.XtraCharts.SeriesPointKey.Argument;
            }

            //set the data base on the statistics.data
            property.Statistics.Data = GetetStatisticsData(template, property.Statistics);

            //add data to the charts
            int cnt = 0;

            var sorted = property.Statistics.Data.OrderBy(e => e.Value);
            foreach (var item in sorted)
            {

                var seriesPoint1 = new DevExpress.XtraCharts.SeriesPoint(item.Key, new object[] { ((object)(item.Value)) }, cnt);
                cnt++;
                series1.Points.Add(seriesPoint1);
            }

            if (!string.IsNullOrEmpty(property.Statistics.ChartTitle))
            {
                DevExpress.XtraCharts.ChartTitle newChartTitle = new DevExpress.XtraCharts.ChartTitle { Text = property.Statistics.ChartTitle };
                newChartTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, FontStyle.Bold);
                newChartTitle.Alignment = StringAlignment.Near;
                newChartTitle.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Top;
                chart1.Titles.Add(newChartTitle);
            }

            //Add total items
            int totalCategory = property.Statistics.Data.Count;

            if (property.Statistics.IsTotalCountVisible)
            {
                int totalCount = GetTotalItems(property.Statistics.Data);
                DevExpress.XtraCharts.ChartTitle totalitems = new DevExpress.XtraCharts.ChartTitle { Text = "Total items: " + totalCount };
                totalitems.Font = new System.Drawing.Font("Tahoma", 8F, FontStyle.Bold);
                totalitems.Alignment = StringAlignment.Near;
                totalitems.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Bottom;
                chart1.Titles.Add(totalitems);
            }
            //chart1.SizeF = new System.Drawing.SizeF(505.2083F, 100 + (totalCategory * 60));
            if (property.Statistics.GraphSize == GraphSize.Small)
                chart1.SizeF = new System.Drawing.SizeF(505.2083F, 300);
            else if (property.Statistics.GraphSize == GraphSize.Normal)
                chart1.SizeF = new System.Drawing.SizeF(505.2083F, 500);
            else if (property.Statistics.GraphSize == GraphSize.Large)
                chart1.SizeF = new System.Drawing.SizeF(505.2083F, 700);
            return chart1;
        }
Exemplo n.º 5
0
        public void LoadTemplateProperty(TemplateProperty property)
        {
            foreach (Band band in this.Bands)
            {
                //set PageNumber's visibility
                SetPageNumberVisibility(band, property.IsPageNumberVisible);

            }
            foreach (Band band in this.Bands)
            {
                //Add pagebreak, textfield, or statistics;
                if (band is ReportHeaderBand)
                {
                    float ylocation = 0F;
                    float xlocation = 0F;
                    foreach (XRControl control in band.Controls)
                    {
                        var ylocationTmp = control.HeightF + control.LocationF.Y;
                        if (ylocationTmp > ylocation)
                        {
                            ylocation = ylocationTmp;
                            xlocation = control.LocationF.X;
                        }
                    }
                    List<XRControl> list = CreateXRControlList(property, (band as ReportHeaderBand), ylocation + 30, xlocation);
                    band.Controls.AddRange(list.ToArray());
                    break;
                }
            }
        }
Exemplo n.º 6
0
 private void simpleButtonClear_Click(object sender, EventArgs e)
 {
     templateData = new TemplateProperty
     {
         DynamicProperty = new List<TemplateDynamicData>(),
         IsFooterVisible = true,
         IsPageNumberVisible = true,
         IsEmptyDynamicValueVisible = false
     };
     reportTemplatePropertyGrid1.CreateDefaultLayoutSetting(templateData);
 }
Exemplo n.º 7
0
        private void LoadLayoutSettings()
        {
            if (gvReportTemplate.RowCount < 1)
                return;

            templateData.DynamicProperty = null;
            CTAdditionalDataReportTemplate _item = gvReportTemplate.GetFocusedRow() as CTAdditionalDataReportTemplate;
            if (string.IsNullOrEmpty(_item.data_config)) {
                reportTemplatePropertyGrid1.CreateDefaultLayoutSetting();
                return;
            }

            /**
             * auto load selected report template item data config.
             */
            templateData = SerializeUtility.DeserializeFromXml<TemplateProperty>(_item.data_config);
            reportTemplatePropertyGrid1.CreateReportLayoutSettings(templateData);
        }
Exemplo n.º 8
0
        private void LoadLayoutSettings()
        {
            if (gvReportTemplate.RowCount < 1)
                return;

            //vGridControlProperty.Rows.Clear();
            templateData.DynamicProperty = null;
            CTAdditionalDataReportTemplate _item = gvReportTemplate.GetFocusedRow() as CTAdditionalDataReportTemplate;
            if (string.IsNullOrEmpty(_item.data_config))
            {
                templateData = new TemplateProperty
                {
                    DynamicProperty = new List<TemplateDynamicData>(),
                    IsFooterVisible = true,
                    IsPageNumberVisible = true,
                    IsEmptyDynamicValueVisible = false
                };

                reportTemplatePropertyGrid.CreateDefaultLayoutSetting(templateData);
                return;
            }
            reportTemplatePropertyGrid.ColumnList = ColumnNameList;
            /**
             * auto load selected report template item data config.
             */
            templateData = SerializeUtility.DeserializeFromXml<TemplateProperty>(_item.data_config);
            reportTemplatePropertyGrid.CreateReportLayoutSettings(templateData);
        }
Exemplo n.º 9
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);
                        }
                    }
                }
            }
Exemplo n.º 10
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
            }
Exemplo n.º 11
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;
            }
Exemplo n.º 12
0
 private void simpleButtonClear_Click(object sender, EventArgs e)
 {
     WaitDialog.Show("Clearing grid ...");
     templateData = new TemplateProperty {
         DynamicProperty = new List<TemplateDynamicData>(),
         IsFooterVisible = true,
         IsPageNumberVisible = true,
         IsEmptyDynamicValueVisible = false
     };
     vgridReportParameter.CreateDefaultLayoutSetting(templateData);
     WaitDialog.Close();
 }
Exemplo n.º 13
0
        private void LoadParameterSettings(bool pLoadFromTemplate = true)
        {
            if (gvReportTemplateParameterTab.RowCount < 1)
                return;

            string _DataConfig = string.Empty;
            templateData.DynamicProperty = null;

            if (pLoadFromTemplate) {
                CTAdditionalDataReportTemplate _item = gvReportTemplateParameterTab.GetFocusedRow() as CTAdditionalDataReportTemplate;
                _DataConfig = GetDataConfig(_item.id);
            }
            else {
                using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                    view_configuration _eftViewConfig = _efDbContext.view_configuration.FirstOrDefault(i => i.id == m_efoViewConfig.id);
                    _DataConfig = _eftViewConfig.report_data_config;
                    _efDbContext.Detach(_eftViewConfig);
                }
            }

            if (string.IsNullOrEmpty(_DataConfig)) {
                vgridReportParameter.CreateDefaultLayoutSetting();
                return;
            }

            /**
             * auto load selected report template item data config.
             */
            templateData = SerializeUtility.DeserializeFromXml<TemplateProperty>(_DataConfig);
            vgridReportParameter.CreateReportLayoutSettings(templateData);
            this.SetStatisticsAvailableColumns();
        }
Exemplo n.º 14
0
 public XtraReportDefaultTemplate(string layout, TemplateProperty property)
 {
     LoadLayoutFromString(layout);
     LoadTemplateProperty(property);
 }
Exemplo n.º 15
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);
                        }
                    }
                }
            }
Exemplo n.º 16
0
        private List<KeyValuePair<string, int>> GetetStatisticsData(TemplateProperty template, StatisticsTemplate statisticsTemplate)
        {
            string name = statisticsTemplate.ColumnName;
            Dictionary<string, int> tempList = new Dictionary<string, int>();
            List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>();

            foreach (DataRow row in template.StatisticsDataSource.Rows)
            {
                string val = row[name].ToString();

                if (statisticsTemplate.IsNullCategoryVisible && string.IsNullOrEmpty(val))
                    val = "Null value";
                else if (!statisticsTemplate.IsNullCategoryVisible && string.IsNullOrEmpty(val))
                    continue;

                if (string.IsNullOrEmpty(val))
                    continue;

                if (tempList.ContainsKey(val))
                {
                    tempList[val] = tempList[val] + 1;
                }
                else
                {
                    tempList.Add(val, 1);
                }
            }
            foreach (var val in tempList)
            {
                list.Add(new KeyValuePair<string, int>(val.Key, val.Value));
            }

            return list;
        }
Exemplo n.º 17
0
        private void EditorDisplayViewReportTemplate_Load(object sender, EventArgs e)
        {
            try
            {
                templateData = new TemplateProperty
                {
                    DynamicProperty = new List<TemplateDynamicData>(),
                    IsFooterVisible = true,
                    IsPageNumberVisible = true
                };
                reportTemplatePropertyGrid.CreateDefaultLayoutSetting(templateData);
                this.LoadAdditionalDataReportTemplates();
                lblCampaignInformation.Text = string.Format(
                    "Current Campaign: {0}{2}Current View: {1}{3}",
                    CampaignInfo,
                    ViewInfo,
                    Environment.NewLine,
                    Environment.NewLine
                );

                /**
                 * create table entry for this view if not yet existing.
                 */
                m_efeExportViewTemplate = m_efDbModel.export_view_report_templates.FirstOrDefault(i =>
                    i.sub_campaign_id == SubCampaignId &&
                    i.view_config_id == ViewConfigId
                );

                if (m_efeExportViewTemplate == null)
                {
                    string _LayoutConfig = null;
                    additional_data_report_templates _efeReportTemplate = m_efDbModel.additional_data_report_templates.FirstOrDefault(i => i.is_default == true);
                    if (_efeReportTemplate != null)
                        _LayoutConfig = _efeReportTemplate.layout_config;

                    m_efeExportViewTemplate = new export_view_report_templates()
                    {
                        sub_campaign_id = SubCampaignId,
                        view_config_id = ViewConfigId,
                        layout_config = _LayoutConfig,
                        created_on = DateTime.Now,
                        created_by = UserSession.CurrentUser.UserId,
                        modified_on = DateTime.Now,
                        modified_by = UserSession.CurrentUser.UserId
                    };
                    if (_efeReportTemplate != null)
                    {
                        m_efeExportViewTemplate.additional_data_report_template_id = _efeReportTemplate.id;
                        m_efDbModel.export_view_report_templates.AddObject(m_efeExportViewTemplate);
                        m_efDbModel.SaveChanges();
                    }
                }
                else if (m_efeExportViewTemplate.additional_data_report_template_id == null || m_efeExportViewTemplate.layout_config == null)
                {
                    string _LayoutConfig = null;
                    additional_data_report_templates _efeReportTemplate = m_efDbModel.additional_data_report_templates.FirstOrDefault(i => i.is_default == true);
                    if (_efeReportTemplate != null)
                        _LayoutConfig = _efeReportTemplate.layout_config;

                    m_efeExportViewTemplate = new export_view_report_templates()
                    {
                        sub_campaign_id = SubCampaignId,
                        view_config_id = ViewConfigId,
                        layout_config = _LayoutConfig,
                        additional_data_report_template_id = _efeReportTemplate.id,
                        created_on = DateTime.Now,
                        created_by = UserSession.CurrentUser.UserId,
                        modified_on = DateTime.Now,
                        modified_by = UserSession.CurrentUser.UserId
                    };
                    m_efDbModel.export_view_report_templates.AddObject(m_efeExportViewTemplate);
                    m_efDbModel.SaveChanges();
                }

                SetInitialSelectedRow(m_efeExportViewTemplate);
                WaitDialog.Close();
            }
            catch (Exception ee)
            {

            }
        }