Blog posts by Shoma2016-01-29T15:47:29.0000000Z/blogs/shoma/Optimizely WorldPickles : Living documentation generator/blogs/shoma/dates/2016/1/pickles--living-documentation-generator/2016-01-29T15:47:29.0000000Z<p>Recently there came a requirement from the business,they wanted to know a high level view of the specification/requirements of an Project. A colleague suggested that feature files written in gherkin statements where ideal for this purpose. </p> <p>Therefore we had to look for a tool that would translate the feature files to a more business-friendly format (word,pdf,html), so that the business could have a look at it at their convenience without having to reach out developers. </p> <p>There were 2 main tools that suited this requirement namely:</p> <ol> <li><a href="http://www.relishapp.com/">Relish</a></li> <li><a href="http://www.picklesdoc.com/">Pickles</a></li></ol> <p>Relish is based on Ruby plus it comes with a <a href="http://www.relishapp.com/plans-and-pricing">subscription fee</a>. They do have a Free plan, but all your projects will be public!</p> <p>Pickles is open-source and easily installed via nuget. The documentation can be found <a href="http://docs.picklesdoc.com/en/latest/">here.</a> Pickles can be run via commandline, GUI,PowerShell or MSBuild</p> <h2>Sample Example using CommandLine</h2> <p>Pickle supports Html, Dhtml,word,JSON and Excel formats.</p> <p>Install Pickles in your project:</p> <p>using nuget console manager : Install-Package Pickles.CommandLine</p> <p>Open Command Prompt in Administrator mode – > Navigate to your Specs project and execute the below command</p> <p><strong>..\packages\Pickles.CommandLine.2.3.0\tools\pickles.exe --feature-directory=C:\BitBucket\TestProj.Specs --output-directory=c:\my-features-output --documentation-format=dhtml</strong></p> <p>where --feature-directory = is the path to your test project</p> <p>--output-directory = path to your output file</p> <p>--documentation-format = format of the output (optional) . The default output is html</p> <p>If you want the output in word format then set --documentation-format=word</p> <h2>Plus</h2> <p>The above command can be copied to a .bat-file.</p> <p>Pickles can also be integrated into automated build or continuous integration tool like <a href="http://docs.picklesdoc.com/en/latest/HowToGeneratePicklesDocOnTeamCity/">TeamCity</a>.</p>EPiServer Integration with DotMailer/blogs/shoma/dates/2015/11/episerver-integration-with-dotmailer/2015-11-11T14:27:29.0000000Z<h1>EPiServer Integration with DotMailer</h1> <p>Hello,</p> <p>This is very first attempt to write a blogpost but definitely not the last!</p> <p>This blog intends to show DotMailer could be integrated into EPiserver using both Dotmailer’s SDK.</p> <p>More documentation regarding DotMailer can be found <a href="https://developer.dotmailer.com/">here</a> and some sample code can be found at <a href="https://github.com/dotmailer/community-supported-projects">gitHub</a> .</p> <p> </p> <h2>Pre-requisites</h2> <p>1. Create a Dotmailer account if you do not have one.</p> <p>2. Create a API user account. Information on how to get a API user key can be found <a href="https://www.dotmailer.com/resources/dev-tools-guides/getting-started-with-the-dotmailer-api/">here</a>.</p> <p>3. Comma separated CSV file </p> <p> </p> <h2>Integrating dotMailer Using SDK</h2> <p>Download the SDK from <a href="https://www.dotmailer.com/media/1104/dotmailersdkv150.zip">here</a> or using the nuget Package manager console command : <em>Install-Package dotMailerSdk</em></p> <h2>Let’s get started : Using SDK</h2> <p>1. Create a static class helper class, i have called it DotMailerHelperClass</p> <p>2. We first need to create a DmService using DmServiceFactory.Create()</p> <p><font color="#9b00d3">private static DmService _dmFactoryService;<br /> public static DmService DmFactoryService<br /> {<br /> get { return _dmFactoryService ?? (_dmFactoryService = SetDmFactoryService()); }<br /> set { _dmFactoryService = value; }<br /> } </font></p> <p><font color="#9b00d3"> private static DmService SetDmFactoryService()<br /> {<br /> DmService dmFactoryService = DmServiceFactory.Create(UserName, Password);<br /> return dmFactoryService;<br /> } </font></p> <p>3. Once we have a DmService, we need to either import contacts to an existing address book or create a new address book to your account. This can be achieved using the DmFactoryService.AddressBookFactory class.</p> <p><font color="#9b00d3">public static DmAddressBook UpdateExistingOrCreateNewAddressBook_UsingSDK(string addressBookName)<br /> { <br /> var addressBookList = DmFactoryService.AddressBookFactory.ListAddressBooks();<br /> var addressBook = addressBookList.FirstOrDefault(x => x.Name == addressBookName);</font></p> <p><font color="#9b00d3"> if (addressBook != null)<br /> {<br /> return addressBook;<br /> }<br /> return DmFactoryService.AddressBookFactory.CreateAddressBook(addressBookName); <br /> }</font></p> <p>4. Before we import contacts, we need to convert the csv file into an IEnumeble<IDmContact> format. The code below does the trick, just pass the path of the csv file:</p> <p><font color="#9b00d3">public static IList<IDmContact> GetContactsForImport_ForSDK(string path)<br /> { <br /> var reader = new StreamReader(File.OpenRead(path));<br /> string format = "dd MMM yyyy hh:mm";<br /> IList<IDmContact> dmContacts = new List<IDmContact>(); <br /> var readLine = reader.ReadLine();<br /> if (readLine != null)<br /> {<br /> var headers = readLine.Split(',');<br /> while (!reader.EndOfStream)<br /> {<br /> var line = reader.ReadLine();<br /> if (line != null)<br /> {<br /> var values = line.Split(',');<br /> DmContact dmContact = DmFactoryService.ContactFactory.CreateNewDmContact(values[0]);<br /> for (int i = 1; i < headers.Count(); i++)<br /> {<br /> if (headers[i] == "DATE_FORMAT")<br /> {<br /> DateTime dateTime= values[i].ToDateTime();<br /> dmContact[headers[i]] = dateTime.ToString(format);<br /> }<br /> else<br /> dmContact[headers[i]] = values[i];<br /> } <br /> dmContacts.Add(dmContact);<br /> }<br /> }<br /> }<br /> <br /> return dmContacts;<br /> } </font></p> <p><font color="#000000">A couple of things are to be noted here:</font></p> <ul> <li>If the csv file contains Date in string format, then this has to be converted into a proper date format. <li>The code also takes care of any custom data fields. <li>Custom fields for a DmContact can be accessed using properties.</li></li></li></ul> <blockquote> <p>Ex : dmContact[“Country”]</p></blockquote> <p>5. Import the IEnumerable<IDmContact> into the address book.</p> <p><font color="#9b00d3">public static ImportContactResult ImportContacts_SDK(IEnumerable<IDmContact> contacts, int addressBookId)<br /> { <br /> try<br /> {<br /> ImportContactOptions importContactOptions = new ImportContactOptions();<br /> var importContactResult =<br /> DmFactoryService.AddressBookFactory.ImportContactsIntoAddressBook(importContactOptions,<br /> addressBookId, contacts)<br /> .GetImportWatcher().Watch(); <br /> importContactResult.GetImportWatcher().Dispose();<br /> return importContactResult;<br /> }<br /> catch (Exception exception)<br /> {<br /> Log.ErrorFormat("Exception in Importing contacts {0}",exception.Message); <br /> }<br /> return null;<br /> } </font></p> <p><font color="#000000">A couple of things are to be noted here:</font></p> <ul> <li>.GetImportWatcher().Watch(); waits for the import to complete. GetImportWatcher() is a overloaded method where Timespan can also be specified to wait a particular duration of time. <li>It’s the implementers responsibility to dispose the watch. <li>The ImportContactResult has information about the import status and importContactResult.ImportReport can be used to generate the report.</li></li></li></ul> <p> </p> <h2>Hope that helps!</h2> <p>Thanks</p>