Exemplo n.º 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("");
            }
        }
Exemplo n.º 2
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("");
            }
        }