Пример #1
0
        /// <summary>
        /// 解析公式
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="relTaskId"></param>
        /// <param name="formulaParam"></param>
        /// <returns></returns>
        public string PatchAnalysisFormula(int taskId, string formulaParam)
        {
            try
            {
                var strOperate = "";
                if (!String.IsNullOrEmpty(formulaParam))
                {
                    //var desTask = dataOp.FindOneByKeyVal("XH_DesignManage_Task", "taskId", taskId.ToString());
                    var desTask = taskList.Where(c => c.Int("taskId") == taskId).FirstOrDefault();
                    if (desTask != null)
                    {
                        var formulaObj = new FormulaObject(formulaParam.ToUpper());
                        formulaObj.taskList = taskList;
                        formulaObj.ConvertExp();
                        double   value        = formulaObj.CalcValue();
                        DateTime tempDateTime = formulaObj.date.HasValue ? formulaObj.date.Value : new DateTime(1900, 1, 1);
                        tempDateTime = tempDateTime.AddDays(value);
                        switch (formulaObj.OperDateType.ToLower())
                        {
                        case "s":
                            // dataOp.Update("XH_DesignManage_Task", "db.XH_DesignManage_Task.findOne({'taskId':'" + taskId + "'})", "curStartData=" + tempDateTime.ToString("yyyy-MM-dd"));
                            desTask.Set("curStartData", tempDateTime.ToString("yyyy-MM-dd"));
                            var updateValueBson = new BsonDocument();
                            updateValueBson.Add("curStartData", tempDateTime.ToString("yyyy-MM-dd"));
                            var udpateStartDate = new StorageData()
                            {
                                Document = updateValueBson, Type = StorageType.Update, Name = "XH_DesignManage_Task", Query = Query.EQ("taskId", taskId.ToString())
                            };
                            updateBsonStorage.Add(udpateStartDate);
                            break;

                        case "e":
                            //  dataOp.Update("XH_DesignManage_Task", "db.XH_DesignManage_Task.findOne({'taskId':'" + taskId + "'})", "curEndData=" + tempDateTime.ToString("yyyy-MM-dd"));
                            desTask.Set("curEndData", tempDateTime.ToString("yyyy-MM-dd"));
                            var updateBson = new BsonDocument();
                            updateBson.Add("curEndData", tempDateTime.ToString("yyyy-MM-dd"));
                            var udpateEndDate = new StorageData()
                            {
                                Document = updateBson, Type = StorageType.Update, Name = "XH_DesignManage_Task", Query = Query.EQ("taskId", taskId.ToString())
                            };
                            updateBsonStorage.Add(udpateEndDate);
                            break;
                        }
                        strOperate = formulaObj.OperDateType;
                    }
                }
                return(strOperate);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Пример #2
0
        /// <summary>
        /// 检查是否有闭环
        /// </summary>
        /// <param name="formulaObj"></param>
        /// <returns></returns>
        public bool IsClosedLoop(FormulaObject formulaObj)
        {
            List <string> strOperateList = new List <string>();

            CheckClosedLoop(formulaObj.OperDateType.ToString() + formulaObj.TaskId + ",", ref strOperateList);
            if (strOperateList.Contains(formulaObj.ReadDateType.ToString() + formulaObj.RelTaskId))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #3
0
        /// <summary>
        /// 递归检测循环
        /// </summary>
        /// <param name="strOperate"></param>
        /// <param name="strOperateList"></param>
        private void CheckClosedLoop(string strOperate, ref List <string> strOperateList)
        {
            List <BsonDocument> formulaList = dataOp.FindAll("XH_DesignManage_TaskFormula").Where(t => t.String("relTaskId").Contains(strOperate)).ToList();

            foreach (var formula in formulaList)
            {
                if (!String.IsNullOrEmpty(formula.String("formulaParam")))
                {
                    FormulaObject formulaObj = new FormulaObject(formula.String("formulaParam"));
                    formulaObj.ConvertExp();
                    if (!String.IsNullOrEmpty(formulaObj.OperDateType) && formulaObj.TaskId != 0)
                    {
                        strOperateList.Add(formulaObj.OperDateType + formulaObj.TaskId);
                        CheckClosedLoop(formulaObj.OperDateType.ToString() + formulaObj.TaskId + ",", ref strOperateList);
                    }
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 解析公式
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="relTaskId"></param>
        /// <param name="formulaParam"></param>
        /// <returns></returns>
        public string AnalysisFormula(int taskId, string formulaParam)
        {
            try
            {
                var strOperate = "";
                if (!String.IsNullOrEmpty(formulaParam))
                {
                    var desTask = dataOp.FindOneByKeyVal("XH_DesignManage_Task", "taskId", taskId.ToString());

                    if (desTask != null)
                    {
                        var formulaObj = new FormulaObject(formulaParam.ToUpper());
                        formulaObj.ConvertExp();
                        double   value        = formulaObj.CalcValue();
                        DateTime tempDateTime = formulaObj.date.HasValue ? formulaObj.date.Value : new DateTime(1900, 1, 1);
                        tempDateTime = tempDateTime.AddDays(value);
                        switch (formulaObj.OperDateType.ToLower())
                        {
                        case "s":
                            dataOp.Update("XH_DesignManage_Task", "db.XH_DesignManage_Task.findOne({'taskId':'" + taskId + "'})", "curStartData=" + tempDateTime.ToString("yyyy-MM-dd"));
                            break;

                        case "e":
                            dataOp.Update("XH_DesignManage_Task", "db.XH_DesignManage_Task.findOne({'taskId':'" + taskId + "'})", "curEndData=" + tempDateTime.ToString("yyyy-MM-dd"));
                            break;
                        }
                        strOperate = formulaObj.OperDateType;
                    }
                }
                return(strOperate);
            }
            catch (Exception ex)
            {
                return("");
            }
        }