예제 #1
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] Mediatype mediatype)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mediatype.Id)
            {
                return(BadRequest());
            }

            mediatype.ModifiedUserId = Convert.ToInt32(((ClaimsIdentity)HttpContext.User.Identity).FindFirst(ClaimTypes.Sid).Value);
            mediatype.ModifiedDate   = DateTime.Now;

            _context.Entry(mediatype).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(mediatype));
        }
예제 #2
0
        private async void Enqueue(Uri uri, string namebase, Mediatype type, string extension = null)
        {
            DebugUtil.Log(() => "ContentsDownloader: Enqueue " + uri.AbsolutePath);

            if (extension == null)
            {
                var split = uri.AbsolutePath.Split('.');
                if (split.Length > 0)
                {
                    extension = "." + split[split.Length - 1].ToLower();
                    DebugUtil.Log(() => "detected file extension: " + extension);
                }
            }

            await SystemUtil.GetCurrentDispatcher().RunAsync(CoreDispatcherPriority.Low, () =>
            {
                var req = new DownloadRequest
                {
                    Uri       = uri,
                    NameBase  = namebase,
                    Completed = OnFetched,
                    Error     = OnFailed,
                    Mediatype = type,
                    extension = extension
                };
                DownloadQueue.Enqueue(req);
                QueueStatusUpdated?.Invoke(DownloadQueue.Count);
                ProcessQueueSequentially();
            });
        }
예제 #3
0
        public void SendMessage(Mediatype media, string message, string reciever)
        {
            switch (media)
            {
            case Mediatype.Email:
                _media = new Email(message, reciever);
                _media.SendMessage();
                break;

            default:
                break;
            }
        }
예제 #4
0
        public async Task <IActionResult> Post([FromBody] Mediatype mediatype)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            mediatype.ModifiedUserId = Convert.ToInt32(((ClaimsIdentity)HttpContext.User.Identity).FindFirst(ClaimTypes.Sid).Value);
            mediatype.ModifiedDate   = DateTime.Now;

            _context.Mediatype.Add(mediatype);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Get", new { id = mediatype.Id }, mediatype));
        }
예제 #5
0
        private async Task Enqueue(Uri uri, string namebase, Mediatype type, CancellationTokenSource cts, string extension = null)
        {
            DebugUtil.LogSensitive(() => "ContentsDownloader: Enqueue {0}", uri.AbsolutePath);

            if (extension == null)
            {
                var split = uri.AbsolutePath.Split('.');
                if (split.Length > 0)
                {
                    extension = "." + split[split.Length - 1].ToLower();
                    DebugUtil.Log(() => "detected file extension: " + extension);
                }
            }

            var tcs = new TaskCompletionSource <bool>();

            await SystemUtil.GetCurrentDispatcher().RunAsync(CoreDispatcherPriority.Low, () =>
            {
                var req = new DownloadRequest
                {
                    Uri                     = uri,
                    NameBase                = namebase,
                    Completed               = OnFetched,
                    Error                   = OnFailed,
                    Mediatype               = type,
                    FileExtension           = extension,
                    CompletionSource        = tcs,
                    CancellationTokenSource = cts,
                };
                DownloadQueue.Enqueue(req);
                QueueStatusUpdated?.Invoke(DownloadQueue.Count);
                ProcessQueueSequentially();
            });

            await tcs.Task;
        }