protected override void Render(HtmlTextWriter writer) { base.Render(writer); SPWeb web = SPContext.Current.Web; string editURL = SPContext.Current.List.Forms[PAGETYPE.PAGE_EDITFORM].Url; editURL = ((web.ServerRelativeUrl == "/") ? "" : web.ServerRelativeUrl) + "/" + editURL; string extraParams = ""; GridGanttSettings gSettings = API.ListCommands.GetGridGanttSettings(SPContext.Current.List); writer.WriteLine("<script>"); writer.WriteLine("WEWebId = '" + SPContext.Current.Web.ID + "';"); writer.WriteLine("WEListId = '" + SPContext.Current.List.ID + "';"); writer.WriteLine("WEItemId = '" + SPContext.Current.ListItem.ID + "';"); //writer.WriteLine("WETitle = \"" + title.Replace("\"", """) + "\";"); writer.WriteLine("WETitle = \"" + HttpUtility.JavaScriptStringEncode(SPContext.Current.ListItem.Title) + "\";"); writer.WriteLine("WEWebUrl = '" + ((web.ServerRelativeUrl == "/") ? "" : web.ServerRelativeUrl) + "';"); writer.WriteLine("WEWebId = '" + web.ID + "';"); writer.WriteLine("WEEditForm = '" + editURL + "';"); writer.WriteLine("WEExtraParams = '" + extraParams.Trim('&') + "';"); writer.WriteLine("WESource = '" + HttpUtility.UrlEncode(HttpContext.Current.Request.Url.ToString()).Replace("+", "%20") + "';"); writer.WriteLine("WEUseTeam = " + gSettings.BuildTeam.ToString().ToLower() + ";"); writer.WriteLine("WEDLG = '" + Page.Request["IsDlg"] + "';"); writer.WriteLine("</script>"); }
private void RegisterAssignToEvent(SPWeb web) { string strProps; for (int i = 0; i < web.Lists.Count; i++) { string sAssembly = "EPM Live Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"; string sClass = "EPMLiveCore.NotificationEvent"; List <SPEventReceiverDefinition> evts = GetListEvents(web.Lists[i], sAssembly, sClass, new List <SPEventReceiverType> { SPEventReceiverType.ItemDeleting }); foreach (SPEventReceiverDefinition e in evts) { e.Delete(); } web.Lists[i].EventReceivers.Add(SPEventReceiverType.ItemDeleting, sAssembly, sClass); SPList list = web.Lists[i]; GridGanttSettings gSettings = new GridGanttSettings(list); if (gSettings.SendEmails) { API.APIEmail.InstallAssignedToEvent(list); } } }
private void InitFields() { try { list = SPContext.Current.List; } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } var gridSettings = new GridGanttSettings(list); DisplayFormRedirect = gridSettings.DisplayFormRedirect; if (DisplayFormRedirect && ControlMode == SPControlMode.New && Page.Request[IsDialogParameter] != ModifiedType) { SPContext.Current.FormContext.OnSaveHandler += CustomHandler; } else if (!string.IsNullOrWhiteSpace(Page.Request[SourceParam])) { RedirectUrl = Page.Request[SourceParam]; SPContext.Current.FormContext.OnSaveHandler += HandleNewItemRecent; } else { SPContext.Current.FormContext.OnSaveHandler += HandleNewItemRecent; } if (gridSettings.DisplaySettings != string.Empty) { fieldProperties = ListDisplayUtils.ConvertFromString(gridSettings.DisplaySettings); } try { isWorkList = gridSettings.EnableWorkList; } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } if (isWorkList) { SPPageContentManager.RegisterClientScriptInclude( this, GetType(), "WorkEngineStatusing", "/_layouts/15/epmlive/WorkEngineStatusing.js"); } if (list == null) { list = SPContext.Current.Web.Lists[new Guid(Page.Request[Listid])]; } }
protected override void OnLoad(EventArgs eventArgs) { if (eventArgs == null) { throw new ArgumentNullException(nameof(eventArgs)); } Title = "Editable Fields"; var gSettings = new GridGanttSettings(CurrentList); if (!string.IsNullOrWhiteSpace(gSettings.DisplaySettings)) { _fieldProperties = ListDisplayUtils.ConvertFromString(gSettings.DisplaySettings); } foreach (SPField field in CurrentList.Fields) { if (field.Reorderable && !field.Sealed) { _displayableFields.Add(field.Title, field); } else { if (MatchROFields(field.Id)) { _displayableFields.Add(field.Title, field); } } } foreach (SPGroup group in CurrentList.ParentWeb.Groups) { _groups.Add(group); } Cancel.PostBackUrl = $"~/_layouts/listedit.aspx?List={CurrentList.ID.ToString()}"; if (IsPostBack) { return; } _pageRender = PrepareRenderPage(); RegisterScript(); }
//private void SetUrlFieldMessage(SPItemEventProperties properties) //{ // EventFiringEnabled = false; // SPSecurity.RunWithElevatedPrivileges(() => // { // using (SPSite s = new SPSite(properties.SiteId)) // { // using (SPWeb w = s.OpenWeb(properties.Web.ID)) // { // SPList l = w.Lists[properties.ListId]; // SPListItem i = l.GetItemById(properties.ListItemId); // if (!FieldExistsInList(l, "WorkspaceUrl")) // { // string fldWorkspaceUrlIntName = l.Fields.Add("WorkspaceUrl", SPFieldType.URL, false); // SPFieldUrl fldWorkspaceUrl = l.Fields.GetFieldByInternalName(fldWorkspaceUrlIntName) as SPFieldUrl; // fldWorkspaceUrl.Update(); // } // i["WorkspaceUrl"] = new SPFieldUrlValue() { Description = "Waiting for security to complete." }; // i.SystemUpdate(); // } // } // }); // EventFiringEnabled = true; //} private bool Initialize(SPItemEventProperties properties) { try { _siteId = properties.SiteId.ToString(); _webId = properties.Web.ID.ToString(); _listId = properties.ListId.ToString(); _itemTitle = properties.ListItem.Title; _itemId = properties.ListItem.ID.ToString(); _settings = new GridGanttSettings(properties.List); SPSecurity.RunWithElevatedPrivileges(() => { using (var s = new SPSite(properties.SiteId)) { using (var lockedWeb = s.OpenWeb(CoreFunctions.getLockedWeb(properties.Web))) { _createFromLiveTemp = CoreFunctions.getConfigSetting(lockedWeb, "EPMLiveUseLiveTemplates"); } } }); _creationParams = "<Data>" + "<Param key=\"IsStandAlone\">false</Param>" + "<Param key=\"TemplateSource\">downloaded</Param>" + "<Param key=\"TemplateItemId\">" + _settings.AutoCreationTemplateId + "</Param>" + "<Param key=\"IncludeContent\">True</Param>" + "<Param key=\"SiteTitle\">" + _itemTitle + "</Param>" + "<Param key=\"AttachedItemId\">" + _itemId + "</Param>" + "<Param key=\"AttachedItemListGuid\">" + _listId + "</Param>" + "<Param key=\"WebUrl\">" + properties.Web.Url + "</Param>" + "<Param key=\"WebId\">" + properties.Web.ID.ToString() + "</Param>" + "<Param key=\"SiteId\">" + _siteId.ToString() + "</Param>" + "<Param key=\"CreatorId\">" + properties.Web.CurrentUser.ID.ToString() + "</Param>" + "<Param key=\"CreateFromLiveTemp\">" + _createFromLiveTemp + "</Param>" + "<Param key=\"UniquePermission\">" + _settings.BuildTeamSecurity.ToString() + "</Param>" + "</Data>"; return(true); } catch (Exception) { return(false); } }
protected void Page_Load(object sender, EventArgs e) { dt.Columns.Add("Web"); dt.Columns.Add("List Name"); SPWeb web = SPContext.Current.Web; { web.Site.CatchAccessDeniedException = false; mainList = web.Lists[new Guid(Request["List"])]; GridGanttSettings gSettings = new GridGanttSettings(mainList); lists = gSettings.RollupLists; if (lists != "") { foreach (SPField field in mainList.Fields) { if (!field.Hidden && field.Type != SPFieldType.Computed) { dt.Columns.Add(field.InternalName); } } processList(web, mainList.Title, ""); processWeb(web, ""); foreach (SPField field in mainList.Fields) { if (dt.Columns.Contains(field.InternalName)) { dt.Columns[field.InternalName].ColumnName = "<div nowrap>" + field.Title + "</div>"; } } } } DataView dvData = new DataView(dt); dvData.Sort = "List Name"; GvItems.DataSource = dvData; GvItems.DataBind(); }
private bool Initialize(SPItemEventProperties properties) { try { _listName = properties.ListTitle; _siteId = properties.SiteId; _webUrl = properties.WebUrl; _listId = properties.ListId; _listItem = properties.ListItem; _itemTitle = _listItem != null ? (!string.IsNullOrEmpty(_listItem.Title) ? _listItem.Title : string.Empty) : string.Empty; _itemId = _listItem != null ? _listItem.ID : -1; _properties = properties; _settings = new GridGanttSettings(properties.List); return(true); } catch (Exception) { return(false); } }
private static void iGetGridRowEdit(ref XmlDocument doc, SPWeb oWeb, XmlDocument DocIn) { Guid ListId = new Guid(DocIn.FirstChild.Attributes["listid"].Value); int itemid = int.Parse(DocIn.FirstChild.Attributes["itemid"].Value); string[] sCols = DocIn.FirstChild.Attributes["Cols"].Value.Split(','); SPList list = oWeb.Lists[ListId]; SPListItem li = list.GetItemById(itemid); XmlNode nd = doc.SelectSingleNode("//I"); EPMLiveCore.GridGanttSettings gSettings = new EPMLiveCore.GridGanttSettings(list); Dictionary <string, Dictionary <string, string> > fieldProperties = EPMLiveCore.ListDisplayUtils.ConvertFromString(gSettings.DisplaySettings); foreach (string sCol in sCols) { if (ValidEditCol(sCol)) { SPField oField = null; try { if (sCol == "FState") { oField = list.Fields.GetFieldByInternalName("State"); } else { oField = list.Fields.GetFieldByInternalName(sCol); } } catch { } if (oField != null) { if (EPMLiveCore.EditableFieldDisplay.isEditable(li, oField, fieldProperties)) { XmlAttribute attr = doc.CreateAttribute(sCol + "CanEdit"); attr.Value = "1"; nd.Attributes.Append(attr); string senum = ""; string senumkeys = ""; string sFormat = ""; string sRange = ""; attr = doc.CreateAttribute(sCol + "Type"); attr.Value = GetFieldType(oField, out senum, out senumkeys, out sFormat, out sRange, oWeb); nd.Attributes.Append(attr); if (senum != "") { attr = doc.CreateAttribute(sCol + "Enum"); attr.Value = senum; nd.Attributes.Append(attr); } if (senumkeys != "") { attr = doc.CreateAttribute(sCol + "EnumKeys"); attr.Value = senumkeys; nd.Attributes.Append(attr); } if (sFormat != "") { attr = doc.CreateAttribute(sCol + "Format"); attr.Value = sFormat; nd.Attributes.Append(attr); } if (sRange != "") { attr = doc.CreateAttribute(sCol + "Range"); attr.Value = sRange; nd.Attributes.Append(attr); } attr = doc.CreateAttribute(sCol); attr.Value = GetCellValue(li, oField, true, oWeb); nd.Attributes.Append(attr); } } } } }
private void AddTypeAheadFieldControls(SPField fld) { if (mode == SPControlMode.New || mode == SPControlMode.Edit) { // this represents a comma separated list of lookup field internal names to modify EnhancedLookupConfigValuesHelper valueHelper = null; string unprocessedModCandidates = string.Empty; GridGanttSettings gSettings = new GridGanttSettings(this.list); try { string rawValue = gSettings.Lookups; //string rawValue = "Region^dropdown^none^none^xxx|State^autocomplete^Region^Region^xxx|City^autocomplete^State^State^xxx"; valueHelper = new EnhancedLookupConfigValuesHelper(rawValue); } catch { } if (valueHelper == null) { return; } bool isEnhanced = valueHelper.ContainsKey(fld.InternalName); bool isParent = valueHelper.IsParentField(fld.InternalName); if (!isEnhanced && !isParent) { return; } LookupConfigData lookupData = valueHelper.GetFieldData(fld.InternalName); if (isParent && !isEnhanced) { SPFieldLookup lookupFld = fld as SPFieldLookup; if (!lookupFld.AllowMultipleValues) { CascadingLookupRenderControl ctrl = new CascadingLookupRenderControl(); if (lookupData == null) { lookupData = new LookupConfigData(); lookupData.IsParent = true; } ctrl.LookupData = lookupData; ctrl.LookupField = lookupFld; string customValue = "<Data>" + "<Param key=\"SPFieldType\">SPFieldUser</Param>" + "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" + "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" + "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" + "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" + "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" + "<Param key=\"Required\">" + lookupFld.Required + "</Param>" + GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) + "</Data>"; ctrl.CustomProperty = customValue; FormField ff = this.GetFormFieldByField(fld); if (ff != null) { ff.Parent.Controls.AddAfter(ff, ctrl); } } } else if (isParent && isEnhanced) { if (lookupData.Type == GenericType) { #region INSERT EPMLIVE GENERIC PICKER CONTROL picker = new GenericEntityEditor(); SPFieldLookup lookupFld = fld as SPFieldLookup; picker.MultiSelect = lookupFld.AllowMultipleValues; string customValue = "<Data>" + "<Param key=\"SPFieldType\"></Param>" + "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" + "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" + "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" + "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" + "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" + GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) + "<Param key=\"Field\">" + lookupData.Field + "</Param>" + "<Param key=\"ControlType\">" + lookupData.Type + "</Param>" + "<Param key=\"Parent\">" + lookupData.Parent + "</Param>" + "<Param key=\"ParentListField\">" + lookupData.ParentListField + "</Param>" + "<Param key=\"Required\">" + lookupFld.Required.ToString() + "</Param>" + "</Data>"; SPFieldLookupValueCollection lookupValCol = null; if (mode == SPControlMode.New || (this.list.BaseTemplate == SPListTemplateType.DocumentLibrary && !string.IsNullOrEmpty(Page.Request[ModeParam]) && Page.Request[ModeParam] == Upload && mode == SPControlMode.Edit)) { lookupValCol = GetQueryStringLookupVal(fld); } else { try { lookupValCol = new SPFieldLookupValueCollection(this.ListItem[lookupFld.Id].ToString()); } catch { } } if (lookupValCol != null && lookupValCol.Count > 0) { ArrayList alItems = new ArrayList(); PickerEntity entity; foreach (SPFieldLookupValue v in lookupValCol) { entity = new PickerEntity(); entity.Key = v.LookupId.ToString(); entity.DisplayText = v.LookupValue; entity.IsResolved = true; alItems.Add(entity); } picker.UpdateEntities(alItems); } picker.CustomProperty = customValue; FormField ff = this.GetFormFieldByField(fld); if (ff != null) { ff.Parent.Controls.AddAfter(ff, picker); } #endregion } else if (lookupData.Type == ModifiedType) { #region INSERT MODIFIED SP CONTROL SPFieldLookup lookupFld = fld as SPFieldLookup; if (!lookupFld.AllowMultipleValues) { CascadingLookupRenderControl cclrCtrl = new CascadingLookupRenderControl(); cclrCtrl.LookupData = lookupData; cclrCtrl.LookupField = lookupFld; string customValue = "<Data>" + "<Param key=\"SPFieldType\">SPFieldUser</Param>" + "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" + "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" + "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" + "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" + "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" + "<Param key=\"Required\">" + lookupFld.Required + "</Param>" + GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) + "</Data>"; cclrCtrl.CustomProperty = customValue; FormField ff = this.GetFormFieldByField(fld); if (ff != null) { ff.Parent.Controls.AddAfter(ff, cclrCtrl); } } #endregion } } else if (!isParent && isEnhanced) { if (lookupData.Type == GenericType) { #region INSERT EPMLIVE GENERIC PICKER CONTROL picker = new GenericEntityEditor(); SPFieldLookup lookupFld = fld as SPFieldLookup; picker.MultiSelect = lookupFld.AllowMultipleValues; string customValue = "<Data>" + "<Param key=\"SPFieldType\">SPFieldUser</Param>" + "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" + "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" + "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" + "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" + "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" + GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) + "<Param key=\"Field\">" + lookupData.Field + "</Param>" + "<Param key=\"ControlType\">" + lookupData.Type + "</Param>" + "<Param key=\"Parent\">" + lookupData.Parent + "</Param>" + "<Param key=\"ParentListField\">" + lookupData.ParentListField + "</Param>" + "<Param key=\"Required\">" + lookupFld.Required.ToString() + "</Param>" + "</Data>"; SPFieldLookupValueCollection lookupValCol = null; if (mode == SPControlMode.New || (this.list.BaseTemplate == SPListTemplateType.DocumentLibrary && !string.IsNullOrEmpty(Page.Request[ModeParam]) && Page.Request[ModeParam] == Upload && mode == SPControlMode.Edit)) { lookupValCol = GetQueryStringLookupVal(fld); } else { try { lookupValCol = new SPFieldLookupValueCollection(this.ListItem[lookupFld.Id].ToString()); } catch { } } if (lookupValCol != null && lookupValCol.Count > 0) { ArrayList alItems = new ArrayList(); PickerEntity entity; foreach (SPFieldLookupValue v in lookupValCol) { entity = new PickerEntity(); entity.Key = v.LookupId.ToString(); entity.DisplayText = v.LookupValue; entity.IsResolved = true; alItems.Add(entity); } picker.UpdateEntities(alItems); } picker.CustomProperty = customValue; FormField ff = this.GetFormFieldByField(fld); if (ff != null) { ff.Parent.Controls.AddAfter(ff, picker); } #endregion } else if (lookupData.Type == ModifiedType) { #region INSERT MODIFIED SP CONTROL SPFieldLookup lookupFld = fld as SPFieldLookup; if (!lookupFld.AllowMultipleValues) { CascadingLookupRenderControl cclrCtrl = new CascadingLookupRenderControl(); cclrCtrl.LookupData = lookupData; cclrCtrl.LookupField = lookupFld; string customValue = "<Data>" + "<Param key=\"SPFieldType\">SPFieldUser</Param>" + "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" + "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" + "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" + "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" + "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" + "<Param key=\"Required\">" + lookupFld.Required + "</Param>" + GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) + "</Data>"; cclrCtrl.CustomProperty = customValue; FormField ff = this.GetFormFieldByField(fld); if (ff != null) { ff.Parent.Controls.AddAfter(ff, cclrCtrl); } } else { CascadingMultiLookupRenderControl cclrCtrl = new CascadingMultiLookupRenderControl(); cclrCtrl.LookupData = lookupData; cclrCtrl.LookupField = lookupFld; string customValue = "<Data>" + "<Param key=\"SPFieldType\">SPFieldUser</Param>" + "<Param key=\"ParentWebID\">" + lookupFld.ParentList.ParentWeb.ID.ToString() + "</Param>" + "<Param key=\"LookupWebID\">" + lookupFld.LookupWebId.ToString() + "</Param>" + "<Param key=\"LookupListID\">" + lookupFld.LookupList + "</Param>" + "<Param key=\"LookupFieldInternalName\">" + lookupFld.LookupField + "</Param>" + "<Param key=\"LookupFieldID\">" + lookupFld.Id + "</Param>" + "<Param key=\"IsMultiSelect\">" + lookupFld.AllowMultipleValues.ToString() + "</Param>" + "<Param key=\"ListID\">" + this.ListId.ToString() + "</Param>" + "<Param key=\"ItemID\">" + this.ItemId.ToString() + "</Param>" + "<Param key=\"Required\">" + lookupFld.Required + "</Param>" + GenerateControlDataForLookupField(fld, lookupFld.AllowMultipleValues) + "</Data>"; cclrCtrl.CustomProperty = customValue; FormField ff = this.GetFormFieldByField(fld); if (ff != null) { ff.Parent.Controls.AddAfter(ff, cclrCtrl); } } #endregion } } } }
private void ManageFields() { _cSite = SPContext.Current.Site; _cWeb = SPContext.Current.Web; _solutionType = (!string.IsNullOrEmpty(Request.Params["type"])) ? Request.Params["type"] : string.Empty; _lstGuid = (!string.IsNullOrEmpty(Request.Params["list"])) ? Request.Params["list"] : string.Empty; _copyFrom = (!string.IsNullOrEmpty(Request.Params["copyfrom"])) ? Request.Params["copyfrom"] : string.Empty; if (!string.IsNullOrEmpty(_copyFrom)) { SPList rqList = _cWeb.Lists[new Guid(_lstGuid)]; if (rqList != null) { SPListItem item = null; try { item = rqList.GetItemById(int.Parse(_copyFrom)); } catch { } if (item != null) { _requestProjectName = item["Title"].ToString(); txtURL.Text = _requestProjectName; } } } Guid lockedWeb = CoreFunctions.getLockedWeb(Web); _parentWebGuid_B = Web.ID.ToString("B"); _parentWebUrl = Web.ServerRelativeUrl; _siteUrl = Site.Url; _siteHostName = Site.HostName; _currentWebRelativeUrl = Web.ServerRelativeUrl; _sourceWebId = Web.ID.ToString(); _curWebUrl = Web.Url; _solutionStoreServiceProxyUrl = Web.Url + SOLUTION_STORE_PROXY_URL; _baseURL = Web.ServerRelativeUrl == "/" ? Web.ServerRelativeUrl : Web.ServerRelativeUrl + "/"; _includeContentClientId = InputformsectionIncludeContent.ClientID; _moreInfoUrlClientId = txtURL.ClientID; _hasCreateSubSitePerm = Web.DoesUserHavePermissions(Web.CurrentUser.LoginName, SPBasePermissions.ManageSubwebs); _moreInfoUrl = Web.Url + MORE_INFO_URL; _smallParentUrl = Web.Url + SMALL_PARENT_URL; _tempGalRedirect = (Web.ServerRelativeUrl == "/" ? "" : Web.ServerRelativeUrl) + TEMP_GAL_REDIRECT; // get available features from corefunctions, which is currently hardcoded for testing purposes //ArrayList features = CoreFunctions.getActivatedFeatures(); Act act = new Act(Web); ArrayList features = act.GetActivatedLevels(); foreach (object array in features) { _featuresList += array.ToString() + ";#"; } string _untranslatedGalleryToken = string.Empty; SPSecurity.RunWithElevatedPrivileges(delegate() { // go to locked web to find settings that specifies the template resource site using (SPWeb web = Site.OpenWeb(lockedWeb)) { try { _untranslatedGalleryToken = CoreFunctions.getConfigSetting(web, "EPMLiveTemplateGalleryURL", false, true); switch (_untranslatedGalleryToken) { case "{Site}": _templateResourceUrl = _cWeb.ServerRelativeUrl; break; case "{site}": _templateResourceUrl = _cWeb.ServerRelativeUrl; break; case "{Root}": _templateResourceUrl = CoreFunctions.getConfigSetting(web, "EPMLiveTemplateGalleryURL", true, true); break; case "{root}": _templateResourceUrl = CoreFunctions.getConfigSetting(web, "EPMLiveTemplateGalleryURL", true, true); break; } } catch { _templateResourceUrl = _cWeb.ServerRelativeUrl; } if (string.IsNullOrEmpty(_templateResourceUrl) || _templateResourceUrl == " ") { _templateResourceUrl = _cWeb.ServerRelativeUrl; } if (!string.IsNullOrEmpty(_templateResourceUrl)) { using (SPWeb templateResourceWeb = Site.AllWebs[_templateResourceUrl]) { _workengineSvcUrl = templateResourceWeb.Url + WORKENGINE_WS_URL; } } else { _workengineSvcUrl = Web.Url + WORKENGINE_WS_URL; } // get comp levels to filter templates by comp levels try { _compLevels = web.AllProperties["CompLevel"].ToString(); } catch { } try { _compLevels = web.AllProperties["complevel"].ToString(); } catch { } //_workengineSvcUrl = "http://" + web.Site.HostName + (web.ServerRelativeUrl == "/" ? "" : web.ServerRelativeUrl) + WORKENGINE_WS_URL; _projectWorkspaceSetting = CoreFunctions.getConfigSetting(web, "EPMLiveNewProjectWorkspaceType"); GridGanttSettings gSettings = new GridGanttSettings(_cWeb.Lists[new Guid(_lstGuid)]); _newItemName = !string.IsNullOrEmpty(_lstGuid) ? gSettings.NewMenuName : "workspace"; _newItemName = !string.IsNullOrEmpty(_newItemName) ? _newItemName : "workspace"; _newItemNameLwrCs = _newItemName.ToLower(); _listName = _cWeb.Lists[new Guid(_lstGuid)].Title.ToLower(); _templateType = _newItemNameLwrCs; if (_templateType.Equals("department site", StringComparison.CurrentCultureIgnoreCase)) { _templateType = "department"; } SPList curList = _cWeb.Lists[new Guid(_lstGuid)]; if (!string.IsNullOrEmpty(gSettings.RollupLists)) { string[] tRollupLists = gSettings.RollupLists.Split(','); _rListName = tRollupLists[0].Split('|')[0]; } _reqListName = gSettings.RequestList; _doNotDelRequest = gSettings.DeleteRequest.ToString(); string epmLiveCreateNewSettings = CoreFunctions.getConfigSetting(web, "EPMLiveCreateNewSettings"); if (!string.IsNullOrEmpty(epmLiveCreateNewSettings)) { EPMLiveCore.API.PropertyHash props = new EPMLiveCore.API.PropertyHash(CoreFunctions.getConfigSetting(web, "EPMLiveCreateNewSettings"), ";#", '|', '^'); if (props != null && props[0].Keys.Count > 0) { _defaultCreateNewOpt = props[0]["Default"].ToString(); _isCreateFromOnlineAvail = bool.Parse(props[1]["Online"].ToString()); _isCreateFromLocalAvail = bool.Parse(props[1]["Local"].ToString()); _isCreateFromExistingAvail = bool.Parse(props[1]["Existing"].ToString()); } else { _defaultCreateNewOpt = "online"; } } else { _defaultCreateNewOpt = "existing"; } _createFromLiveTemp = CoreFunctions.getConfigSetting(web, "EPMLiveUseLiveTemplates"); } }); }
public static Dictionary <int, string[]> GetCreatableLists(SPWeb cWeb, string requestUrl = null) { var dict = new Dictionary <int, string[]>(); requestUrl = requestUrl ?? string.Empty; var count = cWeb.Lists.Count; for (int i = 0; i < count; i++) { var list = cWeb.Lists[i]; if ((list is SPDocumentLibrary)) { continue; } string itemText = string.Empty; string description = string.Empty; string imageUrl = string.Empty; string linkUrl = string.Empty; string onclick = string.Empty; string listId = string.Empty; bool hideNewBtn = true; GridGanttSettings gSettings = new GridGanttSettings(list); // if list is not hidden or // the hide new button option is not true if (!list.Hidden) { if (!list.DoesUserHavePermissions(SPBasePermissions.AddListItems)) { continue; } string sHideNewBtn = string.Empty; hideNewBtn = gSettings.HideNewButton; if (!hideNewBtn) { itemText = list.Title; string newItemText = gSettings.NewMenuName; if (!string.IsNullOrEmpty(newItemText)) { itemText = newItemText; } description = list.Description; imageUrl = list.ImageUrl; listId = list.ID.ToString(); //string rlists = string.Empty; //rlists = gSettings.RollupLists; //bool disableNewButtonMod = false; //string sDisableNewButtonMod = string.Empty; //disableNewButtonMod = gSettings.DisableNewItemMod; //bool useEnhancedNewMenu = false; //string sUseEnhancedNewMenu = string.Empty; //useEnhancedNewMenu = gSettings.UseNewMenu; // if "Use Enhanced New Menu" option is turned on // use the new create modal dialog //if (useEnhancedNewMenu && !disableNewButtonMod) //{ // linkUrl = "#"; // string createNewWorkspaceUrl = (cWeb.ServerRelativeUrl == "/" ? "" : cWeb.ServerRelativeUrl) + "/_layouts/epmlive/createnewworkspace.aspx?list=" + list.ID.ToString("B") + "&type=site&source=" + requestUrl; // onclick = "javascript:HideLayers();var options = { url:'" + createNewWorkspaceUrl + "', width: 800, height:600, title: 'Create', dialogReturnValueCallback : Function.createDelegate(null, HandleCreateNewWorkspaceCreate) }; SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); return false;"; //} // check for roll up lists // not a pop up //else if (!string.IsNullOrEmpty(rlists) && !disableNewButtonMod) //{ // onclick = ""; // string firstListLName = rlists.Split(',')[0]; // linkUrl = (cWeb.ServerRelativeUrl == "/" ? "" : cWeb.ServerRelativeUrl) + "/_layouts/epmlive/newitem.aspx?List=" + firstListLName + "&source=" + requestUrl; //} // if content management is allowed if (list.AllowContentTypes) { //if (list.NavigateForFormsPages) //{ onclick = "javascript:window.location.href='" + GetDefaultFormUrl(list, requestUrl) + "'; return false;"; //} //else //{ // onclick = "javascript:var options = { url:'" + GetDefaultFormUrl(list, requestUrl) + "', title: 'Create', dialogReturnValueCallback: function (dialogResult) { SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.RefreshPage', dialogResult) } }; SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); return false;"; //} } else { //if (list.NavigateForFormsPages) //{ onclick = "javascript:window.location.href='" + GetDefaultFormUrl(list, requestUrl) + "'; return false;"; //} //else //{ // onclick = "javascript:var options = { url:'" + GetDefaultFormUrl(list, requestUrl) + "', title: 'Create', dialogReturnValueCallback: function (dialogResult) { SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.RefreshPage', dialogResult) } }; SP.SOD.execute('SP.UI.Dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); return false;"; //} } dict.Add(i, new[] { description, itemText, imageUrl, linkUrl, onclick, listId }); } } } return(dict); }
private void AddEntityPickersToLookups() { if (mode == SPControlMode.New || mode == SPControlMode.Edit) { // this represents a comma separated list of lookup field internal names to modify EnhancedLookupConfigValuesHelper valueHelper = null; var gSettings = new GridGanttSettings(list); try { var rawValue = gSettings.Lookups; valueHelper = new EnhancedLookupConfigValuesHelper(rawValue); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } if (valueHelper == null) { return; } var formFields = this.GetFormFieldByType(typeof(SPFieldLookup)); foreach (var formField in formFields) { var isEnhanced = valueHelper.ContainsKey(formField.Field.InternalName); var isParent = valueHelper.IsParentField(formField.Field.InternalName); if (!isEnhanced && !isParent) { continue; } var lookupData = valueHelper.GetFieldData(formField.Field.InternalName); if (isParent && !isEnhanced) { InsertModifiedSPControl1(formField, lookupData); } else if (isParent && isEnhanced) { if (lookupData.Type == GenericType) { InsertEPMLiveGenericPickerControl(formField, lookupData, string.Empty); } else if (lookupData.Type == ModifiedType) { InsertModifiedSPControl1(formField, lookupData); } } else if (!isParent && isEnhanced) { if (lookupData.Type == GenericType) { InsertEPMLiveGenericPickerControl(formField, lookupData, "SPFieldUser"); } else if (lookupData.Type == ModifiedType) { InsertModifiedSPControl2(formField, lookupData); } } } } }
private string createProject(SPWeb newWeb, SPList curList) { if (newWeb != null) { try { var oldLi = curList.GetItemById(int.Parse(Request["ID"])); var gSettings = new GridGanttSettings(curList); var listName = string.Empty; try { var tRollupLists = gSettings.RollupLists.Split(','); listName = tRollupLists[0].Split('|')[0]; } catch (Exception ex) { WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.LayoutPage, TraceSeverity.VerboseEx, ex.ToString()); } var newList = newWeb.Lists[listName]; SPField confField = null; try { confField = newList.Fields.GetFieldByInternalName("EPMLiveListConfig"); } catch (Exception ex) { WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.LayoutPage, TraceSeverity.VerboseEx, ex.ToString()); } if (confField == null) { if (newList.DoesUserHavePermissions(SPBasePermissions.ManageLists)) { try { newList.ParentWeb.AllowUnsafeUpdates = true; confField = new SPField(newList.Fields, "EPMLiveConfigField", "EPMLiveListConfig"); confField.Hidden = true; newList.Fields.Add(confField); confField.Update(); newList.Update(); } catch (Exception ex) { WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.LayoutPage, TraceSeverity.VerboseEx, ex.ToString()); } } } var newLi = newList.Items.Add(); newLi["Title"] = oldLi.Title; foreach (SPField field in curList.Fields) { if (field.Reorderable) { if (newList.Fields.ContainsField(field.InternalName)) { try { if (newList.Fields.GetFieldByInternalName(field.InternalName).Type == field.Type) { try { newLi[field.InternalName] = oldLi[field.InternalName]; } catch (Exception ex) { WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.LayoutPage, TraceSeverity.VerboseEx, ex.ToString()); } } } catch (Exception ex) { WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.LayoutPage, TraceSeverity.VerboseEx, ex.ToString()); } } } } newLi.Update(); try { var sourceItemAttachmentsFolder = SPContext.Current.Web .Folders["Lists"] .SubFolders[oldLi.ParentList.Title] .SubFolders["Attachments"] .SubFolders[oldLi.ID.ToString()]; foreach (SPFile file in sourceItemAttachmentsFolder.Files) { var binFile = file.OpenBinary(); newLi.Attachments.Add(file.Name, binFile); } newLi.Update(); } catch (Exception ex) { WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.LayoutPage, TraceSeverity.VerboseEx, ex.ToString()); } oldLi.Delete(); return(newList.Forms[PAGETYPE.PAGE_EDITFORM].ServerRelativeUrl + "?ID=" + newLi.ID); } catch (Exception ex) { label1.Text = "Error: " + ex.Message + ex.StackTrace; Panel2.Visible = true; } } return(string.Empty); }
private bool ProcessDataList(SPWeb web, XmlNode newNode) { var canPublish = false; SPList list = null; try { list = web.Lists[HttpUtility.UrlDecode(Request["List"])]; } catch (Exception ex) { DebugTrace.TraceError("Exception swallowed: {0}", ex); } if (list != null) { if (!list.Hidden) { var gSettings = new GridGanttSettings(list); if (gSettings.HideNewButton) { list = null; } } else { list = null; } } var newCell = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI); if (list != null) { newCell.InnerText = list.Forms[PAGETYPE.PAGE_NEWFORM].ServerRelativeUrl; var attrName = doc.CreateAttribute("name"); attrName.Value = "NewItemURL"; newCell.Attributes.Append(attrName); newNode.AppendChild(newCell); newCell = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI); newCell.InnerText = "No"; attrName = doc.CreateAttribute("name"); attrName.Value = "CanPublish"; newCell.Attributes.Append(attrName); if (list.DoesUserHavePermissions(SPBasePermissions.AddListItems)) { newCell.InnerText = "Yes"; canPublish = true; } } newNode.AppendChild(newCell); newCell = doc.CreateNode(XmlNodeType.Element, "cell", doc.NamespaceURI); newCell.InnerText = web.Title; newNode.AppendChild(newCell); newCell = doc.CreateNode(XmlNodeType.Element, "cell", doc.NamespaceURI); newCell.InnerText = web.ServerRelativeUrl; newNode.AppendChild(newCell); newCell = doc.CreateNode(XmlNodeType.Element, "userdata", doc.NamespaceURI); newCell.InnerText = web.ID.ToString(); var attributeName = doc.CreateAttribute("name"); attributeName.Value = "webid"; newCell.Attributes.Append(attributeName); newNode.AppendChild(newCell); return(canPublish); }
private void AddTimerJob(SPItemEventProperties properties) { SPSecurity.RunWithElevatedPrivileges(delegate() { base.EventFiringEnabled = false; GridGanttSettings settings = new GridGanttSettings(properties.List); bool isSecure = false; try { isSecure = settings.BuildTeamSecurity; } catch { } int priority = 1; if (isSecure) { priority = 0; } using (var sqlConnection = new SqlConnection(CoreFunctions.getConnectionString(properties.Web.Site.WebApplication.Id))) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand("INSERT INTO ITEMSEC (SITE_ID, WEB_ID, LIST_ID, ITEM_ID, USER_ID, priority) VALUES (@siteid, @webid, @listid, @itemid, @userid, @priority)", sqlConnection)) { sqlCommand.Parameters.AddWithValue("@siteid", properties.SiteId); sqlCommand.Parameters.AddWithValue("@webid", properties.Web.ID); sqlCommand.Parameters.AddWithValue("@listid", properties.ListId); sqlCommand.Parameters.AddWithValue("@itemid", properties.ListItemId); sqlCommand.Parameters.AddWithValue("@userid", properties.CurrentUserId); sqlCommand.Parameters.AddWithValue("@priority", priority); sqlCommand.ExecuteNonQuery(); } } SPUser orignalUser = properties.Web.AllUsers.GetByID(properties.CurrentUserId); if (isSecure) { SPListItem li = properties.ListItem; string safeTitle = !string.IsNullOrEmpty(li.Title) ? GetSafeGroupTitle(li.Title) : string.Empty; properties.Web.AllowUnsafeUpdates = true; SPFieldLookup assignedTo = null; try { assignedTo = properties.List.Fields.GetFieldByInternalName("AssignedTo") as SPFieldLookup; } catch { } object assignedToFv = null; string sAssignedTo = string.Empty; try { assignedToFv = li["AssignedTo"]; } catch { } if (assignedToFv != null) { sAssignedTo = assignedToFv.ToString(); } if (string.IsNullOrEmpty(sAssignedTo)) { li["AssignedTo"] = new SPFieldUserValue(properties.Web, orignalUser.ID, orignalUser.LoginName); try { li.SystemUpdate(); } catch (Exception e) { } } } base.EventFiringEnabled = true; }); }
protected void Page_Load(object sender, EventArgs e) { Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Expires = -1; Response.ContentType = "text"; Response.ContentEncoding = System.Text.Encoding.UTF8; SPWeb web = SPContext.Current.Web; SPList list = web.Lists[new Guid(Request["listid"])]; data = "false"; string websetting = Request["websetting"]; string setting = Request["setting"]; string settingid = Request["settingid"]; if (websetting != null && websetting != "") { Guid gWeb = CoreFunctions.getLockedWeb(web); if (websetting == "ReportingServicesURL") { if (gWeb != web.ID) { using (SPWeb lWeb = web.Site.OpenWeb(gWeb)) { data = EPMLiveCore.CoreFunctions.getConfigSetting(lWeb, "ResToolsReportURL"); } } else { data = EPMLiveCore.CoreFunctions.getConfigSetting(web, "ResToolsReportURL"); } if (data == "") { bool integrated = false; try { integrated = bool.Parse(EPMLiveCore.CoreFunctions.getWebAppSetting(web.Site.WebApplication.Id, "ReportsUseIntegrated")); } catch { } if (integrated) { data = EPMLiveCore.CoreFunctions.getWebAppSetting(web.Site.WebApplication.Id, "ReportingServicesURL") + "?" + HttpUtility.UrlEncode(web.Site.Url) + "%2fReport+Library%2fepmlivetl%2fResource%2fResource+Work+vs.+Capacity.rdl"; } else { data = EPMLiveCore.CoreFunctions.getWebAppSetting(web.Site.WebApplication.Id, "ReportingServicesURL") + "?%2fepmlivetl%2fResource%2fResource+Work+vs.+Capacity"; } } } else { data = EPMLiveCore.CoreFunctions.getConfigSetting(web, websetting); } } else if (setting != null && setting != "") { GridGanttSettings gSettings = new GridGanttSettings(list); switch (setting) { case "GeneralSettings": data = gSettings.AllGeneral; break; case "DisplaySettings": data = gSettings.DisplaySettings; break; case "EnableResourcePlan": data = gSettings.EnableResourcePlan.ToString(); break; case "TotalSettings": data = gSettings.TotalSettings; break; } } //web.Close(); }
protected override void CreateChildControls() { var site = SPContext.Current.Site; { var currentWeb = SPContext.Current.Web; currentWeb.Site.CatchAccessDeniedException = false; try { var resourceUrl = string.Empty; var enablePlan = string.Empty; SPSecurity.RunWithElevatedPrivileges(delegate() { resourceUrl = CoreFunctions.getConfigSetting(currentWeb, "EPMLiveResourceURL"); try { GridGanttSettings gSettings = new GridGanttSettings(SPContext.Current.List); enablePlan = gSettings.EnableResourcePlan.ToString(); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } }); if (!string.IsNullOrWhiteSpace(resourceUrl) && enablePlan.Equals(True, StringComparison.InvariantCultureIgnoreCase)) { var menu = string.Empty; var webId = CoreFunctions.getLockedWeb(currentWeb); var reportUrl = string.Empty; if (webId != currentWeb.ID) { using (SPWeb lWeb = site.OpenWeb(webId)) { reportUrl = CoreFunctions.getConfigSetting(lWeb, ResToolsReportURL); } } else { reportUrl = CoreFunctions.getConfigSetting(currentWeb, ResToolsReportURL); } if (!string.IsNullOrWhiteSpace(reportUrl)) { reportUrl = CoreFunctions.getWebAppSetting(currentWeb.Site.WebApplication.Id, "ReportingServicesURL") + "?%2fepmlivetl%2fResource%2fResource+Work+vs.+Capacity"; } menu = "<ie:menuitem id=\"zz25_FindResources\" type=\"option\" iconSrc=\"/_layouts/images/epmlive_rt_find.gif\" onMenuClick=\"javascript:window.open('" + reportUrl + "&URL=" + currentWeb.ServerRelativeUrl + "','', config='height=600,width=800, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes'); return false\" text=\"Find Resource(s)\" description=\"Use this tool to find which resources are available for your work.\" menuGroupId=\"100\"></ie:menuitem>"; menu += "<ie:menuitem id=\"zz26_CheckResource\" type=\"option\" iconSrc=\"/_layouts/images/epmlive_rt_check.gif\" onMenuClick=\"javascript:showgantt('" + ((resourceUrl == "/")?string.Empty:resourceUrl) + "/_layouts/epmlive/checkresgantt.aspx','" + SPContext.Current.ListId + "','" + SPContext.Current.ItemId + "'); return false\" text=\"Check Resource(s)\" description=\"Use this tool to check your assignment against all other work in the system.\" menuGroupId=\"100\"></ie:menuitem>"; var tableControl = new LiteralControl("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"110\"><tr><td class='ms-toolbar'><img src=\"/_layouts/images/epmlive_rt_rt.GIF\" border=\"0\"></td><td class='ms-toolbar'><span style=\"display:none\"><menu type='ServerMenu' id=\"ResourceToolsMenuControls\" largeIconMode=\"true\">" + menu + "</menu></span><span title=\"Open Menu\"><div id=\"ResourceToolsMenu_t\" class=\"ms-menubuttoninactivehover\" onmouseover=\"MMU_PopMenuIfShowing(this);MMU_EcbTableMouseOverOut(this, true)\" hoverActive=\"ms-menubuttonactivehover\" hoverInactive=\"ms-menubuttoninactivehover\" onclick=\" MMU_Open(byid('ResourceToolsMenuControls'), MMU_GetMenuFromClientId('ResourceToolsMenu'),event,false, null, 0);\" foa=\"MMU_GetMenuFromClientId('ResourceToolsMenu')\" oncontextmenu=\"this.click(); return false;\" nowrap=\"nowrap\"><a id=\"ResourceToolsMenu\" accesskey=\"I\" href=\"#\" onclick=\"javascript:return false;\" style=\"cursor:hand;white-space:nowrap;\" onfocus=\"MMU_EcbLinkOnFocusBlur(byid('ResourceToolsMenuControls'), this, true);\" onkeydown=\"MMU_EcbLinkOnKeyDown(byid('ResourceToolsMenuControls'), MMU_GetMenuFromClientId('ResourceToolsMenu'), event);\" onclick=\" MMU_Open(byid('ResourceToolsMenuControls'), MMU_GetMenuFromClientId('ResourceToolsMenu'),event,false, null, 0);\" oncontextmenu=\"this.click(); return false;\" menuTokenValues=\"MENUCLIENTID=ResourceToolsMenu,TEMPLATECLIENTID=ResourceToolsMenuControls\" serverclientid=\"ResourceToolsMenu\">Resource Tools<img src=\"/_layouts/images/blank.gif\" border=\"0\" alt=\"Use SHIFT+ENTER to open the menu (new window).\"/></a><img align=\"absbottom\" src=\"/_layouts/images/menudark.gif\" alt=\"\" /></div></span></td></tr></table>"); Controls.Add(tableControl); var scriptControl = new LiteralControl("<script>" + Properties.Resources.txtCheckResourceJS + "</script>"); Controls.Add(scriptControl); } } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } } base.CreateChildControls(); }
//protected override PickerEntity[] ResolveErrorBySearch(string unresolvedText) //{ // List<PickerEntity> entities = new List<PickerEntity>(); // using (SPWeb web = SPContext.Current.Site.OpenWeb(propBag.LookupWebID)) // { // SPList list = web.Lists[propBag.LookupListID]; // SPField field = list.Fields[propBag.LookupFieldName]; // string valueType = field.TypeAsString; // if (field.Type == SPFieldType.Calculated) // { // valueType = "Text"; // } // SPQuery query = new SPQuery(); // query.ViewAttributes = "Scope=\"Recursive\""; // query.Query = // string.Format( // "<Where><Contains><FieldRef ID=\"{0}\"/><Value Type=\"{1}\">{2}</Value></Contains></Where>", // propBag.LookupFieldName, valueType, unresolvedText); // SPListItemCollection items = list.GetItems(query); // foreach (SPListItem item in items) // { // entities.Add(this.GetEntity(item)); // } // } // return entities.ToArray(); //} private bool IsFieldEditable() { bool isEditable = true; string editableSettings = string.Empty; try { SPList list = SPContext.Current.List; SPField field = list.Fields.GetField(propBag.Field); GridGanttSettings gSettings = new GridGanttSettings(list); if (gSettings.DisplaySettings != "") { fieldProperties = ListDisplayUtils.ConvertFromString(gSettings.DisplaySettings); } switch (mode) { case SPControlMode.Edit: { try { editableSettings = fieldProperties[propBag.Field]["Editable"]; } catch { } if (!string.IsNullOrEmpty(editableSettings)) { if (editableSettings.Split(";".ToCharArray())[0].ToLower().Equals("never")) { isEditable = false; } else if (editableSettings.Split(";".ToCharArray())[0].ToLower().Equals("where")) { string where = editableSettings.Split(";".ToCharArray())[1]; string conditionField = string.Empty; string condition = string.Empty; string group = string.Empty; string valueCondition = string.Empty; if (where.Equals("[Me]")) { condition = editableSettings.Split(";".ToCharArray())[2]; group = editableSettings.Split(";".ToCharArray())[3]; } else //[Field] { conditionField = editableSettings.Split(";".ToCharArray())[2]; condition = editableSettings.Split(";".ToCharArray())[3]; valueCondition = editableSettings.Split(";".ToCharArray())[4]; } isEditable = EditableFieldDisplay.RenderField(field, where, conditionField, condition, group, valueCondition, SPContext.Current.ListItem); } } } break; } } catch { } return(isEditable); }