/// <summary> /// Reads the list. /// </summary> /// <param name="parentSiteUrl">The parent site URL.</param> /// <param name="listName">Name of the list.</param> /// <param name="queryString">The query string.</param> /// <param name="viewFields">The view fields.</param> /// <returns></returns> public DataTable ReadList(String parentSiteUrl, String listName, String queryString, string viewFields) { DataTable objDataTable = null; Common objCommon = null; try { objDataTable = new DataTable(); objCommon = new Common(); //Reads the sharepoint List if(queryString.Length == 0) { objDataTable = objCommon.ReadList(parentSiteUrl, listName); } else { objDataTable = objCommon.ReadList(parentSiteUrl, listName, queryString, viewFields); } } catch(Exception) { throw; } finally { if(objDataTable != null) objDataTable.Dispose(); } return objDataTable; }
/// <summary> /// Gets the userpreferences value. /// </summary> /// <returns></returns> public UserPreferences GetUserPreferencesValue(string userID, string parentSiteURL) { Common objCommon = null; UserPreferences objPreferences = null; UserPreferenceHandler objUserPreferenceHandler = null; DataTable objDefaultPreferences = null; try { objCommon = new Common(); objPreferences = new UserPreferences(); objUserPreferenceHandler = new UserPreferenceHandler(); objPreferences = objUserPreferenceHandler.GetUserPreferences(userID); if(objPreferences != null) { return objPreferences; } else { //Read 'Default Preferences' list and set to the object objDefaultPreferences = new DataTable(); objPreferences = new UserPreferences(); objDefaultPreferences = objCommon.ReadList(parentSiteURL, DEFAULTPREFERENCESLIST); foreach(DataRow objDataRow in objDefaultPreferences.Rows) { if(string.Equals(objDataRow["Title"].ToString(), "Display")) { objPreferences.Display = objDataRow["Default_x0020_Value"].ToString(); } else if(string.Equals(objDataRow["Title"].ToString(), "DepthUnits")) { objPreferences.DepthUnits = objDataRow["Default_x0020_Value"].ToString(); } else if(string.Equals(objDataRow["Title"].ToString(), "RecordsPerPage")) { objPreferences.RecordsPerPage = objDataRow["Default_x0020_Value"].ToString(); } } return objPreferences; } } catch(Exception) { throw; } finally { if(objDefaultPreferences != null) objDefaultPreferences.Dispose(); } }
/// <summary> /// Determines whether [is request exist] [the specified parent site URL]. /// </summary> /// <param name="parentSiteURL">The parent site URL.</param> /// <param name="strUserID">The STR user ID.</param> /// <returns> /// <c>true</c> if [is request exist] [the specified parent site URL]; otherwise, <c>false</c>. /// </returns> public bool IsRequestExist(string parentSiteURL, string userID) { DataTable objListData = null; string strCamlQuery = string.Empty; Common objCommon = null; try { objCommon = new Common(); strCamlQuery = "<OrderBy><FieldRef Name=\"LinkTitleNoMenu\" /></OrderBy><Where><And><Eq><FieldRef Name=\"LinkTitle\" /><Value Type=\"Computed\">" + userID + "</Value></Eq><Eq><FieldRef Name=\"Access_x0020_Approval_x0020_Stat\" /><Value Type=\"Choice\">Approved</Value></Eq></And></Where>"; objListData = objCommon.ReadList(parentSiteURL, "User Access Request", strCamlQuery); if(objListData.Rows.Count > 0) { return true; } else { return false; } } catch(Exception) { throw; } finally { if(objListData != null) objListData.Dispose(); } }
/// <summary> /// Determines whether the logged in user is a valid user or not. /// </summary> /// <param name="parentSiteURL">The parent site URL.</param> /// <param name="strUserID">Logged in userID.</param> /// <returns> /// <c>true</c> if the logged in user is a valid User; otherwise, <c>false</c>. /// </returns> public bool IsValidUser(string parentSiteURL, string userID) { #region Method Variables string strCompanyCode = string.Empty; string strCountryCode = string.Empty; string[] arrUserDetails = new string[2]; string strCAMLQuery = string.Empty; string strCompanyCountryCode = string.Empty; bool blnStatus = false; DataTable objListData = null; DataTable objCompanyList = null; Common objCommon = null; #endregion try { objListData = new DataTable(); objCompanyList = new DataTable(); objCommon = new Common(); userID = objUtility.GetUserName(); try { strCompanyCountryCode = objADService.GetCompanyCountryCode(userID).ToString(); if (strCompanyCountryCode.Length > 0) arrUserDetails = strCompanyCountryCode.Split('|'); else arrUserDetails = null; } catch (Exception Ex) { CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), Ex, 5); } if (arrUserDetails != null) { if (arrUserDetails[0] != null) strCountryCode = arrUserDetails[0]; if (arrUserDetails[1] != null) strCompanyCode = arrUserDetails[1]; strCAMLQuery = "<OrderBy><FieldRef Name=\"Title\" /></OrderBy><Where><Eq>" + "<FieldRef Name=\"Title\" /><Value Type=\"Text\">" + strCountryCode + "</Value></Eq></Where>"; objListData = objCommon.ReadList(parentSiteURL, COUNTRYCODELIST, strCAMLQuery); strCAMLQuery = "<OrderBy><FieldRef Name=\"Title\" /></OrderBy><Where><Eq>" + "<FieldRef Name=\"Title\"/><Value Type=\"Text\">" + strCompanyCode + "</Value></Eq></Where>"; objCompanyList = objCommon.ReadList(parentSiteURL, COMPANYCODELIST, strCAMLQuery); //if both the Country & Company code of logged in user's exist in SP list.. if ((objListData.Rows.Count > 0) && (objCompanyList.Rows.Count > 0)) { blnStatus = true; } else { objListData.Clear(); strCAMLQuery = "<OrderBy><FieldRef Name=\"Title\" /></OrderBy><Where><And><And><Eq>" + "<FieldRef Name=\"Active\" /><Value Type=\"Text\">Yes</Value></Eq>" + "<Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + userID + "</Value></Eq></And><Eq><FieldRef Name=\"Access_x0020_Approval_x0020_Stat\" /><Value Type=\"Choice\">Approved</Value></Eq></And></Where>"; objListData = objCommon.ReadList(parentSiteURL, USERACCESSREQUESTLIST, strCAMLQuery); if (objListData.Rows.Count > 0) { blnStatus = true; } else { blnStatus = false; } } } else { objListData.Clear(); strCAMLQuery = "<OrderBy><FieldRef Name=\"Title\" /></OrderBy><Where><And><And><Eq>" + "<FieldRef Name=\"Active\" /><Value Type=\"Text\">Yes</Value></Eq>" + "<Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + userID + "</Value></Eq></And><Eq><FieldRef Name=\"Access_x0020_Approval_x0020_Stat\" /><Value Type=\"Choice\">Approved</Value></Eq></And></Where>"; objListData = objCommon.ReadList(parentSiteURL, USERACCESSREQUESTLIST, strCAMLQuery); if (objListData.Rows.Count > 0) { blnStatus = true; } else { blnStatus = false; } } return blnStatus; } catch (Exception) { throw; } finally { if (objListData != null) objListData.Dispose(); if (objCompanyList != null) objCompanyList.Dispose(); } }