Exemplo n.º 1
0
        internal static bool AddIntoArray(o2Mate.Dictionnaire dict, string arrayName, Dictionary <string, string> values)
        {
            bool add = true;

            o2Mate.Array arr = null;
            if (dict.IsArray(arrayName))
            {
                arr = dict.GetArray(arrayName) as o2Mate.Array;
                for (int index = 1; index <= arr.Count; ++index)
                {
                    o2Mate.Fields f    = arr.Item(index) as o2Mate.Fields;
                    string        pKey = f.GetString("primaryKey");
                    if (pKey == values["primaryKey"])
                    {
                        add = false;
                    }
                }
            }
            else
            {
                arr = new o2Mate.Array();
                dict.AddArray(arrayName, arr);
            }
            if (add)
            {
                o2Mate.Fields f = new o2Mate.Fields();
                foreach (KeyValuePair <string, string> keyVal in values)
                {
                    f.AddString(keyVal.Key, keyVal.Value);
                }
                arr.Add(f);
            }
            // retourne vrai si l'objet a été ajouté
            return(add);
        }
Exemplo n.º 2
0
 private void btnReload_Click(object sender, EventArgs e)
 {
     this._dict = new o2Mate.Dictionnaire();
     this._dict.Load(AppDomain.CurrentDomain.BaseDirectory + "\\dict\\dict.xml");
     this.layout.Controls.Clear();
     this.Construct();
 }
Exemplo n.º 3
0
 public SyntaxForm(string fileName, o2Mate.Dictionnaire dict)
 {
     this.fileName   = fileName;
     this.dict       = dict;
     this.outputDict = new o2Mate.Dictionnaire();
     InitializeComponent();
 }
Exemplo n.º 4
0
 public DictExecute(System.Windows.Forms.WebBrowser web, o2Mate.Dictionnaire inputDict, o2Mate.Dictionnaire outputDict, string fileName)
 {
     this.web           = web;
     this.inputDict     = inputDict;
     this.outputDict    = outputDict;
     this.fileNameSrc   = fileName;
     this.fileNameFinal = Path.Combine(Documents.TempDirectory, "execute.htm");
 }
Exemplo n.º 5
0
 public DictBienvenue(System.Windows.Forms.WebBrowser web, o2Mate.Dictionnaire inputDict, o2Mate.Dictionnaire outputDict, string fileName)
 {
     this.web        = web;
     this.inputDict  = inputDict;
     this.outputDict = outputDict;
     this.ParseExpressions();
     this.fileNameSrc   = fileName;
     this.fileNameFinal = Path.Combine(Documents.TempDirectory, "bienvenue.htm");
 }
Exemplo n.º 6
0
 public DictWizard(IDictProcess rootPage, Dictionary <string, IDictProcess> pages, System.Windows.Forms.WebBrowser web, o2Mate.Dictionnaire inputDict, o2Mate.Dictionnaire outputDict, string fileName)
 {
     this.rootPage      = rootPage;
     this.pages         = pages;
     this.web           = web;
     this.inputDict     = inputDict;
     this.outputDict    = outputDict;
     this.fileNameSrc   = fileName;
     this.fileNameFinal = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(this.fileNameFinal) + ".htm");
 }
Exemplo n.º 7
0
        public void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Documents.BienvenuePage + ".xml");

            IHMdict.Save(fileNameDict);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
            comp.Compilation(Documents.BienvenuePage, fileNameDict, this.fileNameFinal, null);
        }
Exemplo n.º 8
0
 public DictSaisieChamps(IDictProcess previousPage, IDictProcess rootPage, Dictionary <string, IDictProcess> pages, System.Windows.Forms.WebBrowser web, o2Mate.Dictionnaire inputDict, o2Mate.Dictionnaire outputDict, string fileName, string key, int index)
 {
     this.previousPage  = previousPage;
     this.rootPage      = rootPage;
     this.pages         = pages;
     this.web           = web;
     this.inputDict     = inputDict;
     this.outputDict    = outputDict;
     this.fileNameSrc   = fileName;
     this.keyTab        = key;
     this.index         = index;
     this.keys          = new Dictionary <string, string>();
     this.fileNameFinal = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(fileName).Name) + ".htm");
 }
Exemplo n.º 9
0
 internal void Compilation(string fileName)
 {
     o2Mate.Compilateur comp = new o2Mate.Compilateur();
     comp.LoadTemplates(Documents.TemplatesDirectory);
     comp.LoadSkeletons(Documents.SkeletonsDirectory);
     o2Mate.Dictionnaire dict = comp.OutputDictionary(fileName);
     dict.Save(Documents.TempDictFile);
     // le fichier de sortie n'est pas important
     comp.Debug(Documents.TempDictFile, Documents.UnusedFile, null);
     o2Mate.Compilateur compProject = new o2Mate.Compilateur();
     compProject.LoadTemplates(Documents.TemplatesDirectory);
     o2Mate.Dictionnaire dictProject = comp.Threads.Dictionary;
     dictProject.Save(Documents.TempDictFile);
     compProject.Compilation(Documents.ProjectSourceCode, Documents.TempDictFile, Documents.ProjectPage, null);
 }
Exemplo n.º 10
0
 private void button2_Click(object sender, EventArgs e)
 {
     o2Mate.Dictionnaire dict = new o2Mate.Dictionnaire();
     dict.AddString("test", "test2");
     o2Mate.Array  arr = new o2Mate.Array();
     o2Mate.Fields f   = new o2Mate.Fields();
     f.AddString("value", "t");
     arr.Add(f);
     f = new o2Mate.Fields();
     f.AddString("value", "t2");
     arr.Add(f);
     f = new o2Mate.Fields();
     f.AddString("value", "t2");
     arr.Add(f);
     dict.AddArray("textes", arr);
     dict.Save("c:\\file.xml");
 }
Exemplo n.º 11
0
        /// <summary>
        /// Principal method for writing all files
        /// </summary>
        /// <param name="fileDict">dictionary file</param>
        /// <param name="fileName">final file</param>
        public void WriteToFile(string fileDict, string fileName)
        {
            #region Common Files copy
            string        sourceName = Path.GetFileNameWithoutExtension(fileName);
            DirectoryInfo di         = new DirectoryInfo(CodeCommander.Documents.LanguageConvertersDirectory("powershell"));
            DirectoryInfo dest       = new DirectoryInfo(CodeCommander.Documents.BuildDirectory);
            if (!dest.Exists)
            {
                dest.Create();
            }

            // Copying files
            FileInfo fiMain   = new FileInfo(Path.Combine(di.FullName, "main.ps1.xml"));
            FileInfo fiScript = new FileInfo(Path.Combine(di.FullName, "functions.ps1.xml"));

            fiMain.CopyTo(Path.Combine(dest.FullName, "main" + sourceName + ".ps1.xml"), true);
            fiScript.CopyTo(Path.Combine(dest.FullName, "functions" + sourceName + ".ps1.xml"), true);

            #endregion

            #region Open dictionary

            o2Mate.Dictionnaire dict = new o2Mate.Dictionnaire();
            dict.AddString("DictionaryFileName", fileDict);

            #endregion

            #region main file script
            string defaultFileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".txt");
            dict.AddString("DefaultFileName", defaultFileName);
            string mainFunction = (this.Main.IsMacro ? "macro_" : this.Main.IsJob ? "job_" : "func_") + this.Main.Name;
            dict.AddString("MainFunction", mainFunction);
            dict.AddString("FunctionsFileName", "functions_" + sourceName + ".ps1");
            #endregion

            #region implementation Construct

            // implements all functions
            string functions = String.Empty;
            foreach (IFunction f in this.implementedFunctions)
            {
                functions += "function " + (f.IsMacro ? "macro_" : f.IsJob ? "job_" : "func_") + f.Name + "(";
                bool first = true;
                // ne choisis que les paramètres inconnus
                // recherche que les paramètres qui ne sont pas calculables
                List <string> distincts = new List <string>();
                foreach (IParameter p in f.Parameters.FindAll(new Predicate <IParameter>(delegate(IParameter par)
                {
                    return(!par.IsComputable);
                })))
                {
                    if (!distincts.Contains(p.VariableName))
                    {
                        if (!first)
                        {
                            functions += ", ";
                        }
                        else
                        {
                            first = false;
                        }
                        if (p.IsMutableParameter)
                        {
                            functions += "[ref] ";
                        }
                        functions += "$" + p.VariableName;
                        distincts.Add(p.VariableName);
                    }
                }
                functions += ") {" + Environment.NewLine + this.IndentSource(1, this.ReplaceVars(f.Source, f.InstancesStructure, f.Parameters, f.LocalVariables)) + "}" + Environment.NewLine + Environment.NewLine + Environment.NewLine;
            }

            dict.AddString("ImplementedFunctions", this.IndentSource(2, functions));

            #endregion

            #region Write files

            dict.Save(CodeCommander.Documents.TempDictFile);

            // main.ps1
            FileInfo fiSource = new FileInfo(Path.Combine(dest.FullName, "main" + sourceName + ".ps1.xml"));
            FileInfo fiDict   = new FileInfo(CodeCommander.Documents.TempDictFile);
            FileInfo fiResult = new FileInfo(Path.Combine(dest.FullName, sourceName + ".ps1"));
            this.Compilation(fiSource, fiDict, fiResult);

            // functions.ps1
            fiSource = new FileInfo(Path.Combine(dest.FullName, "functions" + sourceName + ".ps1.xml"));
            fiResult = new FileInfo(Path.Combine(dest.FullName, "functions_" + sourceName + ".ps1"));
            this.Compilation(fiSource, fiDict, fiResult);

            #endregion
        }
Exemplo n.º 12
0
 public DictTab(string fileName, o2Mate.Dictionnaire dict)
 {
     this._fileName = fileName;
     this._dict     = dict;
     InitializeComponent();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Print all statements into the current project
        /// </summary>
        /// <param name="dict">dictionary values</param>
        public void Print(o2Mate.Dictionnaire dict)
        {
            Dictionary <string, string> tabVal = new Dictionary <string, string>();

            tabVal.Add("processName", this.processName);
            tabVal.Add("position", this.position.ToString());
            tabVal.Add("type", this.type);
            switch (this.type)
            {
            case "thread":
                break;

            case "affectation":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("varName", this.values[0]);
                Projects.AddIntoArray(dict, "affectation", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "dictionary string":
                tabVal.Add("primaryKey", this.values[0] + ":" + this.values[1]);
                tabVal.Add("varName", this.values[0]);
                tabVal.Add("stringName", this.values[1]);
                Projects.AddIntoArray(dict, "dictionary string", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "dictionary field":
                tabVal.Add("primaryKey", this.values[0] + ":" + this.values[1] + "." + this.values[2]);
                tabVal.Add("varName", this.values[0]);
                tabVal.Add("tabName", this.values[1]);
                tabVal.Add("fieldName", this.values[2]);
                Projects.AddIntoArray(dict, "dictionary field", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "begin process":
                tabVal.Add("beginProcessName", this.values[0]);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "begin skeleton":
                tabVal.Add("beginSkeletonName", this.values[0]);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "call process":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("callProcessName", this.values[0]);
                Projects.AddIntoArray(dict, "call process", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "call skeleton":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("callSkeletonName", this.values[0]);
                Projects.AddIntoArray(dict, "call skeleton", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "print field":
                tabVal.Add("primaryKey", this.values[0] + "." + this.values[1]);
                tabVal.Add("tabName", this.values[0]);
                tabVal.Add("fieldName", this.values[1]);
                Projects.AddIntoArray(dict, "print field", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "goto":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("label", this.values[0]);
                Projects.AddIntoArray(dict, "goto", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "create mop":
                tabVal.Add("primaryKey", this.values[1] + "(" + this.values[0] + ")");
                tabVal.Add("languageName", this.values[0]);
                tabVal.Add("createMopName", this.values[1]);
                Projects.AddIntoArray(dict, "create mop", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "create writer":
                tabVal.Add("primaryKey", this.values[1]);
                tabVal.Add("writerName", this.values[0]);
                tabVal.Add("fileName", this.values[1]);
                Projects.AddIntoArray(dict, "create writer", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "default writer":
                tabVal.Add("varName", this.values[0]);
                Projects.AddIntoArray(dict, "default writer", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "end process":
                tabVal.Add("endProcessName", this.values[0]);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "end skeleton":
                tabVal.Add("endSkeletonPath", this.values[0]);
                tabVal.Add("endSkeletonName", this.values[1]);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "injector":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("injectorName", this.values[0]);
                Projects.AddIntoArray(dict, "injector", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "label":
                tabVal.Add("primaryKey", this.processName + "." + this.values[0]);
                tabVal.Add("labelName", this.values[0]);
                Projects.AddIntoArray(dict, "label", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "size":
                tabVal.Add("primaryKey", this.values[0] + ":" + this.values[1]);
                tabVal.Add("varName", this.values[0]);
                tabVal.Add("tabName", this.values[1]);
                Projects.AddIntoArray(dict, "size", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "declare template":
                tabVal.Add("primaryKey", this.values[0] + "/" + this.values[1]);
                tabVal.Add("templatePath", this.values[0]);
                tabVal.Add("templateName", this.values[1]);
                tabVal.Add("parameters", this.values[2]);
                Projects.AddIntoArray(dict, "declare template", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "print":
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "use mop":
                tabVal.Add("primaryKey", this.values[1] + "(" + this.values[0] + ")");
                tabVal.Add("languageName", this.values[0]);
                tabVal.Add("command", this.values[1]);
                Projects.AddIntoArray(dict, "use mop", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "use template":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("templateName", this.values[0]);
                Projects.AddIntoArray(dict, "use template", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "print variable":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("varName", this.values[0]);
                Projects.AddIntoArray(dict, "print variable", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "print string":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("stringName", this.values[0]);
                Projects.AddIntoArray(dict, "print string", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;

            case "project":
                tabVal.Add("primaryKey", this.values[0]);
                tabVal.Add("name", this.values[0]);
                Projects.AddIntoArray(dict, "project", tabVal);
                Projects.AddIntoProcess(dict, this.processName, this.position, tabVal);
                break;
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public Projects()
 {
     this.dict   = new o2Mate.Dictionnaire();
     this.record = false;
 }
Exemplo n.º 15
0
        static void Main()
        {
            try
            {
                // création du fichier outils.VBS
                o2Mate.Compilateur  comp = new o2Mate.Compilateur();
                o2Mate.Dictionnaire dict = new o2Mate.Dictionnaire();
                dict.AddString("dir", Documents.EditeurDirectory);
                string fileNameDict = Documents.TempDictFile;
                dict.Save(fileNameDict);
                comp.Compilation(Documents.OutilsVBSXML, fileNameDict, Documents.OutilsVBS, null);
                // le compilateur ne peut pas etre lancé 2 fois de suite
                comp = new o2Mate.Compilateur();
                comp.Compilation(Documents.LocalesVBSXML, fileNameDict, Documents.LocalesVBS, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            try
            {
                DirectoryInfo di = new DirectoryInfo(Documents.CodeCommanderDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
                di = new DirectoryInfo(Documents.SourcesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.ExamplesDirectory);
                    Program.CopyXML(di, Documents.SourcesDirectory);
                }
                di = new DirectoryInfo(Documents.TemplatesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcTemplatesDirectory);
                    Program.CopyXML(di, Documents.TemplatesDirectory);
                }
                di = new DirectoryInfo(Documents.SkeletonsDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcSkeletonsDirectory);
                    Program.CopyXML(di, Documents.SkeletonsDirectory);
                }
                di = new DirectoryInfo(Documents.SyntaxDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcSyntaxDirectory);
                    Program.CopyXML(di, Documents.SyntaxDirectory);
                }
                di = new DirectoryInfo(Documents.LocalesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                    di = new DirectoryInfo(Documents.SrcLocalesDirectory);
                    Program.CopyTSV(di, Documents.LocalesDirectory);
                }
                di = new DirectoryInfo(Documents.DictionariesDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
                di = new DirectoryInfo(Documents.BuildDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
                di = new DirectoryInfo(Documents.TempDirectory);
                if (!di.Exists)
                {
                    di.Create();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("L'application va s'arrêter parce qu'il est impossible de créer des fichiers dans le répertoire 'Mes documents'", "Impossible de continuer", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ComputerSettings computerSettings = new ComputerSettings();

            try
            {
                computerSettings.VerifyPowerShell();
                computerSettings.VerifyExecutingPowerShell();
                computerSettings.TestChangeParameterSettings();
                Application.Run(computerSettings);
                if (computerSettings.DialogResult == DialogResult.Cancel)
                {
                    // si cancel alors on stoppe l'application
                    return;
                }
                if (computerSettings.DialogResult == DialogResult.OK)
                {
                    Form1 form = new Form1(computerSettings);
                    try
                    {
                        // création du fichier editeur.HTM en fonction de la langue
                        o2Mate.Compilateur  comp = new o2Mate.Compilateur();
                        o2Mate.Dictionnaire dict = new o2Mate.Dictionnaire();
                        string fileNameDict      = Documents.TempDictFile;
                        dict.Save(fileNameDict);
                        comp.Compilation(Documents.EditorPageXML, fileNameDict, Documents.EditorPage, null);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            finally
            {
                computerSettings.RevertToSaved();
                // suppress all temporary files
                DirectoryInfo dir = new DirectoryInfo(Documents.TempDirectory);
                dir.EnumerateFiles().AsParallel().ForAll(a => { a.Delete(); });
            }
        }
Exemplo n.º 16
0
        internal static void AddIntoProcess(o2Mate.Dictionnaire dict, string processName, int position, Dictionary <string, string> values)
        {
            int firstPos   = 0;
            int currentPos = 1;

            o2Mate.Array  statements = null;
            o2Mate.Fields process    = null;
            if (dict.IsArray("statements"))
            {
                statements = dict.GetArray("statements") as o2Mate.Array;
                currentPos = statements.Count + 1;
            }
            else
            {
                statements = new o2Mate.Array();
                dict.AddArray("statements", statements);
            }
            o2Mate.Array processes = null;
            bool         found     = false;

            if (dict.IsArray("processes"))
            {
                // je recherche le processus qui a le même nom
                processes = dict.GetArray("processes") as o2Mate.Array;
                for (int index = 1; index <= processes.Count; ++index)
                {
                    process = processes.Item(index) as o2Mate.Fields;
                    if (process.GetString("processName") == processName)
                    {
                        Int32.TryParse(process.GetString("current"), out currentPos);
                        Int32.TryParse(process.GetString("first"), out firstPos);
                        found = true;
                        break;
                    }
                }
            }
            else
            {
                processes = new o2Mate.Array();
                dict.AddArray("processes", processes);
            }
            if (!found)
            {
                process = new o2Mate.Fields();
                process.AddString("processName", processName);
                process.AddString("first", currentPos.ToString());
                process.AddString("current", currentPos.ToString());
                processes.Add(process);
            }
            else
            {
                found = false;
                for (int index = firstPos; index <= currentPos; ++index)
                {
                    o2Mate.Fields f = statements.Item(index) as o2Mate.Fields;
                    // si c'est le même process et que c'est la même position dans le process
                    if (f.GetString("processName") == processName && f.GetString("position") == position.ToString())
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    o2Mate.Fields previous = statements.Item(currentPos) as o2Mate.Fields;
                    previous.AddString("next", (statements.Count + 1).ToString());
                }
            }
            if (!found)
            {
                o2Mate.Fields statmt = new o2Mate.Fields();
                statmt.AddString("processName", processName);
                statmt.AddString("position", position.ToString());
                statmt.AddString("next", "0");
                foreach (KeyValuePair <string, string> keyVal in values)
                {
                    statmt.AddString(keyVal.Key, keyVal.Value);
                }
                statements.Add(statmt);
                process.AddString("current", statements.Count.ToString());
            }
        }
Exemplo n.º 17
0
        public void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(this.fileNameSrc).Name) + ".xml");;

            this.preferredHeight = 270;
            this.keys.Clear();
            o2Mate.Array  tabInput         = this.inputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Fields fieldsInput      = tabInput.Item(1) as o2Mate.Fields;
            o2Mate.Array  tabDefaultFields = new o2Mate.Array();
            int           fieldIndex       = 0;

            if (!this.outputDict.IsArray(this.keyTab))
            {
                this.outputDict.AddArray(this.keyTab, new o2Mate.Array());
            }
            o2Mate.Array  arrRows   = this.outputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Fields rowFields = null;
            if (index > 0)
            {
                rowFields = arrRows.Item(this.index) as o2Mate.Fields;
            }
            o2Mate.Array refArrConnections = new o2Mate.Array();
            foreach (string key in fieldsInput.Keys)
            {
                o2Mate.Fields fieldsDefault = new o2Mate.Fields();
                ++fieldIndex;
                o2Mate.ILegende leg = this.inputDict.Legendes.GetLegendeByName(key, this.keyTab);
                this.keys.Add("field" + fieldIndex.ToString(), key);
                fieldsDefault.AddString("nom", "field" + fieldIndex.ToString());
                string description = key;
                if (leg != null)
                {
                    description = leg.Description;
                }
                fieldsDefault.AddString("description", description);
                string commentaire = "";
                if (leg != null)
                {
                    commentaire = leg.Commentaire;
                }
                fieldsDefault.AddString("commentaire", commentaire);
                string myType = "String";
                if (leg != null)
                {
                    myType = leg.Type;
                    if (leg.Observe != "")
                    {
                        fieldsDefault.AddString("observe", leg.Observe);
                    }
                }
                fieldsDefault.AddString("type", myType);
                string arrName, field;
                if (this.outputDict.GetInConnection(leg, this.keyTab, this.index, out arrName, out field))
                {
                    fieldsDefault.AddString("arrayReference", arrName);
                    o2Mate.Array  arrConnection       = this.outputDict.GetArray(arrName) as o2Mate.Array;
                    o2Mate.Fields refFieldsConnection = new o2Mate.Fields();
                    refFieldsConnection.AddString("name", "field" + index.ToString());
                    refFieldsConnection.AddString("value", "");
                    refArrConnections.Add(refFieldsConnection);
                    for (int indexConnection = 1; indexConnection <= arrConnection.Count; ++indexConnection)
                    {
                        o2Mate.Fields f = arrConnection.Item(indexConnection) as o2Mate.Fields;
                        if (f.Exists(field))
                        {
                            o2Mate.Fields refFields = new o2Mate.Fields();
                            refFields.AddString("name", "field" + index.ToString());
                            refFields.AddString("value", f.GetString(field));
                            refArrConnections.Add(refFields);
                        }
                    }
                }
                if (this.index > 0)
                {
                    if (rowFields.Exists(key))
                    {
                        fieldsDefault.AddString("valeur", rowFields.GetString(key));
                    }
                    else
                    {
                        rowFields.AddString(key, "");
                        fieldsDefault.AddString("valeur", "");
                    }
                }
                tabDefaultFields.Add(fieldsDefault);
                this.preferredHeight += 40;
            }
            IHMdict.AddArray("keyTab", tabDefaultFields);
            IHMdict.AddArray("connections", refArrConnections);
            if (this.index > 0)
            {
                IHMdict.AddString("title", "Nouvel élément du tableau '" + this.keyTab + "'");
            }
            else
            {
                IHMdict.AddString("title", "Edition d'un élément du tableau '" + this.keyTab + "'");
            }
            o2Mate.ILegende legTab         = this.inputDict.Legendes.GetLegendeByName(this.keyTab);
            string          descriptionTab = this.keyTab;

            if (legTab != null)
            {
                descriptionTab = legTab.Description;
            }
            IHMdict.AddString("description", descriptionTab);
            string commentaireTab = "";

            if (legTab != null)
            {
                commentaireTab = legTab.Commentaire;
            }
            IHMdict.AddString("commentaire", commentaireTab);
            IHMdict.Save(fileNameDict);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
            try
            {
                comp.Compilation(Documents.SaisieChampsPage, fileNameDict, this.fileNameFinal, null);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
 public DictSaisieLibre(IDictProcess rootPage, Dictionary <string, IDictProcess> pages, System.Windows.Forms.WebBrowser web, o2Mate.Dictionnaire inputDict, o2Mate.Dictionnaire outputDict, string fileName) : base(rootPage, pages, web, inputDict, outputDict, fileName)
 {
     this.keys      = new Dictionary <string, string>();
     base.Next     += new EventHandler(DictSaisieLibre_Next);
     base.Previous += new EventHandler(DictSaisieLibre_Previous);
 }
Exemplo n.º 19
0
        public new void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(this.fileNameSrc).Name) + ".xml");

            this.PreferredHeight = 270;
            this.keys.Clear();
            o2Mate.Array  tabInput         = this.inputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Fields fieldsInput      = tabInput.Item(1) as o2Mate.Fields;
            o2Mate.Array  tabDefaultFields = new o2Mate.Array();
            int           fieldIndex       = 0;

            foreach (string key in fieldsInput.Keys)
            {
                o2Mate.Fields fieldsDefault = new o2Mate.Fields();
                ++fieldIndex;
                o2Mate.ILegende leg = this.inputDict.Legendes.GetLegendeByName(key, this.keyTab);
                this.keys.Add("field" + fieldIndex.ToString(), key);
                fieldsDefault.AddString("nom", "field" + fieldIndex.ToString());
                string description = key;
                if (leg != null)
                {
                    description = leg.Description;
                }
                fieldsDefault.AddString("description", description);
                string commentaire = "";
                if (leg != null)
                {
                    commentaire = leg.Commentaire;
                }
                fieldsDefault.AddString("commentaire", commentaire);
                string myType = "String";
                if (leg != null)
                {
                    myType = leg.Type;
                    if (leg.Expression != "")
                    {
                        fieldsDefault.AddString("observe", leg.Expression);
                    }
                }
                fieldsDefault.AddString("type", myType);
                tabDefaultFields.Add(fieldsDefault);
            }
            IHMdict.AddArray("keyTab", tabDefaultFields);
            IHMdict.AddString("title", "Saisie du tableau '" + this.keyTab + "'");
            o2Mate.ILegende legTab         = this.inputDict.Legendes.GetLegendeByName(this.keyTab);
            string          descriptionTab = this.keyTab;

            if (legTab != null)
            {
                descriptionTab = legTab.Description;
            }
            IHMdict.AddString("description", descriptionTab);
            string commentaireTab = "";

            if (legTab != null)
            {
                commentaireTab = legTab.Commentaire;
            }
            IHMdict.AddString("commentaire", commentaireTab);
            if (!this.outputDict.IsArray(this.keyTab))
            {
                this.outputDict.AddArray(this.keyTab, new o2Mate.Array());
            }
            o2Mate.Array tabOutput = this.outputDict.GetArray(this.keyTab) as o2Mate.Array;
            o2Mate.Array arrRows   = new o2Mate.Array();
            o2Mate.Array arrFields = new o2Mate.Array();
            for (int index = 1; index <= tabOutput.Count; ++index)
            {
                o2Mate.Fields tabRows = new o2Mate.Fields();
                tabRows.AddString("index", index.ToString());
                arrRows.Add(tabRows);
                o2Mate.Fields tabFieldsInput = tabInput.Item(1) as o2Mate.Fields;
                o2Mate.Fields fields         = tabOutput.Item(index) as o2Mate.Fields;
                fieldIndex = 0;
                foreach (string key in tabFieldsInput.Keys)
                {
                    o2Mate.Fields tabFields = new o2Mate.Fields();
                    tabFields.AddString("rowId", index.ToString());
                    ++fieldIndex;
                    o2Mate.ILegende leg = this.inputDict.Legendes.GetLegendeByName(key, this.keyTab);
                    this.keys.Add("rowId" + index.ToString() + "_field" + fieldIndex.ToString(), key);
                    tabFields.AddString("nom", "rowId" + index.ToString() + "_field" + fieldIndex.ToString());
                    string description = key;
                    if (leg != null)
                    {
                        description = leg.Description;
                    }
                    tabFields.AddString("description", description);
                    string commentaire = "";
                    if (leg != null)
                    {
                        commentaire = leg.Commentaire;
                    }
                    tabFields.AddString("commentaire", commentaire);
                    string myType = "String";
                    if (leg != null)
                    {
                        myType = leg.Type;
                        if (leg.Expression != "")
                        {
                            tabFields.AddString("observe", leg.Expression);
                        }
                    }
                    tabFields.AddString("type", myType);
                    if (fields.Exists(key))
                    {
                        tabFields.AddString("value", fields.GetString(key));
                    }
                    else
                    {
                        tabFields.AddString("value", "");
                    }
                    arrFields.Add(tabFields);
                    this.PreferredHeight += 40;
                }
                this.PreferredHeight += 10;
            }
            IHMdict.AddArray("items", arrRows);
            IHMdict.AddArray("fields", arrFields);
            IHMdict.Save(fileNameDict);
            try
            {
                o2Mate.Compilateur comp = new o2Mate.Compilateur();
                comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
                comp.Compilation(Documents.SaisieTableauPage, fileNameDict, this.fileNameFinal, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            FileInfo fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageTabUp);

            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageTabUp, true);
            fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageTabDown);
            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageTabDown, true);
        }
        public new void Load()
        {
            o2Mate.Dictionnaire IHMdict = new o2Mate.Dictionnaire();
            string fileNameDict         = Path.Combine(Documents.TempDirectory, Path.GetFileNameWithoutExtension(new FileInfo(this.fileNameSrc).Name) + ".xml");

            o2Mate.Array arr = new o2Mate.Array();
            this.PreferredHeight = 258;
            this.keys.Clear();
            int index = 1;

            IHMdict.AddString("title", "Saisie des champs libres");
            o2Mate.Array refArrConnections = new o2Mate.Array();
            foreach (string key in this.inputDict.StringKeys)
            {
                o2Mate.Fields fields = new o2Mate.Fields();
                this.keys.Add("field" + index.ToString(), key);
                fields.AddString("nom", "field" + index.ToString());
                o2Mate.ILegende leg         = this.inputDict.Legendes.GetLegendeByName(key);
                string          description = key;
                if (leg != null)
                {
                    description = leg.Description;
                }
                fields.AddString("description", description);
                string commentaire = "";
                if (leg != null)
                {
                    commentaire = leg.Commentaire;
                }
                fields.AddString("commentaire", commentaire);
                string myType = "String";
                if (leg != null)
                {
                    myType = leg.Type;
                    if (leg.Expression != "")
                    {
                        fields.AddString("observe", leg.Expression);
                    }
                }
                fields.AddString("type", myType);
                string arrName, field;
                if (this.outputDict.GetInConnection(leg, "", 0, out arrName, out field))
                {
                    fields.AddString("arrayReference", arrName);
                    o2Mate.Array  arrConnection       = this.outputDict.GetArray(arrName) as o2Mate.Array;
                    o2Mate.Fields refFieldsConnection = new o2Mate.Fields();
                    refFieldsConnection.AddString("name", "field" + index.ToString());
                    refFieldsConnection.AddString("value", "");
                    refArrConnections.Add(refFieldsConnection);
                    for (int indexConnection = 1; indexConnection <= arrConnection.Count; ++indexConnection)
                    {
                        o2Mate.Fields f = arrConnection.Item(indexConnection) as o2Mate.Fields;
                        if (f.Exists(field))
                        {
                            o2Mate.Fields refFields = new o2Mate.Fields();
                            refFields.AddString("name", "field" + index.ToString());
                            refFields.AddString("value", f.GetString(field));
                            refArrConnections.Add(refFields);
                        }
                    }
                }
                if (this.outputDict.IsString(key))
                {
                    fields.AddString("valeur", this.outputDict.GetString(key));
                }
                else
                {
                    fields.AddString("valeur", "");
                }
                arr.Add(fields);
                this.PreferredHeight += 40;
                ++index;
            }
            IHMdict.AddArray("connections", refArrConnections);
            IHMdict.AddArray("champs", arr);
            IHMdict.Save(fileNameDict);
            o2Mate.Compilateur comp = new o2Mate.Compilateur();
            comp.LoadTemplates(Documents.GeneratedDictionariesTemplatesDirectory);
            comp.Compilation(Documents.SaisieLibrePage, fileNameDict, this.fileNameFinal, null);
            FileInfo fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageAdd);

            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageAdd, true);
            fi = new FileInfo(Documents.GeneratedDictionariesDirectory + Documents.ImageEdit);
            fi.CopyTo(Path.GetDirectoryName(this.fileNameFinal) + Documents.ImageEdit, true);
        }