示例#1
0
        public static void get_data_field_value_compound_component_text(
            string field_specifier,
            string value_from_fen,
            string value_compound_component_text_already_found
            )
        {
            data_field_format the_data_field_format  = null;
            double            numeric_value_original = -1000000001.0;  // guaranteed to be not a value from the db

            if (
                setting.dictionary_data_field_format.TryGetValue(
                    field_specifier,
                    out the_data_field_format
                    )
                )
            {
                if (value_compound_component_text_already_found.Length == 0)
                {
                    numeric_value_original = utility.get_double(value_from_fen, -1000000001.0);

                    if (the_data_field_format.value_format.Length > 0)
                    {
                        if (numeric_value_original > -1000000000.0)
                        {
                            the_data_field_format.value_compound_component_text = string.Format(
                                the_data_field_format.value_format,
                                numeric_value_original * the_data_field_format.conversion_factor
                                );
                        }
                        else
                        {
                            the_data_field_format.value_compound_component_text = string.Format(
                                the_data_field_format.value_format,
                                value_from_fen
                                );
                        }
                    }
                    else
                    {
                        the_data_field_format.value_compound_component_text = value_from_fen;
                    }
                }
                else
                {
                    the_data_field_format.value_compound_component_text = value_compound_component_text_already_found;
                }
            }
        }
示例#2
0
        // load into "dictionary_data_field_format"
        public static bool load_data_field_format(
            string unit_system             // can only be "english" or "metric"
            )
        {
            bool b_return = false;

            dictionary_data_field_format.Clear();
            tech_serv_data_processing_modules.traffic_data_processing_general tdpg = new tech_serv_data_processing_modules.traffic_data_processing_general();
            tdpg.initialize_generic_members("sqlite");
            try
            {
                tdpg.construct_connection_string("", "", "", setting.data_field_format_program_setting_pathname);
                tdpg.open_conn_cmd(0);
                tdpg.cmd[0].CommandText = "select * from mmhis_data_field_format";
                tdpg.reader[0]          = tdpg.cmd[0].ExecuteReader();
                while (tdpg.reader[0].Read())
                {
                    data_field_format the_data_field_format = new data_field_format();
                    the_data_field_format.field_specifier    = tdpg.reader[0]["field_specifier"].ToString();
                    the_data_field_format.caption_suggestion = tdpg.reader[0]["caption_suggestion"].ToString();
                    the_data_field_format.value_format       = tdpg.reader[0]["value_format_" + unit_system].ToString();
                    the_data_field_format.unit = tdpg.reader[0]["unit_" + unit_system].ToString();
                    the_data_field_format.conversion_factor = utility.get_double(tdpg.reader[0]["conversion_factor_" + unit_system], 1.0);
                    dictionary_data_field_format.Add(the_data_field_format.field_specifier, the_data_field_format);
                }
                b_return = true;
            }
            catch
            {
                b_return = false;
            }
            finally
            {
                try
                {
                    tdpg.reader[0].Close();
                }
                catch { }
                try
                {
                    tdpg.close_conn_cmd(0);
                }
                catch { }
            }

            return(b_return);
        }