Esempio n. 1
0
 public void WriteToFile(IProcessInstance proc, FinalFile file)
 {
     if (proc.CurrentScope.Exists(proc.DefaultWriter))
     {
         string             writer = proc.CurrentScope.GetVariable(proc.DefaultWriter).ValueString;
         o2Mate.LocaleGroup lg     = new LocaleGroup();
         string             groupName;
         string             title;
         if (lg.ExtractGroupAndName(this.localeName, out groupName, out title))
         {
             ILocaleSet set      = lg.Get(groupName) as ILocaleSet;
             string     language = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
             try
             {
                 // lève une exception si l'élement n'existe pas
                 FinalFile.WriteToFile(ref writer, set.Get(title, language), this.enc);
             }
             catch
             {
                 FinalFile.WriteToFile(ref writer, this.localeName, this.enc);
             }
         }
         proc.CurrentScope.GetVariable(proc.DefaultWriter).Value = writer;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Make a translation of the summary data in the current language
        /// </summary>
        /// <param name="value">value format to translate</param>
        /// <returns>the text translated</returns>
        public string Translate(string value)
        {
            o2Mate.LocaleGroup group = new LocaleGroup();
            string             groupName, localeName;

            if (group.ExtractGroupAndName(value, out groupName, out localeName))
            {
                if (group.Exists(groupName))
                {
                    o2Mate.ILocaleSet set = group.Get(groupName);
                    if (set.ExistsOne(localeName, System.Threading.Thread.CurrentThread.CurrentUICulture.Name))
                    {
                        return(set.Get(localeName, System.Threading.Thread.CurrentThread.CurrentUICulture.Name));
                    }
                    else
                    {
                        return(value);
                    }
                }
                else
                {
                    return(value);
                }
            }
            else
            {
                return(value);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Update summary from html element
        /// </summary>
        /// <param name="elem">html element object</param>
        public void Update(System.Windows.Forms.HtmlElement elem)
        {
            this.context     = elem.GetAttribute("context");
            this.name        = elem.GetAttribute("name");
            this.description = elem.GetAttribute("description");
            this.type        = elem.GetAttribute("typeLegende");
            this.expression  = elem.GetAttribute("expression");
            this.commentaire = elem.GetAttribute("commentaire");
            this.free        = Boolean.Parse(elem.GetAttribute("free"));
            o2Mate.LocaleGroup group = new LocaleGroup();
            string             groupName, localeName;

            if (group.ExtractGroupAndName(this.description, out groupName, out localeName))
            {
                if (!group.Exists(groupName))
                {
                    group.Create(groupName);
                }
                o2Mate.ILocaleSet set = group.Get(groupName);
                if (!set.ExistsOne(localeName, "fr-FR"))
                {
                    set.Add(localeName, "fr-FR", "");
                }
                if (!set.ExistsOne(localeName, "en-US"))
                {
                    set.Add(localeName, "en-US", "");
                }
            }
            if (group.ExtractGroupAndName(this.commentaire, out groupName, out localeName))
            {
                if (!group.Exists(groupName))
                {
                    group.Create(groupName);
                }
                o2Mate.ILocaleSet set = group.Get(groupName);
                if (!set.ExistsOne(localeName, "fr-FR"))
                {
                    set.Add(localeName, "fr-FR", "");
                }
                if (!set.ExistsOne(localeName, "en-US"))
                {
                    set.Add(localeName, "en-US", "");
                }
            }
        }
        private IVersion TestModifiedFiles(IVersion currentVersion)
        {
            DirectoryInfo dir   = new DirectoryInfo(Path.Combine(this.sources.FullName, this.ProgramName));
            ILocaleGroup  group = new LocaleGroup(CodeCommander.Documents.HostVersions);
            ILocaleSet    set;

            if (!group.Exists(this.ProgramName + "_files"))
            {
                group.Create(this.ProgramName + "_files");
            }
            set = group.Get(this.ProgramName + "_files");
            // compte le nombre de fichiers modifiés
            uint countModified = 0;

            // chercher les dernières dates de modification des fichiers
            foreach (FileInfo fi in this.GetFiles(dir))
            {
                if (set.ExistsOne(fi.Name, this.Language))
                {
                    string value = set.Get(fi.Name.Replace(" ", "_"), this.Language);
                    if (value != fi.LastWriteTimeUtc.ToString())
                    {
                        set.Modify(fi.Name.Replace(" ", "_"), this.Language, fi.LastWriteTimeUtc.ToString());
                        ++countModified;
                    }
                }
                else
                {
                    set.Add(fi.Name.Replace(" ", "_"), this.Language, fi.LastWriteTimeUtc.ToString());
                    ++countModified;
                }
            }

            if (countModified > 0)
            {
                return(new Version(countModified, currentVersion.Minor + 1, currentVersion.Build, currentVersion.Revision));
            }
            else
            {
                return(new Version(currentVersion.Major, currentVersion.Minor + 1, currentVersion.Build, currentVersion.Revision));
            }
        }