예제 #1
0
 public void MyDispose()
 {
     foreach (var Comm in MLocalCommands)
     {
         Comand.Remove(Comm.Key);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            FileManager fm = FileManager.GetFileManager();

            while (true)
            {
                Comand comand = fm.GetInputComand();

                if (comand != Comand.None)
                {
                    switch (comand)
                    {
                    case Comand.Save:
                        fm.SaveChanges();
                        break;

                    case Comand.ChooseSave:
                        fm.ChooseSave(fm.GetLastDirectoryPath());
                        break;

                    case Comand.Revert:
                        fm.RevertChanges();
                        break;
                    }


                    Console.WriteLine(comand);
                    Thread.Sleep(1000);
                }
            }
        }
예제 #3
0
        public override async Task Monitorar(Comand comand, IServerStreamWriter <Resposta> responseStream, ServerCallContext context)
        {
            Comando    comando  = new Comando((Comandos)comand.Cmd, comand.Chave, comand.Valor);
            Requisicao req      = new Requisicao(context, comando);
            string     resposta = "";

            lock (blockComandos)
            {
                filaComandos.Enqueue(req);
            }
            bool flag = true;

            while (flag)
            {
                resposta = "";
                lock (req.block)
                {
                    if (req.respostas.Count > 0)
                    {
                        resposta = req.respostas.Dequeue();
                    }
                    if (!req.HaRespostas && req.respostas.Count <= 0)
                    {
                        flag = false;
                    }
                }

                if (resposta != "")
                {
                    Resposta resp = new Resposta();
                    resp.Mensagem = resposta;
                    await responseStream.WriteAsync(resp);
                }
            }
        }
예제 #4
0
 public void MyDispose()
 {
     foreach (KeyValuePair <Comands, Action <BaseCommand> > mComm in mLocalCommands)
     {
         Comand.Remove(mComm.Key);
     }
     Draw -= EngineConsole_Draw;
 }
예제 #5
0
    void Start()
    {
        UpComand    = new UpComand();
        DownComand  = new DownComand();
        LeftComand  = new LeftComand();
        rightComand = new RightComand();
        Stopcomand  = new StopComand();

        Play = this.gameObject.GetComponent <PlayerCarController> ();
    }
예제 #6
0
        // Server side handler of the SayHello RPC
        public override Task <Resposta> Comando(Comand comand, ServerCallContext context)
        {
            Comando    comando = new Comando((Comandos)comand.Cmd, comand.Chave, comand.Valor);
            Requisicao req     = new Requisicao(context, comando);

            lock (blockComandos)
            {
                filaComandos.Enqueue(req);
            }

            return(Task.FromResult(ProcessaComando(req)));
        }
예제 #7
0
        public Bouqet ExecuteCommand(Comand command, string param)
        {
            Bouqet b = new Bouqet();

            switch (command)
            {
            case Comand.FindByColor:
                b = FindByColor(param);
                return(b);

            case Comand.SortByParam:
                SortByName();
                break;
            }

            return(b);
        }
예제 #8
0
 private void InitControls()
 {
     mLocalCommands.Add(Comands.Left, GeneralMove);
     mLocalCommands.Add(Comands.TenStepsLeft, GeneralMove);
     mLocalCommands.Add(Comands.Right, GeneralMove);
     mLocalCommands.Add(Comands.TenStepsRight, GeneralMove);
     mLocalCommands.Add(Comands.Up, GeneralMove);
     mLocalCommands.Add(Comands.TenStepsUp, GeneralMove);
     mLocalCommands.Add(Comands.Down, GeneralMove);
     mLocalCommands.Add(Comands.TenStepsDown, GeneralMove);
     mLocalCommands.Add(Comands.GenerateALotOfRooms, GenerateRooms);
     mLocalCommands.Add(Comands.GenerateOneRoom, GenerateRooms);
     mLocalCommands.Add(Comands.GenerateRandomPath, GeneratePath);
     foreach (KeyValuePair <Comands, Action <BaseCommand> > mComm in mLocalCommands)
     {
         Comand.Add(mComm.Key, mComm.Value);
     }
 }
예제 #9
0
 private void InitControls()
 {
     MLocalCommands.Add(Comands.Left, GeneralMove);
     MLocalCommands.Add(Comands.TenStepsLeft, GeneralMove);
     MLocalCommands.Add(Comands.Right, GeneralMove);
     MLocalCommands.Add(Comands.TenStepsRight, GeneralMove);
     MLocalCommands.Add(Comands.Up, GeneralMove);
     MLocalCommands.Add(Comands.TenStepsUp, GeneralMove);
     MLocalCommands.Add(Comands.Down, GeneralMove);
     MLocalCommands.Add(Comands.TenStepsDown, GeneralMove);
     MLocalCommands.Add(Comands.GenerateALotOfRooms, GenerateRooms);
     MLocalCommands.Add(Comands.GenerateOneRoom, GenerateRooms);
     MLocalCommands.Add(Comands.GenerateRandomPath, GeneratePath);
     foreach (var Comm in MLocalCommands)
     {
         Comand.Add(Comm.Key, Comm.Value);
     }
 }
예제 #10
0
        private void InputHandling()
        {
            while (true)
            {
                Comand comand = fm.GetInputComand();

                if (comand != Comand.None)
                {
                    switch (comand)
                    {
                    case Comand.Save:
                        fm.SaveChanges();
                        break;

                    case Comand.ChooseSave:
                        if (IsGameRunning())
                        {
                            PrintErrorMessage();
                            break;
                        }

                        fm.ChooseSave(GetFolderPath());
                        break;

                    case Comand.Revert:
                        if (IsGameRunning())
                        {
                            PrintErrorMessage();
                            break;
                        }

                        fm.RevertChanges();
                        break;
                    }
                    Thread.Sleep(1000);
                }
                Thread.Sleep(50);
            }
        }
예제 #11
0
        public void Call()
        {
            OnStart(this);

            if (Output.Target == Target.Library)
            {
                Comand += " -gc -op";
                Comand += " -lib";
                Comand += " -H -Hd\"" + Output.Headers + "\"";
            }

            Comand += " -of\"" + FileItem.BuildNormalizedPath(Output.Assembly.Location) + Output.Assembly.Name.Replace(".", "") + OutputExtension + "\"";

            foreach (string import in Input.Import)
            {
                string clearImport = SolutionDirectory + import;

                if (Output.Target == Target.Executable)
                {
                    Comand += LinkerLibSearchOption + FileItem.BuildNormalizedPath(clearImport, true);
                }

                Comand += " -I" + FileItem.BuildNormalizedPath(clearImport);
            }

            foreach (FileItem file in Input.Files)
            {
                Comand += " \"" + file.Location + file.Name + "\"";
            }

            Comand = Comand.Trim();

            OnBeforeCompile(this, Comand);

            Process compiler = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName        = _driver.Location,
                    Arguments       = Comand,
                    CreateNoWindow  = true,
                    UseShellExecute = false,

                    RedirectStandardOutput = true,
                    RedirectStandardError  = true
                }
            };

            compiler.Start();

            while (!compiler.StandardOutput.EndOfStream)
            {
                OnCompile(this, compiler.StandardOutput.ReadToEnd());
            }

            while (!compiler.StandardError.EndOfStream)
            {
                OnError(this, compiler.StandardError.ReadToEnd());
            }

            FileItem.MoveMassive(WorkingDirectory, Output.Headers, "*.di");

            OnSuccess(this);
        }
예제 #12
0
 void Start()
 {
     UpComand = new UpComand();
     Play     = this.gameObject.GetComponent <PlayerCarController> ();
 }
예제 #13
0
 public Operation(Comand cmd)
 {
     Cmd = cmd;
 }
예제 #14
0
 //Realiza un Update sobre la base de datos
 public void FbUpdate()
 {
     _Comand = new FbCommand(this.StrCadena, _Conect);
     _Conect.Open();
     Comand.ExecuteNonQuery();
 }
예제 #15
0
        static void Main(string[] args)
        {
            if (!File.Exists("portas.txt"))
            {
                var stream = File.Create("portas.txt");
                stream.Close();
                StreamWriter arq = new StreamWriter("portas.txt");
                arq.WriteLine("1700");
                arq.WriteLine("127.0.0.1");
                arq.Close();
            }

            StreamReader file = new StreamReader("portas.txt");

            porta    = int.Parse(file.ReadLine());
            endereco = file.ReadLine();

            Channel channel = new Channel(endereco + ":" + porta, ChannelCredentials.Insecure);

            client = new RPC.RPCClient(channel);

            String data;
            int    comand;
            int    chave;

            Task task = null;

            while (true)
            {
                Console.WriteLine("Qual comando(ADD-1/READ-2/UPDATE-3/DELETE-4/LISTAR-5/DESLIGAR-6)/MONITORAR-7");
                if (!int.TryParse(Console.ReadLine(), out comand) || comand <= 0 || comand > 7)
                {
                    Console.WriteLine("Comando Inválido!");
                    continue;
                }
                switch (comand)
                {
                case (int)Comandos.ADD:
                    Console.WriteLine("Insira chave");
                    if (!int.TryParse(Console.ReadLine(), out chave))
                    {
                        Console.WriteLine("Chave inválida");
                        continue;
                    }

                    Console.WriteLine("Insira dado");
                    data = Console.ReadLine();

                    cmd       = new Comand();
                    cmd.Chave = chave;
                    cmd.Valor = data;
                    cmd.Cmd   = comand;
                    task      = new Task(ThreadGRPC);
                    break;

                case (int)Comandos.READ:
                    Console.WriteLine("Insira chave");
                    if (!int.TryParse(Console.ReadLine(), out chave))
                    {
                        Console.WriteLine("Chave inválida");
                        continue;
                    }
                    cmd       = new Comand();
                    cmd.Chave = chave;
                    cmd.Cmd   = comand;
                    task      = new Task(ThreadGRPC);
                    break;

                case (int)Comandos.UPDATE:
                    Console.WriteLine("Insira chave");
                    if (!int.TryParse(Console.ReadLine(), out chave))
                    {
                        Console.WriteLine("Chave inválida");
                        continue;
                    }
                    Console.WriteLine("Insira dado");
                    data = Console.ReadLine();

                    cmd       = new Comand();
                    cmd.Chave = chave;
                    cmd.Valor = data;
                    cmd.Cmd   = comand;
                    task      = new Task(ThreadGRPC);
                    break;

                case (int)Comandos.DELETE:
                    Console.WriteLine("Insira chave");
                    if (!int.TryParse(Console.ReadLine(), out chave))
                    {
                        Console.WriteLine("Chave inválida");
                        continue;
                    }

                    cmd       = new Comand();
                    cmd.Chave = chave;
                    cmd.Cmd   = comand;
                    task      = new Task(ThreadGRPC);
                    break;

                case (int)Comandos.DESLIGAR:
                    break;

                case (int)Comandos.LISTAR:
                    cmd     = new Comand();
                    cmd.Cmd = comand;
                    task    = new Task(ThreadListar);
                    break;

                case (int)Comandos.MONITORAR:
                    Console.WriteLine("Insira chave");
                    if (!int.TryParse(Console.ReadLine(), out chave))
                    {
                        Console.WriteLine("Chave inválida");
                        continue;
                    }

                    cmd       = new Comand();
                    cmd.Cmd   = comand;
                    cmd.Chave = chave;
                    task      = new Task(ThreadMonitorar);
                    break;
                }
                if (cmd != null && task != null)
                {
                    task.Start();
                }
            }
        }
예제 #16
0
        public static void X()
        {
            string        S = Console.ReadLine();
            int           CountCommantFirstDivision  = int.Parse(S.Split(' ')[0]);
            int           CountCommantSecondDivision = int.Parse(S.Split(' ')[1]);
            List <Comand> CMFirst  = new List <Comand>();
            List <Comand> CMSecond = new List <Comand>();

            //заполняем масивы команд первого и второго дивизиона
            for (int i = 0; i < CountCommantFirstDivision; i++)
            {
                string s = Console.ReadLine();
                Comand C = new Comand();
                C.Id = int.Parse(s.Split(' ')[0]);
                C.CompletedAssignments = int.Parse(s.Split(' ')[1]);
                C.PenaltyTime          = int.Parse(s.Split(' ')[2]);
                if (C.CompletedAssignments > 0)
                {
                    //добавляем только решивших хотябы 1
                    CMFirst.Add(C);
                }
            }
            //прошедшие команды
            List <int> IDComandWIN = new List <int>();

            for (int i = 0; i < CountCommantSecondDivision; i++)
            {
                string s = Console.ReadLine();
                Comand C = new Comand();
                C.Id = int.Parse(s.Split(' ')[0]);
                C.CompletedAssignments = int.Parse(s.Split(' ')[1]);
                C.PenaltyTime          = int.Parse(s.Split(' ')[2]);
                if (C.CompletedAssignments > 0)
                {
                    //добавляем только решивших хотябы 1
                    IDComandWIN.Add(C.Id);
                }
            }


            //сортируем по количеству балов и штрафному времени
            CMFirst = CMFirst.OrderByDescending(asa => asa.CompletedAssignments).ThenBy(assa => assa.PenaltyTime).ToList();
            int MaxComplete = 0;

            if (CMFirst.Count > 0)
            {
                MaxComplete = CMFirst[0].CompletedAssignments;
            }

            //добавляем всех кто выполнил столькоже сколько победитель
            foreach (var item in CMFirst)
            {
                if (item.CompletedAssignments == MaxComplete)
                {
                    IDComandWIN.Add(item.Id);
                }
            }
            //середина списка
            int CentepPlace         = CMFirst.Count() / 2 - 1;
            int CenterCountComplete = 9999;

            if (CentepPlace > 0)
            {
                CenterCountComplete = CMFirst[CentepPlace].CompletedAssignments;
            }



            //добавляем всех кто до середины и набрал больше балов чем центральный
            for (int i = 0; i < CentepPlace; i++)
            {
                if (CMFirst[i].CompletedAssignments > CenterCountComplete)
                {
                    IDComandWIN.Add(CMFirst[i].Id);
                }
            }

            IDComandWIN = IDComandWIN.Distinct().ToList();

            IDComandWIN.Sort();

            Console.WriteLine(IDComandWIN.Count);
            foreach (var id in IDComandWIN)
            {
                Console.Write(id + " ");
            }
            Console.WriteLine();
        }