コード例 #1
0
        private byte[] GetLanguagePackManifest(LocaleFilePack ResourcePack)
        {
            byte[]        manifest           = null;
            XmlSerializer manifestSerializer = new XmlSerializer(typeof(LocaleFilePack));
            MemoryStream  ms = new MemoryStream();

            try
            {
                manifestSerializer.Serialize(ms, ResourcePack);
                manifest    = new byte[(((int)(ms.Length - 1)) + 1)];
                ms.Position = 0L;
                ms.Read(manifest, 0, ((int)ms.Length));
                this.ProgressLog.AddInfo(Localization.GetString("LOG.LangPack.SerializeManifest"));
                return(manifest);
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                this.ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.ManifestFile"), ex));
                return(manifest);
            }

            finally
            {
                ms.Close();
            }
        }
コード例 #2
0
        public string SaveLanguagePack(Locale LocaleCulture, LanguagePackType packtype, ArrayList basefolders, string FileName)
        {
            string         Result;
            LocaleFilePack ResPack = new LocaleFilePack();

            ResPack.Version           = "3.0";
            ResPack.LocalePackCulture = LocaleCulture;

            switch (packtype)
            {
            case LanguagePackType.Core:

                ProcessCoreFiles(ResPack);
                break;

            case LanguagePackType.Module:

                ProcessModuleFiles(ResPack, basefolders);
                break;

            case LanguagePackType.Provider:

                ProcessProviderFiles(ResPack, basefolders);
                break;

            case LanguagePackType.Full:

                ProcessCoreFiles(ResPack);
                ProcessModuleFiles(ResPack);
                ProcessProviderFiles(ResPack);
                break;
            }

            ProgressLog.StartJob(Localization.GetString("LOG.LangPack.ArchiveFiles"));
            Result = CreateResourcePack(ResPack, FileName, packtype);
            ProgressLog.EndJob(Localization.GetString("LOG.LangPack.ArchiveFiles"));

            // log installation event
            try
            {
                LogInfo objEventLogInfo = new LogInfo();
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLogInfo.LogProperties.Add(new LogDetailInfo("Install Language Pack:", FileName));
                PaLogEntry objLogEntry;
                foreach (PaLogEntry tempLoopVar_objLogEntry in ProgressLog.Logs)
                {
                    objLogEntry = tempLoopVar_objLogEntry;
                    objEventLogInfo.LogProperties.Add(new LogDetailInfo("Info:", objLogEntry.Description));
                }
                EventLogController objEventLog = new EventLogController();
                objEventLog.AddLog(objEventLogInfo);
            }
            catch (Exception)
            {
                // error
            }

            return(Result);
        }
コード例 #3
0
 private void ProcessModuleFiles(LocaleFilePack ResPack, ArrayList basefolders)
 {
     this.ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Module")));
     foreach (string f in basefolders)
     {
         this.GetResourceFiles(ResPack.Files, (this.GetServerPath("~/desktopmodules/") + f), this.GetServerPath("~/desktopmodules"), ResPack.LocalePackCulture.Code, LocaleType.LocalResource);
     }
     this.ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Module")));
 }
コード例 #4
0
 private void ProcessProviderFiles(LocaleFilePack ResPack, ArrayList basefolders)
 {
     this.ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Provider")));
     foreach (string string1 in basefolders)
     {
         this.GetResourceFiles(ResPack.Files, (this.GetServerPath("~/providers/HtmlEditorProviders/") + string1), this.GetServerPath("~/providers"), ResPack.LocalePackCulture.Code, LocaleType.ProviderResource);
     }
     this.ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Provider")));
 }
コード例 #5
0
        protected void SaveLocaleFiles(LocaleFilePack LangPack)
        {
            string GlobalResourceDirectory  = HttpContext.Current.Server.MapPath(Localization.ApplicationResourceDirectory);
            string ControlResourceDirectory = HttpContext.Current.Server.MapPath("~/controls/" + Localization.LocalResourceDirectory);
            string ProviderDirectory        = HttpContext.Current.Server.MapPath("~/providers/");

            string AdminResourceRootDirectory = HttpContext.Current.Server.MapPath("~/Admin");
            string LocalResourceRootDirectory = HttpContext.Current.Server.MapPath("~/DesktopModules");

            foreach (LocaleFileInfo LocaleFile in LangPack.Files)
            {
                ProgressLog.AddInfo(string.Format(LOG_LangPack_ImportFiles, LocaleFile.LocaleFileName));
                switch (LocaleFile.LocaleFileType)
                {
                case LocaleType.ControlResource:

                    FileSystemUtils.SaveFile(Path.Combine(ControlResourceDirectory, LocaleFile.LocaleFileName), LocaleFile.Buffer);
                    break;

                case LocaleType.GlobalResource:

                    FileSystemUtils.SaveFile(Path.Combine(GlobalResourceDirectory, LocaleFile.LocaleFileName), LocaleFile.Buffer);
                    break;

                case LocaleType.AdminResource:

                    FileSystemUtils.SaveFile(GetFullLocaleFileName(AdminResourceRootDirectory, LocaleFile), LocaleFile.Buffer);
                    break;

                case LocaleType.LocalResource:

                    try
                    {
                        FileSystemUtils.SaveFile(GetFullLocaleFileName(LocalResourceRootDirectory, LocaleFile), LocaleFile.Buffer);
                    }
                    catch (Exception)
                    {
                        ProgressLog.AddInfo(string.Format(LOG_LangPack_ModuleWarning, LocaleFile.LocaleFileName, LocaleFile.LocaleModule));
                    }
                    break;

                case LocaleType.ProviderResource:

                    try
                    {
                        FileSystemUtils.SaveFile(GetFullLocaleFileName(ProviderDirectory, LocaleFile), LocaleFile.Buffer);
                    }
                    catch (Exception)
                    {
                        ProgressLog.AddInfo(string.Format(LOG_LangPack_ModuleWarning, LocaleFile.LocaleFileName, LocaleFile.LocaleModule));
                    }
                    break;
                }
            }
        }
コード例 #6
0
        private void ProcessCoreFiles(LocaleFilePack ResPack)
        {
            // Global files
            ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Global")));
            GetGlobalResourceFiles(ResPack.Files, ResPack.LocalePackCulture.Code);
            ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Global")));

            // Controls files
            ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Control")));
            GetResourceFiles(ResPack.Files, GetServerPath("~/Controls"), GetServerPath("~/Controls"), ResPack.LocalePackCulture.Code, LocaleType.ControlResource);
            ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Control")));

            // Admin files
            ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Admin")));
            GetResourceFiles(ResPack.Files, GetServerPath("~/Admin"), GetServerPath("~/Admin"), ResPack.LocalePackCulture.Code, LocaleType.AdminResource);
            ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Admin")));
        }
コード例 #7
0
        protected void LoadLocaleFilesFromZip(LocaleFilePack LangPack, Stream LangPackStream)
        {
            LangPackStream.Position = 0;
            ZipInputStream unzip = new ZipInputStream(LangPackStream);

            try
            {
                ZipEntry entry = unzip.GetNextEntry();

                while (!(entry == null))
                {
                    if (entry.Name.ToLower() != "manifest.xml" && (!entry.IsDirectory))
                    {
                        LocaleFileInfo LocaleFile = LangPack.Files.LocaleFile(entry.Name);
                        if (LocaleFile != null)
                        {
                            ProgressLog.AddInfo(string.Format(LOG_LangPack_LoadFiles, LocaleFile.LocaleFileName));
                            LocaleFile.Buffer = new byte[Convert.ToInt32(entry.Size) - 1 + 1];
                            int size = 0;
                            while (size < LocaleFile.Buffer.Length)
                            {
                                size += unzip.Read(LocaleFile.Buffer, size, LocaleFile.Buffer.Length - size);
                            }
                            if (size != LocaleFile.Buffer.Length)
                            {
                                throw (new Exception(EXCEPTION_FileRead + LocaleFile.Buffer.Length + "/" + size));
                            }
                        }
                        else
                        {
                            ProgressLog.AddInfo(string.Format(EXCEPTION_LangPack_FileMissing, entry.Name));
                        }
                    }
                    entry = unzip.GetNextEntry();
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(EXCEPTION_LangPack_ResourceLoad, ex.Message));
            }
        }
コード例 #8
0
        protected LocaleFilePack GetLanguagePack(string Manifest)
        {
            XmlSerializer  ManifestSerializer = new XmlSerializer(typeof(LocaleFilePack));
            LocaleFilePack LanguagePack       = null;

            try
            {
                StringReader  ManifestXML = new StringReader(Manifest);
                XmlTextReader XMLText     = new XmlTextReader(ManifestXML);
                LanguagePack = ((LocaleFilePack)ManifestSerializer.Deserialize(XMLText));
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(EXCEPTION_LangPack_ManifestLoad, ex.Message));
            }
            finally
            {
            }

            return(LanguagePack);
        }
コード例 #9
0
        public PaLogger Install(Stream FileStrm)
        {
            string Manifest;

            try
            {
                FileStrm.Position = 0;

                ProgressLog.StartJob(LOG_LangPack_Job_LoadManifest);
                Manifest = Encoding.UTF8.GetString(GetLanguagePackManifest(FileStrm));
                ProgressLog.EndJob(LOG_LangPack_Job_LoadManifest);

                ProgressLog.StartJob(LOG_LangPack_Job_DeserializeManifest);
                LocaleFilePack LanguagePack = GetLanguagePack(Manifest);
                ProgressLog.EndJob(LOG_LangPack_Job_DeserializeManifest);

                ProgressLog.StartJob(LOG_LangPack_Job_LoadFiles);
                LoadLocaleFilesFromZip(LanguagePack, FileStrm);
                ProgressLog.EndJob(LOG_LangPack_Job_LoadFiles);

                ProgressLog.StartJob(LOG_LangPack_Job_ImportFiles);
                SaveLocaleFiles(LanguagePack);
                ProgressLog.EndJob(LOG_LangPack_Job_ImportFiles);

                ProgressLog.StartJob(LOG_LangPack_Job_CreateLocale);
                CreateLocale(LanguagePack.LocalePackCulture);
                ProgressLog.EndJob(LOG_LangPack_Job_CreateLocale);
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(EXCEPTION_LangPack_Install, ex.Message));
            }

            return(ProgressLog);
        }
コード例 #10
0
 private void ProcessProviderFiles( LocaleFilePack ResPack, ArrayList basefolders )
 {
     this.ProgressLog.StartJob( string.Format( Localization.GetString( "LOG.LangPack.LoadFiles" ), Localization.GetString( "LOG.LangPack.Provider" ) ) );
     foreach( string string1 in basefolders )
     {
         this.GetResourceFiles( ResPack.Files, ( this.GetServerPath( "~/providers/HtmlEditorProviders/" ) + string1 ), this.GetServerPath( "~/providers" ), ResPack.LocalePackCulture.Code, LocaleType.ProviderResource );
     }
     this.ProgressLog.EndJob( string.Format( Localization.GetString( "LOG.LangPack.LoadFiles" ), Localization.GetString( "LOG.LangPack.Provider" ) ) );
 }
コード例 #11
0
        private string CreateResourcePack( LocaleFilePack ResourcePack, string FileName, LanguagePackType packtype )
        {
            int CompressionLevel = 9;
            int BlockSize = 4096;
            string ResPackName;
            string ResPackShortName;
            ResPackShortName = "ResourcePack." + FileName + ".";
            if (packtype == LanguagePackType.Core || packtype == LanguagePackType.Full)
            {
                ResPackShortName += Globals.glbAppVersion + ".";
            }
            ResPackShortName += ResourcePack.LocalePackCulture.Code + ".zip";
            ResPackName = Globals.HostMapPath + ResPackShortName;

            FileStream strmZipFile = null;
            try
            {
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.CreateArchive"), ResPackShortName));
                strmZipFile = File.Create(ResPackName);
                ZipOutputStream strmZipStream = null;
                try
                {
                    strmZipStream = new ZipOutputStream(strmZipFile);

                    ZipEntry myZipEntry;
                    myZipEntry = new ZipEntry("Manifest.xml");

                    strmZipStream.PutNextEntry(myZipEntry);
                    strmZipStream.SetLevel(CompressionLevel);

                    byte[] FileData = GetLanguagePackManifest(ResourcePack);

                    strmZipStream.Write(FileData, 0, FileData.Length);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.SavedFile"), "Manifest.xml"));

                    foreach (LocaleFileInfo LocaleFile in ResourcePack.Files)
                    {
                        myZipEntry = new ZipEntry(LocaleFileUtil.GetFullFileName(LocaleFile));
                        strmZipStream.PutNextEntry(myZipEntry);
                        strmZipStream.Write(LocaleFile.Buffer, 0, LocaleFile.Buffer.Length);
                        ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.SavedFile"), LocaleFile.LocaleFileName));
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.Exceptions.LogException(ex);
                    ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.SavingFile"), ex));
                }
                finally
                {
                    if (strmZipStream != null)
                    {
                        strmZipStream.Finish();
                        strmZipStream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.SavingFile"), ex));
            }
            finally
            {
                if (strmZipFile != null)
                {
                    strmZipFile.Close();
                }
            }

            return ResPackName;
        }
コード例 #12
0
 private void ProcessModuleFiles( LocaleFilePack ResPack, ArrayList basefolders )
 {
     this.ProgressLog.StartJob( string.Format( Localization.GetString( "LOG.LangPack.LoadFiles" ), Localization.GetString( "LOG.LangPack.Module" ) ) );
     foreach( string f in basefolders )
     {
         this.GetResourceFiles( ResPack.Files, ( this.GetServerPath( "~/desktopmodules/" ) + f ), this.GetServerPath( "~/desktopmodules" ), ResPack.LocalePackCulture.Code, LocaleType.LocalResource );
     }
     this.ProgressLog.EndJob( string.Format( Localization.GetString( "LOG.LangPack.LoadFiles" ), Localization.GetString( "LOG.LangPack.Module" ) ) );
 }
コード例 #13
0
 private void ProcessProviderFiles( LocaleFilePack ResPack )
 {
     this.ProgressLog.StartJob( string.Format( Localization.GetString( "LOG.LangPack.LoadFiles" ), Localization.GetString( "LOG.LangPack.Provider" ) ) );
     this.GetResourceFiles( ResPack.Files, this.GetServerPath( "~/providers" ), this.GetServerPath( "~/providers" ), ResPack.LocalePackCulture.Code, LocaleType.ProviderResource );
     this.ProgressLog.EndJob( string.Format( Localization.GetString( "LOG.LangPack.LoadFiles" ), Localization.GetString( "LOG.LangPack.Provider" ) ) );
 }
コード例 #14
0
        private void ProcessCoreFiles( LocaleFilePack ResPack )
        {

            // Global files
            ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Global")));
            GetGlobalResourceFiles(ResPack.Files, ResPack.LocalePackCulture.Code);
            ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Global")));

            // Controls files
            ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Control")));
            GetResourceFiles(ResPack.Files, GetServerPath("~/Controls"), GetServerPath("~/Controls"), ResPack.LocalePackCulture.Code, LocaleType.ControlResource);
            ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Control")));

            // Admin files
            ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Admin")));
            GetResourceFiles(ResPack.Files, GetServerPath("~/Admin"), GetServerPath("~/Admin"), ResPack.LocalePackCulture.Code, LocaleType.AdminResource);
            ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Admin")));
        }
コード例 #15
0
        public string SaveLanguagePack( Locale LocaleCulture, LanguagePackType packtype, ArrayList basefolders, string FileName )
        {
            string Result;
            LocaleFilePack ResPack = new LocaleFilePack();
            ResPack.Version = "3.0";
            ResPack.LocalePackCulture = LocaleCulture;

            switch (packtype)
            {
                case LanguagePackType.Core:

                    ProcessCoreFiles(ResPack);
                    break;

                case LanguagePackType.Module:

                    ProcessModuleFiles(ResPack, basefolders);
                    break;

                case LanguagePackType.Provider:

                    ProcessProviderFiles(ResPack, basefolders);
                    break;

                case LanguagePackType.Full:

                    ProcessCoreFiles(ResPack);
                    ProcessModuleFiles(ResPack);
                    ProcessProviderFiles(ResPack);
                    break;
            }

            ProgressLog.StartJob(Localization.GetString("LOG.LangPack.ArchiveFiles"));
            Result = CreateResourcePack(ResPack, FileName, packtype);
            ProgressLog.EndJob(Localization.GetString("LOG.LangPack.ArchiveFiles"));

            // log installation event
            try
            {
                LogInfo objEventLogInfo = new LogInfo();
                objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLogInfo.LogProperties.Add(new LogDetailInfo("Install Language Pack:", FileName));
                PaLogEntry objLogEntry;
                foreach (PaLogEntry tempLoopVar_objLogEntry in ProgressLog.Logs)
                {
                    objLogEntry = tempLoopVar_objLogEntry;
                    objEventLogInfo.LogProperties.Add(new LogDetailInfo("Info:", objLogEntry.Description));
                }
                EventLogController objEventLog = new EventLogController();
                objEventLog.AddLog(objEventLogInfo);
            }
            catch (Exception)
            {
                // error
            }

            return Result;
        }
コード例 #16
0
 private byte[] GetLanguagePackManifest( LocaleFilePack ResourcePack )
 {
     
     byte[] manifest = null;
     XmlSerializer manifestSerializer = new XmlSerializer( typeof( LocaleFilePack ) );
     MemoryStream ms = new MemoryStream();
     try
     {
         manifestSerializer.Serialize(ms, ResourcePack);
         manifest = new byte[(((int)(ms.Length - 1)) + 1)];
         ms.Position = 0L;
         ms.Read(manifest, 0, ((int)ms.Length));
         this.ProgressLog.AddInfo(Localization.GetString("LOG.LangPack.SerializeManifest"));
         return manifest;
     }
     catch (Exception ex)
     {
         
         Exceptions.Exceptions.LogException(ex);
         this.ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.ManifestFile"), ex));
         return manifest;
     }
     
     finally
     {
         ms.Close();
     }
     
 }
コード例 #17
0
 private void ProcessProviderFiles(LocaleFilePack ResPack)
 {
     this.ProgressLog.StartJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Provider")));
     this.GetResourceFiles(ResPack.Files, this.GetServerPath("~/providers"), this.GetServerPath("~/providers"), ResPack.LocalePackCulture.Code, LocaleType.ProviderResource);
     this.ProgressLog.EndJob(string.Format(Localization.GetString("LOG.LangPack.LoadFiles"), Localization.GetString("LOG.LangPack.Provider")));
 }
コード例 #18
0
        protected void LoadLocaleFilesFromZip(LocaleFilePack LangPack, Stream LangPackStream)
        {
            LangPackStream.Position = 0;
            ZipInputStream unzip = new ZipInputStream(LangPackStream);
            try
            {
                ZipEntry entry = unzip.GetNextEntry();

                while (!(entry == null))
                {
                    if (entry.Name.ToLower() != "manifest.xml" && (!entry.IsDirectory))
                    {
                        LocaleFileInfo LocaleFile = LangPack.Files.LocaleFile(entry.Name);
                        if (LocaleFile != null)
                        {
                            ProgressLog.AddInfo(string.Format(LOG_LangPack_LoadFiles, LocaleFile.LocaleFileName));
                            LocaleFile.Buffer = new byte[Convert.ToInt32(entry.Size) - 1 + 1];
                            int size = 0;
                            while (size < LocaleFile.Buffer.Length)
                            {
                                size += unzip.Read(LocaleFile.Buffer, size, LocaleFile.Buffer.Length - size);
                            }
                            if (size != LocaleFile.Buffer.Length)
                            {
                                throw (new Exception(EXCEPTION_FileRead + LocaleFile.Buffer.Length + "/" + size));
                            }
                        }
                        else
                        {
                            ProgressLog.AddInfo(string.Format(EXCEPTION_LangPack_FileMissing, entry.Name));
                        }
                    }
                    entry = unzip.GetNextEntry();
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(EXCEPTION_LangPack_ResourceLoad, ex.Message));
            }
        }
コード例 #19
0
        protected void SaveLocaleFiles(LocaleFilePack LangPack)
        {
            string GlobalResourceDirectory = HttpContext.Current.Server.MapPath(Localization.ApplicationResourceDirectory);
            string ControlResourceDirectory = HttpContext.Current.Server.MapPath("~/controls/" + Localization.LocalResourceDirectory);
            string ProviderDirectory = HttpContext.Current.Server.MapPath("~/providers/");

            string AdminResourceRootDirectory = HttpContext.Current.Server.MapPath("~/Admin");
            string LocalResourceRootDirectory = HttpContext.Current.Server.MapPath("~/DesktopModules");

            foreach (LocaleFileInfo LocaleFile in LangPack.Files)
            {
                ProgressLog.AddInfo(string.Format(LOG_LangPack_ImportFiles, LocaleFile.LocaleFileName));
                switch (LocaleFile.LocaleFileType)
                {
                    case LocaleType.ControlResource:

                        FileSystemUtils.SaveFile(Path.Combine(ControlResourceDirectory, LocaleFile.LocaleFileName), LocaleFile.Buffer);
                        break;

                    case LocaleType.GlobalResource:

                        FileSystemUtils.SaveFile(Path.Combine(GlobalResourceDirectory, LocaleFile.LocaleFileName), LocaleFile.Buffer);
                        break;

                    case LocaleType.AdminResource:

                        FileSystemUtils.SaveFile(GetFullLocaleFileName(AdminResourceRootDirectory, LocaleFile), LocaleFile.Buffer);
                        break;

                    case LocaleType.LocalResource:

                        try
                        {
                            FileSystemUtils.SaveFile(GetFullLocaleFileName(LocalResourceRootDirectory, LocaleFile), LocaleFile.Buffer);
                        }
                        catch (Exception)
                        {
                            ProgressLog.AddInfo(string.Format(LOG_LangPack_ModuleWarning, LocaleFile.LocaleFileName, LocaleFile.LocaleModule));
                        }
                        break;
                    case LocaleType.ProviderResource:

                        try
                        {
                            FileSystemUtils.SaveFile(GetFullLocaleFileName(ProviderDirectory, LocaleFile), LocaleFile.Buffer);
                        }
                        catch (Exception)
                        {
                            ProgressLog.AddInfo(string.Format(LOG_LangPack_ModuleWarning, LocaleFile.LocaleFileName, LocaleFile.LocaleModule));
                        }
                        break;
                }
            }
        }
コード例 #20
0
        private string CreateResourcePack(LocaleFilePack ResourcePack, string FileName, LanguagePackType packtype)
        {
            int    CompressionLevel = 9;
            int    BlockSize        = 4096;
            string ResPackName;
            string ResPackShortName;

            ResPackShortName = "ResourcePack." + FileName + ".";
            if (packtype == LanguagePackType.Core || packtype == LanguagePackType.Full)
            {
                ResPackShortName += Globals.glbAppVersion + ".";
            }
            ResPackShortName += ResourcePack.LocalePackCulture.Code + ".zip";
            ResPackName       = Globals.HostMapPath + ResPackShortName;

            FileStream strmZipFile = null;

            try
            {
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.CreateArchive"), ResPackShortName));
                strmZipFile = File.Create(ResPackName);
                ZipOutputStream strmZipStream = null;
                try
                {
                    strmZipStream = new ZipOutputStream(strmZipFile);

                    ZipEntry myZipEntry;
                    myZipEntry = new ZipEntry("Manifest.xml");

                    strmZipStream.PutNextEntry(myZipEntry);
                    strmZipStream.SetLevel(CompressionLevel);

                    byte[] FileData = GetLanguagePackManifest(ResourcePack);

                    strmZipStream.Write(FileData, 0, FileData.Length);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.SavedFile"), "Manifest.xml"));

                    foreach (LocaleFileInfo LocaleFile in ResourcePack.Files)
                    {
                        myZipEntry = new ZipEntry(LocaleFileUtil.GetFullFileName(LocaleFile));
                        strmZipStream.PutNextEntry(myZipEntry);
                        strmZipStream.Write(LocaleFile.Buffer, 0, LocaleFile.Buffer.Length);
                        ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.SavedFile"), LocaleFile.LocaleFileName));
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.Exceptions.LogException(ex);
                    ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.SavingFile"), ex));
                }
                finally
                {
                    if (strmZipStream != null)
                    {
                        strmZipStream.Finish();
                        strmZipStream.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                ProgressLog.AddFailure(string.Format(Localization.GetString("LOG.LangPack.ERROR.SavingFile"), ex));
            }
            finally
            {
                if (strmZipFile != null)
                {
                    strmZipFile.Close();
                }
            }

            return(ResPackName);
        }