Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            _CompanyName = "CSFPI";

            /// CHECK CONNECTION TO SERVER
            Classes.MySQL A = new Classes.MySQL();
            if (A.openConnection() == false)
            {
                this.DckMain.IsEnabled = false;
                MessageBox.Show("Error : Cannot connect to App Center Server!", "CSF APP CENTER", MessageBoxButton.OK, MessageBoxImage.Error);
                A.conn.Close(); A.conn.Dispose();
                Application.Current.Shutdown();
            }
            A.conn.Close(); A.conn.Dispose();

            /// get file version of app
            StackPanel Stkpnl = new StackPanel()
            {
                Orientation = Orientation.Vertical
            };
            TextBlock txtb1 = new TextBlock()
            {
                Text = "App Version : " + GetAssemblyFileVersion(), Foreground = Brushes.Black, FontWeight = FontWeights.Bold
            };
            TextBlock txtb2 = new TextBlock()
            {
                Text = "Latest Version : " + AppsCenterLatestVersion(), Foreground = GetAssemblyFileVersion().Equals(AppsCenterLatestVersion()) ? Brushes.Black : Brushes.Crimson, FontWeight = FontWeights.Bold
            };

            Stkpnl.Children.Add(txtb1);
            Stkpnl.Children.Add(txtb2);
            BtnAppInfo.ToolTip = Stkpnl;
        }
Пример #2
0
        private string AppsCenterLatestVersion()
        {
            try
            {
                if (_AppsCenterLatestVersion == null)
                {
                    using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM csf_app_center.apps where appname like '*CSF APPS CENTER';"))
                    {
                        Classes.MySQL A = new Classes.MySQL();
                        if (A.openConnection() == false)
                        {
                            throw new Exception("MySQL Connection is not open!");
                        }

                        cmd.Connection = A.conn;
                        MySqlDataReader rdr = cmd.ExecuteReader();
                        if (rdr.Read())
                        {
                            _AppsCenterLatestVersion = rdr.GetString("Latest_Version");
                        }

                        A.conn.Close();
                        A.conn.Dispose();
                    }
                }

                return(_AppsCenterLatestVersion);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, "CSF TICKETING", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
        }