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); }
void Callback_Click(object sender, System.Windows.Forms.HtmlElementEventArgs e) { string action = this.web.Document.GetElementById("callback").GetAttribute("action"); if (action == "validate") { int rowId = this.index; if (rowId > 0) { o2Mate.Array outputTab = this.outputDict.GetArray(this.keyTab) as o2Mate.Array; o2Mate.Fields outputFields = outputTab.Item(rowId) as o2Mate.Fields; foreach (KeyValuePair <string, string> kv in this.keys) { string value = this.web.Document.GetElementById(kv.Key).GetAttribute("value"); outputFields.AddString(kv.Value, value); } } else { o2Mate.Array outputTab = this.outputDict.GetArray(this.keyTab) as o2Mate.Array; o2Mate.Fields outputFields = new o2Mate.Fields(); foreach (KeyValuePair <string, string> kv in this.keys) { string value = this.web.Document.GetElementById(kv.Key).GetAttribute("value"); outputFields.AddString(kv.Value, value); } outputTab.Add(outputFields); } this.Return_Click(sender, e); } else if (action == "add") { string arrayRef = this.web.Document.GetElementById("callback").GetAttribute("reference"); DictSaisieChamps dsc = new DictSaisieChamps(this, null, null, this.web, this.inputDict, this.outputDict, this.fileNameSrc, arrayRef, 0); dsc.Load(); dsc.Navigate(); } else if (action == "edit") { string arrayRef = this.web.Document.GetElementById("callback").GetAttribute("reference"); int indexRef = 0; Int32.TryParse(this.web.Document.GetElementById("callback").GetAttribute("index"), out indexRef); DictSaisieChamps dsc = new DictSaisieChamps(this, null, null, this.web, this.inputDict, this.outputDict, this.fileNameSrc, arrayRef, indexRef); dsc.Load(); dsc.Navigate(); } }
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"); }
void Callback_Click(object sender, System.Windows.Forms.HtmlElementEventArgs e) { string action = this.web.Document.GetElementById("callback").GetAttribute("action"); if (action == "addRow") { int rowId = 0; Int32.TryParse(this.web.Document.GetElementById("callback").GetAttribute("rowId"), out rowId); o2Mate.Array arr = this.outputDict.GetArray(this.keyTab) as o2Mate.Array; o2Mate.Fields fields = new o2Mate.Fields(); o2Mate.Fields inputFields = (this.inputDict.GetArray(this.keyTab) as o2Mate.Array).Item(1) as o2Mate.Fields; int fieldIndex = 0; foreach (string key in inputFields.Keys) { ++fieldIndex; this.keys.Add("rowId" + rowId.ToString() + "_field" + fieldIndex.ToString(), key); fields.AddString(key, ""); this.PreferredHeight += 40; } arr.Add(fields); this.PreferredHeight += 10; if (this.preferredHeight < this.web.Parent.MaximumSize.Height) { this.web.Parent.Size = new System.Drawing.Size(this.web.Parent.Size.Width, this.preferredHeight); } else { this.web.Parent.Size = new System.Drawing.Size(this.web.Parent.Size.Width, this.web.Parent.MaximumSize.Height); } } else if (action == "onchange") { int rowId = 0; Int32.TryParse(this.web.Document.GetElementById("callback").GetAttribute("rowId"), out rowId); if (rowId > 0) { string value = this.web.Document.GetElementById("callback").GetAttribute("value"); string fieldName = this.web.Document.GetElementById("callback").GetAttribute("fieldId"); o2Mate.Array outputTab = this.outputDict.GetArray(this.keyTab) as o2Mate.Array; o2Mate.Fields outputFields = outputTab.Item(rowId) as o2Mate.Fields; outputFields.AddString(this.keys[fieldName], value); } } }
private void ParseExpressions() { foreach (string key in this.inputDict.StringKeys) { this.inputDict.ParseExpression(this.inputDict.Legendes.GetLegendeByName(key)); } foreach (string tabKey in this.inputDict.ArrayKeys) { this.inputDict.ParseExpression(this.inputDict.Legendes.GetLegendeByName(tabKey)); o2Mate.Array arr = this.inputDict.GetArray(tabKey) as o2Mate.Array; o2Mate.Fields fields = arr.Item(1) as o2Mate.Fields; foreach (string key in fields.Keys) { this.inputDict.ParseExpression(this.inputDict.Legendes.GetLegendeByName(key, tabKey)); } } // recopier toutes les legendes dans le dictionnaire de sortie this.outputDict.Legendes.CopyFrom(this.inputDict.Legendes as o2Mate.LegendeDict); }
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 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); }
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()); } }
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); }