/// <summary> /// Saves the search XML to library. /// </summary> /// <param name="searchName">Name of the search.</param> /// <param name="saveSearchName">Name of the save search.</param> /// <param name="labelException">The label exception.</param> /// <param name="shared">if set to <c>true</c> [shared].</param> /// <param name="saveSearch">The save search.</param> /// <param name="searchRequest">The search request.</param> public void ModifySaveSearchXML(string searchName, string saveSearchName, bool shared, DropDownList saveSearch, XmlDocument searchRequest) { objMossController = objFactory.GetServiceManager(MOSSSERVICE); SaveSearchXMLGenerator objSaveSearchXMLGenerator = new SaveSearchXMLGenerator(); SaveSearchRequest objSaveSearchRequest = new SaveSearchRequest(); CommonUtility objUtility = null; try { SPSecurity.RunWithElevatedPrivileges(delegate() { objUtility = new CommonUtility(); string strUserID = objUtility.GetSaveSearchUserName(); ((MOSSServiceManager)objMossController).ModifySaveSearch(searchName, strUserID, saveSearchName, searchRequest, shared.ToString()); saveSearch.Items.Clear(); ((MOSSServiceManager)objMossController).LoadSaveSearch(searchName, saveSearch); }); } catch { throw; } }
/// <summary> /// Gets the name of the user. /// </summary> /// <returns></returns> protected string GetUserName() { string strUserName = string.Empty; objCommonUtility = new CommonUtility(); strUserName = objCommonUtility.GetSaveSearchUserName(); return strUserName; }
/// <summary> /// Loads the save search into the "Save Search" drop down box. /// </summary> /// <param name="searchType">Type of the search.</param> /// <param name="userID">The user ID.</param> /// <param name="comboBoxControl">The combo box control.</param> internal void LoadSaveSearch(string searchType, DropDownList comboBoxControl) { CommonUtility objCommonUtility = new CommonUtility(); ArrayList arlListSaveSearch = new ArrayList(); try { SPSecurity.RunWithElevatedPrivileges(delegate() { string strUserId = objCommonUtility.GetSaveSearchUserName(); arlListSaveSearch = GetSaveSearchName(searchType, strUserId); //Loops through the values in Save Search List. ListItem objItem; foreach (string strSaveSearchName in arlListSaveSearch) { objItem = new ListItem(); objItem.Text = strSaveSearchName; objItem.Value = strSaveSearchName; comboBoxControl.Items.Add(objItem); } }); } catch (Exception) { throw; } }
/// <summary> /// Renders the control to the specified HTML writer. /// </summary> /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"></see> object that receives the control content.</param> protected override void Render(HtmlTextWriter writer) { try { objMossController = objFactory.GetServiceManager("MOSSService"); // arlAdvSaveSearchNames = new ArrayList(); arlWellAdvSaveSearchNames = new ArrayList(); arlWellboreAdvSaveSearchNames = new ArrayList(); arlPARSSaveSearchNames = new ArrayList(); arlLOGSSaveSearchNames = new ArrayList(); arlFieldSaveSearchNames = new ArrayList(); arlBasinSaveSearchNames = new ArrayList(); arlQuerySaveSearchNames = new ArrayList(); arlReservoirAdvSaveSearchNames = new ArrayList(); if(Page.Request.QueryString["Type"] != null) { if(string.Equals(Page.Request.QueryString["Type"].ToString(), MANAGESEARCH)) { hidDeleteSearchName.RenderControl(writer); hidSearchType.RenderControl(writer); objUtility = new CommonUtility(); #region DeleteSearches string strUserID = objUtility.GetSaveSearchUserName(); GetSaveSearchNames(strUserID, true); //validates the Saved Searches and displays information if there are no saved searches. if((arlWellAdvSaveSearchNames.Count == 0) && (arlWellboreAdvSaveSearchNames.Count == 0) && (arlPARSSaveSearchNames.Count == 0) && (arlLOGSSaveSearchNames.Count == 0) && (arlFieldSaveSearchNames.Count == 0) && (arlBasinSaveSearchNames.Count == 0) && (arlQuerySaveSearchNames.Count == 0) && (arlReservoirAdvSaveSearchNames.Count == 0)) { writer.Write("<div id=\"divStandardSearch\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"middle\" class=\"breadcrumbRow\"><b>My Searches</b></td></tr>"); writer.Write("<tr><td height=\"10\" align=\"left\" valign=\"top\"></td></tr>"); writer.Write("<tr><td align=\"left\" valign=\"top\">"); writer.Write("<div class=\"iframeBorderException\"><table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); lblNoRecords.Text = "There are no saved searches defined."; lblNoRecords.Visible = true; writer.Write("<table><tr><td><BR/>"); lblNoRecords.RenderControl(writer); writer.Write("</td></tr></table>"); writer.Write("</table></div></td></tr></table></div>"); } else { writer.Write("<div id=\"divStandardSearch\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"middle\" class=\"breadcrumbRow\"><b>My Searches</b></td></tr>"); RenderSaveSearchLayout(writer); } #endregion writer.Write("<Script language=\"javascript\">setWindowTitle('My Searches');</Script>"); } else { #region StandardSearches GetSaveSearchNames(ADMIN, false); //validates the Saved Searches and displays information if there are no saved searches. if((arlWellAdvSaveSearchNames.Count == 0) && (arlWellboreAdvSaveSearchNames.Count == 0) && (arlPARSSaveSearchNames.Count == 0) && (arlLOGSSaveSearchNames.Count == 0) && (arlFieldSaveSearchNames.Count == 0) && (arlBasinSaveSearchNames.Count == 0) && (arlQuerySaveSearchNames.Count == 0) && (arlReservoirAdvSaveSearchNames.Count == 0)) { writer.Write("<div id=\"divStandardSearch\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"middle\" class=\"breadcrumbRow\"><b>Shared Searches</b></td></tr>"); writer.Write("<tr><td height=\"10\" align=\"left\" valign=\"top\"></td></tr>"); writer.Write("<tr><td align=\"left\" valign=\"top\">"); writer.Write("<div class=\"iframeBorderException\"><table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); lblNoRecords.Text = "There are no shared searches defined by the administrator."; lblNoRecords.Visible = true; writer.Write("<table><tr><td><BR/>"); lblNoRecords.RenderControl(writer); writer.Write("</td></tr></table>"); writer.Write("</table></div></td></tr></table></div>"); } else { writer.Write("<div id=\"divStandardSearch\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"middle\" class=\"breadcrumbRow\"><b>Shared Searches</b></td></tr>"); RenderSaveSearchLayout(writer); } #endregion writer.Write("<Script language=\"javascript\">setWindowTitle('Shared Searches');</Script>"); } } } catch(Exception ex) { CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex); } }
/// <summary> /// Loads the controls with values populated on the basis of the search name selected in the drop down list /// </summary> /// <param name="srchName"></param> private void BindUIControls(string strSrchName) { try { string strColName = string.Empty; XmlDocument xmldoc = new XmlDocument(); objUtility = new CommonUtility(); strUserID = objUtility.GetSaveSearchUserName(); xmldoc = ((MOSSServiceManager)objMossController).GetDocLibXMLFile(QUERYSEARCH, strUserID); ClearUIControls(); if(xmldoc.DocumentElement != null) { //set the node selected in tree view //codeChange querySearchTree.CollapseAllNodes(); XmlElement rootNode = xmldoc.DocumentElement; XmlNode saveSearchRequestNode = rootNode.SelectSingleNode("saveSearchRequest[@name='" + strSrchName + "']"); XmlNode entityNode = saveSearchRequestNode.SelectSingleNode(ENTITYPATH); string strDataSource = entityNode.Attributes[DATASOURCE.ToLowerInvariant()].Value; string strDataProvider = entityNode.Attributes[DATAPROVIDER.ToLowerInvariant()].Value; string strTableName = entityNode.Attributes[ATTRIBNAME].Value; //newcode RadTreeNode trvDataSourNode = querySearchTree.FindNodeByText(DATASOURCE); trvDataSourNode.Expanded = true; RadTreeNode trvDataSourceNode = trvDataSourNode.Nodes.FindNodeByText(strDataSource); trvDataSourceNode.Expanded = true; RadTreeNode trvDataProviderNode = trvDataSourceNode.Nodes.FindNodeByText(strDataProvider); trvDataProviderNode.Expanded = true; RadTreeNode selNode = trvDataProviderNode.Nodes.FindNodeByValue(strTableName); selNode.Selected = true; QuerySearchTree_SelectedNodeChanged(selNode, null); //end of loading columns of the selected table node string strType = entityNode.Attributes[ATTRITYPE].Value; string strIsShared = saveSearchRequestNode.Attributes[ATTRIBSHARED].Value; chbShared.Checked = Convert.ToBoolean(strIsShared); if(cboSavedSearch.Text != strSrchName) { cboSavedSearch.SelectedIndex = -1; cboSavedSearch.Items.FindByText(strSrchName).Selected = true; } //set the button text based on the query string values if(!IsPostBack) { if(Request.QueryString["operation"] != null) { if(string.Equals(Request.QueryString["operation"].ToString(), MODIFY)) { if(string.Equals(strType, GEN)) { btnSaveSearch.Text = MODIFYSRCH; } else { btnSaveSearch.Text = MODIFYSQL; } //added in dream 3.0 txtSaveSearchName.Text = strSrchName; // txtSaveSearchName.Enabled = false; } } else { if(string.Equals(strType, GEN)) { btnSaveSearch.Text = SAVESRCH; } else { btnSaveSearch.Text = SAVESQL; } txtSaveSearchName.Enabled = true; } } //end of setting the button text //load the values in the grid and sql based on the type of search if(string.Equals(strType, GEN)) { CheckBox chbHeader = chbHeaderColumn; txtSQLQuery.Text = string.Empty; txtSQLQuery.ReadOnly = true; tblColumnNames.Enabled = true; ///Load Criteria for(int intIndex = 0; intIndex < tblColumnNames.Rows.Count; intIndex++) { strColName = tblColumnNames.Rows[intIndex].Cells[1].Text; XmlNode attributeGrp = saveSearchRequestNode.SelectSingleNode(ATTRIBUTEGROUPPATH); XmlNode attribute = null; if(attributeGrp != null) { attribute = attributeGrp.SelectSingleNode("attribute[@name='" + strColName + "']"); } else { attribute = saveSearchRequestNode.SelectSingleNode("requestinfo/entity/attribute[@name='" + strColName + "']"); } ///for criteria selection if(attribute != null) { TextBox txtCriteria = (TextBox)tblColumnNames.Rows[intIndex].Cells[3].FindControl("txtCriteria"); txtCriteria.Text = attribute.FirstChild.InnerText; DropDownList cboOperator = (DropDownList)tblColumnNames.Rows[intIndex].Cells[2].FindControl("cboOperator"); cboOperator.SelectedIndex = -1; cboOperator.Items.FindByText(attribute.Attributes["operator"].Value).Selected = true; } } ///check the display columns XmlNodeList ValueList = saveSearchRequestNode.SelectNodes(VALUEPATH); if(ValueList.Count > 0) { for(int intIndex = 0; intIndex < tblColumnNames.Rows.Count; intIndex++) { strColName = tblColumnNames.Rows[intIndex].Cells[1].Text; CheckBox chbAttribute = (CheckBox)tblColumnNames.Rows[intIndex].Cells[0].FindControl("chbColumns"); chbAttribute.Checked = false; foreach(XmlNode valNode in ValueList) { if(chbHeader.Checked) chbHeader.Checked = false; if(string.Equals(valNode.InnerText, strColName)) { chbAttribute.Checked = true; break; } } } } } else { txtSQLQuery.Text = string.Empty; txtSQLQuery.ReadOnly = false; tblColumnNames.Enabled = false; XmlNode query = saveSearchRequestNode.SelectSingleNode(QUERYPATH); txtSQLQuery.Text = query.InnerText; } } EnableCriteria(); } catch { throw; } }