We need to update Global and Current Navigation Settings for the site.
Below is our code
var publishingWeb = PublishingWeb.GetPublishingWeb(this.CC, subWeb);
// WebNavigationSettings
var webNavigationSettings = new WebNavigationSettings(this.CC, subWeb);
webNavigationSettings.GlobalNavigation.Source = StandardNavigationSource.PortalProvider;
webNavigationSettings.CurrentNavigation.Source = StandardNavigationSource.PortalProvider;
// CSOM don't have: publishingWeb.Navigation.GlobalIncludeSubSites.
subWeb.AllProperties["__GlobalIncludeSubSites"] = "True"; //TODO: Verify why it is not working.
subWeb.AllProperties["__GlobalIncludePages"] = "True"; //TODO: Verify why it is not working.
subWeb.Update();
webNavigationSettings.Update(tSession);
CC.Load(subWeb, WEB_INCLUDES);
// Apply the load
CC.ExecuteQuery();
As we are using CSOM, we did not have
publishingWeb.Navigation.GlobalIncludeSubSites
.
So we tried to set using AllProperties to set GlobalIncludeSubSites and GlobalIncludePages.
But those properties are not getting set.
Is there any way to fix this problem.
I went throught article http://discoveringsharepoint.wordpress.com/2013/03/19/programmatically-set-navigation-settings-in-sharepoint-2013/
But it uses namespace : Microsoft.SharePoint.Publishing.Navigation
But our's namespace is : Microsoft.SharePoint.Client.Publishing.Navigation
As we are doing from client server object model.
Is there any way to solve this ?
Thanks
In SharePoint 2013 was introduced a new Microsoft.SharePoint.Client.Publishing and Microsoft.SharePoint.Client.Publishing.Navigation namespaces in CSOM API. But unfortunately it is not supported to modify navigation settings using WebNavigationSettings class since properties are exposes as a read-only.
You could utilize the following approach for that purpose. ClientPortalNavigation.cs represents a CSOM counterpart for SSOM PortalNavigation Class.
The following example demonstrates how to utilize that class and update Navigation settings:
using (var ctx = new ClientContext(webUri))
{
var navigation = new ClientPortalNavigation(ctx.Web);
navigation.CurrentIncludePages = true;
navigation.GlobalIncludePages = false;
navigation.SaveChanges();
}
ClientPortalNavigation.cs is compatible with SharePoint 2010/2013
CSOM APIs.
References
Access and Manipulate Navigation Settings via SharePoint Client Object Model
ClientPortalNavigation.cs
Related
My mvc application is updating the status on a custom entity in CRM dynamics 2015. we have a plugin which gets triggered when we update a specific status. We are facing a concurrency issue here, when two different is trying to update the same status at a same time on the entity, the status gets updated twice and system fires the plugin twice.
I tried using in my MVC code but it gives an error. Seems like i cannot use it on custom entity
Portal.abcclaim obj= new Portal.abcclaim ();
obj.Attributes["abcclaimreceiveddate"] = Convert.ToDateTime(DateTime.Now);
obj.Attributes["abcdateclaimsubmitted"] = Convert.ToDateTime(DateTime.Now);
obj.Attributes["abcmodifiedbycontact"] = new EntityReference(Portal.Contact.EntityLogicalName, loggedInId);
obj.Attributes["abcstatus"] = new EntityReference(Portal.abc_status.EntityLogicalName, status);
obj.Attributes["SuppressDuplicateDetection"] = false;
obj.Id = objid;
serviceProxy.Update(obj);
is there any other way to handle this?
You should use dedicated request if you want to set request parameters. In yours case it will be UpdateRequest (https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.messages.updaterequest?view=dynamics-general-ce-9).
var updateRequest = new UpdateRequest()
{
Target = obj,
};
updateRequest["SuppressDuplicateDetection"] = false;
var response = (UpdateResponse)osvc.Execute(updateRequest);
But it doesn't look like duplicate detection will solve concurrency problems. You should check check how to use ConcurrencyBehavior parameter. You can read more about concurrency in Dynamics 365 in this MS docs article: https://learn.microsoft.com/en-us/powerapps/developer/common-data-service/optimistic-concurrency
Hope that helps.
I am totally new to proxmox VE and i want to create a Vitual Machine inside proxmox using C# console application.
I have search a lot and i only found an API program which has all the functionality but i don't know how to use it. https://github.com/EnterpriseVE/eve2pve-api-dotnet
Can someone help me how to create and delete a vm in proxmox using this API in detail or anyone have any different approach to do this
Usage:
var client = new Client("10.92.90.91");
if (client.Login("root", "password"))
{
var vm = client.Nodes["pve1"].Qemu[100];
//config vm
var config = vm.Config.VmConfig();
Console.WriteLine(Client.ObjectToJson(config.Response));
//create snapshot
var response = vm.Snapshot.Snapshot("pippo2311");
//update snapshot description
vm.Snapshot["pippo2311"].Config.UpdateSnapshotConfig("descr");
//delete snapshot
vm.Snapshot["pippo2311"].Delsnapshot();
//list of snapshot
foreach (var snapshot in vm.Snapshot.SnapshotList().Response.data)
{
Console.WriteLine(Client.ObjectToJson(snapshot));
Console.WriteLine(snapshot.name);
}
client.ResponseType = "png";
var dataImg = client.Nodes["pve1"].Rrd.Rrd("cpu", "day").Response;
Console.WriteLine("<img src=\"{dataImg}\" \>");
}
Get the project from github
Compile the project
Add reference to the project's dll
Use it just like the example above
I am working with an SDK that can query a set of data as well as update data with a restful web service called VersionOne. We use the web service to document QA testing. Each test has attributes such as "Name", "Status", etc. Most of the attributes have been successfully updating except for "Status".
Here is the method I am calling, when I step through the code I can get the old value but cannot change the attribute value as expected. An error stating "Cannot assign new value to a read-only attribute".
public bool TestInProgress()
{
var testId = Oid.FromToken("Test:26017", _context.MetaModel);
var query = new Query(testId);
var assetType = _context.MetaModel.GetAssetType("Test");
var testStatus = assetType.GetAttributeDefinition("Status.Name");
query.Selection.Add(testStatus);
var result = _context.Services.Retrieve(query);
var test = result.Assets[0];
var oldResult = GetValue(test.GetAttribute(testStatus).Value);
test.SetAttributeValue(testStatus, "Failed");
_context.Services.Save(test);
LogResult(test.Oid.Token, oldResult, GetValue(test.GetAttribute(testStatus).Value));
Console.WriteLine(test.Oid.Token, oldResult, GetValue(test.GetAttribute(testStatus).Value));
return true;
}
https://github.com/versionone/VersionOne.SDK.Net.APIClient#attribute-definition
According to the VersionOne SDK documentation it appears as though "read-only" and is an attribute. I've looked though the different attribute from several different tests and testsets and do not see it. I am authenticated properly and have successfully updated other attributes with many different tests. However, when I attempt to programmatically change the "Status" attribute it says it is read-only.
https://github.com/versionone/VersionOne.SDK.Net.APIClient#learn-by-example-apiclient-setup
How do you change the attribute for an asset in VersionOne programmatically that is currently read-only so you can update the attribute using the restful web service?
Because the Attribute is read-only, you will not be able to change its value. Instead, consider creating a 'new' Asset, set its Attributes, and then save it.
Review the example below and attempt to utilize the idea within your project:
var TestId = Oid.FromToken("Test:26017", _context.MetaModel);
var TestAsset = _context.MetaModel.GetAssetType("Test");
var newTestAsset = _context.Services.New(TestAsset, TestId);
var TestStatusAttr = newTestAsset.GetAttributeDefinition("Status.Name");
newTestAsset.SetAttributeValue(TestStatusAttr, "Failed");
_context.Services.Save(newTestAsset);
Here is the code which I have written to access the Projects and the team, but it shows some error. I want to access the project and then the Source Code present in the Source Control Explorer in the Project/Team.
Uri _serverUri = new Uri("MyURI");
string _teamProjectName = "MyProject";
TfsTeamProjectCollection collection =
TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_serverUri);
// Retrieve the project URI. Needed to enumerate teams.
var css4 = collection.GetService<ICommonStructureService>();
ProjectInfo projectInfo = css4.GetProjectFromName(_teamProjectName);
// Retrieve a list of all teams on the project.
TfsTeamService teamService = collection.GetService<TfsTeamService>();
var allTeams = teamService.QueryTeams(projectInfo.Uri);
allTeams.ToList().ForEach
(
allteams => { Console.WriteLine(allteams); });
The error which it shows is "The type or namespace 'Core' does not exist in the namespace Microsoft.TeamFoundation.Server
I also want to access the source control, so if anyone can help me with both of my issues.
Background:
I have a built-in-house custom SharePoint 2010 web part, inheriting from System.Web.UI.WebControls.WebParts.WebPart, which has a property defined like so:
[Personalizable(PersonalizationScope.User)]
[WebBrowsable(true)]
[WebDisplayName("...")]
[WebDescription("...")]
[Category("...")]
public string CustomProp { get; set; }
The Powers-That-Be would like to know the value of the property for each of its 3,000 users. I'm already familiar with how to use the SPLimitedWebPartManager to extract the property in either shared view or my own personal view, using code similar to:
var pageUrl = "/Pages/SomePage.aspx";
var limitedManager = SPContext.Current.Web.GetLimitedWebPartManager(
pageUrl,
PersonalizationScope.User); // or .Shared, if loading the shared value
var webPart = limitedManager.WebParts.OfType<MyWebPart>().FirstOrDefault();
var prop = webPart.CustomProp;
So, the question:
I'm stuck on collecting this information for all users. Assuming I already have, or know how to retrieve, a list of login names or SPUser objects, how do I go about retrieving the web part property for all users? I can use suggestions in C#, VB.NET, or PowerShell.
Try this code - I haven't tested it but I think it should work.
const string absolutePageUrl = "http://spsite:5000/Pages/SomePage.aspx";
foreach (SPUser user in SPContext.Current.Site.RootWeb.AllUsers.Cast<SPUser>())
{
if (!user.LoginName.StartsWith("DOMAIN NAME"))
continue;
using (SPSite site = new SPSite(absolutePageUrl, user.UserToken))
using (SPWeb web = site.OpenWeb())
{
var mgr = web.GetLimitedWebPartManager(absolutePageUrl, PersonalizationScope.User);
var webPart = mgr.WebParts.OfType<MyWebPart>().FirstOrDefault();
var prop = webPart.CustomProp;
}
}