Пример #1
0
 public Connection( Server serv, ConnManager man )
 {
     Serv = serv;
     CMan = man;
     Thread t = new Thread( new ThreadStart( Active ) );
     t.Start();
 }
Пример #2
0
        public static List<Server> GetServers()
        {
            List<Server> newList = new List<Server>();
            Server s = new Server();
            s.Name = "WiNA";
            s.Address = "wina.ugent.be";
            s.Ident = "TangBot";
            s.MyNick = "YellingBird";
            s.MyDescription = "I'm AWESOME";
            s.Port = 6667;
            s.Channels = new List<Channel>();

            Channel c = new Channel();
            c.CName = "zeus";
            c.CFullName = "#zeus";
            c.CServer = s;
               // s.Channels.Add(c);

            c = new Channel();
            c.CName = "YellingBird";
            c.CFullName = "#YellingBird";
            c.CServer = s;
            s.Channels.Add( c );

            newList.Add( s );
            return newList;
        }
Пример #3
0
 public bool Send( Server serv , string message )
 {
     if ( serv.Name == null )
     {
         foreach ( var item in Sockets.Values )
         {
             item.Write( message );
         }
     }
     if ( Sockets.ContainsKey( serv ) )
     {
         return Sockets[ serv ].Write( message );
     }
     else
     {
         return false;
     }
 }
Пример #4
0
        private void BackupDB(string databaseName, string serverName, string path)
        {
            try
            {
                Backup sqlBackup = new Backup();

                sqlBackup.Action = BackupActionType.Database;
                sqlBackup.BackupSetDescription = "ArchiveDataBase:" + DateTime.Now.ToShortDateString();
                sqlBackup.BackupSetName = "Archive";

                sqlBackup.Database = databaseName;

                BackupDeviceItem deviceItem = new BackupDeviceItem(path, DeviceType.File);
                ServerConnection connection = new ServerConnection(serverName);
                Server sqlServer = new Server(connection);

                Database db = sqlServer.Databases[databaseName];

                sqlBackup.Initialize = true;
                sqlBackup.Checksum = true;
                sqlBackup.ContinueAfterError = true;

                sqlBackup.Devices.Add(deviceItem);
                sqlBackup.Incremental = false;

                //sqlBackup.ExpirationDate = DateTime.Now.AddDays(3);
                sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;

                sqlBackup.FormatMedia = false;

                sqlBackup.SqlBackup(sqlServer);

                MessageBox.Show(Constant.MESSAGE_SUCCESS_BACKUP,
                    Constant.CAPTION_CONFIRMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                MessageBox.Show(Constant.MESSAGE_ERROR_BACKUP + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_ERROR_BACKUP_PATH,
                    Constant.CAPTION_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
 public UnknownChannelException( Server server , Channel channel )
     : base()
 {
     this.server = server;
     this.channel = channel;
 }
Пример #6
0
 public void Receive( Server serv , string message )
 {
     while(PostProc == null) {}
     PostProc.Receive( serv , message );
 }
Пример #7
0
        private void RS()
        {
            Restore sqlRestore = new Restore();

            BackupDeviceItem deviceItem = new BackupDeviceItem(@"D:\Bakup\Weedon.bak", DeviceType.File);
            sqlRestore.Devices.Add(deviceItem);
            sqlRestore.Database = "Weedon";

            ServerConnection connection = new ServerConnection(@".\SQLEXPRESS");

            Server sqlServer = new Server(connection);

            Database db = sqlServer.Databases["Weedon"];
            sqlRestore.Action = RestoreActionType.Database;
            String dataFileLocation = @"C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Weedon.mdf";
            String logFileLocation = @"C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Weedon_Log.ldf";
            db = sqlServer.Databases["Weedon"];
            RelocateFile rf = new RelocateFile("Weedon", dataFileLocation);

            //sqlRestore.RelocateFiles.Add(new RelocateFile("Weedon", dataFileLocation));
            //sqlRestore.RelocateFiles.Add(new RelocateFile("Weedon" + "_log", logFileLocation));

            System.Data.DataTable logicalRestoreFiles = sqlRestore.ReadFileList(sqlServer);
            sqlRestore.RelocateFiles.Add(new RelocateFile(logicalRestoreFiles.Rows[0][0].ToString(), dataFileLocation));
            sqlRestore.RelocateFiles.Add(new RelocateFile(logicalRestoreFiles.Rows[1][0].ToString(), logFileLocation));

            sqlRestore.ReplaceDatabase = true;
            //sqlRestore.Complete += new ServerMessageEventHandler(sqlRestore_Complete);
            sqlRestore.PercentCompleteNotification = 10;
            //sqlRestore.PercentComplete +=
               //new PercentCompleteEventHandler(sqlRestore_PercentComplete);

            //sqlServer.ConnectionContext.Disconnect();

            sqlRestore.SqlRestore(sqlServer);
            db = sqlServer.Databases["Weedon"];
            db.SetOnline();
            sqlServer.Refresh();
        }
Пример #8
0
        private void RestoreDB(string databaseName, string serverName, string path)
        {
            try
            {
                // Create a new database restore operation
                Restore rstDatabase = new Restore();
                // Set the restore type to a database restore
                rstDatabase.Action = RestoreActionType.Database;
                // Set the database that we want to perform the restore on
                rstDatabase.Database = databaseName;

                // Set the backup device from which we want to restore, to a file
                BackupDeviceItem deviceItem = new BackupDeviceItem(path, DeviceType.File);
                // Add the backup device to the restore type
                rstDatabase.Devices.Add(deviceItem);
                // If the database already exists, replace it
                rstDatabase.ReplaceDatabase = true;

                ServerConnection connection = new ServerConnection(serverName);
                Server sqlServer = new Server(connection);

                // Perform the restore
                rstDatabase.SqlRestore(sqlServer);

                MessageBox.Show(Constant.MESSAGE_SUCCESS_RESTORE,
                    Constant.CAPTION_CONFIRMATION, MessageBoxButtons.OK, MessageBoxIcon.Information);

                FormMain.isRestored = true;
                Application.Exit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Constant.MESSAGE_ERROR_RESTORE + Constant.MESSAGE_NEW_LINE + Constant.MESSAGE_ERROR_BACKUP_PATH,
                    Constant.CAPTION_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
 public void Receive( Server server , string msg )
 {
     //:[email protected] PRIVMSG #zeus :3m is ideaal
     //:[email protected] PART #zeus
     //:[email protected] JOIN :#zeus
     //:wina.kelder.be 332 YellingBird #zeus :Zeus WPI | Please don't feed the trolls http://tinyurl.com/33ob4or | Got paint? http://bit.ly/9646nm
     //:wina.kelder.be 333 YellingBird #zeus Lolcat 1278758838
     //:wina.kelder.be 353 YellingBird = #zeus :YellingBird reeeelix kire Rofldawg kidk nudded CIA-1 Chton Tots Frying_ookelvis jaspervdj GilJ Mathiasdm +ddfreyne +polipie @Javache lucas +dolfijn +mrosmosis +MrWhite
     //:wina.kelder.be 366 YellingBird #zeus :End of /NAMES list.
     Message newMessage = new Message();
     newMessage.Time = DateTime.Now;
     newMessage.RawLine = msg;
     msg = msg.TrimStart( ':' );
     newMessage.MServer = server;
     // :[email protected] PRIVMSG #zeus :excellent, time to reverse engineer me some IRC :p
     string[] messageparts = msg.Split( new char[] { ':' } , 2 );
     string left = messageparts[ 0 ];
     string right = "";
     if ( messageparts.Length > 1 )
     {
         right = messageparts[ 1 ];
     }
     //:[email protected] PRIVMSG #zeus :3m is ideaal
     if ( left.Contains( "PRIVMSG" ) )
     {
         ProcessPrivMsg( newMessage , left , right );
     }
     //:[email protected] JOIN :#zeus
     else if ( left.Contains( "JOIN" ) )
     {
         ProcessJoin( newMessage , left , right );
     }
     //:[email protected] PART #zeus
     else if ( left.Contains( "PART" ) )
     {
         ProcessPart( newMessage , left );
     }
     //:[email protected] QUIT :Quit: Lost terminal
     else if ( left.Contains( "QUIT" ) )
     {
         ProcessQuit( newMessage , left , right );
     }
     //:wina.kelder.be 332 YellingBird #zeus :Zeus WPI | Please don't feed the trolls http://tinyurl.com/33ob4or | Got paint? http://bit.ly/9646nm
     else if ( left.Contains( "332" ) )
     {
         ProcessTopic( newMessage , left , right );
     }
     //:wina.kelder.be 353 YellingBird = #zeus :YellingBird reeeelix kire Rofldawg kidk nudded CIA-1 Chton Tots Frying_ookelvis jaspervdj GilJ Mathiasdm +ddfreyne +polipie @Javache lucas +dolfijn +mrosmosis +MrWhite
     else if ( left.Contains( "353" ) )
     {
         ProcessNickList( newMessage , left , right );
     }
     //:wina.kelder.be 311 YellingBird Chton ~Chton ip-213-49-92-48.dsl.scarlet.be * :bram de buyser
     else if ( left.Contains( "311" ) )
     {
         ProcessWhois( newMessage , left , right );
     }
     if ( newMessage.Line == null )
     {
         newMessage.Line = "";
     }
     if ( newMessage.MUser == null )
     {
        newMessage.MUser = ( from User y in newMessage.MServer.AllUsers where y.Nick.Equals( newMessage.MServer.MyNick ) select y ).FirstOrDefault();
     }
     CentralHub.Receive( newMessage );
 }
Пример #10
0
 private void BuildUserList( string right , Server server , Channel channel )
 {
     string[] rightparts = right.Split( new char[] { ' ' } );
     foreach ( string nick in rightparts )
     {
         string n = nick;
         n = n.Replace( "@" , "" );
         n = n.Replace( "+" , "" );
         n = n.Replace( "&" , "" );
         User result = ( from User y in server.AllUsers where y.Nick.Equals( n ) select y ).FirstOrDefault();
         if ( result == null )
         {
             result = new User();
             result.Nick = n;
             result.UServer = server;
             server.AllUsers.Add( result );
         }
         if ( !channel.CUsers.Contains( result ) )
         {
             channel.CUsers.Add( result );
         }
         if ( result.Ident == null )
         {
             ConnManager.Instance.Send( server , "WHOIS " + n );
         }
     }
 }