Наследование: INotifyPropertyChanged, IDataErrorInfo
Пример #1
0
        public void RecordBug(string description,Exception ex)
        {
            if (application.Equals(null))
                throw new ApplicationException(RM.GetString(""));

            Bug bug = new Bug()
            {
                Application = application,
                CreateDate = DateTime.Now,
                CreatedBy = "UNKNOWN",
                Description = description,
                isFixed = false,
                IsActivate = true,
                ExceptionContent = ObjSerilizator.SerializeToString<Exception>(ex)
            };

            try
            {
                BugProvider.Create(bug);
            }
            catch (Exception)
            {
                throw new ApplicationException(RM.GetString(""));
            }
        }
Пример #2
0
 public void Delete(Bug bug)
 {
     if (_bugs.Remove(bug) && BugDeleted != null)
     {
         BugDeleted(this, new BugEvent(bug));
         File.Delete(GetFile(bug));
     }
 }
Пример #3
0
 private void Persist(Bug bug)
 {
     EnsureBugStore();
     using (FileStream stream =
         File.Open(GetFile(bug), FileMode.OpenOrCreate))
     {
         var formatter = new BinaryFormatter();
         formatter.Serialize(stream, bug);
     }
 }
        public void PostNewBugWhenTextIsNullShouldReturn400()
        {
            var repo = Mock.Create<IBugTrackerData>();

            var bug = new Bug { Text = null };

            var server = new InMemoryHttpServer<Bug>(InMemoryServerUrl, repo);

            var response = server.CreatePostRequest("/api/Bugs/Log", bug);

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Пример #5
0
 public void RecordBug(Bug bug)
 {
     if (application.Equals(null))
         throw new ApplicationException(RM.GetString(""));
     try
     {
         BugProvider.Create(bug);
     }
     catch (Exception)
     {
         throw new ApplicationException(RM.GetString(""));
     }
 }
Пример #6
0
        Bug IDataAccess.GetBug(int id)
        {
            using (conn = new SQLiteConnection(connectionString))
            {
                conn.Open();

                var bug = new Bug();

                var reader = new SQLiteCommand(SQLFixedQueries.SelectBug(id), conn)
                                                    .ExecuteReader();

                while (reader.Read())
                    bug = ReadBugFromSQL(reader);

                return bug;
            }
        }
Пример #7
0
        public void Save(Bug bug)
        {
            if (bug.Id == 0)
            {
                bug.Id = _bugs.Any() ? _bugs.Max(x => x.Id) + 1 : 1;
                bug.CreatedOn = DateTime.Now;
                _bugs.Add(bug);
            }
            else
            {
                _bugs.Add(bug);
            }
            Persist(bug);

            if (BugSaved != null)
            {
                var timer = new Timer(2000);
                timer.Elapsed += (sender, args) => BugSaved(this, new BugEvent(bug));
                timer.Start();
            }
        }
Пример #8
0
 public IResult Open(Bug bug)
 {
     return new OpenResult<BugViewModel>()
         .In<DetailViewModel>()
         .BeforeActivation(x => x.Bug = bug);
 }
Пример #9
0
 public BugEvent(Bug bug)
 {
     Bug = bug;
 }
Пример #10
0
 private string GetFile(Bug bug)
 {
     return Path.Combine(BugStore, bug.Id + ".dat");
 }
Пример #11
0
 private void UpdateBugInDB(Bug bug)
 {
     new SQLiteCommand(SQLFixedQueries.UpdateBug(bug.ID,
                                                 bug.VersionFound,
                                                 bug.VersionFixed,
                                                 bug.DetailedDescription,
                                                 bug.StepsToReproduce,
                                                 bug.Workaround,
                                                 bug.Fix),
                       conn).ExecuteNonQuery();
 }
Пример #12
0
        private Bug ReadBugFromSQL(SQLiteDataReader reader)
        {
            var bug = new Bug();

            bug.ID = Convert.ToInt32(reader[1]);
            bug.VersionFound = reader[2].ToString();
            bug.VersionFixed = reader[3].ToString();
            bug.DetailedDescription = reader[4].ToString();
            bug.StepsToReproduce = reader[5].ToString();
            bug.Workaround = reader[6].ToString();
            bug.Fix = reader[7].ToString();

            return bug;
        }
Пример #13
0
 private void InsertBugInDB(Bug bug, int issueID)
 {
     new SQLiteCommand(SQLFixedQueries.InsertBug(issueID,
                                                 bug.VersionFound,
                                                 bug.VersionFixed,
                                                 bug.DetailedDescription,
                                                 bug.StepsToReproduce,
                                                 bug.Workaround,
                                                 bug.Fix),
                       conn).ExecuteNonQuery();
 }
Пример #14
0
        int IDataAccess.SaveBug(Issue issue, Bug bug)
        {
            using (conn = new SQLiteConnection(connectionString))
            {
                conn.Open();

                if (issue.IssueID == 0 || !IssueExists(issue.IssueID))
                {
                    int ID = InsertIssueInDBAndGetID(issue, GetUserID(issue.UserCreated));
                    InsertBugInDB(bug, ID);
                    return ID;
                }
                else
                {
                    UpdateIssueInDB(issue, GetUserID(issue.UserClosed));
                    UpdateBugInDB(bug);
                    return issue.IssueID;
                }
            }
        }
Пример #15
0
        public TabBugViewModel(Messenger messenger,
                               DialogCoordinator dialogCoordinator,
                               IDataAccess dataAccess,
                               Bug bug,
                               Issue issue)
            : base(issue)
        {
            this.messenger = messenger;
            this.dialogCoordinator = dialogCoordinator;
            this.dataAccess = dataAccess;
            this.Bug = bug;
            this.ID = bug.ID;

            ShowCloseButton = true;
            TabHeader = "Bug #" + IssueID.ToString();
        }