示例#1
0
 public FileUploadOrDownload(IHostService hostService, ShellStruct shellData, string sourceFilePath, string targetFilePath)
 {
     _hostService = hostService;
     _shellData = shellData;
     _sourceFilePath = sourceFilePath;
     _targetFilePath = targetFilePath;
 }
示例#2
0
 protected override void OnStart(string[] args)
 {
     base.OnStart(args);
       var container = new Container();
       host = container.GetInstance<IHostService>();
       host.StartServices();
 }
 private void BuildItem(IHostService host, ItemViewModel item, FileModel model)
 {
     item.Summary = Markup(host, item.Summary, model);
     item.Remarks = Markup(host, item.Remarks, model);
     item.Conceptual = Markup(host, item.Conceptual, model);
     if (item.Syntax?.Return?.Description != null)
     {
         item.Syntax.Return.Description = Markup(host, item.Syntax?.Return?.Description, model);
     }
     var parameters = item.Syntax?.Parameters;
     if (parameters != null)
     {
         foreach (var parameter in parameters)
         {
             parameter.Description = Markup(host, parameter.Description, model);
         }
     }
     if (item.Exceptions != null)
     {
         foreach (var exception in item.Exceptions)
         {
             exception.Description = Markup(host, exception.Description, model);
         }
     }
 }
示例#4
0
        public ResolutionAgent()
        {
            hostService = new XenClientGuestHostService();

            SystemEvents.UserPreferenceChanging += new UserPreferenceChangingEventHandler(SystemEvents_UserPreferenceChanging);
            SystemEvents.PaletteChanged += new EventHandler(SystemEvents_PaletteChanged);
            SystemEvents.DisplaySettingsChanged += new EventHandler(SystemEvents_DisplaySettingsChanged);
            SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);

            try
            {
                updateScreen();
            }
            catch (Exception ex)
            {
                MessageBox.Show("XenStore is unavailable, reboot needed",
                                "OpenXT Resolution Agent",
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                Environment.Exit(0);
            }

            InitializeComponent();
            this.WindowState = FormWindowState.Minimized;
            this.ShowInTaskbar = false;
        }
示例#5
0
        public override void Build(FileModel model, IHostService host)
        {
            var toc = (TocItemViewModel)model.Content;
            BuildCore(toc, model, host);

            // todo : metadata.
        }
示例#6
0
        /// <summary>
        /// 1. Expand the TOC reference
        /// 2. Resolve homepage
        /// </summary>
        /// <param name="models"></param>
        /// <param name="host"></param>
        /// <returns></returns>
        public override IEnumerable<FileModel> Prebuild(ImmutableList<FileModel> models, IHostService host)
        {
            var tocModelCache = new Dictionary<string, TocItemInfo>();
            foreach (var model in models)
            {
                if (!tocModelCache.ContainsKey(model.OriginalFileAndType.FullPath))
                {
                    tocModelCache[model.OriginalFileAndType.FullPath] = new TocItemInfo(model.OriginalFileAndType, (TocItemViewModel)model.Content);
                }
            }
            var tocResolver = new TocResolver(host, tocModelCache);
            foreach (var key in tocModelCache.Keys.ToList())
            {
                tocModelCache[key] = tocResolver.Resolve(key);
            }

            foreach (var model in models)
            {
                var wrapper = tocModelCache[model.OriginalFileAndType.FullPath];

                // If the TOC file is referenced by other TOC, remove it from the collection
                if (!wrapper.IsReferenceToc)
                {
                    model.Content = wrapper.Content;
                    yield return model;
                }
            }
        }
 public NewsletterController(INewsletterService newsletterService, IHostService hostService,
     ITripService tripService)
 {
     _newsletterService = newsletterService;
     _hostService = hostService;
     _tripService = tripService;
 }
示例#8
0
 private void FillCore(PageViewModel model, IHostService host)
 {
     if (model.References == null || model.References.Count == 0)
     {
         return;
     }
     foreach (var r in model.References)
     {
         var m = host.LookupByUid(r.Uid).Find(x => x.Type == DocumentType.Article);
         if (m == null)
         {
             continue;
         }
         var page = (PageViewModel)m.Content;
         var item = page.Items.Find(x => x.Uid == r.Uid);
         if (item == null)
         {
             continue;
         }
         r.Additional["summary"] = item.Summary;
         r.Additional["type"] = item.Type;
         r.Additional["syntax"] = item.Syntax;
         r.Additional["platform"] = item.Platform;
     }
 }
示例#9
0
 public override void Build(FileModel model, IHostService host)
 {
     switch (model.Type)
     {
         case DocumentType.Article:
             var restApi = (RestApiRootItemViewModel)model.Content;
             BuildItem(host, restApi, model);
             if (restApi.Children != null)
             {
                 foreach (var item in restApi.Children)
                 {
                     BuildItem(host, item, model);
                 }
             }
             if (restApi.Tags != null)
             {
                 foreach (var tag in restApi.Tags)
                 {
                     BuildTag(host, tag, model);
                 }
             }
             break;
         case DocumentType.Overwrite:
             BuildItem(host, model);
             break;
         default:
             throw new NotSupportedException();
     }
 }
 public IEnumerable<RestApiTagViewModel> GetTagsFromOverwriteDocument(FileModel overwriteModel, string uid, IHostService host)
 {
     return OverwriteDocumentReader.Transform<RestApiTagViewModel>(
         overwriteModel,
         uid,
         s => BuildRestApiDocument.BuildTag(host, s, overwriteModel, content => content != null && content.Trim() == Constants.ContentPlaceholder));
 }
示例#11
0
 public static IEnumerable<OverwriteDocumentModel> ReadMarkdownAsOverwrite(IHostService host, FileAndType ft)
 {
     // Order the list from top to bottom
     var markdown = File.ReadAllText(ft.FullPath);
     var parts = MarkupMultiple(host, markdown, ft);
     return parts.Select(part => TransformModel(ft.FullPath, part));
 }
示例#12
0
        private void ValidateToc(TocItemViewModel item, FileModel model, IHostService hostService)
        {
            if (!PathUtility.IsRelativePath(item.Href)) return;
            var file = model.File;
            var originalFile = model.OriginalFileAndType.File;
            // Special handle for folder ends with '/'
            FileAndType originalTocFile = null;

            string fileName = Path.GetFileName(item.Href);
            if (string.IsNullOrEmpty(fileName))
            {
                var href = item.Href + "toc.yml";
                var absHref = (RelativePath)file + (RelativePath)href;
                string tocPath = absHref.GetPathFromWorkingFolder();
                if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                {
                    href = item.Href + "toc.md";
                    absHref = (RelativePath)file + (RelativePath)href;
                    tocPath = absHref.GetPathFromWorkingFolder();
                    if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                    {
                        var error = $"Unable to find either toc.yml or toc.md inside {item.Href}. Make sure the file is included in config file docfx.json!";
                        Logger.LogError(error, file: model.LocalPathFromRepoRoot);
                        throw new DocumentException(error);
                    }
                }

                Logger.LogInfo($"TOC file {href} inside {item.Href} is used", file: model.LocalPathFromRepoRoot);
                item.Href = href;
                item.OriginalHref = item.Href;
            }

            // Set default homepage
            SetDefaultHomepage(item, originalTocFile, model);
        }
示例#13
0
 private static IEnumerable<YamlHtmlPart> MarkupMultiple(IHostService host, string markdown, FileAndType ft)
 {
     try
     {
         var html = host.Markup(markdown, ft, true);
         var parts = YamlHtmlPart.SplitYamlHtml(html);
         foreach (var part in parts)
         {
             var mr = host.Parse(part.ToMarkupResult(), ft);
             part.Conceptual = mr.Html;
             part.LinkToFiles = mr.LinkToFiles;
             part.LinkToUids = mr.LinkToUids;
             part.YamlHeader = mr.YamlHeader;
             part.FileLinkSources = mr.FileLinkSources;
             part.UidLinkSources = mr.UidLinkSources;
         }
         return parts;
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Fail("Markup failed!");
         var message = $"Markup failed: {ex.Message}.";
         Logger.LogError(message);
         throw new DocumentException(message, ex);
     }
 }
示例#14
0
        private void BuildCore(TocItemViewModel item, FileModel model, IHostService hostService)
        {
            if (item == null)
            {
                return;
            }

            var linkToUids = new HashSet<string>();
            var linkToFiles = new HashSet<string>();
            if (Utility.IsSupportedRelativeHref(item.Href))
            {
                linkToFiles.Add(ParseFile(item.Href));
            }

            if (Utility.IsSupportedRelativeHref(item.Homepage))
            {
                linkToFiles.Add(ParseFile(item.Homepage));
            }

            if (!string.IsNullOrEmpty(item.TopicUid))
            {
                linkToUids.Add(item.TopicUid);
            }

            model.LinkToUids = model.LinkToUids.Union(linkToUids);
            model.LinkToFiles = model.LinkToFiles.Union(linkToFiles);

            if (item.Items != null)
            {
                foreach (var i in item.Items)
                {
                    BuildCore(i, model, hostService);
                }
            }
        }
示例#15
0
        private string _sourceCopyPath; //用于文件复制

        #endregion Fields

        #region Constructors

        public FileManagerControl(IHostService hostService, ShellStruct data)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;
            treeView_Dirs.AfterSelect += treeView_File_AfterSelect;
            listView_File.DragEnter += listView_File_DragEnter;
            listView_File.DragDrop += listView_File_DragDrop;
            listView_File.DoubleClick += listView_File_DoubleClick;
            listView_File.AfterEditSubItem += listView_File_AfterEditSubItem;
            listView_File.EditSubItemCompleted += listView_File_EditSubItemCompleted;
            rightMenu_FileManager.Opening += rightMenu_FileManager_Opening;

            this._hostService = hostService;
            this._shellData = data;

            _fileManager = new FileManagerService(_hostService, _shellData);
            _fileManager.GetWwwRootPathCompletedToDo += fileManager_GetWwwRootPathCompletedToDo;
            _fileManager.DeleteFileOrDirCompletedToDo += fileManager_DeleteFileOrDirCompletedToDo;
            _fileManager.GetFileTreeCompletedToDo += fileManager_GetFileTreeCompletedToDo;
            _fileManager.RenameFileOrDirCompletedToDo += fileManager_RenameFileOrDirCompletedToDo;
            _fileManager.CopyFileOrDirCompletedToDo += fileManager_CopyFileOrDirCompletedToDo;
            _fileManager.ModifyFileOrDirTimeCompletedToDo += fileManager_ModifyFileOrDirTimeCompletedToDo;
            _fileManager.CreateDirCompletedToDo += fileManager_CreateDirCompletedToDo;
            _fileManager.WgetCompletedToDo += fileManager_WgetCompletedToDo;

            //获取根路径
            _fileManager.GetWwwRootPath();
        }
 public IEnumerable<ItemViewModel> GetItemsFromOverwriteDocument(FileModel fileModel, string uid, IHostService host)
 {
     return OverwriteDocumentReader.Transform<ItemViewModel>(
         fileModel,
         uid,
         s => BuildManagedReferenceDocument.BuildItem(host, s, fileModel, content => content != null && content.Trim() == Constants.ContentPlaceholder));
 }
示例#17
0
 private void ApplyOverrides(ImmutableList<FileModel> models, IHostService host)
 {
     foreach (var uid in host.GetAllUids())
     {
         var ms = host.LookupByUid(uid);
         var od = ms.SingleOrDefault(m => m.Type == DocumentType.Override);
         if (od != null)
         {
             var ovm = ((List<ItemViewModel>)od.Content).Single(vm => vm.Uid == uid);
             foreach (
                 var pair in
                     from model in ms
                     where model.Type == DocumentType.Article
                     from item in ((PageViewModel)model.Content).Items
                     where item.Uid == uid
                     select new { model, item })
             {
                 var vm = pair.item;
                 // todo : fix file path
                 Merger.Merge(ref vm, ovm);
                 ((HashSet<string>)pair.model.Properties.LinkToUids).UnionWith((HashSet<string>)od.Properties.LinkToUids);
                 ((HashSet<string>)pair.model.Properties.LinkToFiles).UnionWith((HashSet<string>)od.Properties.LinkToFiles);
             }
         }
     }
 }
示例#18
0
 public override void Build(FileModel model, IHostService host)
 {
     if (model.Type != DocumentType.Article && model.Type != DocumentType.Resource)
     {
         throw new NotSupportedException();
     }
     // todo : metadata.
 }
示例#19
0
 public override IEnumerable<FileModel> Postbuild(ImmutableList<FileModel> models, IHostService host)
 {
     if (models.Count > 0)
     {
         ApplyOverrides(models, host);
     }
     return models;
 }
示例#20
0
 public VMListController(
     IHostService hostService, 
     IMonitoringService monitoringService, 
     IRememberService rememberService)
 {
     this.hostService = hostService;
     this.monitoringService = monitoringService;
     this.rememberService = rememberService;
 }
示例#21
0
        private void UpdateRelativePathAndAddTocMap(TocViewModel toc, FileModel model, HashSet<string> links, Dictionary<string, HashSet<string>> tocMap, IHostService hostService)
        {
            if (toc == null) return;
            var file = model.File;
            var originalFile = model.OriginalFileAndType.File;
            foreach (var item in toc)
            {
                if (PathUtility.IsRelativePath(item.Href))
                {
                    // Special handle for folder ends with '/'
                    FileAndType originalTocFile = null;

                    string fileName = Path.GetFileName(item.Href);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        var href = item.Href + "toc.yml";
                        var absHref = (RelativePath)file + (RelativePath)href;
                        string tocPath = absHref.GetPathFromWorkingFolder();
                        if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                        {
                            href = item.Href + "toc.md";
                            absHref = (RelativePath)file + (RelativePath)href;
                            tocPath = absHref.GetPathFromWorkingFolder();
                            if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                            {
                                var error = $"Unable to find either toc.yml or toc.md inside {item.Href}. Make sure the file is included in config file docfx.json!";
                                Logger.LogError(error, file: model.LocalPathFromRepoRoot);
                                throw new DocumentException(error);
                            }
                        }

                        Logger.LogInfo($"TOC file {href} inside {item.Href} is used", file: model.LocalPathFromRepoRoot);
                        item.Href = href;
                        item.OriginalHref = item.Href;
                    }

                    // Add toc.yml to tocMap before change item.Href to home page
                    item.Href = ((RelativePath)file + (RelativePath)item.Href).GetPathFromWorkingFolder();
                    if (item.OriginalHref != null) item.OriginalHref = ((RelativePath)file + (RelativePath)item.OriginalHref).GetPathFromWorkingFolder();

                    HashSet<string> value;
                    if (tocMap.TryGetValue(item.Href, out value))
                    {
                        value.Add(originalFile);
                    }
                    else
                    {
                        tocMap[item.Href] = new HashSet<string>(FilePathComparer.OSPlatformSensitiveComparer) { originalFile };
                    }
                    links.Add(item.Href);

                    SetHomepage(item, originalTocFile, model);
                }

                UpdateRelativePathAndAddTocMap(item.Items, model, links, tocMap, hostService);
            }
        }
示例#22
0
        public MyFirstPlugin(IHostService host, ShellStruct data)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;

            _host = host;
            _shellData = data;

            ShowShellTypeDataInLable(_shellData);
        }
示例#23
0
        public TrayIcon()
        {
            InitializeComponent();
            hostService = Program.GetHostService();
            alertList = Program.GetAlertList();
            initRunOnStartup();

            //Event handlers
            notifyIcon1.BalloonTipClicked += new EventHandler(notifyIcon1_BalloonTipClicked);
        }
示例#24
0
        public ShellCmderControl(IHostService hostService, ShellStruct data)
        {
            InitializeComponent();
            this.Dock = System.Windows.Forms.DockStyle.Fill;
            this._hostService = hostService;
            this._shellData = data;

            shellTextBox_Cmder.CommandEntered+=shellTextBox_Cmder_CommandEntered;
            shellTextBox_Cmder.Prompt = "SECTools";
            ConnectOneShell();
        }
示例#25
0
 public void Build(FileModel model, IHostService host)
 {
     model.File = Path.ChangeExtension(model.File, ".json");
     var toc = (TocViewModel)model.Content;
     HashSet<string> links = new HashSet<string>();
     Dictionary<string, HashSet<string>> tocMap = new Dictionary<string, HashSet<string>>();
     UpdateRelativePathAndAddTocMap(toc, model, links, tocMap, host);
     model.Properties.LinkToFiles = links.ToImmutableArray();
     model.Properties.TocMap = tocMap.ToImmutableDictionary();
     // todo : metadata.
 }
 private string Markup(IHostService host, string markdown, FileModel model)
 {
     if (string.IsNullOrEmpty(markdown))
     {
         return markdown;
     }
     var mr = host.Markup(markdown, model.FileAndType);
     ((HashSet<string>)model.Properties.LinkToFiles).UnionWith(mr.LinkToFiles);
     ((HashSet<string>)model.Properties.LinkToUids).UnionWith(mr.LinkToUids);
     return mr.Html;
 }
 private static MergeItem CreateMergeItem(string majorUid, FileModel model, IHostService host)
 {
     var vm = (PageViewModel)model.Content;
     var majorItem = vm.Items.Find(item => item.Uid == majorUid);
     if (majorItem == null)
     {
         host.LogError("Cannot find uid in model.", file: model.File);
         return null;
     }
     return CreateMergeItemCore(majorItem, vm);
 }
示例#28
0
 public override IEnumerable<FileModel> Postbuild(ImmutableList<FileModel> models, IHostService host)
 {
     foreach (var model in models)
     {
         if (model.Type == DocumentType.Article)
         {
             var content = (Dictionary<string, object>)model.Content;
             content["wordCount"] = WordCounter.CountWord((string)content["conceptual"]);
         }
     }
     return models;
 }
示例#29
0
        public override void Build(FileModel model, IHostService host)
        {
            if (model.Type != DocumentType.Article)
            {
                return;
            }
            var content = (Dictionary<string, object>)model.Content;
            var markdown = (string)content[ConceputalKey];
            var result = host.Markup(markdown, model.FileAndType);

            var htmlInfo = SeperateHtml(result.Html);
            content["title"] = htmlInfo.Title;
            content["rawTitle"] = htmlInfo.RawTitle;
            content[ConceputalKey] = htmlInfo.Content;

            if (result.YamlHeader != null && result.YamlHeader.Count > 0)
            {
                foreach (var item in result.YamlHeader)
                {
                    if (item.Key == "uid")
                    {
                        var uid = item.Value as string;
                        if (!string.IsNullOrWhiteSpace(uid))
                        {
                            model.Uids = new[] { uid }.ToImmutableArray();
                            content["uid"] = item.Value;
                        }
                    }
                    else
                    {
                        content[item.Key] = item.Value;
                        if (item.Key == DocumentTypeKey)
                        {
                            model.DocumentType = item.Value as string;
                        }
                    }
                }
            }
            model.Properties.LinkToFiles = result.LinkToFiles;
            model.Properties.LinkToUids = result.LinkToUids;
            model.Properties.XrefSpec = null;
            if (model.Uids.Length > 0)
            {
                model.Properties.XrefSpec = new XRefSpec
                {
                    Uid = model.Uids[0],
                    Name = TitleThumbnail(content["title"].ToString() ?? model.Uids[0], TitleThumbnailMaxLength),
                    Href = ((RelativePath)model.File).GetPathFromWorkingFolder()
                };
            }
            model.File = Path.ChangeExtension(model.File, ".json");
        }
示例#30
0
 public override void Postbuild(ImmutableList<FileModel> models, IHostService host)
 {
     if (models.Count > 0)
     {
         foreach (var model in models)
         {
             if (model.Type != DocumentType.Article)
             {
                 continue;
             }
             FillCore((PageViewModel)model.Content, host);
         }
     }
 }