コード例 #1
0
        public void StartNew(WinFileSystem win, ClientInfo client, FileFolderInfo selectedFile)
        {
            ControlledClient = client;
            string path = FileSystemDialog.GetSaveFile(null, true, false, selectedFile.Name);

            if (path != null)
            {
                FileTransmissionInfo trans = new FileTransmissionInfo()
                {
                    File = selectedFile
                };
                try
                {
                    download = new DownloadingInfo(win, client, path, trans);
                }
                catch (Exception ex)
                {
                    TaskDialog.ShowException(ex, "建立本地文件失败!");
                    return;
                }
                Telnet.Instance.FileSystemDownloadErrorReceived += FileSystemDownloadErrorReceived;
                Telnet.Instance.FileSystemDownloadPartReceived  += FileSystemDownloadPartReceived;

                Telnet.Instance.Send(new CommandBody(
                                         File_AskForDownloading, Global.CurrentClient.ID, client.ID, trans));

                download.Dialog.ShowDialog();
            }
        }
コード例 #2
0
 /// <summary>
 ///     Show a dialog formatted to display an Exception message
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Exception_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         File.Open("FileNotFound.txt", FileMode.Open);
     }
     catch (Exception exception)
     {
         TaskDialog.ShowException(exception);
     }
 }
コード例 #3
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Config.Save();
            if (string.IsNullOrWhiteSpace(Config.DbConnectionString))
            {
                TaskDialog.ShowError("数据库连接字符串为空!");
                return;
            }
            grdControl.IsEnabled = false;
            btnStart.Content     = "正在启动服务";
            try
            {
                DatabaseHelper.Instance.Model = new SCMSModel(Config.DbConnectionString);
                DatabaseHelper.Instance.Model.Database.CommandTimeout = 2;

                bool exist = false;
                await Task.Run(() =>
                {
                    exist = DatabaseHelper.Instance.Model.Database.Exists();
                });

                if (!exist)
                {
                    TaskDialog.ShowError("数据库连接失败");
                    grdControl.IsEnabled = true;
                    btnStart.Content     = "启动";
                    return;
                }
                //model.Database.Exists();

                NetHelper.SocketServie();
                btnStart.Content = "服务已启动";
            }
            catch (Exception ex)
            {
                TaskDialog.ShowException(ex, "启动失败");
                try
                {
                    DatabaseHelper.Instance.Model.Dispose();
                }
                catch
                {
                }
                grdControl.IsEnabled = true;
                btnStart.Content     = "启动";
            }
        }
コード例 #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Config.Save();

            grdControl.IsEnabled = false;
            btnStart.Content     = "正在启动服务";
            try
            {
                //DatabaseHelper.Instance.Model = new SCMSModel(Config.DbConnectionString);
                //DatabaseHelper.Instance.Model.Database.CommandTimeout = 2;

                //bool exist = false;
                //await Task.Run(() =>
                //{
                //    //exist = DatabaseHelper.Instance.Model.Database.Exists();
                //});
                //if (!exist)
                //{
                //    TaskDialog.ShowError("数据库连接失败");
                //    grdControl.IsEnabled = true;
                //    btnStart.Content = "启动";
                //    return;

                //}
                ////model.Database.Exists();

                Telnet.Start();
                btnStart.Content = "服务已启动";
            }
            catch (Exception ex)
            {
                TaskDialog.ShowException(ex, "启动失败");
                try
                {
                    //DatabaseHelper.Instance.Model.Dispose();
                }
                catch
                {
                }
                grdControl.IsEnabled = true;
                btnStart.Content     = "启动";
            }
        }