예제 #1
0
 public AnimalAppointments()
 {
     _storageService   = new StorageService();
     _userService      = new UserService();
     _consultType      = new AppointmentCategory();
     _functionsService = new FirebaseFunctionsService(this, this);
 }
예제 #2
0
        public void Add(AppointmentCategoryDTO appointmentCategory, int appointmentCategoryId)
        {
            AppointmentCategory model = _mapper.Map <AppointmentCategory>(appointmentCategory);

            model.CreationDate = DateTime.Now;
            model.CreatedBy    = appointmentCategoryId;
            dbset.Add(model);
        }
예제 #3
0
        public void Update(AppointmentCategoryDTO appointmentCategory, int appointmentCategoryId)
        {
            AppointmentCategory model = _mapper.Map <AppointmentCategory>(appointmentCategory);

            model.ModifiedDate = DateTime.Now;
            model.ModifiedBy   = appointmentCategoryId;

            entities.Entry(model).State = EntityState.Modified;
            entities.Entry(model).Property(m => m.CreatedBy).IsModified    = false;
            entities.Entry(model).Property(m => m.CreationDate).IsModified = false;
        }
예제 #4
0
 public Appointment(
     IDate BeginDate,
     ITime BeginTime,
     IDate EndDate,
     ITime EndTime,
     string Owner,
     ILocation Location,
     AppointmentCategory category,
     string details)
 {
     this.BeginDate = BeginDate;
     this.BeginTime = BeginTime;
     this.EndDate   = EndDate;
     this.EndTime   = EndTime;
     this.Owner     = Owner;
     this.Location  = Location;
     this.Category  = category;
     this.Details   = details;
 }
예제 #5
0
 public AppointmentBuilder(
     Date BeginDate,
     Time BeginTime,
     Date EndDate,
     Time EndTime,
     AppointmentCategory category,
     string Owner,
     string Details,
     mko.BI.Bo.Addresses.Location Location
     )
 {
     _Owner     = Owner;
     _beginDate = BeginDate;
     _beginTime = BeginTime;
     _endDate   = EndDate;
     _endTime   = EndTime;
     _cat       = category;
     _details   = Details;
     _loc       = Location;
 }
예제 #6
0
        public async Task DocStore_Index()
        {
            var t = new Appointment(
                BeginDate: new Date(2017, 5, 15),
                BeginTime: new Time(9, 0, 0),
                EndDate: new Date(2017, 5, 15),
                EndTime: new Time(17, 0, 0),
                category: AppointmentCategory.@private,
                details: "MVC Kurs",
                Location: new mko.BI.Bo.Addresses.Location()
            {
                City = "Düsseldorf", Country = "de"
            },
                Owner: "ich");

            string id = docs.CreateDocHashId(t);
            await docs.PutAsync(id, t);

            await index.AddToIndexAsync(id, t);

            // Allgemeine Termine anlegen
            for (int jahr = 2015; jahr < 2030; jahr++)
            {
                foreach (var tupel in Appointment.RepeatingAppointments)
                {
                    var app = new Appointment(
                        BeginDate: new Date(jahr, tupel.Item2, tupel.Item1),
                        BeginTime: new Time(0),
                        EndDate: new Date(jahr, tupel.Item2, tupel.Item1),
                        EndTime: new Time(23, 59, 59),
                        category: tupel.Item3,
                        details: tupel.Item4,
                        Owner: "alle",
                        Location: new mko.BI.Bo.Addresses.Location());

                    id = docs.CreateDocHashId(app);

                    await docs.PutAsync(id, app);

                    await index.AddToIndexAsync(id, app);
                }
            }

            await index.SaveChangesAsync();

            // Abfragen
            var qb = index.CreateQueryBuilder();

            qb.Between = new BI.Bo.Interval <DateTime>(new DateTime(2017, 1, 1), new DateTime(2018, 1, 1));

            var sob = qb.GetSortOrderBuilder();

            sob.OrderByCategory(false);
            sob.OrderByBegin(true);

            var fss = sob.GetFilteredSortedSet();

            Assert.IsFalse(0 == fss.Count());

            var set = fss.Get();


            AppointmentCategory old_cat = AppointmentCategory.@private;
            IDate old_date = new Date(2100);

            foreach (var key in set)
            {
                var app = await docs.GetAsync(key);

                Debug.WriteLine(app.Category + ", " + app.BeginDate.ToStr() + "T" + app.BeginTime.ToStr() + ": " + app.Details);

                if (old_cat == app.Category)
                {
                    Assert.IsTrue(old_date.ToDateTime().Ticks >= app.BeginDate.ToDateTime().Ticks);
                    old_date = app.BeginDate;
                }
                else
                {
                    old_date = new Date(2100);
                    old_cat  = app.Category;
                }
            }
        }
        public void addAppointment()
        {
            appointmentName = AppointmentName.Text;
            appointmentDate = AppointmentDate;

            appointmentTimeFrom       = AppointmentTimeFrom;
            appointmentTimeTo         = AppointmentTimeTo;
            appointmentLocation       = AppointmentLocation.Text;
            appointmentDescription    = AppointmentDescription.Text;
            appointmentAdditionalNote = AppointmentAdditionalNote.Text;
            appointmentPriorityLevel  = AppointmentPriorityLevel.Text;
            appointmentCategory       = AppointmentCategory;
            appointmentContact        = AppointmentContact.Text;
            appointmentDataGridView   = AppointmentDataGridView;

            try
            {
                SqlConnection databaseConnection = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;Integrated Security=True;database=master");
                databaseConnection.Open();

                var appointmentCreatedTime = DateTime.Now;
                //string formattedTime = time.ToString("yyyy, MM, dd, hh, mm, ss");

                //get hours,minutes, seconds counted
                DateTime startTime = Convert.ToDateTime(appointmentTimeFrom.Value);
                DateTime endTime   = Convert.ToDateTime(appointmentTimeTo.Value);

                TimeSpan span = endTime.Subtract(startTime);

                int hoursDifference   = span.Hours;
                int minutesDifference = span.Minutes;
                int secondsDifference = span.Seconds;

                string        checkExistQuery      = "SELECT appointment_id FROM appointment_record WHERE appointment_name ='" + appointmentName + "';";
                SqlCommand    checkExistcommand    = new SqlCommand(checkExistQuery, databaseConnection);
                SqlDataReader checkExistDataReader = checkExistcommand.ExecuteReader();


                if (checkExistDataReader.Read())
                {
                    MessageBox.Show("Record data by appointment name already exist", "Add Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    checkExistDataReader.Close();
                    //checkExistDataReader.Dispose();
                }
                else
                {
                    checkExistDataReader.Close();

                    string appointmentAddQuery = "INSERT INTO appointment_record(appointment_name,appointment_date," +
                                                 "time_from,time_to,location,description," +
                                                 "category,additional_note,priority_level,created_date_time,updated_date_time,contact_name) " +
                                                 "VALUES('" + appointmentName + "','" + appointmentDate.Text + "','" + appointmentTimeFrom.Text + "','"
                                                 + appointmentTimeTo.Text + "','"
                                                 + appointmentLocation + "','" + appointmentDescription + "','"
                                                 + AppointmentCategory.ToString() + "','" + appointmentAdditionalNote + "','"
                                                 + appointmentPriorityLevel + "','" + appointmentCreatedTime + "','"
                                                 + appointmentCreatedTime + "','" + appointmentContact + "');";

                    SqlCommand appointmentAddCommand = new SqlCommand(appointmentAddQuery, databaseConnection);
                    appointmentAddCommand.ExecuteNonQuery();

                    string checkAddedRecordQuery = "SELECT appointment_id FROM appointment_record WHERE appointment_name='" + appointmentName + "' ;";

                    SqlCommand    checkAddedRecordCommand = new SqlCommand(checkAddedRecordQuery, databaseConnection);
                    SqlDataReader AddedRecordReader       = checkAddedRecordCommand.ExecuteReader();

                    string addStatus = "";
                    switch (AddedRecordReader.HasRows)
                    {
                    case true:
                        MessageBox.Show("Appointment : " + appointmentName + " added successfully. ", "Add Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        AddedRecordReader.Close();
                        addStatus = "created successfully.";
                        break;

                    case false:
                        MessageBox.Show("Appointment : " + appointmentName + " add failed. ", "Add Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        AddedRecordReader.Close();
                        addStatus = "creation failed.";
                        break;
                    }

                    string auditTraceQuery = "INSERT INTO audit_trace(description,traced_page,traced_task,created_date_time)"
                                             + "VALUES('Appointment " + appointmentName + "" + addStatus + "','Appointment Page','Add','" + appointmentCreatedTime + "');";

                    SqlCommand auditTraceAddCommand = new SqlCommand(auditTraceQuery, databaseConnection);
                    auditTraceAddCommand.ExecuteNonQuery();

                    string checkAuditTraceQuery = "SELECT audit_id FROM Audit_Table WHERE created_date_time='" + appointmentCreatedTime + "' ;";

                    SqlCommand    checkAuditTraceCommand = new SqlCommand(checkAddedRecordQuery, databaseConnection);
                    SqlDataReader AuditTraceReader       = checkAuditTraceCommand.ExecuteReader();

                    switch (AuditTraceReader.HasRows)
                    {
                    case true:
                        Console.WriteLine("Auidt trace for add task created successfully.");
                        AuditTraceReader.Close();
                        break;

                    case false:
                        Console.WriteLine("Audit trace for add task creation failed.");
                        AuditTraceReader.Close();
                        break;
                    }

                    string         refreshGridQuery   = "SELECT * FROM appointment_record";
                    SqlCommand     refreshGridCommand = new SqlCommand(refreshGridQuery, databaseConnection);
                    SqlDataAdapter dataAdapter        = new SqlDataAdapter(refreshGridCommand);
                    DataTable      dataTable          = new DataTable();
                    dataAdapter.Fill(dataTable);

                    appointmentDataGridView.DataSource = new BindingSource(dataTable, null);

                    int appointmentDay   = appointmentDate.Value.Day;
                    int appointmentMonth = appointmentDate.Value.Month;
                    int appointmentYear  = appointmentDate.Value.Year;

                    string appointmentPredictPurposeQuery = "INSERT INTO appointment_prediction_purpose(appointment_name,date_from,year,month,day," +
                                                            "hours_count,minutes_count,seconds_count,created_date_time,updated_date_time)"
                                                            + "VALUES('" + appointmentName + "','" + appointmentDate.Text + "','"
                                                            + appointmentYear + "','" + appointmentMonth + "','" + appointmentDay + "','"
                                                            + hoursDifference + "','" + minutesDifference + "','" + secondsDifference + "','"
                                                            + appointmentCreatedTime + "','" + appointmentCreatedTime + "');";

                    SqlCommand appointmentPredictPurposeCommand = new SqlCommand(appointmentPredictPurposeQuery, databaseConnection);
                    appointmentPredictPurposeCommand.ExecuteNonQuery();

                    databaseConnection.Close();
                }
            }
            catch (SqlException producedException)
            {
                MessageBox.Show("Failed function(s) detected." + Environment.NewLine + "Detailed Information: " + producedException.Message, "Add Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }