public Task <DTOs.GeneralHubResponseObject> GeneralHubIncoming(DTOs.GeneralHubRequestObject RequestData) { RequestData.ConnectionId = Context.ConnectionId; RequestData.User = Context.User; InitializeCulture(Context.Request); return(Task.Run(() => _GeneralHubIncoming(RequestData))); }
public DTOs.GeneralHubResponseObject ProcessIncoming(DTOs.GeneralHubRequestObject Request) { GeneralHubResponseObject result = new GeneralHubResponseObject(); var jconf = JsonConvert.SerializeObject(Request.RequestData); var osRequest = JsonConvert.DeserializeObject <OrderServiceRequesObject>(jconf); var signalRGroup = serviceRepository.GetSignalRGroup(Request.ServiceId); switch (osRequest.Command) { case "StageProduct": var spconf = JsonConvert.SerializeObject(osRequest.CommandData); var spdata = JsonConvert.DeserializeObject <Hubs.ProductDataWrap>(spconf); var res = StageProduct(spdata.Product, Request.ServiceId.ToString(), Request.ConnectionId); result.ResponseData = res; if (res.ErrorNumber == 0) { result.Success = true; } else { result.Success = false; result.ErrorMessage = res.ErrorMessage; } break; case "LoadProducts": var sconf = JsonConvert.SerializeObject(osRequest.CommandData); var searchConfig = JsonConvert.DeserializeObject <Hubs.SearchConfigWrap>(sconf); var user = userRepository.GetUser(Request.User.Identity.Name); var pres = getProducts(user.Id, signalRGroup, searchConfig.SearchConfig); result.ResponseData = pres; break; case "RemoveProduct": var rmspconf = JsonConvert.SerializeObject(osRequest.CommandData); var rmspdata = JsonConvert.DeserializeObject <Hubs.ProductRemoveCommand>(rmspconf); RemoveProduct(rmspdata.Id, signalRGroup, Request.ConnectionId); break; default: result.Success = false; result.ErrorMessage = "Unknown/invalid Command"; break; } return(result); }
public DTOs.GeneralHubResponseObject _GeneralHubIncoming(DTOs.GeneralHubRequestObject RequestData) { DTOs.GeneralHubResponseObject result = new DTOs.GeneralHubResponseObject(); Repositories.ServiceSettingContext sc = new Repositories.ServiceSettingContext(db); var service = sc.GetServiceById(RequestData.ServiceId); if (service != null) { switch (service.ServiceType) { case Enums.EnumServiceType.CrowdMinerCoinIMP: var mrp = Factories.MiningRoomFactory.GetImplementation(Enums.EnumMiningRoomType.CoinIMP); return(new DTOs.GeneralHubResponseObject() { Success = true, ResponseData = mrp.ProcessIncoming(RequestData) }); case Enums.EnumServiceType.CrowdMinerJSECoin: var amrp = Factories.MiningRoomFactory.GetImplementation(Enums.EnumMiningRoomType.JSECoin); return(new DTOs.GeneralHubResponseObject() { Success = true, ResponseData = amrp.ProcessIncoming(RequestData) }); case Enums.EnumServiceType.LuckyGameDefault: var lgmp = Factories.SlotGameFactory.GetImplementation(Enums.EnumSlotGame.LuckyGame); return(new DTOs.GeneralHubResponseObject() { Success = true, ResponseData = lgmp.ProcessIncoming(RequestData.User, RequestData) }); case Enums.EnumServiceType.OrderService: var osmp = Factories.OrderProcessFactory.GetOrderProcessImplementation(Enums.EnumServiceType.OrderService); return(new DTOs.GeneralHubResponseObject() { Success = true, ResponseData = osmp.ProcessIncoming(RequestData) }); default: return(new DTOs.GeneralHubResponseObject() { Success = false, ErrorMessage = "not implemented" }); } } return(new DTOs.GeneralHubResponseObject() { Success = false, ErrorMessage = "undefined ingoming..." }); }
public DTOs.GeneralHubResponseObject ProcessIncoming(DTOs.GeneralHubRequestObject Request) { GeneralHubResponseObject result = new GeneralHubResponseObject(); var jconf = JsonConvert.SerializeObject(Request.RequestData); var mrRequest = JsonConvert.DeserializeObject <MiningRoomRequesObject>(jconf); switch (mrRequest.Command) { case "GetRoomOverview": var overviewData = GetOverview(mrRequest.MiningRoomId); result.Success = true; result.ResponseData = overviewData; break; case "ToggleControls": var dbMiningRoomx = db.MiningRooms.FirstOrDefault(ln => ln.Id == mrRequest.MiningRoomId); if (dbMiningRoomx.ServiceSetting.Owner == Request.User || Request.User.IsInRole("Admin")) { bool isOn = bool.Parse(mrRequest.CommandData.ToString()); dbMiningRoomx.ShowControls = isOn; db.SaveChanges(); var vm = GetOverview(mrRequest.MiningRoomId); SendRoomInfoUpdateToClients(vm, dbMiningRoomx.ServiceSetting.ServiceUrl.ToLower()); } break; case "CreateRoom": result = CreateMiningRoom(Request.User, mrRequest); break; case "UpdateDescription": if (!Request.User.Identity.IsAuthenticated) { result.Success = false; result.ErrorMessage = SignalRService.Localization.BaseResource.Get("MsgLoginFirst"); break; } var dbRoom = db.MiningRooms.FirstOrDefault(ln => ln.Id == mrRequest.MiningRoomId); if (dbRoom == null) { result.Success = false; result.ErrorMessage = "Invalid RoomId"; } if (!Utils.ServiceUtils.IsServiceOwner(dbRoom.ServiceSetting.ID, Request.User.Identity.Name)) { if (!Request.User.IsInRole("Admin")) { result.Success = false; result.ErrorMessage = "No Permission"; break; } } string contentData = ((dynamic)mrRequest.CommandData).Content; string cultureName = ((dynamic)mrRequest.CommandData).Culture; var localizationKey = GetDescriptionKeyForRoom(dbRoom.Id); Repositories.LocalizationRepository localizationRepo = new Repositories.LocalizationRepository(db); if (localizationRepo.Exists(localizationKey, cultureName)) { var dbItem = localizationRepo.Get(localizationKey, cultureName); dbItem.Value = contentData; localizationRepo.Update(dbItem, Request.User.Identity.Name); Localization.UiResources.Instance.removeFromCache(localizationKey, cultureName); result.Success = true; result.Message = "description updated successfuly"; } else { localizationRepo.Create(new Models.LocalizationModel() { CreationDate = DateTime.Now, Archived = false, Culture = cultureName, Key = localizationKey, LastModDate = DateTime.Now, ModUser = Request.User.Identity.Name, TranslationStatus = Enums.EnumTranslationStatus.Undefined, Value = contentData, WasHit = false }, Request.User.Identity.Name); result.Success = true; result.Message = "creating localizationItem success."; } break; default: break; } return(result); }
public DTOs.GeneralHubResponseObject ProcessIncoming(DTOs.GeneralHubRequestObject Request) { GeneralHubResponseObject result = new GeneralHubResponseObject(); return(result); }