public ActionResult CreateEdit(ServiceViewModel model) { try { if (ModelState.IsValid) { if (ServiceDataAccess.Update(model)) { return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = ServiceDataAccess.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Lengkapi!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, ex.Message }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Obtener una lista de pares Service/Cantidad de clicks. /// </summary> /// <param name="store">La tienda a la cual computar estadísticas.</param> /// <param name="session">El identificador de sesión del cliente móvil.</param> /// <returns>Un lista de pares nombre/valor.</returns> public List <DictionaryEntry> GetCustomersAccessAmountByStore(StoreEntity store, string session) { List <UserActionEntity> userActionsPartial = new List <UserActionEntity>(new UserActionDataAccess().LoadWhere(UserActionEntity.DBActionType, 0, false, OperatorType.Equal)); Dictionary <int, DictionaryEntry> serviceGroupPartial = new Dictionary <int, DictionaryEntry>(); // Agrupamos por servicio y contamos foreach (UserActionEntity uae in userActionsPartial) { // Las tiendas deben ser las mismas ServiceEntity service = new ServiceDataAccess().Load(uae.IdService, true, null); if (service.IdStore == store.Id) { DictionaryEntry nameValue; if (serviceGroupPartial.TryGetValue(uae.IdService, out nameValue)) { nameValue.Value = Convert.ToString(Convert.ToInt32(nameValue.Value, CultureInfo.InvariantCulture) + 1, CultureInfo.InvariantCulture); serviceGroupPartial[uae.IdService] = nameValue; } else { nameValue = new DictionaryEntry(); nameValue.Key = service.Name; nameValue.Value = "1"; serviceGroupPartial.Add(uae.IdService, nameValue); } } } List <DictionaryEntry> listOfServiceAccesses = new List <DictionaryEntry>(serviceGroupPartial.Values); return(listOfServiceAccesses); }
private static double AppraiseByStore(CustomerEntity customer, CategoryEntity category) { int count = 0; List <UserActionEntity> actions = new List <UserActionEntity>(new UserActionDataAccess().LoadByCustomerCollection(customer.Id)); foreach (UserActionEntity action in actions) { if (action.ActionType == 0) { // Para cada petición de servicio, verificar si la tienda posee la categoría. ServiceEntity consumedService = new ServiceDataAccess().Load(action.IdService, false); StoreEntity serviceStore = new StoreDataAccess().Load(consumedService.IdStore, true); foreach (StoreCategoryEntity storeCategory in serviceStore.StoreCategory) { if (storeCategory.Category.Id == category.Id) { count++; } } } } return(count / actions.Count); }
/// <summary> /// Obtiene una lista de pares Service/Cantidad de tiempo. /// </summary> /// <param name="session">El identificador de sesión del cliente móvil.</param> /// <returns>Un lista de pares nombre/valor.</returns> public List <DictionaryEntry> GetCustomersTimeAmount(string session) { List <UserActionEntity> userActionsPartial = new List <UserActionEntity>(new UserActionDataAccess().LoadWhere(UserActionEntity.DBActionType, 0, false, OperatorType.Equal)); Dictionary <int, DictionaryEntry> serviceGroupPartial = new Dictionary <int, DictionaryEntry>(); // Agrupamos por servicio y contamos foreach (UserActionEntity uae in userActionsPartial) { ServiceEntity service = new ServiceDataAccess().Load(uae.IdService, true, null); DictionaryEntry nameValue; // Grupo de servicios if (serviceGroupPartial.TryGetValue(uae.IdService, out nameValue)) { nameValue.Value = (TimeSpan)nameValue.Value + (uae.Stop - uae.Start); serviceGroupPartial[uae.IdService] = nameValue; } else { nameValue = new DictionaryEntry(); nameValue.Key = service.Name; nameValue.Value = uae.Stop - uae.Start; serviceGroupPartial.Add(uae.IdService, nameValue); } } List <DictionaryEntry> listOfServiceAccesses = new List <DictionaryEntry>(serviceGroupPartial.Values); return(listOfServiceAccesses); }
/// <summary> /// Actualiza los archivos de ensamblado en la entidad de servicio. /// </summary> /// <param name="serviceModel">El modelo de servicio desde el cuál se actualizan los datos.</param> /// <param name="fileName">El nombre de archivo.</param> /// <param name="clientVersionFileName">El nombre del archivo del cliente</param> /// <param name="sessionIdentifier">Sesión de usuario</param> /// <returns>True si se guardó con éxito.</returns> static private bool SaveCustomServiceModel(CustomerServiceDataEntity serviceModel, string fileName, string clientVersionFileName, string sessionIdentifier) { try { ServiceDataAccess serviceDataAccess = new ServiceDataAccess(); ServiceEntity serviceEntity = serviceModel.Service; if (serviceEntity == null) { Service serviceLogic = new Service(); serviceEntity = serviceLogic.GetService(serviceModel.IdService, false, sessionIdentifier); } serviceEntity.Deployed = true; serviceEntity.PathAssemblyServer = Path.GetFileNameWithoutExtension(fileName) + ".dll"; serviceEntity.RelativePathAssembly = Path.GetFileNameWithoutExtension(clientVersionFileName) + ".dll"; serviceDataAccess.Save(serviceEntity); return(true); } catch (UtnEmallDataAccessException error) { Debug.WriteLine("FAILURE : While updating custom service entity. ERROR : " + error.Message); return(false); } catch (UtnEmallBusinessLogicException error) { Debug.WriteLine("FAILURE : While updating custom service entity. ERROR : " + error.Message); return(false); } }
public static void SetIsActive(int serviceId, bool isActive) { var serviceInDatabase = Get(serviceId); if (serviceInDatabase == null) { throw new Exception("Mã dịch vụ không hợp lệ!"); } ServiceDataAccess.SetIsActive(serviceInDatabase, isActive); }
public ActionResult DeleteConfirm(int id) { if (ServiceDataAccess.Delete(id)) { return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Success" }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false, message = "Error" }, JsonRequestBehavior.AllowGet)); }
private void InitCustomServices() { try { // Cargar los modelos de datos y verificar los ensamblados ServiceDataAccess serviceDataAccess = new ServiceDataAccess(); Collection <ServiceEntity> services = serviceDataAccess.LoadAll(true); foreach (ServiceEntity service in services) { string assemblyFileName = service.PathAssemblyServer; if (assemblyFileName != null) { if (File.Exists(Path.Combine(ServiceBuilder.AssembliesFolder, assemblyFileName))) { Type[] servicesTypes = ServiceBuilder.GetCustomServiceTypes(assemblyFileName); Binding serviceBinding = new BasicHttpBinding(); if (PublishCustomService(servicesTypes[0], servicesTypes[1], serviceBinding)) { Debug.WriteLine("SUCCESS : custom service published."); } else { Debug.WriteLine("FAILURE : trying to publish custom service."); } } else { CustomerServiceDataDataAccess customerServiceData = new CustomerServiceDataDataAccess(); CustomerServiceDataEntity customerService = customerServiceData.Load(service.IdCustomerServiceData, true); ServiceBuilder builder = new ServiceBuilder(); service.Deployed = false; customerService.Service = service; builder.BuildAndImplementCustomService(customerService, serverSession); } } } } catch (DataException dataError) { Debug.WriteLine("ERROR : Data exception running infrastructure services. MESSAGE : " + dataError.Message); } catch (IOException ioError) { Debug.WriteLine("ERROR : IO error running infrastructure services. MESSAGE : " + ioError.Message); } }
private static double AppraiseByService(CustomerEntity customer, CategoryEntity category) { int count = 0; List <UserActionEntity> actions = new List <UserActionEntity>(new UserActionDataAccess().LoadByCustomerCollection(customer.Id)); foreach (UserActionEntity action in actions) { if (action.ActionType == 0) { ServiceEntity consumedService = new ServiceDataAccess().Load(action.IdService, true); foreach (ServiceCategoryEntity serviceCategory in consumedService.ServiceCategory) { if (serviceCategory.Category.Id == category.Id) { count++; } } } } return(count / actions.Count); }
public ActionResult Delete(int id) { return(View(ServiceDataAccess.GetById(id))); }
public ActionResult List() { List <ServiceViewModel> model = ServiceDataAccess.GetAll(); return(View(model)); }
public static IEnumerable <Service> Get() => ServiceDataAccess.Get();
public static void Delete(int serviceId) { var serviceInDatabase = GetAndCheckValid(serviceId); ServiceDataAccess.Delete(serviceInDatabase); }
public static Task <Service> Update(Service service) { var serviceInDatabase = GetAndCheckValid(service.Id); return(ServiceDataAccess.Update(serviceInDatabase, service)); }
public static Task <Service> Add(Service service) => ServiceDataAccess.Add(service);
public Service() { serviceDataAccess = new ServiceDataAccess(); }
public static Service Get(int serviceId) => ServiceDataAccess.Get(serviceId);