Пример #1
0
        // POST: Clients/Create
        public ActionResult Create(Client client)
        {
            var cp = new ClientProcess();

            cp.Insert(client);
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // POST: Clients/Edit
        public ActionResult Edit(Client client)
        {
            var cp = new ClientProcess();

            cp.Edit(client);
            return(RedirectToAction("Index"));
        }
Пример #3
0
        //[DllImport("kernel32.dll")]
        //static extern IntPtr OpenProcess(uint dwDesiredAccess, int bInheritHandle, int dwProcessId);
        //[DllImport("kernel32.dll")]
        //static extern uint WriteProcessMemory(IntPtr hProcess, uint lpBaseAddress, byte[] lpBuffer, int nSize, uint lpNumberOfBytesWritten);
        //[DllImport("kernel32.dll")]
        //static extern uint VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, uint flAllocationType, uint flProtect);
        //[DllImport("kernel32.dll")]
        //static extern IntPtr CreateMutex(IntPtr lpMutexAttributes, bool bInitialOwner, string lpName);
        //public static IntPtr Handle;
        //public static IntPtr SROHandle;
        //private Process Started;
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (chkClientless.Checked)
            {
                var gatewayRemoteEP = Configs.ClientConfig.GatewayServer;// new System.Net.IPEndPoint(Metadata.MediaData.ClientInfo.IP, Metadata.MediaData.ClientInfo.Port);
                ProxyClientless.SetGatewayRemoteEndPoint(gatewayRemoteEP);
                ProxyClientless.StartGateway();
                timerClientPing.Enabled = true;
            }
            else
            {
                var agentLocalEP = Configs.PatchConfig.RedirectAgentServer;// new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 20002);
                Proxy.SetAgentLocalEndPoint(agentLocalEP);

                var gatewayLocalEP  = Configs.PatchConfig.RedirectGatewayServer; //new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 20001);
                var gatewayRemoteEP = Configs.ClientConfig.GatewayServer;        // new System.Net.IPEndPoint(Metadata.MediaData.ClientInfo.IP, Metadata.MediaData.ClientInfo.Port);
                Proxy.SetGatewayLocalEndPoint(gatewayLocalEP);
                Proxy.SetGatewayRemoteEndPoint(gatewayRemoteEP);
                Proxy.StartGateway();
            }

            if (!chkExternLoader.Checked)
            {
                ClientProcess.StartProcess();
            }

            btnStart.Enabled = false;
        }
Пример #4
0
        // GET: Clients/Client
        public ActionResult Index()
        {
            var cp    = new ClientProcess();
            var lista = cp.SelectList();

            return(View(lista));
        }
Пример #5
0
        public void Add(ClientProcess clientProcess, int assignTo)
        {
            try
            {
                if (primarySteps.Count() > 0)
                {
                    PrimaryStep primaryStep = primarySteps.First(i => i.Id == clientProcess.PrimaryStepId);

                    if (primaryStep != null)
                    {
                        linkSubSteps  = processService.GetLinkSubSteps(clientProcess.PrimaryStepId);
                        primaryStepNo = primaryStep.StepNo;
                    }
                    else
                    {
                        throw new Exception("Invalid process step as parameter.");
                    }

                    string taskId = addTask(clientProcess, assignTo);
                    addClientProcess(clientProcess, assignTo, taskId);
                }
            }
            catch (Exception ex)
            {
                //log error
            }
        }
        private bool TryKillClient(int attempt = 0)
        {
            const int MAX_ATTEMPTS = 5;

            if (attempt == MAX_ATTEMPTS)
            {
                logger.Error($"Failed to kill client process within {MAX_ATTEMPTS} attempts!");

                return(false);
            }

            logger.Info($"Killing client process with ID = {ClientProcess.Id}.");
            ClientProcess.Kill();

            if (ClientProcess.HasTerminated)
            {
                logger.Info("Client process has terminated.");

                return(true);
            }
            else
            {
                logger.Warn("Failed to kill client process. Trying again...");

                return(TryKillClient(++attempt));
            }
        }
Пример #7
0
        private TaskCard getTaskCard(int AssignTo, ClientProcess clientProcess)
        {
            TaskCard taskCard = new TaskCard();

            taskCard.TaskId              = "OT";
            taskCard.ProjectId           = 3;
            taskCard.TransactionType     = "";
            taskCard.Type                = CardType.Task;
            taskCard.CustomerId          = 0;
            taskCard.Title               = getTaskTitleByProcessId(clientProcess.PrimaryStepId, clientProcess.LinkStepId);
            taskCard.Owner               = 1;
            taskCard.CreatedBy           = 1;
            taskCard.CreatedOn           = System.DateTime.Now.Date;
            taskCard.UpdatedBy           = taskCard.CreatedBy;
            taskCard.UpdatedByUserName   = "******";
            taskCard.UpdatedOn           = System.DateTime.Now.Date;
            taskCard.AssignTo            = AssignTo;
            taskCard.Priority            = Priority.High;
            taskCard.TaskStatus          = Common.Model.TaskManagement.TaskStatus.Backlog;
            taskCard.DueDate             = getDueDate(clientProcess);
            taskCard.CompletedPercentage = 0;
            taskCard.Description         = string.Format(DESCRIPTION, primaryStepNo, taskCard.Title);
            taskCard.MachineName         = System.Environment.MachineName;
            if (clientProcess.IsProcespectClient)
            {
                ProspectClient prospectClient = new ProspectClientService().GetById(clientProcess.ClientId);
                taskCard.OtherName = prospectClient.Name;
            }
            else
            {
                taskCard.CustomerId = clientProcess.ClientId;
            }
            return(taskCard);
        }
        private async Task InteropTestCase(string name)
        {
            using (var serverProcess = new WebsiteProcess(_serverPath, _output))
            {
                await serverProcess.WaitForReady().TimeoutAfter(DefaultTimeout);

                using (var clientProcess = new ClientProcess(_output, _clientPath, serverProcess.ServerPort, name))
                {
                    try
                    {
                        await clientProcess.WaitForReadyAsync().TimeoutAfter(DefaultTimeout);

                        await clientProcess.WaitForExitAsync().TimeoutAfter(DefaultTimeout);

                        Assert.Equal(0, clientProcess.ExitCode);
                    }
                    catch (Exception ex)
                    {
                        var clientOutput = clientProcess.GetOutput();
                        var errorMessage = $@"Error while running client process. Process output:
======================================
{clientOutput}";
                        throw new InvalidOperationException(errorMessage, ex);
                    }
                }
            }
        }
        private bool TryKillClient()
        {
            const int MAX_ATTEMPTS = 5;

            for (var attempt = 1; attempt <= MAX_ATTEMPTS; attempt++)
            {
                logger.Info($"Attempt {attempt}/{MAX_ATTEMPTS} to kill client process with ID = {ClientProcess.Id}.");

                if (ClientProcess.TryKill(500))
                {
                    break;
                }
            }

            if (ClientProcess.HasTerminated)
            {
                logger.Info("Client process has terminated.");
            }
            else
            {
                logger.Error($"Failed to kill client process within {MAX_ATTEMPTS} attempts!");
            }

            return(ClientProcess.HasTerminated);
        }
Пример #10
0
        public static void KillLastFromProfile(int profile)
        {
            ClientProcess last = null;

            foreach (ClientProcess clientProcess in Processes)
            {
                if (clientProcess.profile != profile)
                {
                    continue;
                }
                if (last == null)
                {
                    last = clientProcess;
                }
                if (clientProcess.timeOfCreation > last.timeOfCreation)
                {
                    last = clientProcess;
                }
            }

            if (last == null)
            {
                return;
            }
            last.StopProcess();
            Update();
        }
Пример #11
0
        // POST: Clients/Create
        public ActionResult Create(Client client)
        {
            var cp = new ClientProcess();

            cp.Insert(client);
            return(RedirectToAction("ProductList", "Product", new { area = "Products" }));
        }
Пример #12
0
        public void LogProcess(int id, uint pid)
        {
            ClientProcess process = ClientProcess.CreateClientProcess(id, pid);

            _context.AddToClientProcessContext(process);
            _context.SaveChanges();
        }
Пример #13
0
        // GET: Clients/Delete
        public ActionResult Delete(int id)
        {
            var cp = new ClientProcess();

            cp.Delete(id);
            return(RedirectToAction("Index"));
        }
Пример #14
0
        // GET: Clients/Details
        public ActionResult Details(int id)
        {
            var cp     = new ClientProcess();
            var client = cp.Find(id);

            return(View(client));
        }
Пример #15
0
        // GET: Clients/Edit
        public ActionResult Edit(int id)
        {
            var cp  = new ClientProcess();
            var cat = cp.Find(id);

            return(View(cat));
        }
Пример #16
0
        // GET: Order/Create
        public ActionResult Create()
        {
            var client = new ClientProcess().SelectList();

            ViewBag.Client = new SelectList(client, "Id", "FirstName");

            return(View());
        }
Пример #17
0
        private static void Main(string[] args)
        {
            var clientProcess = new ClientProcess();

            if (clientProcess.Deserialize())
            {
                Console.WriteLine("I'm called");

                // receive arguments from caller process
                var deserializer = clientProcess.Deserializer;

                var person1  = deserializer.GetArgument <Person>("person1");
                var person2  = deserializer.GetArgument <Person>(1);
                var myDog    = deserializer.GetArgument <Dog>("myDog");
                var myString = deserializer.GetArgument <string>(3);
                var myCode   = deserializer.GetArgument <int>(4);

                Console.WriteLine(person1);
                Console.WriteLine(person2);
                Console.WriteLine(myDog);
                Console.WriteLine(myString);
                Console.WriteLine(myCode);

                // communicate with caller process
                clientProcess.Transmitter.PrepareAsync().Wait();
                var message = clientProcess.Transmitter.Receive <string>();
                Console.WriteLine(message);
            }
            else
            {
                Console.WriteLine("I'm calling");

                ProcessExecutor executor = new ProcessExecutor("Example.exe");// execute itself

                // pass arguments while calling
                executor.Add("person1", new Person()
                {
                    Name = "tran xuan son", Age = 23
                });
                executor.Add(new Person()
                {
                    Name = "tran xuan soan", Age = 24
                });
                executor.Add("myDog", new Dog()
                {
                    CoatColor = "black", Type = "i don't know"
                });
                executor.Add("some string");
                executor.Add(3393);
                executor.Execute();

                // communicate with process that is called
                executor.Transmitter.PrepareAsync().Wait();
                executor.Transmitter.Send("ok, i am fine");
            }
            Console.Read();
        }
Пример #18
0
        // GET: Client/Edit/5
        public ActionResult Edit(int id)
        {
            var country = new CountryProcess().SelectList();

            ViewBag.Country = new SelectList(country, "Id", "Name", id);

            var cp = new ClientProcess();

            return(View(cp.findClient(id)));
        }
Пример #19
0
 public void Close()
 {
     BackgroundThreadContinue = false;
     BackgroundThread.Interrupt();
     BackgroundThread.Abort();
     BackgroundThread.Join();
     Send("Have a nice day!");
     ClientSocket.Close();
     ClientProcess.Close();
     OnExited(this);
 }
Пример #20
0
        // GET: Clients/Edit
        public ActionResult Edit(int id)
        {
            var cp  = new ClientProcess();
            var cat = cp.Find(id);

            var cp2   = new CountryProcess();
            var lista = cp2.SelectList();

            ViewData["Country"] = lista;

            return(View(cat));
        }
Пример #21
0
        // GET: Orders/Details
        public ActionResult Details(int id)
        {
            var op    = new OrderProcess();
            var order = op.Find(id);

            var cp         = new ClientProcess();
            var descClient = cp.Find(order.ClientId);

            ViewData["Client"] = descClient.FirstName + " " + descClient.LastName;

            return(View(order));
        }
Пример #22
0
        // GET: Clients/Details
        public ActionResult Details(int id)
        {
            var cp     = new ClientProcess();
            var client = cp.Find(id);

            var cp2         = new CountryProcess();
            var CountryName = cp2.Find(client.CountryId);

            ViewData["Country"] = CountryName.Name;

            return(View(client));
        }
Пример #23
0
        // GET: Clients/Client
        public ActionResult Index()
        {
            var cp    = new ClientProcess();
            var lista = cp.SelectList();

            var cp2          = new CountryProcess();
            var listaCountry = cp2.SelectList();

            ViewData["Country"] = listaCountry;

            return(View(lista));
        }
Пример #24
0
        // GET: Clients/Details
        public ActionResult Details(int id)
        {
            var cp     = new ClientProcess();
            var client = cp.Find(id);

            var cop         = new CountryProcess();
            var descCountry = cop.Find(client.CountryId);

            ViewData["Country"] = descCountry.Name;

            return(View(client));
        }
Пример #25
0
        public static void RegisterProcess(int pid, int profile)
        {
            ClientProcess process = new ClientProcess(pid, profile);

            if (process.Process == null)
            {
                return;
            }
            Processes.Add(process);
            Update();
            EditorUtility.SetDirty(GotoUdonInternalState.Instance);
        }
Пример #26
0
        public async Task StateChanged(ClientProcess clientProcess)
        {
            //TODO: Validate jobState
            if (clientProcess == null)
            {
                var ci = Context.GetClient(_options);
                _logger.LogError($"{nameof(clientProcess)} is null from {ci}");
                return;
            }

            await _swarmStore.AddOrUpdateClientProcess(clientProcess);
        }
Пример #27
0
        private string addTask(ClientProcess clientProcess, int AssignTo)
        {
            TaskCard    taskCard    = getTaskCard(AssignTo, clientProcess);
            TaskService taskService = new TaskService();

            taskService.Add(taskCard);
            System.Threading.Thread.Sleep(1000);
            int taskId = getTaskID(taskCard);

            DataBase.DBService.ExecuteCommandString(string.Format(UPDATE_TASKID, taskCard.TaskId + "-" + taskId, taskId), true);
            return(taskCard.TaskId + "-" + taskId);
        }
Пример #28
0
        public async Task InteropTestCase(string name)
        {
            await _fixture.EnsureStarted(_output).TimeoutAfter(DefaultTimeout);

            using (var clientProcess = new ClientProcess(_output, _clientPath, _fixture.ServerPort, name))
            {
                await clientProcess.WaitForReady().TimeoutAfter(DefaultTimeout);

                await clientProcess.Exited.TimeoutAfter(DefaultTimeout);

                Assert.Equal(0, clientProcess.ExitCode);
            }
        }
        public List <Client> ClientList()
        {
            var lista = _cacheServices.GetOrAdd(
                DataCacheSetting.Client.Key,
                () =>
            {
                var cp = new ClientProcess();
                return(cp.SelectList());
            },
                DataCacheSetting.Client.SlidingExpiration);

            return(lista);
        }
        public void ClientListRemove()
        {
            _cacheServices.Remove(DataCacheSetting.Client.Key);

            var lista = _cacheServices.GetOrAdd(
                DataCacheSetting.Client.Key,
                () =>
            {
                var cp = new ClientProcess();
                return(cp.SelectList());
            },
                DataCacheSetting.Client.SlidingExpiration);
        }
 public void AddToClientProcessContext(ClientProcess clientProcess)
 {
     base.AddObject("ClientProcessContext", clientProcess);
 }
 public static ClientProcess CreateClientProcess(long serverId, long pid)
 {
     ClientProcess clientProcess = new ClientProcess();
     clientProcess.ServerId = serverId;
     clientProcess.Pid = pid;
     return clientProcess;
 }