private void GetData(string sql, Dictionary <string, ObjData> arrAllReturnData, out Dictionary <string, ObjData> arrAllReturnDataout)
 {
     using (DataManager.Current.OpenConnection())
     {
         SqlCommand searchEngineCmd = DataManager.CreateCommand(ConfigurationSettings.AppSettings["EdgeBI.Web.DataServices.MeasureDataService.Commands.GetData"].ToString(), CommandType.StoredProcedure);
         searchEngineCmd.CommandTimeout           = (60 * 1000) * 5;
         searchEngineCmd.Parameters["@Sql"].Value = sql;
         SqlDataReader reader = searchEngineCmd.ExecuteReader();
         while (reader.Read())
         {
             ObjData _Data;
             if (arrAllReturnData.ContainsKey(reader["ID"].ToString()))
             {
                 _Data = arrAllReturnData[reader["ID"].ToString()];
             }
             else
             {
                 _Data = new ObjData();
                 if (!reader["ID"].Equals(System.DBNull.Value))
                 {
                     _Data.ID = Convert.ToInt64(reader["ID"]);
                 }
                 if (!reader["NAME"].Equals(System.DBNull.Value))
                 {
                     _Data.Name = (string)reader["Name"];
                 }
             }
             for (int i = 2; i < reader.FieldCount; i++)
             {
                 ObjValue _value = new ObjValue();
                 _value.FieldName = reader.GetName(i).ToString();
                 if (!reader[_value.FieldName].Equals(System.DBNull.Value))
                 {
                     _value.ValueData = Convert.ToString(reader[_value.FieldName]);
                 }
                 if (_Data.Values == null)
                 {
                     _Data.Values = new List <ObjValue>();
                 }
                 _Data.Values.Add(_value);
             }
             if (arrAllReturnData.ContainsKey(reader["ID"].ToString()))
             {
                 arrAllReturnData[reader["ID"].ToString()] = _Data;
             }
             else
             {
                 arrAllReturnData.Add(reader["ID"].ToString(), _Data);
             }
         }
         reader.Close();
     }
     arrAllReturnDataout = arrAllReturnData;
 }
        private void GetDiffCalculation(out List <ObjData> dataout, List <ObjData> datain, MeasureDiff[] diff)
        {
            List <ObjData> retdata = new List <ObjData>();

            foreach (ObjData Entity in datain)
            {
                Dictionary <string, ArrayList> EntityValues = new Dictionary <string, ArrayList>();;
                if (Entity.Values.Count > 1)
                {
                    foreach (ObjValue lvalue in Entity.Values)
                    {
                        string    mName = lvalue.FieldName.Substring(0, lvalue.FieldName.IndexOf("."));
                        ArrayList values;
                        if (EntityValues.ContainsKey(mName))
                        {
                            values = EntityValues[mName];
                        }
                        else
                        {
                            values = new ArrayList();
                        }

                        values.Add(lvalue);
                        if (EntityValues.ContainsKey(mName))
                        {
                            EntityValues[mName] = values;
                        }
                        else
                        {
                            EntityValues.Add(mName, values);
                        }
                    }
                    foreach (string key in EntityValues.Keys)
                    {
                        ArrayList values = EntityValues[key];
                        for (int i = 0; i < values.Count - 1; i++)
                        {
                            double   value1, value2;
                            ObjValue objvalue1 = (ObjValue)values[i];
                            ObjValue objvalue2 = (ObjValue)values[i + 1];

                            value1 = Convert.ToDouble(objvalue1.ValueData);
                            value2 = Convert.ToDouble(objvalue2.ValueData);
                            ObjValue    value    = new ObjValue();
                            MeasureDiff mDiff    = GetMeasureDiff(key, diff);
                            DiffType    difftype = mDiff.DiffType;
                            if (mDiff.MeasureIndex > -1)
                            {
                                switch (difftype)
                                {
                                case DiffType.Both:
                                    value.FieldName = key + ".R" + (i + 1).ToString() + ".DiffAbs";
                                    value.ValueData = Convert.ToString(value1 - value2);
                                    Entity.Values.Add(value);
                                    value           = new ObjValue();
                                    value.FieldName = key + ".R" + (i + 1).ToString() + ".DiffRel";
                                    if (value2 != 0)
                                    {
                                        value.ValueData = Convert.ToString(((value1 - value2) / Math.Abs(value2)) * 100);
                                    }
                                    break;

                                case DiffType.DiffAbs:
                                    value.FieldName = key + ".R" + (i + 1).ToString() + ".DiffAbs";
                                    value.ValueData = Convert.ToString(value1 - value2);
                                    break;

                                case DiffType.DiffRel:
                                    value.FieldName = key + ".R" + (i + 1).ToString() + ".DiffRel";
                                    if (value2 != 0)
                                    {
                                        value.ValueData = Convert.ToString(((value1 - value2) / Math.Abs(value2)) * 100);
                                    }
                                    break;
                                }
                            }
                            Entity.Values.Add(value);
                        }
                    }
                    retdata.Add(Entity);
                }
            }
            dataout = retdata;
        }