当前位置: 首页>>代码示例>>C#>>正文


C# ServerConnection.ForceDisconnected方法代码示例

本文整理汇总了C#中ServerConnection.ForceDisconnected方法的典型用法代码示例。如果您正苦于以下问题:C# ServerConnection.ForceDisconnected方法的具体用法?C# ServerConnection.ForceDisconnected怎么用?C# ServerConnection.ForceDisconnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServerConnection的用法示例。


在下文中一共展示了ServerConnection.ForceDisconnected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: dbBackupWorker_DoWork

 void dbBackupWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         using (SqlConnection backupConnection = new SqlConnection(Properties.Settings.Default.Cafeteria_Vernier_dbConnectionString))
         {
             backupConnection.Open();
             dbBackupWorker.ReportProgress(10);
             System.Threading.Thread.Sleep(200);
             ServerConnection sc = new ServerConnection(backupConnection);
             Server databaseServer = new Server(sc);
             Backup databaseBackup = new Backup();
             databaseBackup.Action = BackupActionType.Database;
             dbBackupWorker.ReportProgress(20);
             System.Threading.Thread.Sleep(200);
             databaseBackup.Database = backupConnection.Database.ToString();
             databaseBackup.Devices.Add(new BackupDeviceItem(System.IO.Path.Combine(e.Argument.ToString(), string.Format("{0}.bak", DateTime.Now.ToString("ddMMyyyyhhsstt"))), DeviceType.File));
             databaseBackup.LogTruncation = BackupTruncateLogType.Truncate;
             dbBackupWorker.ReportProgress(0);
             databaseBackup.SqlBackup(databaseServer);
             dbBackupWorker.ReportProgress(1);
             System.Threading.Thread.Sleep(200);
             sc.ForceDisconnected();
             dbBackupWorker.ReportProgress(30);
         }
     }
     catch (Exception)
     {
         
         throw;
     }
 }
开发者ID:shuvo009,项目名称:CafeteriaVernier,代码行数:32,代码来源:MainWindow.xaml.cs

示例2: autoBackUp

        private void autoBackUp()
        {
            for (; ; )
            {
                try
                {
                    using (SqlConnection backupConnection = new SqlConnection(Properties.Settings.Default.bdConnectionString))
                    {
                        backupConnection.Open();
                        ServerConnection sc = new ServerConnection(backupConnection);
                        Server databaseServer = new Server(sc);
                        Backup databaseBackup = new Backup();
                        databaseBackup.Action = BackupActionType.Database;
                        databaseBackup.Database = backupConnection.Database.ToString();
                        databaseBackup.Devices.Add(new BackupDeviceItem(System.IO.Path.Combine(this.folderCreateor(Properties.Settings.Default.backupPath, DateTime.Today.ToString("yyyy-MM-dd")), string.Format("{0}.bak", DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss-tt"))), DeviceType.File));
                        databaseBackup.LogTruncation = BackupTruncateLogType.Truncate;
                        databaseBackup.SqlBackup(databaseServer);
                        sc.ForceDisconnected();
                        databaseBackup = null;
                        backupConnection.Dispose();
                    }
                    timeDec = Properties.Settings.Default.backupAfter;
                    Properties.Settings.Default.lastBackup = DateTime.Now;
                    ImagePath = "database.png";
                    Action updateInfo = new Action(() => { this.backupProgress.IsIndeterminate = false; this.lastbackupTime.Text = DateTime.Now.ToString(); this.timeDecrement.Start(); });
                    this.Dispatcher.Invoke(updateInfo, DispatcherPriority.Normal);
                    System.Threading.Thread.Sleep(Properties.Settings.Default.backupAfter);

                }
                catch (System.Threading.ThreadAbortException)
                {

                }
                catch (FailedOperationException ex)
                {
                    Action errorUpdate = new Action(() => { MessageBox.Show(string.Format("{0}\n{1}",ex.Message,Variables.ERROR_MESSAGES[4]), Variables.ERROR_MESSAGES[0], MessageBoxButton.OK, MessageBoxImage.Error); });
                    this.Dispatcher.Invoke(errorUpdate, DispatcherPriority.Normal);
                    System.Threading.Thread.Sleep(Properties.Settings.Default.backupAfter);
                }
                catch (Exception ex)
                {
                    Action errorUpdate = new Action(() => { MessageBox.Show(ex.Message, Variables.ERROR_MESSAGES[0], MessageBoxButton.OK, MessageBoxImage.Error); });
                    this.Dispatcher.Invoke(errorUpdate, DispatcherPriority.Normal);
                    System.Threading.Thread.Sleep(Properties.Settings.Default.backupAfter);
                }
            }
        }
开发者ID:shuvo009,项目名称:CafeteriaVernier,代码行数:47,代码来源:MainWindow.xaml.cs


注:本文中的ServerConnection.ForceDisconnected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。