public static void LoadPermanentVariables(IScope pScope) { Configuration config = Configuration.GetNewInstance(); foreach (Epi.DataSets.Config.PermanentVariableRow row in config.PermanentVariables) { EpiInfo.Plugin.IVariable var = new PluginVariable(row.Name, (EpiInfo.Plugin.DataType)row.DataType, VariableScope.Permanent, row.DataValue); pScope.Define(var); } }
public void LoadTemplate(IEnumerable <IAbridgedFieldInfo> fields, Dictionary <string, string> responseQA) { string pageNumber = ""; foreach (var field in fields) { PluginVariable var = new PluginVariable(); var.Name = field.FieldName; var.VariableScope = VariableScope.DataSource; var.PageNumber = pageNumber; if (responseQA != null && responseQA.Count > 0) { var.Expression = GetControlValue(responseQA, var.Name); } switch ((int)field.FieldType) { case 1: // textbox var.DataType = DataType.Text; var.ControlType = "textbox"; break; case 2: //Label/Title var.DataType = DataType.Text; var.ControlType = "label"; break; case 3: //Label var.DataType = DataType.Text; var.ControlType = "label"; continue; case 4: //MultiLineTextBox var.DataType = DataType.Text; var.ControlType = "multiline"; break; case 5: //NumericTextBox var.DataType = DataType.Number; var.ControlType = "numeric"; break; case 7: // 7 DatePicker var.DataType = DataType.Date; var.ControlType = "datepicker"; break; case 8: //TimePicker var.DataType = DataType.Time; var.ControlType = "timepicker"; break; case 10: //CheckBox var.DataType = DataType.Boolean; var.ControlType = "checkbox"; break; case 11: //DropDown Yes/No var.DataType = DataType.Boolean; var.ControlType = "yesno"; break; case 12: //RadioButton var.DataType = DataType.Number; var.ControlType = "radiobutton"; break; case 17: //DropDown LegalValues var.DataType = DataType.Text; var.ControlType = "legalvalues"; break; case 18: //DropDown Codes var.DataType = DataType.Text; var.ControlType = "codes"; break; case 19: //DropDown CommentLegal var.DataType = DataType.Text; var.ControlType = "commentlegal"; break; case 20: //Relate Button var.DataType = DataType.Text; var.ControlType = "relatebutton"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "commentlegal", "datasource", var.Expression)); break; case 21: //GroupBox var.DataType = DataType.Unknown; var.ControlType = "groupbox"; var.Expression = field.List; string[] IdentifierList = var.Expression.Split(','); string Identifier = field.FieldName; if (this.GroupVariableList.ContainsKey(Identifier)) { this.GroupVariableList[Identifier].Clear(); } else { this.GroupVariableList.Add(Identifier, new List <string>()); } foreach (string s in IdentifierList) { this.GroupVariableList[Identifier].Add(s); this.GroupVariableList[Identifier].Add(Identifier); } break; } this.DefineVariable(var); } }
public void LoadTemplate(XDocument pTemplateDoc, XDocument pSurveyResponseDoc) { // todo for each page in var _FieldsTypeIDs = from _FieldTypeID in pTemplateDoc.Descendants("Field") select _FieldTypeID; string PageNumber = ""; string defineFormat = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", \"{3}\");"; string defineNumberFormat = "cce_Context.define(\"{0}\", \"{1}\", \"{2}\", new Number({3}));"; foreach (var _FieldTypeID in _FieldsTypeIDs) { PluginVariable var = new PluginVariable(); var.Name = _FieldTypeID.Attribute("Name").Value; var.VariableScope = VariableScope.DataSource; var.PageNumber = PageNumber; if (pSurveyResponseDoc != null) { var.Expression = GetControlValue(pSurveyResponseDoc, var.Name); } switch (_FieldTypeID.Attribute("FieldTypeId").Value) { case "1": // textbox var.DataType = DataType.Text; var.ControlType = "textbox"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "textbox", "datasource", var.Expression)); break; case "2": //Label/Title var.DataType = DataType.Text; var.ControlType = "label"; //continue; break; case "3": //Label var.DataType = DataType.Text; var.ControlType = "label"; continue; //break; case "4": //MultiLineTextBox var.DataType = DataType.Text; var.ControlType = "multiline"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "multiline", "datasource", var.Expression)); break; case "5": //NumericTextBox var.DataType = DataType.Number; var.ControlType = "numeric"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineNumberFormat, _FieldTypeID.Attribute("Name").Value, "number", "datasource", var.Expression)); break; case "7": // 7 DatePicker var.DataType = DataType.Date; var.ControlType = "datepicker"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "number", "datasource", var.Expression)); break; case "8": //TimePicker var.DataType = DataType.Time; var.ControlType = "timepicker"; break; case "10": //CheckBox var.DataType = DataType.Boolean; var.ControlType = "checkbox"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "checkbox", "datasource", var.Expression)); break; case "11": //DropDown Yes/No var.DataType = DataType.Boolean; var.ControlType = "yesno"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "yesno", "datasource", var.Expression)); break; case "12": //RadioButton var.DataType = DataType.Number; var.ControlType = "radiobutton"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "yesno", "datasource", var.Expression)); break; case "17": //DropDown LegalValues var.DataType = DataType.Text; var.ControlType = "legalvalues"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "legalvalue", "datasource", var.Expression)); break; case "18": //DropDown Codes var.DataType = DataType.Text; var.ControlType = "codes"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "code", "datasource", var.Expression)); break; case "19": //DropDown CommentLegal var.DataType = DataType.Text; var.ControlType = "commentlegal"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "commentlegal", "datasource", var.Expression)); break; case "20": //Relate Button var.DataType = DataType.Text; var.ControlType = "relatebutton"; //JavaScriptVariableDefinitions.AppendLine(string.Format(defineFormat, _FieldTypeID.Attribute("Name").Value, "commentlegal", "datasource", var.Expression)); break; case "21": //GroupBox var.DataType = DataType.Unknown; var.ControlType = "groupbox"; var.Expression = _FieldTypeID.Attribute("List").Value; //List="Otherpleasespecify,DoubleHearingProtectionWearingEarPlugsandMuffsatthesametime,FittedEarPlugs,EarMuffs,DisposableEarPlugs,FullFaceAirPurifyingCartridgeRespirator,FullFaceorHoodSuppliedAirRespirator,HalfFaceAirPurifyingCartridgeRespirator,DisposibleRespiratorDustMask,WeldingHelmetwithDarkFacePlate,ProtectiveLongSleeveJacket,HeatResistantandFlameRetardantClothing,HeavyLeatherGloves,InsulatedGloves,FaceShield,DarkGoggles,Goggles,None2" string[] IdentifierList = var.Expression.Split(','); string Identifier = _FieldTypeID.Attribute("Name").Value; if (this.GroupVariableList.ContainsKey(Identifier)) { this.GroupVariableList[Identifier].Clear(); } else { this.GroupVariableList.Add(Identifier, new List <string>()); } foreach (string s in IdentifierList) { this.GroupVariableList[Identifier].Add(s); this.GroupVariableList[Identifier].Add(Identifier); } break; } this.DefineVariable(var); } }