Exemplo n.º 1
0
        /// <summary>
        /// 获取任务状态
        /// </summary>
        /// <returns></returns>
        public string GetTaskNodeStatus(BsonDocument task, List <BsonDocument> designTasks, List <BsonDocument> sysTasks)
        {
            var taskstatus    = CommonTaskStatus.NotStarted;
            var curStatusName = EnumDescription.GetFieldText(taskstatus);

            switch (task.Int("nodeType"))
            {
            case (int)TaskNodeType.SelfDefinedTask:
            case (int)TaskNodeType.LastMonthUnfinishedTask:    //自定义与上个月未完成任务
                curStatusName = EnumDescription.GetFieldText((MonthlyTaskStatus)task.Int("taskStatus"));
                break;

            case (int)TaskNodeType.DesignTask:    //项目设计计划
                var designTask = designTasks.Where(c => c.String("taskId") == task.String("taskId")).FirstOrDefault();
                if (designTask != null)
                {
                    var curTaskStatus = designTask.Int("status", 2);
                    if (curTaskStatus < (int)TaskStatus.NotStarted)
                    {
                        curTaskStatus = (int)TaskStatus.NotStarted;
                    }
                    curStatusName = EnumDescription.GetFieldText((TaskStatus)curTaskStatus);
                    double delayDay = 0;
                    if (curTaskStatus < (int)TaskStatus.Completed && designTask.Date("curEndData") != DateTime.MinValue && designTask.Date("curEndData") < DateTime.Now)    //延迟结束
                    {
                        curTaskStatus = -1;
                        curStatusName = "已延迟";
                        delayDay      = (DateTime.Now - task.Date("curEndData")).TotalDays;
                    }
                }
                break;

            case (int)TaskNodeType.SystemTask:    //系统设计计划
                var sysTask = sysTasks.Where(c => c.String("systaskId") == task.String("systaskId")).FirstOrDefault();
                if (sysTask != null)
                {
                    curStatusName = EnumDescription.GetFieldText((SysTaskStatus)sysTask.Int("state"));
                }
                break;
            }
            return(curStatusName);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通过Id字段查找
        /// </summary>
        /// <param name="customerCode"></param>
        /// <returns></returns>
        public bool IsRunning(BsonDocument customer)
        {
            var isRunning = customer.Date("serviceActiveDate") > DateTime.Now.AddMinutes(-10);

            return(isRunning);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 转换操作数
        /// </summary>
        /// <param name="strOpnd"></param>
        /// <param name="result"></param>
        public void ConvertOpnd(ref string strOpnd, ref StringBuilder result)
        {
            if (!String.IsNullOrEmpty(strOpnd))
            {
                result.Append(" ");
                if (IsDouble(strOpnd))
                {
                    var opnd = Double.Parse(strOpnd);
                    result.Append(opnd);
                }
                else if (strOpnd.ToLower().StartsWith("s") || strOpnd.ToLower().StartsWith("e"))
                {
                    var readDateType = strOpnd.Substring(0, 1);
                    this.ReadDateType = readDateType;
                    var relTaskId = strOpnd.Substring(1);
                    var taskId    = 0;
                    if (Int32.TryParse(relTaskId, out taskId))
                    {
                        BsonDocument oriTask = null;
                        if (_taskList != null)
                        {
                            oriTask = _taskList.Where(c => c.Int("taskId") == taskId).FirstOrDefault();
                        }
                        else
                        {
                            oriTask = dataOp.FindOneByKeyVal("XH_DesignManage_Task", "taskId", taskId.ToString());
                        }
                        if (oriTask != null)
                        {
                            if (strOpnd.ToLower().StartsWith("s") && oriTask.Date("curStartData") != DateTime.MinValue)
                            {
                                date = oriTask.Date("curStartData");
                            }
                            if (strOpnd.ToLower().StartsWith("e") && oriTask.Date("curEndData") != DateTime.MinValue)
                            {
                                date = oriTask.Date("curEndData");
                            }
                            StrRelTaskId  += strOpnd + ",";
                            this.RelTaskId = taskId;
                        }
                    }
                    result.Append(0);
                }
                else if (strOpnd.ToLower().StartsWith("g"))
                {
                    var relTaskId = strOpnd.Substring(1);

                    var taskId = 0;
                    if (Int32.TryParse(relTaskId, out taskId))
                    {
                        BsonDocument oriTask = null;
                        if (_taskList != null)
                        {
                            oriTask = _taskList.Where(c => c.Int("taskId") == taskId).FirstOrDefault();
                        }
                        else
                        {
                            oriTask = dataOp.FindOneByKeyVal("XH_DesignManage_Task", "taskId", taskId.ToString());
                        }
                        if (oriTask != null)
                        {
                            result.Append(oriTask.String("period", "0"));

                            StrRelTaskId     += "G" + taskId + ",";
                            this.PeriodTaskId = taskId;
                        }
                    }
                }
                strOpnd = "";
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 获取日期值,无值则返回DateTime.MinValue
 /// </summary>
 /// <param name="bsonDoc"></param>
 /// <param name="name">字段名</param>
 /// <param name="formate">例如"yyyy-MM-dd"</param>
 /// <returns></returns>
 public static string DateFormat(this BsonDocument bsonDoc, string name, string formate)
 {
     return(bsonDoc.Date(name) != DateTime.MinValue ? bsonDoc.Date(name).ToString(formate) : "");
 }
Exemplo n.º 5
0
 /// <summary>
 /// 获取当前记录的创建人
 /// </summary>
 /// <returns></returns>
 public static string UpdateDate(this BsonDocument bsonDoc)
 {
     return(bsonDoc.Date("updateDate").ToString("yyyy-MM-dd"));
 }