Beispiel #1
0
        public void SaveNewTimelogTasks(ObservableCollection <TimelogTask> tlTaskCollection)
        {
            // delete the old ones
            var oldTasks = from TimelogTask tasks in dellAppDB.TimelogTasks
                           select tasks;

            ObservableCollection <TimelogTask> oldTaskCollection = new ObservableCollection <TimelogTask>(oldTasks);

            foreach (TimelogTask oldTask in oldTaskCollection)
            {
                // try to match the UID
                if (!tlTaskCollection.Where(u => u.TimelogTaskUID == oldTask.TimelogTaskUID).Any())
                {
                    //find all worktasks which are using this timelogtask
                    var worktasksUsingOldTask = from WorkTask worktasks in dellAppDB.WorkTasks
                                                where worktasks.TimelogTaskUID == oldTask.TimelogTaskUID
                                                select worktasks;

                    if (worktasksUsingOldTask.Count() > 0)
                    {
                        // set the timelogtask to null
                        ObservableCollection <WorkTask> tlUsingWorktasks = new ObservableCollection <WorkTask>(worktasksUsingOldTask);
                        foreach (WorkTask worktask in tlUsingWorktasks)
                        {
                            worktask.TimelogTask = null;
                        }
                    }
                    dellAppDB.SubmitChanges();
                    dellAppDB.TimelogTasks.DeleteOnSubmit(oldTask);
                }
            }
            dellAppDB.SubmitChanges();

            //insert new ones (or update)
            foreach (TimelogTask newTask in tlTaskCollection)
            {
                if (!oldTaskCollection.Where(u => u.TimelogTaskUID == newTask.TimelogTaskUID).Any())
                {
                    //Insert
                    dellAppDB.TimelogTasks.InsertOnSubmit(newTask);
                }
                else
                {
                    TimelogTask toUpdateTask = oldTaskCollection.Where(u => u.TimelogTaskUID == newTask.TimelogTaskUID).Single();
                    toUpdateTask.TimelogTaskName    = newTask.TimelogTaskName;
                    toUpdateTask.TimelogProjectName = newTask.TimelogProjectName;
                    toUpdateTask.TimelogProjectID   = newTask.TimelogProjectID;
                    toUpdateTask.StartDate          = newTask.StartDate;
                    toUpdateTask.EndDate            = newTask.EndDate;
                }
            }
            dellAppDB.SubmitChanges();
        }
Beispiel #2
0
 public void SetTimelogTasks(ObservableCollection <TimelogProjectManagementService.Task> tasks)
 {
     LastSynchronisationTimestamp = "Last synchronisation: " + DateTime.Now.ToString("yy-MM-dd hh:mm:ss");
     if (tasks != null)
     {
         ObservableCollection <TimelogTask> tlTasks = new ObservableCollection <TimelogTask>();
         foreach (TimelogProjectManagementService.Task task in tasks)
         {
             //Wenn ParentTask vorhanden ist, dann diese nicht anlegen, weil darauf nicht gebucht werden soll
             if (String.IsNullOrEmpty(task.Details.ParentTaskID.ToString()) && !task.Details.IsParent)
             {
                 TimelogTask newTask = new TimelogTask()
                 {
                     TimelogTaskUID     = task.ID.ToString(),
                     TimelogProjectID   = task.Details.ProjectHeader.ID,
                     TimelogProjectName = task.Details.ProjectHeader.Name,
                     TimelogTaskName    = task.Name,
                     EndDate            = task.EndDate,
                     StartDate          = task.StartDate,
                     TimelogTaskID      = task.TaskID
                 };
                 tlTasks.Add(newTask);
             }
             else if (!String.IsNullOrEmpty(task.Details.ParentTaskID.ToString()) && !task.Details.IsParent)
             {
                 TimelogTask newTask = new TimelogTask()
                 {
                     TimelogTaskUID     = task.ID.ToString(),
                     TimelogProjectID   = task.Details.ProjectHeader.ID,
                     TimelogProjectName = task.Details.ProjectHeader.Name,
                     TimelogTaskName    = task.FullName,
                     EndDate            = task.EndDate,
                     StartDate          = task.StartDate,
                     TimelogTaskID      = task.TaskID
                 };
                 tlTasks.Add(newTask);
             }
         }
         TlTaskCollection = tlTasks;
     }
 }
Beispiel #3
0
        private void fillDummyDataInDatabase(DBClass dellAppDB)
        {
            Customer firstCustomer = new Customer() { CustomerID = System.Guid.NewGuid().ToString(), CustomerName = "Krones AG", CustomerShort = "KRO" };
            Customer secondCustomer = new Customer() { CustomerID = System.Guid.NewGuid().ToString(), CustomerName = "MunichRe", CustomerShort = "MR" };
            Customer thirdCustomer = new Customer() { CustomerID = System.Guid.NewGuid().ToString(), CustomerName = "Miltenyi Biotec", CustomerShort = "MB" };
            Customer forthCustomer = new Customer() { CustomerID = System.Guid.NewGuid().ToString(), CustomerName = "Paul Hartmann", CustomerShort = "PH" };
            Customer fifthCustomer = new Customer() { CustomerID = System.Guid.NewGuid().ToString(), CustomerName = "Bell", CustomerShort = "BL" };
            Customer sixthCustomer = new Customer() { CustomerID = System.Guid.NewGuid().ToString(), CustomerName = "Wüstenrot", CustomerShort = "WW" };
            
            dellAppDB.Customer.InsertOnSubmit(firstCustomer);
            dellAppDB.Customer.InsertOnSubmit(secondCustomer);
            dellAppDB.Customer.InsertOnSubmit(thirdCustomer);
            dellAppDB.Customer.InsertOnSubmit(forthCustomer);
            dellAppDB.Customer.InsertOnSubmit(fifthCustomer);
            dellAppDB.Customer.InsertOnSubmit(sixthCustomer);

            dellAppDB.SubmitChanges();

            Project firstProject = new Project() { ProjectID = System.Guid.NewGuid().ToString(), CustomerID = firstCustomer.CustomerID, ProjectCode = "123456M", ProjectShort = "IAM", ProjectName = "IAM Projekt", ProjectDescription = "Implementierung und Konzeption des IAM Projekts", Ident_Project = firstCustomer.CustomerShort + "-IAM" };
            Project secondProject = new Project() { ProjectID = System.Guid.NewGuid().ToString(), CustomerID = secondCustomer.CustomerID, ProjectCode = "223457M", ProjectShort = "IAM", ProjectName = "IAM Projekt", ProjectDescription = "Implementierung und Konzeption des IAM Projekts", Ident_Project = secondCustomer.CustomerShort + "-IAM" };
            Project thirdProject = new Project() { ProjectID = System.Guid.NewGuid().ToString(), CustomerID = firstCustomer.CustomerID, ProjectCode = "123457M", ProjectShort = "REISE", ProjectName = "Reisezeit", ProjectDescription = "Reisezeit für das Projekt", Ident_Project = firstCustomer.CustomerShort + "-REI" };
            Project forthProject = new Project() { ProjectID = System.Guid.NewGuid().ToString(), CustomerID = secondCustomer.CustomerID, ProjectCode = "223456M", ProjectShort = "REISE", ProjectName = "Reisezeit", ProjectDescription = "Reisezeit für das Projekt", Ident_Project = secondCustomer.CustomerShort + "-REI" };
            Project fifthProject = new Project() { ProjectID = System.Guid.NewGuid().ToString(), CustomerID = thirdCustomer.CustomerID, ProjectCode = "323456M", ProjectShort = "IAM", ProjectName = "IAM Projekt", ProjectDescription = "Implementierung und Konzeption des IAM Projekts", Ident_Project = thirdCustomer.CustomerShort + "-IAM" };
            Project sixthProject = new Project() { ProjectID = System.Guid.NewGuid().ToString(), CustomerID = thirdCustomer.CustomerID, ProjectCode = "323457M", ProjectShort = "REI", ProjectName = "Reisezeit", ProjectDescription = "Reisezeit für das Projekt", Ident_Project = thirdCustomer.CustomerShort + "-REI" };


            Timecard firstTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 10", StartDate = new DateTime(2014, 3, 3) };
            Timecard secondTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 09", StartDate = new DateTime(2014, 3, 3).AddDays(-7) };
            Timecard thirdTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 08", StartDate = new DateTime(2014, 3, 3).AddDays(-14) };
            Timecard forthTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 07", StartDate = new DateTime(2014, 3, 3).AddDays(-21) };
            Timecard fifthTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 06", StartDate = new DateTime(2014, 3, 3).AddDays(-28) };
            Timecard sixthTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 05", StartDate = new DateTime(2014, 3, 3).AddDays(-35) };
            Timecard seventhTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 04", StartDate = new DateTime(2014, 3, 3).AddDays(-42) };
            Timecard eigthTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 03", StartDate = new DateTime(2014, 3, 3).AddDays(-49) };
            Timecard ningthTimecard = new Timecard() { TimecardID = System.Guid.NewGuid().ToString(), TimecardName = "KW 21", StartDate = new DateTime(2014, 5, 19) };

            dellAppDB.Projects.InsertOnSubmit(firstProject);
            dellAppDB.Projects.InsertOnSubmit(secondProject);
            dellAppDB.Projects.InsertOnSubmit(thirdProject);
            dellAppDB.Projects.InsertOnSubmit(forthProject);
            dellAppDB.Projects.InsertOnSubmit(fifthProject);
            dellAppDB.Projects.InsertOnSubmit(sixthProject);

            dellAppDB.SubmitChanges();

            dellAppDB.Timecards.InsertOnSubmit(firstTimecard);
            dellAppDB.Timecards.InsertOnSubmit(secondTimecard);
            dellAppDB.Timecards.InsertOnSubmit(thirdTimecard);
            dellAppDB.Timecards.InsertOnSubmit(forthTimecard);
            dellAppDB.Timecards.InsertOnSubmit(fifthTimecard);
            dellAppDB.Timecards.InsertOnSubmit(sixthTimecard);
            dellAppDB.Timecards.InsertOnSubmit(seventhTimecard);
            dellAppDB.Timecards.InsertOnSubmit(eigthTimecard);
            dellAppDB.Timecards.InsertOnSubmit(ningthTimecard);

            dellAppDB.SubmitChanges();

            DEBUG_NewTimecard(dellAppDB, firstTimecard);
            DEBUG_NewTimecard(dellAppDB, secondTimecard);
            DEBUG_NewTimecard(dellAppDB, thirdTimecard);
            DEBUG_NewTimecard(dellAppDB, forthTimecard);
            DEBUG_NewTimecard(dellAppDB, fifthTimecard);
            DEBUG_NewTimecard(dellAppDB, sixthTimecard);
            DEBUG_NewTimecard(dellAppDB, seventhTimecard);
            DEBUG_NewTimecard(dellAppDB, eigthTimecard);
            DEBUG_NewTimecard(dellAppDB, ningthTimecard);

            TimelogTask firstTask = new TimelogTask() { 
                TimelogTaskUID = System.Guid.NewGuid().ToString(), 
                TimelogProjectID = 15, 
                TimelogProjectName = "Allianz", 
                TimelogTaskName = "Implementerung Q4",
                StartDate = new DateTime(2014,10,01), 
                EndDate = new DateTime(2014,12,31)};
            TimelogTask secondTask = new TimelogTask() { 
                TimelogTaskUID = System.Guid.NewGuid().ToString(), 
                TimelogProjectID = 15, 
                TimelogProjectName = "Allianz", 
                TimelogTaskName = "Implementerung Q3",
                StartDate = new DateTime(2014,07,01), 
                EndDate = new DateTime(2014,09,30)};
            TimelogTask thirdTask = new TimelogTask() { 
                TimelogTaskUID = System.Guid.NewGuid().ToString(), 
                TimelogProjectID = 16, 
                TimelogProjectName = "MunichRe",
                TimelogTaskName = "Implementerung",
                StartDate = new DateTime(2014, 01, 01),
                EndDate = new DateTime(2014, 09, 30)};
            TimelogTask forthTask = new TimelogTask()
            {
                TimelogTaskUID = System.Guid.NewGuid().ToString(),
                TimelogProjectID = 15,
                TimelogProjectName = "Allianz",
                TimelogTaskName = "Implementerung Q4-1",
                StartDate = new DateTime(2014, 10, 01),
                EndDate = new DateTime(2014, 12, 31)
            };
            TimelogTask fifthTask = new TimelogTask()
            {
                TimelogTaskUID = System.Guid.NewGuid().ToString(),
                TimelogProjectID = 15,
                TimelogProjectName = "Allianz",
                TimelogTaskName = "Implementerung Q4-2",
                StartDate = new DateTime(2014, 10, 01),
                EndDate = new DateTime(2014, 12, 31)
            };
            TimelogTask sixthTask = new TimelogTask()
            {
                TimelogTaskUID = System.Guid.NewGuid().ToString(),
                TimelogProjectID = 15,
                TimelogProjectName = "Allianz",
                TimelogTaskName = "Implementerung Q4-3",
                StartDate = new DateTime(2014, 10, 01),
                EndDate = new DateTime(2014, 12, 31)
            };

            dellAppDB.TimelogTasks.InsertOnSubmit(firstTask);
            dellAppDB.TimelogTasks.InsertOnSubmit(secondTask);
            dellAppDB.TimelogTasks.InsertOnSubmit(thirdTask);
            dellAppDB.TimelogTasks.InsertOnSubmit(forthTask);
            dellAppDB.TimelogTasks.InsertOnSubmit(fifthTask);
            dellAppDB.TimelogTasks.InsertOnSubmit(sixthTask);
            dellAppDB.SubmitChanges();
        
        }