How can I override DocumentCreatedWhen and DocumentModifiedWhen while using Kentico Import Toolkit? - kentico

I've created a number of .iprofile files to import pages from a legacy WebForms site into the "Content-Only" versions on a new MVC site. This works great except that it ignores the mapping for DocumentCreatedWhen and DocumentModifiedWhen. Each time the import occurs without errors but the Created and Modified dates in the MVC site are the date/time of the import, not the original date and time.
I've tried using the GUI version of the Import Toolkit and the command-line version, I've verified that there are mapping elements in the .iprofile files for DocumentCreatedWhen and DocumentModifiedWhen, like so:
<mapping target="documentcreatedwhen" source="DocumentCreatedWhen" />
<mapping target="documentmodifiedwhen" source="DocumentModifiedWhen" />
Does this work with the Kentico Import Toolkit or will I need to use a different mechanism?
Edited title to use correct field names...

Unfortunately, both values are set when an object is created and/or modified and both these properties have internal setters so basically from your perspective are just read-only. Onehack around it would be to change system clock as they rely on DateTime.Now; and another would be to actually convince framework with your own implementation of DateTime
Last and easiest approach would be to import data and than run SQL to adjust modified fields directly.

Related

Tabulator - Download and re-use changes

I am new to Tabulator and started building my first project. While usage and setup is very intuitive and nicely built I struggle with one concept. I want to keep changes and entries I made to the table and load them again when re-opening the page.
My first thought was to download all entries as csv or xls and then import either from an array/JSON or from an HTML table. Is this the preferred way or is there another method I can use?
Thanks!
Note: I am using version 4.1
Tabulator doesn't include what you are looking for. However, you can use Tabulator to retrieve the table's values. As for saving and restoring the edited data, you may want to use your browser's localStorage: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

How to directly export a collection of DTOs to CSV, Excel or PDF?

I have a List<MyDto> which I want to export with PrimeFaces. I tried with <p:dataExporter>, but it seems that it only uses UI <p:dataTable> content.
How can I directly export a list of DTOs to CSV, Excel or PDF?
You need a library to handle this. Primefaces doesn't inherently know how to display your data (it analyzes the columns and then exports based on that) so you need to give it some hints. The short answer is that you can easily create a table either programatically via reflection on the DTO and binding it to the page or by creating a simple data-table and set it to a style of "display:none" and then using the exporter.
Alternatively you can look at a reporting suite like JasperReports that handles "printing" to the above formats, but again, you will need to do something to interpret it. If you don't care about performance JSON-Lib has a very nice "toXML" method that will rip down a DTO to xml which could then be easily exported to any of the formats you choose.
Basically, you're looking at ~ 1 hour of work if it is a complex set of DTOs or 10 minutes if it isn't--as long as bandwidth isn't an issue this should be completely painless.

Expression Engine - import member data

I am finishing a site for a client and they want to import their customer database. Is there an effective way to import such data? I have used AJW Datagrab for importing data, but this is different.
Any suggestions?
I noticed that EE has an xml import template is there a handy way to convert a spreadsheet to an xml file that would fit that format?
Thanks.
ExpressionEngine 1.x used to come bundled with three native first-party Import Utilities:
pMachine Pro Import Utility
Movable Type Import Utility
Member Import Utility
With the rewrite of ExpressionEngine 2.x, only the following made the conversion:
Member Import Utility
You can access it within the Control Panel at: CP Home > Tools > Utilities > Import Utilities.
The first-party Member Import Utility allows you to import members from other systems into ExpressionEngine, in the following two formats:
Import from XML File - Allows you to import members from an XML file
in ExpressionEngine's Member XML format.
Convert Delimited Text to XML - Allows you to create an
ExpressionEngine Member XML file from another application's delimited
text file.
If you're looking to import more than just Members into your ExpressionEngine database, DataGrab by Andrew Weaver of Brand New Box in the UK is your best choice.
DataGrab allows you to import data from RSS/ATOM feeds, CSV files and XML files. Other datatypes can be added.
Among DataGrab's many uses are:
Importing initial content into ExpressionEngine from other CMS's (WordPress, Tumblr, etc.)
Aggregating data from your various websites from around the
internet, such as Twitter or Flickr (using RSS feeds or APIs)
Keeping product stock or price details synchronised with an external
system
You can also harness EE's powerful, built-in functionality (flexible templating, search, archives), DataGrab makes your data easily available as a channel entry.
The developer of DataGrab provides a walk thru on using CSV imports with DataGrab, perfect for use with Excel documents or a Google Docs Spreadsheets.
Surprisingly, the once-popular Solspace Importer still hasn't made the conversion to EE2.
A bit late, but for the record Solspace Importer is now ee2.x compatible. The big advantage over DataGrab is Importer's ability to call with JSON.

How can I perform Search&Replace on an XML file after WIX installation?

After installing my files using WIX 3.5 I would like to changes some values in one of my xml files.
Currently there are multiple entries like this:
<endpoint address="net.tcp://localhost/XYZ" .../>
I would like to change the localhost to the real servername wich is available due to a property. How can I perform this replacement on each entry inside this xml file? Is there a way to do this without writing an own CA?
Thanks in advance!
XmlConfig and/or XmlFile elements are your friends here.
UPDATE: Well, according to the comments below, it turns out that only part of the attribute (or element) value should be changed. This seems not to be supported by either of two referenced elements.
I would take one of the two approaches then:
Use third-party "read XML" actions, like this one
It's better than creating your own because you can rely on deeper testing in this case
Teach your build script to control the string pattern
Let's say you put `net.tcp://localhost/XYZ` to build file and your code is pointed out to take this value as a string pattern to use at install time. For instance, keep the string pattern as a Property in your MSI package. When it changes, e.g. to `net.tcp://localhost/ABC` you'll have to change nothing in your action. In this case from a XMLFile perspective you always know your FROM and TO attribute values.
If your XML configuration file is not large, you can load the file into memory and perform replace using JScript.
var s = "<endpoint address=\"net.tcp://localhost/XYZ\" .../>";
var re = /"net.tcp:\/\/localhost\//g;
var r = s.replace(re, "\"http://newhost.com/");
Here s is your complete XML file, re is the regular expression, and r would contain the result or replace.
You can read and write to public properties of Windows Installer using JScript. Yet there's still one problem: you have to read your XML file and to write it back to disk. To do it, you can use Win32_ReadFile and Win32_WriteFile custom actions from the AppSecInc. MSI Extensions library referenced by Yan in his answer.
However, it could be easier to write a complete Custom Action which will load your XML configuration file, do the replace, and write the file back to disk. To do it you can use XSLT and JScript (see an example code).
InstallShield has a built-in data driven custom action called Text Search. It basically allows for RegEx style replacements like what you are describing.
WiX doesn't have this functionality but you could write a custom action ( say using C#/DTF ) to do it for you.
There nothing in Wix, you can do to change something in a file without using a custom action. If you don't want to use CA, you can consider saving the settings in some other place e.g. User's registry and always read that setting from there

Integrating XMLRPC/Web Services with Core Data

I'm doing design for a project and nothing's been implemented - so I'm still going through the thought process to determine if Core Data is viable for the project.
Here's my query -
I want to create a managed object model using Core Data to represent some server side objects e.g Folder, File, etc....
All the objects (Folder, File etc..) are accessible via XMLRPC APIs that return some well formed XML.
For example, there may be an API called getFolders that can return the following -
<xml>
<folders>
<folder id=1>
<name>Test 123</name>
<files>
<file id=100>
<name>hello.txt</name>
<path>./hello.txt</path>
</file>
...
</files>
</folder>
...
</folders>
Similarly there can be an updateFolders API that operates on an existing folder item and for simplicity lets say it just updates the folder name. The request for it would post something like the following -
<xml>
<method name="updateFolder">
<folder_id="1">
<params>
<param name="folder_name" value="Test"/>
</params>
</method>
I'm trying to figure out -
1. How can I represent folder as a managed object i.e., how do I initialize it from the above XML
2. Once initialized, how can I handle an update to it using the updateFolder API shown above
It seems like the NSPersistentStore such as XMLStoreType point directly to actual XML files that hold the final data. In my case, the XML is simply whats returned from an XMLRPC call and the actual data is stored on a server side DB. Therefore, since the stores are not direct representations of the objects (or where the objects are stored), I was wondering if I should create a custom NSAtomicStore and handle load and save for initialization and update respectively. Here's a link on doing this for a NSAtomicStore -
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/AtomicStore_Concepts/Articles/asLoading.html#//apple_ref/doc/uid/TP40005298
Please let me know if this makes sense or if there's a better way to handle this.
Have you read through:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
Also check out TBXML:
TBXML is a light-weight XML document parser written in Objective-C designed for use on Apple iPad, iPhone & iPod Touch devices. TBXML aims to provide the fastest possible XML parsing whilst utilising the fewest resources. This requirement for absolute efficiency is achieved at the expense of XML validation and modification. It is not possible to modify and generate valid XML from a TBXML object and no validation is performed whatsoever whilst importing and parsing an XML document.
There is no simple way to do what you ask and Core Data won't make it any easier for you.
I assume you've read the docs - you need to determine a suitable model to represent your remote data locally, manage the interactions between the remote end and the local end, and synchronize the state between the ends. Deciding on and coordinating your synchronization process is the hardest part. I'm not sure whether there is any third-party framework that can automate this process.

Resources