Beispiel #1
0
        public Gs2WebSocketResponse(string message) : base(message)
        {
            try
            {
                var gs2Message = Gs2Message.FromDict(JsonMapper.ToObject(message));
                Body = gs2Message.body;

                var errorMessage = "";
                if (gs2Message.status != 200)
                {
                    var error = GeneralError.FromDict(gs2Message.body);
                    if (error != null)
                    {
                        errorMessage = error.Message;
                    }
                    else
                    {
                        errorMessage = message;
                    }
                }

                Error            = ExtractError(errorMessage, gs2Message.status ?? 0);
                Gs2SessionTaskId = new Gs2SessionTaskId(gs2Message.requestId);
            }
            catch (System.Exception)
            {
                Error            = new UnknownException("JSON parsing error: \n" + message);
                Gs2SessionTaskId = Gs2SessionTaskId.InvalidId;
            }
        }
Beispiel #2
0
        public void GetGeneralErrorStringTest()
        {
            var errorMessage = "Das ist ein Fehler!";
            var generalError = new GeneralError(errorMessage);

            Assert.IsTrue(generalError.ToString() == errorMessage + "\r\n");
        }
Beispiel #3
0
        /// <summary>
        /// Возвращает описание общего кода ошибки по его значению
        /// </summary>
        /// <param name="value">Значение кода ошибки</param>
        protected static string GetGeneralDescription(GeneralError value)
        {
            switch (value)
            {
            case GeneralError.Success:
                return("Успешно (ошибок нет)");

            case GeneralError.Busy:
                return("Устройство занято другим приложением");

            case GeneralError.Timeout:
                return("Таймаут во время обмена данными с устройством");

            case GeneralError.Inactive:
                return("Устройство неактивно. Требуется активировать устройство перед обращением к его интерфейсным методам");

            case GeneralError.Exception:
                return("Исключительная ситуация во время обмена данными с устройством");

            case GeneralError.Unsupported:
                return("Функция не поддерживается устройством");

            case GeneralError.CurrentlyUnsupported:
                return("Функция не поддерживается устройством при данных параметрах команды");

            default:
                return("Ошибка, специфическая для протокола обмена с устройством");
            }
        }
Beispiel #4
0
        public void Disassemble(int tofile0editor1)
        {
            //First Check if there are lines loading in MC list
            if (MachineCodes.Count != 0)
            {
                DisassemblyStarted.Invoke(); //just to notify anyone who's registered with the event ...

                //Now load one line at a time
                //Then decode it and place it in assembledLine, then invoke complete~
                for (int i = 0; i < MachineCodes.Count; i++)
                {
                    //here is da decoding part
                    string x = DecodeLine(MachineCodes.ElementAt <string>(i));
                    //Here is the part to store...
                    AssembledLines.Add(x);
                    //Incrment counter
                    Current_Inst_Address += 4;
                }
                //Current_Inst_Address = 4194308;
                //ResolveLabels();
                DisassemblyComplete.Invoke(tofile0editor1); //yay!
            }
            else
            {
                GeneralError.Invoke("Disassemble::Disassembler", "We ain't got no machine codes", "Lol, u messin with me? I didn't find any machine codes to disassemble!");
            }
        }
Beispiel #5
0
 /// <summary>
 /// Создает экземпляр класса
 /// </summary>
 /// <param name="value">Общий код ошибки</param>
 /// <param name="description">Описание общего кода ошибки</param>
 /// <param name="specificValue">Код ошибки протокола обмена с устройством</param>
 /// <param name="specificDescription">Описание кода ошибки</param>
 /// <param name="sender">Устройство-отправитель кода ошибки</param>
 public ErrorCode(string sender, GeneralError value, string description,
                  Int16 specificValue, string specificDescription)
 {
     _sender              = sender;
     _value               = value;
     _description         = description;
     _specificValue       = specificValue;
     _specificDescription = specificDescription;
 }
 public FileResult OnGet(string id, string file)
 {
     try
     {
         SignStorageObject     signStorageObject     = SignStorageObjectFinder.Find(id);
         DocumentStorageObject documentStorageObject = getDocumentStorageObject(signStorageObject, file);
         var response = new FileContentResult(documentStorageObject.SignedDocument, "application/octet-stream")
         {
             FileDownloadName = documentStorageObject.FileName
         };
         return(response);
     }
     catch (Exception Error)
     {
         GeneralError = ErrorHelper.GetError(Error);
         return(null);
     }
 }
Beispiel #7
0
    /// <summary>
    /// Use of WorkSpace
    /// </summary>
    /// <param name="pController"></param>
    public void Interact(PlayerController pController)
    {
        GrabableObject objectInHand = pController.pDatas.objectInHand;

        // Put object = No object in workspace and object in hand of player
        if (haveAnObject == false && objectInHand != null)
        {
            grabableReceived = objectInHand;
            PutObject(pController);
            photonView.RPC("PutObjectInPost", RpcTarget.Others, pController.photonView.OwnerActorNr);
        }
        else if (objectInHand == null && haveAnObject) // Take object = object in workSpace and no object in hand of player
        {
            GeneralError.ErrorNoOutfit(pController);
        }
        else if (objectInHand != null && haveAnObject == true)// put object impossible = object in workspace and object in hand of player
        {
            GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
        }
    }
Beispiel #8
0
        //Main Methods
        public string DecodeLine(string MachineCode)
        {
            switch (getFormat(MachineCode))
            {
            case 0:
                return(decodeR(MachineCode));

            case 1:
                return(decodeI(MachineCode));

            case 2:
                return(decodeJ(MachineCode));

            case -1:
                UnsupportedFormat.Invoke("DecodeLine::Disassembler", "MC : " + MachineCode, "Sorry, but COPROC instructions aren't currently supported.. tuff luck chump");
                return("ERR-DecodeLine::Disassembler::Coproc_Error");

            default:
                GeneralError.Invoke("DecodeLine::Disassembler", "--", "Lol, this is some wierd shit for realz!");
                return("ERR-DecodeLine::Disassembler::LOL");
            }
        }
        /// <summary>
        /// Создает экземпляр класса
        /// </summary>
        /// <param name="value">Общий код ошибки</param>
        /// <param name="description">Описание общего кода ошибки</param>
        /// <param name="specificValue">Код ошибки протокола обмена с устройством</param>
        /// <param name="specificDescription">Описание кода ошибки</param>
        /// <param name="sender">Устройство-отправитель кода ошибки</param>
        /// <param name="commandDump"></param>
        public ServerErrorCode(IDevice sender, GeneralError value, string description,
                               Int16 specificValue, string specificDescription, string commandDump)
            : base(sender.DeviceId, value, description, specificValue, specificDescription)
        {
            _commandDump = commandDump;
            if (Value == GeneralError.Success)
            {
                return;
            }

            // сохраняем ошибку в логе
            EventLogEntryType entryType = EventLogEntryType.Information;

            switch (Value)
            {
            // грубые ошибки
            case GeneralError.Busy:
            case GeneralError.Exception:
            case GeneralError.Specific:
            case GeneralError.Timeout:
            case GeneralError.Inactive:
                entryType = EventLogEntryType.Error;
                break;

            // предупреждения
            case GeneralError.CurrentlyUnsupported:
            case GeneralError.Unsupported:
                entryType = EventLogEntryType.Warning;
                break;
            }

            StringBuilder sb = new StringBuilder(FullDescription);

            sb.AppendLine("Дамп команды или ответа:");
            sb.AppendLine(string.IsNullOrEmpty(_commandDump) ? "Нет данных" : _commandDump);
            sender.Logger.WriteEntry(sb.ToString(), entryType);
        }
Beispiel #10
0
        public string decodeR(string rLine)
        {
            //r format holds opcode, rs, rt, rd, sa , and funct...
            //OPCODE(6) RS(5) RT(5) RD(5) SA(5) FUNCT(6)
            string rs    = rLine.Substring(6, 5);
            string rt    = rLine.Substring(11, 5);
            string rd    = rLine.Substring(16, 5);
            string sa    = rLine.Substring(21, 5);
            string funct = rLine.Substring(26);

            //Lets first decode the rs, rd, rt , sa then see what funct it is and determine
            //the print format, just like in the Iformat;
            string rs_name = getRegName(rs);
            string rt_name = getRegName(rt);
            string rd_name = getRegName(rd);
            int    sa_int  = Convert.ToInt32(sa, 2);
            string mnemonic;
            string mipsline;

            //Ok now we got all the info except for funct, decode it and return string :)
            switch (funct)
            {
            case "100000":     //add
                mnemonic = "add";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "100001":     //addu
                mnemonic = "addu";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "100100":     //and
                mnemonic = "and";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "001000":     //jr
                mnemonic = "jr";
                mipsline = mnemonic + " $" + rs_name;
                return(mipsline);

            case "100111":     //nor
                mnemonic = "nor";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "100101":     //or
                mnemonic = "or";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "000000":     //sll
                mnemonic = "sll";
                mipsline = mnemonic + " $" + rd_name + ", $" + rt_name + ", " + sa_int;
                return(mipsline);

            case "000100":     //sllv
                mnemonic = "sllv";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "101010":     //slt
                mnemonic = "slt";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "101011":     //sltu
                mnemonic = "sltu";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "000011":     //sra
                mnemonic = "sra";
                mipsline = mnemonic + " $" + rd_name + ", $" + rt_name + ", " + sa_int;
                return(mipsline);

            case "000111":     //srav
                mnemonic = "srav";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "000010":     //srl
                mnemonic = "srl";
                mipsline = mnemonic + " $" + rd_name + ", $" + rt_name + ", " + sa_int;
                return(mipsline);

            case "000110":     //srlv
                mnemonic = "srlv";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "100010":     //sub
                mnemonic = "sub";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "100011":     //subu
                mnemonic = "subu";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            case "001100":     //syscall
                mnemonic = "syscall";
                mipsline = mnemonic;
                return(mipsline);

            case "100110":     //xor
                mnemonic = "xor";
                mipsline = mnemonic + " $" + rd_name + ", $" + rs_name + ", $" + rt_name;
                return(mipsline);

            default:
                GeneralError.Invoke("decodeR::Disassembler", "FUNCT: " + funct, "Unsupported R instruction found, sorry for that");
                return("ERR");
            }
        }
Beispiel #11
0
        /// <summary>
        /// Purges queues for messages older then the <see cref="MessagePurgeLifespan"/>
        /// </summary>
        /// <param name="cancellationToken">The cancellation token</param>
        public void PurgeOldMessages(CancellationToken cancellationToken)
        {
            while (cancellationToken.IsCancellationRequested == false)
            {
                // Ensure the service is not paused
                if (!IsPaused)
                {
                    try
                    {
                        // Get all files inside the Queue
                        DirectoryInfo          dirInfo = new DirectoryInfo(Folders.RootFolder);
                        IEnumerable <FileInfo> files   = dirInfo.EnumerateFiles("*.EML", SearchOption.AllDirectories);

                        // Purged Files Collection
                        List <FileInfo> purgedFiles = new List <FileInfo>();

                        // Date to Purge
                        DateTime purgeDate = DateTime.Now.Subtract(MessagePurgeLifespan);

                        // Retrieve all files on the queues
                        foreach (FileInfo fi in files)
                        {
                            // Refresh the FileInfo to get the proper CreationTime
                            fi.Refresh();

                            // Check Date
                            if (fi.CreationTime.CompareTo(purgeDate) < 0)
                            {
                                // Calls the Purge Event
                                PurgeFileEventArgs purgeFileEventArgs = new PurgeFileEventArgs(fi, purgeDate);
                                bool cancelPurge = false;

                                if (MessagePurging != null)
                                {
                                    MessagePurging.Invoke(this, purgeFileEventArgs);
                                    cancelPurge = purgeFileEventArgs.Cancel;
                                }

                                // Purge or Keep File
                                if (!cancelPurge)
                                {
                                    // Delete the file
                                    File.Delete(fi.FullName);

                                    // Add it to collection (since the refresh method was called before, the information does not get lost)
                                    purgedFiles.Add(fi);
                                }
                            }
                        }

                        // Trigger event if handled
                        if (purgedFiles.Count > 0)
                        {
                            MessagesPurged?.Invoke(this, new PurgeFilesEventArgs(purgedFiles, purgeDate));
                        }
                    }
                    catch (Exception e)
                    {
                        // Call the GeneralError Event Handler
                        GeneralError?.Invoke(this, new GeneralErrorEventArgs(e, nameof(PurgeOldMessages)));
                    }

                    // Wait for 10 minutes before trying it again (cancellationToken forces it to exit too)
                    Task.Delay(new TimeSpan(0, 10, 0)).Wait(cancellationToken);
                }
                else
                {
                    // Wait for 10 seconds trying it again (cancellationToken forces it to exit too)
                    Task.Delay(10000).Wait(cancellationToken);
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Process the Smtp Queue for messages already routed
        /// </summary>
        /// <param name="connectionNumber">The number of the connection on the same queue. This information is inserted on the header of the MimeMessage</param>
        /// <param name="smtpConfiguration">The configuration information for the queue</param>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <remarks>This method is expected to run into multiple tasks, hence it uses a <see cref="ConcurrentQueue{T}"/></remarks>
        private void SendRoutedMessages(int connectionNumber, SmtpConfiguration smtpConfiguration, CancellationToken cancellationToken)
        {
            // Connects to the Smtp
            SmtpClient client = new SmtpClient();

            // Control the Number of Attempts
            int attempts    = 0;
            int maxAttempts = 20;

            while (cancellationToken.IsCancellationRequested == false)
            {
                try
                {
                    // Pull a message from the queue
                    RoutableMessage routableMessage = null;
                    bool            Dequeued        = false;

                    lock (SmtpQueues[smtpConfiguration.QueueNumber])
                    {
                        Dequeued = SmtpQueues[smtpConfiguration.QueueNumber].TryDequeue(out routableMessage);
                    }

                    if ((Dequeued) && (routableMessage != null))
                    {
                        try
                        {
                            // Append details to the header
                            var receiveByString = string.Format("Queue [{0}] at Connection [{1}] of Smtp Key [{2}] with Smtp Router Service; {3}",
                                                                (smtpConfiguration.QueueNumber + 1),
                                                                connectionNumber,
                                                                smtpConfiguration.Key,
                                                                DateTime.Now.ToString("ddd, dd MMM yyy HH:mm:ss %K"));

                            routableMessage.Message.Headers.Add("X-SM-SentBy", receiveByString);

                            // Append File Name to the Header
                            routableMessage.Message.Headers.Add("X-SM-FileName", Path.GetFileName(routableMessage.FileName));

                            // Create folder to store sent files
                            string SentFolder = smtpConfiguration.Folders.SentFolderWithGroupingOptions(routableMessage.CreationDateTime);
                            if (!Directory.Exists(SentFolder))
                            {
                                Directory.CreateDirectory(SentFolder);
                            }

                            // Sends the message with the active connection
                            bool messageSent = false;

                            // Reset attempts
                            attempts = 0;

                            while ((!messageSent) && (attempts <= maxAttempts))
                            {
                                // Increment number of attempts
                                attempts++;

                                try
                                {
                                    // Ensure to create a connection
                                    if (TryConnectToSmtp(ref client, smtpConfiguration))
                                    {
                                        // Tries to send the message
                                        if (client.TrySend(routableMessage.Message, routableMessage.MailFrom, routableMessage.Recipients, out Exception eSendException))
                                        {
                                            messageSent = true;

                                            // Move file to the sent folder
                                            File.Move(routableMessage.FileName, Path.Combine(SentFolder, Path.GetFileName(routableMessage.FileName)));

                                            // Notify that a message has been sent
                                            MessageSentSuccessfully?.Invoke(this, new MessageEventArgs(routableMessage));
                                        }
                                        else
                                        {
                                            // Notify the message has not been sent
                                            MessageNotSent?.Invoke(this, new MessageErrorEventArgs(routableMessage, eSendException));

                                            // Something happened, give it a few seconds before trying again
                                            Task.Delay(2000).Wait(cancellationToken);
                                        }

                                        // Disconnect the client
                                        if (client.IsConnected)
                                        {
                                            client.Disconnect(true);
                                        }
                                    }
                                    else
                                    {
                                        // Something happened, give it a few seconds before trying again
                                        Task.Delay(2000).Wait(cancellationToken);
                                    }
                                }
                                catch
                                {
                                    // Give it some time before trying again to connect on this loop
                                    Task.Delay(2000).Wait(cancellationToken);
                                }
                            }

                            // Check if message is still not sent
                            if (!messageSent)
                            {
                                if (attempts == maxAttempts)
                                {
                                    throw new MessageNotSentException(routableMessage, new Exception($"Reached the limit of attempts to send the message ({maxAttempts} times) without any success"));
                                }
                                else
                                {
                                    throw new MessageNotSentException(routableMessage, new Exception($"Unable to send the message after {attempts} attempts"));
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            // Move message to the error queue
                            File.Move(routableMessage.FileName, Path.Combine(smtpConfiguration.Folders.ErrorFolder, Path.GetFileName(routableMessage.FileName)));

                            // Notify that a message was not Sent
                            MessageNotSent?.Invoke(this, new MessageErrorEventArgs(routableMessage, e));
                        }
                    }
                    else
                    {
                        // Wait for a few seconds before trying again
                        Task.Delay(3000).Wait(cancellationToken);
                    }
                }
                catch (Exception e)
                {
                    // Nothing else to try, notifies system about the issue
                    GeneralError?.Invoke(this, new GeneralErrorEventArgs(new Exception($"General Error on '{nameof(SendRoutedMessages)}' method", e), nameof(SendRoutedMessages)));
                }
                finally
                {
                    // Disconnects client if needed
                    if (client != null)
                    {
                        if (client.IsConnected)
                        {
                            client.Disconnect(true);
                        }
                    }
                }
            }

            // Notify that the Smtp Connection has been closed
            SmtpConnectionEnded?.Invoke(this, new SmtpConnectionEventArgs(smtpConfiguration, connectionNumber, null));
        }
    /// <summary>
    /// Use of Disinfection Post
    /// </summary>
    /// <param name="pController"></param>
    public void Interact(PlayerController pController)
    {
        player = pController;
        GrabableObject objectInHand = player.pDatas.objectInHand;
        Gastro         gastroInHand = player.pDatas.gastroInHand;

        // Put object = No object on post and object in hand of player
        if (haveAnObject == false && objectInHand != null)
        {
            if (grabableReceived == null)
            {
                Aliment actualAliment;
                if (gastroInHand != null)
                {
                    actualAliment = gastroInHand.alimentStocked;
                }
                else
                {
                    actualAliment = objectInHand.GetComponent <Aliment>();
                }
                if (actualAliment != null && actualAliment.alimentState == AlimentState.InContent)
                {
                    if (player.pDatas.gastroInHand != null)
                    {
                        grabableReceived = player.pDatas.gastroInHand.ReleaseObject(false, false, false);
                    }
                    else
                    {
                        grabableReceived = player.pInteract.ReleaseObject(false, false, false);
                    }
                    grabableReceived.AllowGrab(false);
                    grabableReceived.transform.position = initPos.position;
                    grabableReceived.transform.rotation = initPos.rotation;

                    haveAnObject = true;

                    Aliment newAliment = grabableReceived.GetComponent <Aliment>();

                    // Affect the player
                    player.TeleportTo(playerPosition, true);
                    player.BeginInteractionState();

                    // transform dirty aliment into fresh aliment
                    if (newAliment != null)
                    {
                        GeneralError.ErrorNoOutfit(pController);
                        currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true, true));
                    }

                    photonView.RPC("PutObjectInPost", RpcTarget.Others, pController.photonView.OwnerActorNr);
                }
                else
                {
                    GameManager.Instance.PopUp.CreateText("Cet object ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                }
            }
        }
        else if (objectInHand != null && haveAnObject == true)
        {
            GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
        }
    }
Beispiel #14
0
        public string decodeI(string iLine)
        {
            //I format can hold rs, rt and immediate
            //In that order OPCODE(6) RS(5) RT(5) IMM(16)
            string opcode = iLine.Substring(0, 6);
            string rs     = iLine.Substring(6, 5);
            string rt     = iLine.Substring(11, 5);
            string imm    = iLine.Substring(16);
            string imm_s  = imm;

            signExtend(ref imm_s, 32); //So just in case we have a signed op.

            //rs rt and imm, then decode opcode so you know where to place em;
            //Declare the elements of the big string to retrun

            int    imm_int  = Convert.ToInt32(imm, 2);
            int    imm_sint = Convert.ToInt32(imm_s, 2);
            string rs_name  = getRegName(rs); //so if the namer didn't get them just throw the word err
            string rt_name  = getRegName(rt);
            string mnemonic;
            string mipsline;
            ulong  fulladdress = (ulong)imm_sint * 4 + Current_Inst_Address + 4;

            //Ok We got Register names, and IM now we need to decode OPCode to see where they fit in the STRING :)
            //Start decoding OPcode and return :) we're done
            switch (opcode)
            {
            case "001000":     //Addi
                mnemonic = "addi";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_sint;
                return(mipsline);

            case "001001":     //Addiu
                mnemonic = "addiu";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_int;
                return(mipsline);

            case "001100":     //Andi
                mnemonic = "andi";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_int;
                return(mipsline);

            case "000100":     //beq
                mnemonic = "beq";
                int iol = (int)(Current_Inst_Address + 4 - 4194304) / 4;
                iOfLinesMentionsLabel.Add(iol - 1);
                UnresolvedBLabelsLongs.Add(Current_Inst_Address + 4);
                unresolvedBlabel.Add(Current_Inst_Address + 4, imm_sint);
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + "%" + fulladdress;
                return(mipsline);

            case "000101":     //bne
                mnemonic = "bne";
                iol      = (int)(Current_Inst_Address + 4 - 4194304) / 4;
                iOfLinesMentionsLabel.Add(iol - 1);
                UnresolvedBLabelsLongs.Add(Current_Inst_Address + 4);
                unresolvedBlabel.Add(Current_Inst_Address + 4, imm_sint);
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + "%" + fulladdress;
                return(mipsline);

            case "100000":     //lb
                mnemonic = "lb";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_sint + "($" + rs_name + ")";
                return(mipsline);

            case "100100":     //lbu
                mnemonic = "lbu";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_int + "($" + rs_name + ")";
                return(mipsline);

            case "100001":     //lh
                mnemonic = "lh";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_sint + "($" + rs_name + ")";
                return(mipsline);

            case "100101":     //lhu
                mnemonic = "lhu";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_int + "($" + rs_name + ")";
                return(mipsline);

            case "100011":     //lw
                mnemonic = "lw";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_int + "($" + rs_name + ")";
                return(mipsline);

            case "001101":     //ori
                mnemonic = "ori";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_int;
                return(mipsline);

            case "101000":     //sb
                mnemonic = "sb";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_int + "($" + rs_name + ")";
                return(mipsline);

            case "001010":     //slti
                mnemonic = "slti";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_sint;
                return(mipsline);

            case "001011":     //sltiu
                mnemonic = "sltiu";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_int;
                return(mipsline);

            case "101001":     //sh
                mnemonic = "sh";
                mipsline = mnemonic + " $" + rt_name + ", " + imm + "($" + rs_name + ")";
                return(mipsline);

            case "101011":     //sw
                mnemonic = "sw";
                mipsline = mnemonic + " $" + rt_name + ", " + imm + "($" + rs_name + ")";
                return(mipsline);

            case "001110":     //xori
                mnemonic = "xori";
                mipsline = mnemonic + " $" + rt_name + ", $" + rs_name + ", " + imm_int;
                return(mipsline);

            case "001111":     //Lui
                mnemonic = "lui";
                mipsline = mnemonic + " $" + rt_name + ", " + imm_int;
                return(mipsline);

                break;

            default:
                //unsupported, throw error
                GeneralError.Invoke("iFormatDecoder::Disassembler", "OPCODE: " + opcode, "Hi there, the disassembler encountered an unsupported i-format instruction");
                return("ERR");
            }
        }
    public void Interact(PlayerController pController)
    {
        player = pController;
        GrabableObject objectInHand = player.pDatas.objectInHand;
        Gastro         gastroInHand = pController.pDatas.gastroInHand;

        // Put object = No object on post and object in hand of player
        if (haveAnObject == false && objectInHand != null)
        {
            if (gastroInHand == null)
            {
                if (grabableReceived == null)
                {
                    Aliment actualAliment = objectInHand.GetComponent <Aliment>();
                    string  alimentType   = actualAliment.alimentType.ToString();
                    string  postType      = typeOfTreament.ToString();

                    if (alimentType == postType)
                    {
                        sameState = true;
                    }
                    else
                    {
                        sameState = false;
                    }

                    Debug.Log(alimentType);
                    Debug.Log(postType);
                    Debug.Log(sameState);

                    if (actualAliment != null && (actualAliment.alimentState == AlimentState.InContent || actualAliment.alimentState == AlimentState.Standard))
                    {
                        AlimentObject actualAlimentObject = FoodDatabase.mapAlimentObject[actualAliment.alimentName];

                        bool alimenStateExist = false;
                        for (int i = 0; i < actualAlimentObject.listState.Count; i++)
                        {
                            if (actualAlimentObject.listState[i].state == AlimentState.Clean)
                            {
                                alimenStateExist = true;
                                break;
                            }
                        }

                        if (sameState && alimenStateExist)
                        {
                            grabableReceived = player.pInteract.ReleaseObject(false, false, false);
                            grabableReceived.AllowGrab(false);
                            grabableReceived.AllowPhysic(false);
                            grabableReceived.transform.position = initPos.position;
                            grabableReceived.transform.rotation = initPos.rotation;

                            haveAnObject = true;

                            Aliment newAliment = grabableReceived.GetComponent <Aliment>();

                            // Affect the player
                            player.TeleportTo(playerPosition, true);
                            player.BeginInteractionState();

                            // transform dirty aliment into fresh aliment
                            if (newAliment != null)
                            {
                                GeneralError.ErrorNoOutfit(pController);
                                currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true, true));
                            }

                            photonView.RPC("PutObjectInPost", RpcTarget.Others, pController.photonView.OwnerActorNr);
                        }
                        else
                        {
                            GameManager.Instance.PopUp.CreateText("Cet Objet ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                        }
                    }
                    else if (objectInHand != null && haveAnObject == true)
                    {
                        GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
                    }
                    else
                    {
                        GameManager.Instance.PopUp.CreateText("Cet Objet ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                    }
                }
            }
            else
            {
                GameManager.Instance.PopUp.CreateText("Il n'est pas possible d'utiliser un gastro ici", 50, new Vector2(0, 300), 3.0f);
            }
        }
        else
        {
            GameManager.Instance.PopUp.CreateText("Cet object ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
        }
    }
 /// <summary>
 /// Создает экземпляр класса для хранения ошибки из диапазона
 /// общих кодов ошибок
 /// </summary>
 /// <param name="value">Общий код ошибки</param>
 /// <param name="sender">Устройство-отправитель кода ошибки</param>
 public ServerErrorCode(IDevice sender, GeneralError value)
     : this(sender, value, GetGeneralDescription(value), 0, noErrors, string.Empty)
 {
 }
 /// <summary>
 /// Создает экземпляр класса для хранения ошибки из диапазона
 /// общих кодов ошибок, включая дамп команды или ответа
 /// </summary>
 /// <param name="value">Общий код ошибки</param>
 /// <param name="sender">Устройство-отправитель кода ошибки</param>
 /// <param name="commandDump">Дамп команды или ответа</param>
 public ServerErrorCode(IDevice sender, GeneralError value, string commandDump)
     : this(sender, value, GetGeneralDescription(value), 0, noErrors, commandDump)
 {
 }
Beispiel #18
0
    //Set Player who use ColdRoom
    public void Interact(PlayerController pController)
    {
        gameManager.FreeMouse();

        player = pController;

        if (player.pDatas.objectInHand == null)
        {
            ui.DisplayUiMenu(); // Display Menu
        }
        else                    // put object in coldRoom
        {
            Gastro gastroInHand = pController.pDatas.gastroInHand;

            if (gastroInHand == null)
            {
                Aliment   foodToAdd = player.pDatas.objectInHand.GetComponent <Aliment>();
                Nominator nominator = player.pDatas.objectInHand.GetComponent <Nominator>();

                if (foodToAdd == null)                 // EXIT IF NO ALIMENT FOUND
                {
                    GameManager.Instance.PopUp.CreateText("Imossible de placer " + nominator.customName + " dans la chambre froide", 50, new Vector2(0, 300), 3.0f);
                    return;
                }

                photonView.RPC("PutObjectInColdRoom", RpcTarget.Others, player.photonView.OwnerActorNr);

                if ((foodToAdd.alimentState == AlimentState.Stack || foodToAdd.alimentState == AlimentState.Box))                 // unlimited Food
                {
                    if (!foodsStocked.Contains(foodToAdd.CreateKeyPairValue()))
                    {
                        AddFood(foodToAdd.CreateKeyPairValue(), true);
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                    else
                    {
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                }
                else                                                                      // limited food
                {
                    if (!limitedFoodsStocked.ContainsKey(foodToAdd.CreateKeyPairValue())) //first deposit
                    {
                        AddFood(foodToAdd.CreateKeyPairValue(), true);
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                    else
                    {
                        limitedFoodsStocked[foodToAdd.CreateKeyPairValue()] += 1;
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                }
            }
            else
            {
                GameManager.Instance.PopUp.CreateText("Il n'est pas possible de déposer/utiliser un gastro ici", 50, new Vector2(0, 300), 3.0f);
            }
        }
    }
Beispiel #19
0
        /// <summary>
        /// Get messages form the <see cref="MessagesToRouteQueue"/> and routes them to the proper Smtp Queue
        /// </summary>
        /// <param name="cancellationToken">The cancellation token</param>
        /// <remarks>This method is expected to be run in different tasks at the same time, hence it uses a <see cref="ConcurrentQueue{T}"/> to avoid deadlocks</remarks>
        private void RouteMessages(CancellationToken cancellationToken)
        {
            while (cancellationToken.IsCancellationRequested == false)
            {
                if (!IsPaused)
                {
                    // Pull next message from the queue
                    bool            Dequeued        = false;
                    RoutableMessage routableMessage = null;

                    // Lock the Queue to Ensure Thread-Safety
                    lock (MessagesToRouteQueue)
                    {
                        Dequeued = MessagesToRouteQueue.TryDequeue(out routableMessage);
                    }

                    if ((Dequeued) && (routableMessage != null))
                    {
                        // The Message Current Location
                        string FileCurrentLocation = routableMessage.FileName;

                        // Route the message that just came from the queue
                        try
                        {
                            // Validate Incoming IP Address (unless the Force Routing flag is set)
                            if (!routableMessage.ForceRouting)
                            {
                                if (AcceptedIPAddresses?.Count > 0)
                                {
                                    // Check if Incoming IP Address is on the list
                                    if (!AcceptedIPAddresses.Contains(routableMessage.IPAddress))
                                    {
                                        throw new UnauthorizedSenderException(routableMessage, RejectReasons.NotInAcceptedAddressesList);
                                    }
                                }

                                if (RejectedIPAddresses?.Count > 0)
                                {
                                    // Check if Incoming IP Address is on the rejection list
                                    if (RejectedIPAddresses.Contains(routableMessage.IPAddress))
                                    {
                                        throw new UnauthorizedSenderException(routableMessage, RejectReasons.ExistsInRejectedAddressesList);
                                    }
                                }
                            }

                            // Validate Rules
                            if (RoutingRules == null)
                            {
                                throw new Exception("No rules configured to process routing. The message will be sent to the Error Queue after exceeding the Maximum Number of Attempts.");
                            }

                            if (RoutingRules?.Count == 0)
                            {
                                throw new Exception("No rules configured to process routing. The message will be sent to the Error Queue after exceeding the Maximum Number of Attempts.");
                            }

                            // Validate SMTP Configurations
                            if (DestinationSmtps == null)
                            {
                                throw new Exception("There is no SMTP configuration to route the emails to. The message will be sent to the Error Queue after exceeding the Maximum Number of Attempts");
                            }

                            if (DestinationSmtps?.Count == 0)
                            {
                                throw new Exception("There is no SMTP configuration to route the emails to. The message will be sent to the Error Queue after exceeding the Maximum Number of Attempts");
                            }

                            // Ensure there is a valid Routable Message
                            if (routableMessage == null)
                            {
                                throw new Exception("The Routable Message is not valid");
                            }

                            // Ensure there is a valid MimeMessage
                            if (routableMessage.Message == null)
                            {
                                throw new Exception("The MimeMessage is nov valid");
                            }

                            // The rule selected for use
                            RoutingRule selectedRule = null;

                            // Fetch Rules sorted by the Execution Sequence
                            foreach (RoutingRule rule in (from r in RoutingRules orderby r.ExecutionSequence select r))
                            {
                                // Try the rule
                                if (rule.Match(routableMessage))
                                {
                                    selectedRule = rule;

                                    // No need to continue loop
                                    break;
                                }
                            }

                            // Ensure a rule was found
                            if (selectedRule == null)
                            {
                                throw new Exception($"Unable to find a {nameof(RoutingRule)} for the given message");
                            }

                            // Verify SMTP Connection
                            if (string.IsNullOrWhiteSpace(selectedRule.SmtpConfigurationKey))
                            {
                                throw new Exception($"The {nameof(selectedRule.SmtpConfigurationKey)} is empty");
                            }

                            if (!DestinationSmtps.ContainsKey(selectedRule.SmtpConfigurationKey))
                            {
                                throw new Exception($"There is no Smtp configured for the key '{selectedRule.SmtpConfigurationKey}'");
                            }

                            SmtpConfiguration smtpConfiguration = DestinationSmtps[selectedRule.SmtpConfigurationKey];

                            if (smtpConfiguration == null)
                            {
                                throw new ArgumentNullException($"The Smtp by the key '{selectedRule.SmtpConfigurationKey}' is misconfigured");
                            }

                            // All checks passed, Send it to the proper queue

                            // Move files and enqueue
                            File.Move(routableMessage.FileName, Path.Combine(smtpConfiguration.Folders.InQueueFolder, Path.GetFileName(routableMessage.FileName)));
                            FileCurrentLocation      = Path.Combine(smtpConfiguration.Folders.InQueueFolder, Path.GetFileName(routableMessage.FileName));
                            routableMessage.FileName = FileCurrentLocation;
                            SmtpQueues[smtpConfiguration.QueueNumber].Enqueue(routableMessage);

                            // Notify the message was routed
                            MessageRoutedSuccessfully?.Invoke(this, new MessageEventArgs(routableMessage));
                        }
                        catch (UnauthorizedSenderException e)
                        {
                            // Move the message to the Rejected folder
                            try
                            {
                                File.Move(FileCurrentLocation, Path.Combine(Folders.RejectedFolder, Path.GetFileName(FileCurrentLocation)));
                            }
                            catch (Exception e2)
                            {
                                // That is a very unlikely situation
                                GeneralError?.Invoke(this, new GeneralErrorEventArgs(new Exception("Unable to move file to Rejected Folder", e2), nameof(RouteMessages)));
                            }

                            // Notify the message was not routed
                            MessageNotRouted?.Invoke(this, new MessageErrorEventArgs(routableMessage, e));
                        }
                        catch (Exception e)
                        {
                            // Move the message to the retry or error folder
                            try
                            {
                                File.Move(FileCurrentLocation, Path.Combine(Folders.ErrorFolder, Path.GetFileName(FileCurrentLocation)));
                            }
                            catch (Exception e2)
                            {
                                // That is a very unlikely situation
                                GeneralError?.Invoke(this, new GeneralErrorEventArgs(new Exception("Unable to move file to Error Folder", e2), nameof(RouteMessages)));
                            }

                            // Notify the message was not routed
                            MessageNotRouted?.Invoke(this, new MessageErrorEventArgs(routableMessage, new MessageNotRoutedException(routableMessage, e)));
                        }
                    }
                    else
                    {
                        // Wait two seconds before trying again
                        Task.Delay(2000).Wait(cancellationToken);
                    }
                }
                else
                {
                    // Nothing to do other than wait a few seconds before trying again
                    Task.Delay(5000).Wait(cancellationToken);
                }
            }
        }
 public GeneralErrorTest()
 {
     mError = new GeneralError("type", "message");
 }
    /// <summary>
    /// Use of Disinfection Post
    /// </summary>
    /// <param name="pController"></param>
    public void Interact(PlayerController pController)
    {
        player = pController;
        GrabableObject objectInHand = player.pDatas.objectInHand;
        Gastro         gastroInHand = player.pDatas.gastroInHand;

        // Put object = No object in furnace and object in hand of player
        if (haveAnObject == false && objectInHand != null)
        {
            if (grabableReceived == null)
            {
                Aliment actualAliment;
                if (gastroInHand != null)
                {
                    actualAliment = gastroInHand.alimentStocked;
                }
                else
                {
                    actualAliment = objectInHand.GetComponent <Aliment>();
                }
                if (actualAliment != null && (actualAliment.alimentState == AlimentState.Standard || actualAliment.alimentState == AlimentState.Clean))
                {
                    AlimentObject actualAlimentObject = FoodDatabase.mapAlimentObject[actualAliment.alimentName];

                    bool alimenStateExist = false;

                    for (int i = 0; i < actualAlimentObject.listState.Count; i++)
                    {
                        if (actualAlimentObject.listState[i].state == AlimentState.Cut)
                        {
                            alimenStateExist = true;
                            break;
                        }
                    }
                    if (alimenStateExist)
                    {
                        if (player.pDatas.gastroInHand != null)
                        {
                            grabableReceived = player.pDatas.gastroInHand.ReleaseObject(false, false, false);
                        }
                        else
                        {
                            grabableReceived = player.pInteract.ReleaseObject(false, false, false);
                        }
                        grabableReceived.AllowGrab(false);
                        grabableReceived.transform.position = foodPos.position;
                        grabableReceived.transform.rotation = foodPos.rotation;

                        haveAnObject = true;

                        Aliment newAliment = grabableReceived.GetComponent <Aliment>();

                        // Affect the player
                        player.TeleportTo(playerPosition, true);
                        player.BeginInteractionState();

                        // transform dirty aliment into fresh aliment
                        if (newAliment != null)
                        {
                            GeneralError.ErrorNoOutfit(pController);
                            currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true, true));
                        }

                        photonView.RPC("PutObjectInPost", RpcTarget.Others, pController.photonView.OwnerActorNr);
                    }
                    else
                    {
                        GameManager.Instance.PopUp.CreateText("Cet aliment ne peut pas être coupé", 50, new Vector2(0, 300), 3.0f);
                    }
                }
                else
                {
                    GameManager.Instance.PopUp.CreateText("Cet object ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                }
            }
        }
        else if (objectInHand == null && haveAnObject == true)  // Take object = object in furnace and no object in hand of player
        {
            if (player.pDatas.gastroInHand != null)
            {
                if (player.pDatas.gastroInHand.StockAliment(objectCutted, true) == false)
                {
                    GameManager.Instance.PopUp.CreateText("impossible de mettre " + objectCutted.GetComponent <Aliment>().alimentName + " dans le gastro", 50, new Vector2(0, 300), 3.0f);
                }
            }
            else
            {
                if (player.pInteract.GrabObject(objectCutted, true) == false)
                {
                    GameManager.Instance.PopUp.CreateText("impossible de prendre " + objectCutted.GetComponent <Aliment>().alimentName + " dans vos mains", 50, new Vector2(0, 300), 3.0f);
                }
            }
        }
        else if (objectInHand != null && haveAnObject == true) // put object impossible = object in furnace and object in hand of player
        {
            GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
        }
    }