예제 #1
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //var button = (MenuCommand)sender;
            // 右键点击后选中的文件(一般是一个,但也可以多个)
            var items = ProjectHelpers.GetSelectedItemPaths();

            if (items.Count() == 0)
            {
                ErrBox.Info(this.package, "未选中文件!"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                ErrBox.Info(this.package, "未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                ErrBox.Info(this.package, res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>();

            foreach (string path in items)
            {
                // 可能选中的是目录
                if (File.Exists(path))
                {
                    srcfiles.Add(path);
                }
            }
            if (srcfiles.Count == 0)
            {
                ErrBox.Info(this.package, "至少选择一个文件!");
                return;
            }
            // 发布处理
            string resinfo = PublishHelpers.PublishFiles(srcfiles);

            if (resinfo != null)
            {
                ErrBox.Info(this.package, resinfo);
            }
        }
예제 #2
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //var button = (MenuCommand)sender;
            // 右键点击后选中的文件夹(一般是一个,但也可以多个)
            var selectedDirs = ProjectHelpers.GetSelectedItemPaths();
            if (selectedDirs.Count() == 0)
            {
                ErrBox.Info(this.package, "未选中文件夹!"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();
            if (activeProj == null)
            {
                ErrBox.Info(this.package, "未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();
            if (res != null)
            {
                ErrBox.Info(this.package, res); return;
            }

            // 取得要发布的文件路径 
            List<string> srcfiles = new List<string>();
            foreach (string dirPath in selectedDirs)
            {
                // 选中的可能是文件和目录,如果是目录才取出其中文件和子目录文件
                if (Directory.Exists(dirPath))
                    srcfiles.AddRange(Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories));
            }
            if (srcfiles.Count == 0)
            {
                ErrBox.Info(this.package, "至少选择一个文件夹!");
                return;
            }
            // 发布处理
            string resinfo = PublishHelpers.PublishFiles(srcfiles);
            if (resinfo != null)
            {
                ErrBox.Info(this.package, resinfo);
            }
        }
예제 #3
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            // 发布当前处于活动状态的1个文件 如果没有活动文件,不动作
            var activedoc = ProjectHelpers.GetActiveDoc();

            if (activedoc == null)
            {
                ErrBox.Info(this.package, "未找到激活的文件"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                ErrBox.Info(this.package, "未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                ErrBox.Info(this.package, res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>
            {
                activedoc.FullName
            };
            // 发布处理
            string resinfo = PublishHelpers.PublishFiles(srcfiles);

            if (resinfo != null)
            {
                ErrBox.Info(this.package, resinfo);
            }
        }