예제 #1
0
        //Checks the server status & channel
        private void checkServerStatus()
        {
            //Lower the server availability flag while this method is running
            serverIsAvailable = false;

            try
            {
                //Check if the server has been initialized
                if (server == null)
                {
                    //Prepare the instance context
                    InstanceContext instanceContext = new InstanceContext(this);
                    //Initialize the server using the instance context above
                    server = new ServerInterfaceClient(instanceContext);
                }
                //Check the server state
                if (server.State != CommunicationState.Opened)
                {
                    //Prepare the instance context
                    InstanceContext instanceContext = new InstanceContext(this);
                    //Initialize the server using the instance context above
                    server = new ServerInterfaceClient(instanceContext);
                }
            }
            catch (Exception e)
            {
                debugMessage(e.StackTrace);
                //If the current method fails - raise this custom exception
                throw new Exception("ATMS/Model-0002: Failed to check the server.");
            }
        }
예제 #2
0
파일: Model.cs 프로젝트: op07n/ATMPractice
        public Model(ViewModel viewModel)
        {
            // Construct InstanceContext to handle messages on callback interface
            InstanceContext instanceContext = new InstanceContext(this);

            //create a client
            this.c1 = new ServerInterfaceClient(instanceContext);

            this.viewModel = viewModel;
        }