コード例 #1
0
ファイル: GameDatabase.cs プロジェクト: afii369/FagNet
        public ChannelCollection GetChannels(EServerType serverType)
        {
            var col = new ChannelCollection();

            using (var con = GetConnection())
            {
                using (var cmd = con.CreateCommand())
                {
                    cmd.CommandText = "SELECT * FROM channels";
                    using (var r = cmd.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            var channel = new Channel
                            {
                                ServerType = serverType,
                                ID         = r.GetUInt16("ID"),
                                Name       = r.GetString("Name")
                            };
                            col.TryAdd(channel.ID, channel);
                        }
                    }
                }
            }
            return(col);
        }
コード例 #2
0
        private BaseClient(string playerName, Rooms rooms, PlayerChannels playerChannels, RoomChannels roomChannels)
        {
            if (playerName == null)
            {
                throw new ArgumentNullException("playerName");
            }
            if (rooms == null)
            {
                throw new ArgumentNullException("rooms");
            }
            if (playerChannels == null)
            {
                throw new ArgumentNullException("playerChannels");
            }
            if (roomChannels == null)
            {
                throw new ArgumentNullException("roomChannels");
            }

            Log = Logs.Create(LogCategory.Network, GetType().Name);

            _playerName = playerName;

            _byteBufferPool = new ConcurrentPool <byte[]>(10, () => new byte[1024]);
            _queuedUnreliableTransmissions = new TransferBuffer <ArraySegment <byte> >(16);
            _queuedReliableTransmissions   = new TransferBuffer <ArraySegment <byte> >(16);
            _queuedEvents = new List <NetworkEvent>();

            _peers                = new PeerCollection(this);
            _channels             = new ChannelCollection(_peers.RoutingTable, playerChannels, roomChannels);
            _connectionNegotiator = new ConnectionNegotiator(this);
            _router               = new PacketRouter(this, _connectionNegotiator);
            _commsProcessor       = new CommsProcessor(this, _peers.RoutingTable, rooms, _channels);
            _roomsManager         = new RoomMembershipManager(this, _connectionNegotiator, rooms);
        }
コード例 #3
0
ファイル: Server.cs プロジェクト: aarondl/Project-2Q
        /// <summary>
        /// Creates a server from a ServerConfig with a parameter
        /// to provide an interface for logging.
        /// </summary>
        /// <param name="config">The configuration to build the Server from.</param>
        /// <param name="logFunction">The function to call to log text for the application.</param>
        public Server(Configuration.ServerConfig config, Project2QService.WriteLogFunction logFunction)
        {
            //Instantiate and load databases
            uc = new UserCollection();
            cc = new ChannelCollection();
            uc.LoadRegisteredUsers( "userdb\\" + config.Name + ".udb" );

            //Rip up this little guy to help us out :D
            currentHost = new IRCHost();
            currentIP = null;

            this.authmode = !File.Exists( "userdb\\" + config.Name + ".udb" );

            this.writeLogFunction = logFunction;

            //Assign a Server ID
            this.serverId = Server.NextServerId;
            if ( this.serverId == -1 ) throw new OverflowException( "Too many servers created." );
            servers[serverId] = this;

            //Save the configuration.
            this.config = config;

            //Tie default static handlers together for this instance of IRCEvents.
            irce = new IRCEvents();

            //Initialize the socket pipe before the modules. Modules are scary.
            state = State.Disconnected;

            socketPipe = new SocketPipe(
                this.serverId, config.RetryTimeout, config.OperationTimeout, config.SendInhibit, config.SocketBufferSize ); //Default values for now, get them from config later plz.
            socketPipe.OnDisconnect += new SocketPipe.NoParams( this.OnDisconnect );
            socketPipe.OnReceive += new SocketPipe.ReceiveData( this.OnReceive );
        }
コード例 #4
0
 public GameServerTcp(string ip, int port, int maxConnections) : base(ip, port, maxConnections)
 {
     Channels = new ChannelCollection(this)
     {
         new Channel("Free #1", maxPlayers: 100, typechannel: ChannelTypeEnum.All, id: 1),
     };
 }
コード例 #5
0
        public override void ServerStart()
        {
            try
            {
                Data.InsertServer();
                _isRunning = true;
                _server.Start((int)Data.MaxPlayers);

                if (DateTime.Now == EndTime || (DateTime.Now.Month == EndTime.Month && DateTime.Now.Day == EndTime.Day))
                {
                    _isRunning = false;
                }
                WriteConsole.WriteLine($"[SERVER_START]: PORT {Data.Port}", ConsoleColor.Green);
                //Inicia os Lobby's
                Ini = new IniFile(ConfigurationManager.AppSettings["ChannelConfig"]);

                LobbyList = new ChannelCollection(Ini);
                //Inicia a leitura dos arquivos .iff
                new IffBaseManager();//is 100% work? test for iff
                //Inicia Thread para escuta de clientes
                var WaitConnectionsThread = new Thread(new ThreadStart(HandleWaitConnections));
                WaitConnectionsThread.Start();
            }
            catch (Exception erro)
            {
                new GameTools.ClearMemory().FlushMemory();
                WriteConsole.WriteLine($"[ERROR_START]: {erro.Message}");
                Console.ReadKey();
                Environment.Exit(1);
            }
        }
コード例 #6
0
        private ChannelCollection <TChannel> RefreshPlaylistAsync(BackgroundWorker worker, DoWorkEventArgs e)
        {
            if (worker == null)
            {
                throw new ArgumentNullException("worker");
            }
            var channels = new ChannelCollection <TChannel>();

            int percentageComplete = 0;

            worker.ReportProgress(0);
            worker.ReportProgress(50);

            worker.ReportProgress(100);

            try
            {
                channels = _channelView.GetView(false);
            }
            catch (XmlException)
            {
                DISiteUnavailable();
            }

            return(channels);
        }
コード例 #7
0
 private void RemoveAllChannel()
 {
     if (MsgBox.QuestionShow("确认清空所有通道吗?") == MsgBoxResult.OK)
     {
         ChannelCollection?.Clear();
     }
 }
コード例 #8
0
        private void AddChannel()
        {
            var channel = new ChannelInfo();

            channel.CSMSSelectedItem = CSMSCollection.First();
            ChannelCollection.Add(channel);
        }
コード例 #9
0
ファイル: Channel.cs プロジェクト: nhatkycon/AoCuoiHongNhung
        public static ChannelCollection SelectByDmIdByBid(string DM_ID, string B_ID)
        {
            ChannelCollection List = new ChannelCollection();

            SqlParameter[] obj = new SqlParameter[2];
            if (String.IsNullOrEmpty(DM_ID))
            {
                obj[0] = new SqlParameter("DM_ID", DBNull.Value);
            }
            else
            {
                obj[0] = new SqlParameter("DM_ID", DM_ID);
            }
            if (String.IsNullOrEmpty(B_ID))
            {
                obj[1] = new SqlParameter("B_ID", DBNull.Value);
            }
            else
            {
                obj[1] = new SqlParameter("B_ID", B_ID);
            }
            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "tblRss_sp_tblRssChannel_Select_SelectByDmIdByBid_linhnx", obj))
            {
                while (rd.Read())
                {
                    List.Add(getFromReader(rd));
                }
            }
            return(List);
        }
コード例 #10
0
ファイル: pProject.aspx.cs プロジェクト: wwkkww1983/yh
 /// <summary>
 ///
 /// </summary>
 /// <param name="n1"></param>
 /// <param name="channelCollection"></param>
 private void CreateLowLevelChannel(TreeNode parent, ChannelCollection channelCollection)
 {
     foreach (ChannelClass c in channelCollection)
     {
         TreeNode n = CreateChannelTreeNode(c);
         CreateLowLevelChannel(n, c.LowLevelCollection);
         parent.ChildNodes.Add(n);
     }
 }
コード例 #11
0
ファイル: Account.cs プロジェクト: Klako/ShitChat
 public Account(string username, string password, AccountTypes userType, bool isBanned)
 {
     this.username = username;
     this.password = password;
     this.accountType = userType;
     this.isBanned = isBanned;
     this.friends = new AccountCollection();
     this.channelList = new ChannelCollection();
 }
コード例 #12
0
ファイル: Account.cs プロジェクト: Klako/ShitChat
 public Account(string username, string password, AccountTypes userType, bool isBanned, AccountCollection friends, ChannelCollection channelList)
 {
     this.username = username;
     this.password = password;
     this.accountType = userType;
     this.isBanned = isBanned;
     this.channelList = channelList;
     this.friends = friends;
 }
コード例 #13
0
        /// <summary>
        /// Emits all devices in Storage.settingsData.logicalChannelManager that have the particular ChannelType ct
        /// to the GridView in the "Logical devices" tab of the ChannelManager form. It makes use of EmitLogicalDeviceToGrid
        /// method which is responsible for emitting a single logical device to the grid.
        /// </summary>
        private void EmitLogicalDeviceDictToGrid(HardwareChannel.HardwareConstants.ChannelTypes ct)
        {
            ChannelCollection selectedDeviceDict =
                Storage.settingsData.logicalChannelManager.GetDeviceCollection(ct);

            foreach (int logicalID in selectedDeviceDict.Channels.Keys)
            {
                EmitLogicalDeviceToGrid(ct, logicalID, selectedDeviceDict.Channels[logicalID]);
            }
        }
コード例 #14
0
        public void DoNotDuplicateChannelWhenCallingGetChannel()
        {
            var collection = new ChannelCollection();
            var channel    = new Channel("#test");

            collection.Add(channel);
            var channel2 = collection.GetChannel("#test");

            Assert.Single(collection);
            Assert.Same(channel, channel2);
        }
コード例 #15
0
 private void Init()
 {
     if (this.channels == null)
     {
         this.channels = new ChannelCollection(this.Invalidate);
     }
     if (backImage == null)
     {
         backImage = new Bitmap(Width, Height);
     }
 }
コード例 #16
0
ファイル: IrcClient.cs プロジェクト: angelog/ChatSharp
        public IrcClient(string serverAddress, IrcUser user)
        {
            if (serverAddress == null) throw new ArgumentNullException("serverAddress");
            if (user == null) throw new ArgumentNullException("user");

            User = user;
            ServerAddress = serverAddress;
            Encoding = Encoding.UTF8;
            Channels = new ChannelCollection(this);
            Settings = new ClientSettings();
        }
コード例 #17
0
ファイル: BaseLocalTuner.cs プロジェクト: ewin66/media
 /// <summary>
 /// Called when the KnownChannels collection should be loaded
 /// </summary>
 public virtual void LoadKnownChannels()
 {
     try
     {
         this.KnownChannels = ChannelCollection.LoadFromFile(GetKnownChannelsStoreFilename());
     }
     catch (Exception ex)
     {
         this.KnownChannels = new ChannelCollection();
         ErrorLogger.DumpToDebug(ex);
     }
 }
コード例 #18
0
        /// <summary>
        /// For the channels in the specified channel collection, if any of them are CurrentFavorites, we will assume that
        /// the argument has more current information, and we'll copy that info.
        /// </summary>
        /// <param name="knownChannels">the most up to date channel information</param>
        public void UpdateFavorites(ChannelCollection knownChannels)
        {
            for (int i = 0; i < CurrentFavorites.Items.Count; i++)
            {
                int index = knownChannels.IndexOf(CurrentFavorites.Items[i]);
                if (index > -1)
                {
                    CurrentFavorites.Items[i] = knownChannels.Items[index];
                }
            }

            RecreateThumbnails();
        }
コード例 #19
0
ファイル: Channel.cs プロジェクト: nhatkycon/AoCuoiHongNhung
        public static ChannelCollection SelectAll()
        {
            ChannelCollection List = new ChannelCollection();

            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "tblRss_sp_tblRssChannel_Select_SelectAll_linhnx"))
            {
                while (rd.Read())
                {
                    List.Add(getFromReader(rd));
                }
            }
            return(List);
        }
コード例 #20
0
ファイル: IrcClient.cs プロジェクト: randacc/ChatSharp
        public IrcClient(string serverAddress, IrcUser user)
        {
            if (serverAddress == null) throw new ArgumentNullException("serverAddress");
            if (user == null) throw new ArgumentNullException("user");

            User = user;
            ServerAddress = serverAddress;
            Encoding = Encoding.UTF8;
            Channels = new ChannelCollection(this);
            Settings = new ClientSettings();
            Handlers = new Dictionary<string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
        }
コード例 #21
0
        private void deleteDeviceButton_Click(object sender, EventArgs e)
        {
            // Determine the device that is being edited
            SelectedDevice selectedDevice = DetermineSelectedLogicalChannelFromGrid();

            if (selectedDevice != null) // Abort if nothing is selected
            {
                ChannelCollection selectedDeviceCollection = Storage.settingsData.logicalChannelManager.GetDeviceCollection(
                    selectedDevice.channelType);
                selectedDeviceCollection.RemoveChannel(selectedDevice.logicalID);

                // For visual feedback
                RefreshLogicalDeviceDataGrid();
            }
        }
コード例 #22
0
ファイル: pProject.aspx.cs プロジェクト: wwkkww1983/yh
        /// <summary>
        ///
        /// </summary>
        private void BindTree()
        {
            TreeView1.Nodes.Clear();
            WaterUserClass    wu       = SessionManager.LoginSession.WaterUser;
            ChannelCollection channels = wu.ChannelCollection;

            foreach (ChannelClass c in channels)
            {
                //this.TreeView1
                TreeNode n = CreateChannelTreeNode(c);
                CreateLowLevelChannel(n, c.LowLevelCollection);
                CreateStation(n, c.StationCollection);
                this.TreeView1.Nodes.Add(n);
            }
        }
コード例 #23
0
ファイル: ChannelSelect.aspx.cs プロジェクト: wwkkww1983/yh
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            ChannelCollection cc = SessionManager.WaterUserSession.WaterUser.ChannelCollection;

            cc.Clear();
            foreach (ListItem item in this.clChannel.Items)
            {
                if (item.Selected)
                {
                    int          id = Convert.ToInt32(item.Value);
                    ChannelClass c  = ChannelFactory.CreateChannel(id);
                    cc.Add(c);
                }
            }
            Response.Redirect("WaterUser.aspx");
        }
コード例 #24
0
 private void EnsureIncomingChannelCollection()
 {
     lock (base.ThisLock)
     {
         if (this.incomingChannels == null)
         {
             this.incomingChannels = new ChannelCollection(this, base.ThisLock);
             if (this.firstIncomingChannel != null)
             {
                 this.incomingChannels.Add(this.firstIncomingChannel);
                 this.ChannelRemoved(this.firstIncomingChannel);
                 this.firstIncomingChannel = null;
             }
         }
     }
 }
コード例 #25
0
 private void EnsureIncomingChannelCollection()
 {
     lock (ThisLock)
     {
         if (_incomingChannels == null)
         {
             _incomingChannels = new ChannelCollection(this, ThisLock);
             if (_firstIncomingChannel != null)
             {
                 _incomingChannels.Add(_firstIncomingChannel);
                 ChannelRemoved(_firstIncomingChannel); // Adding to collection called ChannelAdded, so call ChannelRemoved to balance
                 _firstIncomingChannel = null;
             }
         }
     }
 }
コード例 #26
0
 void EnsureIncomingChannelCollection()
 {
     lock (this.ThisLock)
     {
         if (this.incomingChannels == null)
         {
             this.incomingChannels = new ChannelCollection(this, this.ThisLock);
             if (this.firstIncomingChannel != null)
             {
                 this.incomingChannels.Add(this.firstIncomingChannel);
                 this.ChannelRemoved(this.firstIncomingChannel); // Adding to collection called ChannelAdded, so call ChannelRemoved to balance
                 this.firstIncomingChannel = null;
             }
         }
     }
 }
コード例 #27
0
        /// <summary>
        /// Emits all devices in Storage.settingsData.logicalChannelManager that have the particular ChannelType ct
        /// to the GridView in the "Logical devices" tab of the ChannelManager form. It makes use of EmitLogicalDeviceToGrid
        /// method which is responsible for emitting a single logical device to the grid.
        /// </summary>
        private void EmitLogicalDeviceDictToGrid(HardwareChannel.HardwareConstants.ChannelTypes ct)
        {
            ChannelCollection selectedDeviceDict =
                Storage.settingsData.logicalChannelManager.GetDeviceCollection(ct);
            List <KeyValuePair <int, LogicalChannel> > channels = new List <KeyValuePair <int, LogicalChannel> >(selectedDeviceDict.Channels);

            if (orderChannelsCheckBox.Checked)
            {
                OrderLogicalChannels(orderChannels.SelectedItem as String, channels);
            }

            foreach (KeyValuePair <int, LogicalChannel> channel in channels)
            {
                EmitLogicalDeviceToGrid(ct, channel.Key, channel.Value);
            }
        }
コード例 #28
0
        public StreamingTVGraph(StreamSourceInfo sourceConfig, OpenGraphRequest openGraphRequest)
            : base(sourceConfig, openGraphRequest)
        {
            InitializeNetworkSink();

            this.TVConfig = sourceConfig.TVTuner;

            try
            {
                this.KnownChannels = ChannelCollection.LoadFromFile(GetKnownChannelsStoreFilename());
            }
            catch (Exception ex)
            {
                this.KnownChannels = new ChannelCollection();
                AppLogger.Dump(ex);
            }
        }
コード例 #29
0
ファイル: ChannelView.cs プロジェクト: jaypatrick/dica
        /// <summary>
        /// </summary>
        /// <param name="channels"> </param>
        public ChannelView(ChannelCollection <TChannel> channels)
        // NEED A SPECIFIC VIEW TYPE SERVED UP (WEB, WINFORMS, ETC)
            : base(channels)
        {
            if (channels == null)
            {
                throw new ArgumentNullException("channels");
            }
            ParseSortSettings();

            Settings.Default.SettingsSaving += (sender, e) =>
            {
                ClearItems <object>();
                ParseSortSettings();
                IsViewSet = false;
            };
        }
コード例 #30
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RecordService recordService = new RecordService();

            records = new RecordCollection(recordService.GetAll());

            ProgramService programService = new ProgramService();

            programs = new ProgramCollection(programService.GetAll());

            dgridTvRecord.ItemsSource = records.collecion;
            dgridProgram.ItemsSource  = programs.collecion;

            ChannelService channelService = new ChannelService();

            channels = new ChannelCollection(channelService.GetAll());
        }
コード例 #31
0
ファイル: IrcClient.cs プロジェクト: Luigifan/Luigibot
        public IrcClient(string serverAddress, IrcUser user, bool useSSL = false)
        {
            if (serverAddress == null) throw new ArgumentNullException("serverAddress");
            if (user == null) throw new ArgumentNullException("user");

            User = user;
            ServerAddress = serverAddress;
            Encoding = Encoding.UTF8;
            Channels = new ChannelCollection(this);
            Settings = new ClientSettings();
            Handlers = new Dictionary<string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
            UseSSL = useSSL;
            WriteQueue = new ConcurrentQueue<string>();
            PrivmsgPrefix = "";
        }
コード例 #32
0
        protected virtual void LoadFavoritesLists()
        {
            ChannelCollection <TChannel> channels = _channelView.GetView(true, StationType.All);

            ChannelCountLabel.Text = string.Format(P.Resources.ChannelsAvailableNumber, channels.Count.ToString());

            channels.ForEach(channel =>
            {
                switch (channel.PlaylistType)
                {
                case StationType.DI:
                    {
                        PlaylistLabel1.Text = string.Format("{0} {1}", channel.PlaylistType.ToString(),
                                                            "Channels");
                        DIPlaylistCheckedList.Items.Add(channel.ChannelName,
                                                        Settings.Default.PlaylistFavorites.Contains(
                                                            channel.ChannelName));
                        break;
                    }

                case StationType.Sky:
                    {
                        PlaylistLabel2.Text = string.Format("{0} {1}", channel.PlaylistType.ToString(),
                                                            "Channels");
                        SkyPlaylistCheckedList.Items.Add(channel.ChannelName,
                                                         Settings.Default.PlaylistFavorites.Contains(
                                                             channel.ChannelName));
                        break;
                    }

                //case PlaylistTypes.External:
                default:
                    {
                        PlaylistLabel3.Text = string.Format("{0} {1}", channel.PlaylistType.ToString(),
                                                            "Channels");
                        ExternalPlaylistCheckBox.Items.Add(channel.ChannelName,
                                                           Settings.Default.PlaylistFavorites.Contains(
                                                               channel.ChannelName));
                        break;
                    }
                }
            });
        }
コード例 #33
0
        public void Start()
        {
            _logger.Info("Connecting to MySQL database...");
            try
            {
                GameDatabase.Instance.TryConnect(ChatConfig.Instance.MySQLGame.Server, ChatConfig.Instance.MySQLGame.User, ChatConfig.Instance.MySQLGame.Password, ChatConfig.Instance.MySQLGame.Database);
                AuthDatabase.Instance.TryConnect(ChatConfig.Instance.MySQLAuth.Server, ChatConfig.Instance.MySQLAuth.User, ChatConfig.Instance.MySQLAuth.Password, ChatConfig.Instance.MySQLAuth.Database);

                _channels = GameDatabase.Instance.GetChannels(EServerType.Chat);
            }
            catch (Exception ex)
            {
                _logger.Error("Could not connect to MySQL database: {0}\r\n{1}",
                              ex.Message, ex.InnerException);
                Environment.Exit(0);
            }
            _server.Start();
            _logger.Info("Ready for connections!");
        }
コード例 #34
0
        /// <summary>
        /// Begins the channel scanning operation
        /// </summary>
        public void StartChannelScan()
        {
            AppLogger.Message("StreamingTVGraph.StartChannelScan");
            if (channelScanWorker == null)
            {
                channelScanWorker                            = new BackgroundWorker();
                channelScanWorker.DoWork                    += new DoWorkEventHandler(channelScanWorker_DoWork);
                channelScanWorker.ProgressChanged           += new ProgressChangedEventHandler(channelScanWorker_ProgressChanged);
                channelScanWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(channelScanWorker_RunWorkerCompleted);
                channelScanWorker.WorkerReportsProgress      = true;
                channelScanWorker.WorkerSupportsCancellation = true;
            }

            if (!channelScanWorker.IsBusy)
            {
                _foundChannels = new ChannelCollection();
                channelScanWorker.RunWorkerAsync();
            }
        }
コード例 #35
0
        public MainWindow()
        {
            InitializeComponent();

            ptsc = new PolytweetServiceClient.PolytweetServiceClient();
            user = ptsc.connect("bobo", "pass");
            ptsc.initTestContext();
            channelCollection = new ChannelCollection();
            //channelCollection.Add(new ChannelObject(ptsc.findChannel("name")[0]));
            channelCollection = new ChannelCollection(ptsc.getAllChannel());
            channelCollectionEmpty = new ChannelCollection();

            ObjectDataProvider channelSource = (ObjectDataProvider)FindResource("ChannelCollection");
            channelSource.ObjectInstance = channelCollection;
            ObjectDataProvider channelSourceEmpty = (ObjectDataProvider)FindResource("ChannelCollectionEmpty");
            channelSourceEmpty.ObjectInstance = channelCollectionEmpty;

            foreach(ChannelObject c in channelCollection)
            {
                cbx_choixChannel.Items.Add(c);
            }
        }
コード例 #36
0
        /// <summary>
        /// In the small AddDevice form, everything begins as soon as the user specifies which ChannelType is to
        /// be modified.
        /// </summary>
        private void deviceTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Point to the correct DeviceCollection
            string selectedTypeString = this.deviceTypeCombo.SelectedItem.ToString();

            selectedChannelType       = HardwareChannel.HardwareConstants.ParseChannelTypeFromString(selectedTypeString);
            selectedChannelCollection = Storage.settingsData.logicalChannelManager.GetDeviceCollection(selectedChannelType);

            // Initialize and enable the Name, Description text entries and the HardwareChannel drop-down list
            this.deviceNameText.Enabled = true;
            this.deviceDescText.Enabled = true;

            refreshHardwareChanCombo();
            this.availableHardwareChanCombo.Enabled = true;

            // Indicate the logical ID to be used
            this.logicalIDText.Text = selectedChannelCollection.GetNextSuggestedKey().ToString();

            okButton.Enabled = true; // Now we can allow the OK button

            if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog)
            {
                checkBox1.Visible = true;
            }
            else
            {
                checkBox1.Visible = false;
            }

            if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog ||
                selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.digital)
            {
                togglingCheck.Visible = true;
            }
            else
            {
                togglingCheck.Visible = false;
            }
        }
コード例 #37
0
ファイル: ChannelSelect.aspx.cs プロジェクト: wwkkww1983/yh
        /// <summary>
        ///
        /// </summary>
        private void Bind()
        {
            ChannelCollection cc = ChannelFactory.CreateChannelCollection();

            this.clChannel.DataSource     = cc;
            this.clChannel.DataTextField  = "ChannelName";
            this.clChannel.DataValueField = "ChannelID";
            this.DataBind();


            ChannelCollection selectedCC = SessionManager.WaterUserSession.WaterUser.ChannelCollection;

            foreach (ChannelClass c in selectedCC)
            {
                foreach (ListItem item in this.clChannel.Items)
                {
                    if (c.ChannelID == Convert.ToInt32(item.Value))
                    {
                        item.Selected = true;
                    }
                }
            }
        }
コード例 #38
0
 public ProcessingUnit()
 {
     InputChannels = new ChannelCollection<IChannel>(1);
     OutputChannels = new ChannelCollection<IChannel>(Multiplicity.Many);
     ControlChannels = new ChannelCollection<IChannel>(1);
 }
コード例 #39
0
ファイル: GameDatabase.cs プロジェクト: KingCrazy/S115
 public ChannelCollection GetChannels(EServerType serverType)
 {
     var col = new ChannelCollection();
     using (var con = GetConnection())
     {
         using (var cmd = con.CreateCommand())
         {
             cmd.CommandText = "SELECT * FROM channels";
             using (var r = cmd.ExecuteReader())
             {
                 while (r.Read())
                 {
                     var channel = new Channel
                     {
                         ServerType = serverType,
                         ID = r.GetUInt16("ID"),
                         Name = r.GetString("Name")
                     };
                     col.TryAdd(channel.ID, channel);
                 }
             }
         }
     }
     return col;
 }
コード例 #40
0
ファイル: pProject.aspx.cs プロジェクト: hkiaipc/yh
 /// <summary>
 /// 
 /// </summary>
 /// <param name="n1"></param>
 /// <param name="channelCollection"></param>
 private void CreateLowLevelChannel(TreeNode parent, ChannelCollection channelCollection)
 {
     foreach (ChannelClass c in channelCollection)
     {
         TreeNode n = CreateChannelTreeNode(c);
         CreateLowLevelChannel(n, c.LowLevelCollection);
         parent.ChildNodes.Add(n);
     }
 }
コード例 #41
0
ファイル: AccountInformation.cs プロジェクト: Klako/ShitChat
        public static void Save(string filename = "accounts")
        {
            Console.WriteLine("Saving data");
            string accountsPlainText = "";
            foreach (Account account in accounts)
            {
                accountsPlainText += account.Name + ";";
                accountsPlainText += account.Password + ";";
                accountsPlainText += account.IsBanned.ToString() + ";";
                accountsPlainText += Enum.GetName(typeof(AccountTypes), account.AccountType) + ";";
                if (account.Friends.Count > 0)
                {
                    string friends = "";
                    foreach (Account friend in account.Friends)
                    {
                        friends += friend.Name + ";";
                    }
                    accountsPlainText += friends;
                }
                accountsPlainText += ".";
                if (account.ChannelList.Count > 0)
                {
                    string channels = ";";
                    foreach (Channel channel in account.ChannelList)
                    {
                        channels += channel.Name;
                        if (channel != account.ChannelList.Last())
                        {
                            channels += ";";
                        }
                    }
                    accountsPlainText += channels;
                }
                if (account != accounts.Last())
                {
                    accountsPlainText += "\n";
                }
            }

            byte[] accountsData = Encoding.UTF8.GetBytes(accountsPlainText);
            FileStream fStream = File.Open("accounts", FileMode.OpenOrCreate);
            fStream.SetLength(accountsData.Length);
            fStream.Write(accountsData, 0, accountsData.Length);
            fStream.Close();
        }
コード例 #42
0
 private static void fixChannelReferences(ChannelCollection<IChannel> collection,
     ChannelReferencesCollection reference,
     Dictionary<string, IChannel> lookup)
 {
     for (int k = 0; k < reference.Count; k++)
     {
         if (!lookup.ContainsKey(reference[k].Name))
             throw new KeyNotFoundException(string.Format("Channel '{0}' undefined.", reference[k].Name));
         collection.Add(lookup[reference[k].Name]);
     }
 }
コード例 #43
0
ファイル: ChatServer.cs プロジェクト: KingCrazy/S115
        public void Start()
        {
            _logger.Info("Connecting to MySQL database...");
            try
            {
                GameDatabase.Instance.TryConnect(ChatConfig.Instance.MySQLGame.Server, ChatConfig.Instance.MySQLGame.User, ChatConfig.Instance.MySQLGame.Password, ChatConfig.Instance.MySQLGame.Database);
                AuthDatabase.Instance.TryConnect(ChatConfig.Instance.MySQLAuth.Server, ChatConfig.Instance.MySQLAuth.User, ChatConfig.Instance.MySQLAuth.Password, ChatConfig.Instance.MySQLAuth.Database);

                _channels = GameDatabase.Instance.GetChannels(EServerType.Chat);
            }
            catch (Exception ex)
            {
                _logger.Error("Could not connect to MySQL database: {0}\r\n{1}",
                    ex.Message, ex.InnerException);
                Environment.Exit(0);
            }
            _server.Start();
            _logger.Info("Ready for connections!");
        }
コード例 #44
0
ファイル: GameServer.cs プロジェクト: jacerrillo/TempestCore
        public GameServer()
        {
            Channels = new ChannelCollection();
            Rooms = new RoomCollection();
            Players = new PlayerCollection();
            Logger = new Logger() { WriteToConsole = true };
            _packetLogger = new PacketLogger();
            Logger.Load(Path.Combine("logs", string.Format("game_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss"))));
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject));
                Environment.Exit(0);
            };

            _packetLogger.Load("game_packets.log");

            Logger.Info("Loading game_config.xml...");
            GameConfig.Load();
            Logger.Info("Setting up servers...");
            _server = new TcpServer(IPAddress.Parse(GameConfig.Instance.IP), GameConfig.Instance.Port);
            _server.PacketReceived += HandlePacket;
            _server.ClientDisconnected += ClientDisconnected;
            _server.Error += Error;

            var isMono = Type.GetType("Mono.Runtime") != null;
            switch (GameConfig.Instance.AuthRemote.Binding)
            {
                case "pipe":
                    if (isMono)
                    {
                        Logger.Error("pipe is not supported in mono, use http!");
                        Environment.Exit(1);
                        return;
                    }
                    _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(GameConfig.Instance.AuthRemote.Password)));
                    break;

                case "tcp":
                    if (isMono)
                    {
                        Logger.Error("pipe is not supported in mono, use http!");
                        Environment.Exit(1);
                        return;
                    }
                    _authRemoteClient = new RemoteClient(ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", GameConfig.Instance.AuthRemote.Server, GameConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(GameConfig.Instance.AuthRemote.Password)));
                    break;

                case "http":
                    _authRemoteClient = new RemoteClient(ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", GameConfig.Instance.AuthRemote.Server, GameConfig.Instance.AuthRemote.Port, SHA256.ComputeHash(GameConfig.Instance.AuthRemote.Password)));
                    break;

                default:
                    Logger.Error("Invalid remote binding '{0}' for AuthRemote", GameConfig.Instance.AuthRemote.Binding);
                    Environment.Exit(1);
                    break;
            }

            Logger.Info("Loading plugins... {0}",AppDomain.CurrentDomain.BaseDirectory);
            _pluginManager.Load();

            foreach (var plugin in _pluginManager.Plugins)
                Logger.Info("Loaded {0}", plugin.Name);
        }
コード例 #45
0
ファイル: GameServer.cs プロジェクト: jacerrillo/TempestCore
        public void Start()
        {
            Logger.Info("Connecting to MySQL database...");
            try
            {
                GameDatabase.Instance.TryConnect(GameConfig.Instance.MySQLGame.Server, GameConfig.Instance.MySQLGame.User, GameConfig.Instance.MySQLGame.Password, GameConfig.Instance.MySQLGame.Database);
                AuthDatabase.Instance.TryConnect(GameConfig.Instance.MySQLAuth.Server, GameConfig.Instance.MySQLAuth.User, GameConfig.Instance.MySQLAuth.Password, GameConfig.Instance.MySQLAuth.Database);
                Channels = GameDatabase.Instance.GetChannels(EServerType.Game);

                GameDatabase.Instance.UpdateOnlineFlags();
            }
            catch (Exception ex)
            {
                Logger.Error("Could not connect to MySQL database: {0}\r\n{1}", ex.Message, ex.InnerException);
                Environment.Exit(0);
            }
            _server.Start();

            _roomHandlerTask = Task.Factory.StartNew(RoomHandler);
            _roomHandlerTask.ContinueWith((t) => { if (t.IsFaulted) Error(this, new ExceptionEventArgs(t.Exception)); });
            Logger.Info("Ready for connections!");
        }