Ejemplo n.º 1
0
        /// <summary>
        /// 周报发送记录新增
        /// Created:20170509(ChengMengjia)
        /// </summary>
        /// <param name="project"></param>
        /// <param name="node"></param>
        /// <param name="id"></param>
        public JsonResult AddPubInfo(PubInfo entity, List <PubInfoFiles> list)
        {
            JsonResult jsonreslut = new JsonResult();
            ISession   s          = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                s.Save(entity);
                list.ForEach(t =>
                {
                    s.Save(t);
                });
                UpdateProject(s);
                s.Transaction.Commit();
                s.Close();
                jsonreslut.result = true;
                jsonreslut.msg    = "操作成功!";
                jsonreslut.data   = entity.ID;
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex, LogType.DataAccessDLL);
                jsonreslut.result = false;
                jsonreslut.msg    = ex.Message;
                s.Transaction.Rollback();
                s.Close();
            }
            return(jsonreslut);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新增问题
        ///  Created:20170601(zhuguanjun)
        ///  Updated:20170607(ChengMengjia) 添加作为节点插入
        /// </summary>
        /// <param name="entity">问题实体</param>
        /// <param name="listWork">责任人列表</param>
        public virtual void AddTrouble(Trouble entity, PNode node, List <TroubleWork> listWork)
        {
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                s.Save(entity);
                if (node != null)
                {
                    s.Save(node);
                }
                if (listWork != null)
                {
                    foreach (TroubleWork item in listWork)
                    {
                        item.ID        = Guid.NewGuid().ToString();
                        item.Status    = 1;
                        item.CREATED   = DateTime.Now;
                        item.TroubleID = entity.ID.Substring(0, 36);
                        s.Save(item);
                    }
                }
                UpdateProject(s);//更新项目时间
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("插入实体失败", ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新付款信息和里程碑
        /// Created:20170612(ChengMengjia)
        /// </summary>
        /// <param name="entity">日常工作实体</param>
        /// <param name="listWork">负责人列表</param>
        public void UpdateEntities(SubContractLCB newlcb, SubContractLCB oldlcb, SubContractSKXX newskxx, SubContractSKXX oldskxx)
        {
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                if (newlcb != null)
                {
                    s.Save(newlcb);
                }
                if (oldlcb != null)
                {
                    s.Update(oldlcb);
                }
                if (newskxx != null)
                {
                    s.Save(newskxx);
                }
                if (oldskxx != null)
                {
                    s.Update(oldskxx);
                }
                UpdateProject(s);//更新项目时间
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("插入实体失败", ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 交付物节点的修改
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="hisFlg"></param>
        /// <param name="id"></param>
        public virtual void UpdatedDeliverables(DeliverablesJBXX new_jbxx, DeliverablesJBXX old_jbxx, PNode new_node, PNode old_node, List <DeliverablesWork> listWork)
        {
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                s.Save(new_jbxx);
                s.Save(new_node);
                s.Update(old_jbxx);
                s.Update(old_node);
                if (listWork != null)
                {
                    s.CreateQuery("delete from DeliverablesWork where JBXXID='" + new_jbxx.ID.Substring(0, 36) + "';").ExecuteUpdate();
                    foreach (DeliverablesWork entity in listWork)
                    {
                        entity.ID      = Guid.NewGuid().ToString();
                        entity.CREATED = DateTime.Now;
                        entity.JBXXID  = new_jbxx.ID.Substring(0, 36);
                        entity.Manager = entity.Manager.Substring(0, 36);
                        entity.Status  = 1;
                        s.Save(entity);
                    }
                }
                UpdateProject(s);//更新项目时间
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("更新失败", ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 交付物节点的添加
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="hisFlg"></param>
        /// <param name="id"></param>
        public virtual void AddDeliverables(PNode node, DeliverablesJBXX jbxx, NodeProgress progress, List <DeliverablesWork> listWork)
        {
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                s.Save(node);
                s.Save(jbxx);
                s.Save(progress);
                if (listWork != null)
                {
                    foreach (DeliverablesWork entity in listWork)
                    {
                        entity.ID      = Guid.NewGuid().ToString();
                        entity.Status  = 1;
                        entity.CREATED = DateTime.Now;
                        entity.JBXXID  = jbxx.ID.Substring(0, 36);
                        entity.Manager = entity.Manager.Substring(0, 36);
                        s.Save(entity);
                    }
                }
                UpdateProject(s);//更新项目时间
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("插入实体失败", ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 项目修改
        /// Created:20170527(ChengMengjia)
        /// </summary>
        /// <param name="project"></param>
        /// <param name="id"></param>
        public void Update(Project entity, out string id)
        {
            id = string.Empty;
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                id                       = entity.ID;
                entity.UPDATED           = DateTime.Now;
                entity.ProjectLastUpdate = DateTime.Now;
                s.Update(entity);

                #region 顶级节点
                s.CreateSQLQuery("update PNode set Name=:name where PID=:pid and ParentID is null and Status=1; ")
                .SetString("name", entity.Name).SetString("pid", entity.ID).ExecuteUpdate();
                #endregion

                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("保存实体失败", ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取周报收件人列表
        ///  Created:2017.04.11(ChengMengjia)
        /// </summary>
        /// <returns></returns>
        public IList <dynamic> GetMemberList(string ProjectID, string IDs)
        {
            string    sql   = "select * from Stakeholders where PID=:PID and ID in (" + IDs + ")";
            ISQLQuery query = NHHelper.GetCurrentSession().CreateSQLQuery(sql.ToString());

            query.SetString("PID", ProjectID);
            return(query.DynamicList());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 问题工作
        /// Created:20170601(zhuguanjun)
        /// Updated:20170607(ChengMengjia) 更新节点插入
        /// </summary>
        /// <param name="entity">问题实体</param>
        /// <param name="listWork">负责人列表</param>
        public virtual void UpdateTrouble(Trouble newEntity, Trouble oldEntity, PNode newNode, PNode oldNode, List <TroubleWork> listWork)
        {
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                s.Update(oldEntity);
                s.Save(newEntity);
                if (newNode != null)
                {
                    s.Save(newNode);
                }
                if (oldNode != null)
                {
                    s.Update(oldNode);
                }

                //删除责任人
                s.CreateQuery("delete from TroubleWork where TroubleID='" + oldEntity.ID.Substring(0, 36) + "';").ExecuteUpdate();

                //保存新的责任人
                if (listWork != null)
                {
                    foreach (TroubleWork item in listWork)
                    {
                        item.ID        = Guid.NewGuid().ToString();
                        item.Status    = 1;
                        item.CREATED   = DateTime.Now;
                        item.TroubleID = newEntity.ID.Substring(0, 36);
                        s.Save(item);
                    }
                }
                UpdateProject(s);//更新项目时间
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("插入实体失败", ex);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 周报发送记录新增
        /// Created:20170509(ChengMengjia)
        /// </summary>
        /// <param name="project"></param>
        /// <param name="node"></param>
        /// <param name="id"></param>
        public JsonResult Add_RptWeekly(Report_Weekly entity, List <Report_WeeklyFiles> list)
        {
            JsonResult jsonreslut = new JsonResult();
            ISession   s          = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                entity.ID      = Guid.NewGuid().ToString();
                entity.Status  = 1;
                entity.CREATED = DateTime.Now;
                s.Save(entity);
                list.ForEach(t =>
                {
                    t.ID       = Guid.NewGuid().ToString();
                    t.ReportID = entity.ID;
                    t.Status   = 1;
                    t.CREATED  = DateTime.Now;
                    s.Save(t);
                });

                s.Transaction.Commit();
                s.Close();
                jsonreslut.result = true;
                jsonreslut.msg    = "操作成功!";
                jsonreslut.data   = entity.ID;
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex, LogType.DataAccessDLL);
                jsonreslut.result = false;
                jsonreslut.msg    = ex.Message;
                s.Transaction.Rollback();
                s.Close();
            }
            return(jsonreslut);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 保存分包信息
        /// 2017/04/13(zhuguanjun)
        /// </summary>
        /// <param name="entity">分包信息</param>
        /// <param name="dicFile">上传文件集合</param>
        /// <param name="_id"></param>
        /// <returns></returns>
        public JsonResult SaveSubContract(SubContract entity, Dictionary <int, string> dicFile, out string _id)
        {
            _id = string.Empty;            //实际id
            string   SubID = string.Empty; //版本id
            ISession s     = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();

                #region 保存分包信息
                if (string.IsNullOrEmpty(entity.ID))
                {
                    if (entity.Status == null)
                    {
                        entity.Status = 1;
                    }
                    entity.ID      = Guid.NewGuid().ToString() + "-1";
                    entity.CREATED = DateTime.Now;
                    SubID          = entity.ID; //原始版本id
                    _id            = entity.ID; //实际id
                    s.Save(entity);
                }
                else
                {
                    SubContract old = new Repository <SubContract>().Get(entity.ID);
                    old.UPDATED = DateTime.Now;
                    old.Status  = 0;
                    s.Update(old);
                    string hisNo = entity.ID.Substring(37);
                    entity.ID      = entity.ID.Substring(0, 36) + "-" + (int.Parse(hisNo) + 1).ToString();
                    _id            = entity.ID;                         //实际id
                    SubID          = entity.ID.Substring(0, 36) + "-1"; //原始版本id
                    entity.Status  = 1;
                    entity.CREATED = old.CREATED;
                    s.Save(entity);
                }
                #endregion

                #region 保存上传的附件信息
                foreach (var item in dicFile)
                {
                    SubContractFiles file = new SubContractFiles();
                    switch (item.Key)
                    {
                    case 1:
                        file.Name = "合同扫描件";
                        break;

                    case 2:
                        file.Name = "合同电子档";
                        break;

                    case 3:
                        file.Name = "工作说明书扫描件";
                        break;

                    case 4:
                        file.Name = "工作说明书电子档";
                        break;

                    case 5:
                        file.Name = "其他";
                        break;
                    }
                    file.Path  = item.Value;
                    file.SubID = SubID;
                    file.Type  = item.Key;
                    List <QueryField> qlist = new List <QueryField>();
                    qlist.Add(new QueryField()
                    {
                        Name = "SubID", Type = QueryFieldType.String, Value = SubID
                    });                                                                                         //版本id
                    qlist.Add(new QueryField()
                    {
                        Name = "Status", Type = QueryFieldType.Numeric, Value = 1
                    });
                    qlist.Add(new QueryField()
                    {
                        Name = "Type", Type = QueryFieldType.Numeric, Value = item.Key
                    });                                                                                            //附件类型
                    SubContractFiles old = new Repository <SubContractFiles>().FindSingle(qlist);
                    if (old != null && !string.IsNullOrEmpty(old.ID))
                    {
                        old.Path    = file.Path;
                        old.UPDATED = DateTime.Now;
                        s.Update(old);
                    }
                    else
                    {
                        file.CREATED = DateTime.Now;
                        file.ID      = Guid.NewGuid().ToString();
                        file.Status  = 1;
                        s.Save(file);
                    }
                }
                #endregion

                s.Transaction.Commit();
                s.Close();
                return(new JsonResult {
                    result = true, msg = "保存成功", data = SubID
                });
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("保存实体失败", ex);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 节点移动后位置和父级修改保存
        /// Created:20170406(ChengMengjia)
        /// </summary>
        /// <param name="node"></param>
        /// <param name="oldNo"></param>
        /// <param name="oldParentID"></param>
        public void UpdateNode(PNode node, PNode oldNode, string oldParentID)
        {
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                string sql;

                if (string.IsNullOrEmpty(oldParentID))
                {
                    //父节点不变
                    sql = string.Format("select WBSNo from PNode where substr(ID,1,36)='{0}'", node.ParentID);
                    string wbsno = s.CreateSQLQuery(sql).DynamicList().FirstOrDefault().WBSNo;
                    if (!string.IsNullOrEmpty(wbsno))
                    {
                        wbsno += ".";
                    }
                    if (node.No < oldNode.No)
                    {
                        #region 向上移动
                        sql = string.Format("Update PNode set WBSNo='{0}'||(No+1)  where ParentID='{1}' and No>={2} and No<{3}  ;",
                                            wbsno, node.ParentID, node.No, oldNode.No);
                        s.CreateSQLQuery(sql).ExecuteUpdate();

                        sql = string.Format("Update PNode set No=No+1 where ParentID='{0}' and No>={1} and No<{2} ;",
                                            node.ParentID, node.No, oldNode.No);
                        s.CreateSQLQuery(sql).ExecuteUpdate();
                        #endregion
                    }
                    else
                    {
                        #region 向下移动
                        sql = string.Format("Update PNode set No=No-1 where ParentID='{0}' and No>{1} and No<={2} ;",
                                            node.ParentID, node.No, oldNode.No);
                        s.CreateSQLQuery(sql).ExecuteUpdate();
                        sql = string.Format("Update PNode set WBSNo='{0}'||(No-1) where ParentID='{0}' and No>{1} and No<={2} ;",
                                            wbsno, node.ParentID, node.No, oldNode.No);
                        s.CreateSQLQuery(sql).ExecuteUpdate();
                        #endregion
                    }
                }
                else
                {
                    #region 更新新同级编号
                    sql = string.Format("select WBSNo from PNode where substr(ID,1,36)='{0}'", node.ParentID);
                    string wbsno = s.CreateSQLQuery(sql).DynamicList().FirstOrDefault().WBSNo;
                    if (!string.IsNullOrEmpty(wbsno))
                    {
                        wbsno += ".";
                    }
                    sql = string.Format("Update PNode set WBSNo='{0}'||(No+1) where ParentID='{1}'  and No>={2} ;",
                                        wbsno, node.ParentID, node.No);
                    s.CreateSQLQuery(sql).ExecuteUpdate();
                    #endregion
                    sql = string.Format("Update PNode set No=No+1 where ParentID='{0}' and No>={1} ;",
                                        node.ParentID, node.No);
                    s.CreateSQLQuery(sql).ExecuteUpdate();

                    #region 更新原同级编号
                    sql   = string.Format("select WBSNo from PNode where substr(ID,1,36)='{0}'", oldParentID);
                    wbsno = s.CreateSQLQuery(sql).DynamicList().FirstOrDefault().WBSNo;
                    if (!string.IsNullOrEmpty(wbsno))
                    {
                        wbsno += ".";
                    }
                    sql = string.Format("Update PNode set WBSNo='{0}'||(No-1) where ParentID='{1}' and No>{2} ;",
                                        wbsno, oldParentID, oldNode.No);
                    s.CreateSQLQuery(sql).ExecuteUpdate();
                    #endregion

                    sql = string.Format("Update PNode set No=No-1 where ParentID='{0}' and No>{1} ;",
                                        oldParentID, oldNode.No);
                    s.CreateSQLQuery(sql).ExecuteUpdate();
                }
                s.Save(node);
                s.Update(oldNode);
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("插入实体失败", ex);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 项目新增
        /// Created:2017.3.24(ChengMengjia)
        /// Updated:2017.4.6(zhuguanjun)
        /// </summary>
        /// <param name="project"></param>
        /// <param name="node"></param>
        /// <param name="id"></param>
        public virtual void Add(Project project, List <PNode> list, List <DeliverablesJBXX> listJbxx, out string id)
        {
            id = string.Empty;
            ISession s = NHHelper.GetCurrentSession();

            try
            {
                s.BeginTransaction();
                if (list == null)
                {
                    #region 顶级节点
                    PNode node = new PNode();
                    node.No      = 1;
                    node.ID      = Guid.NewGuid().ToString();
                    node.PID     = project.ID;
                    node.Name    = project.Name;
                    node.PType   = 0;
                    node.Status  = 1;
                    node.CREATED = DateTime.Now;
                    s.Save(node);
                    #endregion
                }
                else
                {
                    foreach (PNode node in list)
                    {
                        s.Save(node);
                    }
                    foreach (DeliverablesJBXX jbxx in listJbxx)
                    {
                        s.Save(jbxx);
                    }
                }
                //成本、收入、收款取消6条
                //(2017/05/09)zhuguanjun
                #region 成本信息
                //for (int i = 1; i < 7; i++)
                //{
                //    Cost entityC = new Cost();
                //    entityC.ID = Guid.NewGuid().ToString() + "-1";
                //    entityC.PID = project.ID;
                //    entityC.Tag = "成本分配" + i;
                //    entityC.Status = 1;
                //    entityC.Total = 0;
                //    entityC.Transit = 0;
                //    entityC.Used = 0;
                //    entityC.Remaining = 0;
                //    entityC.CREATED = DateTime.Now.AddSeconds(i);
                //    s.Save(entityC);
                //}
                #endregion

                #region 收入信息
                //for (int i = 1; i < 7; i++)
                //{
                //    Income entityI = new Income();
                //    entityI.ID = Guid.NewGuid().ToString() + "-1";
                //    entityI.PID = project.ID;
                //    entityI.Status = 1;
                //    entityI.Step = "阶段" + i;
                //    entityI.CREATED = DateTime.Now;
                //    s.Save(entityI);
                //}
                #endregion

                #region 收款信息
                //for (int i = 1; i < 7; i++)
                //{
                //    Receivables entityR = new Receivables();
                //    entityR.ID = Guid.NewGuid().ToString() + "-1";
                //    entityR.PID = project.ID;
                //    entityR.Status = 1;
                //    entityR.BatchNo = "第" + i + "次收款";
                //    entityR.CREATED = DateTime.Now;
                //    s.Save(entityR);
                //}
                #endregion

                s.Save(project);
                s.Transaction.Commit();
                s.Close();
            }
            catch (Exception ex)
            {
                s.Transaction.Rollback();
                s.Close();
                throw new Exception("保存实体失败", ex);
            }
        }