public void RunSchedule(ScheduleModel schedule, bool manualRun = false, string username = "******", string termCode = null) { var log = new List <string>(); log.Add("Test Action 5 at: " + DateTime.Now); //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", log); if ((schedule.NextRunDate == null || schedule.NextRunDate == DateTime.MinValue) || schedule.NextRunDate < DateTime.Now || manualRun) { //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", new string[] { "Test Action 6 at: " + DateTime.Now }); var actionClass = Type.GetType(schedule.ActionMethod.Remove(schedule.ActionMethod.LastIndexOf('.')) + ",IAUECProfessorsEvaluation.Service"); if (actionClass != null) { //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", new string[] { "Test Action 7 at: " + DateTime.Now }); var action = schedule.ActionMethod.Remove(0, schedule.ActionMethod.LastIndexOf('.') + 1); var method = actionClass.GetMethod(action, BindingFlags.Static | BindingFlags.Public); if (method != null) { //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", new string[] { "Test Action 8 at: " + DateTime.Now }); schedule.NextRunDate = DateTime.Now.AddMinutes(UtilityFunction.GetTimeLapse(schedule.TimeLapse, schedule.TimeLapseMeasurement)); schedule.LastRunDate = DateTime.Now; _scheduleService.AddOrUpdate(Mapper.Map <Model.Models.Schedule>(schedule)); //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", new string[] { "Test Action 9 at: " + DateTime.Now }); object[] par = new object[] { _termService, _mappingService, _collegeService, _educationalGroupService, _professorService, _educationalClassService, _studentEducationalClassService, _professorScoreService, _indicatorService, _mappingTypeService, _universityLevelMappingService, _educationalGroupScoreService, _logService, _logTypeService, _userService, termCode }; var user = _userService.Get(x => x.Username.ToLower() == username.ToLower()); //System.IO.File.AppendAllLines(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt", new string[] { "Test Action 10 at: " + DateTime.Now }); SyncService.LogSync(_logService, _logTypeService, _userService, user, (int)LogTypeValue.شروع_عملیات_بروزرسانی_داده_ها); method.Invoke(null, par); SyncService.LogSync(_logService, _logTypeService, _userService, user, (int)LogTypeValue.پایان_عملیات_بروزرسانی_داده_ها); } } } }