Ejemplo n.º 1
0
        public void UpdateMachineInfo(MachineInfo machineInfo)
        {

            lock (syncMachineInfoObject)
            {
                int count = machineInfolist.Count;
                bool searchmac = false;
                for (int i = 0; i < count; i++)
                {
                    if (machineInfolist[i].MachineName == machineInfo.MachineName)
                    {
                        searchmac = true;
                        machineInfolist[i].MachineInvokeInfos = machineInfo.MachineInvokeInfos;
                        int mivcount = machineInfo.MachineInvokeInfos.Count;
                        for (int j = 0; j < mivcount; j++)
                        {
                            ///TO DO....
                            if (machineInfo.MachineInvokeInfos[j].Status == MachineInvokeStatus.Completed)
                            {
                                ///log 
                                string logmessage = machineInfo.MachineName + " " + machineInfo.MachineInvokeInfos[j].TaskID + " " + machineInfo.MachineInvokeInfos[j].ActionName + " " +
                                    machineInfo.MachineInvokeInfos[j].ControllerName + " " + machineInfo.MachineInvokeInfos[j].Status + "\r\n";
                                File.AppendAllText(Environment.CurrentDirectory + @"\\Task.txt", logmessage);
                            }
                        }

                    }

                }
                if (!searchmac)
                {
                    machineInfolist.Add(machineInfo);
                }

            }

        }
Ejemplo n.º 2
0
        public void Start()
        {
            if (Repository == null)
            {
                Console.WriteLine("There is no TinctTask,Please arrange task! ");
                return;
            }

            Task t = new Task
            (
                () => { msp.tinctCon.StartMasterServer(masterPort); }
            );
            t.Start();

            Repository.EnqueTask += Repository_EnqueTask;
            while (true)
            {
                BaseTinctTask task = null;
                if (Repository.AvailableTinctTasksCount == 0)
                {
                    singal.WaitOne();
                    singal.Reset();
                }
                else
                {
                    task = Repository.AvailableTinctTask;
                }
                if (task == null)
                {
                    return;
                }



                task.Start((context) =>
                {
                    currentMachinename = msp.GetAvaiableMachineName(context.ControllerName, context.ActionName);
                    if (string.IsNullOrEmpty(currentMachinename))
                    {

                        updateMachinesingal = true;
                        currentControllerName = context.ControllerName;
                        currentActionName = context.ActionName;
                        macsingal.WaitOne();
                        macsingal.Reset();
                        updateMachinesingal = false;
                    }
                    context.MachineName = currentMachinename;
                    JsonSerializer serializer = new JsonSerializer();
                    using (StringWriter sw = new StringWriter())
                    {
                        serializer.Serialize(sw, context);
                        string message = sw.GetStringBuilder().ToString();

                        ///to do rewrite message

                        new Task(() => { msp.SendMessageToSlave(message, currentMachinename); }).Start();

                        MachineInfo machineInfo = new MachineInfo();
                        machineInfo.MachineName = currentMachinename;
                        machineInfo.MachineInvokeInfos.Add(new MachineInvokeInfo(task.ID, currentControllerName, currentActionName, MachineInvokeStatus.Running));
                        msp.UpdateMachineInfo(machineInfo);
                    }

                });


            }

        }