I'm having a problem with saving content programmatically, I click a link on an email message and I'm taken to the site, on this occasion, the CMS is updated. But if I click the link again I get the following error:
Cannot save a non-current version
" at Umbraco.Core.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity)\r\n
at Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)\r\n
at Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase`2.Save(TEntity entity)\r\n
at Umbraco.Core.Services.Implement.ContentService.<>c__DisplayClass57_0.<CommitDocumentChangesInternal>g__SaveDocument|2(IContent c)\r\n
at Umbraco.Core.Services.Implement.ContentService.CommitDocumentChangesInternal(IScope scope, IContent content, ContentSavingEventArgs saveEventArgs,
IReadOnlyCollection`1 allLangs, Int32 userId, Boolean raiseEvents, Boolean branchOne, Boolean branchRoot)\r\n
at Umbraco.Core.Services.Implement.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId, Boolean raiseEvents)\r\n
at Web.Controller.Controllers.ContactController.CoachConfirmed(String id)
The code is below
var contentService = Services.ContentService;
var content = contentService.GetById(new Guid(coachDocType));
content.SetValue("numberOfTrainees", newNumberOfSpaces);
content.SetValue("numberOfTraineesFollowing", newNumberOfSpacesTaken);
contentService.SaveAndPublish(content);
In V7, I use to be able to do ApplicationContext.Current.Services.ContentService.RePublishAll();, but V8 does not seem to have that option anymore
Any help would be appreciated
George
Seems this is a bug in Umbraco, as per https://github.com/umbraco/Umbraco-CMS/issues/2997 and fix will be rolled out in version 8.3.0
Related
I need to create some reports using the websdk pertaining to orders and price quotes.
I tried following the documentation but even the example given in the developer portal is lacking a lot of crucial information.
Specifically, I need to work with these two procedures:
ESH_WWWSHOWORDER3
ESH_WWWSHOWCPROF2
I tried writing some logic arround the sample found on https://prioritysoftware.github.io/api/procedure/#Introduction
const procedure = priority.procStart(PROC_NAME,"R", () => {},customerName, function(procSuccess){
logger.info('Proc start OK, received documentOptions');
logger.info(JSON.stringify(procSuccess));
logger.info('Specifying format...');
resolve(new Promise((resolve, reject) => {
procSuccess.proc.documentOptions(1,1,2,procSuccess => {
logger.info('Received inputFields');
logger.info(JSON.stringify(procSuccess));
procSuccess.proc.inputFields(1,{ORDNUM: ordernum}, procSuccess => {
logger.info('Received url');
logger.info(JSON.stringify(procSuccess));
});
}, procError => {
reject(procError)
})
}));
}, function(procError){
logger.error('Proc start error');
logger.error(procError);
reject(procError);
});
}).catch(err => {
logger.error(err);
})
Where PROC_NAME is WWWSHOWORDER
I am trying to understand what the process is asking of me, but it's not really clear. I tried supplying some values in the order specified by the documentation but I get errors that are not very descriptive to someone who doesn't know the ins and outs of Priority.
The logs look somehting like this
Starting Procedure WWWSHOWORDER
2019-11-26T11:55:31.718Z info: Proc start OK, received documentOptions
2019-11-26T11:55:31.719Z info: {"proc":{"name":"WWWSHOWORDER"},"type":"message","message":"No such Tabula entity"}
2019-11-26T11:55:31.721Z info: Specifying format...
2019-11-26T11:55:32.124Z info: Received inputFields
2019-11-26T11:55:32.125Z info: {"proc":{"name":"WWWSHOWORDER"},"type":"message","message":"Failure to p...
Unfortunately my logs are truncated for some strange reason...
EDIT:
I switched trying to work with ESH_WWWSHOWORDER3, I am getting an inputFields parameter, and I hope what I need to do, is take the iinputFields.input.EditFields object, and populate the value field with the name of the order, I think, unfortunately this results in a 500 error from the server...
{"proc":{"title":"(אישור הזמנה עם מפרט ללקוח (פריו","name":"ESH_WWWSHOWORDER3"},"type":"inputFields","input":{"EditFields":[{"field":1,"helpstring":"","ispassword":0,"mandatory":0,"operator":0,"readonly":0,"title":"Order","type":"text","code":"Str","value":"*","value1":"","maxlength":56,"zoom":"Zoom","format":""}],"Operators":[{"name":"= ","op":0,"title":"equals"},{"name":"< ","op":1,"title":"less than"},{"name":"<=","op":2,"title":"less than or equal to"},{"name":"> ","op":3,"title":"greater than"},{"name":">=","op":4,"title":"greater than or equal to"},{"name":"<>","op":5,"title":"not equal to"},{"name":"- ","op":6,"title":"between"},{"name":"! ","op":7,"title":"ולא"},{"name":"| ","op":8,"title":"או"}],"text":"","title":"Parameter Input"}}
2019-12-02T09:07:10.129Z info: Specifying input...
2019-12-02T09:07:10.550Z error: ###Can't connect to server. HTTP Response: 500, Internal Server Error
details: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2019-12-02T09:07:07.700Z</u:Created><u:Expires>2019-12-02T09:12:07.700Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="he-IL">Object reference not set to an instance
of an object.</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>Object reference not set to an instance of an object.</Message><StackTrace> at WCFService.ProcEditFieldsOKMob(String session, Boolean save, Byte[] xml)
at SyncInvokeProcEditFieldsOKMob(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.NullReferenceException</Type></ExceptionDetail></detail></s:Fault></s:Body></s:Envelope>
Again, documentation does not seem to be very detailed on this topic, the EditFields object itself is not very well described...
I am also not an experienced priority user, so I am not sure where I need to navigate to check out these procedures and what else.
It seems that you are passing "R" as the second parameter, which means that you are calling for a report. Try passing "P" instead.
Also, what is customerName? according to the Web SDK I believe this should be dname: "Internal name of the company in which the procedure is run."
You can tell that WWWSHOWORDER is a Procedure and not a Report by going to System Management -> Generators -> Procedures -> Procedure Generator and querying for it. If you find it in the procedure generator - its a procedure (in this case it is a procedure which generates a report), and you should call it with a "P" parameter.
If you find the entity in Management -> Generators -> Reports-> ReportGenerator than its a plain Report and you should call it with the "R" Parameter.
Grails 2.4.x comes with support for HAL.
Despite some problems with embedded resources (https://jira.grails.org/browse/GRAILS-10954) i'm starting to make it works. However still i am not sure how to deal with pagination links ("prev", "next") as they are shown in the documentation.
Is there any way HalJsonRenderer can help with this point?
What i've done is extend HalJsonCollectionRenderer and overwrite this method:
protected void writeLinkForCurrentPath(RenderContext context, MimeType mimeType, JsonWriter writer) {
final href = linkGenerator.link(uri: context.resourcePath, method: HttpMethod.GET.toString(), absolute: absoluteLinks)
final resourceRef = href
final locale = context.locale
def link = new Link(RELATIONSHIP_SELF, href)
link.title = getResourceTitle(resourceRef, locale)
link.contentType = mimeType ? mimeType.name : null
writeLink(link, locale, writer)
}
Adding links for PREV and NEXT to get rendered when required.
In order to do this we need access querystring params that can be accessed as arguments in the RenderContext object (context.getArguments())
It works quite well and is not too complex.
However if ther is another way i will be happy to know.
I've written a console app using the Umbraco (7.1.4) contentService API to move some nodes and rename them in a site redesign. It all works fine except when I rename the document the 'Link to Document' doesn't change. The code is adapted from https://github.com/sitereactor/umbraco-console-example.
private static void MoveNode(IContentService contentService, int nodeId, int newParentId, string newname)
{
//Get the Root Content
var nodeContent = contentService.GetByIds(nodeId.AsEnumerableOfOne()).First();
nodeContent.Name = newname;
contentService.Move(nodeContent, newParentId);
var status = contentService.SaveAndPublishWithStatus(nodeContent);
Console.WriteLine(status);
}
Status is True and the page name is changed when I look at it in back office but the 'Link to Document' doesn't change. Now if I use
var status = contentService.PublishWithChildrenWithStatus(nodeContent);
Then it works but takes a lot longer (minutes), but if I change the name in back office then it only takes seconds but the links are updated correctly. Is there another way to rename a document without Publishing all the children?
(I've left out a bit of code in the above - sometimes it moves sometimes it just renames, but in either case I have to publish with the children to get it to work.)
It seems this happens because the XML cache file has not been updated.
Have a look here for a few ways of doing it
http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing
Or the quickest is just delete APP_Data\umbraco.config - the XML cache file, probably not recommended for Prod but gets things working quickly in dev.
We are upgrading from jsf 1.2 to jsf 2.
We are using apache myfaces 2.1 and rich faces 4.3.
We are facing very strange issue with <rich:autocomplete>. Below is the xhtml code.
<rich:autocomplete mode="cachedAjax" minChars="2" autocompleteMethod="#{bean.getData}"
var="result" value="#{bean.inputData}">
<h:column>
<h:outputText value="#{result}" />
</h:column>
</rich:autocomplete>
Following is the scenario , when an input is entered in an autocomplete input box , suggetions are shown - that is bean.getData method is called.
Surprisingly , after any of the suggestion is selected , bean.getData method is called again with chosen option value , which I believe is not the correct behaviour
since user has selected an option and not typed any input.
I don't want the bean.getData method to be called again. Is there any alternative ?
Please help.
EDIT 1
Since I am running a db query to get suggestion values , they are different than the actual input value typed to get suggestions. That is if I type "at" , my sugegstions could be "check me" . I understand that once prefix for search is changed , suggestions are evaluated again , but here i am not changing the prefix but selecting the entire suggestion value.
EDIT 2
Providing the context the issue occured with.
When autoCompleted method is called , it populates a hashMap with all the suggestions with CustomUserObject as the value.
Below is the code for this :
public List<String> getData(FacesContext context, UIComponent component, String input) {
Map<String, CustomUserObject> userMap = new HashMap<String, CustomUserObject>();
//get users from db
List<CustomUserObject> users = bean.fetchUserList(input);
//put users in map
for (CustomUserObject user : users) {
userMap.put(user.id, user) ;
}
List<String> userList = new ArrayList<String>();
//convert the list to List<String>
if(userList != null && !userList.isEmpty()){
//convert the List<CustomUserObject> to List<String>
}
return userList;
}
Now because of the issue mentioned in the question , getData is called again and corrupts userMap.
This map is used to retrieve correct CustomUserObject by comparing it with selected Suggestion like below :
if(userMap != null && !userMap.isEmpty()){
for(CustomUserObject user : userMap.values()){
if(selectedSuggestion != null && selectedSuggestion.equals(user.name)){
//match is found
//set variables to update ui at re-render
}
//no match found
//set variables to update ui at re-render
}
}
EDIT 3
In addition to above issues , it seems that there is no "nothing label" attribute for rich:autocomplete which was present for rich:suggestionBox which comes into picture when there is no result found.
This issue alongwith above issue is really making a difficult job to get this component working same as rich:suggestionBox
I have recently created my first RDLC report using Visual Studio 2010 to my MVC application.
I used Report Wizard to create Report1.rdlc and I run the following controller code to render output to a PDF.
My data source when the report runs references Site Object in my Model. Everything runs fine but 2 of the 4 columns in the output are rendered as #Error
Both columns have data in them for every record, there are no nulls
The only thing that makes the 2 #Error columns different from the ones that render is that they are a level down the model. i.e. of the 4 columns :
1st field SiteDescription renders OK
2nd field SiteOperator renders value as #Error for each row
3rd field SiteStatus renders value as #Error for each row
4th field CapacityMW renders OK
NB: SiteOperator is Site.SiteOperator.Operator. Similar for 3rd field. The 1st and forth are fields in the Site table (i.e. top level of model in this case)
QUESTION: Is there something else developer has to do to allow RDLC to work with existing objects from the Model? i.e. I noticed the report wizard creates a Report1.rdlc.xml file, perhaps this has to be modified, I have ran out of ideas on this one. Any comments greatly appreciated
Here is my controller code :
private void RenderReport(string ReportPath, object Model)
{
var localReport = new LocalReport { ReportPath = ReportPath };
var reportDataSource = new ReportDataSource("DataSet1", Model);
localReport.DataSources.Add(reportDataSource);
var reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
//The DeviceInfo settings should be changed based on the reportType
//http://msdn2.microsoft.com/en-us/library/ms155397.aspx
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>1in</MarginLeft>" +
" <MarginRight>1in</MarginRight>" +
" <MarginBottom>0.5in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
//Render the report
renderedBytes = localReport.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
//Clear the response stream and write the bytes to the outputstream
//Set content-disposition to "attachment" so that user is prompted to take an action
//on the file (open or save)
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
Response.BinaryWrite(renderedBytes);
Response.End();
}
The first thing to look at when receiving "#Error" responses in RDLC is the Output/Debug tab in Visual Studio. This should have a specific error message for each error the reporting engine received while rendering the report. While not always the most intuitive messages in the world, they should at least point you in the right direction.
I use RDLCs in MVC with models that originated with a C# class generated by Entity Framework (using POCO object template).
Now, my class is a relatively "flat" class with just properties (nullables, numerics, strings, DateTimes, etc.) and no collections of other objects so that might make a difference.
I created my RDLCs without the use of the wizard, but found that to do so with the designer in MVC I had to add a .aspx to the project for the designer to work. I also just have public static methods in a mock class that return the IEnumerables of the types I use for consumption by the report data source wizards and such.
I also use EF to populate my data so it definitely doesn't need stored procedures:
var data = dal.PrintFriendlies.Where( p => p.ApplicationId == applicationId );
viewer.LocalReport.DataSources.Add( new ReportDataSource( "DataSourceName" , data ) );
I also am returning the PDF bytes so your code looks very close to what I use (I use both datasources and parameters, plus subreports).
You don't describe what your class structure is like, but I think it has issues with hierarchichal structures so you may need to flatten it to something the report writer prefers.
I have managed to get the reports working well. I switched to using a stored procedure and calling it from the controller. I placed the RDLC file in the view and render it directly to PDF. Really happy with this since I never had to touch routing in the MVC app and I never had to ADD any ASP.NET pages with controls or anything like that.Very neat and clean solution.