create tridion collection class file - tridion

using TDS = Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.TDSDefines;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Xml.Linq;
namespace ConsumerHealth.Web
{
class Common
{
public Common()
{
}
public TridionCollection<Publication> getAllPublicationList()
{
TDSE objTom = new TDSE();
try
{
TridionCollection<Publication> publications = new TridionCollection<Publication>(objTom.GetListPublications(ListColumnFilter.XMLListIDAndTitle));
return publications;
}
catch (Exception ex)
{
throw ex;
}
finally
{
Marshal.ReleaseComObject(objTom);
}
}
}
}
public TridionCollection<Publication> getAllPublicationList(), it shows an error TridionCollection could not found, what am I missing, which dll should I use,
except this all is working fine.

I think Tridion Collection is user defined class, it is not there in any Tridion dll.

That is not a class that is provided by the Content Manager.
A quick Google search shows that a "Tridion Generic .NET Collections" extension for 2009 provided this. My guess is that you'd have to rewrite it for 2011.

You need this assembly provided by your dear friends at SDLTridionWorld.com.
This was written for Tridion 2009 (as was already mentioned before) and as far as I know it might not work on Tridion 2011. Given that it is open source, feel free to change it and adapt it as needed, and report it back to SDL Tridion World so they can update it with a newer version.

Related

Could not load file or assembly

I want to archive a pdf version of a DESADV, therefore I create a Html page via Biztalk Custom XSLT Mapping from the original XML file and render it via Pechkin.Synchronized to a pdf (wrapper for wkhtmltopdf).
This works like a charm in my Solution, but once I try to deploy the solution to the QA System biztalk keeps nagging that it can not find the Pechkin Library.
The Libs are deployed via "gacutil -I", I even build it from source and signed it with our Biztalk signing key and changed the build mode from x86 to "any CPU".
I added all the needed dlls to the Helper Class and deployed them also manually but BizTalk is unable to access the lib. Please help me, I am trying for days without making any progress and it makes me mad.
I even struggle to debug why it can not load the dll.
I am not so fluent in BizTalk and always thought that DLLs in the GAC are accessible to BizTalk...
I also build a console application, that directly references to the DLL in GAC_MSIL and the application renders the html with the exact code, I wrote in the BizTalk Solutions helper class.
even this can not be considered a real answer but it solved the problem somehow.
As already someone mentioned it, the DLL had dependencies onto other libs. This in combination that I was unable to deploy the DLL to the gac and no deeper understanding of the topic I simply chose another lib as this already took to much time. meh.
I choose the shareware https://selectpdf.com/community-edition/, they have a nuget package that simply worked. (i like). The overall render speed is not as good, but in the end it is more important to stay BizTalk compatible with your project I guess.
If someone stumbles upon this:
Create XSL Mapping for your Message XML and map it to some fancy
HTML layout (css supported)
Xtract XML from BizTalk Message in Orchestration
Render PDF with a Helper Solution
My code of the helper class:
You need to add the "Microsoft.XLANGs.BaseTypes" reference from References->Add reference->Assemblies->Extensions for it to work.
using System;
using Microsoft.XLANGs.BaseTypes;
using System.IO;
namespace BIS.CLC.DESADV.Helper
{
public class HtmlHelper
{
public string xTractStringFromMessage(XLANGMessage message)
{
string retVal = string.Empty;
try
{
using (var reader = new StreamReader(message[0].RetrieveAs(typeof(Stream)) as Stream))
{
retVal = reader.ReadToEnd();
}
}
catch (Exception ex)
{
Exception logex = new Exception("BIS.CLC.DESADV.Helper.HtmlHelper.xtractStringFromMsg: string extraction failed" + ex.Message.ToString() + ex.InnerException.ToString());
BIS.Common.Helper.StaticClass.writeEventLog_BizTalk(logex.Message.ToString(), "BisLog");
throw ex;
}
finally
{
message.Dispose();
}
return retVal;
}
public void renderPDFfromHTML(string html, string targetPath)
{
try
{
//do things
SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();
SelectPdf.PdfDocument doc = converter.ConvertHtmlString(html);
doc.Save(new Uri(targetPath).LocalPath.Replace(".XML", ".PDF"));
doc.Close();
}
catch (Exception ex)
{
Exception logex = new Exception("BIS.CLC.DESADV.Helper.HtmlHelper.renderPDFfromHTML: render pdf failed " + ex.Message.ToString() + ex.InnerException.ToString());
BIS.Common.Helper.StaticClass.writeEventLog_BizTalk(logex.Message.ToString(), "BisLog");
throw ex;
}
}
}
}

Is it possible to referencing the specific Xamarin.IOS into Xamarin Form

We are trying to combine the Xamarin code that one is created using Xamarin Form (non XAML) and the other one is purely Xamarin.IOS.
We look at the library of Xamarin.Essential and it looks it doesn't have CoreMotion.CMPedometer (iOS) as we need to count the steps.
Is it possible to run the code within the Xamarin Form (shared) to handle specific OS?
Thanks
Yes, you need to use a Dependency Service.
All of the doco can be found here ... https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction
An example is shown here in relation to device information (which has been cut down for simplicity reasons)
Firstly, you create an interface in your .NET standard/PCL project (if you're not using shared that is, which is likely the case).
using System;
namespace MyApplication.Interfaces
{
public interface IDeviceInfo
{
String GetDeviceModel();
String GetDeviceVersion();
}
}
Then down in your platform specific project, create a Dependency Service that implements that interface and directs the compiler to recognise the class as a Dependency Service.
using System;
using MyApplication.Interfaces;
using UIKit;
[assembly: Xamarin.Forms.Dependency(typeof(MyApplication.iOS.DeviceInfo))]
Namespace MyApplication.iOS
{
public class DeviceInfo : IDeviceInfo
{
UIDevice _device;
Public DeviceInfo()
{
_device = new UIDevice();
}
public string GetDeviceModel()
{
return _device.Model;
}
public string GetDeviceVersion()
{
return _device.SystemVersion;
}
}
}
Now from your .NET standard/PCL project, you can call the dependency service as required.
var deviceModel = DependencyService.Get<IDeviceInfo>().GetDeviceModel();
The above is specific for iOS which means you'd then need to implement the same concept for Android and UWP (or whatever is applicable).
See if that helps you.

MEF Error message - VS2010

Can anybody help me with explaining this error message please:
system.componentmodel.composition.changerejectedexception
The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error.
The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) No exports were found that match the constraint:
ContractName Itok.BusinessLogic.Interfaces.IFolderService
RequiredTypeIdentity Itok.BusinessLogic.Interfaces.IFolderService
Resulting in: Cannot set import 'Itok.Web.Photos.Presenters.DefaultPresenter._folderService (ContractName="Itok.BusinessLogic.Interfaces.IFolderService")' on part 'Itok.Web.Photos.Presenters.DefaultPresenter'.
Element: Itok.Web.Photos.Presenters.DefaultPresenter._folderService (ContractName="Itok.BusinessLogic.Interfaces.IFolderService") --> Itok.Web.Photos.Presenters.DefaultPresenter
Here is the IFolderService.cs:
using System;
using System.Collections.Generic;
using Itok.Entities;
namespace Itok.BusinessLogic.Interfaces
{
public interface IFolderService
{
List<Folder> GetFriendsFolders(Int32 AccountID);
void DeleteFolder(Folder folder);
List<Folder> GetFoldersByAccountID(Int32 AccountID);
Folder GetFolderByID(Int64 FolderID);
Int64 SaveFolder(Folder folder);
}
}
And this is the exporting class definition, FolderService.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Itok.BusinessLogic.Interfaces;
using System.ComponentModel.Composition;
using Itok.DataAccess.Interfaces;
using Itok.Common;
using Itok.DataAccess;
using Itok.Interfaces;
using Itok.Entities;
namespace Itok.BusinessLogic
{
[Export(typeof(IFolderService))]
[Export(typeof(ICache))]
public class FolderService : IFolderService
{
[Import]
private IFriendRepository _friendRepository;
[Import]
private IFolderRepository _folderRepository;
[Import]
private ICache _cacheService;
public FolderService()
{
MEFManager.Compose(this);
}
public List<Folder> GetFriendsFolders(Int32 AccountID)
{
List<Friend> friends = _friendRepository.GetFriendsByAccountID(AccountID);
List<Folder> folders = _folderRepository.GetFriendsFolders(friends);
folders.OrderBy(f => f.CreateDate).Reverse();
return folders;
}
public void DeleteFolder(Folder folder)
{
if (_cacheService.Exists(folder.AccountID.ToString()))
{
_cacheService.Delete(folder.AccountID.ToString());
}
_folderRepository.DeleteFolder(folder);
}
public List<Folder> GetFoldersByAccountID(int AccountID)
{
List<Folder> cachedFolders = _cacheService.Get(AccountID.ToString()) as List<Folder>;
if (cachedFolders != null)
{
return cachedFolders;
}
else
{
cachedFolders = _folderRepository.GetFoldersByAccountID(AccountID);
_cacheService.Set(AccountID.ToString(), cachedFolders);
return cachedFolders;
}
}
public Folder GetFolderByID(Int64 FolderID)
{
return _folderRepository.GetFolderByID(FolderID);
}
public Int64 SaveFolder(Folder folder)
{
return _folderRepository.SaveFolder(folder);
}
}
}
I thank you prior to any help for saving my time.
The error message means that MEF is looking for a class that is exported with the interface IFolderService but there isn't one in the container.
To investigate this, firstly check that there is a class that exports that interface and if there is, then look into whether that class being picked up by the container or not and thirdly, if neither of those resolve the issue, look into whether the class that is exported with the interface IFolderService has some other imports that can't be satisfied.
Finally, I found the Solution for the problem. It has got has nothing to do directly with IFolderService that MEF was pointing to. The App has dependencies on a component (FolderService) in the business logic, which in turn is dependent upon an interface ICache, and an implementation wrapper, Cache.cs. ICache, specified by a contract name Itok.Interfaces.ICache, had been exported FOUR times (on just one Import). This was left unnoticed while I was trying to scale the solution. MEF couldn't tell which Export to use. The real problem is that MEF was pointing to a class two levels upper the chain!
Thanks TomDoesCode for looking at the problem, and I hope this will help others who'll get a similar problem.
A long term solution for this problem would be if you have many Exports that will satisfy an Import, you'll probably have two options:
I) Change the [Import] with [ImportMany]. Then during runtime, decide which import to use for the contract. Ask yourself if just picking up the first available, or using one at a time in random.
II) Use [ImportMany] in conjunction with Metadata in order to decide which Import to use.

Is there some way to save objects to disk in Visual Studio 2012?

I'm hunting for a bug, and it would be really helpful if I could dump the contents of the objects my Locals Window to a file so that I could compare it in Notepad++ with another object record that works correctly. The problem is this: we are not sure if there is a bug in code or a discrepancy in the record.
Is there some way to save a object/variable to disk?
I found this extension, but sadly it is only for VS 2010, and I have 2012.
You could use the ObjectDumper extension. It's also available as a NuGet package.
I'm a bit late to the party but I created a Visual Studio extension called Object Exporter that does exactly what you're looking for. It will export any object in your debugging windows (currently only limited to the locals window) to JSON, XML or CSharp object initialization code.
Here's the extension: Visual Studio Marketplace > Object Explorer
And here's an accompanying blog post: Exporting Objects from the Visual Studio Debugger
The sources of the Export Locals extension made available for download by the author at
http://barad-dur.nl/net/export-locals/ so you should be able to convert it to VS2012 easily.
I work at OzCode. It's a debugging extension for Visual Studio and we've been working on a feature that exports instances as XML, json or C# code for a future version.
You can download the early access preview from Visual Studio's marketplace.
It's a commercial grade solution which enable exporting large amount of data - quickly.
I suggest you try it out - once you install OzCode using Export is just a matter of opening the DataTip window and choosing "Export".
Try opening Immediate Window and type object name. It'll print out the simple properties and their values. It does not handle properties that are objects well, though.
Alternatively, you could use JSON serializer to serialize it and print it out in debug console.
I did a little experimentation with Log4Net and ObjectDumper to dump objects.
Check out my blog post: Logging Complete Objects with Log4Net
Basically you create your own IObjectRenderer, configure it, and then you can simply log.Debug(yourObject)
public class Log4NetObjectLogger : IObjectRenderer
{
public void RenderObject(RendererMap rendererMap, object obj, TextWriter writer)
{
var ex = obj as Exception;
//if its not an exception, dump it. If it's an exception, log extended details.
if (ex == null)
{
//by default log up to 10 levels deep.
ObjectDumper.Write(obj,10,writer);
}
else
{
while (ex != null)
{
RenderException(ex, writer);
ex = ex.InnerException;
}
}
}
private void RenderException(Exception ex, TextWriter writer)
{
writer.WriteLine(string.Format("Type: {0}", ex.GetType().FullName));
writer.WriteLine(string.Format("Message: {0}", ex.Message));
writer.WriteLine(string.Format("Source: {0}", ex.Source));
writer.WriteLine(string.Format("TargetSite: {0}", ex.TargetSite));
RenderExceptionData(ex, writer);
writer.WriteLine(string.Format("StackTrace: {0}", ex.StackTrace));
}
private void RenderExceptionData(Exception ex, TextWriter writer)
{
foreach (DictionaryEntry entry in ex.Data)
{
writer.WriteLine(string.Format("{0}: {1}", entry.Key, entry.Value));
}
}
}

Adding Wcf Service does not allow namespace access

I have created a wcf service called ServiceIRE. I add a service reference to my project by right clicking on th eproject in solution explorer and clicking add Service Reference. I am able to discover my created service and click ok after specifying the namespace ServiceReference1. All files seem to be generated properly.
I then go to the codebehind and try to add a using statment "using ServiceReference1;". This is unrecognized by the file even though the namespace apparently exists in the same project.
Any help would be greatly appreciated.
ServiceIRE.cs
namespace FakeIREServiceLibrary
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ServiceIRE : IServiceIRE
{
public string GetData()
{
Random rnd = new Random();
var randomNumber = rnd.Next(10);
Random rndID = new Random();
var randomNumberID = rnd.Next(10000);
Thread.Sleep(randomNumber*1000);
return string.Format("Thread # {0} returned in {1} nanoseconds", randomNumberID, rnd.Next());
}
}
IServiceIRE.cs
namespace FakeIREServiceLibrary
{
[ServiceContract]
public interface IServiceIRE
{
[OperationContract]
string GetData();
}
}
Page.aspx.cs
using ServiceReference1; //THIS IS NOT RECOGNIZED
Thank you in advance :)
What's the default namespace for your project?
I believe you have to do something like "using DefaultNamespaceForProject.ServiceReference1;"
You can find the default namespace by right clicking your project.. clicking Properties, and then going to the Application tab.
You can find the namespace of the service client generated by Visual Studio by looking at the Reference.cs file within the Service Reference after you show all files for that project. The default is [Project namespace].[Namespace specified].
It's possible that it did NOT generate the file because of an error. That may be the behavior you're seeing.
I would also encourage you to NOT use Add Service Reference, but to instead use a ChannelFactory or build a reusable service client.

Resources