/// <summary>
        /// The constructor for creating a new <see cref="ResourceObject"/>
        /// </summary>
        /// <param name="emk">The filtered entry. Can be null!</param>
        /// <param name="resource">The original entry. Can't be null!</param>
        public ResourceObject(EmkResource emk, OperationResource resource)
        {
            Assertions.AssertNotNull(resource, "resource");

            Emk = emk;
            Resource = resource;
        }
Example #2
0
        /// <summary>
        /// The constructor for creating a new <see cref="ResourceObject"/>
        /// </summary>
        /// <param name="emk">The filtered entry. Can be null!</param>
        /// <param name="resource">The original entry. Can't be null!</param>
        public ResourceObject(EmkResource emk, OperationResource resource)
        {
            Assertions.AssertNotNull(resource, "resource");

            Emk      = emk;
            Resource = resource;
        }
Example #3
0
        public ActionResult GetResourceImage(string id)
        {
            using (var emkService = ServiceFactory.GetServiceWrapper <IEmkService>())
            {
                IList <EmkResource> emkResources = emkService.Instance.GetAllResources();
                EmkResource         resource     = emkResources.FirstOrDefault(x => x.Id == id);
                if (resource == null)
                {
                    return(null);
                }
                using (FileTransferServiceClient client = new FileTransferServiceClient())
                {
                    try
                    {
                        Stream content = client.GetFileFromPath(resource.IconFileName);

                        if (content != null)
                        {
                            return(File(content, GetMimeType(resource.IconFileName)));
                        }
                    }
                    catch (IOException ex)
                    {
                        // This exception is totally OK. No image will be displayed.
                    }
                    catch (AssertionFailedException)
                    {
                        // This exception is totally OK. No image will be displayed.
                    }
                }
            }
            return(null);
        }
        internal ResourceViewModel(OperationResource resource, EmkResource emkResource)
            : base()
        {
            Assertions.AssertNotNull(resource, "resource");

            this.Resource = resource;

            _emkResource = emkResource;
            if (_emkResource != null)
            {
                LoadIconAsync();
            }
        }
        internal ResourceViewModel(OperationResource resource, EmkResource emkResource)
            : base()
        {
            if (resource == null && emkResource == null)
            {
                throw new InvalidOperationException(Properties.Resources.NoResourceGiven);
            }
            this.Resource = resource;

            EmkResourceItem = emkResource;
            if (EmkResourceItem != null)
            {
                LoadIconAsync();
            }
        }
Example #6
0
        private void ApplyFilteredResources(Operation operation)
        {
            Resources.Clear();
            using (var service = ServiceFactory.GetServiceWrapper <IEmkService>())
            {
                IList <EmkResource> emkResources = service.Instance.GetAllResources();

                foreach (OperationResource resource in service.Instance.GetFilteredResources(operation.Resources))
                {
                    EmkResource emk = emkResources.FirstOrDefault(item => item.IsActive && item.IsMatch(resource));

                    Resources.Add(new ResourceViewModel(resource, emk));
                }
            }
        }
        internal ResourceViewModel(OperationResource resource, EmkResource emkResource)
            : base()
        {
            if (resource == null && emkResource == null)
            {
                throw new InvalidOperationException(Properties.Resources.NoResourceGiven);
            }
            this.Resource = resource;

            EmkResourceItem = emkResource;
            if (EmkResourceItem != null)
            {
                LoadIconAsync();
            }
        }
Example #8
0
        public void IsMatch_Negative_Test()
        {
            EmkResource emk = new EmkResource()
            {
                SiteAlias     = "ABC",
                ResourceAlias = "99/9",
                DisplayName   = "99.9",
            };

            OperationResource opRes = new OperationResource()
            {
                FullName = "1.2.3 XYZ 99/9 HLF",
            };

            Assert.IsFalse(emk.IsMatch(opRes));
        }
        public void IsMatch_Negative_Test()
        {
            EmkResource emk = new EmkResource()
            {
                SiteAlias = "ABC",
                ResourceAlias = "99/9",
                DisplayName = "99.9",
            };

            OperationResource opRes = new OperationResource()
            {
                FullName = "1.2.3 XYZ 99/9 HLF",
            };

            Assert.IsFalse(emk.IsMatch(opRes));
        }
Example #10
0
        public void Equals_Negative_Test()
        {
            EmkResource resourceA = new EmkResource()
            {
                SiteAlias     = "ABC",
                ResourceAlias = "99/9",
                DisplayName   = "99.9",
            };

            EmkResource resourceB = new EmkResource()
            {
                SiteAlias     = "ABC",
                ResourceAlias = "xx/9",
                DisplayName   = "99.9",
            };

            Assert.IsFalse(resourceA.Equals(resourceB));
        }
        public void Equals_Negative_Test()
        {
            EmkResource resourceA = new EmkResource()
            {
                SiteAlias = "ABC",
                ResourceAlias = "99/9",
                DisplayName = "99.9",
            };

            EmkResource resourceB = new EmkResource()
            {
                SiteAlias = "ABC",
                ResourceAlias = "xx/9",
                DisplayName = "99.9",
            };

            Assert.IsFalse(resourceA.Equals(resourceB));
        }
Example #12
0
        void IDispositioningServiceCallback.OnEvent(DispositionEventArgs args)
        {
            if (_operation.Id == args.OperationId)
            {
                switch (args.Action)
                {
                case DispositionEventArgs.ActionType.Dispatch:
                    EmkResource emk = _emkResources.FirstOrDefault(x => x.IsActive && x.Id == args.EmkResourceId);
                    Resources.Add(new ResourceViewModel(null, emk));
                    break;

                case DispositionEventArgs.ActionType.Recall:
                    if (Resources.Any(x => x.EmkResourceItem.Id == args.EmkResourceId))
                    {
                        Resources.Remove(Resources.First(x => x.EmkResourceItem.Id == args.EmkResourceId));
                    }
                    break;
                }
            }
        }
Example #13
0
        /// <summary>
        /// Gets the list of filtered resources for a given operation
        /// GET: /Display/Alarm/GetFilteredResources/Id
        /// </summary>
        /// <param name="id">The id of the operation</param>
        /// <returns>A <see cref="JsonResult"/> containing a <see cref="ResourcesData"/> object or null if an error occured.</returns>
        public ActionResult GetFilteredResources(int id)
        {
            using (var emkService = ServiceFactory.GetServiceWrapper <IEmkService>())
            {
                Operation operation;
                try
                {
                    using (var service = ServiceFactory.GetCallbackServiceWrapper <IOperationService>(new OperationServiceCallback()))
                    {
                        operation = service.Instance.GetOperationById(id);
                        if (operation == null)
                        {
                            return(null);
                        }
                    }
                }
                catch (Exception)
                {
                    return(null);
                }

                ResourcesData         data              = new ResourcesData();
                IList <EmkResource>   emkResources      = emkService.Instance.GetAllResources();
                List <ResourceObject> filteredResources = new List <ResourceObject>();

                IList <OperationResource> filtered = emkService.Instance.GetFilteredResources(operation.Resources);
                foreach (OperationResource resource in filtered)
                {
                    EmkResource emk = emkResources.FirstOrDefault(item => item.IsActive && item.IsMatch(resource));
                    filteredResources.Add(new ResourceObject(emk, resource));
                }
                data.Resources = filteredResources;

                JsonResult result = new JsonResult();
                result.Data = data;
                result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
                return(result);
            }
        }
Example #14
0
        private void ApplyFilteredResources(Operation operation)
        {
            Resources.Clear();
            using (var service = ServiceFactory.GetServiceWrapper <IEmkService>())
            {
                _emkResources = service.Instance.GetAllResources();

                foreach (OperationResource resource in service.Instance.GetFilteredResources(operation.Resources))
                {
                    EmkResource emk = _emkResources.FirstOrDefault(item => item.IsActive && item.IsMatch(resource));

                    Resources.Add(new ResourceViewModel(resource, emk));
                }
            }
            string[] dispatchedResources = _disposingService.GetDispatchedResources(operation.Id);

            foreach (string resource in dispatchedResources)
            {
                EmkResource emk = _emkResources.FirstOrDefault(x => x.IsActive && x.Id == resource);
                Resources.Add(new ResourceViewModel(null, emk));
            }
        }
Example #15
0
        /// <summary>
        /// Creates a new instance of a ResourceItem.
        /// </summary>
        /// <param name="emkResource">The <see cref="EmkResource"/>. Must not be null!</param>
        public ResourceItem(EmkResource emkResource)
        {
            Assertions.AssertNotNull(emkResource, "emkResource");

            EmkResourceItem = emkResource;
        }
        /// <summary>
        /// Creates a new instance of a ResourceItem.
        /// </summary>
        /// <param name="emkResource">The <see cref="EmkResource"/>. Must not be null!</param>
        public ResourceItem(EmkResource emkResource)
        {
            Assertions.AssertNotNull(emkResource, "emkResource");

            EmkResourceItem = emkResource;
        }