Пример #1
0
 public void UpdateProject(EditedProject newValues)
 {
   try
   {
     string dataPath = HttpContext.Current.Server.MapPath("~/tracker");
     using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
     {
       session.BeginUpdate();
       if (newValues.Id == 0)
       {
         if (newValues.Name == null)
           Console.WriteLine("Project null storeName detected in Update method");
         else
         {
           IssueTracker issueTracker = session.AllObjects<IssueTracker>(false).FirstOrDefault();
           User user = lookupUser(issueTracker, session);
           Project newProject = new Project(user, newValues.Name, newValues.Description);
           session.Persist(newProject);
           issueTracker.ProjectSet.Add(newProject);
         }
       }
       else
       {
         Project existingProject = (Project)session.Open(newValues.Id);
         existingProject.Name = newValues.Name;
         existingProject.Description = newValues.Description;
       }
       session.Commit();
       s_sharedReadOnlySession.ForceDatabaseCacheValidation();
     }
   }
   catch (System.Exception ex)
   {
     this.errorLabel.Text = ex.ToString();
   }
 }
Пример #2
0
 public void InsertProject(EditedProject newValues)
 {
   newValues.Id = 0;
   newValues.Oid = "";
   newValues.Name = "";
   newValues.Description = "";
 }
Пример #3
0
 public void UpdateProject(EditedProject newValues)
 {
   try
   {
     using (SessionNoServer session = new SessionNoServer(dataPath, 2000, true, true))
     {
       session.BeginUpdate();
       if (newValues.Id == 0)
       {
         if (newValues.Name == null)
           Console.WriteLine("Project null storeName detected in Update method");
         else
         {
           IssueTracker issueTracker = (IssueTracker)session.Open(IssueTracker.PlaceInDatabase, 1, 1, false);
           User user = lookupUser(issueTracker, session);
           Project newProject = new Project(user, newValues.Name, newValues.Description);
           Placement placer = new Placement(newProject.PlacementDatabaseNumber, 1, 1, 10000, 10000);
           newProject.Persist(placer, session);
           issueTracker.ProjectSet.Add(newProject);
         }
       }
       else
       {
         Project existingProject = (Project)session.Open(newValues.Id);
         existingProject.Name = newValues.Name;
         existingProject.Description = newValues.Description;
       }
       session.Commit();
     }
   }
   catch (System.Exception ex)
   {
     this.errorLabel.Text = ex.ToString();
   }
 }