public LanguageComponentWriter(LanguagePackInfo languagePack, string basePath, Dictionary<string, InstallFile> files, PackageInfo package)
     : base(basePath, files, package)
 {
     _Language = Localization.Localization.GetLocaleByID(languagePack.LanguageID);
     _PackageType = languagePack.PackageType;
     _DependentPackageID = languagePack.DependentPackageID;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="LanguageComponentWriter"/> class.
 /// Constructs the LanguageComponentWriter.
 /// </summary>
 /// <param name="languagePack">Language Package info.</param>
 /// <param name="basePath">Base Path.</param>
 /// <param name="files">A Dictionary of files.</param>
 /// <param name="package">Package Info.</param>
 /// -----------------------------------------------------------------------------
 public LanguageComponentWriter(LanguagePackInfo languagePack, string basePath, Dictionary <string, InstallFile> files, PackageInfo package)
     : base(basePath, files, package)
 {
     this._Language           = LocaleController.Instance.GetLocale(languagePack.LanguageID);
     this._PackageType        = languagePack.PackageType;
     this._DependentPackageID = languagePack.DependentPackageID;
 }
Beispiel #3
0
 public LanguageComponentWriter(LanguagePackInfo languagePack, string basePath, Dictionary <string, InstallFile> files, PackageInfo package)
     : base(basePath, files, package)
 {
     _Language           = Localization.Localization.GetLocaleByID(languagePack.LanguageID);
     _PackageType        = languagePack.PackageType;
     _DependentPackageID = languagePack.DependentPackageID;
 }
Beispiel #4
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);
        }
        protected void cmdCreate_Click(Object sender, EventArgs e)
        {
            LocaleFilePackWriter LangPackWriter = new LocaleFilePackWriter();
            Locale LocaleCulture = new Locale();

            LocaleCulture.Code = cboLanguage.SelectedValue;
            LocaleCulture.Text = cboLanguage.SelectedItem.Text;

            LanguagePackType packtype    = (LanguagePackType)(@Enum.Parse(typeof(LanguagePackType), rbPackType.SelectedValue));
            ArrayList        basefolders = new ArrayList();

            if (packtype == LanguagePackType.Module || packtype == LanguagePackType.Provider)
            {
                foreach (ListItem l in lbItems.Items)
                {
                    if (l.Selected)
                    {
                        basefolders.Add(l.Value);
                    }
                }
            }
            //verify filename
            txtFileName.Text = Globals.CleanFileName(txtFileName.Text);

            string LangPackName = LangPackWriter.SaveLanguagePack(LocaleCulture, packtype, basefolders, txtFileName.Text);

            if (LangPackWriter.ProgressLog.Valid)
            {
                lblMessage.Text     = string.Format(Localization.GetString("LOG.MESSAGE.Success", LocalResourceFile), LangPackName, null);
                lblMessage.CssClass = "Head";
                hypLink.Text        = string.Format(Localization.GetString("Download", LocalResourceFile), Path.GetFileName(LangPackName), null);
                hypLink.NavigateUrl = Globals.HostPath + Path.GetFileName(LangPackName);
                hypLink.Visible     = true;
            }
            else
            {
                lblMessage.Text     = Localization.GetString("LOG.MESSAGE.Error", LocalResourceFile);
                lblMessage.CssClass = "NormalRed";
                hypLink.Visible     = false;
            }
            divLog.Controls.Add(LangPackWriter.ProgressLog.GetLogsTable());
            pnlLogs.Visible = true;
        }
Beispiel #6
0
        private bool GetInfo(string capability, out LanguagePackType type, out string language, out string name)
        {
            type     = LanguagePackType.Unknown;
            language = null;
            name     = "Language." + capability;

            string[] splitted = capability.Split(new char[] { '.', '~' }, StringSplitOptions.RemoveEmptyEntries);

            string packageTypeStr = splitted[0].ToLower();

            switch (packageTypeStr)
            {
            case "basic": type = LanguagePackType.Basic; break;

            case "fonts": return(false);   //type = LanguagePackType.Font; break;

            case "ocr": type = LanguagePackType.OCR; break;

            case "handwriting": type = LanguagePackType.Handwriting; break;

            case "texttospeech": type = LanguagePackType.TextToSpeech; break;

            case "speech": type = LanguagePackType.Speech; break;

            default: Log("[WARNING] Unknown package type " + packageTypeStr); return(false);
            }

            try
            {
                language = LocaleHelper.GetCultureCode(splitted[1]);
            }
            catch (Exception e)
            {
                Log("Invalid language " + language + Environment.NewLine + "Exception: " + e);
            }

            return(true);
        }
 public LanguageInstaller(LanguagePackType type)
 {
     LanguagePackType = type;
 }
Beispiel #8
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Constructs the LanguageComponentWriter
 /// </summary>
 /// <param name="language">Language Info.</param>
 /// <param name="basePath">Base Path.</param>
 /// <param name="files">A Dictionary of files</param>
 /// <param name="package">Package Info.</param>
 /// -----------------------------------------------------------------------------
 public LanguageComponentWriter(Locale language, string basePath, Dictionary <string, InstallFile> files, PackageInfo package) : base(basePath, files, package)
 {
     _Language    = language;
     _PackageType = LanguagePackType.Core;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Constructs the LanguageComponentWriter
 /// </summary>
 /// <param name="language">Language Info.</param>
 /// <param name="basePath">Base Path.</param>
 /// <param name="files">A Dictionary of files</param>
 /// <param name="package">Package Info.</param>
 /// <history>
 /// 	[cnurse]	02/08/2008	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public LanguageComponentWriter(Locale language, string basePath, Dictionary<string, InstallFile> files, PackageInfo package) : base(basePath, files, package)
 {
     _Language = language;
     _PackageType = LanguagePackType.Core;
 }
 public LanguageInstaller(LanguagePackType type)
 {
     this.LanguagePackType = type;
 }
Beispiel #11
0
 public LanguagePack(LanguagePackType type, string language, string name)
 {
     Type     = type;
     Language = language;
     Name     = name;
 }
        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;
        }
        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;
        }
Beispiel #14
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);
        }