/// <summary>
        /// Date:25/11/2016 #2819 Following method is created to load _ViewAllReportTable partial view(pop-up)
        /// </summary>

        public async Task <PartialViewResult> LoadReportTablePartial(int Id, string Container, string[] SDV, string ViewBy = "Q", string StartDate = "01/01/1900", string EndDate = "01/01/2100", int DashboardId = 0, int DashboardPageid = 0, int DashboardContentId = 0, string DisplayName = "")
        {
            ReportTableParameters objReportTable = new ReportTableParameters();

            objReportTable.Id          = Id;
            objReportTable.DisplayName = DisplayName;
            objReportTable.Container   = Container;
            //SDV is parameter to pass selected filter
            objReportTable.SDV                = SDV;
            objReportTable.TopOnly            = false;
            objReportTable.ViewBy             = ViewBy;
            objReportTable.StartDate          = StartDate;
            objReportTable.EndDate            = EndDate;
            objReportTable.DashboardId        = DashboardId;
            objReportTable.DashboardPageid    = DashboardPageid;
            objReportTable.DashboardContentId = DashboardContentId;
            await Task.Delay(1);

            return(PartialView("_ViewAllReportTable", objReportTable));
        }
        /// <summary>
        /// Action method to load DrillDownDetail partial view
        /// </summary>
        /// //Start- By Nandish Shah For Ticket #2820
        public async Task <PartialViewResult> LoadDrillDownData(string DbName, int Id, string DisplayName, string DimensionValueName, string DimensionValueCount, string DimensionActualValueCount, string HeaderDimensionValue, string DashboardContentId, string DashboardId, string MeasureName, string childchartid, string CustomQuery, int HelpTextId = 0, bool IsSortByValue = false, string SortOrder = "desc", string ChartType = "")
        {
            DrillDownDetails objDrillDownDetails = new DrillDownDetails();

            objDrillDownDetails.ChartId                   = Id;
            objDrillDownDetails.DisplayName               = DisplayName;
            objDrillDownDetails.DimensionValueName        = DimensionValueName;
            objDrillDownDetails.DimensionValueCount       = DimensionValueCount;
            objDrillDownDetails.DimensionActualValueCount = DimensionActualValueCount;
            objDrillDownDetails.HeaderDimensionValue      = HeaderDimensionValue;
            objDrillDownDetails.childchartid              = childchartid;
            int _dashboardContentId;

            int.TryParse(DashboardContentId, out _dashboardContentId);
            objDrillDownDetails.DashboardContentId = _dashboardContentId;
            int _dashboardId;

            int.TryParse(DashboardId, out _dashboardId);
            objDrillDownDetails.DashboardId = _dashboardId;
            objDrillDownDetails.MeasureName = MeasureName;
            if (string.IsNullOrEmpty(CustomQuery))
            {
                CustomQuery = "0";
            }
            objDrillDownDetails.CustomQuery   = CustomQuery;
            objDrillDownDetails.HelpTextId    = HelpTextId;
            objDrillDownDetails.IsSortByValue = IsSortByValue;
            objDrillDownDetails.SortOrder     = SortOrder;
            objDrillDownDetails.ChartType     = ChartType;

            string AuthorizedReportAPIUserName = string.Empty;
            string AuthorizedReportAPIPassword = string.Empty;
            string ApiUrl           = string.Empty;
            string ConnectionString = string.Empty;

            if (!string.IsNullOrEmpty(DbName) && string.Compare(DbName, Convert.ToString(Enums.ApplicationCode.RPC), true) == 0)
            {
                // Get Measure Connection String
                ConnectionString = Sessions.User.UserApplicationId.Where(o => o.ApplicationTitle == Enums.ApplicationCode.RPC.ToString()).Select(o => o.ConnectionString).FirstOrDefault();
            }

            if (ConfigurationManager.AppSettings.Count > 0)
            {
                if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["AuthorizedReportAPIUserName"])))
                {
                    AuthorizedReportAPIUserName = System.Configuration.ConfigurationManager.AppSettings.Get("AuthorizedReportAPIUserName");
                }
                if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["AuthorizedReportAPIPassword"])))
                {
                    AuthorizedReportAPIPassword = System.Configuration.ConfigurationManager.AppSettings.Get("AuthorizedReportAPIPassword");
                }
                if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["IntegrationApi"])))
                {
                    ApiUrl = System.Configuration.ConfigurationManager.AppSettings.Get("IntegrationApi");
                    if (!string.IsNullOrEmpty(ApiUrl) && !ApiUrl.EndsWith("/"))
                    {
                        ApiUrl += "/";
                    }
                }
                try
                {
                    HttpClient client = new HttpClient();

                    int    CommonWebAPITimeout = 0;
                    string strwebAPITimeout    = System.Configuration.ConfigurationManager.AppSettings["CommonIntegrationWebAPITimeOut"];
                    if (!string.IsNullOrEmpty(strwebAPITimeout))
                    {
                        CommonWebAPITimeout = Convert.ToInt32(strwebAPITimeout);
                    }

                    client.Timeout = TimeSpan.FromHours(CommonWebAPITimeout); //set timeout for Common Integration API call
                    client.Timeout = TimeSpan.FromHours(3);                   //set timeout for Common Integration API call

                    Uri baseAddress = new Uri(ApiUrl);
                    client.BaseAddress = baseAddress;

                    ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                    ConnectionString = string.Concat(ConnectionString, " multipleactiveresultsets=True;");
                    ReportTableParameters objParams = new ReportTableParameters();

                    if (string.IsNullOrEmpty(DashboardId))
                    {
                        DashboardId = "0";
                    }
                    objParams.DashboardId        = Convert.ToInt32(DashboardId);
                    objParams.DashboardContentId = _dashboardContentId;
                    objParams.UserName           = AuthorizedReportAPIUserName;
                    objParams.Password           = AuthorizedReportAPIPassword;
                    objParams.ConnectionString   = ConnectionString;


                    HttpResponseMessage response = await client.PostAsJsonAsync("api/Report/LoadDrillDownData ", objParams);

                    if (response != null && response.Content.ReadAsStringAsync().Result != null)
                    {
                        List <SelectListItem> lstDispBy = JsonConvert.DeserializeObject <List <SelectListItem> >(response.Content.ReadAsStringAsync().Result);
                        ViewData["DisplayBy"] = lstDispBy;
                    }
                }
                catch (Exception ex)
                {
                    ErrorSignal.FromCurrentContext().Raise(ex);
                }
            }

            return(PartialView("_DrillDownDetails", objDrillDownDetails));
        }
        /// <summary>
        /// Add By Nandish Shah
        /// Get Report table Data
        /// </summary>
        public async Task <string> GetReportTable(int Id, string DbName, string Container, string[] SDV, bool TopOnly = true, string ViewBy = "Q", string StartDate = "01/01/1900", string EndDate = "01/01/2100", int DashboardId = 0, int DashboardPageid = 0, int DashboardContentId = 0)
        {
            string AuthorizedReportAPIUserName = string.Empty;
            string AuthorizedReportAPIPassword = string.Empty;
            string ApiUrl           = string.Empty;
            string ConnectionString = string.Empty;

            Sessions.ViewByValue = ViewBy;
            if (SDV != null && SDV.Count() == 1 && string.IsNullOrEmpty(SDV[0]))
            {
                SDV = null;
            }
            if (!string.IsNullOrEmpty(DbName) && DbName == Convert.ToString(Enums.ApplicationCode.RPC))
            {
                // Get Measure Connection String
                ConnectionString = Sessions.User.UserApplicationId.Where(o => o.ApplicationTitle == Enums.ApplicationCode.RPC.ToString()).Select(o => o.ConnectionString).FirstOrDefault();
            }

            if (ConfigurationManager.AppSettings.Count > 0)
            {
                if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["AuthorizedReportAPIUserName"])))
                {
                    AuthorizedReportAPIUserName = System.Configuration.ConfigurationManager.AppSettings.Get("AuthorizedReportAPIUserName");
                }
                if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["AuthorizedReportAPIPassword"])))
                {
                    AuthorizedReportAPIPassword = System.Configuration.ConfigurationManager.AppSettings.Get("AuthorizedReportAPIPassword");
                }
                if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["IntegrationApi"])))
                {
                    ApiUrl = System.Configuration.ConfigurationManager.AppSettings.Get("IntegrationApi");
                    if (!string.IsNullOrEmpty(ApiUrl) && !ApiUrl.EndsWith("/"))
                    {
                        ApiUrl += "/";
                    }
                }

                try
                {
                    HttpClient client = new HttpClient();

                    int    CommonWebAPITimeout = 0;
                    string strwebAPITimeout    = System.Configuration.ConfigurationManager.AppSettings["CommonIntegrationWebAPITimeOut"];
                    if (!string.IsNullOrEmpty(strwebAPITimeout))
                    {
                        CommonWebAPITimeout = Convert.ToInt32(strwebAPITimeout);
                    }

                    client.Timeout = TimeSpan.FromHours(CommonWebAPITimeout); //set timeout for Common Integration API call
                    client.Timeout = TimeSpan.FromHours(3);                   //set timeout for Common Integration API call

                    Uri baseAddress = new Uri(ApiUrl);
                    client.BaseAddress = baseAddress;

                    ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                    ConnectionString = ConnectionString + " multipleactiveresultsets=True;";
                    ReportTableParameters objParams = new ReportTableParameters();
                    objParams.Id = Id;
                    objParams.ConnectionString = ConnectionString;
                    objParams.Container        = Container;
                    objParams.SDV = SDV;

                    objParams.TopOnly            = TopOnly;
                    objParams.ViewBy             = ViewBy;
                    objParams.StartDate          = StartDate;
                    objParams.EndDate            = EndDate;
                    objParams.UserName           = AuthorizedReportAPIUserName;
                    objParams.Password           = AuthorizedReportAPIPassword;
                    objParams.DashboardId        = DashboardId;
                    objParams.DashboardPageid    = DashboardPageid;
                    objParams.DashboardContentId = DashboardContentId;
                    objParams.UserId             = Convert.ToString(Sessions.User.UserId);
                    objParams.RoleId             = Convert.ToString(Sessions.User.RoleId);

                    HttpResponseMessage response = await client.PostAsJsonAsync("api/Report/GetReportTable ", objParams);

                    return(response.Content.ReadAsStringAsync().Result);
                }
                catch (Exception ex)
                {
                    ErrorSignal.FromCurrentContext().Raise(ex);
                }
            }
            return(string.Empty);
        }