Esempio n. 1
0
 public static void notifyFrameDestroy()
 {
     mEditorCore          = null;
     mCommandSystem       = null;
     mHttpDownloadManager = null;
     mDownloadManager     = null;
     mUploadManager       = null;
     mEventSystem         = null;
 }
Esempio n. 2
0
 public static void notifyConstructDone()
 {
     if (mEditorCore == null)
     {
         mEditorCore          = EditorCore.getSingleton();
         mCommandSystem       = mEditorCore.getSystem <CommandSystem>();
         mHttpDownloadManager = mEditorCore.getSystem <HttpDownloadManager>();
         mDownloadManager     = mEditorCore.getSystem <DownloadManager>();
         mUploadManager       = mEditorCore.getSystem <UploadManager>();
         mEventSystem         = mEditorCore.getSystem <EventSystem>();
     }
 }
Esempio n. 3
0
        private async Task LoadFromWebAsync(IHtmlContainer container, string url)
        {
            using (var httpDownloadManager = new HttpDownloadManager())
            {
                var download = await httpDownloadManager.DownloadAsStringAsync(new Uri(url),
                                                                               acceptMediaType : @"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

                if (download.IsSuccess)
                {
                    container.LoadHtml(download.Result);
                }
                else
                {
                    throw new DownloadException <string>(Resources.HtmlContentDownloadException_Message, download);
                }
            }
        }
Esempio n. 4
0
        public async Task <ActionResult> UrlNullResolve(int?id, AuthorResolvesViewModels.ResolvedNullUrlModel resolveModel)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (ModelState.IsValid)
            {
                do
                {
                    var currentAuthorResolve = await _db.AuthorsResolves.FindAsync(id);

                    if (resolveModel.SelectedAuthorId.HasValue)
                    {
                        var authorUrlName = Author.GetUrlName(resolveModel.ResolvedUrl);
                        await ApplayAuthorResolve(currentAuthorResolve, resolveModel.SelectedAuthorId.Value, resolveModel.ResolvedUrl, authorUrlName);
                    }
                    else
                    {
                        try
                        {
                            var    authorUrlName = Author.GetUrlName(resolveModel.ResolvedUrl);
                            Author author        = null;

                            var updateService = new UpdateService(AppConstants.ServerPaths.MediaDirectory, AppConstants.ServerPaths.ArchiveDirectory);
                            using (var downloadManger = new HttpDownloadManager(100, 100, 3, new InCloakWebAnonymizer()))
                            {
                                var callResult =
                                    await
                                    updateService.CreateAuthorAsync(currentAuthorResolve.TrainingProviderId, authorUrlName,
                                                                    downloadManger);

                                if (callResult.Succeeded)
                                {
                                    author = callResult.Value;
                                }
                                else
                                {
                                    ModelState.AddModelError("", string.Join(";\r\n", callResult.Errors));
                                    break;
                                }
                            }

                            await ApplayAuthorResolve(currentAuthorResolve, author.Id, resolveModel.ResolvedUrl, authorUrlName);
                        }
                        // ReSharper disable once CatchAllClause
                        catch (Exception ex)
                        {
                            ModelState.AddModelError("", ex.ToString());
                            break;
                        }
                    }

                    return(RedirectToAction("Index"));

                    // need for flow control
#pragma warning disable 162
                } while (false);
#pragma warning restore 162
            }

            var viewModel = await GetUrlNullResolveViewModel(id.Value);

            viewModel.SelectedAuthorId = resolveModel.SelectedAuthorId;
            viewModel.ResolvedUrl      = resolveModel.ResolvedUrl;

            return(View(viewModel));
        }