public List <SchedulerEvent> GetSchedulerEvents(DateTime?from, DateTime?to, int unitId) { var result = new List <SchedulerEvent>(); var now = DateTime.Now; var dataService = new QNomyDataService(); var appointments = dataService.GetAppointments(from, to); CustomizeData customizeData = GetCustomizeData(unitId); var calendarStages = dataService.GetClendarStages(customizeData.ConfigId); var statusMapping = GetMappingCalendarStageTypeToEntityStatus(); foreach (var app in appointments) { app.CalendarStageType = statusMapping[app.CurrentEntityStatus]; int?stageId = GetStageByServiceId(app.ServiceId, app.CalendarStageType, calendarStages, customizeData); if (!stageId.HasValue) { continue; } app.StageId = stageId.Value; SchedulerEvent se = ToScheduleEvent(app); result.Add(se); } return(result); }
/// <summary> /// Returns id of stage for "InService" calendar stage type, returns null if not one valid type is found. /// </summary> /// <param name="serviceId"></param> /// <param name="customizeData"></param> /// <returns></returns> public int?GetInServiceStageByServiceId(int serviceId, CustomizeData customizeData) { int?result = null; foreach (var stage in customizeData.Stages) { if (stage.StageType != CalendarStageType.InService) { continue; } foreach (var stageService in stage.Services) { if (stageService.ServiceId == serviceId) { result = stage.Id; break; } } if (result.HasValue) { break; } } return(result); }
internal AppointmentChangedResult AppointmentCancel(int userId, int unitId, SchedulerEvent schedulerEvent) { var dataService = new QNomyDataService(); AppointmentChangedResult result = new AppointmentChangedResult(); int processId = schedulerEvent.ProcessId; ProcessCancelCaseResults cancelResult = Process.CancelCase(processId, userId, 0); if (cancelResult.CurrentProcessId > 0) { schedulerEvent.ProcessId = cancelResult.CurrentProcessId; CustomizeData customizeData = GetCustomizeData(unitId); var calendarStages = dataService.GetClendarStages(customizeData.ConfigId); AdjustStageType(schedulerEvent, calendarStages, customizeData); result.EventData = schedulerEvent; } List <AppUser.UserStatus> okStatus = new List <AppUser.UserStatus>() { AppUser.UserStatus.Idle, AppUser.UserStatus.Unknown, AppUser.UserStatus.SignedOut }; if (!okStatus.Contains(cancelResult.UserStatus)) { throw new DataException($"Not Canceled, user status {cancelResult.UserStatus.ToString()}"); } return(result); }
//private void OnDisable() //{ // Debug.Log("I left you"); // this.enabled = true; // LoadData(); //} void LoadData() { //make a serializer for customizedata var serializer = new XmlSerializer(typeof(CustomizeData)); //while using the file on filepath using (var stream = new FileStream(filePath, FileMode.Open)) { //convert the data from filepath into CustomizeData data = serializer.Deserialize(stream) as CustomizeData; } //assign player managers variables and sprite indexes from the CustomizeData class data playerManager.strCur = data.strCur; playerManager.dexCur = data.dexCur; playerManager.conCur = data.conCur; playerManager.intCur = data.intCur; playerManager.wisCur = data.wisCur; playerManager.charCur = data.charCur; legI = data.legI; armI = data.armI; torsoI = data.torsoI; handI = data.handI; hairI = data.hairI; eyesI = data.eyesI; eyebrowsI = data.eyebrowsI; mouthI = data.mouthI; headI = data.headI; }
private void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } }
internal bool SaveCustomizeData(CustomizeData data) { if (data.UnitId <= 0) { throw new ArgumentException("unit is not defined"); } int sortOrder = 0; var stageIds = new List <int>(); var dataService = new QNomyDataService(); if (data.ConfigId <= 0) { data.ConfigId = dataService.InsertConfigId(data.UnitId); } dataService.DeleteCalendarStageServices(data.ConfigId); var dataNotShownStage = dataService.GetClendarStageByType(data.ConfigId, CalendarStageType.None); if (dataNotShownStage == null) { dataNotShownStage = new CalendarStage() { Name = "None", StageType = CalendarStageType.None, CalendarStageConfigId = data.ConfigId }; dataNotShownStage.Id = dataService.InserCalendarStage(dataNotShownStage); } stageIds.Add(dataNotShownStage.Id); dataService.InsertCalendarStageServices(dataNotShownStage.Id, data.NotShownServices); foreach (var stage in data.Stages) { sortOrder++; stage.SortOrder = sortOrder; dataService.UpdateOrInsertStage(data.ConfigId, stage); stageIds.Add(stage.Id); } dataService.DeleteCalendarStagesExcept(data.ConfigId, stageIds); return(true); }
public void Init(SerializedObject serializedObject, UnityEngine.MonoBehaviour behaviour) { this.serializedObject = serializedObject; #if USE_HOT var appdomain = DllInitByEditor.appdomain; #endif this.behaviour = behaviour; var customizeDataField = GetField(behaviour.GetType(), SerializedKey, BindingFlags.Instance | BindingFlags.NonPublic); if (customizeDataField != null) { customizeData = customizeDataField.GetValue(behaviour) as CustomizeData; if (customizeData == null) { customizeData = new CustomizeData(); customizeDataField.SetValue(behaviour, customizeData); EditorUtility.SetDirty(behaviour); } } else { EditorGUILayout.LabelField($"type:{behaviour.GetType()} not find customizeData!"); return; } }
public int?GetStageByServiceId(int serviceId, CalendarStageType stageType, List <DataService.CalendarStage> calendarStages, CustomizeData customizeData) { int?inServiceStageId = GetInServiceStageByServiceId(serviceId, customizeData); if (!inServiceStageId.HasValue) { return(null); } if (stageType == CalendarStageType.InService) { return(inServiceStageId.Value); } int?result = null; foreach (var stage in calendarStages) { if (stage.StageType == stageType) { result = stage.Id; break; } } return(result); }
private void AdjustStageType(SchedulerEvent theEvent, List <CalendarStage> calendarStages, CustomizeData customizeData) { var qnomyApp = Appointment.Get(theEvent.AppointmentId); var statusMapping = GetMappingCalendarStageTypeToEntityStatus(); theEvent.StageType = statusMapping[qnomyApp.CurrentEntityStatus]; int?stageId = GetStageByServiceId(theEvent.ServiceId, theEvent.StageType, calendarStages, customizeData); theEvent.StageId = stageId ?? -1; var currentService = Service.Get(theEvent.ServiceId); theEvent.ServiceName = currentService.Name; }
internal AppointmentChangedResult AppointmentChanged(int currentUserId, int currentUnitId, int previousStageId, int nextStageId, SchedulerEvent theEvent, int?routeId) { AppointmentChangedResult result = new AppointmentChangedResult(); var dataService = new QNomyDataService(); CustomizeData customizeData = GetCustomizeData(currentUnitId); // qnomy var calendarStages = customizeData.Stages.ToList <CalendarStage>(); //var allCalendarStageServices = customizeData.GetClendarStageServices(); var prevCalendarStageType = GetStageTypeById(previousStageId, calendarStages); var nextCalendarStageType = GetStageTypeById(nextStageId, calendarStages); int previousServiceId = theEvent.ServiceId; RouteResultData routeResult = null; int delegateId = 0; if ((nextCalendarStageType == CalendarStageType.InService) || (prevCalendarStageType != nextCalendarStageType)) { // calendar stage type - is old stageType. if (prevCalendarStageType == CalendarStageType.Completed) { throw new DataException("Already Completed, cannot change"); } switch (nextCalendarStageType) { case CalendarStageType.Completed: ProcessPromoteResults processPromoteResults = Process.Promote(theEvent.ProcessId, currentUserId, delegateId, Process.ProcessPromoteAction.Complete, false); break; case CalendarStageType.Expected: throw new NotSupportedException("Cannot back to expected status"); case CalendarStageType.InService: var nextStage = customizeData.Stages.Find(x => x.Id == nextStageId); if (nextStage == null) { throw new DataException("stage is not valid"); } var servicesInStage = GetServicesIds(nextStage.Services); if (servicesInStage.Count == 0) { throw new DataException("Cannot find any service for this stage"); } if (prevCalendarStageType != CalendarStageType.InService) { if (servicesInStage.Contains(theEvent.ServiceId)) { CallUser(currentUserId, theEvent, delegateId); } else { routeResult = RouteUser(currentUserId, theEvent, dataService, delegateId, servicesInStage, true, routeId); } } else { routeResult = RouteUser(currentUserId, theEvent, dataService, delegateId, servicesInStage, true, routeId); } break; case CalendarStageType.None: throw new InvalidOperationException("Invalid stage is not defined"); case CalendarStageType.Waiting: if (prevCalendarStageType == CalendarStageType.Expected) { ProcessEnqueueAppointmentResults enqueResult = Process.EnqueueAppointment(theEvent.ProcessId, forceEarly: true, forceLate: true); var enqueValidStatuses = new List <ProcessEnqueueAppointmentResults.ProcessEnqueueAppointmentResultsStatus>(); enqueValidStatuses.Add(ProcessEnqueueAppointmentResults.ProcessEnqueueAppointmentResultsStatus.Success); enqueValidStatuses.Add(ProcessEnqueueAppointmentResults.ProcessEnqueueAppointmentResultsStatus.Late); if (!enqueValidStatuses.Contains(enqueResult.Status)) { throw DataException.GetDataException(enqueResult.Status); } break; } if (prevCalendarStageType == CalendarStageType.WaitingCustomerAction) { ProcessStopWaitingForCustomerActionResults stopWaitResult = Process.StopWaitingForCustomerAction(theEvent.ProcessId, currentUserId, delegateId); break; } if (prevCalendarStageType == CalendarStageType.Waiting) { break; } if (prevCalendarStageType == CalendarStageType.InService) { ProcessRequeueInServiceResults requeResult = Process.RequeueInService(theEvent.ProcessId, currentUnitId, delegateId); break; } throw new DataException("Waiting stage does not accessible from this stage"); case CalendarStageType.WaitingCustomerAction: ProcessWaitForCustomerActionResults waitResult = Process.WaitForCustomerAction(theEvent.ProcessId, currentUserId, 0); break; default: throw new InvalidOperationException("Stage is not supported"); } } if (routeResult != null && !routeResult.IsRouted) { result.RouteData = routeResult; return(result); } AdjustStageType(theEvent, calendarStages, customizeData); result.EventData = theEvent; return(result); }
internal CustomizeData GetCustomizeData(int currentUnitId) { var result = new CustomizeData(); var dataService = new QNomyDataService(); result.UnitId = currentUnitId; result.ConfigId = dataService.GetConfigId(currentUnitId); result.NotShownServices = new List <CustomizeStageService>(); result.Stages = new List <CustomizeCalendarStage>(); List <CalendarStage> calendarStages = dataService.GetClendarStages(result.ConfigId); var services = dataService.GetServicesForUnit(currentUnitId); var stageServices = dataService.GetClendarStageServices(result.ConfigId); foreach (var stage in calendarStages) { if (stage.StageType == CalendarStageType.None) { continue; } var calendarStage = new CustomizeCalendarStage { Id = stage.Id, Name = stage.Name, StageType = stage.StageType, SortOrder = stage.SortOrder, IsServiceDefault = stage.IsServiceDefault, CalendarStageConfigId = stage.CalendarStageConfigId }; calendarStage.Services = new List <CustomizeStageService>(); result.Stages.Add(calendarStage); } CustomizeCalendarStage defaultInServiceStageForNotMappedServices = result.Stages.Find(x => x.IsServiceDefault); //can be null; foreach (var service in services) { CustomizeCalendarStage stage = null; CalendarStageService stageForService = stageServices.Find(x => x.ServiceId == service.Id); if (stageForService == null) { stage = defaultInServiceStageForNotMappedServices; } else { stage = result.Stages.Find(x => x.Id == stageForService.CalendarStageId); } if (stage != null && stage.StageType == CalendarStageType.None) { stage = null; } if (stage == null) { result.NotShownServices.Add(new CustomizeStageService() { ServiceId = service.Id, Name = service.Name, CalendarStageId = -1 }); } else { stage.Services.Add(new CustomizeStageService() { ServiceId = service.Id, Name = service.Name, CalendarStageId = stage.Id }); } } return(result); }