Exemplo n.º 1
0
        //Modified at 2008-11-20 13:31:43@Scott
        private void CalculateDistFrequence(DataTable i_Table, Webb.Collections.Int32Collection i_Rows)
        {
            if (i_Table.Columns.Contains(this._FieldName))
            {
                ArrayList arrValue = new ArrayList();

                foreach (int row in i_Rows)
                {
                    object value = i_Table.Rows[row][this._FieldName];

                    if (arrValue.Contains(value))
                    {
                        continue;
                    }
                    else
                    {
                        arrValue.Add(value);
                    }
                }

                this._Result.Add(arrValue.Count);
            }
            else
            {
                this._Result.Add(0);
            }
        }
Exemplo n.º 2
0
        public void GetResult(System.Data.DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows)
        {
            RowIndicators.Clear();

            FieldGroupInfo m_GroupInfo = new FieldGroupInfo();

            m_GroupInfo.GroupByField  = this.SortingField;
            m_GroupInfo.ColumnHeading = this.SortingField;

            m_GroupInfo.CalculateGroupResult(i_Table, i_OuterRows, i_OuterRows, m_GroupInfo);

            if (m_GroupInfo.GroupResults == null || m_GroupInfo.GroupResults.Count <= 0)
            {
                return;
            }

            m_GroupInfo.GroupResults.Sort(this.Sorting, this.SortingBy, m_GroupInfo.UserDefinedOrders);

            foreach (GroupResult gr in m_GroupInfo.GroupResults)
            {
                if (gr.RowIndicators.Count > 0)
                {
                    RowIndicators.Add(gr.RowIndicators[0]);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Calculate grouped result
        /// </summary>
        /// <param name="i_Table">data source</param>
        public override void CalculateResult(DataTable i_Table)
        {
            //Convert old group struct to new one
            ConvertOldGroupInfo(this._RootGroupInfo);

            //If have no data source ,clear group struct
            if (i_Table == null)
            {
                this.RootGroupInfo.ClearGroupResult(this._RootGroupInfo);

                return;
            }

            //Filter rows
            Webb.Collections.Int32Collection m_Rows = this.OneValueScFilter.Filter.GetFilteredRows(i_Table);

            m_Rows = this.RepeatFilter.Filter.GetFilteredRows(i_Table, m_Rows);                  //Added this code at 2008-12-26 12:22:40@Simon

            m_Rows = this.Filter.GetFilteredRows(i_Table, m_Rows);

            m_Rows.CopyTo(this.FilteredRows);

            //Find and create section filters
            //this.CheckSectionFilters();

            //Calculate group result
            this._RootGroupInfo.CalculateGroupResult(i_Table, m_Rows, m_Rows, this.RootGroupInfo);

            //Calculate Total
            //Int32Collection totalIndicators = this.GetAllTotalIndicators();

            //if(this.Total) this.CalculateAllTotal(i_Table,totalIndicators.Count,totalIndicators);
        }
Exemplo n.º 4
0
//		public bool CheckOldResult(DataRow row)	//old check result method
//		{
//			try
//			{
//				//12-17-2007@Scott
//				BoolStack stack = new BoolStack();
//
//				this.InnerList.Reverse();
//
//				foreach(DBCondition condition in this)
//				{
//					bool bResult = condition.CheckResult(row);
//
//					BoolResult br = new BoolResult(bResult,condition.Bracket,condition.FollowedOperand);
//
//					stack.Push(br);
//				}
//				BoolResult result = stack.GetResult();
//
//				this.InnerList.Reverse();
//
//				return result.Result;
//			}
//			catch(Exception ex)
//			{
//				System.Diagnostics.Debug.WriteLine("Check filter result error. Message:"+ex.Message);
//
//				return false;
//			}
//		}

        //06-04-2008@Scott
        public Int32Collection GetFilteredRows(System.Data.DataTable table, Webb.Collections.Int32Collection baseRows)
        {
            if (this.InnerList.Count == 0 && !this.PlayAfter)
            {
                return(baseRows);
            }

            Int32Collection filteredRows = new Int32Collection();

            foreach (int row in baseRows)
            {
                if (table.Rows.Count <= row)
                {
                    continue;
                }

                //if(this.CheckResult(table.Rows[row],0,this.Count - 1))	//Modified at 2009-2-13 13:40:23@Scott
                if (this.CheckResultWithBracket(table.Rows[row]))                       //Modified at 2009-2-16 16:38:31@Scott
                {
                    if (this.PlayAfter && table.Rows.Count > row + 1)
                    {
                        filteredRows.Add(row + 1);
                    }
                    else
                    {
                        filteredRows.Add(row);
                    }
                }
            }

            return(filteredRows);
        }
Exemplo n.º 5
0
        public void GetResult(System.Data.DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows)
        {
            Int32Collection filteredRows = this.Filter.GetFilteredRows(i_Table, i_OuterRows);

            if (filteredRows.Count > 0)
            {
                _RowIndicator = filteredRows[0];
            }
        }
Exemplo n.º 6
0
        //04-11-2008@Scott
        private void CalculateMin(DataTable i_Table, Webb.Collections.Int32Collection i_Rows)
        {
            double m_Min = 0, m_Temp = 0;

            if (!i_Table.Columns.Contains(this._FieldName))
            {
                goto EXIT;
            }

            if (i_Rows.Count <= 0)
            {
                goto EXIT;
            }

            int i = 0;

            for (; i < i_Rows.Count; i++)
            {
                try
                {
                    string strValue = i_Table.Rows[i_Rows[i]][this._FieldName].ToString();

                    if (strValue == null || strValue == string.Empty)
                    {
                        continue;
                    }

                    m_Min = Convert.ToDouble(strValue);

                    break;
                }
                catch { continue; }
            }

            for (i++; i < i_Rows.Count; i++)
            {
                try
                {
                    string strValue = i_Table.Rows[i_Rows[i]][this._FieldName].ToString();

                    if (strValue == null || strValue == string.Empty)
                    {
                        continue;
                    }

                    m_Temp = Convert.ToDouble(strValue);

                    if (m_Temp < m_Min)
                    {
                        m_Min = m_Temp;
                    }
                }
                catch { continue; }
            }
EXIT:
            this._Result.Add(m_Min);
        }
Exemplo n.º 7
0
        private Int32Collection GetFilteredRows(System.Data.DataTable i_Table, Webb.Collections.Int32Collection i_Rows, Webb.Data.DBFilter filter)
        {//06-04-2008@Scott
            if (filter == null || i_Table == null || i_Rows == null)
            {
                return(i_Rows);
            }

            return(filter.GetFilteredRows(i_Table, i_Rows));
        }
Exemplo n.º 8
0
        //Modified at 2008-11-20 13:31:48@Scott
        private void CalculateDistPercent(DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_InnerRows)
        {
            int nInnerCount = 0, nOuterCount = 0;

            if (i_Table.Columns.Contains(this._FieldName))
            {
                ArrayList arrValue = new ArrayList();

                foreach (int row in i_InnerRows)
                {
                    object value = i_Table.Rows[row][this._FieldName];

                    if (arrValue.Contains(value))
                    {
                        continue;
                    }
                    else
                    {
                        arrValue.Add(value);
                    }
                }

                nInnerCount = arrValue.Count;

                arrValue.Clear();

                foreach (int row in i_OuterRows)
                {
                    object value = i_Table.Rows[row][this._FieldName];

                    if (arrValue.Contains(value))
                    {
                        continue;
                    }
                    else
                    {
                        arrValue.Add(value);
                    }
                }

                nOuterCount = arrValue.Count;

                if (nOuterCount == 0)
                {
                    this._Result.Add(0);
                }
                else
                {
                    this._Result.Add((double)nInnerCount / nOuterCount);
                }
            }
            else
            {
                this._Result.Add(0);
            }
        }
Exemplo n.º 9
0
        public override ArrayList GetFields(DataTable table, Webb.Collections.Int32Collection rows)
        {
            ArrayList m_tempList = new ArrayList();

            foreach (SectionFilter m_Section in this.SectionFilters)
            {
                m_tempList.Add(m_Section.FilterName);
            }
            return(m_tempList);
        }
Exemplo n.º 10
0
        //Modified at 2008-11-11 16:12:33@Scott
        private void CalculateOneValuePercent(DataTable i_Table, Webb.Collections.Int32Collection i_FilteredRows /*outer filter*/, Webb.Collections.Int32Collection i_Rows /*inner filter*/)
        {
            Int32Collection filteredRows = this.DenominatorFilter.GetFilteredRows(i_Table);     //Modified at 2008-11-28 11:11:57@Scott

            if (i_Table != null && filteredRows.Count > 0)
            {
                float percent = (float)(i_Rows.Count) / filteredRows.Count;

                this._Result.Add(percent);
            }
            else
            {
                this._Result.Add(0.0f);
            }
        }
Exemplo n.º 11
0
        //calculate result for printing table
        public override void CalculateResult(DataTable i_Table)
        {
            if (this._RootGroupInfo == null)
            {
                return;
            }

            Webb.Collections.Int32Collection m_Rows = new Webb.Collections.Int32Collection();

            for (int i = 0; i < i_Table.Rows.Count; i++)
            {
                if (this.Filter.CheckResult(i_Table.Rows[i]))
                {
                    m_Rows.Add(i);
                }
            }
            this._RootGroupInfo.CalculateGroupResult(i_Table, m_Rows.Count, m_Rows, this.RootGroupInfo);
        }
Exemplo n.º 12
0
        public override void CalculateResult(DataTable i_Table)
        {
            GroupView.ConvertOldGroupInfo(this._RootGroupInfo);

            if (i_Table == null)
            {
                this.RootGroupInfo.ClearGroupResult(this._RootGroupInfo);

                return;
            }

            Webb.Collections.Int32Collection m_Rows = this.OneValueScFilter.Filter.GetFilteredRows(i_Table);

            m_Rows = this.RepeatFilter.Filter.GetFilteredRows(i_Table, m_Rows);                  //Added this code at 2008-12-26 12:22:40@Simon

            m_Rows = this.Filter.GetFilteredRows(i_Table, m_Rows);

            this.AddSummaries(this._Series);                    //create summaries by series

            this._RootGroupInfo.CalculateGroupResult(i_Table, m_Rows, m_Rows, this._RootGroupInfo);

            switch (this.AppearanceType)
            {            //calculate chart
            case ChartAppearanceType.Pie:
            {
//					Pie pie = new Pie();
//					this.Chart = pie.CalculatePie(i_Table,this._RootGroupInfo,this.Filter,this.OneValueScFilter);
//					if(this.Chart is PieChart)
//					{
//						PieChart pieChart = this.Chart as PieChart;
//						pieChart.GradientText = this.GradientText;
//						pieChart.Position = this.TextPosition;
//					}
                break;
            }

            default:
                break;
            }
        }
Exemplo n.º 13
0
//        public override void CalculateGroupResult(DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_FilterRows, Webb.Collections.Int32Collection i_InnerRows, GroupInfo i_GroupInfo)
//        {
//            i_GroupInfo.UpdateSectionSummaries();	//Modified at 2009-1-21 15:08:49@Scott

//            this._Filter=AdvFilterConvertor.GetAdvFilter(DataProvider.VideoPlayBackManager.AdvReportFilters,this._Filter);    //2009-4-29 11:37:37@Simon Add UpdateAdvFilter

//            //Added this code at 2008-12-22 8:29:27@Simon
//            #region Modified Area
//            if(this._GroupResults == null) this._GroupResults = new GroupResultCollection();
//            this._GroupResults.Clear();

//            i_InnerRows=this.Filter.GetFilteredRows(i_Table,i_InnerRows);   //Added this code at 2008-12-24 8:26:50@Simon

//            i_FilterRows=this.Filter.GetFilteredRows(i_Table,i_FilterRows);   //Added this code at 2008-12-24 8:26:50@Simon

//            if(this.SectionFilters.Count>0)
//            {
//                if (this.AddTotal)
//                {
//                    GroupResult m_GroupResult = new GroupResult();

//                    m_GroupResult.Filter = new Webb.Data.DBFilter();

//                    m_GroupResult.GroupValue = this.TotalTitle;

//                    m_GroupResult.ParentGroupInfo = this;  //Add at 2009-2-19 14:23:47@Simon

//                    m_GroupResult.ClickEvent = i_GroupInfo.ClickEvent;

//                    this._GroupResults.Add(m_GroupResult);
//                }

//                int LimitCount=0;

//                foreach(SectionFilter m_Section in this.SectionFilters)
//                {
//                   if(this.TopCount>0&&LimitCount>=this.TopCount)break;   //Added this code at 2009-2-9 9:36:32@Simon

//                    GroupResult m_Result = new GroupResult();

//                    m_Result.GroupValue = m_Section.FilterName;

//                    m_Result.Filter = m_Section.Filter;

//                    m_Result.ParentGroupInfo = this;

//                    m_Result.ClickEvent = i_GroupInfo.ClickEvent;

//                    this._GroupResults.Add(m_Result);

//                    LimitCount++;
//                }

//                foreach(GroupResult m_GroupResult in this.GroupResults)
//                {
//                    m_GroupResult.ClickEvent = this.ClickEvent;	//12-28-2007@Scott

//                    m_GroupResult.CalculateRowIndicators(i_Table,i_InnerRows);

//                    if(this.Summaries != null)
//                    {
//                        m_GroupResult.Summaries = this.Summaries.CopyStructure();
//                        m_GroupResult.CalculateSummaryResult(i_Table,i_OuterRows,i_InnerRows);
//                    }
//                }
//            }
//            else
//            {
//                GroupResult m_GroupResult = new GroupResult();
//                m_GroupResult.GroupValue = string.Empty;

//                m_GroupResult.ParentGroupInfo = this;

//                m_GroupResult.RowIndicators = new Int32Collection();
//                i_InnerRows.CopyTo(m_GroupResult.RowIndicators);
//                m_GroupResult.ClickEvent = i_GroupInfo.ClickEvent;
//                this._GroupResults.Add(m_GroupResult);

//                if(this.Summaries != null)
//                {
//                    m_GroupResult.Summaries = this.Summaries.CopyStructure();
//                    m_GroupResult.CalculateSummaryResult(i_Table,i_OuterRows,i_InnerRows);
//                }
//            }

//            if(i_GroupInfo.SubGroupInfos.Count > 0)
//            {
//                foreach(GroupResult m_GroupResult in this._GroupResults)
//                {
////					if(m_GroupResult.RowIndicators==null)continue;
////					m_GroupResult.SubGroupInfos = i_GroupInfo.SubGroupInfos.Copy();
////					foreach(GroupInfo subGroupinfo in m_GroupResult.SubGroupInfos)
////					{
////						subGroupinfo.CalculateGroupResult(i_Table, i_OuterRows,i_FilterRows, m_GroupResult.RowIndicators,subGroupinfo);
////					}

//                    if(m_GroupResult.RowIndicators==null)continue;

//                    m_GroupResult.SubGroupInfos = i_GroupInfo.SubGroupInfos.Copy();

//                    for(int i = 0; i < m_GroupResult.SubGroupInfos.Count; i++)
//                    {
//                        GroupInfo resultGroupInfo = m_GroupResult.SubGroupInfos[i];

//                        GroupInfo subGroupInfo = i_GroupInfo.SubGroupInfos[i];

//                        resultGroupInfo.IsSectionOutSide = false;
//                        subGroupInfo.IsSectionOutSide = false;

//                        System.Diagnostics.Trace.Assert(resultGroupInfo != null && subGroupInfo != null,"Calculate Section Group Error");
//                        resultGroupInfo.CalculateGroupResult(i_Table,i_OuterRows,i_FilterRows,m_GroupResult.RowIndicators,subGroupInfo);
//                    }
//                    //End Edit

//                }
//            }
//            #endregion        //Modify at 2008-12-19 11:29:27@Simon
//        }

        public override void CalculateGroupResult(DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_FilterRows, Webb.Collections.Int32Collection i_InnerRows, GroupInfo i_GroupInfo)
        {
            i_GroupInfo.UpdateSectionSummaries();                                                                             //Modified at 2009-1-21 15:08:49@Scott

            this._Filter = AdvFilterConvertor.GetAdvFilter(DataProvider.VideoPlayBackManager.AdvReportFilters, this._Filter); //2009-4-29 11:37:37@Simon Add UpdateAdvFilter

            //Added this code at 2008-12-22 8:29:27@Simon
            #region Modified Area

            if (this._GroupResults == null)
            {
                this._GroupResults = new GroupResultCollection();
            }
            this._GroupResults.Clear();

            i_InnerRows = this.Filter.GetFilteredRows(i_Table, i_InnerRows);   //Added this code at 2008-12-24 8:26:50@Simon

            i_FilterRows = this.Filter.GetFilteredRows(i_Table, i_FilterRows); //Added this code at 2008-12-24 8:26:50@Simon

            if (this.SectionFilters.Count > 0)
            {
                if (this.AddTotal)
                {
                    #region Add total
                    GroupResult m_GroupResult = new GroupResult();

                    m_GroupResult.Filter = new Webb.Data.DBFilter();

                    m_GroupResult.GroupValue = this.TotalTitle;

                    m_GroupResult.ParentGroupInfo = this;  //Add at 2009-2-19 14:23:47@Simon

                    m_GroupResult.ClickEvent = i_GroupInfo.ClickEvent;

                    i_InnerRows.CopyTo(m_GroupResult.RowIndicators);

                    this._GroupResults.Add(m_GroupResult);
                    #endregion
                }

                int LimitCount = 0;

                foreach (SectionFilter m_Section in this.SectionFilters)
                {
                    #region Add group Result

                    if (this.TopCount > 0 && LimitCount >= this.TopCount)
                    {
                        break;                                                     //Added this code at 2009-2-9 9:36:32@Simon
                    }
                    GroupResult m_Result = new GroupResult();

                    m_Result.GroupValue = m_Section.FilterName;

                    m_Result.Filter = m_Section.Filter;

                    m_Result.ParentGroupInfo = this;

                    m_Result.ClickEvent = i_GroupInfo.ClickEvent;

                    m_Result.RowIndicators = new Int32Collection();

                    m_Result.ClickEvent = this.ClickEvent;      //12-28-2007@Scott

                    this._GroupResults.Add(m_Result);

                    LimitCount++;
                    #endregion
                }
                #region Calculate result Rows

                foreach (int row in i_InnerRows)
                {
                    if (row < 0 || row >= i_Table.Rows.Count)
                    {
                        continue;
                    }

                    DataRow dataRow = i_Table.Rows[row];

                    foreach (GroupResult m_GroupResult in this.GroupResults)
                    {
                        if (m_GroupResult.Filter.CheckResultWithBracket(dataRow))        //Modified at 2009-2-16 16:38:31@Scott
                        {
                            if (m_GroupResult.Filter.PlayAfter && i_Table.Rows.Count > row + 1)
                            {
                                m_GroupResult.RowIndicators.Add(row + 1);
                            }
                            else
                            {
                                m_GroupResult.RowIndicators.Add(row);
                            }
                        }
                    }
                }
                #endregion
            }
            else
            {
                GroupResult m_GroupResult = new GroupResult();
                m_GroupResult.GroupValue = string.Empty;

                m_GroupResult.ParentGroupInfo = this;

                m_GroupResult.RowIndicators = new Int32Collection();

                i_InnerRows.CopyTo(m_GroupResult.RowIndicators);

                m_GroupResult.ClickEvent = i_GroupInfo.ClickEvent;

                this._GroupResults.Add(m_GroupResult);
            }

            foreach (GroupResult m_GroupResult in this.GroupResults)
            {
                if (this.Summaries != null)
                {
                    m_GroupResult.Summaries = this.Summaries.CopyStructure();
                    m_GroupResult.CalculateSummaryResult(i_Table, i_OuterRows, i_InnerRows);
                }
            }

            if (i_GroupInfo.SubGroupInfos.Count > 0)
            {
                foreach (GroupResult m_GroupResult in this._GroupResults)
                {
                    if (m_GroupResult.RowIndicators == null)
                    {
                        continue;
                    }

                    m_GroupResult.SubGroupInfos = i_GroupInfo.SubGroupInfos.Copy();

                    for (int i = 0; i < m_GroupResult.SubGroupInfos.Count; i++)
                    {
                        GroupInfo resultGroupInfo = m_GroupResult.SubGroupInfos[i];

                        GroupInfo subGroupInfo = i_GroupInfo.SubGroupInfos[i];

                        resultGroupInfo.IsSectionOutSide = false;
                        subGroupInfo.IsSectionOutSide    = false;

                        System.Diagnostics.Trace.Assert(resultGroupInfo != null && subGroupInfo != null, "Calculate Section Group Error");

                        resultGroupInfo.CalculateGroupResult(i_Table, i_OuterRows, i_FilterRows, m_GroupResult.RowIndicators, subGroupInfo);
                    }
                    //End Edit
                }
            }
            #endregion        //Modify at 2008-12-19 11:29:27@Simon
        }
Exemplo n.º 14
0
        //04-11-2008@Scott
        private void CalculateTotal(DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_Rows, Data.StatTypes i_Type)
        {
            decimal m_Total = 0, fieldValue = 0m;

            DateTime totalDateTime = new DateTime(0);

            Webb.Reports.DataProvider.WebbDataProvider publicprovider = Webb.Reports.DataProvider.VideoPlayBackManager.PublicDBProvider;

            bool isTimeData = (publicprovider != null && publicprovider.IsCCRMTimeData(this._FieldName));

            bool isFeetInchesData = (publicprovider != null && publicprovider.IsFeetInchesData(this._FieldName));

            if (!i_Table.Columns.Contains(this._FieldName))
            {
                goto EXIT;
            }

            foreach (int i_RowIndex in i_Rows)
            {
                try
                {
                    #region Old
                    //string strValue = i_Table.Rows[i_RowIndex][this._FieldName].ToString();

                    //if (strValue == null || strValue == string.Empty)
                    //{
                    //    continue;
                    //}

                    //decimal fieldValue = Convert.ToDecimal(strValue);

                    //switch (i_Type)
                    //{
                    //    case Data.StatTypes.TotalPlus:
                    //        if (fieldValue > 0) m_Total += fieldValue;
                    //        break;

                    //    case Data.StatTypes.TotalMinus:
                    //        if (fieldValue < 0) m_Total += fieldValue;
                    //        break;

                    //    case Data.StatTypes.Total:
                    //    default:
                    //        m_Total += fieldValue;
                    //        break;
                    //}
                    #endregion

                    #region New
                    object objValue = i_Table.Rows[i_RowIndex][this._FieldName];

                    if (objValue == null || objValue is System.DBNull)
                    {
                        continue;
                    }

                    if (isTimeData)
                    {
                        TimeSpan timeSpan = Webb.Utility.ConvertToTimeTicks(objValue.ToString());

                        totalDateTime = totalDateTime.Add(timeSpan);
                    }
                    if (isFeetInchesData)
                    {
                        fieldValue = Webb.Utility.ConvertFeetInchToNum(objValue.ToString());

                        m_Total += fieldValue;
                    }
                    else
                    {
                        #region calcaulate Numer

                        string strValue = objValue.ToString();

                        if (strValue == null || strValue == string.Empty)
                        {
                            continue;
                        }

                        fieldValue = Convert.ToDecimal(strValue);

                        switch (i_Type)
                        {
                        case Data.StatTypes.AveragePlus:
                            if (fieldValue > 0)
                            {
                                m_Total += fieldValue;
                            }
                            break;

                        case Data.StatTypes.AverageMinus:
                            if (fieldValue < 0)
                            {
                                m_Total += fieldValue;
                            }

                            break;

                        case Data.StatTypes.Average:
                        default:
                            m_Total += fieldValue;
                            break;
                        }
                        #endregion
                    }
                    #endregion
                }
                catch { continue; }
            }
EXIT:
            if (isTimeData)
            {
                object objResultValue = string.Empty;

                #region CCRM Time Description

                bool outputTimeFormat = Webb.Utility.IsTimeFormatForOut(i_Table, i_OuterRows, _FieldName);

                if (outputTimeFormat)
                {
                    if (totalDateTime.Hour > 0)
                    {
                        objResultValue = totalDateTime.ToString("h:m:s.ff");
                    }
                    else
                    {
                        objResultValue = totalDateTime.ToString("m:s.ff");;
                    }
                }
                else
                {
                    objResultValue = totalDateTime.TimeOfDay.TotalSeconds;;
                }

                this._Result.Add(objResultValue);

                #endregion
            }
            else if (isFeetInchesData)
            {
                this._Result.Add(Webb.Utility.FormatFeetInchData(m_Total));
            }
            else
            {
                this._Result.Add(m_Total);
            }
        }
Exemplo n.º 15
0
        private void CalculateAverage(DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_Rows, Data.StatTypes i_Type)
        {
            decimal m_Sum = 0, fieldValue = 0m;

            DateTime totalDateTime = new DateTime(0);

            long timeTicks = 0;

            Type type = null;

            Webb.Reports.DataProvider.WebbDataProvider publicprovider = Webb.Reports.DataProvider.VideoPlayBackManager.PublicDBProvider;

            bool isTimeData = (publicprovider != null && publicprovider.IsCCRMTimeData(this._FieldName));

            bool isFeetInchesData = (publicprovider != null && publicprovider.IsFeetInchesData(this._FieldName));

            if (!i_Table.Columns.Contains(this._FieldName))
            {
                goto EXIT;
            }

            type = i_Table.Columns[_FieldName].DataType;

            foreach (int i_RowIndex in i_Rows)
            {
                try
                {
                    #region Old
                    //string strValue = i_Table.Rows[i_RowIndex][this._FieldName].ToString();

                    //if (strValue == null || strValue == string.Empty)
                    //{
                    //    continue;
                    //}

                    //double fieldValue = Convert.ToDouble(strValue);

                    //switch (i_Type)
                    //{
                    //    case Data.StatTypes.AveragePlus:
                    //        if (fieldValue > 0) m_Sum += fieldValue;
                    //        break;

                    //    case Data.StatTypes.AverageMinus:
                    //        if (fieldValue < 0) m_Sum += fieldValue;
                    //        break;

                    //    case Data.StatTypes.Average:
                    //    default:
                    //        m_Sum += fieldValue;
                    //        break;
                    //}
                    #endregion

                    object objValue = i_Table.Rows[i_RowIndex][this._FieldName];

                    if (objValue == null || objValue is System.DBNull)
                    {
                        continue;
                    }

                    if (isTimeData)
                    {
                        TimeSpan timeSpan = Webb.Utility.ConvertToTimeTicks(objValue.ToString());

                        totalDateTime = totalDateTime.Add(timeSpan);
                    }
                    if (isFeetInchesData)
                    {
                        fieldValue = Webb.Utility.ConvertFeetInchToNum(objValue.ToString());

                        m_Sum += fieldValue;
                    }
                    else if (type == typeof(DateTime))
                    {
                        timeTicks += Convert.ToDateTime(objValue).Ticks;
                    }
                    else
                    {
                        #region calcaulate Numer

                        string strValue = objValue.ToString();

                        if (strValue == null || strValue == string.Empty)
                        {
                            continue;
                        }

                        fieldValue = Convert.ToDecimal(strValue);

                        switch (i_Type)
                        {
                        case Data.StatTypes.AveragePlus:
                            if (fieldValue > 0)
                            {
                                m_Sum += fieldValue;
                            }
                            break;

                        case Data.StatTypes.AverageMinus:
                            if (fieldValue < 0)
                            {
                                m_Sum += fieldValue;
                            }

                            break;

                        case Data.StatTypes.Average:
                        default:
                            m_Sum += fieldValue;
                            break;
                        }
                        #endregion
                    }
                }
                catch { continue; }
            }

EXIT:
            if (i_Rows.Count > 0)
            {
                #region Old
                //this._Result.Add(m_Sum / i_Rows.Count);
                #endregion

                object objResultValue = string.Empty;

                #region New
                if (type == typeof(DateTime))
                {
                    objResultValue = new DateTime(timeTicks / i_Rows.Count);

                    objResultValue = CResolveFieldValue.GetResolveValue(this._FieldName, @"M/d/yy", objResultValue);
                }
                if (isTimeData)
                {
                    timeTicks = totalDateTime.Ticks / i_Rows.Count;

                    DateTime dateTime = new DateTime(timeTicks);

                    bool outputTimeFormat = Webb.Utility.IsTimeFormatForOut(i_Table, i_OuterRows, _FieldName);

                    if (outputTimeFormat)
                    {
                        if (dateTime.Hour > 0)
                        {
                            objResultValue = dateTime.ToString("h:m:s.ff");
                        }
                        else
                        {
                            objResultValue = dateTime.ToString("m:s.ff");;
                        }
                    }
                    else
                    {
                        objResultValue = dateTime.TimeOfDay.TotalSeconds;
                    }
                }
                else if (isFeetInchesData)
                {
                    m_Sum = m_Sum / i_Rows.Count;

                    objResultValue = Webb.Utility.FormatFeetInchData(m_Sum);
                }
                else
                {
                    objResultValue = m_Sum / i_Rows.Count;
                }
                #endregion

                this._Result.Add(objResultValue);
            }
            else
            {
                this._Result.Add(0);
            }
        }
Exemplo n.º 16
0
        //		private void CalculateResultEx(System.Data.DataTable i_Table,Webb.Collections.Int32Collection i_FilteredRows/*outer filter*/, Webb.Collections.Int32Collection i_Rows/*inner filter*/)
        //		{
        //			foreach(Data.StatTypes type in this.StatTypes)
        //			{
        //				switch(type)
        //				{
        //					case Data.StatTypes.Average:
        //					case Data.StatTypes.AveragePlus:
        //					case Data.StatTypes.AverageMinus:
        //						this.CalculateAverage(i_Table, i_Rows, type);
        //						break;
        //
        //					case Data.StatTypes.Frequence:
        //						this._Result.Add(i_Rows.Count);
        //						break;
        //
        //					case Data.StatTypes.Max:
        //						this.CalculateMax(i_Table,i_Rows);
        //						break;
        //
        //					case Data.StatTypes.Min:
        //						this.CalculateMin(i_Table,i_Rows);
        //						break;
        //
        //					case Data.StatTypes.Percent:
        //						Webb.Collections.Int32Collection denominatorRows = this.GetFilteredRows(i_Table, i_FilteredRows, this._DenominatorFilter);
        //						if(denominatorRows.Count > 0)
        //						{
        //							this._Result.Add(1.0 * i_Rows.Count / denominatorRows.Count);
        //						}
        //						else
        //						{
        //							this._Result.Add(0);
        //						}
        //						break;
        //
        //					case Data.StatTypes.DistFrequence:
        //						this.CalculateDistFrequence(i_Table,i_Rows);	//Modified at 2008-11-20 13:36:28@Scott
        //						break;
        //
        //					case Data.StatTypes.DistPercent:
        //						this.CalculateDistPercent(i_Table,i_FilteredRows,i_Rows);	//Modified at 2008-11-20 13:36:31@Scott
        //						break;
        //
        //					case Data.StatTypes.Total:
        //					case Data.StatTypes.TotalPlus:
        //					case Data.StatTypes.TotalMinus:
        //						this.CalculateTotal(i_Table, i_Rows, type);
        //						break;
        //					case Data.StatTypes.OneValuePercent:	//Modified at 2008-11-11 16:10:57@Scott
        //						this.CalculateOneValuePercent(i_Table,i_FilteredRows,i_Rows);
        //						break;
        //					default:
        //						this._Result.Add(string.Empty);
        //						break;
        //				}
        //			}
        //		}

        #endregion
        private void CalculateResultEx(System.Data.DataTable i_Table, Webb.Collections.Int32Collection i_FilteredRows /*outer filter*/, Webb.Collections.Int32Collection i_Rows /*inner filter*/)
        {
            FollowedStatTypesCollection statTypesFollow = this._FollowedStatTypes;

            this.StatTypes.Clear();
            foreach (FollowedStatTypes followtype in statTypesFollow)
            {
                StatTypes type = followtype.StatTypes;
                this.StatTypes.Add(type);
                switch (type)
                {
                case Data.StatTypes.Average:
                case Data.StatTypes.AveragePlus:
                case Data.StatTypes.AverageMinus:
                    this.CalculateAverage(i_Table, i_FilteredRows, i_Rows, type);
                    break;

                case Data.StatTypes.Frequence:
                    this._Result.Add(i_Rows.Count);
                    break;

                case Data.StatTypes.Max:
                    this.CalculateMax(i_Table, i_Rows);
                    break;

                case Data.StatTypes.Min:
                    this.CalculateMin(i_Table, i_Rows);
                    break;

                case Data.StatTypes.Percent:
                    Webb.Collections.Int32Collection denominatorRows = this.GetFilteredRows(i_Table, i_FilteredRows, this._DenominatorFilter);
                    if (denominatorRows.Count > 0)
                    {
                        this._Result.Add(1.0 * i_Rows.Count / denominatorRows.Count);
                    }
                    else
                    {
                        this._Result.Add(0);
                    }
                    break;

                case Data.StatTypes.DistFrequence:
                    this.CalculateDistFrequence(i_Table, i_Rows);       //Modified at 2008-11-20 13:36:28@Scott
                    break;

                case Data.StatTypes.DistPercent:
                    this.CalculateDistPercent(i_Table, i_FilteredRows, i_Rows);         //Modified at 2008-11-20 13:36:31@Scott
                    break;

                case Data.StatTypes.Total:
                case Data.StatTypes.TotalPlus:
                case Data.StatTypes.TotalMinus:
                    this.CalculateTotal(i_Table, i_FilteredRows, i_Rows, type);
                    break;

                case Data.StatTypes.OneValuePercent:            //Modified at 2008-11-11 16:10:57@Scott
                    this.CalculateOneValuePercent(i_Table, i_FilteredRows, i_Rows);
                    break;

                default:
                    this._Result.Add(string.Empty);
                    break;
                }
            }
        }
Exemplo n.º 17
0
 public void CalculateRowIndicators(System.Data.DataTable i_Table, Webb.Collections.Int32Collection i_Rows)
 {    //06-04-2008@Scott
     this._RowIndicators = this._Filter.GetFilteredRows(i_Table, i_Rows);
 }
Exemplo n.º 18
0
        public virtual void CalculateResult(System.Data.DataTable i_Table, int i_FilteredRowsCount, Webb.Collections.Int32Collection i_Rows)
        {
            Int32Collection m_FilteredRows = this.GetFilteredRows(i_Table, i_Rows, this._Filter);

            this._RowIndicators = m_FilteredRows;

            this.Result.Clear();

            this.CalculateResultEx(i_Table, i_Rows, m_FilteredRows);
        }
Exemplo n.º 19
0
        public override void CalculateGroupResult(DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_InnerRows, GroupInfo i_GroupInfo)
        {
            i_GroupInfo.UpdateSectionSummaries();                                                                             //Modified at 2009-1-21 15:08:49@Scott

            this._Filter = AdvFilterConvertor.GetAdvFilter(DataProvider.VideoPlayBackManager.AdvReportFilters, this._Filter); //2009-4-29 11:37:37@Simon Add UpdateAdvFilter

            #region Modified Area
            if (this._GroupResults == null)
            {
                this._GroupResults = new GroupResultCollection();
            }

            this._GroupResults.Clear();

            i_InnerRows = this.Filter.GetFilteredRows(i_Table, i_InnerRows); //Added this code at 2008-12-24 8:26:50@Simon

            if (this.SectionFilters.Count > 0)                               //modify this code at 2009-2-6 10:15:01@Simon
            {
                int LimitCount = 0;

                foreach (SectionFilter m_Section in this.SectionFilters)
                {
                    if (this.TopCount > 0 && LimitCount >= this.TopCount)
                    {
                        break;                                                                  //Added this code at 2009-2-9 9:36:32@Simon
                    }
                    GroupResult m_Result = new GroupResult();
                    m_Result.GroupValue      = m_Section.FilterName;
                    m_Result.Filter          = m_Section.Filter.Copy();
                    m_Result.ParentGroupInfo = this;
                    m_Result.ClickEvent      = i_GroupInfo.ClickEvent;

                    m_Result.CalculateRowIndicators(i_Table, i_InnerRows);

                    if (m_Result.RowIndicators.Count == 0 && !this.ShowZero)
                    {
                        continue;
                    }

                    if (this.Summaries != null)
                    {
                        m_Result.Summaries = this.Summaries.CopyStructure();
                        m_Result.CalculateSummaryResult(i_Table, i_OuterRows, i_InnerRows);
                    }

                    this._GroupResults.Add(m_Result);

                    LimitCount++;
                }
            }
            else
            {
                GroupResult m_GroupResult = new GroupResult();

                m_GroupResult.GroupValue = string.Empty;

                m_GroupResult.ParentGroupInfo = this;

                m_GroupResult.RowIndicators = new Int32Collection();
                i_InnerRows.CopyTo(m_GroupResult.RowIndicators);
                m_GroupResult.ClickEvent = i_GroupInfo.ClickEvent;
                this._GroupResults.Add(m_GroupResult);

                if (this.Summaries != null)
                {
                    m_GroupResult.Summaries = this.Summaries.CopyStructure();

                    m_GroupResult.CalculateSummaryResult(i_Table, i_OuterRows, i_InnerRows);
                }
            }


            if (i_GroupInfo.SubGroupInfos.Count > 0)
            {
                foreach (GroupResult m_GroupResult in this._GroupResults)
                {
                    if (m_GroupResult.RowIndicators == null)
                    {
                        continue;
                    }
                    m_GroupResult.SubGroupInfos = i_GroupInfo.SubGroupInfos.Copy();

                    for (int i = 0; i < m_GroupResult.SubGroupInfos.Count; i++)
                    {
                        GroupInfo resultGroupInfo = m_GroupResult.SubGroupInfos[i];
                        GroupInfo subGroupInfo    = i_GroupInfo.SubGroupInfos[i];

                        resultGroupInfo.IsSectionOutSide = false;
                        subGroupInfo.IsSectionOutSide    = false;

                        System.Diagnostics.Trace.Assert(resultGroupInfo != null && subGroupInfo != null, "Calculate Section Group Error");
                        resultGroupInfo.CalculateGroupResult(i_Table, i_OuterRows, m_GroupResult.RowIndicators, subGroupInfo);
                    }
                }
            }
            #endregion                    //Modify at 2008-11-4 11:29:27@Scott
        }
Exemplo n.º 20
0
        public void CalculateSummaryResult(System.Data.DataTable i_Table, Webb.Collections.Int32Collection i_OuterRows, Webb.Collections.Int32Collection i_InnerRows)
        {
            if (this._Summaries == null)
            {
                return;
            }
            // TODO: implement
            foreach (GroupSummary m_Summary in this._Summaries)
            {
                m_Summary.ParentGroupInfo = this.ParentGroupInfo;

                if (m_Summary.SummaryType == SummaryTypes.ParentRelatedPercent)
                {
                    GroupInfo groupInfo = this.ParentGroupInfo;

                    #region Modify codes at 2009-4-8 13:22:22@Simon
                    GroupResult m_Result = groupInfo.ParentGroupResult;
                    while (m_Result != null)
                    {
                        if (m_Result.ParentGroupInfo.IsParentGroup)
                        {
                            break;
                        }

                        m_Result = m_Result.ParentGroupInfo.ParentGroupResult;
                    }

                    if (m_Result != null)
                    {
                        m_Summary.CalculateResult(i_Table, i_OuterRows, m_Result.RowIndicators, this._RowIndicators);

                        continue;
                    }
                    else if (groupInfo.ParentGroupResult != null)
                    {
                        GroupResult parentGroupResult = groupInfo.ParentGroupResult;

                        GroupInfo parentGroupInfo = parentGroupResult.ParentGroupInfo;

                        if (parentGroupInfo.ParentGroupResult != null)
                        {
                            m_Summary.CalculateResult(i_Table, i_OuterRows, parentGroupInfo.ParentGroupResult.RowIndicators /*08-27-2008@Scott*/, this._RowIndicators);

                            continue;
                        }
                    }
                    #endregion            //End Modify

                    m_Summary.CalculateResult(i_Table, i_OuterRows, i_InnerRows /*08-27-2008@Scott*/, this._RowIndicators);
                }
                else if (m_Summary.SummaryType == SummaryTypes.GroupPercent)
                {
                    #region GroupPercent

                    GroupInfo groupInfo = this.ParentGroupInfo;

                    if (groupInfo.ParentGroupResult != null)
                    {
                        GroupResult parentGroupResult = groupInfo.ParentGroupResult;

                        if (parentGroupResult != null)
                        {
                            m_Summary.CalculateResult(i_Table, i_OuterRows, parentGroupResult.RowIndicators, this._RowIndicators);

                            continue;
                        }
                    }


                    m_Summary.CalculateResult(i_Table, i_OuterRows, i_InnerRows /*08-27-2008@Scott*/, this._RowIndicators);

                    #endregion
                }
                else if (m_Summary.SummaryType == SummaryTypes.FrequenceAllData || m_Summary.SummaryType == SummaryTypes.PercentAllData)
                {
                    Int32Collection allResultRows = this.Filter.GetFilteredRows(i_Table, i_OuterRows);

                    m_Summary.CalculateResult(i_Table, i_OuterRows, allResultRows, allResultRows);
                }
                else
                {
                    m_Summary.CalculateResult(i_Table, i_OuterRows, i_InnerRows /*08-27-2008@Scott*/, this._RowIndicators);
                }
            }
        }