Exemple #1
0
 public MainWindow()
 {
     InitializeComponent();
     try
     {
         CALogger.InitLogFile(Properties.Settings.Default.LogFile);
     }
     catch
     {
         MessageBox.Show("Ошибка в файле конфигурации");
         Close();
     }
     CALogger.WriteToLogFile("Программа запущена");
     CALogger.WriteToLogFile("Подключение к БД…");
     try
     {
         string UserLevelPath = Properties.Settings.Default.DBFilePath;
         if (ConnectionStringGiver.GetValidConnectionString(ref UserLevelPath) != null)
         {
             Properties.Settings.Default.DBFilePath = UserLevelPath;
         }
         else
         {
             CALogger.WriteToLogFile("Не найдена БД"); Close();
         }
     }
     catch
     {
         CALogger.WriteToLogFile("Ошибка при считывании строки подключения!");
         MessageBox.Show("Ошибка в файле конфигурации");
         Close();
     }
 }
        static Sample()
        {
            string s = "";

            if (connection is null)
            {
                connection = new SqlConnection(ConnectionStringGiver.GetValidConnectionString(ref s));
            }
        }
        public DataPoint()
        {
            string s = "";

            if (connection is null)
            {
                connection = new SqlConnection(ConnectionStringGiver.GetValidConnectionString(ref s));
            }
        }
Exemple #4
0
        public SaltAnalysisData(decimal CarnalliteThreshold = (decimal)0.0008)
        {
            string s = "";

            if (connection is null)
            {
                connection = new SqlConnection(ConnectionStringGiver.GetValidConnectionString(ref s));
            }
            carnalliteThreshold = CarnalliteThreshold;
        }
Exemple #5
0
        static LinearCalibration()
        {
            //couldn't save new path so use a dummy string
            string s = string.Empty;

            if (connection is null)
            {
                connection = new SqlConnection(ConnectionStringGiver.GetValidConnectionString(ref s));
            }
        }
Exemple #6
0
        public LinearCalibration()
        {
            string s = string.Empty;

            if (connection is null)
            {
                connection = new SqlConnection(ConnectionStringGiver.GetValidConnectionString(ref s));
            }
            LinearCalibrationData    = new ObservableCollection <DataPoint> [2];
            LinearCalibrationData[0] = new ObservableCollection <DataPoint>();
            LinearCalibrationData[1] = new ObservableCollection <DataPoint>();
            Slope           = new decimal[2];
            RSquared        = new decimal[2];
            Intercept       = new decimal[2];
            CalibrationDate = DateTime.Today;
        }
Exemple #7
0
        static SaltAnalysisData()
        {
            string s = "";

            if (connection is null)
            {
                connection = new SqlConnection(ConnectionStringGiver.GetValidConnectionString(ref s));
            }
            if (lcDict is null)
            {
                lcDict = new Dictionary <int, Calibration.LinearCalibration>();
            }
            if (elementsWeights is null)
            {
                Uri    UriAssemblyFolder = new Uri(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase));
                string appPath           = UriAssemblyFolder.LocalPath;

                //Open the configuration file and retrieve the applicationSettings section.
                Configuration config = ConfigurationManager.OpenExeConfiguration(appPath + @"\ChemicalAnalyses.exe");
                elementsWeights = (ClientSettingsSection)config.SectionGroups["applicationSettings"].Sections[0];
                NumberFormatInfo nfi = new NumberFormatInfo {
                    NumberDecimalSeparator = "."
                };
                //read application level constants
                if (!decimal.TryParse(elementsWeights.Settings.Get("Mg").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awMg))
                {
                    awMg = (decimal)24.305;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("H").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awH))
                {
                    awH = (decimal)1.008;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("O").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awO))
                {
                    awO = (decimal)15.999;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("Ca").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awCa))
                {
                    awCa = (decimal)40.078;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("Cl").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awCl))
                {
                    awCl = (decimal)35.45;
                }
                _water2MagnesiumRatioInCarnallite = 6 * (2 * awH + awO) / awMg;
                if (!decimal.TryParse(elementsWeights.Settings.Get("Na").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awNa))
                {
                    awNa = (decimal)23.99;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("K").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awK))
                {
                    awK = (decimal)39.099;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("C").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awC))
                {
                    awC = (decimal)12.011;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("S").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awS))
                {
                    awS = (decimal)32.07;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("Br").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awBr))
                {
                    awBr = (decimal)79.9;
                }
                if (!decimal.TryParse(elementsWeights.Settings.Get("B").Value.ValueXml.InnerText, NumberStyles.Number, nfi, out awB))
                {
                    awB = (decimal)10.81;
                }
                _SO4_2_CaS04            = (awS + 4 * awO) / (awS + 4 * awO + awCa);
                _CaSO4_2_SO4            = (awS + 4 * awO + awCa) / (awS + 4 * awO);
                _CaCl2_2_Ca             = (awCa + awCl * 2) / awCa;
                _MgCl2_2_Mg             = (awMg + awCl * 2) / awMg;
                _KCl_2_K                = (awK + awCl) / awK;
                _NaCl_2_Cl              = (awNa + awCl) / awCl;
                _KBr_2_Br               = (awK + awBr) / awBr;
                _Carnallite_2_Magnesium = (12 * awH + 6 * awO + awMg + 3 * awCl + awK) / awMg;
            }
        }