/********************************************************************************************* * Copyright 2021 - Volian Enterprises, Inc. All rights reserved. * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE * ------------------------------------------------------------------------------ * $Workfile: ROField.cs $ $Revision: 11 $ * $Author: Kathy $ $Date: 4/04/03 9:41a $ * * $History: ROField.cs $ * * ***************** Version 11 ***************** * User: Kathy Date: 4/04/03 Time: 9:41a * Updated in $/LibSource/ROFields * B2003-030: get correct field type for new image * * ***************** Version 10 ***************** * User: Kathy Date: 12/10/02 Time: 2:27p * Updated in $/LibSource/ROFields * fieldname special chars * * ***************** Version 9 ***************** * User: Kathy Date: 12/02/02 Time: 8:30a * Updated in $/LibSource/ROFields * fieldname replace chars * * ***************** Version 8 ***************** * User: Kathy Date: 11/11/02 Time: 7:14a * Updated in $/LibSource/ROFields * image field type should be 32 not 20 * * ***************** Version 7 ***************** * User: Kathy Date: 10/15/02 Time: 2:17p * Updated in $/LibSource/ROFields * combo field number * * ***************** Version 6 ***************** * User: Kathy Date: 9/27/02 Time: 1:11p * Updated in $/LibSource/ROFields * fix digit as first char in fieldname * * ***************** Version 5 ***************** * User: Kathy Date: 9/25/02 Time: 2:31p * Updated in $/LibSource/ROFields * multitxt->variable * * ***************** Version 4 ***************** * User: Kathy Date: 9/03/02 Time: 2:53p * Updated in $/LibSource/ROFields * missing " on image field def. * * ***************** Version 3 ***************** * User: Kathy Date: 8/30/02 Time: 11:56a * Updated in $/LibSource/ROFields * image * * ***************** Version 2 ***************** * User: Kathy Date: 8/28/02 Time: 10:59a * Updated in $/LibSource/ROFields * development *********************************************************************************************/ using System; using System.Text; namespace ROFields { // Field Types: // SingleTxt - Single Line Text // VariableTxt - Variable Length Text (multiple lines) // FrmtSingleTxt - Single Line Formatted text - used for Accessory ID fields // XYPlot - used to enter the plot language commands // Table - Used to enter a table (16-bit VE-PROMS text based style using dashes and pipe characters to define cells) // Image - Used for images (ex. TIF,JPG,BMP file references) // MultiTxt - ?? // Combination - used for Setpoint return values - user can select type of return value (Single/Multi line text, Table, X/Y Plot) // when entering the RO data // MultiField - ?? public enum FieldTypes: uint { Nil=0, SingleTxt=1, VariableTxt=2, FrmtSingleTxt=4, XYPlot=8, Table=10, Image=32, MultiTxt=40, Combination=128, MultiFld=100 } /// /// Summary description for ROField: This class contains RO Field information. Each ROField /// contains: /// string fieldname - the name of the field /// string recid - its database record id (used to interface to the database - null if /// not created yet. /// string masterrecID - its record id in the master if appropriate. /// uint fieldtype - the field type as defined in the enum FieldTypes (listed above) /// public class ROField { string fieldname; string recID; string masterrecID; uint fldtype; // constuctor public ROField(string fname, string rID, string mrID, uint fieldtype) { fieldname = fname; recID = rID; masterrecID = mrID; fldtype = fieldtype; } public string GetFieldname { get {return fieldname;}} public string GetRecID { get {return recID;}} public string GetMasterRecID { get {return masterrecID;}} public uint GetFieldType{ get {return fldtype;}} public void SetFieldname(string name) {fieldname = name;} public void SetRecID(string recid) {recID = recid;} public void SetMasterRecID(string mrecid) {masterrecID = mrecid;} public void SetFieldType(uint ftype) {fldtype = ftype;} // C2021-026 return true if we allow child values for the current field type public bool FieldTypeCanDoApplicability() { bool rtnval = false; switch (fldtype) { case (uint)FieldTypes.SingleTxt: case (uint)FieldTypes.VariableTxt: case (uint)FieldTypes.Combination: rtnval = true; break; } return rtnval; } // Given a schema string, determine which RO Field type it is. public uint ParseFieldType(string info) { int indx; // formatted single line text has 'pattern' in schema definition) indx = info.IndexOf("xsd:pattern"); if (indx >= 0) return (uint) FieldTypes.FrmtSingleTxt; // Combination field has 'choice' in schema definition indx = info.IndexOf("xsd:choice"); if (indx >= 0) return (uint) FieldTypes.Combination; // image - search for 'Image_Height', in case Image is in the string from some other mechanism indx = info.IndexOf("Image_Height"); if (indx >=0) return (uint) FieldTypes.Image; // single line text has 'normalizedString' (pattern does too, but // it would be eliminated above. indx = info.IndexOf("xsd:normalizedString"); if (indx >=0) return (uint) FieldTypes.SingleTxt; // now look for all of the multi-line fields: multi text, table, & XY Plot indx = info.IndexOf("xsd:string"); if (indx <0) indx = info.IndexOf("xsd:String"); if (indx >=0) { int indxspecific; indxspecific = info.IndexOf("Variable"); if (indxspecific >= 0) return (uint) FieldTypes.VariableTxt; indxspecific = info.IndexOf("Table"); if (indxspecific >= 0) return (uint) FieldTypes.Table; indxspecific = info.IndexOf("XYPlot"); if (indxspecific >= 0) return (uint) FieldTypes.XYPlot; } // indx = info.IndexOf("Image"); // if (indx >=0) return (uint) FieldTypes.Image; return 1000; } // Creates a string representing the schema for this field. note that the input // fieldname will override that which is stored for this ROField (for editting // purposes). public string MakeFieldName(string fldname) { if (fldname.Length < 2) return fldname; // a digit cannot start an xml fieldname, prepend a "__" to it. string tmp0; if (char.IsDigit(fldname,0)) tmp0 = "__" + fldname; else tmp0 = fldname; // an xml fieldname cannot have a space, change it to a "__" string tmpstr = tmp0.Replace(" ","__"); int len = tmpstr.Length; int cnt = 0; // this is also our sequence that tells us the follow 3 digits is the ascii number (base 10) // of the character we replaced. string OKpunch = "-._"; string outstr = ""; int decval; while (cnt < len) { char tmpchr = tmpstr[cnt]; if(!char.IsLetterOrDigit(tmpchr)&& (OKpunch.IndexOf(tmpchr) == -1) ) { decval = tmpchr; outstr += OKpunch + decval.ToString("D3"); } else { outstr += tmpchr.ToString(); } cnt++; } return outstr; } public string MakeSchemaString(string fieldname, string width, string pattern) { uint ftype = this.GetFieldType; StringBuilder strbld = new StringBuilder(); strbld.Append("\n"); if (ftype == (uint)FieldTypes.VariableTxt || ftype == (uint)FieldTypes.Table || ftype == (uint)FieldTypes.XYPlot) { strbld.Append("\n"); if (ftype == (uint)FieldTypes.VariableTxt) strbld.Append("Variable"); else if (ftype == (uint)FieldTypes.Table) strbld.Append("Table"); else strbld.Append("XYPlot"); strbld.Append("\n"); } strbld.Append("\n\n\n\n"); if (ftype == (uint)FieldTypes.FrmtSingleTxt) { strbld.Append("\n"); } strbld.Append("\n\n"); return (strbld.ToString()); } public string MakeComboSchemaString(string fieldname, bool fixd, string fixdwid, bool multi, string multiwid, bool table, string tablewid, bool xyplot, string xyplotwid) { StringBuilder strbld = new StringBuilder(); strbld.Append("\n"); if (fixd == true) { strbld.Append("\n"); strbld.Append("\n\n\n\n\n\n"); } if (multi == true) { strbld.Append("\n"); strbld.Append("\n\nVariable\n"); strbld.Append("\n\n\n"); strbld.Append("\n\n\n\n\n"); } if (table == true) { strbld.Append("\n"); strbld.Append("\n\nTable\n"); strbld.Append("\n\n\n"); strbld.Append("\n\n\n\n"); } if (xyplot == true) { strbld.Append("\n"); strbld.Append("\n\nXYPlot\n"); strbld.Append("\n\n\n"); strbld.Append("\n\n\n\n"); } strbld.Append(""); return (strbld.ToString()); } public string MakeImageSchemaString(string fieldname) { StringBuilder strbld = new StringBuilder(); strbld.Append("\n\n"); strbld.Append("\n"); strbld.Append("\n\n"); strbld.Append("VLN_FINDFILE\n"); strbld.Append("\n\n"); strbld.Append("\n\n"); strbld.Append("\n\n"); strbld.Append("\n\n"); strbld.Append("Lines (6 lines per inch)\n"); strbld.Append("\n\n"); strbld.Append("\n\n\n"); strbld.Append("\n\n"); strbld.Append("\n\n"); strbld.Append("Characters (12 chars. Per inch)\n"); strbld.Append("\n\n"); strbld.Append("\n\n\n"); strbld.Append("\n\n\n"); return(strbld.ToString()); } } }