예제 #1
0
        public IActionResult StartTask()
        {
            TinctTaskRepository q = new TinctTaskRepository();
            var mloggname         = "Masterlogger";
            var mfilename         = "Log4net.config";

            TinctTaskService.StartMasterService();


            Thread.Sleep(2000);
            TinctTaskService.StartTaskService(q, mloggname, mfilename);

            TinctTask t1 = new TinctTask();

            t1.Name          = "test";
            t1.DllName       = "Tinct.PlatformController";
            t1.NamespaceName = "Tinct.PlatformController";
            t1.ClassName     = "TinctTestController";
            t1.MethodName    = "LoadData1";
            t1.Datas         = "test";
            Thread.Sleep(1000);
            TinctTask t2 = new TinctTask();

            t2.Name          = "test";
            t2.DllName       = "Tinct.PlatformController";
            t2.NamespaceName = "Tinct.PlatformController";
            t2.ClassName     = "TinctTest1Controller";
            t2.MethodName    = "LoadData1";
            t2.Datas         = "test";

            q.QueueTinctTask(t1);
            q.QueueTinctTask(t2);

            return(View("Index"));
        }
예제 #2
0
        private void ReturnCommand(MessageBody messageBody)
        {
            var task = TinctTask.GetObjectBySerializeString(messageBody.Datas);

            TinctTaskRepository.Current.UpdateRunningTask(task);
            TinctTaskRepository.Current.UpdateWaittingTask(task);
        }
예제 #3
0
        private TinctMessage BuildTaskMessage(TinctTask tinctTask, CommandType type)
        {
            TinctMessage tmsg = new TinctMessage();

            tmsg.MessageHeader = new MessageHeader()
            {
                CommandType = type
            };
            tmsg.MessageBody       = new MessageBody();
            tmsg.MessageBody.Datas = tinctTask.ToJsonSerializeString();
            return(tmsg);
        }
예제 #4
0
        public IActionResult CreateTask()
        {
            TinctTask t = new TinctTask();

            t.Name          = Request.Form["Name"];
            t.Datas         = Request.Form["Data"];
            t.DllName       = Request.Form["DllName"];
            t.ClassName     = Request.Form["ClassName"];
            t.NamespaceName = Request.Form["NamespaceName"];
            t.MethodName    = Request.Form["MethodName"];

            TinctTaskRepository.Current.QueueTinctTask(t);
            return(View("Index"));
        }
예제 #5
0
        public void RunFileTask()
        {
            TinctTaskRepository q = new TinctTaskRepository();
            var mloggname         = "Masterlogger";
            var mfilename         = "Log4net.config";
            var slogname          = "Slavelogger";

            TinctTaskService.StartMasterService();

            Thread.Sleep(2000);
            TinctTaskService.StartSlaveService(slogname, mfilename);
            Thread.Sleep(2000);
            TinctTaskService.StartTaskService(q, mloggname, mfilename);


            TinctTask t1 = new TinctTask();

            t1.Name          = "test";
            t1.DllName       = "Tinct.PlatformController";
            t1.NamespaceName = "Tinct.PlatformController";
            t1.ClassName     = "TinctTestController";
            t1.MethodName    = "LoadData1";
            t1.Datas         = "test";

            q.QueueTinctTask(t1);

            FileTask file = new FileTask();

            file.FileName   = "Tinct.PlatformController.dll";
            file.SourcePath = "test.txt";
            file.Content    = new List <byte>();


            Thread.Sleep(10000);

            TinctTaskService.DeployFile(file);
            //TinctMessage msg = new TinctMessage();
            //msg.MessageHeader = new MessageHeader();
            //msg.MessageHeader.CommandType = CommandType.Deploy;
            //msg.MessageBody = new MessageBody();
            //msg.MessageBody.Datas = file.ToJsonSerializeString();
            //TinctMasterNode.Current.SendMessage(TinctNodeCongratulations.MasterName, msg);

            Console.Read();
        }
예제 #6
0
        public void StartTest()
        {
            TinctTaskRepository q = new TinctTaskRepository();
            var mloggname         = "Masterlogger";
            var mfilename         = "Log4net.config";
            var slogname          = "Slavelogger";

            TinctTaskService.StartMasterService();

            Thread.Sleep(2000);
            TinctTaskService.StartSlaveService(slogname, mfilename);
            Thread.Sleep(2000);
            TinctTaskService.StartTaskService(q, mloggname, mfilename);



            TinctTask t1 = new TinctTask();

            t1.Name          = "test";
            t1.DllName       = "Tinct.PlatformController";
            t1.NamespaceName = "Tinct.PlatformController";
            t1.ClassName     = "TinctTestController";
            t1.MethodName    = "LoadData1";
            t1.Datas         = "test";

            TinctTask t2 = new TinctTask();

            t2.Name          = "test";
            t2.DllName       = "Tinct.PlatformController";
            t2.NamespaceName = "Tinct.PlatformController";
            t2.ClassName     = "TinctTest1Controller";
            t2.MethodName    = "LoadData1";
            t2.Datas         = "test";

            q.QueueTinctTask(t1);
            q.QueueTinctTask(t2);


            Thread.Sleep(12000);



            Assert.IsTrue(t2.Status == TinctTaskStatus.Completed);
        }
예제 #7
0
        static void Main(string[] args)
        {
            TinctTaskRepository q = new TinctTaskRepository();
            var mloggname         = "Masterlogger";
            var mfilename         = "Log4net.config";

            TinctTaskService.StartMasterService();

            //Thread.Sleep(2000);
            //TinctTaskService.StartSlaveService(slogname, mfilename);
            Thread.Sleep(2000);
            TinctTaskService.StartTaskService(q, mloggname, mfilename);



            TinctTask t1 = new TinctTask();

            t1.Name          = "test";
            t1.DllName       = "Tinct.PlatformController";
            t1.NamespaceName = "Tinct.PlatformController";
            t1.ClassName     = "TinctTestController";
            t1.MethodName    = "LoadData1";
            t1.Datas         = "test";

            TinctTask t2 = new TinctTask();

            t2.Name          = "test";
            t2.DllName       = "Tinct.PlatformController";
            t2.NamespaceName = "Tinct.PlatformController";
            t2.ClassName     = "TinctTest1Controller";
            t2.MethodName    = "LoadData1";
            t2.Datas         = "test";

            q.QueueTinctTask(t1);
            q.QueueTinctTask(t2);

            Console.Read();
        }
예제 #8
0
        public void ExuteTask(string datas, string loggerName, string loggerFileName)
        {
            var logger = TinctLoggerManger.GetLogger(loggerName, loggerFileName);
            var task   = TinctTask.GetObjectBySerializeString(datas);

            if (logger != null)
            {
                logger.LogMessage(task.ToJsonSerializeString());
            }
            AssemblyExcuteEnvironment.Current.AppDomainDicts.TryGetValue(task.ClassName + "\\" + task.MethodName, out AppDomain runTimeActionDomain);
            if (runTimeActionDomain == null)
            {
                runTimeActionDomain = AppDomain.CreateDomain(task.ClassName + "\\" + task.MethodName, AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
                AssemblyExcuteEnvironment.Current.AppDomainDicts.TryAdd(runTimeActionDomain.FriendlyName, runTimeActionDomain);
            }
            try
            {
                dynamic controler = runTimeActionDomain.CreateInstanceFrom(task.DllName + ".dll", task.NamespaceName + "." + task.ClassName).Unwrap();

                MethodInfo method         = controler.GetType().GetMethod(task.MethodName);
                int        parametercount = method.GetParameters().Count();
                if (parametercount == 0)
                {
                    method.Invoke(controler, null);
                }
                else
                {
                    method.Invoke(controler, new object[] { task.Datas });
                }

                task.Status = TinctTaskStatus.Completed;
            }
            catch (AppDomainUnloadedException e)
            {
                Console.WriteLine(e);
                //log
                task.Status = TinctTaskStatus.Exception;

                task.Exption         = e;
                task.HasException    = true;
                task.ExceptionString = e.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                //log
                task.Status          = TinctTaskStatus.Exception;
                task.Exption         = e;
                task.HasException    = true;
                task.ExceptionString = e.ToString();
            }

            AssemblyExcuteEnvironment.Current.UnloadDomain(runTimeActionDomain.FriendlyName);
            task.EndTime = DateTimeExtension.GetTimeStamp();
            if (logger != null)
            {
                logger.LogMessage(task.ToJsonSerializeString());
            }
            TinctMessage message = new TinctMessage();

            message.MessageHeader = new MessageHeader()
            {
                CommandType = CommandType.Return
            };
            MessageBody body = new MessageBody();

            body.Datas          = task.ToJsonSerializeString();
            message.MessageBody = body;

            TinctSlaveNode.Current.SendMessage(TinctNodeCongratulations.MasterName, message);
        }