public IHttpActionResult Download()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.PluginsPermissions.Add))
                {
                    return(Unauthorized());
                }

                var packageId = request.GetPostString("packageId");
                var version   = request.GetPostString("version");

                if (!StringUtils.EqualsIgnoreCase(packageId, PackageUtils.PackageIdSiteServerPlugin))
                {
                    try
                    {
                        PackageUtils.DownloadPackage(packageId, version);
                    }
                    catch
                    {
                        PackageUtils.DownloadPackage(packageId, version);
                    }
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 2
0
        public IHttpActionResult Main()
        {
            var request = new AuthenticatedRequest();

            if (!request.IsAdminLoggin)
            {
                return(Unauthorized());
            }

            var packageId = request.GetPostString("packageId");
            var version   = request.GetPostString("version");

            try
            {
                PackageUtils.DownloadPackage(packageId, version);
            }
            catch
            {
                PackageUtils.DownloadPackage(packageId, version);
            }

            if (StringUtils.EqualsIgnoreCase(packageId, PackageUtils.PackageIdSsCms))
            {
                CacheDbUtils.RemoveAndInsert(PackageUtils.CacheKeySsCmsIsDownload, true.ToString());
            }

            return(Ok());
        }
Ejemplo n.º 3
0
        public IHttpActionResult Main()
        {
            var request = new AuthRequest();

            if (!request.IsAdminLoggin)
            {
                return(Unauthorized());
            }

            var packageId = request.GetPostString("packageId");
            var version   = request.GetPostString("version");

            PackageUtils.DownloadPackage(packageId, version);

            return(Ok());
        }
Ejemplo n.º 4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _pluginId  = Body.GetQueryString("pluginId");
            _returnUrl = Body.GetQueryString("returnUrl");

            if (Body.IsQueryExists("install"))
            {
                var version = Body.GetQueryString("version");

                string errorMessage;

                PackageUtils.DownloadPackage(_pluginId, version);

                var idWithVersion = $"{_pluginId}.{version}";
                if (!PackageUtils.UpdatePackage(idWithVersion, false, out errorMessage))
                {
                    FailMessage(errorMessage);
                    return;
                }

                PluginManager.ClearCache();
                Body.AddAdminLog("安装插件", $"插件:{_pluginId}");

                AddScript(AlertUtils.Success("插件安装成功", "插件安装成功,系统需要重载页面", "重新载入", "window.top.location.reload();"));
            }
            else if (Body.IsQueryExists("update"))
            {
                PageUtils.Redirect(PageUpdate.GetRedirectUrl());
            }

            if (Page.IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.Permissions.Plugins.Add, ConfigManager.Permissions.Plugins.Management);
        }
Ejemplo n.º 5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (TranslateUtils.ToBool(RblInstallType.SelectedValue))
            {
                if (HifFile.PostedFile == null || HifFile.PostedFile.FileName == "")
                {
                    return;
                }

                var filePath = HifFile.PostedFile.FileName;
                if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".nupkg"))
                {
                    FailMessage("必须上传后缀为.nupkg的文件");
                    return;
                }

                var idAndVersion  = Path.GetFileNameWithoutExtension(filePath);
                var directoryPath = PathUtils.GetPackagesPath(idAndVersion);
                var localFilePath = PathUtils.Combine(directoryPath, idAndVersion + ".nupkg");

                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }

                HifFile.PostedFile.SaveAs(localFilePath);

                ZipUtils.ExtractZip(localFilePath, directoryPath);

                string errorMessage;
                if (!PackageUtils.UpdatePackage(idAndVersion, PackageType.Plugin, out errorMessage))
                {
                    FailMessage($"手动安装插件失败:{errorMessage}");
                    return;
                }

                AuthRequest.AddAdminLog("手动安装插件:" + idAndVersion);

                LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
            }
            else
            {
                string errorMessage;
                try
                {
                    PackageUtils.DownloadPackage(TbPluginId.Text, TbVersion.Text);
                }
                catch (Exception ex)
                {
                    FailMessage($"手动安装插件失败:{ex.Message}");
                    return;
                }

                var idWithVersion = $"{TbPluginId.Text}.{TbVersion.Text}";
                if (!PackageUtils.UpdatePackage(idWithVersion, PackageType.Plugin, out errorMessage))
                {
                    FailMessage($"手动安装插件失败:{errorMessage}");
                    return;
                }

                AuthRequest.AddAdminLog($"手动安装插件:{TbPluginId.Text} {TbVersion.Text}");

                LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
            }
        }