Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Mostrar na listBox2 os alunos do curso selecionado no listBox1:
            try
            {
                listBox2.Items.Clear(); //limpamos a segunda lista
                string cursoSelec = (string)((DataRowView)listBox1.SelectedItem)[0];

                string sql = "SELECT * FROM Alunos WHERE abrevcurso = '" + cursoSelec + "'";

                //suponhamos o BD em C:\tempo
                System.Data.OleDb.OleDbConnection conexao =
                    new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/temp/Universidade3.mdb");
                conexao.Open();

                System.Data.OleDb.OleDbCommand comando =
                    new System.Data.OleDb.OleDbCommand(sql, conexao);

                System.Data.OleDb.OleDbDataReader dr = comando.ExecuteReader();

                while (dr.Read())
                {
                    string dadosAluno = dr.GetString(0)
                                        + ", " + dr.GetString(1) + ", " + dr.GetString(2)
                                        + ", " + dr.GetInt32(3) + ", " + dr.GetString(4);
                    listBox2.Items.Add(dadosAluno);
                }

                dr.Close();
                comando.Dispose();
                conexao.Close();
            }
            catch (Exception exc) { MessageBox.Show(exc.Message); }
        }
        private void button3_Click(object sender, EventArgs e)
        {   // Botão btnResultados
            try
            {
                string id1 = txtIdade1.Text;
                string id2 = txtIdade2.Text;
                string strSsexo = "";
                if (rbMasculino.Checked) strSsexo = " sexo = 'M' AND ";
                    else if (rbFeminino.Checked) strSsexo = " sexo = 'F' AND ";
                        else strSsexo = "";

                sql = "select * from alunos WHERE " + strSsexo 
                    + " idade>=" + id1 + " AND idade<=" + id2 
                    + " ORDER BY nome";
                stm = new System.Data.OleDb.OleDbCommand(sql, conexao);
                rs = stm.ExecuteReader();
                string strSaida = "";
                while (rs.Read())
                {
                    string dados = "RGM: " + rs.GetString(0) 
                        + ", " + rs.GetString(1) + ", idade: " + rs.GetInt32(3)
                        + ", sexo: " + rs.GetString(4)
                        + ", curso: " + rs.GetString(2);
                    strSaida += dados + "\r\n";
                }
                txtResultados.Text = strSaida;
            }
            catch (Exception exsql) { MessageBox.Show("Erro na consulta"); }
            if(stm!=null)stm.Dispose();
            if(rs!=null)rs.Close();
        }
Esempio n. 3
0
        internal Structs.ResultWeaponsClass[] GetResultWeaponClassesWithResults()
        {
            string select = "SELECT DISTINCT weapons.class " +
                            "FROM (weapons RIGHT JOIN Competitors ON weapons.WeaponId = Competitors.WeaponId) " +
                            "INNER JOIN CompetitorResults ON Competitors.CompetitorId = CompetitorResults.CompetitorId;";

            System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(
                select, myInterface.databaseClass.Conn);

            if (myInterface.databaseClass.Conn.State != ConnectionState.Open)
            {
                myInterface.databaseClass.Conn.Open();
            }

            System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader();

            List <Structs.WeaponClass> wclasses = new List <Structs.WeaponClass>();

            while (r.Read())
            {
                wclasses.Add((Structs.WeaponClass)r.GetInt32(0));
            }


            r.Dispose();
            cmd.Dispose();

            List <Structs.ResultWeaponsClass> rwclasses = new List <Structs.ResultWeaponsClass>();

            foreach (Structs.WeaponClass wclass in wclasses)
            {
                // Check for duplicates
                Structs.ResultWeaponsClass rwc =
                    CConvert.ConvertWeaponsClassToResultClass(
                        wclass,
                        myInterface.CompetitionCurrent.Type);
                if (!rwclasses.Contains(rwc))
                {
                    rwclasses.Add(rwc);
                }
            }

            // Sort
            rwclasses.Sort();

            return(rwclasses.ToArray());
        }
Esempio n. 4
0
        private void button3_Click(object sender, EventArgs e)
        {   // Botão btnResultados
            try
            {
                string id1      = txtIdade1.Text;
                string id2      = txtIdade2.Text;
                string strSsexo = "";
                if (rbMasculino.Checked)
                {
                    strSsexo = " sexo = 'M' AND ";
                }
                else if (rbFeminino.Checked)
                {
                    strSsexo = " sexo = 'F' AND ";
                }
                else
                {
                    strSsexo = "";
                }

                sql = "select * from alunos WHERE " + strSsexo
                      + " idade>=" + id1 + " AND idade<=" + id2
                      + " ORDER BY nome";
                stm = new System.Data.OleDb.OleDbCommand(sql, conexao);
                rs  = stm.ExecuteReader();
                string strSaida = "";
                while (rs.Read())
                {
                    string dados = "RGM: " + rs.GetString(0)
                                   + ", " + rs.GetString(1) + ", idade: " + rs.GetInt32(3)
                                   + ", sexo: " + rs.GetString(4)
                                   + ", curso: " + rs.GetString(2);
                    strSaida += dados + "\r\n";
                }
                txtResultados.Text = strSaida;
            }
            catch (Exception exsql) { MessageBox.Show("Erro na consulta"); }
            if (stm != null)
            {
                stm.Dispose();
            }
            if (rs != null)
            {
                rs.Close();
            }
        }
Esempio n. 5
0
        private void m_axCalendar_DoCreateRPattern(object sender, AxXtremeCalendarControl._DCalendarControlEvents_DoCreateRPatternEvent e)
        {
            e.bResult = false;

            if (!IsOpen())
            {
                return;
            }

            try
            {
                String strSQL = "SELECT * FROM CalendarRecurrencePatterns WHERE RecurrencePatternID = 0 ";

                System.Data.OleDb.OleDbDataAdapter    oleDbDataAdapter = new System.Data.OleDb.OleDbDataAdapter(strSQL, m_oleDbConnection);
                System.Data.OleDb.OleDbCommandBuilder custCB           = new System.Data.OleDb.OleDbCommandBuilder(oleDbDataAdapter);
                custCB.QuotePrefix = "[";
                custCB.QuoteSuffix = "]";

                System.Data.DataSet objPatternDSet = new System.Data.DataSet();
                oleDbDataAdapter.Fill(objPatternDSet);

                //code to modify data in dataset here
                System.Data.DataRow objDRow = objPatternDSet.Tables[0].NewRow();
                objPatternDSet.Tables[0].Rows.Add(objDRow);

                m_DataHelper.PutRPatternToData(e.pPattern, objDRow);

                oleDbDataAdapter.Update(objPatternDSet);

                //'-- update Auto EventID
                System.Data.OleDb.OleDbCommand objCommand = m_oleDbConnection.CreateCommand();
                objCommand.CommandText = "SELECT MAX(RecurrencePatternID) AS NewNewPatternID FROM CalendarRecurrencePatterns";
                System.Data.OleDb.OleDbDataReader objReader = objCommand.ExecuteReader();
                objReader.Read();

                e.newPatternID = objReader.GetInt32(0);

                objReader.Close();

                e.bResult = true;
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("EXCEPTION! providerSQLServer.m_axCalendar_DoCreateRPattern: " + ex.Message);
            }
        }
Esempio n. 6
0
        /// <summary> Returns the Java source code for a class that represents the specified segment.</summary>
        public static System.String makeSegment(System.String name, System.String version)
        {
            System.Text.StringBuilder source = new System.Text.StringBuilder();
            try
            {
                System.Data.OleDb.OleDbConnection conn = NuGenNormativeDatabase.Instance.Connection;

                System.Text.StringBuilder sql = new System.Text.StringBuilder();
                sql.Append("SELECT HL7SegmentDataElements.seg_code, HL7SegmentDataElements.seq_no, ");
                sql.Append("HL7SegmentDataElements.repetitional, HL7SegmentDataElements.repetitions, ");
                sql.Append("HL7DataElements.description, HL7DataElements.length, HL7DataElements.table_id, ");
                sql.Append("HL7SegmentDataElements.req_opt, HL7Segments.description, HL7DataElements.data_structure ");
                sql.Append("FROM HL7Versions RIGHT JOIN (HL7Segments INNER JOIN (HL7DataElements INNER JOIN HL7SegmentDataElements ");
                sql.Append("ON (HL7DataElements.version_id = HL7SegmentDataElements.version_id) ");
                sql.Append("AND (HL7DataElements.data_item = HL7SegmentDataElements.data_item)) ");
                sql.Append("ON (HL7Segments.version_id = HL7SegmentDataElements.version_id) ");
                sql.Append("AND (HL7Segments.seg_code = HL7SegmentDataElements.seg_code)) ");
                sql.Append("ON (HL7Versions.version_id = HL7Segments.version_id) ");
                sql.Append("WHERE HL7SegmentDataElements.seg_code = '");
                sql.Append(name);
                sql.Append("' and HL7Versions.hl7_version = '");
                sql.Append(version);
                sql.Append("' ORDER BY HL7SegmentDataElements.seg_code, HL7SegmentDataElements.seq_no;");
                //System.out.println(sql.toString());  //for debugging
                System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
                System.Data.OleDb.OleDbCommand temp_OleDbCommand;
                temp_OleDbCommand             = stmt;
                temp_OleDbCommand.CommandText = sql.ToString();
                System.Data.OleDb.OleDbDataReader rs       = temp_OleDbCommand.ExecuteReader();
                System.Collections.ArrayList      elements = new System.Collections.ArrayList();
                System.String       segDesc = null;
                NuGenSegmentElement se;
                while (rs.Read())
                {
                    if (segDesc == null)
                    {
                        segDesc = System.Convert.ToString(rs[9 - 1]);
                    }
                    se             = new NuGenSegmentElement();
                    se.field       = rs.GetInt32(2 - 1);
                    se.rep         = System.Convert.ToString(rs[3 - 1]);
                    se.repetitions = rs.GetInt32(4 - 1);
                    if (se.repetitions == 0)
                    {
                        if (se.rep == null || !se.rep.ToUpper().Equals("Y".ToUpper()))
                        {
                            se.repetitions = 1;
                        }
                    }
                    se.desc   = System.Convert.ToString(rs[5 - 1]);
                    se.length = rs.GetInt32(6 - 1);
                    se.table  = rs.GetInt32(7 - 1);
                    se.opt    = System.Convert.ToString(rs[8 - 1]);
                    se.type   = System.Convert.ToString(rs[10 - 1]);
                    //shorten CE_x to CE
                    if (se.type.StartsWith("CE"))
                    {
                        se.type = "CE";
                    }

                    elements.Add(se);

                    /*System.out.println("Segment: " + name + " Field: " + se.field + " Rep: " + se.rep +
                     * " Repetitions: " + se.repetitions + " Desc: " + se.desc + " Length: " + se.length +
                     * " Table: " + se.table + " Segment Desc: " + segDesc);*/
                }
                NuGenNormativeDatabase.Instance.returnConnection(conn);

                //write imports, class documentation, etc ...
                source.Append("package ");
                source.Append(NuGenSourceGenerator.getVersionPackageName(version));
                source.Append("segment;\r\n\r\n");
                source.Append("import Genetibase.NuGenHL7.model.*;\r\n");
                source.Append("import ");
                source.Append(NuGenSourceGenerator.getVersionPackageName(version));
                source.Append("datatype.*;\r\n\r\n");
                source.Append("import Genetibase.NuGenHL7.parser.ModelClassFactory;\r\n");
                source.Append("import Genetibase.NuGenHL7.HL7Exception;\r\n\r\n");
                source.Append("/**\r\n");
                source.Append(" * <p>Represents an HL7 ");
                source.Append(name);
                source.Append(" message segment. \r\n");
                source.Append(" * This segment has the following fields:</p><p>\r\n");
                for (int i = 0; i < elements.Count; i++)
                {
                    se = (NuGenSegmentElement)elements[i];
                    source.Append(" * ");
                    source.Append(name);
                    source.Append("-");
                    source.Append(se.field);
                    source.Append(": ");
                    source.Append(se.desc);
                    source.Append(" (");
                    source.Append(se.type);
                    source.Append(")<br> \r\n");
                }
                source.Append(" * </p><p>The get...() methods return data from individual fields.  These methods \r\n");
                source.Append(" * do not throw exceptions and may therefore have to handle exceptions internally.  \r\n");
                source.Append(" * If an exception is handled internally, it is logged and null is returned.  \r\n");
                source.Append(" * This is not expected to happen - if it does happen this indicates not so much \r\n");
                source.Append(" * an exceptional circumstance as a bug in the code for this class.</p>    \r\n");
                source.Append(" */\r\n");
                source.Append("public class ");
                source.Append(name);
                source.Append(" extends AbstractSegment ");

                //implement interface from model.control package if required

                /*Class correspondingControlInterface = Control.getInterfaceImplementedBy(name);
                 * if (correspondingControlInterface != null) {
                 * source.append("implements ");
                 * source.append(correspondingControlInterface.getName());
                 * } */

                source.Append(" {\r\n\r\n");
                source.Append("  /**\r\n");
                source.Append("   * Creates a ");
                source.Append(name);
                source.Append(" (");
                source.Append(segDesc);
                source.Append(") segment object that belongs to the given \r\n");
                source.Append("   * message.  \r\n");
                source.Append("   */\r\n");

                //write constructor
                source.Append("  public ");
                source.Append(name);
                source.Append("(Group parent, ModelClassFactory factory) {\r\n");
                source.Append("    super(parent, factory);\r\n");
                source.Append("    Message message = getMessage();\r\n");
                if (elements.Count > 0)
                {
                    source.Append("    try {\r\n");
                    for (int i = 0; i < elements.Count; i++)
                    {
                        se = (NuGenSegmentElement)elements[i];
                        System.String type = NuGenSourceGenerator.getAlternateType(se.type, version);
                        source.Append("       this.add(");
                        source.Append(type);
                        source.Append(".class");
                        //                    if (type.equalsIgnoreCase("Varies")) {
                        //                    } else {
                        //                        source.append("factory.getTypeClass(\"");
                        //                        source.append(type);
                        //                        source.append("\", \"");
                        //                        source.append(version);
                        //                        source.append("\")");
                        //                    }
                        source.Append(", ");
                        if (se.opt == null)
                        {
                            source.Append("false");
                        }
                        else
                        {
                            if (se.opt.ToUpper().Equals("R".ToUpper()))
                            {
                                source.Append("true");
                            }
                            else
                            {
                                source.Append("false");
                            }
                        }
                        source.Append(", ");
                        source.Append(se.repetitions);
                        source.Append(", ");
                        source.Append(se.length);
                        source.Append(", ");
                        if (se.type.Equals("ID") || se.type.Equals("IS"))
                        {
                            source.Append("new Object[]{message, new Integer(");
                            source.Append(se.table);
                            source.Append(")}");
                        }
                        else
                        {
                            source.Append("new Object[]{message}");
                        }
                        source.Append(");\r\n");
                    }
                    source.Append("    } catch (HL7Exception he) {\r\n");
                    source.Append("    }\r\n");
                }
                source.Append("  }\r\n\r\n");

                //write a datatype-specific accessor for each field
                for (int i = 0; i < elements.Count; i++)
                {
                    se = (NuGenSegmentElement)elements[i];
                    if (!se.desc.ToUpper().Equals("UNUSED".ToUpper()))
                    {
                        //some entries in 2.1 DB say "unused"
                        System.String type = NuGenSourceGenerator.getAlternateType(se.type, version);
                        source.Append("  /**\r\n");
                        source.Append("   * Returns ");
                        if (se.repetitions != 1)
                        {
                            source.Append("a single repetition of ");
                        }
                        source.Append(se.desc);
                        source.Append(" (");
                        source.Append(name);
                        source.Append("-");
                        source.Append(se.field);
                        source.Append(").\r\n");
                        if (se.repetitions != 1)
                        {
                            source.Append("   * @param rep the repetition number (this is a repeating field)\r\n");
                            source.Append("   * @throws HL7Exception if the repetition number is invalid.\r\n");
                        }
                        source.Append("   */\r\n");
                        source.Append("  public ");
                        source.Append(type);
                        source.Append(" ");
                        source.Append(NuGenSourceGenerator.makeAccessorName(se.desc));
                        source.Append("(");
                        if (se.repetitions != 1)
                        {
                            source.Append("int rep");
                        }
                        source.Append(") ");
                        if (se.repetitions != 1)
                        {
                            source.Append("throws HL7Exception");
                        }
                        source.Append(" {\r\n");
                        source.Append("    ");
                        source.Append(type);
                        source.Append(" ret = null;\r\n");
                        source.Append("    try {\r\n");
                        source.Append("        Type t = this.getField(");
                        source.Append(se.field);
                        source.Append(", ");
                        if (se.repetitions == 1)
                        {
                            source.Append("0");
                        }
                        else
                        {
                            source.Append("rep");
                        }
                        source.Append(");\r\n");
                        source.Append("        ret = (");
                        source.Append(type);
                        source.Append(")t;\r\n");

                        source.Append("    } catch (ClassCastException ) {\r\n");
                        source.Append("        throw new Exception();\r\n");
                        if (se.repetitions == 1)
                        {
                            source.Append("    } catch (HL7Exception he) {\r\n");
                            source.Append("        throw new Exception();\r\n");
                        }
                        source.Append("    }\r\n");
                        source.Append("    return ret;\r\n");
                        source.Append("  }\r\n\r\n");

                        //add an array accessor as well for repeating fields
                        if (se.repetitions != 1)
                        {
                            source.Append("  /**\r\n");
                            source.Append("   * Returns all repetitions of ");
                            source.Append(se.desc);
                            source.Append(" (");
                            source.Append(name);
                            source.Append("-");
                            source.Append(se.field);
                            source.Append(").\r\n");
                            source.Append("   */\r\n");
                            source.Append("  public ");
                            source.Append(type);
                            source.Append("[] ");
                            source.Append(NuGenSourceGenerator.makeAccessorName(se.desc));
                            source.Append("() {\r\n");
                            source.Append("     ");
                            source.Append(type);
                            source.Append("[] ret = null;\r\n");
                            source.Append("    try {\r\n");
                            source.Append("        Type[] t = this.getField(");
                            source.Append(se.field);
                            source.Append(");  \r\n");
                            source.Append("        ret = new ");
                            source.Append(type);
                            source.Append("[t.length];\r\n");
                            source.Append("        for (int i = 0; i < ret.length; i++) {\r\n");
                            source.Append("            ret[i] = (");
                            source.Append(type);
                            source.Append(")t[i];\r\n");
                            source.Append("        }\r\n");
                            source.Append("    } catch (ClassCastException ) {\r\n");
                            source.Append("        throw new Exception();\r\n");
                            source.Append("    } catch (HL7Exception he) {\r\n");
                            source.Append("        throw new Exception();\r\n");
                            source.Append("    }\r\n");
                            source.Append("    return ret;\r\n");
                            source.Append("  }\r\n\r\n");
                        }
                    }
                }

                //add adapter method code for control package if it exists
                //source.append(Control.getImplementation(correspondingControlInterface, version));

                source.Append("}");
            }
            catch (System.Data.OleDb.OleDbException sqle)
            {
                SupportClass.WriteStackTrace(sqle, Console.Error);
            }

            return(source.ToString());
        }
Esempio n. 7
0
        /// <summary> Creates source code for a single data type in the HL7 normative
        /// database.
        /// </summary>
        /// <param name="targetDirectory">the directory into which the file will be written
        /// </param>
        /// <param name="datatype">the name (e.g. ST, ID, etc.) of the data type to be created
        /// </param>
        /// <param name="version">the HL7 version of the intended data type
        /// </param>
        public static void  make(System.IO.FileInfo targetDirectory, System.String dataType, System.String version)
        {
            Console.WriteLine(" Writing " + targetDirectory.FullName + dataType);
            //make sure that targetDirectory is a directory ...
            if (!System.IO.Directory.Exists(targetDirectory.FullName))
            {
                throw new System.IO.IOException("Can't create file in " + targetDirectory.ToString() + " - it is not a directory.");
            }

            //get any components for this data type
            //UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'"
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            //UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'"
            System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
            System.Text.StringBuilder      sql  = new System.Text.StringBuilder();
            //this query is adapted from the XML SIG informative document
            sql.Append("SELECT HL7DataStructures.data_structure, HL7DataStructureComponents.seq_no, HL7DataStructures.description, HL7DataStructureComponents.table_id,  ");
            sql.Append("HL7Components.description, HL7Components.table_id, HL7Components.data_type_code, HL7Components.data_structure ");
            sql.Append("FROM HL7Versions LEFT JOIN (HL7DataStructures LEFT JOIN (HL7DataStructureComponents LEFT JOIN HL7Components ");
            sql.Append("ON HL7DataStructureComponents.comp_no = HL7Components.comp_no AND ");
            sql.Append("HL7DataStructureComponents.version_id = HL7Components.version_id) ");
            sql.Append("ON HL7DataStructures.version_id = HL7DataStructureComponents.version_id ");
            sql.Append("AND HL7DataStructures.data_structure = HL7DataStructureComponents.data_structure) ");
            sql.Append("ON HL7DataStructures.version_id = HL7Versions.version_id ");
            sql.Append("WHERE HL7DataStructures.data_structure = '");
            sql.Append(dataType);
            sql.Append("' AND HL7Versions.hl7_version = '");
            sql.Append(version);
            sql.Append("' ORDER BY HL7DataStructureComponents.seq_no");
            //System.out.println(sql.toString());  //for debugging
            //UPGRADE_TODO: Interface 'java.sql.ResultSet' was converted to 'System.Data.OleDb.OleDbDataReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlResultSet'"
            System.Data.OleDb.OleDbCommand temp_OleDbCommand;
            temp_OleDbCommand             = stmt;
            temp_OleDbCommand.CommandText = sql.ToString();
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList dataTypes    = new System.Collections.ArrayList(20);
            System.Collections.ArrayList descriptions = new System.Collections.ArrayList(20);
            System.Collections.ArrayList tables       = new System.Collections.ArrayList(20);
            System.String description = null;
            while (rs.Read())
            {
                if (description == null)
                {
                    description = System.Convert.ToString(rs[3 - 1]);
                }

                System.String de = System.Convert.ToString(rs[5 - 1]);
                System.String dt = System.Convert.ToString(rs[8 - 1]);
                int           ta = -1;
                if (!rs.IsDBNull(4 - 1))
                {
                    ta = rs.GetInt32(4 - 1);
                }
                //trim all CE_x to CE
                if (dt != null)
                {
                    if (dt.StartsWith("CE"))
                    {
                        dt = "CE";
                    }
                }
                //System.out.println("Component: " + de + "  Data Type: " + dt);  //for debugging
                dataTypes.Add(dt);
                descriptions.Add(de);
                tables.Add((System.Int32)ta);
            }
            if (dataType.ToUpper().Equals("TS") && version != "2.5")
            {
                dataTypes[0] = "TSComponentOne";
            }

            rs.Close();
            //UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'"
            stmt.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            //if there is only one component make a Primitive, otherwise make a Composite
            System.String source = null;
            if (dataTypes.Count == 1)
            {
                if (dataType.Equals("FT") || dataType.Equals("ST") || dataType.Equals("TX") || dataType.Equals("NM") || dataType.Equals("SI") || dataType.Equals("TN") || dataType.Equals("GTS"))
                {
                    source = makePrimitive(dataType, description, version);
                }
                else
                {
                    source = null;                     //note: IS, ID, DT, DTM, and TM are coded manually
                }
            }
            else if (dataTypes.Count > 1)
            {
                int numComponents = dataTypes.Count;
                //copy data into arrays ...
                System.String[] type  = new System.String[numComponents];
                System.String[] desc  = new System.String[numComponents];
                int[]           table = new int[numComponents];
                for (int i = 0; i < numComponents; i++)
                {
                    type[i]  = ((System.String)dataTypes[i]);
                    desc[i]  = ((System.String)descriptions[i]);
                    table[i] = ((System.Int32)tables[i]);
                }
                source = makeComposite(dataType, description, type, desc, table, version);
            }
            else
            {
                //no components?
                //throw new DataTypeException("The data type " + dataType + " could not be found");
                Console.WriteLine("No components for " + dataType);
            }
            //System.out.println(source);

            //write to file ...
            if (source != null)
            {
                System.String targetFile = targetDirectory.ToString() + "/" + dataType + ".cs";
                //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
                //UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'"
                //UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'"
                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(targetFile))
                {
                    writer.Write(source);
                    writer.Write("}");                    //End namespace
                }
            }
            else
            {
                Console.WriteLine("No Source for " + dataType);
            }
        }
Esempio n. 8
0
        /// <summary>   Creates source code for a single data type in the HL7 normative database. </summary>
        ///
        /// <exception cref="IOException">  Thrown when an IO failure occurred. </exception>
        ///
        /// <param name="targetDirectory">  the directory into which the file will be written. </param>
        /// <param name="dataType">         Type of the data. </param>
        /// <param name="version">          the HL7 version of the intended data type. </param>
        ///
        /// ### <param name="datatype"> the name (e.g. ST, ID, etc.) of the data type to be created. </param>

        public static void make(System.IO.FileInfo targetDirectory, System.String dataType, System.String version)
        {
            Console.WriteLine(" Writing " + targetDirectory.FullName + dataType);
            //make sure that targetDirectory is a directory ...
            if (!System.IO.Directory.Exists(targetDirectory.FullName))
            {
                throw new System.IO.IOException("Can't create file in " + targetDirectory + " - it is not a directory.");
            }

            //get any components for this data type
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            System.Data.OleDb.OleDbCommand    stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
            System.Text.StringBuilder         sql  = new System.Text.StringBuilder();
            //this query is adapted from the XML SIG informative document
            sql.Append(
                "SELECT HL7DataStructures.data_structure, HL7DataStructureComponents.seq_no, HL7DataStructures.description, HL7DataStructureComponents.table_id,  ");
            sql.Append(
                "HL7Components.description, HL7Components.table_id, HL7Components.data_type_code, HL7Components.data_structure ");
            sql.Append(
                "FROM HL7Versions LEFT JOIN (HL7DataStructures LEFT JOIN (HL7DataStructureComponents LEFT JOIN HL7Components ");
            sql.Append("ON HL7DataStructureComponents.comp_no = HL7Components.comp_no AND ");
            sql.Append("HL7DataStructureComponents.version_id = HL7Components.version_id) ");
            sql.Append("ON HL7DataStructures.version_id = HL7DataStructureComponents.version_id ");
            sql.Append("AND HL7DataStructures.data_structure = HL7DataStructureComponents.data_structure) ");
            sql.Append("ON HL7DataStructures.version_id = HL7Versions.version_id ");
            sql.Append("WHERE HL7DataStructures.data_structure = '");
            sql.Append(dataType);
            sql.Append("' AND HL7Versions.hl7_version = '");
            sql.Append(version);
            sql.Append("' ORDER BY HL7DataStructureComponents.seq_no");
            System.Data.OleDb.OleDbCommand temp_OleDbCommand;
            temp_OleDbCommand             = stmt;
            temp_OleDbCommand.CommandText = sql.ToString();
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList dataTypes    = new System.Collections.ArrayList(20);
            System.Collections.ArrayList descriptions = new System.Collections.ArrayList(20);
            System.Collections.ArrayList tables       = new System.Collections.ArrayList(20);
            System.String description = null;
            while (rs.Read())
            {
                if (description == null)
                {
                    description = System.Convert.ToString(rs[3 - 1]);
                }

                System.String de = System.Convert.ToString(rs[5 - 1]);
                System.String dt = System.Convert.ToString(rs[8 - 1]);
                int           ta = -1;
                if (!rs.IsDBNull(4 - 1))
                {
                    ta = rs.GetInt32(4 - 1);
                }
                //trim all CE_x to CE
                if (dt != null)
                {
                    if (dt.StartsWith("CE"))
                    {
                        dt = "CE";
                    }
                }
                //System.out.println("Component: " + de + "  Data Type: " + dt);  //for debugging
                dataTypes.Add(dt);
                descriptions.Add(de);
                tables.Add(ta);
            }
            if (dataType.ToUpper().Equals("TS"))
            {
                dataTypes[0] = "TSComponentOne";
            }

            rs.Close();
            stmt.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            //if there is only one component make a Primitive, otherwise make a Composite
            System.String source = null;
            if (dataTypes.Count == 1)
            {
                if (dataType.Equals("FT") || dataType.Equals("ST") || dataType.Equals("TX") || dataType.Equals("NM") ||
                    dataType.Equals("SI") || dataType.Equals("TN") || dataType.Equals("GTS"))
                {
                    source = makePrimitive(dataType, description, version);
                }
                else
                {
                    source = null; //note: IS, ID, DT, DTM, and TM are coded manually
                }
            }
            else if (dataTypes.Count > 1)
            {
                int numComponents = dataTypes.Count;
                //copy data into arrays ...
                System.String[] type  = new System.String[numComponents];
                System.String[] desc  = new System.String[numComponents];
                int[]           table = new int[numComponents];
                for (int i = 0; i < numComponents; i++)
                {
                    type[i]  = ((System.String)dataTypes[i]);
                    desc[i]  = ((System.String)descriptions[i]);
                    table[i] = ((System.Int32)tables[i]);
                }
                source = makeComposite(dataType, description, type, desc, table, version);
            }
            else
            {
                //no components?
                //throw new DataTypeException("The data type " + dataType + " could not be found");
                Console.WriteLine("No components for " + dataType);
            }
            //System.out.println(source);

            //write to file ...
            if (source != null)
            {
                System.String targetFile = targetDirectory + "/" + dataType + ".cs";
                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(targetFile))
                {
                    writer.Write(source);
                    writer.Write("}"); //End namespace
                }
            }
            else
            {
                Console.WriteLine("No Source for " + dataType);
            }
        }
Esempio n. 9
0
        protected CalendarEvent _CreateEventFromData(System.Data.OleDb.OleDbDataReader pEventData, Boolean bRException)
        {
            try
            {
                CalendarEvent pEvent = null;
                int           nEventID;

                if (pEventData.IsClosed /*|| !pEventData.HasRows*/)
                {
                    return(null);
                }

                nEventID = pEventData.GetInt32(pEventData.GetOrdinal("EventID"));
                pEvent   = m_pCalendar.DataProvider.CreateEventEx(nEventID);

                if (pEvent == null)
                {
                    return(null);
                }

                pEvent.Subject  = pEventData.GetString(pEventData.GetOrdinal("Subject"));
                pEvent.Location = pEventData.GetString(pEventData.GetOrdinal("Location"));
                pEvent.Body     = pEventData.GetString(pEventData.GetOrdinal("Body"));

                pEvent.MeetingFlag = ToBool(pEventData.GetInt32(pEventData.GetOrdinal("IsMeeting")));
                pEvent.PrivateFlag = ToBool(pEventData.GetInt32(pEventData.GetOrdinal("IsPrivate")));

                pEvent.Label      = pEventData.GetInt32(pEventData.GetOrdinal("LabelID"));
                pEvent.BusyStatus = (CalendarEventBusyStatus)pEventData.GetInt32(pEventData.GetOrdinal("BusyStatus"));
                pEvent.Importance = (CalendarEventImportance)pEventData.GetInt32(pEventData.GetOrdinal("ImportanceLevel"));

                pEvent.StartTime = pEventData.GetDateTime(pEventData.GetOrdinal("StartDateTime"));
                pEvent.EndTime   = pEventData.GetDateTime(pEventData.GetOrdinal("EndDateTime"));

                pEvent.AllDayEvent = ToBool(pEventData.GetInt32(pEventData.GetOrdinal("IsAllDayEvent")));

                pEvent.Reminder = ToBool(pEventData.GetInt32(pEventData.GetOrdinal("IsReminder")));
                pEvent.ReminderMinutesBeforeStart = pEventData.GetInt32(pEventData.GetOrdinal("ReminderMinutesBeforeStart"));
                pEvent.ReminderSoundFile          = pEventData.GetString(pEventData.GetOrdinal("RemainderSoundFile"));

                pEvent.CustomProperties.LoadFromString(pEventData.GetString(pEventData.GetOrdinal("CustomPropertiesXMLData")));
                pEvent.CustomIcons.LoadFromString(pEventData.GetString(pEventData.GetOrdinal("CustomIconsIDs")));

                pEvent.ScheduleID = pEventData.GetInt32(pEventData.GetOrdinal("ScheduleID"));

                if (bRException)
                {
                    pEvent.MakeAsRException();

                    pEvent.RExceptionStartTimeOrig = pEventData.GetDateTime(pEventData.GetOrdinal("RExceptionStartTimeOrig"));
                    pEvent.RExceptionEndTimeOrig   = pEventData.GetDateTime(pEventData.GetOrdinal("RExceptionEndTimeOrig"));
                    pEvent.RExceptionDeleted       = ToBool(pEventData.GetInt32(pEventData.GetOrdinal("ISRecurrenceExceptionDeleted")));
                }

                if (!bRException)
                {
                    //	"process_RecurrenceState" and "process_RecurrencePatternID" properties
                    //	 are used to process master events.
                    //
                    //	 If they are set and RecurrenceStaie is Master Data provider will
                    //	 fier DoReadRPattern event and make event as Master.
                    //	 And it will also generate occurrences for RetrieveDayEvents method.
                    //
                    //	 These properties are temporary and they will be removed by data provider.
                    //
                    //	 If these properties are not set data provider expect that master event
                    //	 is already compleated - CreateRecurrence method is called and
                    //	 Recurrence pattern is set.
                    //
                    //	 This mechanism is useful for DB data providers, when events and patterns
                    //	 are stored separately (in tables).
                    //	 But if events stored in some memory collection or array
                    //	 it should not be used because master event store recurrence pattern inside.

                    pEvent.CustomProperties["process_RecurrenceState"]     = pEventData.GetValue(pEventData.GetOrdinal("RecurrenceState"));
                    pEvent.CustomProperties["process_RecurrencePatternID"] = pEventData.GetValue(pEventData.GetOrdinal("RecurrencePatternID"));
                }

                return(pEvent);
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine("EXCEPTION! SQLDataHelper.CreateEventFromRS: " + e.Message);
            }

            return(null);
        }
Esempio n. 10
0
        public CalendarRecurrencePattern CreateRPatternFromData(System.Data.OleDb.OleDbDataReader pRPatternData,
                                                                System.Data.OleDb.OleDbConnection pOleDbConn)
        {
            try
            {
                CalendarRecurrencePattern pRPattern = null;
                int nPatternID;

                if (pRPatternData.IsClosed /*|| !pRPatternData.HasRows*/)
                {
                    return(null);
                }

                nPatternID = pRPatternData.GetInt32(pRPatternData.GetOrdinal("RecurrencePatternID"));
                pRPattern  = m_pCalendar.DataProvider.CreateRecurrencePattern(nPatternID);

                if (pRPattern == null)
                {
                    return(null);
                }

                pRPattern.MasterEventId = pRPatternData.GetInt32(pRPatternData.GetOrdinal("MasterEventID"));

                pRPattern.StartTime       = pRPatternData.GetDateTime(pRPatternData.GetOrdinal("EventStartTime"));
                pRPattern.DurationMinutes = pRPatternData.GetInt32(pRPatternData.GetOrdinal("EventDuration"));

                pRPattern.StartDate = pRPatternData.GetDateTime(pRPatternData.GetOrdinal("PatternStartDate"));

                pRPattern.EndMethod = (CalendarPatternEnd)pRPatternData.GetInt32(pRPatternData.GetOrdinal("PatternEndMethod"));

                if (pRPattern.EndMethod == CalendarPatternEnd.xtpCalendarPatternEndDate)
                {
                    pRPattern.EndDate = pRPatternData.GetDateTime(pRPatternData.GetOrdinal("PatternEndDate"));
                }
                else if (pRPattern.EndMethod == CalendarPatternEnd.xtpCalendarPatternEndAfterOccurrences)
                {
                    pRPattern.EndAfterOccurrences = pRPatternData.GetInt32(pRPatternData.GetOrdinal("PatternEndAfterOccurrences"));
                }
                else
                {
                    System.Diagnostics.Debug.Assert(pRPattern.EndMethod == CalendarPatternEnd.xtpCalendarPatternEndNoDate);
                }

                pRPattern.Options.Data1 = pRPatternData.GetInt32(pRPatternData.GetOrdinal("OptionsData1"));
                pRPattern.Options.Data2 = pRPatternData.GetInt32(pRPatternData.GetOrdinal("OptionsData2"));
                pRPattern.Options.Data3 = pRPatternData.GetInt32(pRPatternData.GetOrdinal("OptionsData3"));
                pRPattern.Options.Data4 = pRPatternData.GetInt32(pRPatternData.GetOrdinal("OptionsData4"));

                pRPattern.CustomProperties.LoadFromString(pRPatternData.GetString(pRPatternData.GetOrdinal("CustomPropertiesXMLData")));

                pRPatternData.Close();

                ReadRPatternExceptions(pRPattern, pOleDbConn);

                return(pRPattern);
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine("EXCEPTION! SQLDataHelper.CreateRPatternFromData: " + e.Message);
            }

            return(null);
        }