コード例 #1
0
ファイル: AppImport.ascx.cs プロジェクト: BravoSierra/2sxc
        protected void ImportFromStream(Stream importStream)
        {
            var messages = new List<ExportImportMessage>();
            var success = false;

            success = new ZipImport(ZoneId.Value, null, UserInfo.IsSuperUser).ImportApp(importStream, Server, PortalSettings, messages);

            lstvSummary.DataSource = messages;
            lstvSummary.DataBind();
            pnlSummary.Visible = true;
            pnlUpload.Visible = false;
        }
コード例 #2
0
        public HttpResponseMessage InstallPackage(string packageUrl)
        {
            var zoneId = SexyContent.GetZoneID(ActiveModule.PortalID);
            var appId = SexyContent.GetAppIdFromModule(ActiveModule);
            bool success;

            // Install package
            var messages = new List<ExportImportMessage>();
            try
            {
                success = new ZipImport(zoneId.Value, appId, PortalSettings.UserInfo.IsSuperUser).ImportZipFromUrl(
                    packageUrl, messages, ActiveModule.DesktopModule.ModuleName == "2sxc-app");
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                throw new Exception("An error occurred while installing the app: " + ex.Message, ex);
            }

            return Request.CreateResponse(success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError, new { success, messages });
        }
コード例 #3
0
ファイル: Import.ascx.cs プロジェクト: BravoSierra/2sxc
        protected void ImportFromStream(Stream importStream, bool isZip)
        {
            var messages = new List<ExportImportMessage>();
            var success = false;

            if (isZip)
            {
                success = new ZipImport(ZoneId.Value, AppId.Value, UserInfo.IsSuperUser).ImportZip(importStream, Server, PortalSettings, messages);
            }
            else
            {
                var xml = new StreamReader(importStream).ReadToEnd();
                var doc = XDocument.Parse(xml);
                var import = new XmlImport(PortalSettings.Current.DefaultLanguage, PortalSettings.Current.UserInfo.Username);
                success = import.ImportXml(ZoneId.Value, AppId.Value, doc);
                messages = import.ImportLog;
            }

            lstvSummary.DataSource = messages;
            lstvSummary.DataBind();
            pnlSummary.Visible = true;
            pnlUpload.Visible = false;
        }
コード例 #4
0
ファイル: ImportExportController.cs プロジェクト: 2sic/2sxc
        public ImportResult ImportContent()
        {
            var result = new ImportResult();

            var request = HttpContext.Current.Request;

            var allowSystemChanges = UserInfo.IsSuperUser;

            var appId = int.Parse(request["AppId"]);
            var zoneId = int.Parse(request["ZoneId"]);
            if (request.Files.Count > 0)
            {
                var file = request.Files[0];
                if (file.FileName.EndsWith(".zip"))
                {   // ZIP
                    var zipImport = new ZipImport(zoneId, appId, PortalSettings.UserInfo.IsSuperUser);
                    result.Succeeded = zipImport.ImportZip(file.InputStream, HttpContext.Current.Server, PortalSettings, result.Messages);
                }
                else
                {   // XML
                    using (var fileStreamReader = new StreamReader(file.InputStream))
                    {
                        var xmlImport = new XmlImport(PortalSettings.DefaultLanguage, UserIdentity.CurrentUserIdentityToken, allowSystemChanges);
                        var xmlDocument = XDocument.Parse(fileStreamReader.ReadToEnd());
                        result.Succeeded = xmlImport.ImportXml(zoneId, appId, xmlDocument);
                        result.Messages = xmlImport.ImportLog;
                    }
                }
            }
            return result;
        }
コード例 #5
0
ファイル: ImportExportController.cs プロジェクト: 2sic/2sxc
        public ImportResult ImportApp()
        {
            var result = new ImportResult();

            var request = HttpContext.Current.Request;

            //var appId   = int.Parse(request["AppId"]);
            var zoneId  = int.Parse(request["ZoneId"]);
            if (request.Files.Count > 0)
            {
                var zipImport = new ZipImport(zoneId, null, PortalSettings.UserInfo.IsSuperUser);
                result.Succeeded = zipImport.ImportApp(request.Files[0].InputStream, HttpContext.Current.Server, PortalSettings, result.Messages);
            }
            return result;
        }