/// <summary>
    /// Get language list
    /// </summary>
    /// <param name="requestParam"></param>
    /// <returns></returns>
    public string AdminGetAllLanguageList()
    {
        string RetVal = string.Empty;

        string LanguageFile = string.Empty;
        XmlDocument XmlDoc;
        XmlNodeList LngCodeList;
        DataTable DtLanguage;
        HTMLTableGenerator TableGenerator;

        try
        {
            DtLanguage = new DataTable();
            DtLanguage.Columns.Add("LngId");
            DtLanguage.Columns.Add("Language Name");
            DtLanguage.Columns.Add("Language Code");
            DtLanguage.Columns.Add("Page Direction");

            LanguageFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.LanguageFile]);
            XmlDoc = new XmlDocument();
            XmlDoc.Load(LanguageFile);

            LngCodeList = XmlDoc.SelectNodes("/" + Constants.XmlFile.Language.Tags.Root + "/child::node()");

            foreach (XmlNode xNode in LngCodeList)
            {
                DataRow Row;
                Row = DtLanguage.NewRow();
                Row[0] = xNode.Attributes[Constants.XmlFile.Language.Tags.LanguageAttributes.Code].Value;
                Row[1] = xNode.Attributes[Constants.XmlFile.Language.Tags.LanguageAttributes.Name].Value;
                Row[2] = xNode.Attributes[Constants.XmlFile.Language.Tags.LanguageAttributes.Code].Value;
                Row[3] = xNode.Attributes[Constants.XmlFile.Language.Tags.LanguageAttributes.RTLDirection].Value == "T" ? "rtl" : "ltr";

                DtLanguage.Rows.Add(Row);
            }

            TableGenerator = new HTMLTableGenerator();
            TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
            RetVal = TableGenerator.GetTableHmtl(DtLanguage, "LngId", "Lng", true);
        }
        catch (Exception ex)
        {
            Global.CreateExceptionString(ex, null);
        }

        return RetVal;
    }
    /// <summary>
    /// Get required database details for editing
    /// </summary>
    /// <param name="requestParam"></param>
    /// <returns></returns>
    public string AdminGetAllDbConnections(string requestParam)
    {
        string RetVal = string.Empty;
        string CategoryName = string.Empty;

        string DBFile = string.Empty;
        XmlDocument XmlDoc;
        XmlNode xmlNode;
        DataTable DtDatabase;
        HTMLTableGenerator TableGenerator;
        int i = 0;
        string DefDbNId = string.Empty;
        string ConnStr = string.Empty;
        string DbType = string.Empty;
        string DbTypeStr = string.Empty;
        //  string DefalutStr = string.Empty;

        try
        {
            CategoryName = requestParam;

            DefDbNId = Global.GetDefaultDbNId();

            DtDatabase = new DataTable();
            DtDatabase.Columns.Add("DbId");
            DtDatabase.Columns.Add("Connection Name");
            DtDatabase.Columns.Add("Database NId");
            DtDatabase.Columns.Add("Database Type");
            DtDatabase.Columns.Add("Created On");
            //    DtDatabase.Columns.Add("Default");

            DBFile = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, ConfigurationManager.AppSettings[Constants.WebConfigKey.DBConnectionsFile]);
            XmlDoc = new XmlDocument();
            XmlDoc.Load(DBFile);

            xmlNode = XmlDoc.SelectSingleNode("/" + Constants.XmlFile.Db.Tags.Root + "/" + Constants.XmlFile.Db.Tags.Category + "[@" + Constants.XmlFile.Db.Tags.CategoryAttributes.Name + "='" + CategoryName + "']");

            for (i = 0; i < xmlNode.ChildNodes.Count; i++)
            {
                if (xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.SDMXDb].Value.ToLower() == "false")
                {
                    DataRow Row;
                    Row = DtDatabase.NewRow();
                    Row[0] = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value;
                    Row[1] = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Name].Value;
                    Row[2] = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.Id].Value;

                    ConnStr = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.DatabaseConnection].Value;

                    if (!string.IsNullOrEmpty(ConnStr))
                    {
                        DbType = Global.SplitString(ConnStr, "||")[0];
                    }
                    if (DbType == "0")
                    {
                        DbTypeStr = "Sql Server";
                    }
                    else if (DbType == "3")
                    {
                        DbTypeStr = "My Sql";
                    }
                    else if (DbType == "8")
                    {
                        DbTypeStr = "Firebird";
                    }
                    else
                    {
                        DbTypeStr = "";
                    }

                    Row[3] = DbTypeStr;
                    Row[4] = xmlNode.ChildNodes[i].Attributes[Constants.XmlFile.Db.Tags.DatabaseAttributes.LastModified].Value;
                    DtDatabase.Rows.Add(Row);
                }
            }

            TableGenerator = new HTMLTableGenerator();
            TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
            RetVal = TableGenerator.GetTableHmtl(DtDatabase, "DbId", "db", true);
        }
        catch (Exception ex)
        {
            //Global.WriteErrorsInLog("Getting all database connection");
            //Global.WriteErrorsInLog(ex.StackTrace);
            //Global.WriteErrorsInLog(ex.Message);
            Global.CreateExceptionString(ex, null);
        }

        return RetVal;
    }
    public string GetAllUsers(string requestParam)
    {
        string RetVal = string.Empty;
        int AdapNId;
        string[] Params;
        string sortExp = "";
        HTMLTableGenerator TableGenerator;
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            AdapNId = int.Parse(Params[0]);
            int CurrentPage = int.Parse(Params[1]);
            if (Params.Length > 1)
            {
                sortExp = Params[3].ToString() + " " + Params[2].ToString();
            }
            DataSet dsUsers = new DataSet();
            AdaptationUsers.AdaptationUsers UserLoginService = new AdaptationUsers.AdaptationUsers();
            UserLoginService.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.AdaptationUserWebService;
            dsUsers = UserLoginService.GetGlobalUsers(AdapNId);
            DataTable dtUsers = dsUsers.Tables[0].Clone();
            for (int i = ((CurrentPage - 1) * Convert.ToInt32(Global.AdapUserPageSize)) + 1; i <= (CurrentPage * Convert.ToInt32(Global.AdapUserPageSize)); i++)
            {
                if (i <= dsUsers.Tables[0].Rows.Count)
                {
                    DataRow newRow = dsUsers.Tables[0].Rows[i - 1];
                    dtUsers.ImportRow(newRow);
                }
                else
                {
                    break;
                }
            }
            if (sortExp != "")
            {
                dtUsers.DefaultView.Sort = sortExp;
            }
            TableGenerator = new HTMLTableGenerator();
            TableGenerator.ShowSorting = true;
            TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
            RetVal = TableGenerator.GetTableHmtl(dtUsers.DefaultView.ToTable(), "NId", "AdapUser", true) + Constants.Delimiters.ParamDelimiter + CalPageCount((dsUsers.Tables[0].Rows.Count), Convert.ToInt32(Global.AdapUserPageSize));

        }

        catch (Exception ex)
        {
            Global.CreateExceptionString(ex, null);
        }
        return RetVal;
    }
    ///// <summary>
    ///// Get all users of current Adaptation
    ///// </summary>
    ///// <param name="requestParam"></param>
    ///// <returns></returns>
    //public string GetCurentAdaptationsUser(string requestParam)
    //{
    //    string RetVal = string.Empty;
    //    int AdapNId;
    //    string[] Params;
    //    string sortExp = "";
    //    HTMLTableGenerator TableGenerator;
    //    //string AdaptationURl = string.Empty;
    //    try
    //    {
    //        Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
    //        AdapNId = int.Parse(Params[0]); // Not in use now
    //        int CurrentPage = int.Parse(Params[1]);
    //        if (Params.Length > 1)
    //        {
    //            sortExp = Params[3].ToString() + " " + Params[2].ToString();
    //        }
    //        // Get Adaptation URL
    //        //AdaptationURl = Global.GetAdaptationUrl();
    //        DataSet dsUsers = new DataSet();
    //        AdaptationUsers.AdaptationUsers UserLoginService = new AdaptationUsers.AdaptationUsers();
    //        UserLoginService.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.AdaptationUserWebService;
    //        // Get ALL the users of current Adaptation by Adaptation URL
    //        dsUsers = UserLoginService.GetUsersByAdaptationURL(Global.GetAdaptationGUID());
    //        DataTable dtUsers = dsUsers.Tables[0].Clone();
    //        // Set Paging and creatwe data table
    //        for (int i = ((CurrentPage - 1) * Convert.ToInt32(Global.AdapUserPageSize)) + 1; i <= (CurrentPage * Convert.ToInt32(Global.AdapUserPageSize)); i++)
    //        {
    //            if (i <= dsUsers.Tables[0].Rows.Count)
    //            {
    //                DataRow newRow = dsUsers.Tables[0].Rows[i - 1];
    //                dtUsers.ImportRow(newRow);
    //            }
    //            else
    //            {
    //                break;
    //            }
    //        }
    //        // Sort Result
    //        if (sortExp != "")
    //        {
    //            dtUsers.DefaultView.Sort = sortExp;
    //        }
    //        TableGenerator = new HTMLTableGenerator();
    //        TableGenerator.ShowSorting = true;
    //        TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
    //        RetVal = TableGenerator.GetTableHmtl(dtUsers.DefaultView.ToTable(), "NId", "AdapUser", true) + Constants.Delimiters.ParamDelimiter + CalPageCount((dsUsers.Tables[0].Rows.Count), Convert.ToInt32(Global.AdapUserPageSize));
    //    }
    //    catch (Exception ex)
    //    {
    //        Global.CreateExceptionString(ex, null);
    //    }
    //    return RetVal;
    //}
    public string GetCurentAdaptationsUser(string requestParam)
    {
        //////string RetVal = string.Empty;
        //////string[] Params;
        //////string sortExp = "";
        //////HTMLTableGenerator TableGenerator;
        //////string SearchStr = string.Empty;
        //////DataView DefDataView = null;
        //////try
        //////{
        //////    Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
        //////    int CurrentPage = int.Parse(Params[1]);
        //////    if (Params.Length > 1)
        //////    {
        //////        sortExp = Params[3].ToString() + " " + Params[2].ToString();
        //////        if (Params.Length > 4)
        //////        {
        //////            SearchStr = Params[4].ToString();
        //////        }
        //////    }
        //////    DataSet dsUsers = new DataSet();
        //////    AdaptationUsers.AdaptationUsers UserLoginService = new AdaptationUsers.AdaptationUsers();
        //////    UserLoginService.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.AdaptationUserWebService;
        //////    // Get ALL the users of current Adaptation Guid
        //////    dsUsers = UserLoginService.GetUsersByAdaptationURL(Global.GetAdaptationGUID());
        //////    DataTable DTFullTable = dsUsers.Tables[0];
        //////    DataTable DTFullTableClone = null;
        //////    if (Convert.ToBoolean(Global.ShowWebmasterAccount) == false)
        //////    {
        //////        DTFullTableClone = dsUsers.Tables[0].Clone();
        //////        DataRow[] Drows = DTFullTable.Select("IsMasterAccount <> 'true'");
        //////        foreach (DataRow dr in Drows)
        //////        {
        //////            DTFullTableClone.ImportRow(dr);
        //////        }
        //////    }
        //////    else
        //////    {
        //////        DTFullTableClone = DTFullTable;
        //////    }
        //////    DTFullTableClone.Columns.Remove("IsMasterAccount");
        //////    //dsUsers.Tables[0].Columns.Remove("IsMasterAccount");
        //////    //dsUsers.Tables[0] = DTFullTable;
        //////    DataTable dtUsers = dsUsers.Tables[0].Clone();
        //////    DataTable dtTempUsers = dsUsers.Tables[0].Clone();
        //////    DefDataView = new DataView();

        //////    if (!string.IsNullOrEmpty(SearchStr))
        //////    {
        //////        var FilteredTable = DTFullTableClone.Select(@"UserName like '%" + SearchStr + "%' or EmailId like '%" + SearchStr + "%'", sortExp);
        //////        foreach (DataRow Dr in FilteredTable)
        //////        {
        //////            dtTempUsers.ImportRow(Dr);
        //////        }

        //////        if (dtTempUsers.Rows.Count > 0)
        //////        {
        //////            DefDataView = dtTempUsers.DefaultView;
        //////        }
        //////    }
        //////    else
        //////    {
        //////        DefDataView = DTFullTableClone.DefaultView;
        //////    }
        //////    if (!string.IsNullOrEmpty(sortExp) && DefDataView.Table != null && DefDataView.Table.Rows != null && DefDataView.Table.Rows.Count > 0)
        //////    {
        //////        DefDataView.Sort = sortExp;
        //////        dtTempUsers = DefDataView.ToTable();
        //////    }

        //////    // Set Paging and creatwe data table
        //////    for (int i = ((CurrentPage - 1) * Convert.ToInt32(Global.AdapUserPageSize)) + 1; i <= (CurrentPage * Convert.ToInt32(Global.AdapUserPageSize)); i++)
        //////    {
        //////        if (i <= dtTempUsers.Rows.Count)
        //////        {
        //////            DataRow newRow = dtTempUsers.Rows[i - 1];
        //////            dtUsers.ImportRow(newRow);
        //////        }
        //////        else
        //////        {
        //////            break;
        //////        }
        //////    }

        //////    TableGenerator = new HTMLTableGenerator();
        //////    TableGenerator.ShowSorting = true;
        //////    TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
        //////    RetVal = TableGenerator.GetTableHmtl(dtUsers.DefaultView.ToTable(), "NId", "AdapUser", true) + Constants.Delimiters.ParamDelimiter + CalPageCount((dtTempUsers.Rows.Count), Convert.ToInt32(Global.AdapUserPageSize));
        //////}

        //////catch (Exception ex)
        //////{
        //////    Global.CreateExceptionString(ex, null);
        //////}
        //////return RetVal;

        string RetVal = string.Empty;
        string[] Params;
        string sortExp = "";
        HTMLTableGenerator TableGenerator;
        string SearchStr = string.Empty;
        DataView DefDataView = null;
        try
        {
            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            int CurrentPage = int.Parse(Params[1]);
            if (Params.Length > 1)
            {
                sortExp = Params[3].ToString() + " " + Params[2].ToString();
                if (Params.Length > 4)
                {
                    SearchStr = Params[4].ToString();
                }
            }
            DataSet dsUsers = new DataSet();
            AdaptationUsers.AdaptationUsers UserLoginService = new AdaptationUsers.AdaptationUsers();
            UserLoginService.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.AdaptationUserWebService;
            // Get ALL the users of current Adaptation Guid
            //dsUsers = UserLoginService.GetUsersByAdaptationURL(Global.GetAdaptationGUID());
            DataTable dtUsers = dsUsers.Tables[0].Clone();
            DataTable dtTempUsers = dsUsers.Tables[0].Clone();
            DefDataView = new DataView();
            if (!string.IsNullOrEmpty(SearchStr))
            {
                var FilteredTable = dsUsers.Tables[0].Select(@"UserName like '%" + SearchStr + "%' or EmailId like '%" + SearchStr + "%'", sortExp);
                foreach (DataRow Dr in FilteredTable)
                {
                    dtTempUsers.ImportRow(Dr);
                }

                if (dtTempUsers.Rows.Count > 0)
                {
                    DefDataView = dtTempUsers.DefaultView;
                }
            }
            else
            {
                DefDataView = dsUsers.Tables[0].DefaultView;
            }
            if (!string.IsNullOrEmpty(sortExp) && DefDataView.Table != null && DefDataView.Table.Rows != null && DefDataView.Table.Rows.Count > 0)
            {
                DefDataView.Sort = sortExp;
                dtTempUsers = DefDataView.ToTable();
            }

            // Set Paging and creatwe data table
            for (int i = ((CurrentPage - 1) * Convert.ToInt32(Global.AdapUserPageSize)) + 1; i <= (CurrentPage * Convert.ToInt32(Global.AdapUserPageSize)); i++)
            {
                if (i <= dtTempUsers.Rows.Count)
                {
                    DataRow newRow = dtTempUsers.Rows[i - 1];
                    dtUsers.ImportRow(newRow);
                }
                else
                {
                    break;
                }
            }

            TableGenerator = new HTMLTableGenerator();
            TableGenerator.ShowSorting = true;
            TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
            RetVal = TableGenerator.GetTableHmtl(dtUsers.DefaultView.ToTable(), "NId", "AdapUser", true) + Constants.Delimiters.ParamDelimiter + CalPageCount((dtTempUsers.Rows.Count), Convert.ToInt32(Global.AdapUserPageSize));
        }

        catch (Exception ex)
        {
            Global.CreateExceptionString(ex, null);
        }
        return RetVal;
    }
    public string GetAllUsersGridHTML()
    {
        string RetVal = string.Empty;

        DataTable DtUsers;
        DIConnection DIConnection = null;
        HTMLTableGenerator TableGenerator;

        try
        {
            //AdaptationUrl = Global.GetAdaptationUrl();
            GlobalUserWebService.Url = ConfigurationManager.AppSettings[Constants.WebConfigKey.DiWorldWide4] + Constants.WSQueryStrings.UserLoginService;
            if (ConfigurationManager.AppSettings[Constants.WebConfigKey.IsGlobalAllow].ToLower() == "true")
            {
                DtUsers = GlobalUserWebService.GetAllUsersGridHTML(Global.GetAdaptationGUID());
            }
            else
            {
                DIConnection = new DIConnection(DIServerType.MsAccess, string.Empty, string.Empty, Server.MapPath("~//stock//Database.mdb"),
                          string.Empty, string.Empty);
                string Query = "SELECT NId, User_Email_Id as Email, User_First_Name as [Name], User_Country as [User Country], User_Is_Admin as [Admin User], User_Is_Admin as [Provider User], User_Send_Updates AS [Send Updates] FROM Users Where User_Is_Admin = 'False'";

                DtUsers = DIConnection.ExecuteDataTable(Query);
            }

            DtUsers = this.Replace_AreaNIds_With_Names(DtUsers);

            TableGenerator = new HTMLTableGenerator();
            TableGenerator.RowDisplayType = HTMLTableGenerator.DisplayType.RadioButtonType;
            RetVal = TableGenerator.GetTableHmtl(DtUsers, "NId", "usr", true);
        }
        catch (Exception ex)
        {
            Global.CreateExceptionString(ex, null);

            throw ex;
        }
        finally
        {
            if (DIConnection != null)
            {
                DIConnection.Dispose();
            }
        }

        return RetVal;
    }