예제 #1
0
        public int Update(CICheckItem checkitem)
        {
            const string sql = @"UPDATE CICheckItem SET
				                                        UpdateTime = @UpdateTime,	
				                                        Status = @Status,	
				                                        ValidateNote = @ValidateNote,	
				                                        DeployNote = @DeployNote,	
				                                        VersionCode = @VersionCode,	
				                                        DemandCode = @DemandCode,	
				                                        CodeList = @CodeList,	
				                                        Attachment = @Attachment,	
				                                        Remark = @Remark,	
				                                        Developer = @Developer,	
				                                        Tester = @Tester,	
				                                        AddTime = @AddTime,
				                                        GetVssCnt = @GetVssCnt,
				                                        ItemType = @ItemType,
				                                        UserName = @UserName,
				                                        PlanId = @PlanId
				                       WHERE ID=@ID "                            ;

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(sql, checkitem));
            }
        }
예제 #2
0
 /// <summary>
 /// 更新checkitem
 /// </summary>
 /// <param name="checkitem"></param>
 /// <returns></returns>
 public int UpdateCheckItem(CICheckItem checkItem, CILog log)
 {
     if (log != null)
     {
         new LogService().InsertLog(log);
     }
     return(_checkItemRepository.Update(checkItem));
 }
예제 #3
0
        public int Delete(CICheckItem checkitem)
        {
            const string sql = "DELETE FROM CICheckItem WHERE ID=@ID ";

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(sql, new { ID = checkitem.ID }));
            }
        }
예제 #4
0
        public ActionResult AddItemToPlan(CICheckItem Item)
        {
            var model = new CheckItemModel();

            model.CheckItem = Item;

            bool success = true;

            //验证代码清单
            #region 格式验证
            if (Item.DemandCode == "")
            {
                ErrorNotification("需求编号不能为空");
                success = false;
            }
            #endregion

            if (string.IsNullOrEmpty(Item.ID))
            {
                Item.AddTime    = DateTime.Now;
                Item.UpdateTime = DateTime.Now;
                Item.Developer  = CurrentUser.FullName;
                Item.UserName   = CurrentUser.UserName;
                Item.Status     = "计划中";
                //验证需求编号
                if (!_checkItemService.ExistsDemandCode(Item.DemandCode))
                {
                    success = false;
                    ErrorNotification("需求或者bug编号不存在");
                    return(AddItemToPlan());
                }
                int num = 0;
                if (success)
                {
                    Item.ID = Guid.NewGuid().ToString();
                    num     = _checkItemService.InsertCheckItem(Item);
                }
                if (num > 0)
                {
                    SuccessNotification("添加成功");
                }
                else
                {
                    ErrorNotification("添加失败");
                    return(AddItemToPlan());
                }
            }

            if (success)
            {
                return(Redirect(Url.Action("checklist", "checkitem")));
            }
            else
            {
                return(AddItemToPlan());
            }
        }
예제 #5
0
        public int Insert(CICheckItem checkitem)
        {
            var sql = @"INSERT INTO CICheckItem 
                              (ID,UpdateTime,Status,ValidateNote,DeployNote,VersionCode,DemandCode,CodeList,Attachment,Remark,Developer,Tester,AddTime,GetVssCnt,ItemType,UserName,PlanId) 
                      VALUES (@ID,@UpdateTime,@Status,@ValidateNote,@DeployNote,@VersionCode,@DemandCode,@CodeList,@Attachment,@Remark,@Developer,@Tester,@AddTime,@GetVssCnt,@ItemType,@UserName,@PlanId)";

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(sql, checkitem));
            }
        }
예제 #6
0
        /// <summary>
        /// 根据计划编号 获取计划开放时间 判断是否能编辑
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool IsCanEdit(CICheckItem item)
        {
            //如果当期时间在此记录的计划时间范围之类才允许修改或者删除
            var list = from plan in this.PlanList where plan.ID == item.PlanId select plan;

            if (list != null && list.Count() > 0)
            {
                var p = list.First();
                return(DateTime.Now > Convert.ToDateTime(p.BeginTime) && DateTime.Now < Convert.ToDateTime(p.EndTime));
            }
            return(false);
        }
예제 #7
0
        /// <summary>
        /// 更新checkitem
        /// </summary>
        /// <param name="checkitem"></param>
        /// <returns></returns>
        public int UpdateCheckItem(CICheckItem checkItem)
        {
            //记录日志
            var logService = new LogService();
            var log        = new CILog();

            log.Contents   = "修改提交物,开发人员:" + checkItem.Developer;
            log.UserName   = (new UserService()).GetUserFromCookie().UserName;
            log.LogTime    = DateTime.Now;
            log.DemandCode = checkItem.DemandCode;
            log.CodeFile   = checkItem.CodeList;
            logService.InsertLog(log);

            return(UpdateCheckItem(checkItem, log));
        }
예제 #8
0
 public CheckItemModel()
 {
     CheckItem      = new CICheckItem();
     plan           = new CIVersionPlan();
     PlanSelectItem = new List <SelectListItem>();
 }
예제 #9
0
        public ActionResult ItemEdit(CICheckItem Item)
        {
            var model = new CheckItemModel();

            model.CheckItem = Item;

            bool success = true;

            //验证代码清单
            #region 格式验证
            Item.CodeList = Item.CodeList.Trim().Replace("(", "(").Replace(")", ")");
            //if (Item.CodeList == "")
            //{
            //    ErrorNotification("代码不能为空");
            //    success = false;
            //}
            if (Item.DemandCode == "")
            {
                ErrorNotification("需求编号不能为空");
                success = false;
            }
            var attachment = Request.Files["AttachmentFile"];
            if ((attachment == null || attachment.FileName == "") && string.IsNullOrEmpty(Item.Attachment))
            {
                success = false;
                ErrorNotification("提交物不能为空");
            }
            else
            {
                if (attachment != null && attachment.FileName != "")
                {
                    var folder = "/" + ConfigHelper.GetValue("uploadpath") + "/" + CurrentUser.UserName;

                    if (!System.IO.Directory.Exists(Server.MapPath(folder)))
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath(folder));
                    }
                    var savepath = Server.MapPath(folder + "/" + attachment.FileName);
                    if (System.IO.File.Exists(savepath))
                    {
                        System.IO.File.Delete(savepath);
                    }
                    attachment.SaveAs(savepath);
                    Item.Attachment = Request.Url.Authority + folder + "/" + attachment.FileName;
                    if (Item.Attachment.IndexOf("http://") < 0)
                    {
                        Item.Attachment = "http://" + Item.Attachment;
                    }
                }
            }
            if (Item.DeployNote == "")
            {
                success = false;
                ErrorNotification("部署注意事项不能为空");
            }

            var codelist = Item.CodeList;

            if (!string.IsNullOrEmpty(codelist))
            {
                codelist = codelist.Replace("/", @"\");//统一替换成反斜杠
                string[] stringSeparators = new string[] { "\r\n" };
                string[] files            = codelist.Split(stringSeparators, StringSplitOptions.None);
                foreach (var file in files)
                {
                    //正则验证:^ccms_7|ccms_6(\/[\w-]*)(新增)|(修改)$
                    //必须是ccms_7或者ccms_v6开头
                    var v6 = file.ToLower().IndexOf(@"ccms_v6\");
                    var v7 = file.ToLower().IndexOf(@"ccms_v7\");
                    if (v6 != 0 && v7 != 0)
                    {
                        ErrorNotification(@"代码必须是ccms_v7\或者ccms_v6\开头:" + file);
                        success = false;
                    }
                    //(新增)或者(修改)结尾
                    var posfixadd  = file.LastIndexOf("(新增)");
                    var postfixmod = file.LastIndexOf("(修改)");
                    if (posfixadd == -1 && postfixmod == -1)
                    {
                        success = false;
                        ErrorNotification("代码必须是(新增)或者(修改)结尾:" + file);
                    }
                    // 中间必须包含这个斜杠 /
                    if (file.IndexOf(@"\") <= 0)
                    {
                        success = false;
                        ErrorNotification(@"代码中间必须包含这个斜杠 \:" + file);
                    }
                    // 不能包含这个斜杠 \
                    //if (file.IndexOf("\\") >= 0)
                    //{
                    //    success = false;
                    //    ErrorNotification("代码不能包含这个斜杠 \\:" + file);
                    //}
                }
            }

            #endregion

            if (string.IsNullOrEmpty(Item.ID))
            {
                Item.AddTime    = DateTime.Now;
                Item.UpdateTime = DateTime.Now;
                Item.Developer  = CurrentUser.FullName;
                Item.UserName   = CurrentUser.UserName;
                //验证需求编号
                if (!_checkItemService.ExistsDemandCode(Item.DemandCode))
                {
                    success = false;
                    ErrorNotification("需求或者bug编号不存在");
                    return(View(model));
                }
                int num = 0;
                if (success)
                {
                    Item.ID = Guid.NewGuid().ToString();
                    num     = _checkItemService.InsertCheckItem(Item);
                }
                if (num > 0)
                {
                    SuccessNotification("添加成功");
                }
                else
                {
                    ErrorNotification("添加失败");
                    return(View(model));
                }
            }
            else
            {
                var oldmodel = _checkItemService.GetCheckItem(Item.ID);
                Item.AddTime    = oldmodel.AddTime;
                Item.GetVssCnt  = oldmodel.GetVssCnt;
                Item.Developer  = oldmodel.Developer;
                Item.UpdateTime = DateTime.Now;
                Item.PlanId     = oldmodel.PlanId;
                Item.UserName   = oldmodel.UserName;
                model.plan      = new VersionPlanService().GetPlan(Item.PlanId);
                int num = 0;
                if (success)
                {
                    num = _checkItemService.UpdateCheckItem(Item);
                }
                if (num > 0)
                {
                    SuccessNotification("修改成功");
                }
                else
                {
                    ErrorNotification("修改失败");
                    return(View(model));
                }
            }
            if (success)
            {
                var url = PressRequest.GetUrlReferrer();
                return(Redirect(url));
            }
            else
            {
                return(View(model));
            }
        }