Ejemplo n.º 1
0
        private void PrintBtn_Click(object sender, RoutedEventArgs e)
        {
            hasAccess();
            SubSystem x = new SubSystem();

            if (datagrid.ItemsSource == null)
            {
                ErrorHandler.NotifyUser(Errors.NotSearched);
                return;
            }
            if (SubsystemCom.Text == "مناقصات")
            {
                x = SubSystem.Tendering;
            }
            else if (SubsystemCom.Text == "قرارداد ها")
            {
                x = SubSystem.Contract;
            }
            else if (SubsystemCom.Text == "آیین نامه ها")
            {
                x = SubSystem.Regulation;
            }
            else if (SubsystemCom.Text == "مدیریت کاربران")
            {
                x = SubSystem.UserManagement;
            }
            else
            {
                x = SubSystem.TenderingArchive;
            }

            string y = ((int)x).ToString();

            NavigationService.Navigate(new RTM.Report.GenralRep.Log_Viewer(Date1DP.SelectedDate, Date2DP.SelectedDate, y));
        }
Ejemplo n.º 2
0
        protected Message ProcessIncomingEnvelope(Envelope env)
        {
            this.IncomingEnvelopes.Enqueue(env);
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            appState = SubSystem.appState as GMAppState;
            if (env.Message.GetType() == typeof(ShotMessage))
            {
                Logger.Info("Received a shot message in RespondShot convo");
                ShotMessage shotMessage = (ShotMessage)env.Message;
                GameId = shotMessage.getGameId();
                appState.isAHit(shotMessage.getXcord(), shotMessage.getYcord(), shotMessage.getPlayerId());
                appState.isAWin(shotMessage.getPlayerId());
                appState.P1turn = !appState.P1turn;
                appState.LastX  = shotMessage.getXcord();
                appState.LastY  = shotMessage.getYcord();

                ResultMessage resultMessage = new ResultMessage(appState.lastShotResult, GameId, appState.end, appState.end, false, appState.LastX, appState.LastY, messageNumber, this.ConversationId);
                return(resultMessage);
            }
            else
            {
                Logger.Error("Did not receive a shot message in RespondShot convo");
                return(new ErrorMessage(1, messageNumber, ConversationId));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutSubSystem(int id, SubSystem subSystem)
        {
            if (id != subSystem.SubSystemId)
            {
                return(BadRequest());
            }

            _context.Entry(subSystem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubSystemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
    public virtual bool configure(SubSystem subSystem)
    {
      if (this.state == 0)
      {
        int num1;
        NoClassDefFoundError classDefFoundError;
        Exception exception;
        try
        {
          try
          {
            this.module.configure(subSystem);
            this.state = 1;
            num1 = 1;
          }
          catch (Exception ex)
          {
            int num2 = 0;
            M0 m0 = ByteCodeHelper.MapException<NoClassDefFoundError>(ex, (ByteCodeHelper.MapFlags) num2);
            if (m0 == null)
            {
              throw;
            }
            else
            {
              classDefFoundError = (NoClassDefFoundError) m0;
              goto label_9;
            }
          }
        }
        catch (Exception ex)
        {
          int num2 = 0;
          M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num2);
          if (m0 == null)
          {
            throw;
          }
          else
          {
            exception = (Exception) m0;
            goto label_10;
          }
        }
        return num1 != 0;
label_9:
        Log.warn((object) new Log.SimpleMessage("Unable to load module classes for ", (object) this.module.getName(), (object) ":", (object) Throwable.instancehelper_getMessage((Exception) classDefFoundError)));
        this.state = -2;
        goto label_15;
label_10:
        Exception e = exception;
        if (Log.isDebugEnabled())
          Log.warn((object) new StringBuffer().append("Unable to configure the module ").append(this.module.getName()).toString(), e);
        else if (Log.isWarningEnabled())
          Log.warn((object) new StringBuffer().append("Unable to configure the module ").append(this.module.getName()).toString());
        this.state = -2;
      }
label_15:
      return false;
    }
        protected Message ProcessIncomingEnvelope(Envelope env)
        {
            this.IncomingEnvelopes.Enqueue(env);
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            if (env.Message.GetType() == typeof(ResultMessage))
            {
                Logger.Info("Received a result message in RespondTurns convo");
                playerAppState = SubSystem.appState as PlayerAppState;

                ResultMessage message = env.Message as ResultMessage;
                playerAppState.lastShotHit = message.getHit();
                playerAppState.turn        = message.getMyTurn();
                playerAppState.end         = message.getEnd();
                playerAppState.won         = message.getWin();
                playerAppState.gameId      = message.getGameId();
                playerAppState.lastX       = message.getXcord();
                playerAppState.lastY       = message.getYcord();
                playerAppState.SetTurn();
                playerAppState.ColorButtonResult(playerAppState.turn, playerAppState.lastX, playerAppState.lastY, playerAppState.lastShotHit); //Setting gameScreen according to shot.

                return(new AckMessage(playerAppState.gameId, 1, messageNumber, this.ConversationId));
            }
            else
            {
                Logger.Error("Received an error message in RespondTurns convo");
                return(new ErrorMessage());
            }
        }
Ejemplo n.º 6
0
 public Packet(MessageType type, SubSystem subSystem, byte commandId, byte[] payload = null)
 {
     Type      = type;
     SubSystem = subSystem;
     Cmd1      = commandId;
     Payload   = payload != null ? payload : new byte[0];
 }
        public async Task EditSubSystemAsync(EditSubSystemModel model)
        {
            SubSystem subSystemFromDB = await _subSystemRepository.FirstOrDefaultAsync(m => m.Name == model.Name && m.ID != model.ID);

            if (subSystemFromDB != null)
            {
                throw new InvalidOperationException("子系统代码已存在");
            }
            subSystemFromDB = await _subSystemRepository.FirstOrDefaultAsync(m => m.Code == model.Code && m.ID != model.ID);

            if (subSystemFromDB != null)
            {
                throw new InvalidOperationException("子系统代码已存在");
            }
            subSystemFromDB = await _subSystemRepository.FirstOrDefaultAsync(model.ID);

            if (subSystemFromDB == null)
            {
                throw new InvalidOperationException("子系统不存在");
            }
            model.CopyProperties(subSystemFromDB);
            subSystemFromDB.UpdateTime = DateTime.Now;
            _authorityUnitOfWork.RegisterEdit(subSystemFromDB);
            await _authorityUnitOfWork.CommitAsync();
        }
Ejemplo n.º 8
0
        public ExampleGame1()
        {
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            SubSystem.RegisterGame(new WindowsGamePlatform(this));
        }
Ejemplo n.º 9
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            SubSystem x = new SubSystem();

            if (!hasAccess())
            {
                ErrorHandler.NotifyUser(Errors.OperationNotAllowed);
                return;
            }

            if (SubsystemCom.Text == "مناقصات")
            {
                x = SubSystem.Tendering;
            }
            else if (SubsystemCom.Text == "قرارداد ها")
            {
                x = SubSystem.Contract;
            }
            else if (SubsystemCom.Text == "آیین نامه ها")
            {
                x = SubSystem.Regulation;
            }
            else if (SubsystemCom.Text == "مدیریت کاربران")
            {
                x = SubSystem.UserManagement;
            }
            else
            {
                x = SubSystem.TenderingArchive;
            }

            datagrid.ItemsSource = DataManagement.SearchLogs(x, Date1DP.SelectedDate, Date2DP.SelectedDate, (int?)UserCom.SelectedValue);
        }
Ejemplo n.º 10
0
        public async Task <ActionResult <SubSystem> > PostSubSystem(SubSystem subSystem)
        {
            _context.SubSystems.Add(subSystem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSubSystem", new { id = subSystem.SubSystemId }, subSystem));
        }
Ejemplo n.º 11
0
 internal void SetDefaults(string name)
 {
     Contract.Requires(name != null);
     fromExisting = false;
     isDLL        = name.EndsWith(".dll") || name.EndsWith(".DLL");
     if (isDLL)
     {
         characteristics = FileImage.dllCharacteristics;
     }
     else
     {
         characteristics = FileImage.exeCharacteristics;
     }
     lMajor       = MetaData.LMajors[0];
     lMinor       = 0;
     fileAlign    = FileImage.minFileAlign;
     osMajor      = 4;
     osMinor      = 0;
     userMajor    = 0;
     userMinor    = 0;
     subSysMajor  = 4;
     subSysMinor  = 0;
     subSystem    = SubSystem.Windows_CUI;
     DLLFlags     = FileImage.DLLFlags;
     cliMajVer    = 2;
     cliMinVer    = 0;
     corFlags     = CorFlags.CF_IL_ONLY;
     mdMajVer     = 1;
     mdMinVer     = 1; // MetaData Minor Version  ECMA = 0, PEFiles = 1
     netVersion   = NetVersion.Everett;
     netVerString = MetaData.versions[0];
     tsMajVer     = 1;
     tsMinVer     = 0;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Compare sub-systems
 /// </summary>
 private int CompareSubSystem(SubSystem x, SubSystem y)
 {
     if (x.OwnedClasses.Count.CompareTo(y.OwnedClasses.Count) != 0)
     {
         return(x.OwnedClasses.Count.CompareTo(y.OwnedClasses.Count));
     }
     else
     {
         foreach (Class c in x.OwnedClasses) // search the owned classes x in y
         {
             if (y.OwnedClasses.Find(a => CompareClass(c, a) == 0) == null)
             {
                 return(-1);
             }
         }
         foreach (Class c in y.OwnedClasses) // Search the owned classes y in x
         {
             if (x.OwnedClasses.Find(a => CompareClass(c, a) == 0) == null)
             {
                 return(1);
             }
         }
         return(0);
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// New LogMessage
 /// </summary>
 /// <param name="message">Message to log</param>
 /// <param name="level">Log-Level</param>
 /// <param name="source">Source (subsystem)</param>
 /// <param name="timestamp">Timestamp</param>
 public LogMessage(string message, LoggerLevel level, SubSystem source, DateTime timestamp)
 {
     Message   = message;
     Level     = level;
     Source    = source;
     Timestamp = timestamp;
 }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                int       c = Int32.Parse((string)value);
                SubSystem s = (SubSystem)c;
                switch (s)
                {
                case SubSystem.Contract:
                    return("قراردادها");

                case SubSystem.Regulation:
                    return("آئين نامه");

                case SubSystem.Tendering:
                    return("مناقصات");

                case SubSystem.UserManagement:
                    return("مديريت کاربران");
                }
                return("");
            }
            catch (System.Exception ex)
            {
                return("");
            }
        }
Ejemplo n.º 15
0
        protected Message ProcessIncomingEnvelope(Envelope env)
        {
            if (env.Message.GetType() == typeof(PlayerIdMessage))
            {
                //TODO: Put info from PlayerIdMessage In AppState.
                GMAppState      gmAppState = (GMAppState)this.SubSystem.appState;
                PlayerIdMessage mess       = (PlayerIdMessage)env.Message;

                gmAppState.p1PID = mess.getP1Id();
                gmAppState.p2PID = mess.getP2Id();

                gmAppState.P1EndPoint = SubSystem.ParseEPString(mess.getP1EndPoint());
                Logger.Debug($"Set the Player 1 endpoint to {mess.getP1EndPoint()}");

                gmAppState.P2EndPoint = SubSystem.ParseEPString(mess.getP2EndPoint());
                Logger.Debug($"Set the Player 2 endpoint to {mess.getP2EndPoint()}");


                gmAppState.p1Name = mess.getP1Name();
                gmAppState.p2Name = mess.getP2Name();

                gmAppState.gameId = mess.getGameId();

                //TODO: Not sure what to do with mess.getp1Wins and mess.getp2Wins.

                return(new AckMessage(99, 0, new Identifier(this.SubSystem.ProcessID, SubSystem.GetNextSeqNumber()), this.ConversationId)); //TODO: Not sure what to do with the ID in Ack here.
            }
            else
            {
                Logger.Error($"Did not receive a playerIdMessage, instead received a {env.Message.GetType()}");
            }

            return(null);
        }
        public static bool HasAccessToDestinationPage(SubSystem subsystem, NavigationMethod mode)
        {
            var  access = UserData.CurrentAccessRight;
            bool canRead = false, canEdit = false, canDelete = false, canConfirm = false, canLog = false;

            switch (subsystem)
            {
            case SubSystem.Contract:
                canRead    = true; //(bool)UserData.CurrentUser.ManagingPaymentDraft || (bool)access.ContractPermanentWrite || (bool)access.ContractRead || (bool)UserData.CurrentUser.PaymentDraftCommittee ;
                canEdit    = true; //(bool)access.ContractWrite || (bool)UserData.CurrentUser.ManagingPaymentDraft;
                canDelete  = true; //(bool)access.ContractDelete;
                canConfirm = true; //(bool)access.ContractPermanentWrite;
                canLog     = (bool)access.ContractLog;
                break;

            case SubSystem.Regulation:
                canRead    = (bool)access.RegulationRead;
                canEdit    = (bool)access.RegulationWrite;
                canDelete  = (bool)access.RegulationDelete;
                canConfirm = (bool)access.RegulationPermanentWrite;
                canLog     = (bool)access.RegulationLog;
                break;

            case SubSystem.Tendering:
                canRead    = (bool)access.TenderingRead;
                canEdit    = (bool)access.TenderingWrite;
                canDelete  = (bool)access.TenderingDelete;
                canConfirm = (bool)access.TenderingPermanentWrite;
                canLog     = (bool)access.TenderingLog;
                break;

            case SubSystem.TenderingArchive:
                canRead   = (bool)access.TenderingArchiveRead;
                canEdit   = (bool)access.TenderingArchiveWrite;
                canDelete = (bool)access.TenderingArchiveDelete;
                canLog    = (bool)access.TenderingArchiveLog;
                break;
            }

            if (subsystem == SubSystem.UserManagement)
            {
                if (UserData.CurrentAccessRight.CreatingUser == true)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (mode == NavigationMethod.NewMode || mode == NavigationMethod.EditMode)
            {
                return(canEdit);
            }
            if (mode == NavigationMethod.ViewMode)
            {
                return(canRead);
            }
            return(true);
        }
Ejemplo n.º 17
0
 public static void InitSubSystem(SubSystem flags)
 {
     if (SDL_InitSubSystem(flags) != 0)
     {
         throw new SDLException();
     }
 }
Ejemplo n.º 18
0
        protected override Message CreateFirstMessage()
        {
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            ConversationId = messageNumber;

            return(new EndGameResultMessage(Pid, ((GMAppState)SubSystem.appState).gameId, messageNumber, ConversationId));
        }
Ejemplo n.º 19
0
        public JObject ToJson()
        {
            JObject jErrorDetails = new JObject();

            jErrorDetails.Add(SubSystemString, new JValue(SubSystem.ToString()));
            jErrorDetails.Add(ErrorCodeString, new JValue(this.HResult));
            jErrorDetails.Add(ErrorContextString, new JValue(base.Message));
            return(jErrorDetails);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Determine if the configuration is empty.  The
        /// configuration is empty if the default value is
        /// set for the command setup.
        /// </summary>
        /// <returns>TRUE = Empty Configuration.</returns>
        public bool IsEmpty()
        {
            if (SubSystem.IsEmpty() && CepoIndex == DEFAULT_SETUP)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 21
0
        protected override Message CreateFirstMessage()
        {
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            ConversationId = messageNumber;
            string publicKey = ((GMAppState)SubSystem.appState).publicKey;

            return(new GMJoinLobbyMessage(publicKey, messageNumber, ConversationId, SubSystem.tcpcomm.getListenerEndPoint().Port));
        }
        public void RespondBoardRespondingToRetries()
        {
            //Create a SubSystem with dummy factory.
            dummyConversationFactory dumConvoFact = new dummyConversationFactory();
            WaitingRoom    waitingRoom            = new WaitingRoom();
            PlayerAppState playerAppState         = new PlayerAppState(waitingRoom);
            SubSystem      commSubSys             = new SubSystem(dumConvoFact, playerAppState);
            //Note: we dont want to start the threads of the subSystem.

            //Create Conversation
            RespondTurns respondTurnsConvo = new RespondTurns();

            respondTurnsConvo.SubSystem      = commSubSys;
            respondTurnsConvo.RemoteEndPoint = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 1111);

            //Create fake incoming env.
            Envelope IncomingEnv = new Envelope(new ResultMessage(true, 1, true, true, false, -1, -1, new Identifier(0, 1), new Identifier(0, 1)), new IPEndPoint(IPAddress.Parse("1.1.1.1"), 1111), new IPEndPoint(IPAddress.Parse("2.2.2.2"), 2222), false);

            //Set the incoming env.
            respondTurnsConvo.IncomingEnvelope = IncomingEnv;
            respondTurnsConvo.recievedMessagesDict.TryAdd(IncomingEnv.Message.MessageNumber.ToString(), IncomingEnv);

            //Start the conversation
            respondTurnsConvo.Launch();

            Thread.Sleep(500);

            //check the outgoing message.
            Assert.IsTrue(commSubSys.outQueue.Count >= 1);

            //Give a duplicate message.
            respondTurnsConvo.Process(IncomingEnv);

            Thread.Sleep(500);

            //check the outgoing message.
            Assert.IsTrue(commSubSys.outQueue.Count >= 2);

            //get count of outgoing messages for later.
            int countOfOutGoingMessages = commSubSys.outQueue.Count;

            //Wait for timeout time
            Thread.Sleep(2000);

            //Check that there are no new messages.
            Assert.IsTrue(countOfOutGoingMessages == commSubSys.outQueue.Count);

            //Cheack that thread has ended.
            respondTurnsConvo.Process(IncomingEnv); //If thread was running outgoing messages should go up.
            Thread.Sleep(500);
            Assert.IsTrue(countOfOutGoingMessages == commSubSys.outQueue.Count);

            //Close the communicators for next test.
            commSubSys.udpcomm.closeCommunicator();
            commSubSys.tcpcomm.closeCommunicator();
        }
        public void RespondJoinLobbyRespondingToRetreis()
        {
            //Create a SubSystem with dummy factory.
            dummyCoversationFactory dumConvoFact  = new dummyCoversationFactory();
            LobbyAppState           lobbyAppState = new LobbyAppState();
            SubSystem commSubSys = new SubSystem(dumConvoFact, lobbyAppState);
            //Note: we dont want to start the threads of the subSystem.

            //Create Conversation
            RespondJoinLobby resJoinLobbyConvo = new RespondJoinLobby();

            resJoinLobbyConvo.SubSystem      = commSubSys;
            resJoinLobbyConvo.RemoteEndPoint = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 1111);

            //Create fake incoming env.
            string   strXML      = "<RSAKeyValue><Modulus>CmZ5Hasfdldkjrjghtyremeddfjdn4738ejdjHGTFEeeeeeeeeeefjdkeldkfjguehendjeufi8ejdmGFDSqaalskebejdu==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
            Envelope IncomingEnv = new Envelope(new GMJoinLobbyMessage(strXML, new Identifier(0, 1), new Identifier(0, 1), 1111), new IPEndPoint(IPAddress.Parse("1.1.1.1"), 1111), new IPEndPoint(IPAddress.Parse("2.2.2.2"), 2222), false);

            //Set the incoming env.
            resJoinLobbyConvo.IncomingEnvelope = IncomingEnv;
            resJoinLobbyConvo.recievedMessagesDict.TryAdd(IncomingEnv.Message.MessageNumber.ToString(), IncomingEnv);

            //Start the conversation
            resJoinLobbyConvo.Launch();

            Thread.Sleep(500);

            //check the outgoing message.
            Assert.IsTrue(commSubSys.outQueue.Count >= 1);

            //Give a duplicate message.
            resJoinLobbyConvo.Process(IncomingEnv);

            Thread.Sleep(500);

            //check the outgoing message.
            Assert.IsTrue(commSubSys.outQueue.Count >= 2);

            //get count of outgoing messages for later.
            int countOfOutGoingMessages = commSubSys.outQueue.Count;

            //Wait for timeout time
            Thread.Sleep(2000);

            //Check that there are no new messages.
            Assert.IsTrue(countOfOutGoingMessages == commSubSys.outQueue.Count);

            //Cheack that thread has ended.
            resJoinLobbyConvo.Process(IncomingEnv); //If thread was running outgoing messages should go up.
            Thread.Sleep(500);
            Assert.IsTrue(countOfOutGoingMessages == commSubSys.outQueue.Count);

            //Close the communicators for next test.
            commSubSys.udpcomm.closeCommunicator();
            commSubSys.tcpcomm.closeCommunicator();
        }
Ejemplo n.º 24
0
        protected override Message CreateFirstMessage()
        {
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            ConversationId = messageNumber;

            appState = SubSystem.appState as PlayerAppState;
            Logger.Info("Shot message created in Shot convo");
            return(new ShotMessage(appState.shotCoordinates.Item1, appState.shotCoordinates.Item2, appState.gameId, appState.playerID, messageNumber, ConversationId));
        }
        public async Task <SubSystemDTO> GetSubSystemInfoAsync([Required(ErrorMessage = "唯一标识不能为空")] Guid id)
        {
            SubSystem subSystemFromDB = await _subSystemRepository.FirstOrDefaultAsync(id);

            if (subSystemFromDB == null)
            {
                throw new InvalidOperationException("子系统不存在");
            }
            return(_mapper.Map <SubSystemDTO>(subSystemFromDB));
        }
Ejemplo n.º 26
0
        protected override Message CreateFirstMessage()
        {
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            ConversationId = messageNumber;

            playerAppState = SubSystem.appState as PlayerAppState;
            Logger.Info("Board message created in Board convo");
            return(new BoardMessage(playerAppState.gameId, playerAppState.planningGrid, messageNumber, ConversationId));
        }
Ejemplo n.º 27
0
 public override void initialize(SubSystem subSystem)
 {
   if (LogConfiguration.isDisableLogging() || !String.instancehelper_equals(LogConfiguration.getLogTarget(), (object) (DefaultLogModule.class\u0024org\u0024jfree\u0024util\u0024PrintStreamLogTarget != null ? DefaultLogModule.class\u0024org\u0024jfree\u0024util\u0024PrintStreamLogTarget : (DefaultLogModule.class\u0024org\u0024jfree\u0024util\u0024PrintStreamLogTarget = DefaultLogModule.class\u0024("org.jfree.util.PrintStreamLogTarget"))).getName()))
     return;
   DefaultLog.installDefaultLog();
   Log.getInstance().addTarget((LogTarget) new PrintStreamLogTarget());
   if (String.instancehelper_equals("true", (object) subSystem.getGlobalConfig().getConfigProperty("org.jfree.base.LogAutoInit")))
     Log.getInstance().init();
   Log.info((object) "Default log target started ... previous log messages could have been ignored.");
 }
Ejemplo n.º 28
0
        protected override Message CreateFirstMessage()
        {
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            ConversationId = messageNumber;

            appState = SubSystem.appState as GMAppState;
            Logger.Info("Result message created in turns convo");
            return(new ResultMessage(appState.lastShotResult, appState.gameId, false, appState.end, this.myTurn, appState.LastX, appState.LastY, messageNumber, ConversationId));
        }
Ejemplo n.º 29
0
        protected override Message CreateFirstMessage()
        {
            Identifier messageNumber = new Identifier(SubSystem.ProcessID, SubSystem.GetNextSeqNumber());

            ConversationId = messageNumber;

            string name      = ((PlayerAppState)SubSystem.appState).playerName;
            string publicKey = ((PlayerAppState)SubSystem.appState).publicKey;

            return(new PlayerJoinLobbyMessage(name, publicKey, messageNumber, this.ConversationId));
        }
        public async Task DeleteSubSystemAsync([Required(ErrorMessage = "唯一标识不能为空")] Guid id)
        {
            SubSystem subSystemFromDB = await _subSystemRepository.FirstOrDefaultAsync(id);

            if (subSystemFromDB == null)
            {
                throw new InvalidOperationException("子系统不存在");
            }
            _authorityUnitOfWork.RegisterDelete(subSystemFromDB);
            await _authorityUnitOfWork.CommitAsync();
        }
        public void TurnsConvoRetries()
        {
            dummyConversationFactory dumConvoFact = new dummyConversationFactory();
            GMAppState gmAppState = new GMAppState();
            SubSystem  commSubSys = new SubSystem(dumConvoFact, gmAppState);

            Turns turnsConvo = new Turns();

            turnsConvo.SubSystem      = commSubSys;
            turnsConvo.RemoteEndPoint = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 1111);

            turnsConvo.Launch();

            Thread.Sleep(1000);

            Assert.IsTrue(commSubSys.outQueue.Count >= 1);

            Thread.Sleep(2000);

            Assert.IsTrue(commSubSys.outQueue.Count >= 2);

            Thread.Sleep(2000);

            Assert.IsTrue(commSubSys.outQueue.Count >= 3);

            //Make sure those messages are the same.
            Envelope env1;

            if (!commSubSys.outQueue.TryDequeue(out env1))
            {
                Assert.Fail();
            }
            Envelope env2;

            if (!commSubSys.outQueue.TryDequeue(out env2))
            {
                Assert.Fail();
            }
            Envelope env3;

            if (!commSubSys.outQueue.TryDequeue(out env3))
            {
                Assert.Fail();
            }

            //Make sure the message in the outQ are the same.
            Assert.IsTrue(env1.Message.ConversationId.Equals(env2.Message.ConversationId) && env1.Message.MessageNumber.Equals(env2.Message.MessageNumber));
            Assert.IsTrue(env1.Message.ConversationId.Equals(env3.Message.ConversationId) && env1.Message.MessageNumber.Equals(env3.Message.MessageNumber));

            //Close the communicators for next test.
            commSubSys.udpcomm.closeCommunicator();
            commSubSys.tcpcomm.closeCommunicator();
        }
Ejemplo n.º 32
0
        protected string GetOutputTypeString(SubSystem subSystem)
        {
            switch (subSystem)
            {
            case SubSystem.Library: return("Library");

            case SubSystem.Windows: return("WinExe");

            case SubSystem.Console: return("Exe");
            }
            throw new ArgumentException("Invalid sub system");
        }
Ejemplo n.º 33
0
 public NetProjectTemplate(string name, Bitmap icon,
     NetLanguageDescriptor language,
     SubSystem applicationType,
     params FileTemplate[] files)
     : base(name, icon, files)
 {
     Language = language;
     ApplicationType = applicationType;
     References = new List<string>()
     {
         "System.dll",
     };
 }
Ejemplo n.º 34
0
 protected override void OnInit(EventArgs e)
 {
     subSys = AppContext.Context.CurrentSubSys;
     this.EnableViewState = false;
     base.OnInit(e);
     InitPaper( );
 }
Ejemplo n.º 35
0
        protected override void Render(HtmlTextWriter writer)
        {
            try
            {
                _subSys = BasePage.CurrentSubSys;
                switch (Region)
                {
                    case MenuRegion.Header:
                        BuildHeaderMenuHTML(writer);
                        break;
                    case MenuRegion.Left:
                        BuildLeftMenuHTML(writer);
                        break;
                    case MenuRegion.Foot:
                        BuildFootMenuHTML(writer);
                        break;
                    default:
                        if (_subSys == SubSystem.Member)
                            BuildMemberMainNavMenu(writer);
                        else
                            BuildMainNavMenuHTML(writer);
                        break;
                }

            }
            catch (Exception ex)
            {
                Logging.Log("UcMenuNavigation->Render", ex);
                Response.Write(ex.Message + Environment.NewLine + ex.StackTrace);
            }
            base.Render(writer);
        }
Ejemplo n.º 36
0
        public static int UserLogin(string txtUserName, string txtUserPass, SubSystem subSys, LoginSystem sys, out SysMember loginUser)
        {
            loginUser = null;
            int id = 0;
            if (txtUserName.Length <= 9)
                int.TryParse(txtUserName, out id);
            SqlQuery query = null;
            if (id > 0)
                query = DB.Select().From<SysMember>()
                                    .Where(SysMember.IdColumn).IsEqualTo(id);
            else
                query = DB.Select().From<SysMember>()
                                .Where(SysMember.MemberPhoneNumberColumn).IsEqualTo(txtUserName);
            if (subSys == SubSystem.Company)
                query.And(SysMember.CompanyIdColumn).IsGreaterThan(0);
            SysMemberCollection users = query.ExecuteAsCollection<SysMemberCollection>();
            if (users == null || users.Count == 0)
                return 1;
            bool bPass = false;
            SysMember user = null;
            foreach (SysMember item in users)
            {
                string enPass = Utilities.DESEncrypt(txtUserPass);
                bPass = Utilities.Compare(item.MemberPwd, txtUserPass) ||
                        Utilities.Compare(item.MemberPwd, enPass);
                if (bPass)
                {
                    if (Utilities.Compare(item.MemberPwd, txtUserPass))
                        item.MemberPwd = enPass;
                    user = item;
                    break;
                }
            }
            if (!bPass)
                return 2;
            if (user.MemberRoleId == null)
                user.MemberRoleId = 0;
            if (user.CompanyRoleId == null)
                user.CompanyRoleId = 0;
            if (user.AdminRoleId == null)
                user.AdminRoleId = 0;
            int roleId = 0;
            switch (subSys)
            {
                case SubSystem.Admin:
                    roleId = Convert.ToInt32(user.AdminRoleId);
                    break;
                case SubSystem.Member:
                    roleId = Convert.ToInt32(user.MemberRoleId);
                    break;
                case SubSystem.Company:
                    roleId = Convert.ToInt32(user.CompanyRoleId);
                    break;
            }

            if (GetUserRoleAssignmentById(roleId) == null)
            {
                return 3;
            }
            if (user.MemberStatus != 1)
            {
                return 4;
            }
            user.ValidateWhenSaving = false;
            user.LastLoginSubSys = (int)subSys;
            user.LastLoginDate = DateTime.Now;
            user.Save(user.Id);
            if (sys != LoginSystem.Mobile)
                Utilities.LoginSigIn(user.Id, subSys, sys);
            loginUser = user;
            return 0;
        }
Ejemplo n.º 37
0
        public void Read(ReaderContext ctxt, BlobReader reader)
        {
            ImageBase = reader.ReadUInt32();
            var actualSectionAlignment = reader.ReadUInt32();
            if (actualSectionAlignment != sectionAlignment)
                throw new PEException("invalid PEHeaderNTSpecificFields.SectionAlignment");
            FileAlignment = reader.ReadUInt32();
            if (FileAlignment != fileAlignment1 && FileAlignment != fileAlignment2)
                throw new PEException("invalid PEHeaderNTSpecificFields.FileAlignment");
            var actualOSMajor = reader.ReadUInt16();
            if (actualOSMajor != osMajor)
                throw new PEException("invalid PEHeaderNTSpecificFields.OSMajor");
            var actualOSMinor = reader.ReadUInt16();
            if (actualOSMinor != osMinor)
                throw new PEException("invalid PEHeaderNTSpecificFields.OSMinor");
            var actualUserMajor = reader.ReadUInt16();
            if (actualUserMajor != userMajor)
                throw new PEException("invalid PEHeaderNTSpecificFields.UserMajor");
            var actualUserMinor = reader.ReadUInt16();
            if (actualUserMinor != userMinor)
                throw new PEException("invalid PEHeaderNTSpecificFields.UserMinor");
            var actualSubSysMajor = reader.ReadUInt16();
            if (actualSubSysMajor != subSysMajor)
                throw new PEException("invalid PEHeaderNTSpecificFields.SubSysMajor");
            var actualSubSysMinor = reader.ReadUInt16();
            if (actualSubSysMinor != subSysMinor)
                throw new PEException("invalid PEHeaderNTSpecificFields.SubSysMinor");
            var actualReserved = reader.ReadUInt32();
            if (actualReserved != reserved)
                throw new PEException("invalid PEHeaderNTSpecificFields.Reserved");
            ImageSize = reader.ReadUInt32();
            if (ImageSize % sectionAlignment != 0)
                throw new PEException("invalid PEHeaderNTSpecificFields.ImageSize");
            HeaderSize = reader.ReadUInt32();
            if (HeaderSize % FileAlignment != 0)
                throw new PEException("invalid PEHeaderNTSpecificFields.HeaderSize");
            FileChecksum = reader.ReadUInt32();
            SubSystem = (SubSystem)reader.ReadUInt16();
            if (SubSystem != SubSystem.WINDOWS_CUI && SubSystem != SubSystem.WINDOWS_GUI)
                throw new PEException("invalid PEHeaderNTSpecificFields.SubSystem");
            DllFlags = reader.ReadUInt16();
            var actualStackReserveSize = reader.ReadUInt32();
            if (actualStackReserveSize != stackReserveSize)
                throw new PEException("invalid PEHeaderNTSpecificFields.StackReserveSize");
            StackCommitSize = reader.ReadUInt32();
            HeapReserveSize = reader.ReadUInt32();
            HeapCommitSize = reader.ReadUInt32();
            var actualLoaderFlags = reader.ReadUInt32();
            if (actualLoaderFlags != loaderFlags)
                throw new PEException("invalid PEHeaderNTSpecificFields.LoaderFlags");
            var actualNumberOfDataDirectories = reader.ReadUInt32();
            if (actualNumberOfDataDirectories != numberOfDataDirectories)
                throw new PEException("invalid PEHeaderNTSpecificFields.NumberOfDataDirectories");

            if (ctxt.Tracer != null)
            {
                ctxt.Tracer.AppendLine(String.Format("PEHeaderNTSpecificFields.ImageBase: {0:x8}", ImageBase));
                ctxt.Tracer.AppendLine(String.Format("PEHeaderNTSpecificFields.ImageSize: {0:x8}", ImageSize));
                ctxt.Tracer.AppendLine(String.Format("PEHeaderNTSpecificFields.HeaderSize: {0:x8}", HeaderSize));
                ctxt.Tracer.AppendLine(String.Format("PEHeaderNTSpecificFields.FileChecksum: {0:x8}", FileChecksum));
            }
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Set the subsystem (.subsystem) (Default is Windows Console mode)
 /// </summary>
 /// <param name="subS">subsystem value</param>
 public void SetSubSystem(SubSystem subS) {
   fileImage.subSys = subS;
 }
Ejemplo n.º 39
0
 protected bool TryParseOutputType(string outputType, out SubSystem value)
 {
     value = SubSystem.Unknown;
     switch (outputType.ToLower())
     {
         case "library": value = SubSystem.Library; return true;
         case "winexe": value = SubSystem.Windows; return true;
         case "exe": value = SubSystem.Console; return true;
     }
     return false;
 }
Ejemplo n.º 40
0
 protected string GetOutputTypeString(SubSystem subSystem)
 {
     switch (subSystem)
     {
         case SubSystem.Library: return "Library";
         case SubSystem.Windows: return "WinExe";
         case SubSystem.Console: return "Exe";
     }
     throw new ArgumentException("Invalid sub system");
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Set the subsystem (.subsystem) (Default is Windows Console mode)
 /// </summary>
 /// <param name="subS">subsystem value</param>
 public void SetSubSystem(SubSystem subS)
 {
     versionInfo.subSystem = subS;
 }
Ejemplo n.º 42
0
 internal void SetDefaults(string name)
 {
     fromExisting = false;
     isDLL = name.EndsWith(".dll") || name.EndsWith(".DLL");
     if (isDLL) {
         characteristics = FileImage.dllCharacteristics;
     } else {
         characteristics = FileImage.exeCharacteristics;
     }
     lMajor = MetaData.LMajors[0];
     lMinor = 0;
     fileAlign = FileImage.minFileAlign;
     osMajor = 4;
     osMinor = 0;
     userMajor = 0;
     userMinor = 0;
     subSysMajor = 4;
     subSysMinor = 0;
     subSystem = SubSystem.Windows_CUI;
     DLLFlags = FileImage.DLLFlags;
     cliMajVer = 2;
     cliMinVer = 0;
     corFlags = CorFlags.CF_IL_ONLY ;
     mdMajVer = 1;
     mdMinVer = 1; // MetaData Minor Version  ECMA = 0, PEFiles = 1
     netVersion = NetVersion.Everett;
     netVerString = MetaData.versions[0];
     tsMajVer = 1;
     tsMinVer = 0;
 }