/// <summary> /// This function is called when the IlcCore Server request informations for an InfoPoint. /// Step 2 /// To get Informations into your apps you need insert the appropiate BusinessObject into the dataInterface /// </summary> /// <param name="context"></param> /// <param name="infoPoint"></param> /// <param name="dataInterface"></param> public void CollectInformations(InformationProcess context, InfoPoint infoPoint, IInformationDataInterface dataInterface) { var company = infoPoint.Value as Company; if (company == null) return; dataInterface.Insert(company); dataInterface.Flush(); if (dataInterface.MustCollect<ContactPerson>()) { var contactsLoader = new ContactsLoader(); var contacts = contactsLoader.LoadContactsByCompany(company); dataInterface.Insert(contacts); dataInterface.Flush(); } // Step 3 // we Add the ProductsLoader and the Ilc.BusinessObjects.AdventureWorks Library // to showcase the Detail-Loading procedure // Details-Loading is deferred by creating and setting an DetailsLink for the InformationObject if (dataInterface.MustCollect<BikeProduct>()) { var productsLoader = new ProductsLoader(); var products = productsLoader.LoadProductByCompany(company); foreach (var product in products) { var detailsLink = new List<DetailsLink>(); detailsLink.Add(dataInterface.CreateDetailsLink(Constants.ProductPhotoDetailslink, product.Id)); dataInterface.Insert(product, null, detailsLink); } dataInterface.Flush(); } }
/// <summary> /// This function is called when the Harvester is configured to Expand objects of a certain type /// Step 4 /// Now we are expanding Person objects with a picture url, that we retrive from a different PictureService /// </summary> /// <param name="context"></param> /// <param name="informationIds"></param> /// <param name="dataInterface"></param> public void ExpandInformations(InformationProcess context, List<string> informationIds, IInformationDataInterface dataInterface) { var pictures = new PictureService(); // Get the stored credentials, so we can authenticate on the PictureService var identity = base.GetCredentials(context.Session); if (identity != null) { var authResult = pictures.Authenticate(identity.Username, identity.GetPassword()); if (authResult == false) { ResetCredentials(context.Session, identity.Username); Ilc.NotificationManager.NotificationHandler.Instance.FireApiLoginExpired(context.Session.Tenant, identity.UserId, AppName, AppName); } } else Ilc.NotificationManager.NotificationHandler.Instance.FireApiLoginExpired(context.Session.Tenant, identity.UserId, AppName, AppName); // Iterate throu the informations and check if it is a Person object, // that we can try to expand with the PictureUrl // and signaling the server if we updated an object or not. for (int i = 0; i < informationIds.Count; i++) { var informationId = informationIds[i]; var item = dataInterface.GetExisting(informationId); var person = item as Person; if (person != null) { var url = pictures.Get(person); person.PictureUrl = url; if(!string.IsNullOrEmpty(url)) dataInterface.Update(informationId, item); else dataInterface.NoUpdate(informationId); } // Flush the data every 25 items so long running iterations will get there updates in between. // A final flush is automatically invoked so you dont need to take care of that. if (i % 25 == 0) dataInterface.Flush(); } }
/// <summary> /// This function is called when the Harvester is configured to Expand objects of a certain type /// Step 4 /// Now we are expanding Person objects with a picture url, that we retrive from a different PictureService /// </summary> /// <param name="context"></param> /// <param name="informationIds"></param> /// <param name="dataInterface"></param> public void ExpandInformations(InformationProcess context, List <string> informationIds, IInformationDataInterface dataInterface) { var pictures = new PictureService(); // Get the stored credentials, so we can authenticate on the PictureService var identity = base.GetCredentials(context.Session); if (identity != null) { var authResult = pictures.Authenticate(identity.Username, identity.GetPassword()); if (authResult == false) { ResetCredentials(context.Session, identity.Username); Ilc.NotificationManager.NotificationHandler.Instance.FireApiLoginExpired(context.Session.Tenant, identity.UserId, AppName, AppName); } } else { Ilc.NotificationManager.NotificationHandler.Instance.FireApiLoginExpired(context.Session.Tenant, identity.UserId, AppName, AppName); } // Iterate throu the informations and check if it is a Person object, // that we can try to expand with the PictureUrl // and signaling the server if we updated an object or not. for (int i = 0; i < informationIds.Count; i++) { var informationId = informationIds[i]; var item = dataInterface.GetExisting(informationId); var person = item as Person; if (person != null) { var url = pictures.Get(person); person.PictureUrl = url; if (!string.IsNullOrEmpty(url)) { dataInterface.Update(informationId, item); } else { dataInterface.NoUpdate(informationId); } } // Flush the data every 25 items so long running iterations will get there updates in between. // A final flush is automatically invoked so you dont need to take care of that. if (i % 25 == 0) { dataInterface.Flush(); } } }
public void CollectInformations(InformationProcess context, InfoPoint infoPoint, IInformationDataInterface dataInterface) { }
/// <summary> /// This Harvester does not Expand Informations. You can leave this empty /// </summary> public void ExpandInformations(InformationProcess context, List<string> informationIds, IInformationDataInterface dataInterface) { }
/// <summary> /// This function is called when the IlcCore Server request informations for an InfoPoint. /// Step 2 /// To get Informations into your apps you need insert the appropiate BusinessObject into the dataInterface /// </summary> /// <param name="context"></param> /// <param name="infoPoint"></param> /// <param name="dataInterface"></param> public void CollectInformations(InformationProcess context, InfoPoint infoPoint, IInformationDataInterface dataInterface) { var company = infoPoint.Value as Company; if (company == null) { return; } dataInterface.Insert(company); dataInterface.Flush(); if (dataInterface.MustCollect <ContactPerson>()) { var contactsLoader = new ContactsLoader(); var contacts = contactsLoader.LoadContactsByCompany(company); dataInterface.Insert(contacts); dataInterface.Flush(); } // Step 3 // we Add the ProductsLoader and the Ilc.BusinessObjects.AdventureWorks Library // to showcase the Detail-Loading procedure // Details-Loading is deferred by creating and setting an DetailsLink for the InformationObject if (dataInterface.MustCollect <BikeProduct>()) { var productsLoader = new ProductsLoader(); var products = productsLoader.LoadProductByCompany(company); foreach (var product in products) { var detailsLink = new List <DetailsLink>(); detailsLink.Add(dataInterface.CreateDetailsLink(Constants.ProductPhotoDetailslink, product.Id)); dataInterface.Insert(product, null, detailsLink); } dataInterface.Flush(); } }
/// <summary> /// This Harvester does not Expand Informations. You can leave this empty /// </summary> public void ExpandInformations(InformationProcess context, List <string> informationIds, IInformationDataInterface dataInterface) { }