We are managing an umbraco site which has over 2000 nodes .We have recently added a new property in one of our master document type,since it is a new property the existing nodes doesn't have the property value .We have to update the value of that property in each node before deploying the new changes.It is very difficult to update the values manually since it takes a lot of time.What we are planning is to use a one time upgrade aspx page or user control to accomplish this job. has anyone ever been into this kind of a situation ?how to make a one time upgrade page ? Any help would be appreciated .
I fairly sure that this isn't in the core and that there hasn't been a package created for exactly this purpose. But it's pretty simple to create a macro containing a razor (cshtml) script that updates a single property for all the descendants of a particular node:
Something like (just from memory of the Level 2 course):
var nodes = #Model.DescendantsOrSelf(-1); //-1 is the root node
foreach (var node in nodes)
{
Document doc = new Document(node.Id);
doc.getProperty("yourProperty").Value = "xxx"; // the getProperty looks wrong, I know
doc.Publish(new User(0)); //User 0 is the admin user
umbraco.library.UpdateDocumentCache(doc.Id);
}
This great package http://our.umbraco.org/projects/developer-tools/content-maintenance-dashboard-package does mass updating, but last time I checked it didn't update single fields - but it might do by now.
I would have thought doing a republish of the xml cache should do this if you go to the following url:
/umbraco/dialogs/republish.aspx?xml=true
Related
I have this unique requirement where each time a particular Content Fragment is updated in AEM, all the Experience Fragments referencing that particular Content Fragment need to be automatically exported to Adobe Target.
Thinking about using SQL2 query to retrieve XFs referencing a particular CF and then incorporating this into a workflow process. Also, wondering if I can leverage aem OOTB workflow process called "Export to Target" in this.
Not really sure of how to call this "Export to Target" process on each Experience Fragment that we need to export to Target or is this possible at all?
Wondering if anyone has ever come across this requirement and succeeded.
Highly appreciate any tips or suggestions in this regard. Many Thanks in advance.
Whenever a Content Fragment is created or updated an OSGi event is triggered. All events are logged under http://localhost:4502/system/console/events. You could write a EventListener or EventHandler, get the path of the event, get the Resource and adapt it to com.adobe.cq.dam.cfm.ContentFragment. The topic for these events is "com/day/cq/dam" or in this constant.
From the adapted Class or Resource you can get informations about the model and if it's the model you want to process.
To find all references I would also create an oak index and use SQL2 query to find all references.
The query would be something like this:
select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, '"/content/dam/myReferencedModel"')
If you have all referencing XF's you can kick off any workflow via WorkflowService:
#Reference
private WorkflowService workflowService;
WorkflowSession wfSession = workflowService.getWorkflowSession(session);
WorkflowModel wfModel = wfSession.getModel("/var/workflow/models/mymodel");
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", "/payload");
wfSession.startWorkflow(wfModel, wfData);
I have a content item the has a field with a library of files. I created a separate content item to store the metadata for the files, which includes an integer field called SortOrder that is used for controlling the order of images on the page.
To make the sorting faster at the client's request, I created a page for admins with a jQuery sortable grid of the images that enables drag-and-drop ordering. This works very well by updating the metadata each time an image is dragged.
The problem is that a metadata entry isn't automatically created each time a new image is dragged into the library, so in this case there is no metadata to update. I can manually create the content item, but there doesn't seem to be a way in the API to tag it as belonging to a particular library item.
Hopefully someone can help me find a way using the 2SXC WebAPI or c# code to add metadata to any library item that doesn't exist. I see in the database that the entities are linked in the ToSIC_EAV_Entities using the AssignmentObjectTypeID and KeyString fields, but I would prefer to not make direct database changes. These changes also seem to require clearing the cache and restarting the application pool to be reflected in the UI.
So as of now this is actually a missing detail in the REST API, but the App.Data.Create has an overload for this. check out https://github.com/2sic/eav-server/blob/master/ToSic.Eav.AppEngine/DataSources/App.cs#L26
So it's not perfect but you should be able to continue your work for now.
Based on your pointers, I was able to create a solution using a custom WebAPI:
var contentTypeName = "PhotoDetails";
var userName = Dnn.User.Username;
var fileId = metadata.FileId.ToString();
MetadataFor target = new MetadataFor()
{
TargetType = 10, // hardcoded based on other content item metadata for no until further understood
KeyString = "file:" + fileId // file number comes from dnn's file table
};
var values = new Dictionary<string, object>()
{
{"Title", metadata.Title},
{"SortOrder", (fileId+99)}, // make new images appear at the end by adding 99 to the fileid so they stay in the upload order
{"IsPrimary", false} // image is not a primary photo by default
};
App.Data.Create(contentTypeName, values, userName, target);
Thanks again for the advice!
I am trying to add PerformanceCounter logging as part of our WebForms application. I am attempting to port an MVC implementation that uses ActionFilters to write request durations per controller action to custom performance counter instances here.
My implementation is to write an HttpModule that logs the OnBeginRequest and OnEndRequest to write to these custom performance counters. However, when I view in PerfMon, I can see the instances of my counters show up in PerfMon, but the values are all empty ("------").
I am initializing the performance counter using the following code:
var counter = new PerformanceCounter {
CategoryName = categoryName,
CounterName = counterName,
InstanceName = instanceName,
ReadOnly = false,
InstanceLifetime = PerformanceCounterInstanceLifetime.Process,
RawValue = 0,
};
Even if I didn't update the value, I would assume that the Last value would be 0, but instead it is '-------'.
The code in the sample associated with the article does work and uses the same syntax. I did notice that the counters written by the MVC attribute have no 'Parent' but the ones created by the WebForms module have a parent specified. I don't know if this has anything to do with it.
I have checked to ensure that no errors are being recorded in the Event log. I would appreciate guidance on why my performance counters are not updating.
Thanks
UPDATE 6/5/2014
I discovered that the issue was a '/' in the instance name, which gets turned into parent/instance which cannot be found once created. Make sure that you clean up your instance name to ensure that no forward slashes exist, or you won't be able to update the values.
I discovered that the issue was a forward slash ('/') in the instance name I was assigning, which gets split into parent/instance which cannot be found once created. Make sure that you clean up your instance name to ensure that no forward slashes exist, or you won't be able to update the performance counter's values.
I'm using WF, I res-hosted the designer, and everything is fine till i need in my custom activities to wait a value when workflow is running, that what i made using BOOKMARK. i tried bookmark in ConsoleApplication and its work.
the following code i used in the main class in the ConsoleApplication:
AutoResetEvent syncEvent = new AutoResetEvent(false);
wa.Completed = delegate(WorkflowApplicationCompletedEventArgs r)
{
syncEvent.Set();
};
wa.Run();
wa.ResumeBookmark("bookmarkName", Console.ReadLine());
syncEvent.WaitOne();
but here in my rehosted project, i need to call many workflows. not only 1. and I can't specify it before runtime.
for this method:
wa.ResumeBookmark("bookmarkName", Console.ReadLine());
1st argument: bookmarks' names, i tried and i found i can name all bookmarks the same name.
About the 2nd argument, how can I pass the value for each workflow, and some workflows have more than 1 bookmark.
I have to read the value from many places, asp.net pages, DB and others.
Im sure there is something like these in WF 4.0, but i didnt find it. can u help me please :)
Thank you.
You need to keep track of each workflow's Id, and record that Id when a bookmark is created. Once you wish to return to the workflow, you can search for the one with the matching Id and then resume your bookmark.
Hello friends I have a list box control in my asp.net project.
I want to know how to get selected index to set currently updated item in database.
Please help me with this. Do i need to perform some data base operation to find the key for currently updated data and then i'll have to set it or there exist some property to deal with this? thanks in adavance
One thing to watch out for, which I have come accross more than once is that if you call your CompanyListBox() method in your Page_Load method, you will lose the selected index unless it is only called on the first page load. To make sure of this, place your call to CompanyListBox() within the following block:
if(!Page.IsPostBack)
{
CompanyListBox();
}
You can access the selected index in your postback by using the following code:
var id = (Int32)listCompany.SelectedItem.Value
Then it is up to you to use that in your data access to update the record in the database. Looks to me that you are using some kind of framework or manager class for your database access. The companyManager should have methods for saving your updated item to the database. Good luck.