예제 #1
0
        /// <summary>
        /// 获取PNode集合并为其设置WBSCode编码
        /// 2017/05/08(zhuguanjun)
        /// </summary>
        /// <param name="ProjectID">项目ID</param>
        /// <returns></returns>
        public List <PNode> SetWBSNo(string ProjectID)
        {
            int step = 0;//层级

            List <PNode>        listNode   = new WBSBLL().GetNodes(ProjectID, null);
            IEnumerable <PNode> parentNode = null;

            parentNode = listNode.Where(t => string.IsNullOrEmpty(t.ParentID)).OrderBy(t => t.No);

            DataTable dt = GetWBSCodeList(ProjectID);                                                                            //WBSCode集合

            DomainDLL.WBSCode[] wbscodeArray = JsonHelper.TableToList <DomainDLL.WBSCode>(dt).OrderBy(t => t.CREATED).ToArray(); //dt转array

            if (wbscodeArray == null || wbscodeArray.Count() == 0)
            {
                return(null);
            }
            foreach (PNode parent in parentNode)
            {
                DomainDLL.WBSCode wc    = wbscodeArray[step];
                byte[]            array = SetStepNo(wc.LengthName, wc.Orderr, parent.No);
                parent.WBSNo = Ascii2Str(array) + wc.BreakName;
                SetChildWBSNo(listNode, parent, step, wbscodeArray);
            }
            return(listNode);
        }
예제 #2
0
        /// <summary>
        /// 日常工作保存
        /// Created:20170601(zhuguanjun)
        /// Updated:20170605(ChengMengjia) 添加作为节点插入
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="listWork"></param>
        /// <returns></returns>
        public JsonResult SaveRoutine(string ProjectID, Routine entity, List <RoutineWork> listWork)
        {
            JsonResult jsonreslut = new JsonResult();

            try
            {
                //如果是新增
                if (string.IsNullOrEmpty(entity.ID))
                {
                    #region 新增WBS节点
                    PNode node = null;
                    if (!string.IsNullOrEmpty(entity.NodeID))
                    {
                        node          = new PNode();
                        node.ID       = Guid.NewGuid().ToString() + "-1";
                        node.Name     = entity.Name;
                        node.ParentID = entity.NodeID.Substring(0, 36);
                        node.PID      = ProjectID;
                        node.PType    = 2;
                        node.Status   = 1;
                        node.CREATED  = DateTime.Now;
                    }
                    #endregion
                    #region 新插入实体
                    entity.NodeID  = node == null ? null : node.ID.Substring(0, 36);
                    entity.ID      = Guid.NewGuid().ToString() + "-1";
                    entity.CREATED = DateTime.Now;
                    entity.Status  = 1;
                    #endregion
                    dao.AddRoutine(entity, node, listWork);
                    jsonreslut.data = entity.ID;
                }
                //编辑
                else
                {
                    #region 更新实体
                    Routine oldEntity = new Repository <Routine>().Get(entity.ID);
                    oldEntity.Status  = 0;
                    oldEntity.UPDATED = DateTime.Now;
                    #endregion
                    #region 修改WBS节点
                    PNode oldNode = null;
                    if (!string.IsNullOrEmpty(oldEntity.NodeID))
                    {
                        oldNode         = new WBSBLL().GetNode(oldEntity.NodeID);
                        oldNode.Status  = 0;
                        oldNode.UPDATED = DateTime.Now;
                    }
                    #endregion
                    #region 新增WBS节点
                    PNode newNode = null;
                    if (!string.IsNullOrEmpty(entity.NodeID))
                    {
                        newNode = new PNode();
                        if (oldNode == null)
                        {
                            newNode.ID = Guid.NewGuid().ToString() + "-1";
                        }
                        else
                        {
                            newNode.ID = oldNode.ID.Substring(0, 36) + "-" + (int.Parse(oldNode.ID.Substring(37)) + 1).ToString();
                        }
                        newNode.Name     = entity.Name;
                        newNode.ParentID = entity.NodeID.Substring(0, 36);
                        newNode.PID      = ProjectID;
                        newNode.PType    = 2;
                        newNode.Status   = 1;
                        newNode.CREATED  = DateTime.Now;
                    }
                    #endregion
                    #region 新插入实体
                    string hisNo = oldEntity.ID.Substring(37);
                    entity.ID      = oldEntity.ID.Substring(0, 36) + "-" + (int.Parse(hisNo) + 1).ToString();
                    entity.NodeID  = newNode == null ? null : newNode.ID.Substring(0, 36);
                    entity.Status  = 1;
                    entity.CREATED = DateTime.Now;
                    #endregion
                    dao.UpdateRoutine(entity, oldEntity, newNode, oldNode, listWork);
                    jsonreslut.data = entity.ID;
                }
                jsonreslut.result = true;
                jsonreslut.msg    = "保存成功!";
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex, LogType.BussinessDLL);
                jsonreslut.result = false;
                jsonreslut.msg    = ex.Message;
            }
            return(jsonreslut);
        }