/// <summary>
        /// Inserts / Updates list of DoctorInfos.
        /// </summary>
        /// <param name="doctors">List of DoctorInfos</param>
        public static int SetDoctors(List <DoctorInfo> doctors)
        {
            int count = 0;

            foreach (DoctorInfo doctor in doctors)
            {
                DoctorInfo doc = DoctorInfoProvider.GetDoctorInfo(doctor.DoctorCodeName);

                if (doc == null)
                {
                    DoctorInfoProvider.SetDoctorInfo(doctor);
                }
                else
                {
                    doc.DoctorFirstName    = doctor.DoctorFirstName;
                    doc.DoctorLastName     = doctor.DoctorLastName;
                    doc.DoctorEmail        = doctor.DoctorEmail;
                    doc.DoctorLastModified = DateTime.Now;
                    DoctorInfoProvider.SetDoctorInfo(doc);
                    count++;
                }
            }

            return(count);
        }
Exemplo n.º 2
0
        public string Execute(TaskInfo ti)
        {
            string result = "";

            try
            {
                // Load path from TaskData property
                string filePath = FileHelper.GetFullFilePhysicalPath(ti.TaskData.Trim());

                if (File.Exists(filePath))
                {
                    // Read all lines
                    var lines = File.ReadAllLines(filePath);

                    var doctors = new List <DoctorInfo>();

                    // Loop through each line and get individual fields: column0 = FisrtName, column1 = LastName, column2 = Email, column3 = Number, column4 = Speciality
                    foreach (var line in lines)
                    {
                        var fields = line.Split(',');

                        // Create new doctor
                        var doctor = new DoctorInfo()
                        {
                            DoctorFirstName = fields[0],
                            DoctorLastName  = fields[1],
                            DoctorEmail     = fields[2],
                            DoctorCodeName  = fields[3],
                            DoctorSpecialty = fields[4]
                        };

                        // Add doctor to a list
                        doctors.Add(doctor);
                    }

                    // Set all doctors
                    int inserted = DoctorInfoProvider.SetDoctors(doctors);

                    // Doctors were successfully imported
                    result = string.Format("{0} new doctor(s) was/were imported.", inserted);
                }
                else
                {
                    // Prepare error message.
                    result = string.Format("File '{0}' does not exist.", filePath);
                }
            }
            catch (Exception e)
            {
                result = e.Message;
            }

            // Logs the execution of the task in the event log.
            Service.Resolve <IEventLogService>().LogInformation("DoctorsAppointment", "IMPORT", result);


            // Return result of scheduled task execution.
            return(result);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the object using appropriate provider.
 /// </summary>
 protected override void SetObject()
 {
     DoctorInfoProvider.SetDoctorInfo(this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deletes the object using appropriate provider.
 /// </summary>
 protected override void DeleteObject()
 {
     DoctorInfoProvider.DeleteDoctorInfo(this);
 }