Example #1
0
        /// <summary>
        /// By default, we are configured to use MEF
        /// </summary>
        protected override void Configure()
        {
            //1. First init catalog for start up.
            var catalog = new AggregateCatalog(
                AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType <ComposablePartCatalog>()
                );

            catalog.Catalogs.Add(CreateDirectoryCatalog(Environment.CurrentDirectory + "/Presentation"));
            catalog.Catalogs.Add(CreateDirectoryCatalog(Environment.CurrentDirectory + "/Workbench"));

            container = new CompositionContainer(catalog);
            var batch = new CompositionBatch();

            //2. Inject export values to IoC container and resolve their dependencies if needed.
            var windowManager       = new YoZuoWindowManager();
            var presentationService = new PresentationService();
            var resourceService     = new ResourceService();

            batch.AddExportedValue <IEventAggregator>(new EventAggregator());
            batch.AddExportedValue <IResourceService>(resourceService);
            batch.AddExportedValue <IWindowManager>(windowManager);
            batch.AddExportedValue <IYoZuoWindowManager>(windowManager);
            batch.AddExportedValue <IPresentationService>(presentationService);
            batch.AddExportedValue(container);
            batch.AddExportedValue(catalog);

            container.Compose(batch);
            container.ComposeParts(resourceService);
            container.ComposeParts(presentationService);

            //3. Init the startup environment : Presentation -> Ribbon ; Language -> Chinese
            presentationService.ChangePresentation("PART_OPTION_PRESENTATION_RIBBON");
            resourceService.ChangeLanguage("zh-cn");
        }
        protected async Task ReloadSectionsAsync(IEnumerable <string> reloadEntityIds)
        {
            if (UIResolver == null || Sections == null)
            {
                return;
            }

            var newSections = await Sections.ToListAsync(async x =>
            {
                if (reloadEntityIds.Contains(x.editContext.Entity.Id))
                {
                    var reloadedEditContext = await PresentationService.GetEntityAsync(new GetEntityRequestModel
                    {
                        CollectionAlias = x.editContext.CollectionAlias,
                        Id         = x.editContext.Entity.Id,
                        ParentPath = x.editContext.Parent?.GetParentPath(),
                        UsageType  = x.editContext.UsageType
                    });

                    return(reloadedEditContext, await UIResolver.GetSectionsForEditContextAsync(reloadedEditContext));
                }
                else
                {
                    return(x);
                }
            });

            Sections = newSections;
        }
Example #3
0
        public override void FillField(IDataMap map, ref Item newItem, object importRow)
        {
            var importValue = string.Join(Delimiter, map.GetFieldValues(ExistingDataNames, importRow));

            if (string.IsNullOrWhiteSpace(Component) || !ID.IsID(Component))
            {
                var path = importRow is Item ? ((Item)importRow).Paths.FullPath : "N/A";
                Logger.Log($"The Component value is empty or is not an id", path, LogType.FieldToComponent, "Component", Component);

                return;
            }

            var deviceItem = PresentationService.FindDeviceDefinition(newItem, Device);
            var dsName     = DatasourcePath.Contains("/")
                ? DatasourcePath.Substring(DatasourcePath.LastIndexOf("/") + 1)
                : DatasourcePath;

            if (!OverwriteExisting)
            {
                var datasource = PresentationService.CreateDatasource(map, newItem, deviceItem, dsName, DatasourceFolder, DatasourcePath, Component, OverwriteExisting);
                if (datasource == null)
                {
                    return;
                }

                var isSet = SetField(map, datasource, importRow, importValue);
                if (!isSet)
                {
                    datasource.Delete();
                }
                else
                {
                    PresentationService.AddComponent(newItem, datasource, Placeholder, Component, Device, Parameters, IsSXA);
                }
            }
            else
            {
                var rendering = PresentationService.FindRendering(deviceItem, Placeholder, Component);
                if (rendering == null)
                {
                    Logger.Log($"There was no rendering matching device:{Device} - placeholder:{Placeholder} - component:{Component}", newItem.Paths.FullPath, LogType.MultilistToComponent, "device xml", deviceItem.ToXml());
                    return;
                }

                var datasource = PresentationService.FindDatasourceByName(map, newItem, rendering, dsName);
                if (datasource == null)
                {
                    Logger.Log($"There was no datasource found matching name:{dsName}", newItem.Paths.FullPath, LogType.MultilistToComponent, "rendering xml", rendering.ToXml());
                    return;
                }

                var isSet = SetField(map, datasource, importRow, importValue);
                if (!isSet)
                {
                    datasource.Delete();
                    PresentationService.RemoveComponent(newItem, rendering, Device);
                }
            }
        }
Example #4
0
        public TouTvChannel(ILogManager logManager, IHttpClient httpClient, IJsonSerializer jsonSerializer)
        {
            _logger = logManager.GetLogger(GetType().Name);

            var presentationService      = new PresentationService(httpClient, jsonSerializer);
            var mediaValidationV1Service = new MediaValidationV1Service(httpClient, jsonSerializer);

            _touTvProvider = new TouTvProvider(presentationService, mediaValidationV1Service);
        }
Example #5
0
        public bool CheckKMPresentationService(string docId, ref int size, ref string errorMsg)
        {
            size = -1;
            WSDocument wsDocument = null;

            try
            {
                HP.Csn.Business.KM.Services.PresentationService.WSUserInfo wsUserInfo = new HP.Csn.Business.KM.Services.PresentationService.WSUserInfo();
                wsUserInfo.userId   = base.userId;
                wsUserInfo.portalId = base.portalId;

                WSCPRequest wsCPRequest = new WSCPRequest();
                wsCPRequest.docId  = docId;
                wsCPRequest.locale = DEFAULT_LANGUAGECODE;

                PresentationService presentationService = new PresentationService();
                presentationService.SetConnectionInfo(base.presentationUrl, base.userId, base.userPassword, base.timeOut);

                wsDocument = presentationService.retrieveDocument(wsUserInfo, wsCPRequest);
            }
            catch (SoapException ex)
            {
                errorMsg = "Error While Retrieving Document. ERROR : (" + ex.Message + ")";
                return(false);
            }
            catch (WebException ex)
            {
                errorMsg = "Error Connecting To Webservices. ERROR : (" + ex.Message + ")";
                return(false);
            }
            catch (Exception ex)
            {
                errorMsg = "Unexpected Error While Accessing Webservices. ERROR : (" + ex.Message + ")";
                return(false);
            }


            if (wsDocument == null)
            {
                errorMsg = "Unable To Retrieve Document " + docId;
            }

            if (wsDocument.payload.Length == 0)
            {
                size     = 0;
                errorMsg = "Error While Retrieving Document. Payload Is Empty";
            }
            else
            {
                size = wsDocument.payload.Length;
            }

            return(true);
        }
Example #6
0
        private bool HasDuplicates()
        {
            IPresentationService presentationService = new PresentationService();
            bool hasDuplicates = presentationService.ApplicationIsRunning(AppMutex);

            if (hasDuplicates)
            {
                MessageBox.Show(NavigationAssistant.Properties.Resources.ProgramIsRunningError,
                                NavigationAssistant.Properties.Resources.ProgramIsRunningErrorCaption);
            }
            return(hasDuplicates);
        }
        protected async Task LoadPageDataAsync(CancellationToken cancellationToken)
        {
            var contents = await PresentationService.GetPageAsync(CurrentNavigationState.PageType == PageType.Dashboard
                                                                  ? "__dashboard"
                                                                  : CurrentNavigationState.CollectionAlias);

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            PageContents = contents;
        }
Example #8
0
        protected async Task <ListContext> LoadSectionsAsync()
        {
            var query = Query.Create(ListUI !.PageSize, CurrentState.CurrentPage, CurrentState.SearchTerm, CurrentState.ActiveTab);

            query.CollectionAlias = CurrentState.CollectionAlias;

            if (ListUI.OrderBys != null)
            {
                query.SetOrderBys(ListUI.OrderBys);
            }

            var request = CurrentState.Related != null
                ? (GetEntitiesRequestModel) new GetEntitiesOfRelationRequestModel
            {
                CollectionAlias = CurrentState.CollectionAlias,
                Query           = query,
                Related         = CurrentState.Related,
                UsageType       = CurrentState.UsageType,
                VariantAlias    = CurrentState.VariantAlias
            }
                : (GetEntitiesRequestModel) new GetEntitiesOfParentRequestModel
            {
                CollectionAlias = CurrentState.CollectionAlias,
                ParentPath      = CurrentState.ParentPath,
                Query           = query,
                UsageType       = CurrentState.UsageType,
                VariantAlias    = CurrentState.VariantAlias
            };

            var listContext = await PresentationService.GetEntitiesAsync <GetEntitiesRequestModel, ListContext>(request);

            await SetSectionsAsync(listContext);

            if (!query.MoreDataAvailable)
            {
                CurrentState.MaxPage = CurrentState.CurrentPage;

                if (CurrentState.CurrentPage > 1 && !Sections.Any())
                {
                    CurrentState.CurrentPage--;
                    CurrentState.MaxPage = null;
                    await LoadSectionsAsync();
                }
            }
            if (CurrentState.MaxPage == CurrentState.CurrentPage && query.MoreDataAvailable)
            {
                CurrentState.MaxPage = null;
            }

            return(listContext);
        }
        protected async Task <(ListContext listContext, List <(FormEditContext editContext, IEnumerable <SectionUI> sections)> sections)> LoadSectionsAsync(ListUI listUI, IListUIResolver uiResolver)
        {
            var query = Query.Create(listUI.PageSize, CurrentState.CurrentPage, CurrentState.SearchTerm, CurrentState.ActiveTab);

            query.CollectionAlias = CurrentState.CollectionAlias;

            if (listUI.OrderBys != null)
            {
                query.SetOrderBys(listUI.OrderBys);
            }

            var request = CurrentState.Related != null
                ? (GetEntitiesRequestModel) new GetEntitiesOfRelationRequestModel
            {
                CollectionAlias = CurrentState.CollectionAlias,
                Query           = query,
                Related         = CurrentState.Related,
                UsageType       = CurrentState.UsageType,
                VariantAlias    = CurrentState.VariantAlias
            }
                : (GetEntitiesRequestModel) new GetEntitiesOfParentRequestModel
            {
                CollectionAlias = CurrentState.CollectionAlias,
                ParentPath      = CurrentState.ParentPath,
                Query           = query,
                UsageType       = CurrentState.UsageType,
                VariantAlias    = CurrentState.VariantAlias
            };

            var listContext = await PresentationService.GetEntitiesAsync <GetEntitiesRequestModel, ListContext>(request);

            var sections = await listContext.EditContexts.ToListAsync(async editContext => (editContext, await uiResolver.GetSectionsForEditContextAsync(editContext)));

            if (!query.MoreDataAvailable)
            {
                CurrentState.MaxPage = CurrentState.CurrentPage;

                if (CurrentState.CurrentPage > 1 && sections?.Any() != true)
                {
                    CurrentState.CurrentPage--;
                    CurrentState.MaxPage = null;
                    return(await LoadSectionsAsync(listUI, uiResolver));
                }
            }
            if (CurrentState.MaxPage == CurrentState.CurrentPage && query.MoreDataAvailable)
            {
                CurrentState.MaxPage = null;
            }

            return(listContext, sections);
        }
Example #10
0
 public LoginViewModel(LoginService loginService, PresentationService presentationService, UserDataService userDataService)
 {
     if ((_LoginService = loginService) == null)
     {
         throw new ArgumentNullException("Login Service is null.");
     }
     if ((_UserDataService = userDataService) == null)
     {
         throw new ArgumentNullException("User Data Service is null.");
     }
     if ((_PresentationService = presentationService) == null)
     {
         throw new ArgumentNullException("Presentation Service is null.");
     }
 }
Example #11
0
 public FieldToComponent(Item i, ILogger l) : base(i, l)
 {
     ExistingDataNames   = GetItemField(i, "From What Field").Split(comSplitr, StringSplitOptions.RemoveEmptyEntries);
     Delimiter           = GetItemField(i, "Delimiter");
     Component           = GetItemField(i, "Component");
     Placeholder         = GetItemField(i, "Placeholder");
     DatasourcePath      = GetItemField(i, "Datasource Path");
     Device              = GetItemField(i, "Device");
     OverwriteExisting   = GetItemField(i, "Overwrite Existing") == "1";
     DatasourceFolder    = GetItemField(i, "Datasource Folder");
     Parameters          = GetItemField(i, "Parameters");
     IsSXA               = GetItemField(i, "Is SXA") == "1";
     PresentationService = new PresentationService(l);
     MediaService        = new MediaService(l);
 }
 public PresentationService GetPresentationService()
 {
     if (presentationService == null)
     {
         presentationService = new PresentationService();
         presentationService.ResourcePath       = PlanificationResourcePath.TRANSFORMATION_SLIDE_RESOURCE_PATH;
         presentationService.SocketResourcePath = PlanificationResourcePath.SOCKET_TRANSFORMATION_SLIDE_RESOURCE_PATH;
         presentationService.FileService        = GetFileService();
         presentationService.GroupService       = GetGroupService();
         presentationService.MeasureService     = GetMeasureService();
         presentationService.ModelService       = GetModelService();
         presentationService.PeriodicityService = GetPeriodicityService();
         presentationService.TargetService      = GetTargetService();
         presentationService.ReportService      = GetReportService();
         presentationService.PeriodNameService  = GetPeriodNameService();
         configureService(presentationService);
     }
     return(presentationService);
 }
Example #13
0
        public MultilistToComponents(Item i, ILogger l) : base(i, l)
        {
            ExistingDataNames   = GetItemField(i, "From What Field").Split(comSplitr, StringSplitOptions.RemoveEmptyEntries);
            Delimiter           = GetItemField(i, "Delimiter");
            Device              = GetItemField(i, "Device");
            DatasourceFolder    = GetItemField(i, "Datasource Folder");
            IsSXA               = GetItemField(i, "Is SXA") == "1";
            PresentationService = new PresentationService(l);
            ComponentMaps       = new Dictionary <string, ComponentMap>();
            MediaService        = new MediaService(l);

            var maps = InnerItem.GetChildren();

            foreach (Item m in maps)
            {
                var c = new ComponentMap
                {
                    FromWhatTemplate  = GetItemField(m, "From What Template"),
                    Component         = GetItemField(m, "Component"),
                    Placeholder       = GetItemField(m, "Placeholder"),
                    DatasourcePath    = GetItemField(m, "Datasource Path"),
                    OverwriteExisting = GetItemField(m, "Overwrite Existing") == "1",
                    Fields            = new Dictionary <string, IBaseField>(),
                    Parameters        = GetItemField(m, "Parameters")
                };

                foreach (Item f in m.GetChildren())
                {
                    var bf = FieldService.BuildBaseField(f);
                    var a  = GetItemField(f, "From What Field");
                    if (string.IsNullOrWhiteSpace(a) || bf == null)
                    {
                        continue;
                    }

                    c.Fields.Add(a, bf);
                }

                ComponentMaps.Add(c.FromWhatTemplate, c);
            }
        }
Example #14
0
        protected async Task LoadNodeDataAsync(CancellationToken cancellationToken)
        {
            if (CurrentState == null)
            {
                throw new InvalidOperationException();
            }

            var editContext = await PresentationService.GetEntityAsync <GetEntityRequestModel, FormEditContext>(new GetEntityRequestModel
            {
                CollectionAlias = CurrentState.CollectionAlias,
                Id           = CurrentState.Id,
                ParentPath   = CurrentState.ParentPath,
                UsageType    = CurrentState.UsageType,
                VariantAlias = CurrentState.VariantAlias
            });

            var resolver = await UIResolverFactory.GetNodeUIResolverAsync(CurrentState.UsageType, CurrentState.CollectionAlias);

            var buttons = await resolver.GetButtonsForEditContextAsync(editContext);

            var sections = new[] { (editContext, await resolver.GetSectionsForEditContextAsync(editContext)) }.ToList();
        protected async Task <List <(FormEditContext editContext, IEnumerable <SectionUI> sections)> > ReloadSectionsAsync(IEnumerable <string> reloadEntityIds, IListUIResolver uiResolver)
        {
            if (Sections == null)
            {
                return(new List <(FormEditContext editContext, IEnumerable <SectionUI> sections)>());
            }

            var newSections = await Sections.ToListAsync(async x =>
            {
                if (reloadEntityIds.Contains <string>(x.editContext.Entity.Id !))
                {
                    var reloadedEditContext = await PresentationService.GetEntityAsync <GetEntityRequestModel, FormEditContext>(new GetEntityRequestModel
                    {
                        CollectionAlias = x.editContext.CollectionAlias,
                        Id           = x.editContext.Entity.Id,
                        ParentPath   = x.editContext.Parent?.GetParentPath(),
                        UsageType    = x.editContext.UsageType,
                        VariantAlias = x.editContext.EntityVariantAlias
                    });

                    return(reloadedEditContext, await uiResolver.GetSectionsForEditContextAsync(reloadedEditContext));
                }
Example #16
0
        public SitecoreDataMap(Database db, string connectionString, Item importItem, ILogger l)
            : base(db, connectionString, importItem, l)
        {
            //get 'from' language
            ImportFromLanguage = GetImportItemLanguage("Import From Language", FromDB);

            //get recursive setting
            RecursivelyFetchChildren = ImportItem.GetItemBool("Recursively Fetch Children");

            //populate template definitions
            TemplateMappings = GetTemplateDefinitions(ImportItem);

            ComponentMappings = GetComponentDefinitions(ImportItem);

            ImportRoot        = GetImportRootItem();
            DeleteOnOverwrite = ImportItem.GetItemBool("Delete On Overwrite");

            AllLanguages = LanguageManager.GetLanguages(ToDB).ToArray();

            SkipIfExists       = importItem.GetItemBool("Skip Already Imported Items");
            SkipIfUpdatedAfter = importItem.GetItemDate("Skip If Updated After");

            PresentationService = new PresentationService(l);
        }
Example #17
0
 public BaseApiController()
 {
     PresentationService = new PresentationService();
 }
Example #18
0
 private void OnShowWindow()
 {
     PresentationService.ShowWindowAsync <SecondWindowViewModel>(
         x => x.Message = $"Hello, Second Window! {DateTime.Now}");
 }
Example #19
0
 public TouTvProvider(PresentationService presentationService, MediaValidationV1Service mediaValidationV1Service)
 {
     _presentationService      = presentationService;
     _mediaValidationV1Service = mediaValidationV1Service;
 }
Example #20
0
 public PresentationController(PulpFreshContext _context)
 {
     _presentationService = new PresentationService(_context);
 }
Example #21
0
 public CateogryController(PulpFreshContext _context)
 {
     _categoryService     = new CategoryService(_context);
     _PresentationService = new PresentationService(_context);
 }
Example #22
0
        public byte[] RetrieveDocument(string DocumentID, ref string mimeType, string Language)
        {
            if (DocumentID == null || DocumentID == "")
            {
                throw new DocumentSearchException(21, DocumentSearchException.ERROR_TYPE.INFORMATION, "Please Specify The Document Id To Search.");
            }

            try
            {
                HP.Csn.Business.KM.Services.PresentationService.WSUserInfo wsUserInfo = new HP.Csn.Business.KM.Services.PresentationService.WSUserInfo();
                wsUserInfo.userId   = base.userId;
                wsUserInfo.portalId = base.portalId;

                // Disclosure levels supported by CSN
                // Get from database in future
                int[] disclosureLevel = new int[4] {
                    1, 3, 5, 7
                };
                wsUserInfo.disclosureLevels = disclosureLevel;

                // Temp fix : Send disclosure levels to entitlements as expected by CSR
                string[] tempDisclosureLevels = new string[4] {
                    "1", "3", "5", "7"
                };
                wsUserInfo.entitlements = tempDisclosureLevels;

                WSCPRequest wsCPRequest = new WSCPRequest();
                wsCPRequest.docId = DocumentID;
                // Release 8.7 Enhancement
                if (Language != null && Language != "")
                {
                    wsCPRequest.locale = Language;
                }
                else
                {
                    wsCPRequest.locale = DEFAULT_LANGUAGE;
                }

                WSDocument wsDocument = null;

                PresentationService presentationService = new PresentationService();
                presentationService.SetConnectionInfo(base.presentationUrl, base.userId, base.userPassword, base.timeOut);

                wsDocument = presentationService.retrieveDocument(wsUserInfo, wsCPRequest);

                //Sachin Added for 13.11 Release-Start
                string      strMetaData       = wsDocument.metaData;
                string      strDocumentStatus = string.Empty;
                XmlDocument objXmlMetaData    = new XmlDocument();
                XmlNode     objXmlNode;
                XmlNodeList objXmlNodeList;
                objXmlMetaData.LoadXml(strMetaData);
                objXmlNodeList = objXmlMetaData.GetElementsByTagName("document_status");

                if (objXmlNodeList.Count > 0)
                {
                    objXmlNode        = objXmlNodeList.Item(0);
                    strDocumentStatus = objXmlNode.InnerText;
                }
                OracleUtil objOraUtil       = new OracleUtil();
                string[]   WorkFlowStatuses = objOraUtil.workflowstate();
                if (WorkFlowStatuses != null)
                {
                    bool bFindStatus = false;
                    for (int i = 0; i <= WorkFlowStatuses.Length - 1; i++)
                    {
                        if (strDocumentStatus == WorkFlowStatuses[i].ToString())
                        {
                            bFindStatus = true;
                        }
                    }
                    if (bFindStatus == false)
                    {
                        throw new DocumentSearchException(23, DocumentSearchException.ERROR_TYPE.INFORMATION, "No records found for this document number." + DocumentID);
                    }
                }
                //Sachin Added for 13.11 Release-End


                if (wsDocument == null)
                {
                    throw new DocumentSearchException(23, DocumentSearchException.ERROR_TYPE.INFORMATION, "Unable To Retrieve Document " + DocumentID);
                }

                if (wsDocument.payload.Length == 0)
                {
                    throw new DocumentSearchException(24, DocumentSearchException.ERROR_TYPE.INFORMATION, "Error While Retrieving Document. Payload Is Empty");
                }

                mimeType = wsDocument.mimetype;

                return(wsDocument.payload);
            }
            catch (SoapException ex)
            {
                throw new DocumentSearchException(25, DocumentSearchException.ERROR_TYPE.INFORMATION, "Error While Retrieving Document. ERROR :" + ex.Message, ex);
            }
            catch (WebException ex)
            {
                throw new DocumentSearchException(26, DocumentSearchException.ERROR_TYPE.WARNING, "Error Connecting To Web Service. ERROR :" + ex.Message, ex);
            }
            catch (DocumentSearchException ex)
            {
                //Catching and throwing document search exception when payload size is 0
                throw ex;
            }
            catch (Exception ex)
            {
                throw new DocumentSearchException(27, DocumentSearchException.ERROR_TYPE.WARNING, "Unexpected Error While Accessing Web Service. ERROR :" + ex.Message, ex);
            }
        }
Example #23
0
 public ProductoController(PulpFreshContext _context)
 {
     _productService      = new ProductService(_context);
     _CategoryService     = new CategoryService(_context);
     _PresentationService = new PresentationService(_context);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedController"/> class.
 /// </summary>
 /// <param name="rssFeedService">RssFeedService.</param>
 /// <param name="presentationService">PresentationService.</param>
 public FeedController(RssFeedService rssFeedService, PresentationService presentationService)
 {
     this.feedService         = rssFeedService ?? throw new ArgumentNullException(nameof(rssFeedService));
     this.presentationService = presentationService ?? throw new ArgumentNullException(nameof(presentationService));
 }
Example #25
0
        public override void FillField(IDataMap map, ref Item newItem, object importRow)
        {
            var importValue = string.Join(Delimiter, map.GetFieldValues(ExistingDataNames, importRow));

            if (string.IsNullOrEmpty(importValue))
            {
                var path = importRow is Item ? ((Item)importRow).Paths.FullPath : "N/A";
                Logger.Log($"There was no import value", path, LogType.MultilistToComponent);
                return;
            }

            var layoutField = newItem.Fields[FieldIDs.FinalLayoutField];

            if (layoutField == null)
            {
                return;
            }

            var layout      = LayoutDefinition.Parse(layoutField.Value);
            var deviceItem  = layout.GetDevice(Device);
            var entries     = importValue.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            var sitecoreMap = (SitecoreDataMap)map;
            var itemList    = entries.Select(a => sitecoreMap.FromDB.GetItem(new ID(a))).Where(b => b != null).ToList();

            foreach (var i in itemList)
            {
                var itemTemplate = i.TemplateID.ToString();
                if (!ComponentMaps.ContainsKey(itemTemplate))
                {
                    Logger.Log($"There was no component mapping found", i.Paths.FullPath, LogType.MultilistToComponent, i.TemplateName, itemTemplate);
                    continue;
                }

                var cm     = ComponentMaps[itemTemplate];
                var dsName = cm.DatasourcePath.Contains("/")
                    ? cm.DatasourcePath.Substring(cm.DatasourcePath.LastIndexOf("/") + 1)
                    : cm.DatasourcePath;

                if (!cm.OverwriteExisting)
                {
                    var datasource = PresentationService.CreateDatasource(map, newItem, deviceItem, dsName, DatasourceFolder, cm.DatasourcePath, cm.Component, cm.OverwriteExisting);
                    if (datasource == null)
                    {
                        Logger.Log($"There was no datasource created for matching device:{Device} - placeholder:{cm.Placeholder} - component:{cm.Component}", i.Paths.FullPath, LogType.MultilistToComponent, "device xml", deviceItem.ToXml());
                        continue;
                    }

                    SetFields(i, datasource, cm, sitecoreMap);
                    PresentationService.AddComponent(newItem, datasource, cm.Placeholder, cm.Component, Device, cm.Parameters, IsSXA);
                }
                else
                {
                    var rendering = PresentationService.FindRendering(deviceItem, cm.Placeholder, cm.Component);
                    if (rendering == null)
                    {
                        Logger.Log($"There was no rendering matching device:{Device} - placeholder:{cm.Placeholder} - component:{cm.Component}", i.Paths.FullPath, LogType.MultilistToComponent, "device xml", deviceItem.ToXml());
                        continue;
                    }

                    var datasource = PresentationService.FindDatasourceByName(map, newItem, rendering, dsName);
                    if (datasource == null)
                    {
                        Logger.Log($"There was no datasource found matching name:{dsName}", i.Paths.FullPath, LogType.MultilistToComponent, "rendering xml", rendering.ToXml());
                        continue;
                    }

                    SetFields(i, datasource, cm, sitecoreMap);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HomeController"/> class.
 /// </summary>
 /// <param name="presentationService">PresentationService.</param>
 public HomeController(PresentationService presentationService)
 {
     this.presentationService = presentationService;
 }
Example #27
0
 public PresentationsController(PresentationService presentServ)
 {
     _presentServ = presentServ;
 }
Example #28
0
        public void ProcessComponents(Item newItem, Item importItem)
        {
            var components = new List <IComponentMapping>();

            components.AddRange(ComponentMappings);

            TemplateMapping tm = GetTemplateMapping(newItem);

            if (tm != null)
            {
                components.AddRange(tm.ComponentMappings);
            }

            foreach (var cm in components)
            {
                using (new LanguageSwitcher(ImportToLanguage))
                {
                    try
                    {
                        var dsName = cm.ToDatasourcePath.Contains("/")
                            ? cm.ToDatasourcePath.Substring(cm.ToDatasourcePath.LastIndexOf("/") + 1)
                            : cm.ToDatasourcePath;

                        var oldDeviceDef = PresentationService.FindDeviceDefinition(importItem, cm.FromDevice);
                        if (oldDeviceDef == null)
                        {
                            continue;
                        }

                        var oldRendering = PresentationService.FindRendering(oldDeviceDef, cm.FromPlaceholder, cm.FromComponent);
                        if (oldRendering == null)
                        {
                            Logger.Log($"There was no rendering matching device:{cm.FromDevice} - placeholder:{cm.FromPlaceholder} - component:{cm.FromComponent}", importItem.Paths.FullPath, LogType.MultilistToComponent, "device xml", oldDeviceDef.ToXml());
                            continue;
                        }

                        var oldDatasource = PresentationService.FindDatasource(this, importItem, oldRendering);
                        if (oldDatasource == null)
                        {
                            Logger.Log($"There was no datasource found matching name:{dsName}", importItem.Paths.FullPath, LogType.MultilistToComponent, "rendering xml", oldRendering.ToXml());
                            continue;
                        }

                        var newDeviceDef = PresentationService.FindDeviceDefinition(newItem, cm.ToDevice);
                        if (newDeviceDef == null)
                        {
                            continue;
                        }

                        if (!cm.OverwriteExisting)
                        {
                            var createDatasource = !string.IsNullOrWhiteSpace(cm.ToDatasourcePath);
                            var newDatasource    = createDatasource
                                ? PresentationService.CreateDatasource(this, newItem, newDeviceDef, dsName, cm.ToDatasourceFolder, cm.ToDatasourcePath, cm.ToComponent, cm.OverwriteExisting)
                                : null;
                            if (newDatasource == null && createDatasource)
                            {
                                Logger.Log($"There was no datasource created for device:{cm.ToDevice} - placeholder:{cm.ToPlaceholder} - component:{cm.ToComponent}", newItem.Paths.FullPath, LogType.MultilistToComponent, "device xml", newDeviceDef.ToXml());
                                continue;
                            }

                            SetDatasourceFields(oldDatasource, newDatasource, cm);
                            PresentationService.AddComponent(newItem, newDatasource, cm.ToPlaceholder, cm.ToComponent, cm.ToDevice, cm.ToParameters, cm.IsSXA);
                        }
                        else
                        {
                            var newRendering = PresentationService.FindRendering(newDeviceDef, cm.ToPlaceholder, cm.ToComponent);
                            if (newRendering == null)
                            {
                                Logger.Log($"There was no rendering matching device:{cm.ToDevice} - placeholder:{cm.ToPlaceholder} - component:{cm.ToComponent}", importItem.Paths.FullPath, LogType.MultilistToComponent, "device xml", newDeviceDef.ToXml());
                                continue;
                            }

                            var newDatasource = PresentationService.FindDatasource(this, newItem, newRendering);
                            if (newDatasource == null)
                            {
                                Logger.Log($"There was no datasource found matching name:{dsName}", newItem.Paths.FullPath, LogType.MultilistToComponent, "rendering xml", newRendering.ToXml());
                                continue;
                            }

                            SetDatasourceFields(oldDatasource, newDatasource, cm);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("SitecoreDataMap.ProcessComponents", string.Format("failed to import component {0} on item {1}", cm.FromComponent, importItem.Paths.FullPath));
                    }
                }
            }
        }
        private bool HasDuplicates()
        {
            IPresentationService presentationService = new PresentationService();
            bool hasDuplicates = presentationService.ApplicationIsRunning(AppMutex);

            if (hasDuplicates)
            {
                MessageBox.Show(NavigationAssistant.Properties.Resources.ProgramIsRunningError,
                                NavigationAssistant.Properties.Resources.ProgramIsRunningErrorCaption);
            }
            return hasDuplicates;
        }
Example #30
0
 public TouTvRestfulService(IHttpClient httpClient, IJsonSerializer jsonSerializer)
 {
     _presentationService = new PresentationService(httpClient, jsonSerializer);
 }
Example #31
0
 public MarketPresenter(IDistributor parent, string symbol, bool direct) : base(parent, symbol, direct)
 {
     Symbol = symbol;
     PresentationService.RegisterService(this);
 }