Пример #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="bug"></param>
 /// <returns></returns>
 public bool CreateNewBug(BBug bug)
 {
     if (bug.Created_By == null)
     {
         throw new KMJXCException("创建Bug时必须有创建人");
     }
     bool result = false;
     using (KuanMaiEntities db = new KuanMaiEntities())
     {
         Bug dbBug = new Bug();
         dbBug.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
         if (bug.Created_By != null)
         {
             dbBug.Created_By = bug.Created_By.ID;
         }
         dbBug.Description = bug.Description;
         if (bug.Feature != null)
         {
             dbBug.Feature = bug.Feature.ID;
         }
         dbBug.Function = 0;
         dbBug.Modified = dbBug.Created;
         dbBug.Modified_By = dbBug.Created_By;
         dbBug.Resolved = 0;
         dbBug.Resolved_By = 0;
         dbBug.Status = 1;
         dbBug.Title = bug.Title;
         db.Bug.Add(dbBug);
         db.SaveChanges();
         result = true;
     }
     return result;
 }
Пример #2
0
        public ApiMessage CreateBug()
        {
            ApiMessage message = new ApiMessage() { Status="ok"};
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            BugManager bugManager = new BugManager(int.Parse(user_id));
            int feature=0;
            int.TryParse(request["feature"],out feature);
            try
            {
                BBug newBug = new BBug();
                newBug.Created_By = bugManager.CurrentUser;
                newBug.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                newBug.Modified_By = bugManager.CurrentUser;
                newBug.Modified = newBug.Created;
                newBug.Status = new BBugStatus() {  ID=1};
                newBug.Title = HttpUtility.HtmlDecode(request["title"]);
                newBug.Description = HttpUtility.HtmlDecode(request["description"]);
                newBug.Feature = new BBugFeature() { ID = feature };

                bool result = bugManager.CreateNewBug(newBug);
            }
            catch (KMJXCException kex)
            {
                message.Status = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status = "failed";
                message.Message = "未知错误";
            }

            return message;
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="bug"></param>
        /// <returns></returns>
        public bool UpdateBug(BBug bug)
        {
            if (bug.Modified_By == null)
            {
                throw new KMJXCException("更新Bug时必须有更新人");
            }
            bool result = false;
            using (KuanMaiEntities db = new KuanMaiEntities())
            {
                Bug existed=(from b in db.Bug where b.ID==bug.ID select b).FirstOrDefault<Bug>();
                if (existed == null)
                {
                    throw new KMJXCException("所需更新的Bug信息不存在");
                }

                if (bug.Status != null)
                {
                    existed.Status = bug.Status.ID;
                }

                if (bug.Modified_By != null)
                {
                    existed.Modified_By = bug.Modified_By.ID;
                    existed.Modified = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                }
                if (!string.IsNullOrEmpty(bug.Title))
                {
                    existed.Title = bug.Title;
                }

                if (!string.IsNullOrEmpty(bug.Description))
                {
                    existed.Description = bug.Description;
                }
                db.SaveChanges();
                result = true;
            }
            return result;
        }
Пример #4
0
        public ApiMessage GetBugFullInfo()
        {
            BBug data = new BBug();
            ApiMessage message = new ApiMessage();
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            BugManager bugManager = new BugManager(int.Parse(user_id));
            try
            {
                int bugId = 0;
                int.TryParse(request["bug_id"], out bugId);
                data = bugManager.GetBugInfo(bugId);
                message.Item = data;
            }
            catch (KMJXCException kex)
            {
                message.Status = "failed";
                message.Message = kex.Message;
            }
            catch (Exception ex)
            {
                message.Status = "failed";
                message.Message = "未知错误";
            }

            return message;
        }