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 ObjData GetDataObject(List <ObjData> AllReturnData, Int64 Key)
        {
            ObjData RetEntity = new ObjData();

            foreach (ObjData Entity in AllReturnData)
            {
                if (Entity.ID == Key)
                {
                    RetEntity = Entity;
                    break;
                }
            }
            return(RetEntity);
        }
        private void GetFormateData(out List <ObjData> dataout, List <ObjData> datain)
        {
            List <ObjData> data = new List <ObjData>();

            foreach (ObjData d in datain)
            {
                ObjData rd = new ObjData();
                foreach (ObjValue value in d.Values)
                {
                    if (rd.Values == null)
                    {
                        rd.Values = new List <ObjValue>();
                    }
                    if (!value.FieldName.Contains(".Diff") && value.ValueData != null)
                    {
                        string StringFormat = DicMeasuresFormat[value.FieldName];
                        if (StringFormat.Contains("C"))
                        {
                            string MinusSign = "";
                            if (Convert.ToDouble(value.ValueData) < 0)
                            {
                                MinusSign = "-";
                            }
                            int NativeValue = decimal.ToInt32(Convert.ToDecimal(value.ValueData));
                            if (NativeValue < 0)
                            {
                                NativeValue = NativeValue * -1;
                            }
                            value.ValueData = string.Format("{0:" + StringFormat + "}", Convert.ToDouble(value.ValueData));
                            value.ValueData = value.ValueData.Replace(Convert.ToString(NativeValue), MinusSign + Convert.ToString(NativeValue));
                        }
                        if (StringFormat.Contains("$"))
                        {
                            int NativeValue = decimal.ToInt32(Convert.ToDecimal(value.ValueData));
                            if (NativeValue < 0)
                            {
                                NativeValue = NativeValue * -1;
                            }
                            value.ValueData = string.Format("{0:" + StringFormat + "}", Convert.ToDouble(value.ValueData));
                        }
                        else
                        {
                            value.ValueData = string.Format("{0:" + StringFormat + ";" + StringFormat + ";0}", Convert.ToDouble(value.ValueData));
                        }
                    }
                    else if (value.FieldName.Contains(".Diff") && value.ValueData != null)
                    {
                        if (value.FieldName.Contains(".DiffAbs"))
                        {
                            value.ValueData = string.Format("{0:" + ConfigurationSettings.AppSettings["EdgeBI.Web.DataServices.MeasureDataService.Formating.Diff.Abs"].ToString() + "}", Convert.ToDouble(value.ValueData));//"{0:0.##}"
                        }
                        else if (value.FieldName.Contains(".DiffRel"))
                        {
                            value.ValueData = string.Format("{0:" + ConfigurationSettings.AppSettings["EdgeBI.Web.DataServices.MeasureDataService.Formating.Diff.Rel"].ToString() + "}", Convert.ToDouble(value.ValueData));//"{0:0.##}"
                        }
                    }
                    rd.ID   = d.ID;
                    rd.Name = d.Name;
                    rd.Values.Add(value);
                }
                data.Add(rd);
            }
            dataout = data;
        }