Ejemplo n.º 1
0
 public override NextCall Invoke(WorkflowMethod invoker)
 {
     string errorText = null;
     if (invoker is WMContentForm) {
         _text = ((WMContentForm)invoker).Result.Get<LongStringPropertyValue>("values").Value;
         string[] rows = _text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
         try {
             int colCodeName = -1;
             int colValue = -1;
             Dictionary<int, int> colsNameByLcId = new Dictionary<int, int>();
             Dictionary<int, int> colsDescByLcId = new Dictionary<int, int>();
             var header = rows[0].Split(new char[] { '\t', ';' }, StringSplitOptions.None);
             for (int col = 0; col < header.Length; col++) {
                 string v = header[col].Trim();
                 if (v == "CODENAME") colCodeName = col;
                 else if (v == "VALUE") colValue = col;
                 else if (v.StartsWith("NAME")) colsNameByLcId.Add(col, int.Parse(v.Substring(4)));
                 else if (v.StartsWith("DESC")) colsDescByLcId.Add(col, int.Parse(v.Substring(4)));
             }
             var newValues = new Dictionary<int, MemDefEnumerationValue>();
             for (int row = 1; row < rows.Length; row++) {
                 var e = new MemDefEnumerationValue();
                 var cols = rows[row].Split(new char[] { '\t', ';' }, StringSplitOptions.None);
                 e.CodeName = cols[colCodeName].Trim();
                 e.Value = int.Parse(cols[colValue].Trim());
                 foreach (int col in colsNameByLcId.Keys) e.NameByLCID.Add(colsNameByLcId[col], cols[col].Trim());
                 foreach (int col in colsDescByLcId.Keys) e.DescriptionByLCID.Add(colsDescByLcId[col], cols[col].Trim());
                 newValues.Add(e.Value, e);
             }
             _defEnum.Values = newValues;
             WFContext.SendClientScriptToStartupRequest(_onCompleteScript);
             return null;
         } catch (Exception error) {
             errorText = "The import failed, there are formatting errors in the text. " + error.Message + " ";
         }
     }
     ContentFormDefinition cfd = new ContentFormDefinition();
     var settings = new LongStringPropertySettings();
     settings.Height = Unit.Percentage(95);
     settings.Layout = PropertyLayout.NoTitle;
     cfd.AddPropertyHeading("", "<span style=\"color:red;\">" + errorText + "</span>Each column can be separated by a TAB or SEMICOLON. Use Excel or similar to edit large datasets. Select paste \"as text\" when pasting into excel for best formatting. You must include the first header to indicate the position of each coloum. You may add or delete language specific columns. Not all language specific columns must be filled in for each row.", false, true, true, Unit.Percentage(100), Unit.Pixel(70));
     cfd.AddPropertyLongString("values", "Values", _text, null, settings);
     return new NextCall(new WMContentForm(DialogueIcon.Info, "Values of \"" + _defEnum.CodeName + "\"", 600, 300, cfd, new string[] { "Import values..." }, true), Invoke);
 }
Ejemplo n.º 2
0
 void btnSave_Click(object sender, EventArgs e)
 {
     if (writeAccess) {
         if (!currentDef.IsChangeDef) {
             currentDef.CodeName = txtCodeName.Text;
             currentDef.Namespace = txtNameSpace.Text;
             currentDef.Values = new Dictionary<int, MemDefEnumerationValue>();
             foreach (var en in enumControls) {
                 var v = new MemDefEnumerationValue();
                 en.SetChanges(v);
                 try {
                     currentDef.Values.Add(v.Value, v);
                 } catch {
                     Session.Notify(DialogueIcon.Critical, "Not all values where unique", "Changes was saved, but the second enum with id " + v.Value + " could not be included.");
                 }
             }
         }
         if (langVersions != null) {
             currentDef.NameByLCID = langVersions.GetNameByLCID();
             currentDef.DescriptionByLCID = langVersions.GetDescriptionByLCID();
         }
         tempDef.RegisterChange(currentDef.Guid);
         WAFContext.FlagChangeInTemporaryDefinition();
         WAFContext.UpdateTemporaryLocalDefinitionFile();
         if (DefinitionType == DefinitionType.Native) WAFContext.UpdateNativeDefinitionFile();
         if (Save != null) Save(this, EventArgs.Empty);
     }
     this.Refresh();
 }
Ejemplo n.º 3
0
 public void SetChanges(MemDefEnumerationValue v)
 {
     v.CodeName = _codeNameControl.Text;
     v.Value = Utils.GetIntOnly(_valueControl.Text);
     v.NameByLCID = _lcidControl.GetNameByLCID();
     v.DescriptionByLCID = _lcidControl.GetDescriptionByLCID();
 }
Ejemplo n.º 4
0
 void btnAddValue_Click(object sender, EventArgs e)
 {
     if (writeAccess) {
         if (!currentDef.IsChangeDef) {
             int newValue = currentDef.Values.Count == 0 ? 1 : (from i in currentDef.Values.Keys select i).Max() + 1;
             var v = new MemDefEnumerationValue();
             v.CodeName = currentDef.CodeName + newValue;
             v.Value = newValue;
             currentDef.Values.Add(newValue, v);
             currentDef.Namespace = txtNameSpace.Text;
         }
     }
     this.Refresh();
 }