Esempio n. 1
0
        private void CheckAndUpdateState()
        {
            try
            {
                string tableName = ManagerFs.GetTableNameFromCtl();
                if (tableName == "Не найден файл контрола")
                {
                    MessageBox.Show(tableName);
                    this.Close();
                    return;
                }

                string curDir  = ManagerFs.GetCurrentDir().FullName;
                string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                this.Title = curDir.Substring(curDir.IndexOf('\\') + 1) + "   (" + tableName + ")    v." + version;
                bool isTableFree = ManagerDb.IsTableFree(tableName);
                if (isTableFree)
                {
                    ManagerDb.InsertToTable(tableName);
                    MediatorSema.CurrentFileType = FileType.Bat;
                    GetFiles();
                }
                else
                {
                    AskWindow askWin = new AskWindow();
                    askWin.Title             = tableName;
                    askWin.label_ask.Content = String.Format("Таблица занята пользователем {0} c {1}.", MediatorSema.UsingTable.UserName, MediatorSema.UsingTable.StartTime);
                    askWin.EventExit        += AskWin_EventExit;
                    askWin.EventPickUpTable += AskWin_EventPickUpTable;
                    askWin.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "CheckAndUpdateState() Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }