Ejemplo n.º 1
0
        private static DibalScale[] GetScales(string MP)   // Записываем в массив настройки подключения весов
        {
            try
            {
                ConfigTxt  config       = new ConfigTxt();
                SqlCommand mySqlCommand = mySqlConnection.CreateCommand();
                mySqlCommand.CommandText = "SELECT IpAddress , ReceptionPortRx  From ScalesDibal Where fAct = 'true' and  MP = '" + MP + "' and [NumberScale] = '" + config.NumberProgramImport + "' ";
                SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
                mySqlDataAdapter.SelectCommand = mySqlCommand;
                DataSet myDataSet = new DataSet();
                mySqlConnection.Open();
                int numberScales = mySqlDataAdapter.Fill(myDataSet, "Scales");
                mySqlConnection.Close();
                DataTable    myDataTable = myDataSet.Tables["Scales"];
                DibalScale   scale;
                DibalScale[] myScales = new DibalScale[numberScales];
                ArrayList    arlScale = new ArrayList();
                //Default Scale variables
                int    scaleMasterAddressAux = 0;
                string scaleIpAddressAux     = string.Empty;
                int    scalePortRxAux        = 3000;
                int    scalePortTxAux        = 3001;
                string scaleModelAux         = MODEL500RANGE;
                string scaleDisplayAux       = string.Empty;
                string scaleSectionsAux      = string.Empty;
                int    scaleGroupAux         = 0;
                string scaleLogsPathAux      = string.Empty;

                foreach (DataRow myDataRow in myDataTable.Rows)
                {
                    if (!string.IsNullOrEmpty(myDataRow["IpAddress"].ToString()))
                    {
                        scaleIpAddressAux = myDataRow["IpAddress"].ToString();
                    }
                    int.TryParse(myDataRow["ReceptionPortRx"].ToString(), out scalePortRxAux);
                    scaleModelAux = MODEL500RANGE;
                    scale         = new DibalScale(scaleMasterAddressAux, scaleIpAddressAux, scalePortTxAux, scalePortRxAux, scaleModelAux, scaleDisplayAux, scaleSectionsAux, scaleGroupAux, scaleLogsPathAux);
                    arlScale.Add(scale);
                    myScales = (DibalScale[])arlScale.ToArray(typeof(DibalScale));
                }
                return(myScales);
            }
            catch (Exception ex)
            {
                Log.Write(ex, "Ошибка записи в массив настройки подключения весов  DibalScale[] GetScales(string id ) ");
                throw ex;
            }
            finally
            {
                if (mySqlConnection != null)
                {
                    mySqlConnection.Close();
                }
            }
        }
Ejemplo n.º 2
0
 public static string ConnectionString()
 {
     try
     {
         ConfigTxt config = new ConfigTxt();
         return("Data Source=" + config.Server + @"\" + config.SqlServer + ";Initial Catalog=" + config.DateBase + ";Integrated Security=True");
     }
     catch (Exception ex)
     {
         Log.Write(ex, " - Ошибка в class DBConStrs");
         throw ex;
     }
 }