Inheritance: OptimizedPersistable
コード例 #1
0
ファイル: Attachment.cs プロジェクト: VelocityDB/VelocityDB
 public Attachment(string filePath, string fileName, string note, byte[] content, string contentType, Issue issue)
 {
   m_fileName = fileName;
   m_filePath = filePath;
   m_comment = note;
   m_contentType = contentType;
   m_fileContent = content;
   if (issue != null)
     m_issueAttachedTo = new WeakIOptimizedPersistableReference<Issue>(issue);
 }
コード例 #2
0
 public void Add(Issue issue)
 {
   issueSetById.Add(issue); 
   issueSetByDescription.Add(issue);
   issueSetByPriority.Add(issue);
   issueSetByDateTimeCreated.Add(issue);
   issueSetByDateTimeUpdated.Add(issue);
   issueSetByStatus.Add(issue);
   issueSetBySummary.Add(issue);
   issueSetByProject.Add(issue);
   issueSetByCategory.Add(issue);
   issueSetByReportedBy.Add(issue);
   issueSetByLastUpdatedBy.Add(issue);
   issueSetByAssignedTo.Add(issue);
   issueSetByDueDate.Add(issue);
   issueSetByVersion.Add(issue);
 }
コード例 #3
0
ファイル: TrackerTests.cs プロジェクト: VelocityDB/VelocityDB
 public void Create6Issues(int numberOfIssues)
 {
   Issue issue = null;
   Issue priorIssue = null;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     for (int i = 0; i < numberOfIssues; i++)
     {
       IssueTracker issueTracker = session.AllObjects<IssueTracker>(false).FirstOrDefault();
       User user = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Count)];
       User assignedTo = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Count)];
       Project project = issueTracker.ProjectSet.Keys[rand.Next(issueTracker.ProjectSet.Count)];
       Component component = issueTracker.ComponentSet.Keys[rand.Next(issueTracker.ComponentSet.Count)];
       ProductVersion version = issueTracker.VersionSet.Keys[rand.Next(issueTracker.VersionSet.Count)];
       Issue.CategoryEnum category = (Issue.CategoryEnum)rand.Next(5);
       Issue.Resolution resolution = (Issue.Resolution)rand.Next(5);
       Issue.PriorityEnum priority = (Issue.PriorityEnum)rand.Next(5);
       Issue.StatusEnum status = (Issue.StatusEnum)rand.Next(5);
       if (status == Issue.StatusEnum.Open || status == Issue.StatusEnum.InProgress || status == Issue.StatusEnum.Reopened)
         resolution = Issue.Resolution.Incomplete; // the other states does not make sense
       DateTime dueDate = new DateTime(rand.Next(), DateTimeKind.Utc);
       string c = "project" + i.ToString();
       string s = "summary" + i.ToString();
       string e = "environment" + i.ToString();
       string d = "idescription" + i.ToString();
       issue = new Issue(user, priority, project, category, component, version, resolution, s, d, e, assignedTo, dueDate, null, status);
       session.Persist(issue);
       priorIssue = issue;
       issueTracker.Add(issue);       
     }
     session.Commit();
   }
 }
コード例 #4
0
 public bool Remove(Issue issue)
  {
    return issueSetById.Remove(issue) &&
           issueSetByDescription.Remove(issue) &&
           issueSetByPriority.Remove(issue) &&
           issueSetByDateTimeCreated.Remove(issue) &&
           issueSetByDateTimeUpdated.Remove(issue) &&
           issueSetByStatus.Remove(issue) &&
           issueSetBySummary.Remove(issue) &&
           issueSetByProject.Remove(issue) &&
           issueSetByCategory.Remove(issue) &&
           issueSetByReportedBy.Remove(issue) &&
           issueSetByLastUpdatedBy.Remove(issue) &&
           issueSetByAssignedTo.Remove(issue) &&
           issueSetByDueDate.Remove(issue) &&
           issueSetByVersion.Remove(issue);
  }
コード例 #5
0
ファイル: Issues.aspx.cs プロジェクト: VelocityDB/VelocityDB
 public IEnumerable<Issue> SelectIssue(UInt64 Id)
 {
   try
   {
     Issue issue;
     if (Id > 0)
     {
       issue = (Issue)s_sharedReadOnlySession.Open(Id);
     }
     else
       issue = new Issue();
     List<Issue> list = new List<Issue>(1);
     list.Add(issue);
     return list;
   }
   catch (System.Exception ex)
   {
     this.errorLabel.Text = ex.ToString();
   }
   return null;
 }
コード例 #6
0
ファイル: Issues.aspx.cs プロジェクト: VelocityDB/VelocityDB
    public void UpdateIssue(EditedIssue newValues)
    {
      try
      {
        object projectIndexObj = Session["ProjectSelected"];
        int projectIndex = projectIndexObj == null ? 0 : (int)projectIndexObj;
        object componentIndexObj = Session["ComponentSelected"];
        int componentIndex = componentIndexObj == null ? 0 : (int)componentIndexObj;
        object versionIndexObj = Session["VersionSelected"];
        int versionIndex = versionIndexObj == null ? 0 : (int)versionIndexObj;
        object assignedToIndexObj = Session["AssignedToSelected"];
        int assignedToIndex = assignedToIndexObj == null ? 0 : (int)assignedToIndexObj;
        object statusIndexObj = Session["StatusSelected"];
        int statusIndex = statusIndexObj == null ? 0 : (int)statusIndexObj;
        object resolutionIndexObj = Session["ResolutionSelected"];
        int resolutionIndex = resolutionIndexObj == null ? 0 : (int)resolutionIndexObj;
        object categoryIndexObj = Session["CategorySelected"];
        int categoryIndex = categoryIndexObj == null ? 0 : (int)categoryIndexObj;
        object priorityIndexObj = Session["PrioritySelected"];
        int priorityIndex = priorityIndexObj == null ? 0 : (int)priorityIndexObj;
        object updatedAttachementsObj = Session["UpdatedAttachments"];
        SortedSetAny<Attachment> updatedAttachments = null;
        if (updatedAttachementsObj != null)
          updatedAttachments = (SortedSetAny<Attachment>)Session["UpdatedAttachments"];
        Session["UpdatedAttachments"] = null;
        int sessionId = -1;
        SessionBase session = null;
        try
        {
          session = s_sessionPool.GetSession(out sessionId);
          session.BeginUpdate();
          IssueTracker issueTracker = session.AllObjects<IssueTracker>(false).FirstOrDefault();
          Project project = issueTracker.ProjectSet.Keys[projectIndex];
          Component component = issueTracker.ComponentSet.Keys[componentIndex];
          ProductVersion version = issueTracker.VersionSet.Count > 0 ? issueTracker.VersionSet.Keys[versionIndex] : null;
          Issue.StatusEnum status = (Issue.StatusEnum)AllStatus().GetValue(statusIndex);
          Issue.CategoryEnum category = (Issue.CategoryEnum)AllCategory().GetValue(categoryIndex);
          Issue.PriorityEnum priority = (Issue.PriorityEnum)AllPriority().GetValue(priorityIndex);
          Issue.Resolution resolution = (Issue.Resolution)AllResolution().GetValue(resolutionIndex);
          User assignedTo = issueTracker.UserSet.Keys[assignedToIndex];
          if (newValues.Id == 0)
          {
            if (newValues.Summary == null)
              Console.WriteLine("Issue null summary detected in Update method");
            else
            {
              User user = lookupUser(issueTracker, session);
              Issue issue = new Issue(user, priority, project, category, component, version, resolution, newValues.Summary, newValues.Description,
                newValues.Environment, assignedTo, newValues.DueDate, updatedAttachments);
              if (updatedAttachments != null)
                foreach (Attachment attachment in updatedAttachments)
                  attachment.IssueAttachedTo = new WeakIOptimizedPersistableReference<Issue>(issue);
              session.Persist(issue);
              issueTracker.Add(issue);
            }
          }
          else
          {
            Issue existingIssue = (Issue)session.Open(newValues.Id);
            User user = lookupUser(issueTracker, session);
            if (existingIssue.Summary != newValues.Summary)
            {
              issueTracker.IssueSetBySummary.Remove(existingIssue);
              existingIssue.Summary = newValues.Summary;
              issueTracker.IssueSetBySummary.Add(existingIssue);
            }
            existingIssue.Description = newValues.Description;
            existingIssue.FixMessage = newValues.FixMessage;
            if (existingIssue.DueDate != newValues.DueDate)
            {
              issueTracker.IssueSetByDueDate.Remove(existingIssue);
              existingIssue.DueDate = newValues.DueDate;
              issueTracker.IssueSetByDueDate.Add(existingIssue);
            }
            if (existingIssue.LastUpdatedBy != user)
            {
              issueTracker.IssueSetByLastUpdatedBy.Remove(existingIssue);
              existingIssue.LastUpdatedBy = user;
              issueTracker.IssueSetByLastUpdatedBy.Add(existingIssue);
            }
            issueTracker.IssueSetByDateTimeUpdated.Remove(existingIssue);
            existingIssue.DateTimeLastUpdated = DateTime.Now;
            issueTracker.IssueSetByDateTimeUpdated.Add(existingIssue);

            if (priorityIndexObj != null && existingIssue.Priority != priority)
            {
              issueTracker.IssueSetByPriority.Remove(existingIssue);
              existingIssue.Priority = priority;
              issueTracker.IssueSetByPriority.Add(existingIssue);
            }
            if (categoryIndexObj != null && existingIssue.Category != category)
            {
              issueTracker.IssueSetByCategory.Remove(existingIssue);
              existingIssue.Category = category;
              issueTracker.IssueSetByCategory.Add(existingIssue);
            }
            if (componentIndexObj != null && existingIssue.Component != component)
            {
              existingIssue.Component = component;
              project = component.Project;
            }
            if (versionIndexObj != null && existingIssue.Version != version)
            {
              issueTracker.IssueSetByVersion.Remove(existingIssue);
              existingIssue.Version = version;
              issueTracker.IssueSetByVersion.Add(existingIssue);
            }
            existingIssue.Environment = newValues.Environment;
            if (projectIndexObj != null && existingIssue.Project != project)
            {
              issueTracker.IssueSetByProject.Remove(existingIssue);
              existingIssue.Project = project;
              issueTracker.IssueSetByProject.Add(existingIssue);
            }
            if (assignedToIndexObj != null && existingIssue.AssignedTo != assignedTo)
            {
              issueTracker.IssueSetByAssignedTo.Remove(existingIssue);
              existingIssue.AssignedTo = assignedTo;
              issueTracker.IssueSetByAssignedTo.Add(existingIssue);
            }
            if (statusIndexObj != null && existingIssue.Status != status)
            {
              issueTracker.IssueSetByStatus.Remove(existingIssue);
              existingIssue.Status = status;
              issueTracker.IssueSetByStatus.Add(existingIssue);
            }
            if (resolutionIndexObj != null && existingIssue.FixResolution != resolution)
            {
              //issueTracker.IssueSetByStatus.Remove(existingIssue);
              existingIssue.FixResolution = resolution;
              //issueTracker.IssueSetByStatus.Add(existingIssue);
            }
            if (updatedAttachments != null)
              foreach (Attachment attachment in updatedAttachments)
              {
                attachment.IssueAttachedTo = new WeakIOptimizedPersistableReference<Issue>(existingIssue);
                existingIssue.Attachments.Add(attachment);
              }
          }
          session.Commit();
          s_sharedReadOnlySession.ForceDatabaseCacheValidation();
        }
        catch (Exception ex)
        {
          session?.Abort();
          Console.Out.WriteLine(ex.StackTrace);
        }
        finally
        {
          s_sessionPool.FreeSession(sessionId, session);
        }
      }
      catch (System.Exception ex)
      {
        Console.WriteLine(ex.ToString());
        this.errorLabel.Text = ex.ToString();
      }
    }
コード例 #7
0
 public IEnumerable<Issue> SelectIssue(UInt64 Id)
 {
   try
   {
     Issue issue;
     if (Id > 0)
     {
       using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
       {
         session.BeginRead();
         issue = (Issue)session.Open(Id);
         session.Commit();
       }
     }
     else
       issue = new Issue();
     List<Issue> list = new List<Issue>(1);
     list.Add(issue);
     return list;
   }
   catch (System.Exception ex)
   {
     this.errorLabel.Text = ex.ToString();
   }
   return null;
 }
コード例 #8
0
    public void UpdateIssue(EditedIssue newValues)
    {
      try
      {
        object projectIndexObj = Session["ProjectSelected"];
        int projectIndex = projectIndexObj == null ? 0 : (int)projectIndexObj;
        object componentIndexObj = Session["ComponentSelected"];
        int componentIndex = componentIndexObj == null ? 0 : (int)componentIndexObj;
        object versionIndexObj = Session["VersionSelected"];
        int versionIndex = versionIndexObj == null ? 0 : (int)versionIndexObj;
        object assignedToIndexObj = Session["AssignedToSelected"];
        int assignedToIndex = assignedToIndexObj == null ? 0 : (int)assignedToIndexObj;
        object statusIndexObj = Session["StatusSelected"];
        int statusIndex = statusIndexObj == null ? 0 : (int)statusIndexObj;
        object resolutionIndexObj = Session["ResolutionSelected"];
        int resolutionIndex = resolutionIndexObj == null ? 0 : (int)resolutionIndexObj;
        object categoryIndexObj = Session["CategorySelected"];
        int categoryIndex = categoryIndexObj == null ? 0 : (int)categoryIndexObj;
        object priorityIndexObj = Session["PrioritySelected"];
        int priorityIndex = priorityIndexObj == null ? 0 : (int)priorityIndexObj;
        object updatedAttachementsObj = Session["UpdatedAttachments"];
        SortedSetAny<Attachment> updatedAttachments = null;
        if (updatedAttachementsObj != null)
          updatedAttachments = (SortedSetAny<Attachment>)Session["UpdatedAttachments"];
        Session["UpdatedAttachments"] = null;
        using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
        {
          session.BeginUpdate();
          IssueTracker issueTracker = (IssueTracker)session.Open(IssueTracker.PlaceInDatabase, 1, 1, false);
          Project project = issueTracker.ProjectSet.Keys[projectIndex];
          Component component = issueTracker.ComponentSet.Keys[componentIndex];
          ProductVersion version = issueTracker.VersionSet.Count > 0 ? issueTracker.VersionSet.Keys[versionIndex] : null;
          Issue.StatusEnum status = (Issue.StatusEnum)AllStatus().GetValue(statusIndex);
          Issue.CategoryEnum category = (Issue.CategoryEnum)AllCategory().GetValue(categoryIndex);
          Issue.PriorityEnum priority = (Issue.PriorityEnum)AllPriority().GetValue(priorityIndex);
          Issue.Resolution resolution = (Issue.Resolution)AllResolution().GetValue(resolutionIndex);
          User assignedTo = issueTracker.UserSet.Keys[assignedToIndex];
          if (newValues.Id == 0)
          {
            if (newValues.Summary == null)
              Console.WriteLine("Issue null summary detected in Update method");
            else
            {
              User user = lookupUser(issueTracker, session);
              Issue issue = new Issue(user, priority, project, category, component, version, resolution, newValues.Summary, newValues.Description,
                newValues.Environment, assignedTo, newValues.DueDate, updatedAttachments);
              if (updatedAttachments != null)
                foreach (Attachment attachment in updatedAttachments)
                  attachment.IssueAttachedTo = new WeakIOptimizedPersistableReference<Issue>(issue);
              Placement placer = new Placement(issue.PlacementDatabaseNumber);
              issue.Persist(placer, session, true, true);
              issueTracker.Add(issue);
            }
          }
          else
          {
            Issue existingIssue = (Issue)session.Open(newValues.Id);
            if (existingIssue.Summary != newValues.Summary)
            {
              issueTracker.IssueSetBySummary.Remove(existingIssue);
              existingIssue.Summary = newValues.Summary;
              issueTracker.IssueSetBySummary.Add(existingIssue);
            }
            existingIssue.Description = newValues.Description;
            existingIssue.FixMessage = newValues.FixMessage;
            if (existingIssue.DueDate != newValues.DueDate)
            {
              issueTracker.IssueSetByDueDate.Remove(existingIssue);
              existingIssue.DueDate = newValues.DueDate;
              issueTracker.IssueSetByDueDate.Add(existingIssue);
            }

            issueTracker.IssueSetByDateTimeUpdated.Remove(existingIssue);
            existingIssue.DateTimeLastUpdated = DateTime.Now;
            issueTracker.IssueSetByDateTimeUpdated.Add(existingIssue);

            if (priorityIndexObj != null && existingIssue.Priority != priority)
            {
              issueTracker.IssueSetByPriority.Remove(existingIssue);
              existingIssue.Priority = priority;
              issueTracker.IssueSetByPriority.Add(existingIssue);
            }
            if (categoryIndexObj != null && existingIssue.Category != category)
            {
              issueTracker.IssueSetByCategory.Remove(existingIssue);
              existingIssue.Category = category;
              issueTracker.IssueSetByCategory.Add(existingIssue);
            }
            if (componentIndexObj != null && existingIssue.Component != component)
            {
              existingIssue.Component = component;
              project = component.Project;
            }
            if (versionIndexObj != null && existingIssue.Version != version)
            {
              issueTracker.IssueSetByVersion.Remove(existingIssue);
              existingIssue.Version = version;
              issueTracker.IssueSetByVersion.Add(existingIssue);
            }
            existingIssue.Environment = newValues.Environment;
            if (projectIndexObj != null && existingIssue.Project != project)
            {
              issueTracker.IssueSetByProject.Remove(existingIssue);
              existingIssue.Project = project;
              issueTracker.IssueSetByProject.Add(existingIssue);
            }
            if (assignedToIndexObj != null && existingIssue.AssignedTo != assignedTo)
            {
              issueTracker.IssueSetByAssignedTo.Remove(existingIssue);
              existingIssue.AssignedTo = assignedTo;
              issueTracker.IssueSetByAssignedTo.Add(existingIssue);
            }
            if (statusIndexObj != null && existingIssue.Status != status)
            {
              issueTracker.IssueSetByStatus.Remove(existingIssue);
              existingIssue.Status = status;
              issueTracker.IssueSetByStatus.Add(existingIssue);
            }
            if (resolutionIndexObj != null && existingIssue.FixResolution != resolution)
            {
              //issueTracker.IssueSetByStatus.Remove(existingIssue);
              existingIssue.FixResolution = resolution;
              //issueTracker.IssueSetByStatus.Add(existingIssue);
            }
            if (updatedAttachments != null)
              foreach (Attachment attachment in updatedAttachments)
              {
                attachment.IssueAttachedTo = new WeakIOptimizedPersistableReference<Issue>(existingIssue);
                existingIssue.Attachments.Add(attachment);
              }
          }
          session.Commit();
        }
      }
      catch (System.Exception ex)
      {
        Console.WriteLine(ex.ToString());
      }
    }