Ejemplo n.º 1
0
 public void Run()
 {
     while (work)
     {
         //TaskDelegate task = GetTask();
         //task();
         GetTask()();
     }
 }
Ejemplo n.º 2
0
 private void Run()
 {
     while (work)
     {
         try
         {
             GetTask()();
         }
         catch (Exception exc)
         {
             Console.WriteLine(exc.Message);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 取回审批
        /// </summary>
        public void TackBackCheck()
        {
            GenerWorkFlow gwf = new GenerWorkFlow(this.WorkID);

            /* 判断是否有取回审批的权限。*/
            this.Pub2.AddEasyUiPanelInfoBegin("取回审批");
            string sql    = "SELECT NodeID FROM WF_Node WHERE CheckNodes LIKE '%" + gwf.FK_Node + "%'";
            int    myNode = DBAccess.RunSQLReturnValInt(sql, 0);

            if (myNode != 0)
            {
                GetTask gt = new GetTask(myNode);
                if (gt.Can_I_Do_It() == true)
                {
                    this.Pub2.Add("功能执行:<a href=\"javascript:Takeback('" + WorkID + "','" + FK_Flow + "','" + gwf.FK_Node + "','" + myNode + "')\" >点击执行取回审批流程</a>。");
                    this.Pub2.AddBR("说明:如果被成功取回,ccflow就会把停留在别人工作节点上的工作发送到您的待办列表里。");
                }
            }
            else
            {
                this.Pub2.Add("您没有此权限.");
            }
            this.Pub2.AddEasyUiPanelInfoEnd();
            Pub2.AddBR();
        }
Ejemplo n.º 4
0
        public async Task Run_ReturnsTaskOnSuccess()
        {
            var handler   = new Mock <IQueryHandler <GetTaskQuery, TaskDTO> >();
            var container = new Container();
            var logger    = new Mock <ILogger>().Object;
            var listid    = Guid.NewGuid().ToString();
            var taskid    = Guid.NewGuid().ToString();
            var request   = new DefaultHttpRequest(new DefaultHttpContext());

            handler.Setup(h => h.Execute(It.IsAny <GetTaskQuery>()))
            .ReturnsAsync(new TaskDTO {
                Id = taskid, Name = "name", Description = "description"
            });
            container.RegisterInstance(handler.Object);
            container.RegisterInstance(_telemetryClient);
            GetTask.Container = container;

            var result = await GetTask.Run(request, listid, taskid, logger) as OkObjectResult;

            Assert.IsNotNull(result);

            var value = result.Value as TaskDTO;

            Assert.IsNotNull(value);

            Assert.AreEqual(taskid, value.Id);
            Assert.AreEqual("name", value.Name);
            Assert.AreEqual("description", value.Description);
        }
Ejemplo n.º 5
0
        public void Test_GetBigFile()
        {
            GetTask getTask = new GetTask();

            getTask.Project = CreateEmptyProject();

            string source      = "http://www.tolvanen.com/eraser/eraser52.zip";
            string destination = Path.GetTempFileName() + ".zip";

            if (File.Exists(destination))
            {
                File.Delete(destination);
            }

            Assert.IsTrue(!File.Exists(destination), destination + " exists, but shouldn't");

            getTask.Source          = source;
            getTask.DestinationFile = new FileInfo(destination);
            getTask.UseTimeStamp    = true;
            getTask.Verbose         = true;
            getTask.Execute();

            Assert.IsTrue(File.Exists(destination), destination + " doesn't exist.");

            // cleanup
            if (File.Exists(destination))
            {
                File.Delete(destination);
            }

            Assert.IsTrue(!File.Exists(destination), destination + " exists, but shouldn't.");
        }
Ejemplo n.º 6
0
        public void Test_GetFtpFile()
        {
            GetTask getTask = new GetTask();

            getTask.Project   = CreateEmptyProject();
            getTask.HttpProxy = _proxy;

            string source      = "ftp://ftp.info-zip.org/pub/infozip/zlib/zlib.html";
            string destination = Path.GetTempFileName() + ".html";

            if (File.Exists(destination))
            {
                File.Delete(destination);
            }
            Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't.");

            getTask.Source          = source;
            getTask.DestinationFile = new FileInfo(destination);
            getTask.UseTimeStamp    = false;
            getTask.IgnoreErrors    = true;
            getTask.Verbose         = true;;
            try {
                getTask.Execute();
            } catch {
                // error is expected until FTP support is added
            }

            // after FTP support is added, do the assert
            //Assertion.Assert(destination + " should exist, but doesn't.", File.Exists(destination));
        }
Ejemplo n.º 7
0
        public void Test_GetHtmlFile()
        {
            GetTask getTask = new GetTask();

            getTask.Project   = CreateEmptyProject();
            getTask.HttpProxy = _proxy;

            string source      = "http://nant.sourceforge.net/index.html";
            string destination = Path.GetTempFileName() + ".gif";

            if (File.Exists(destination))
            {
                File.Delete(destination);
            }

            Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't.");

            getTask.Source          = source;
            getTask.DestinationFile = new FileInfo(destination);
            getTask.UseTimeStamp    = false;
            getTask.IgnoreErrors    = true;
            getTask.Verbose         = true;;
            getTask.Execute();

            Assert.IsTrue(File.Exists(destination), destination + " should exist, but doesn't.");

            // cleanup
            if (File.Exists(destination))
            {
                File.Delete(destination);
            }
            Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't.");
        }
Ejemplo n.º 8
0
        public List <GetTask> GetTask()
        {
            List <GetTask> myList = new List <GetTask>();

            var response = auth.service.Tasks.List("@default");
            var result   = response.Execute();
            var tasks    = result.Items;

            if (tasks != null && tasks.Count > 0)
            {
                foreach (Task t in tasks)
                {
                    GetTask a = new GetTask();
                    a.id      = t.Id;
                    a.title   = t.Title;
                    a.note    = t.Notes;
                    a.duedate = t.Due;
                    myList.Add(a);
                }
            }
            else
            {
                //return prompt about NO Tasks
            }
            return(myList);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 获取匹配数据
        /// </summary>
        /// <param name="key">关键字</param>
        /// <param name="dictionaryKey">字典关键字</param>
        /// <param name="nullValue">失败返回值</param>
        /// <returns>匹配数据</returns>
        public valueType Get(keyType key, dictionaryKeyType dictionaryKey, valueType nullValue)
        {
            GetTask task = new GetTask(this, key, dictionaryKey);

            counter.SqlTable.AddQueue(task);
            return(task.Wait() ?? nullValue);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets one message from a queue.
        /// </summary>
        /// <param name="QueueName">Name of queue.</param>
        /// <param name="TimeoutMilliseconds">Timeout, in milliseconds.</param>
        /// <returns>Message read, if received within the given time, null otherwise.</returns>
        public Task <string> GetOneAsync(string QueueName, int TimeoutMilliseconds)
        {
            GetTask Item = new GetTask(this, QueueName, TimeoutMilliseconds);

            MqTasks.ExecuteTask(Item);
            return(Item.Completed);
        }
Ejemplo n.º 11
0
        public GetTaskShould()
        {
            _storageQueueService = new Mock <IStorageQueueService>();
            var getTaskValidator = new Mock <IGetTaskValidator>();

            getTaskValidator.Setup(val => val.Validate(It.IsAny <TaskModel>())).Returns(true);
            _getTask = new GetTask(_storageQueueService.Object, getTaskValidator.Object);
        }
Ejemplo n.º 12
0
        public void GettersAndSetters_Invoked_StoreAndReturnData()
        {
            const CharacterAttribute Attribute       = CharacterAttribute.INT;
            const bool             ByHabitica        = true;
            const object           Challenge         = null;
            Guid                   ChallengeLeaderId = Guid.NewGuid();
            DateTime               CreatedAt         = DateTime.Now;
            const object           Group             = null;
            Guid                   Id        = Guid.NewGuid();
            const string           Notes     = "Notes";
            const double           Priority  = 1.0;
            IEnumerable <Reminder> Reminders = new List <Reminder>();
            var Tags = new List <Guid> {
                Guid.NewGuid(), Guid.NewGuid()
            };
            const string   Text      = "Text";
            const TaskType Type      = TaskType.Habit;
            DateTime       UpdatedAt = DateTime.Now;
            Guid           UserId    = Guid.NewGuid();
            const double   Value     = 350.0;

            var request = new GetTask
            {
                Attribute         = Attribute,
                ByHabitica        = ByHabitica,
                Challenge         = Challenge,
                ChallengeLeaderId = ChallengeLeaderId,
                CreatedAt         = CreatedAt,
                Group             = Group,
                Id        = Id,
                Notes     = Notes,
                Priority  = Priority,
                Reminders = Reminders,
                Tags      = Tags,
                Text      = Text,
                Type      = Type,
                UpdatedAt = UpdatedAt,
                UserId    = UserId,
                Value     = Value
            };

            Assert.Equal(Attribute, request.Attribute);
            Assert.Equal(ByHabitica, request.ByHabitica);
            Assert.Equal(Challenge, request.Challenge);
            Assert.Equal(ChallengeLeaderId, request.ChallengeLeaderId);
            Assert.Equal(CreatedAt, request.CreatedAt);
            Assert.Equal(Group, request.Group);
            Assert.Equal(Id, request.Id);
            Assert.Equal(Notes, request.Notes);
            Assert.Equal(Priority, request.Priority);
            Assert.Equal(Reminders, request.Reminders);
            Assert.Equal(Tags, request.Tags);
            Assert.Equal(Text, request.Text);
            Assert.Equal(Type, request.Type);
            Assert.Equal(UpdatedAt, request.UpdatedAt);
            Assert.Equal(UserId, request.UserId);
            Assert.Equal(Value, request.Value);
        }
Ejemplo n.º 13
0
        public void ChangeDelay(int minutes)
        {
            CheckTask();

            // recreate the trigger
            GetTask.Definition.Triggers.Clear();
            GetTask.Definition.Triggers.Add(GenerateLogonTrigger(minutes));
            GetTask.RegisterChanges();
        }
Ejemplo n.º 14
0
        public T GetObject()
        {
            if (objectStack.Count == 0)
            {
                CreateObject(1);
            }
            T instance = objectStack.Pop();

            GetTask?.Invoke(instance);
            return(instance);
        }
Ejemplo n.º 15
0
        public GetTask GetTask(string id)
        {
            var     response = auth.service.Tasks.Get("@default", id);
            var     result   = response.Execute();
            GetTask a        = new GetTask();

            a.title = result.Title;
            a.note  = result.Notes;


            return(a);
        }
Ejemplo n.º 16
0
        public string taskInsert([FromBody] GetTask _Task)
        {
            Task task = new Task {
                Title = _Task.title
            };

            task.Notes = _Task.note;
            task.Due   = System.DateTime.Today;

            var response = auth.service.Tasks.Insert(task, "@default");
            var result   = response.Execute();

            return("successfull inserted task");
        }
Ejemplo n.º 17
0
        public List <GetTask> GetTask(string taskid)
        {
            List <GetTask> mytask   = new List <GetTask>();
            var            response = auth.service.Tasks.Get("@default", taskid);
            var            result   = response.Execute();
            GetTask        a        = new GetTask();

            a.title = result.Title;
            a.note  = result.Notes;

            mytask.Add(a);

            return(mytask);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 缓存数据集合
 /// </summary>
 /// <param name="key">关键字</param>
 /// <returns>缓存数据集合</returns>
 public LeftArray <valueType> this[keyType key]
 {
     get
     {
         memberCacheType node = getTarget(key);
         if (node != null)
         {
             GetTask task = new GetTask(this, node, key);
             sqlTable.AddQueue(task);
             return(task.Wait());
         }
         return(default(LeftArray <valueType>));
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// 缓存数据
 /// </summary>
 /// <param name="key">关键字</param>
 /// <returns>缓存数据</returns>
 public cacheValueType this[keyType key]
 {
     get
     {
         memberCacheType node = getTarget(key);
         if (node != null)
         {
             GetTask task = new GetTask(this, node, key);
             sqlTable.AddQueue(task);
             return(task.Wait());
         }
         return(null);
     }
 }
Ejemplo n.º 20
0
        public void Test_Accessors()
        {
            GetTask getTask = new GetTask();

            getTask.Project = CreateEmptyProject();

            string proxy = _proxy;

            getTask.HttpProxy = proxy;
            Assert.IsTrue(getTask.HttpProxy == proxy, "Proxy accessor bug");

            string source = "http://nant.sourceforge.net/arrow.gif";

            getTask.Source = source;
            Assert.IsTrue(getTask.Source == source, "Source accessor bug");

            string destination = Path.GetTempFileName();

            getTask.DestinationFile = new FileInfo(destination);

            bool ignoreErrors = true;

            getTask.IgnoreErrors = ignoreErrors;
            Assert.IsTrue(getTask.IgnoreErrors == ignoreErrors, "ignoreErrors=true accessor bug");

            ignoreErrors         = false;
            getTask.IgnoreErrors = ignoreErrors;
            Assert.IsTrue(getTask.IgnoreErrors == ignoreErrors, "ignoreErrors=false accessor bug");

            bool useTimeStamp = true;

            getTask.UseTimeStamp = useTimeStamp;
            Assert.IsTrue(getTask.UseTimeStamp == useTimeStamp, "useTimeStamp=true accessor bug");

            useTimeStamp         = false;
            getTask.UseTimeStamp = useTimeStamp;
            Assert.IsTrue(getTask.UseTimeStamp == useTimeStamp, "useTimeStamp=false accessor bug");

            bool verbose = true;

            getTask.Verbose = verbose;
            Assert.IsTrue(getTask.Verbose == verbose, "Verbose=true accessor bug");

            verbose         = false;
            getTask.Verbose = verbose;
            Assert.IsTrue(getTask.Verbose == verbose, "Verbose=false accessor bug");
        }
Ejemplo n.º 21
0
        public override bool TakeAction()
        {
            UserDailyQuestData dailyQuest = GetTask.FindTask(id);

            if (dailyQuest.Status != TaskStatus.Finished)
            {
                return(false);
            }
            var taskcfg = new ShareCacheStruct <Config_Task>().FindKey(id);

            if (taskcfg == null)
            {
                new BaseLog().SaveLog(string.Format("查找每日任务ID出错 ID={0}", id));
                return(false);
            }

            dailyQuest.Status = TaskStatus.Received;
            GetTask.Liveness += taskcfg.Liveness;

            switch (taskcfg.RewardsType)
            {
            case TaskAwardType.Gold:
            {
                BigInteger bi    = BigInteger.Parse(taskcfg.RewardsNum);
                BigInteger value = Math.Ceiling(GetBasis.UserLv / 50.0).ToInt() * bi;
                UserHelper.RewardsGold(Current.UserId, value, UpdateCoinOperate.NormalReward, true);
            }
            break;

            case TaskAwardType.Diamond:
            {
                UserHelper.RewardsDiamond(Current.UserId, Convert.ToInt32(taskcfg.RewardsNum));
            }
            break;

            case TaskAwardType.Item:
            {
                var lotteryGem = UserHelper.RandomLotteryGem();
                UserHelper.RewardsItem(Current.UserId, lotteryGem.ID, 1);
            }
            break;
            }
            receipt = true;
            return(true);
        }
Ejemplo n.º 22
0
        public async Task Run_ReturnsErrorOnServerError()
        {
            var handler   = new Mock <IQueryHandler <GetTaskQuery, TaskDTO> >();
            var container = new Container();
            var logger    = new Mock <ILogger>().Object;
            var listid    = Guid.NewGuid().ToString();
            var taskid    = Guid.NewGuid().ToString();
            var request   = new DefaultHttpRequest(new DefaultHttpContext());

            handler.Setup(h => h.Execute(It.IsAny <GetTaskQuery>()))
            .ThrowsAsync(new Exception());
            container.RegisterInstance(handler.Object);
            container.RegisterInstance(_telemetryClient);
            GetTask.Container = container;

            var result = await GetTask.Run(request, listid, taskid, logger) as InternalServerErrorResult;

            Assert.IsNotNull(result);
        }
Ejemplo n.º 23
0
        void btn_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (btn.ID == "Btn_Cancel")
            {
                this.WinClose();
                return;
            }

            BP.WF.GetTasks jcs = new GetTasks();
            jcs.Retrieve(NodeAttr.FK_Flow, this.RefNo);

            string strs = "";

            foreach (GetTask jc in jcs)
            {
                if (jc.Step == 1)
                {
                    continue;
                }

                if (this.Pub1.GetCBByID("CB_" + jc.NodeID).Checked == false)
                {
                    continue;
                }

                strs += "'" + jc.NodeID + "',";
            }

            if (strs.Length == 0)
            {
                this.Alert("您没有设置可以跳转审核的节点。");
                return;
            }
            strs = strs.Substring(0, strs.Length - 1);
            GetTask myjc = new GetTask(this.FK_Node);

            myjc.CheckNodes = strs;
            myjc.Update();
            this.WinCloseWithMsg("保存成功...");
        }
Ejemplo n.º 24
0
        public IActionResult AddTask([FromBody] GetTask t)
        {
            Task task = new Task();

            task.EventName    = t.EventName;
            task.EndDate      = t.EndDate;
            task.StartDate    = t.StartDate;
            task.Status       = t.Status;
            task.TaskName     = t.TaskName;
            task.Description  = t.Description;
            task.BudgetedCost = t.BudgetedCost;
            task.AddDate      = t.AddDate;


            int taskid = _service.AddTask(task);

            if (taskid != 0)

            {
                EmployeeTask eTask = new EmployeeTask();
                //eTask.EmpId = t.Employees[0];
                int x = 0;
                foreach (var i in t.Employees)
                {
                    // int x = Int32.Parse(i);
                    eTask.EId    = t.Employees[x];
                    eTask.TaskId = taskid;
                    _service.AddEmployeeTask(eTask);
                    x++;
                }


                return(Ok(t));
            }
            else
            {
                return(BadRequest("error"));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// checks the task if the execution path is up2date (because the application should be portable)
        /// </summary>
        public void CheckTask()
        {
            if (GetTask.Definition.Actions.Count != 1 || GetTask.Definition.Triggers.Count != 1)
            {
                // no idea what happened - recreate the task
                Logging.WriteLine("Task is no longer valid. Removing the complete task and readding it.");
                TaskService.Instance.RootFolder.DeleteTask(GetTask.Name);
                CreateTask();
            }

            // check action
            ExecAction ea = (ExecAction)GetTask.Definition.Actions.First();

            if (!ea.Path.Equals(Application.ExecutablePath))
            {
                // need to update the current task path
                Logging.WriteLine("Task action path does not match current path - updating action path.");
                ea.Path             = Application.ExecutablePath;
                ea.WorkingDirectory = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
                GetTask.RegisterChanges();
            }
        }
Ejemplo n.º 26
0
        public List <Tasks> GetTasks(GetTask getTasksModel)
        {
            List <Tasks> results = null;

            try
            {
                var statusId = (from s in _context.Status
                                where s.StatusName == getTasksModel.Status
                                select s.StatusId).FirstOrDefault();

                results = (from t in _context.Tasks
                           where t.UserId == getTasksModel.userId &&
                           t.TaskDate == getTasksModel.TaskDate &&
                           t.StatusId == statusId
                           select t).ToList();
                return(results);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 27
0
        public IHttpActionResult gettask(int id, string state)
        {
            try
            {
                DataTable      taskData = DataManager.gettask(id, state);
                List <GetTask> taskList = new List <GetTask>();
                foreach (DataRow tdata in taskData.Rows)
                {
                    GetTask objGetTask = new GetTask();
                    objGetTask.tid     = Convert.ToInt32(tdata["tid"]);
                    objGetTask.title   = tdata["title"].ToString();
                    objGetTask.img_url = tdata["img_url"].ToString();
                    objGetTask.status  = tdata["status"].ToString();
                    taskList.Add(objGetTask);
                }

                return(Ok(taskList));

                /*var listOfGettask = new List<GetTask>();
                 * while (reader.Read())
                 * {
                 *  var Task = new GetTask();
                 *  Task.title = ;
                 *  Task.img_url = ;
                 *  Task.status = ;
                 *
                 *  listOfGettask.Add(Task);
                 * }
                 * return listOfGettask;
                 *
                 * return Ok(listOfGettask);
                 *
                 */
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Ejemplo n.º 28
0
 public override bool TakeAction()
 {
     receipt = GetTask.FindTask(type);
     return(true);
 }
Ejemplo n.º 29
0
        /// <summary>
        /// 获取可操作状态信息
        /// </summary>
        /// <returns></returns>
        public string OP_GetStatus()
        {
            GenerWorkFlow gwf = new GenerWorkFlow(this.WorkID);

            Hashtable ht = new Hashtable();

            string json = "{";
            bool   isCan;

            #region 文件打印的权限判断,这里为天业集团做的特殊判断,现实的应用中,都可以打印.
            bool CanPackUp = false;
            if (SystemConfig.CustomerNo == "TianYe")
            {
                bool isAdmin = false;
                if (BP.Web.WebUser.No == "admin")
                {
                    isAdmin = true;
                }

                //  if (BP.Web.WebUser.No == "admin" || BP.Web.WebUser.IsAdmin == true)

                // 判断是否可以打印.
                //string sql = "SELECT NDFrom,NDFromT,EmpFrom FROM ND" + int.Parse(this.FK_Flow) + "Track WHERE WorkID=" + this.WorkID + " AND (EmpFrom='" + BP.Web.WebUser.No + "' OR  EmpTo='" + BP.Web.WebUser.No + "')  ";
                string    sql = "SELECT Distinct NDFrom, EmpFrom FROM ND" + int.Parse(this.FK_Flow) + "Track WHERE WorkID=" + this.WorkID;
                DataTable dt  = DBAccess.RunSQLReturnTable(sql);
                foreach (DataRow dr in dt.Rows)
                {
                    //判断节点是否启用了按钮?
                    int    nodeid = int.Parse(dr[0].ToString());
                    BtnLab btn    = new BtnLab(nodeid);
                    if (btn.PrintPDFEnable == true || btn.PrintZipEnable == true)
                    {
                        string empFrom = dr[1].ToString();
                        if (isAdmin == true || BP.Web.WebUser.No == empFrom || gwf.Starter == WebUser.No)
                        {
                            CanPackUp = true;
                            break;
                        }
                    }
                }
            }
            else
            {
                CanPackUp = true;
            }
            #endregion 文件打印的权限判断,这里为天业集团做的特殊判断,现实的应用中,都可以打印.

            ht.Add("CanPackUp", CanPackUp.ToString().ToLower());

            //是否可以打印.
            switch (gwf.WFState)
            {
            case WFState.Runing:     /* 运行时*/
                /*删除流程.*/
                isCan = BP.WF.Dev2Interface.Flow_IsCanDeleteFlowInstance(this.FK_Flow, this.WorkID, WebUser.No);

                ht.Add("CanFlowOverByCoercion", isCan.ToString().ToLower());

                /*取回审批*/
                isCan = false;
                string para   = "";
                string sql    = "SELECT NodeID FROM WF_Node WHERE CheckNodes LIKE '%" + gwf.FK_Node + "%'";
                int    myNode = DBAccess.RunSQLReturnValInt(sql, 0);

                if (myNode != 0)
                {
                    GetTask gt = new GetTask(myNode);
                    if (gt.Can_I_Do_It())
                    {
                        isCan = true;

                        ht.Add("TackBackFromNode", gwf.FK_Node);
                        ht.Add("TackBackToNode", myNode);
                    }
                }

                ht.Add("CanTackBack", isCan.ToString().ToLower());



                /*撤销发送*/
                GenerWorkerLists workerlists = new GenerWorkerLists();
                QueryObject      info        = new QueryObject(workerlists);
                info.AddWhere(GenerWorkerListAttr.FK_Emp, WebUser.No);
                info.addAnd();
                info.AddWhere(GenerWorkerListAttr.IsPass, "1");
                info.addAnd();
                info.AddWhere(GenerWorkerListAttr.IsEnable, "1");
                info.addAnd();
                info.AddWhere(GenerWorkerListAttr.WorkID, this.WorkID);
                isCan = info.DoQuery() > 0;
                ht.Add("CanUnSend", isCan.ToString().ToLower());
                break;

            case WFState.Complete:   // 完成.
            case WFState.Delete:     // 逻辑删除..
                /*恢复使用流程*/
                isCan = WebUser.No == "admin";
                ht.Add("CanRollBack", isCan.ToString().ToLower());
                //判断是否可以打印.
                break;

            case WFState.HungUp:     // 挂起.
                /*撤销挂起*/
                isCan = BP.WF.Dev2Interface.Flow_IsCanDoCurrentWork(FK_Flow, FK_Node, WorkID, WebUser.No);

                ht.Add("CanUnHungUp", isCan.ToString().ToLower());
                break;

            default:
                break;
            }

            return(BP.Tools.Json.ToJson(ht));

            //return json + "}";
        }
Ejemplo n.º 30
0
        public void Setup()
        {
            //create base folder for "project"'s local copy
            _workingFolder = Path.Combine(Path.GetTempPath(), "FROM_VSS");
            Directory.CreateDirectory(_workingFolder);

            //This item represents the base project item
            _project      = new MockVssItem();
            _project.Name = "TEMPVSSPROJECT";
            _project.SetType((int)VSSItemType.VSSITEM_PROJECT);
            string localProjectPath = _workingFolder;

            Directory.CreateDirectory(localProjectPath);

            //a normal file item whose local copy is in the project's local folder;
            _normalItem      = new MockVssItem();
            _normalItem.Name = "normalItem.txt";
            _normalItem.SetType((int)VSSItemType.VSSITEM_FILE);
            _normalItem.Deleted  = false;
            _localNormalItemPath = Path.Combine(localProjectPath, _normalItem.Name);
            StreamWriter s = File.CreateText(_localNormalItemPath);

            s.Close();

            //a deleted file item that represents an earlier, deleted version of the normal file item
            _normalItemDeleted      = new MockVssItem();
            _normalItemDeleted.Name = "normalItem.txt";
            _normalItemDeleted.SetType((int)VSSItemType.VSSITEM_FILE);
            _normalItemDeleted.Deleted = true;

            //a deleted file item whose local copy is located under the base project's local folder
            _item      = new MockVssItem();
            _item.Name = "tempVSSItem.txt";
            _item.SetType((int)VSSItemType.VSSITEM_FILE);
            _item.Deleted  = true;
            _localItemPath = Path.Combine(localProjectPath, _item.Name);
            s = File.CreateText(_localItemPath);
            s.Close();

            //a deleted file item with *no* local copy
            _alreadyGoneItem      = new MockVssItem();
            _alreadyGoneItem.Name = "notthere.txt";
            _alreadyGoneItem.SetType((int)VSSItemType.VSSITEM_FILE);
            _alreadyGoneItem.Deleted = true;

            //a deleted file item whose local copy is located under the base project's local folder and read-only
            _readOnlyItem      = new MockVssItem();
            _readOnlyItem.Name = "readOnlyTempVSSItem.txt";
            _readOnlyItem.SetType((int)VSSItemType.VSSITEM_FILE);
            _readOnlyItem.Deleted  = true;
            _localReadOnlyItemPath = Path.Combine(localProjectPath, _readOnlyItem.Name);
            s = File.CreateText(_localReadOnlyItemPath);
            s.Close();
            File.SetAttributes(_localReadOnlyItemPath, FileAttributes.ReadOnly);

            //a deleted project item whose local copy is located under the base project's local folder and read-only
            _readOnlySubProject      = new MockVssItem();
            _readOnlySubProject.Name = "READONLYSUBPROJECT";
            _readOnlySubProject.SetType((int)VSSItemType.VSSITEM_PROJECT);
            _readOnlySubProject.Deleted  = true;
            _localReadOnlySubProjectPath = Path.Combine(localProjectPath, _readOnlySubProject.Name);
            Directory.CreateDirectory(_localReadOnlySubProjectPath);
            File.SetAttributes(_localReadOnlySubProjectPath, FileAttributes.ReadOnly);

            //a deleted file item whose local copy is located under the read-only sub project's local folder
            //is itself read-only
            _readOnlySubItem      = new MockVssItem();
            _readOnlySubItem.Name = "readOnlySubItem.txt";
            _readOnlySubItem.SetType((int)VSSItemType.VSSITEM_FILE);
            _readOnlySubItem.Deleted  = true;
            _localReadOnlySubItemPath = Path.Combine(_localReadOnlySubProjectPath, _readOnlySubItem.Name);
            s = File.CreateText(_localReadOnlySubItemPath);
            s.Close();
            File.SetAttributes(_localReadOnlySubItemPath, FileAttributes.ReadOnly);

            //a deleted project item whose local copy is in the base project's local folder
            _subProject      = new MockVssItem();
            _subProject.Name = "SUBPROJECT";
            _subProject.SetType((int)VSSItemType.VSSITEM_PROJECT);
            _subProject.Deleted  = true;
            _localSubProjectPath = Path.Combine(localProjectPath, _subProject.Name);
            Directory.CreateDirectory(_localSubProjectPath);

            //a deleted file item whose local copy is in the sub-project's local folder
            _subItem      = new MockVssItem();
            _subItem.Name = "tempVSSSubItem.txt";
            _subItem.SetType((int)VSSItemType.VSSITEM_FILE);
            _subItem.Deleted  = true;
            _localSubItemPath = Path.Combine(_localSubProjectPath, _subItem.Name);
            s = File.CreateText(_localSubItemPath);
            s.Close();

            //add the sub file item to the sub project's items collection
            MockVssItems items = new MockVssItems();

            items.Add(_subItem);
            _subProject.SetItems(items);

            //add the read-only sub file item to read-only sub-project's items collection
            items = new MockVssItems();
            items.Add(_readOnlySubItem);
            _readOnlySubProject.SetItems(items);

            //create the instance of the GetTask that we will use in the tests
            _getTask               = new GetTask();
            _getTask.Item          = _project;
            _getTask.LocalPath     = new DirectoryInfo(_workingFolder);
            _getTask.RemoveDeleted = true;

            //make the GetTask happy by giving it a dummy project file to reference
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<project name='test'/>");
            _getTask.Project = new Project(doc, Level.Info, 0);
        }