public static SPList GetListByRelariveUrlOrId(SPWeb web, string listRelativeUrlOrID) { SPList list = null; Guid listID = Guid.Empty; Guid.TryParse(listRelativeUrlOrID, out listID); if (listID != Guid.Empty) { list = web.Lists.GetList(listID, true); } else { list = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, listRelativeUrlOrID)); } return(list); }
/// <summary> /// An item was added. /// </summary> public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite elevatedSite = new SPSite(properties.WebUrl)) { using (SPWeb elevatedWeb = elevatedSite.OpenWeb()) { string serverRelativeListItemUrl = SPUrlUtility.CombineUrl(properties.Web.ServerRelativeUrl, properties.ListItem.Url); SPListItem item = elevatedWeb.GetListItem(serverRelativeListItemUrl); item.BreakRoleInheritance(true); item.RoleAssignments.Remove(elevatedWeb.AssociatedVisitorGroup); item.Update(); } } }); }
private static SPList GetListByUrl(SPWeb web, ListDefinition listModel) { SPList result; try { var targetListUrl = SPUrlUtility.CombineUrl(web.Url, listModel.GetListUrl()); result = web.GetList(targetListUrl); } catch { result = null; } return(result); }
public static SPList TryGetList(this SPWeb web, string listUrl) { if (!string.IsNullOrEmpty(web.ServerRelativeUrl)) { listUrl = SPUrlUtility.CombineUrl(web.ServerRelativeUrl, listUrl); } try { return(web.GetList(listUrl)); } catch (Exception) { return(null); } }
protected void Page_Load(object sender, EventArgs e) { try { SPList list = SPContext.Current.Web.Lists["Conteúdo de Mídia"]; IntranetData intranet = new IntranetData(SPContext.Current.Web.Url); IEnumerable <DG.EmbratelIntranet.Home.ConteudoMidia> itensTv = intranet.ConteudoMidia.Where(t => (t.DataInicio <= DateTime.Now && t.DataFim > DateTime.Now)); List <string> htmlElements = new List <string>(); foreach (DG.EmbratelIntranet.Home.ConteudoMidia tv in itensTv) { SPListItem item = list.GetItemById(tv.Id.Value); string url = new SPFieldUrlValue(tv.URL).Url; if (item.Attachments.Count > 0) { url = SPUrlUtility.CombineUrl(item.Attachments.UrlPrefix, item.Attachments[0]); } else if (!string.IsNullOrWhiteSpace(tv.URL)) { url = new SPFieldUrlValue(tv.URL).Url; } else { continue; } htmlElements.Add(itemhtml .Replace("{titulo}", tv.Title) .Replace("{destino}", ObterDestino(tv)) .Replace("{url}", url)); } rptItens.DataSource = htmlElements; rptItens.DataBind(); if (rptItens.Items.Count == 0) { this.Hidden = true; } } catch { } }
private bool Check_If_Emp_and_Year_saved_before() { bool result = false; SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite oSite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = oSite.OpenWeb(); SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "SkillsRating")); //SPList oList = oWeb.GetList("/Lists/SkillsRating"); #region Get any previous Ratings of same Emp and Year SPQuery qry = new SPQuery(); qry.Query = @" <Where> <And> <And> <Eq> <FieldRef Name='Emp' /> <Value Type='User'>" + strEmpDisplayName + @"</Value> </Eq> <Eq> <FieldRef Name='ObjYear' /> <Value Type='Text'>" + Active_Rate_Goals_Year + @"</Value> </Eq> </And> <Eq> <FieldRef Name='deleted' /> <Value Type='Number'>0</Value> </Eq> </And> </Where>"; qry.ViewFieldsOnly = true; qry.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='Rating' />"; SPListItemCollection listItems = spList.GetItems(qry); if (listItems.Count > 0) { tbl_Rated_Skills = listItems.GetDataTable(); result = true; } #endregion Get any previous Ratings of same Emp and Year }); return(result); }
public static File CreateFile(this Folder folder, string fileName, byte[] content, bool overwrite) { if (!folder.IsPropertyAvailable("ServerRelativeUrl")) { folder.Context.Load(folder); folder.Context.ExecuteQuery(); } FileCreationInformation fileCreateInfo = new FileCreationInformation { Content = content, Overwrite = overwrite, Url = SPUrlUtility.CombineUrl(folder.ServerRelativeUrl, fileName) }; return(folder.CreateFile(fileCreateInfo)); }
protected override void OnPreInit(EventArgs e) { // this sets the MasterPageFile to public.master (if the web has been setup to use that) base.OnPreInit(e); try { if (SPContext.Current.Web.CurrentUser != null && this.MasterPageFile.EndsWith("public.master", StringComparison.OrdinalIgnoreCase)) { //the user is logged in and the site uses the public.master // change it to private.master this.MasterPageFile = SPUrlUtility.CombineUrl(SPContext.Current.Site.ServerRelativeUrl, string.Concat("_catalogs/masterpage/", "private.master")); } } catch { } // this is an error trap, don't do anything }
public static string GetUrlFromPrefixedUrl(string prefixedUrl, bool fullUrl = false) { if (string.IsNullOrEmpty(prefixedUrl) || SPContext.Current == null) { return(prefixedUrl); } string webUrl = fullUrl ? SPContext.Current.Web.Url : SPContext.Current.Web.ServerRelativeUrl; string siteUrl = fullUrl ? SPContext.Current.Site.Url : SPContext.Current.Site.ServerRelativeUrl; StringBuilder stringBuilder = new StringBuilder(); int length; if (prefixedUrl.StartsWith("~layouts/", true, CultureInfo.InvariantCulture)) { stringBuilder.Append(SPUrlUtility.CombineUrl(siteUrl, GetLayoutsFolder())); length = "~layouts/".Length; } else if (prefixedUrl.StartsWith("~siteLayouts/", true, CultureInfo.InvariantCulture)) { stringBuilder.Append(SPUrlUtility.CombineUrl(webUrl, GetLayoutsFolder())); length = "~siteLayouts/".Length; } else if (prefixedUrl.StartsWith(SPUtility.SiteRelativeUrlPrefix, true, CultureInfo.InvariantCulture)) { stringBuilder.Append(siteUrl); length = SPUtility.SiteRelativeUrlPrefix.Length; } else if (prefixedUrl.StartsWith(SPUtility.WebRelativeUrlPrefix, true, CultureInfo.InvariantCulture)) { stringBuilder.Append(webUrl); length = SPUtility.WebRelativeUrlPrefix.Length; } else { return(prefixedUrl); } if (stringBuilder.Length <= 0 || stringBuilder[stringBuilder.Length - 1] != '/') { stringBuilder.Append('/'); } stringBuilder.Append(prefixedUrl.Substring(length)); return(stringBuilder.ToString()); }
/// <summary> /// Añadir Campos /// </summary> /// <param name="column"></param> /// <returns></returns> public bool AddField(SiteColumn column) { try { var listEdit = Web.GetList(SPUrlUtility.CombineUrl(Web.Url, string.Concat("/lists/", Name))); switch (column.Type) { case SPFieldType.Boolean: AddFieldBoolean(column, listEdit); break; case SPFieldType.Choice: AddFieldChoice(column, listEdit); break; case SPFieldType.DateTime: AddFieldDateTime(column, listEdit); break; case SPFieldType.Lookup: AddFieldLookup(column, listEdit); break; case SPFieldType.Calculated: AddFieldCalculated(column, listEdit); break; case SPFieldType.Currency: Web.Fields.Add(Name, column.Type, column.Required); AddFieldCurrency(column); break; default: listEdit.Fields.Add(column.Name, column.Type, column.Required); break; } } catch (Exception exception) { Logger.Error(string.Concat("Add Field", exception.Message)); return(false); } return(true); }
protected SPSite GetExistingSite(SPWebApplication webApp, SiteDefinition definition) { var siteCollectionUrl = SPUrlUtility.CombineUrl(definition.PrefixName, definition.Url); siteCollectionUrl = siteCollectionUrl.TrimEnd('/'); if (siteCollectionUrl.StartsWith("/") && siteCollectionUrl.Length > 0) { siteCollectionUrl = siteCollectionUrl.Substring(1, siteCollectionUrl.Length - 1); } if (webApp.Sites.Names.Contains(siteCollectionUrl)) { return(webApp.Sites[siteCollectionUrl]); } return(null); }
protected override SPList GetCurrentObject(WebModelHost typedModelHost, ListDefinition definition) { SPList result; try { var web = typedModelHost.HostWeb; var targetListUrl = SPUrlUtility.CombineUrl(web.Url, definition.GetListUrl()); result = web.GetList(targetListUrl); } catch { result = null; } return(result); }
protected override void DeployModelInternal(object modelHost, DefinitionBase model) { var webModelHost = modelHost.WithAssertAndCast <WebModelHost>("modelHost", value => value.RequireNotNull()); var web = webModelHost.HostWeb; var listModel = model.WithAssertAndCast <ListDefinition>("model", value => value.RequireNotNull()); TraceUtils.WithScope(traceScope => { var spList = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, listModel.GetListUrl())); traceScope.WriteLine(string.Format("Validate model:[{0}] field:[{1}]", listModel, spList)); // assert base properties traceScope.WithTraceIndent(trace => { trace.WriteLine(string.Format("Validate Title: model:[{0}] list:[{1}]", listModel.Title, spList.Title)); Assert.AreEqual(listModel.Title, spList.Title); trace.WriteLine(string.Format("Validate Description: model:[{0}] list:[{1}]", listModel.Description, spList.Description)); Assert.AreEqual(listModel.Description, spList.Description); trace.WriteLine(string.Format("Validate ContentTypesEnabled: model:[{0}] list:[{1}]", listModel.ContentTypesEnabled, spList.ContentTypesEnabled)); Assert.AreEqual(listModel.ContentTypesEnabled, spList.ContentTypesEnabled); // TODO // template type & template name if (listModel.TemplateType > 0) { trace.WriteLine(string.Format("Validate TemplateType: model:[{0}] list:[{1}]", listModel.TemplateType, spList.BaseTemplate)); Assert.AreEqual(listModel.TemplateType, (int)spList.BaseTemplate); } else { trace.WriteLine(string.Format("Skipping TemplateType check. It is 0")); } // TODO // url checking trace.WriteLine(string.Format("Validate Url: model:[{0}] list:[{1}]", listModel.GetListUrl(), spList.RootFolder.ServerRelativeUrl)); Assert.IsTrue(spList.RootFolder.ServerRelativeUrl.Contains(listModel.GetListUrl())); }); }); }
protected override string GetFileNodeNavigationUrl(SPListItem item) { if (item == null) { throw new ArgumentNullException("item"); } const string urlTemplate = "Javascript:frameview(\"{0}/_layouts/ReportServer/RSViewerPage.aspx?rv:RelativeReportUrl={1}{2}&rv:HeaderArea=none\");"; const string slash = "/"; var urlParameters = Get2006Parameters(SPUrlUtility.CombineUrl(web.Url, item.Url)); var relativeUrl = web.ServerRelativeUrl == slash ? string.Empty : web.ServerRelativeUrl; var navUrl = string.Format(urlTemplate, relativeUrl, HttpUtility.UrlEncode(string.Concat(relativeUrl, slash, item.Url)), urlParameters); return(navUrl); }
public static SPListItemCollection get_StrategicDirections() { SPListItemCollection listItems = null; SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite oSite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = oSite.OpenWeb(); SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "StrDir")); //SPList spList = spWeb.GetList("/Lists/StrDir"); if (spList != null) { SPQuery qry = new SPQuery(); qry.ViewFieldsOnly = true; qry.ViewFields = @"<FieldRef Name='ID' /><FieldRef Name='Title' />"; listItems = spList.GetItems(qry); } }); return(listItems); }
protected override void CreateChildControls() { Controls.Clear(); #if SP2010 string versionedControlTemplatesFolder = @"~/_CONTROLTEMPLATES"; #endif #if SP2013 string versionedControlTemplatesFolder = SPUrlUtility.CombineUrl("/", SPUtility.ContextControlTemplatesFolder); #endif _ascxPath = versionedControlTemplatesFolder + "/Glyma/MappingToolWebPartUserControl.ascx"; _mappingToolControl = Page.LoadControl(_ascxPath) as GlymaMappingToolWebPart.MappingToolWebPartUserControl; if (_mappingToolControl != null) { Controls.Add(_mappingToolControl); } }
private static void copyTemplates(SPFolder template, SPFolder dest, bool isProtected) { foreach (SPFile f in template.Files) { Hashtable fileProperties = new Hashtable(); fileProperties["vti_Title"] = Regex.Replace(f.Name, "[0-9]+\\s", ""); int intOutNr; string strNumber = f.Name.Substring(0, 2); if (int.TryParse(strNumber, out intOutNr)) { fileProperties["DocumentNumber"] = strNumber; } var templatefile = f.OpenBinaryStream(SPOpenBinaryOptions.SkipVirusScan); var file = dest.Files.Add(SPUrlUtility.CombineUrl(dest.ServerRelativeUrl, f.Name), templatefile, fileProperties, true); if (isProtected) { file.Item[BriefingFields.DocumentIsProtectedName] = isProtected; file.Item.UpdateOverwriteVersion(); SPUtil.SecureBriefing(file.Item); } if (file.CheckOutType != SPFile.SPCheckOutType.None) { file.CheckIn(""); } } foreach (SPFolder folder in template.SubFolders) { if (folder.Item != null && folder.Name != "Forms") { SPFolder fld = dest.SubFolders.Add(folder.Name); SPListItem folderItem = fld.Item; folderItem["ExemptPublishAll"] = folder.Item["ExemptPublishAll"]; folderItem.Update(); copyTemplates(folder, fld, isProtected); } } }
public static SPListItemCollection get_PrimaryGoals(string str_dir_id) { SPListItemCollection listItems = null; SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite oSite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = oSite.OpenWeb(); SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "LinesRelToStrDir")); //SPList spList = spWeb.GetList("/Lists/LinesRelToStrDir"); if (spList != null) { SPQuery qry = new SPQuery(); qry.Query = "<Where><Eq><FieldRef Name='RelStrDir_x003a__x0627__x0644__x' /><Value Type='Lookup' >" + str_dir_id + "</Value></Eq></Where>"; listItems = spList.GetItems(qry); } }); DataTable test = listItems.GetDataTable(); return(listItems); }
protected override void CreateChildControls() { if (String.IsNullOrEmpty(ChartTitle) || String.IsNullOrEmpty(LibraryTitle)) { this.Controls.Add(new LiteralControl( "Configuration Error: Chart Title or Library Title has not been set.")); } else { try { SPSite site = SPContext.Current.Site; SPList mpGallery = site.RootWeb.GetCatalog(SPListTemplateType.MasterPageCatalog); string xapUrl = SPUrlUtility.CombineUrl(mpGallery.RootFolder.ServerRelativeUrl, "Chapter11.Silverlight.xap"); string markup = String.Format( @"<div id=""silverlightControlHost""> <object data=""data:application/x-silverlight-2,"" type=""application/x-silverlight-2"" width=""100%"" height=""100%""> <param name=""source"" value=""{0}""/> <param name=""minRuntimeVersion"" value=""5.0.61118.0"" /> <param name=""initParams"" value=""MS.SP.url={1},ChartTitle={2},LibraryTitle={3}"" /> <param name=""autoUpgrade"" value=""true"" /> <a href=""http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0"" style=""text-decoration:none""> <img src=""http://go.microsoft.com/fwlink/?LinkId=161376"" alt=""Get Microsoft Silverlight"" style=""border-style:none""/> </a> </object><iframe id=""_sl_historyFrame"" style=""visibility:hidden;height:0px;width:0px;border:0px""></iframe> </div>", xapUrl, SPHttpUtility.HtmlEncode(SPContext.Current.Web.Url), this.ChartTitle, this.LibraryTitle); this.Controls.Add(new LiteralControl(markup)); } catch (Exception ex) { this.Controls.Add(new LiteralControl("Error: " + ex.Message)); } } }
protected override string GetFileNodeNavigationUrl(SPListItem item) { if (item == null) { throw new ArgumentNullException("item"); } const string slash = "/"; var urlTemplateBuilder = new StringBuilder().Append("Javascript:window.open('{0}/_layouts/ReportServer/RSViewerPage.aspx?") .Append("rv:RelativeReportUrl={1}{2}") .Append("&rv:HeaderArea=none','',config='toolbar=no, menubar=no, scrollbars=yes, ") .Append("resizable=yes,location=no, directories=no, status=yes');void(0);"); var relativeUrl = web.ServerRelativeUrl == slash ? string.Empty : web.ServerRelativeUrl; var urlParameters = Get2006Parameters(SPUrlUtility.CombineUrl(web.Url, item.Url)); var navUrl = string.Format(urlTemplateBuilder.ToString(), relativeUrl, HttpUtility.UrlEncode(string.Concat(relativeUrl, slash, item.Url)), urlParameters); return(navUrl); }
// Обновляем поле после изменений пользователя public override void UpdateFieldValueInItem() { // Проверяем валидность страницы Page.Validate(); if (Page.IsValid) { // Посмотрим, что пришло с клиента FileUpload fuDocument = (FileUpload)TemplateContainer.FindControl("fuDocument"); HiddenField hdFileName = (HiddenField)TemplateContainer.FindControl("hdFileName"); // Если скрытое поле пусто и есть файл, значит, его нужно удалить if (hdFileName.Value == String.Empty && currentFile != null) { // Удаляем файл deleteFile(); // Обнуляем значение поля currentFile = null; } // Загружаем файл и выставляем на него ссылки if (fuDocument.HasFile) { SPWeb web = SPContext.Current.Site.RootWeb; SPFolder folder = web.GetFolder(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, libraryName)); // Если файл был, удалим его if (currentFile != null) { deleteFile(); } // Добавим новый файл и сохраним соответствующие значения currentFile = addFile(folder, fuDocument); } base.UpdateFieldValueInItem(); } }
public static string get_Active_Set_Goals_Year() { string pActiveYear = "NoSetGoalsActiveYear"; SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite oSite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = oSite.OpenWeb(); SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "EPMYear")); //SPList spList = spWeb.GetList("/Lists/EPMYear"); if (spList != null) { SPQuery qry = new SPQuery(); qry.Query = @" <Where> <Eq> <FieldRef Name='State' /> <Value Type='Choice'>مفعل</Value> </Eq> </Where>"; qry.ViewFieldsOnly = true; qry.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='Year' /><FieldRef Name='State' />"; SPListItemCollection listItems = spList.GetItems(qry); if (listItems.Count > 0) { foreach (SPListItem item in listItems) { if (item["State"].ToString() == "مفعل" && item["Title"].ToString() == "البدء بتفعيل وضع الأهداف لسنة") { pActiveYear = item["Year"].ToString(); } } } } }); return(pActiveYear); }
private string read_Year_to_display_if_none_active() { string pActiveYear = ((DateTime.Today.Year) - 1).ToString(); SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite oSite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = oSite.OpenWeb(); SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "EPMYear")); //SPList spList = spWeb.GetList("/Lists/EPMYear"); if (spList != null) { SPQuery qry = new SPQuery(); qry.Query = @" <Where> <Eq> <FieldRef Name='State' /> <Value Type='Choice'>عرض فقط</Value> </Eq> </Where>"; qry.ViewFieldsOnly = true; qry.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='Year' /><FieldRef Name='State' />"; SPListItemCollection listItems = spList.GetItems(qry); if (listItems.Count > 0) { foreach (SPListItem item in listItems) { if (item["State"].ToString() == "عرض فقط" && item["Title"].ToString() == "سنة عرض التقييم (فى حالة عدم وجود عام مفعل)") { pActiveYear = item["Year"].ToString(); } } } } }); return(pActiveYear); }
public static SPList GetTargetList(SPWeb targetWeb, string listTitle, string listUrl, Guid?listId) { SPList result = null; if (listId.HasValue && listId != default(Guid)) { result = targetWeb.Lists[listId.Value]; } else if (!string.IsNullOrEmpty(listUrl)) { result = targetWeb.GetList(SPUrlUtility.CombineUrl(targetWeb.ServerRelativeUrl, listUrl)); } else if (!string.IsNullOrEmpty(listTitle)) { result = targetWeb.Lists.TryGetList(listTitle); } else { throw new SPMeta2Exception("ListUrl, ListTitle or ListId should be defined."); } return(result); }
/// <summary> /// A site is being provisioned /// </summary> public override void WebAdding(SPWebEventProperties properties) { base.WebAdding(properties); using (SPWeb web = properties.Web) { SPList webRegistryList = web.Lists.TryGetList(Constants.WebRegistry.ListTitle); if (webRegistryList != null) { SPListItem webRegistryItem = webRegistryList.Items.Add(); webRegistryItem[Constants.WebRegistry.SiteRelativeUrl] = SPUrlUtility.CombineUrl(properties.FullUrl, properties.NewServerRelativeUrl); webRegistryItem[Constants.WebRegistry.Template] = properties.Web.ID; webRegistryItem[Constants.WebRegistry.CreatedDate] = DateTime.Now; using (EventReceiverScope scope = new EventReceiverScope(false)) { webRegistryItem.Update(); } Logger.WriteLog(Logger.Category.Information, "DetectionSubSiteEventReceiver", "Event WebAdding. Added new Web Registry element in list"); } else { Logger.WriteLog(Logger.Category.High, "DetectionSubSiteEventReceiver", "Event WebAdding. WebRegistry List is null"); } } }
private static void saveAdditionalDocuments(SPWeb web, SPListItem briefingItem, string briefingNumber, string[] additionalDocuments) { SPFolder additionalDocumentsFolder = web.GetFolder(SPUrlUtility.CombineUrl(briefingItem.Folder.Url, "/Additional Documents")); if (additionalDocumentsFolder.Exists) { if (additionalDocuments != null) { foreach (SPFile file in additionalDocumentsFolder.Files.OfType <SPFile>().ToList()) { if (!additionalDocuments.Contains(file.Name)) { file.Recycle(); } } } } else { additionalDocumentsFolder = briefingItem.Folder.SubFolders.Add("Additional Documents"); } SPSecurity.RunWithElevatedPrivileges(() => { using (var ctx = new SPFolderContext()) { var tempDocuments = ctx.BriefingInputDocuments .Where(doc => doc.BriefingNumber == briefingNumber) .Where(doc => additionalDocuments.Contains(doc.Filename)); foreach (var file in tempDocuments) { additionalDocumentsFolder.Files.Add(file.Filename, file.Filecontent, true); } ctx.ClearBriefingInputDocuments(briefingNumber); } }); }
private void DeployNintexWorkflow(ListModelHost listModelHost, NintexWorkflowDefinition workflowDefinition) { var list = listModelHost.HostList; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = workflowDefinition, ObjectType = typeof(NintexWorkflowDefinition), ObjectDefinition = workflowDefinition, ModelHost = list }); using (var nintexService = new NintexWorkflowService.NintexWorkflowWS()) { nintexService.Url = SPUrlUtility.CombineUrl(list.ParentWeb.Url, NintexUrls.WorkflowServiceUrl); nintexService.PreAuthenticate = true; nintexService.Credentials = System.Net.CredentialCache.DefaultCredentials; var xmlnw = Encoding.UTF8.GetString(workflowDefinition.WorkflowXml); var result = nintexService.PublishFromNWFXml(xmlnw, list.Title, workflowDefinition.WorkflowName, true); } InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = workflowDefinition, ObjectType = typeof(NintexWorkflowDefinition), ObjectDefinition = workflowDefinition, ModelHost = list }); }
protected void Btn_Click(object sender, EventArgs e) { NewListItem newListItem = new NewListItem( Title_TextBox.Text, Description_TextBox.Text, PublishingDate_TextBox.Text, PersonAsign_TextBox.Text, CheckBoxVisible.Checked); SPWeb web = SPContext.Current.Web; SPList list = web.GetList(SPUrlUtility.CombineUrl(web.ServerRelativeUrl, "/Lists/News")); SPListItem listItem = list.Items.Add(); listItem["Title"] = newListItem.Title; listItem["DescriptionNews"] = newListItem.Description; listItem["PublishingDate"] = newListItem.PublishingDate; listItem["PersonAssigned"] = newListItem.PersonAsigne; listItem["Visible"] = newListItem.IsVisible; listItem.Update(); Add_Item_In_Repeater("ID", true); }
public string CreateSiteCollection(SiteData site) { string siteUrl = string.Empty; uint siteLcIdint = 1033; Guid siteId = SPContext.Current.Site.ID; // Elevation - would not actually be neeeded if we call this by using specific account with the right permissions, but is also one option. SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite elevSite = new SPSite(siteId)) { if (!string.IsNullOrEmpty(site.LcId)) { siteLcIdint = Convert.ToUInt16(site.LcId); } siteUrl = SPUrlUtility.CombineUrl(elevSite.Url, site.Url); if (!SPSite.Exists(new Uri(siteUrl))) { using (SPSite newSite = elevSite.SelfServiceCreateSite(siteUrl, site.Title, site.Description, siteLcIdint, site.WebTemplate, site.OwnerLogin, string.Empty, string.Empty, site.SecondaryContactLogin, string.Empty, string.Empty)) { //create the default groups newSite.RootWeb.CreateDefaultAssociatedGroups(newSite.Owner.LoginName, newSite.SecondaryContact.LoginName, site.Title); } } else { //TODO - site already existed... abort abort! } } }); return(siteUrl); }
public static void Change_State_to(WF_States pNew_state, string strEmpDisplayName, string Active_Set_Goals_Year) { SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite oSite = new SPSite(SPContext.Current.Web.Url); SPWeb spWeb = oSite.OpenWeb(); spWeb.AllowUnsafeUpdates = true; SPList spList = spWeb.GetList(SPUrlUtility.CombineUrl(spWeb.ServerRelativeUrl, "lists/" + "Objectives")); SPQuery qry = new SPQuery(); qry.Query = @" <Where> <And> <Eq> <FieldRef Name='Emp' /> <Value Type='User'>" + strEmpDisplayName + @"</Value> </Eq> <Eq> <FieldRef Name='ObjYear' /> <Value Type='Text'>" + Active_Set_Goals_Year + @"</Value> </Eq> </And> </Where>"; qry.ViewFieldsOnly = true; qry.ViewFields = @"<FieldRef Name='ID' /><FieldRef Name='Status' />"; SPListItemCollection listItems = spList.GetItems(qry); foreach (SPListItem item in listItems) { SPListItem itemToUpdate = spList.GetItemById(item.ID); itemToUpdate["Status"] = pNew_state.ToString(); itemToUpdate.Update(); } spWeb.AllowUnsafeUpdates = false; }); }