예제 #1
0
        public static void Upload()
        {
            if (thrProcess != null)
            {
                return;
            }

            thrProcess = new Thread(() =>
            {
                try
                {
                    while (true)
                    {
                        DbAttachment f = new DbAttachment();
                        using (MDB mdb = new MDB())
                        {
                            f = mdb.Find <DbAttachment>(x => x.State == 0).FirstOrDefault();
                        }

                        if (f == null)
                        {
                            thrProcess = null;
                            return;
                        }

                        using (MDB mdb = new MDB())
                        {
                            f.State = 1;
                            mdb.UpdateOne <DbAttachment>(x => x.Id == f.Id, f);
                        }

                        YHFSClient client = new YHFSClient();
                        string log        = client.Upload(f.RemotePath, f.Path);

                        System.IO.File.AppendAllText("/wwwroot/maratonbus/log.log", log);

                        using (MDB mdb = new MDB())
                        {
                            f.State = 2;
                            mdb.UpdateOne <DbAttachment>(x => x.Id == f.Id, f);
                        }

                        System.IO.File.Delete(f.Path);
                    }
                }
                catch
                {
                    thrProcess = null;
                }
            });
            thrProcess.Start();
        }
예제 #2
0
        public Message.MessageTaskDeliverReply TaskDeliver(DbTask task, DbPipeline line)
        {
            var servants = ServantList();

            Message.MessageTaskDeliver td = new Message.MessageTaskDeliver();
            td.id         = task.Id;
            td.input      = task.Inputs;
            td.servants   = servants.Select(m => m.id).ToList();
            td.resources  = new List <string>();
            td.isParallel = line.IsParallel;
            td.originalID = td.id;
            td.pipeline   = (new Message.MessagePipeline()
            {
                id = line.Id,
                name = line.Name,
                pipes = new List <Message.MessagePipe>()
            });

            using (MDB db = new MDB())
            {
                for (int i = 0; i < line.PipeIds.Count; i++)
                {
                    var pipe = db.FindOne <DbPipe>(x => x.Id == line.PipeIds[i]);
                    var p    = new Message.MessagePipe()
                    {
                        id             = pipe.Id,
                        executor       = pipe.Executor,
                        multipleInput  = pipe.IsMultipleInput,
                        multipleThread = pipe.IsMultipleThread,
                        parameters     = pipe.Parameters,
                        name           = pipe.Name
                    };

                    td.pipeline.pipes.Add(p);
                }
            }

            var msg = PostData <Message.MessageTaskDeliverReply>("/task/deliver", Newtonsoft.Json.JsonConvert.SerializeObject(td));

            //sock.Send<Message.MessageTaskDeliver>(Message.MessageTaskDeliver.SerializeToBytes(td));
            //msg = sock.Receive() as Message.MessageTaskDeliverReply;
            //sock.Close();
            return(msg);
        }