Esempio n. 1
0
        //[AdminAccess]
        public IActionResult ChannelIcon(string provider)
        {
            MicroserviceDescription description = _addinManager.FindMicroservice(provider);

            byte[] data = LoadIconFile(description);
            if (data == null)
            {
                return(null);
            }

            string contentType = MediaType.GetMimeByFileName(description.Icon);

            return(File(data, contentType));
        }
        /// <summary>
        /// Подготовить ответное сообщение.
        /// </summary>
        /// <param name="resMsg"></param>
        protected void PrepareResponseMessage(Message resMsg)
        {
            #region Validate parameters
            if (resMsg == null)
            {
                throw new ArgumentNullException("msg");
            }
            #endregion

            _logger.LogTrace(String.Format("Подготовка ответного сообщения {0}.", resMsg));

            #region Header
            //resMsg.Channel = this.Channel.VirtAddress;

            if (resMsg.LINK == 0)
            {
                resMsg.SetStatus(MessageStatus.NULL);
            }

            if (String.IsNullOrWhiteSpace(resMsg.Direction))
            {
                resMsg.Direction = MessageDirection.OUT;
            }

            //if ( String.IsNullOrWhiteSpace(resMsg.From) )
            //	resMsg.From = this.Channel.VirtAddress;

            if (String.IsNullOrWhiteSpace(resMsg.Version))
            {
                resMsg.Version = MessageVersion.Current;
            }

            if (String.IsNullOrWhiteSpace(resMsg.Type))
            {
                resMsg.Type = MessageType.DOCUMENT;
            }

            if (String.IsNullOrWhiteSpace(resMsg.Class))
            {
                resMsg.Class = MessageClass.RESPONSE;
            }

            if (resMsg.Date == null)
            {
                resMsg.Date = DateTime.Now;
            }
            #endregion

            #region Body
            if (resMsg.Body != null)
            {
                if (String.IsNullOrWhiteSpace(resMsg.Body.Type))
                {
                    resMsg.Body.Type = MediaType.GetMimeByFileName(resMsg.Body.Name);
                }

                if (resMsg.Body.Length == null)
                {
                    using (MessageBody body = _dataAdapter.GetMessageBody(resMsg.LINK))
                    {
                        resMsg.Body.Length = body.Length;
                    }
                }
            }
            #endregion

            #region Contents
            foreach (MessageContentInfo contentInfo in resMsg.Contents)
            {
                if (String.IsNullOrWhiteSpace(contentInfo.Type))
                {
                    contentInfo.Type = MediaType.GetMimeByFileName(contentInfo.Name);
                }

                if (contentInfo.Length == null)
                {
                    using (MessageContent content = _dataAdapter.GetMessageContent(contentInfo.LINK))
                    {
                        contentInfo.Length = content.Length;
                    }
                }
            }
            #endregion
        }