public JsonResult AssignRooms() { int userid = -1; string token = string.Empty; string message = ""; bool result = false; if (GetToken(out userid, out token)) { string startId = Request.Form["startId"]; string endId = Request.Form["endId"]; string agentId = Request.Form["agentId"]; DSClient client = new DSClient(Models.Const.ApplicationId); try { client.AssignRoomsToAgent(userid, token, int.Parse(startId), int.Parse(endId), int.Parse(agentId)); result = true; } catch (DatabaseException ex) { message = ex.Message; } } return(Json(new { Success = result, Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteRoomRole() { int userid = -1; string token = string.Empty; string message = ""; bool result = false; if (GetToken(out userid, out token)) { string roomId = Request.Form["roomId"]; string roomAdminId = Request.Form["roomAdminId"]; string roomDirId = Request.Form["roomDirId"]; DSClient client = new DSClient(Models.Const.ApplicationId); try { client.DeleteRoomRole(userid, token, int.Parse(roomId), int.Parse(roomAdminId), BuiltIns._9258RoomAdministratorRole.Id); client.DeleteRoomRole(userid, token, int.Parse(roomId), int.Parse(roomDirId), BuiltIns._9258RoomDirectorRole.Id); result = true; } catch (DatabaseException ex) { message = ex.Message; } } return(Json(new { Success = result, Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetMusics(string page, string pageSize) { string message = string.Empty; List <MusicInfo> result = new List <MusicInfo>(); try { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { int start = -1; int p = 0, s = 0; if (int.TryParse(page, out p) && int.TryParse(pageSize, out s)) { start = (p - 1) * s; } List <MusicInfo> musics = client.GetMusics(Models.Const.ApplicationId, userId, token); for (int i = start; i < musics.Count && i < s; i++) { result.Add(musics[i]); } } } catch (Exception exception) { message = exception.Message; } return(Json(new { Rows = result.ToArray() }, JsonRequestBehavior.AllowGet)); }
public JsonResult AssignAgentUserIds(string app, string start, string end, string agent) { int userId = -1; string token = ""; bool result = false; string message = string.Empty; if (GetToken(out userId, out token)) { int a, s, e, ag; if (int.TryParse(app, out a) && int.TryParse(start, out s) && int.TryParse(end, out e) && int.TryParse(agent, out ag)) { DSClient client = new DSClient(Models.Const.ApplicationId); try { client.AssignAgentUserIds(userId, token, a, s, e, ag); result = true; } catch (DatabaseException exception) { message = exception.Message; } } } return(Json(new { Success = result, Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult AddUserIds(string start, string end, string app, string role, string owner, string password, bool isDirect) { int userId = -1; string token = ""; bool result = false; string message = string.Empty; if (GetToken(out userId, out token)) { int s, e, a, r, o; if (int.TryParse(start, out s) && int.TryParse(end, out e) && int.TryParse(app, out a) && int.TryParse(role, out r)) { if (s <= BuiltIns.UserDefinedUserStartId) { return(Json(new { Success = false, Message = "用户Id不能小于100!" }, JsonRequestBehavior.AllowGet)); } o = -1; int.TryParse(owner, out o); DSClient client = new DSClient(Models.Const.ApplicationId); try { client.AddUserIdLists(userId, token, s, e, userId, o, r, a, Utility.GetMD5String(password), isDirect); result = true; } catch (DatabaseException exception) { message = exception.Message; } } } return(Json(new { Success = result, Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetFunctionTree(string test) { int userId; string token; string message = string.Empty; bool success = false; List <TreeNodeModel> nodes = new List <TreeNodeModel>(); if (GetToken(out userId, out token)) { try { DSClient client = new DSClient(Models.Const.ApplicationId); var commands = client.GetCommands(userId, token, "", -1, -1); var myCommands = client.GetRoleCommandsForUser(userId, token, userId); var applications = client.GetApplications(userId, token, "", -1, -1).Where(c => !BuiltIns.ExcludeApplicationIds.Contains(c.Id)).ToList(); var me = client.GetUser(userId, token, userId); Session["Me"] = me; Session["Commands"] = myCommands.Select(t => t.Command_Id); nodes.Add(GetCommandNode(commands, myCommands)); nodes.Add(GetApplicationNode(applications, commands, myCommands)); nodes.Add(GetPersonalNode()); success = true; } catch (DatabaseException exception) { message = exception.Message; } } return(Json(new { Success = success, Rows = nodes.ToArray(), Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult SettleExchangeCache(List <ExchangeHistoryModel> models) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; string message = string.Empty; bool success = false; if (GetToken(out userId, out token)) { List <ExchangeHistory> histories = new List <ExchangeHistory>(); foreach (ExchangeHistoryModel model in models) { if (model.Status == (int)RequestStatus.Submitted) { histories.Add(model.GetConcretModelEntity <ExchangeHistory>()); } } try { client.SettleExchangeCache(userId, token, histories); success = true; } catch (DatabaseException exception) { message = exception.Message; } } return(Json(new { Success = success, Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetExchangeHistoryForSettlement(string page, string pageSize) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; string message = string.Empty; bool success = false; List <ExchangeHistoryModel> models = new List <ExchangeHistoryModel>(); if (GetToken(out userId, out token)) { int start = -1, count = -1; int p = 0, s = 0; if (int.TryParse(page, out p) && int.TryParse(pageSize, out s)) { start = (p - 1) * s + 1; count = s; } try { List <ExchangeHistory> exchangeHistories = client.GetExchangeHistoryForSettlement(userId, token, "Status <> " + (int)RequestStatus.None, start, count); foreach (var history in exchangeHistories) { models.Add(new ExchangeHistoryModel(history)); } success = true; } catch (DatabaseException exception) { message = exception.Message; } } return(Json(new { Success = success, Rows = models.ToArray(), Message = message }, JsonRequestBehavior.AllowGet)); }
public JsonResult ScoreDeposit(string id) { int userid = -1; string token = string.Empty; int score = 0; if (int.TryParse(id, out score)) { if (GetToken(out userid, out token)) { string uid = Request.Form["uid"]; string aid = Request.Form["aid"]; int user = -1, app = -1; if (int.TryParse(uid, out user) && int.TryParse(aid, out app)) { try { DSClient client = new DSClient(Models.Const.ApplicationId); client.ScoreDeposit(userid, token, app, user, score); return(Json(new { Success = true, Score = score }, JsonRequestBehavior.AllowGet)); } catch (DatabaseException exception) { return(Json(new { Success = false, Score = score }, JsonRequestBehavior.AllowGet)); } } } } return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); }
private JsonResult Deposit(string money, bool isAgent) { int userid = -1; string token = string.Empty; int m = 0; if (int.TryParse(money, out m)) { if (GetToken(out userid, out token)) { string uid = Request.Form["uid"]; string aid = Request.Form["aid"]; int user = -1, app = -1; if (int.TryParse(uid, out user) && int.TryParse(aid, out app)) { try { DSClient client = new DSClient(Models.Const.ApplicationId); if (client.Deposit(userid, token, app, user, m, isAgent)) { return(Json(new { Success = true, Money = money }, JsonRequestBehavior.AllowGet)); } } catch (DatabaseException exception) { return(Json(new { Success = false, Message = exception.Message }, JsonRequestBehavior.AllowGet)); } } } } return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Initializes a new instance of the <see cref="EntryValueMaterializationPolicy" /> class. /// </summary> /// <param name="context">The context.</param> /// <param name="entityTrackingAdapter">The entity tracking adapter.</param> /// <param name="lazyPrimitivePropertyConverter">The lazy primitive property converter.</param> /// <param name="nextLinkTable">The next link table.</param> internal EntryValueMaterializationPolicy( IODataMaterializerContext context, EntityTrackingAdapter entityTrackingAdapter, DSClient.SimpleLazy<PrimitivePropertyConverter> lazyPrimitivePropertyConverter, Dictionary<IEnumerable, DataServiceQueryContinuation> nextLinkTable) : base(context, lazyPrimitivePropertyConverter) { this.nextLinkTable = nextLinkTable; this.EntityTrackingAdapter = entityTrackingAdapter; }
public void DeleteEntity(ModelEntity entity) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { DeleteEntity(client, userId, token, entity); } }
public T AddEntity <T>(T entity) where T : ModelEntity { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { return(AddEntity <T>(client, userId, token, entity)); } return(null); }
protected JsonResult SaveEntities <T>(IEnumerable <YoYoJson.JsonModel> models) where T : ModelEntity { string result = string.Empty; bool succeed = false; if (models != null) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { try { foreach (YoYoJson.JsonModel model in models) { T entity = model.GetConcretModelEntity <T>(); if (entity != null) { switch (model.GetEntityState()) { case PersistentState.Changed: UpdateEntity(client, userId, token, entity); break; case PersistentState.Added: UpdateEntity(client, userId, token, entity); break; case PersistentState.Deleted: DeleteEntity(client, userId, token, entity); break; default: break; } } } succeed = true; } catch (DatabaseException error) { result = error.Message; } } } return(Json(new { Success = succeed, Message = result })); }
public JsonResult GetExchangeHistories(string page, string pageSize) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; int total = 0; string message = string.Empty; bool success = false; List <ExchangeHistoryModel> models = new List <ExchangeHistoryModel>(); if (GetToken(out userId, out token)) { int start = -1, count = -1; int p = 0, s = 0; if (int.TryParse(page, out p) && int.TryParse(pageSize, out s)) { start = (p - 1) * s + 1; count = s; } string condition = ""; string appId = Request.Form["aid"]; string exchangeCache = Request.Form["exchangeCache"]; int id = -1; if (int.TryParse(appId, out id)) { condition = "([Application_Id] =" + id + ")"; try { List <ExchangeHistory> exchangeHistories = client.GetExchangeHistories(userId, token, condition, Convert.ToBoolean(exchangeCache), start, count); total = client.GetExchangeHistoryCount(userId, token, "", Convert.ToBoolean(exchangeCache)); exchangeHistories.ForEach(h => { models.Add(new ExchangeHistoryModel(h)); }); success = true; } catch (DatabaseException exception) { message = exception.Message; } } } return(Json(new { Success = success, Rows = models.ToArray(), Total = total, Message = message }, JsonRequestBehavior.AllowGet)); }
public static void Initialize() { log4net.Config.XmlConfigurator.Configure(); dataServiceClient = new DSClient(ApplicationId); serviceToken = dataServiceClient.Login(BuiltIns._9258Administrator.Id, BuiltIns._9258Administrator.Password); cache = new DataServiceCache(ApplicationId); cache.RefreshCache(BuiltIns._9258Administrator.Id, serviceToken); cache.BuildRelationship(); timer.Interval = TimeSpan.FromMinutes(1).TotalMilliseconds; timer.Elapsed += timer_Elapsed; timer.Start(); if (File.Exists(cacheVersionFile)) { var lines = File.ReadLines(cacheVersionFile); cacheVersion = long.Parse(lines.ElementAt(0)) + 1; } File.Delete(cacheVersionFile); File.WriteAllText(cacheVersionFile, cacheVersion.ToString()); }
public JsonResult ResetPassword(int id) { int userid = -1; string token = string.Empty; if (GetToken(out userid, out token)) { try { DSClient client = new DSClient(Models.Const.ApplicationId); string pwd = client.ResetPassword(userid, token, id); return(Json(new { Success = true, Password = pwd }, JsonRequestBehavior.AllowGet)); } catch (DatabaseException exception) { return(Json(new { Success = false, password = string.Empty }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); }
public FileContentResult GetImage(int id) { if (id > 0) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { try { Image img = client.GetImage(userId, token, id); return(File(img.TheImage, "image/jpeg")); } catch { } } } return(File(GetBytes(NotFound), "image/jpge")); }
public JsonResult UploadMusics(List <Byte[]> toUpload) { string message = string.Empty; try { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { client.UploadMusics(Models.Const.ApplicationId, userId, token, toUpload); message = "Success"; } } catch (Exception exception) { message = exception.Message; } return(Json(new { Message = message }, JsonRequestBehavior.AllowGet)); }
private JsonResult GetApplicationsForCommand(int cmdid, bool includeAll = false) { int userId = -1; string token = string.Empty; bool success = false; string message = string.Empty; List <ApplicationModel> models = null; if (GetToken(out userId, out token)) { try { DSClient client = new DSClient(Models.Const.ApplicationId); var apps = client.GetApplicationsForCommand(userId, token, cmdid); models = new List <ApplicationModel>(); if (apps != null && apps.Count() > 0) { foreach (var app in apps) { Application application = app as Application; if (!includeAll) { if (BuiltIns.ExcludeApplicationIds.Contains(application.Id)) { continue; } } models.Add(new ApplicationModel(application)); } success = true; } } catch (DatabaseException exception) { message = exception.Message; } return(Json(new { Success = success, Rows = models.ToArray(), Message = message }, JsonRequestBehavior.AllowGet)); } return(null); }
public JsonResult GetMyCommands(int?appid) { int userId; string token; string message = string.Empty; bool success = false; if (GetToken(out userId, out token)) { try { DSClient client = new DSClient(Models.Const.ApplicationId); var myCommands = client.GetRoleCommandsForUser(userId, token, userId); bool hasAll = myCommands.FirstOrDefault(rc => rc.Application_Id == BuiltIns.AllApplication.Id && rc.Command_Id == BuiltIns.AllCommand.Id) != null; if (!hasAll && appid.HasValue) { hasAll = myCommands.FirstOrDefault(rc => rc.Application_Id == appid.Value && rc.Command_Id == BuiltIns.AllCommand.Id) != null; } success = true; if (hasAll) { return(Json(new { Success = success, hasAll = true, Message = message }, JsonRequestBehavior.AllowGet)); } else { var ids = appid.HasValue ? myCommands.Where(rc => rc.Application_Id == appid.Value).Select(rc => rc.Command_Id) : myCommands.Select(rc => rc.Command_Id); return(Json(new { Success = success, hasAll = false, cmdIds = ids.ToArray(), Message = message }, JsonRequestBehavior.AllowGet)); } } catch (DatabaseException exception) { message = exception.Message; } } return(Json(new { Success = success, Message = message }, JsonRequestBehavior.AllowGet)); }
private static void RunClient(string ip, int port) { client = new DSClient(ip, port); client.DataRecieved += client_OnDataRecieved; }
/// <summary> /// Initializes a new instance of the <see cref="ComplexValueMaterializationPolicy" /> class. /// </summary> /// <param name="materializerContext">The materializer context.</param> /// <param name="lazyPrimitivePropertyConverter">The lazy primitive property converter.</param> internal ComplexValueMaterializationPolicy(IODataMaterializerContext materializerContext, DSClient.SimpleLazy<PrimitivePropertyConverter> lazyPrimitivePropertyConverter) : base(materializerContext, lazyPrimitivePropertyConverter) { }
protected void DeleteEntity(DSClient client, int userId, string token, ModelEntity entity) { if (entity is Application) { client.DeleteApplication(userId, token, (entity as Application).Id); } else if (entity is Role) { client.DeleteRole(userId, token, (entity as Role).Id); } else if (entity is Command) { client.DeleteCommand(userId, token, (entity as Command).Id); } else if (entity is RoleCommand) { client.DeleteRoleCommand(userId, token, (entity as RoleCommand).Id); } else if (entity is RoleCommandView) { client.DeleteRoleCommand(userId, token, (entity as RoleCommandView).Id); } else if (entity is Image) { client.DeleteImage(userId, token, (entity as Image).Id); } else if (entity is UserIdList) { client.DeleteUserIdList(userId, token, (entity as UserIdList).Application_Id, (entity as UserIdList).User_Id); } else if (entity is User) { client.DeleteUser(userId, token, (entity as User).Id); } else if (entity is UserApplicationInfo) { //delete the user instead //client.DeleteUserInfo(userId, token, (entity as UserApplicationInfo).User_Id, (entity as UserApplicationInfo).Application_Id); client.DeleteUser(userId, token, (entity as UserApplicationInfo).User_Id); } else if (entity is Room) { client.DeleteRoom(userId, token, (entity as Room).Id); } else if (entity is RoomGroup) { client.DeleteRoomGroup(userId, token, (entity as RoomGroup).Id); } else if (entity is Gift) { client.DeleteGift(userId, token, (entity as Gift).Id); } else if (entity is GiftGroup) { client.DeleteGiftGroup(userId, token, (entity as GiftGroup).Id); } else if (entity is DepositHistory) { client.DeleteDepositHistory(userId, token, (entity as DepositHistory).Id); } else if (entity is ExchangeHistory) { client.DeleteExchangeHistory(userId, token, (entity as ExchangeHistory).Id); } else if (entity is BlockList) { client.DeleteBlockList(userId, token, (entity as BlockList).Id); } else if (entity is BlockType) { client.DeleteBlockType(userId, token, (entity as BlockType).Id); } else if (entity is ExchangeRate) { client.DeleteExchangeRate(userId, token, (entity as ExchangeRate).Id); } else if (entity is RoomConfig) { client.DeleteRoomConfig(userId, token, (entity as RoomConfig).Id); } }
protected T AddEntity <T>(DSClient client, int userId, string token, ModelEntity entity) where T : ModelEntity { if (entity is Application) { return(client.AddApplication(userId, token, entity as Application) as T); } else if (entity is Role) { return(client.AddRole(userId, token, entity as Role) as T); } else if (entity is Command) { return(client.AddCommand(userId, token, entity as Command) as T); } else if (entity is RoleCommand) { return(client.AddRoleCommand(userId, token, entity as RoleCommand) as T); } else if (entity is RoleCommandView) { return(client.AddRoleCommand(userId, token, (entity as RoleCommandView).GetRoleCommand()) as T); } else if (entity is Image) { client.AddImage(userId, token, entity as Image); return(entity as T); } else if (entity is UserIdList) { return(client.AddUserIdList(userId, token, entity as UserIdList) as T); } else if (entity is Room) { return(client.AddRoom(userId, token, entity as Room) as T); } else if (entity is RoomGroup) { return(client.AddRoomGroup(userId, token, entity as RoomGroup) as T); } else if (entity is Gift) { return(client.AddGift(userId, token, entity as Gift) as T); } else if (entity is GiftGroup) { return(client.AddGiftGroup(userId, token, entity as GiftGroup) as T); } else if (entity is User) { return(client.AddUser(userId, token, entity as User) as T); } else if (entity is UserApplicationInfo) { return(client.AddUserInfo(userId, token, entity as UserApplicationInfo) as T); } else if (entity is BlockList) { return(client.AddBlockList(userId, token, entity as BlockList) as T); } else if (entity is BlockType) { return(client.AddBlockType(userId, token, entity as BlockType) as T); } else if (entity is ExchangeRate) { return(client.AddExchangeRate(userId, token, entity as ExchangeRate) as T); } else if (entity is RoomRole) { return(client.AddRoomRole(userId, token, entity as RoomRole) as T); } else if (entity is ExchangeHistory) { return(client.AddExchangeHistory(userId, token, entity as ExchangeHistory) as T); } else if (entity is RoomConfig) { return(client.AddRoomConfig(userId, token, entity as RoomConfig) as T); } return(null); }
protected void UpdateEntity(DSClient client, int userId, string token, ModelEntity entity) { if (entity is Application) { client.UpdateApplication(userId, token, entity as Application); } else if (entity is Role) { client.UpdateRole(userId, token, entity as Role); } else if (entity is Command) { client.UpdateCommand(userId, token, entity as Command); } else if (entity is RoleCommand) { client.UpdateRoleCommand(userId, token, entity as RoleCommand); } else if (entity is RoleCommandView) { client.UpdateRoleCommand(userId, token, (entity as RoleCommandView).GetRoleCommand()); } else if (entity is Image) { client.UpdateImage(userId, token, entity as Image); } else if (entity is UserIdList) { client.UpdateUserIdList(userId, token, entity as UserIdList); } else if (entity is Room) { client.UpdateRoom(userId, token, entity as Room); } else if (entity is RoomGroup) { client.UpdateRoomGroup(userId, token, entity as RoomGroup); } else if (entity is Gift) { client.UpdateGift(userId, token, entity as Gift); } else if (entity is GiftGroup) { client.UpdateGiftGroup(userId, token, entity as GiftGroup); } else if (entity is User) { client.UpdateUser(userId, token, entity as User); } else if (entity is UserApplicationInfo) { client.UpdateUserInfo(userId, token, entity as UserApplicationInfo); } else if (entity is BlockType) { client.UpdateBlockType(userId, token, entity as BlockType); } else if (entity is BlockList) { client.UpdateBlockList(userId, token, entity as BlockList); } else if (entity is ExchangeRate) { client.UpdateExchangeRate(userId, token, entity as ExchangeRate); } else if (entity is RoomRole) { client.UpdateRoomRole(userId, token, entity as RoomRole); } else if (entity is RoomConfig) { client.UpdateRoomConfig(userId, token, entity as RoomConfig); } }
/// <summary> /// Initializes a new instance of the <see cref="ComplexValueMaterializationPolicy" /> class. /// </summary> /// <param name="materializerContext">The materializer context.</param> /// <param name="lazyPrimitivePropertyConverter">The lazy primitive property converter.</param> protected StructuralValueMaterializationPolicy(IODataMaterializerContext materializerContext, DSClient.SimpleLazy<PrimitivePropertyConverter> lazyPrimitivePropertyConverter) { Debug.Assert(materializerContext != null, "materializer!=null"); this.MaterializerContext = materializerContext; this.lazyPrimitivePropertyConverter = lazyPrimitivePropertyConverter; }
public T GetEntity <T>(int[] ids) where T : ModelEntity { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { var t = typeof(T); if (t == typeof(Application)) { Application app = client.GetApplication(userId, token, ids[0]); return(app as T); } else if (t == typeof(Role)) { Role role = client.GetRole(userId, token, ids[0]); return(role as T); } else if (t == typeof(Image)) { Image image = client.GetImage(userId, token, ids[0]); return(image as T); } else if (t == typeof(Command)) { Command cmd = client.GetCommand(userId, token, ids[0]); return(cmd as T); } else if (t == typeof(RoleCommand)) { RoleCommand rc = client.GetRoleCommand(userId, token, ids[0]); return(rc as T); } else if (t == typeof(RoleCommandView)) { RoleCommandView rc = client.GetRoleCommandView(userId, token, ids[0]); return(rc as T); } else if (t == typeof(User)) { User user = client.GetUser(userId, token, ids[0]); return(user as T); } else if (t == typeof(UserApplicationInfo)) { UserApplicationInfo info = client.GetUserInfo(userId, token, ids[0], ids[1]); return(info as T); } else if (t == typeof(RoomGroup)) { RoomGroup roomGroup = client.GetRoomGroup(userId, token, ids[0]); return(roomGroup as T); } else if (t == typeof(Room)) { Room room = client.GetRoom(userId, token, ids[0]); return(room as T); } else if (t == typeof(RoomRole)) { RoomRole rRole = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]); return(rRole as T); } else if (t == typeof(GiftGroup)) { GiftGroup giftGroup = client.GetGiftGroup(userId, token, ids[0]); return(giftGroup as T); } else if (t == typeof(Gift)) { Gift gift = client.GetGift(userId, token, ids[0]); return(gift as T); } else if (t == typeof(BlockType)) { BlockType b = client.GetBlockType(userId, token, ids[0]); return(b as T); } else if (t == typeof(BlockList)) { BlockList b = client.GetBlockList(userId, token, ids[0]); return(b as T); } else if (t == typeof(RoomRole)) { RoomRole rr = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]); return(rr as T); } else if (t == typeof(RoomConfig)) { RoomConfig c = client.GetRoomConfig(userId, token, ids[0]); return(c as T); } } return(null); }
public int GetEntityCount <T>(string condition) { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { var t = typeof(T); if (t == typeof(Application)) { return(client.GetApplicationCount(userId, token, condition)); } else if (t == typeof(Role)) { return(client.GetRoleCount(userId, token, condition)); } else if (t == typeof(Image)) { return(client.GetImageCount(userId, token, condition)); } else if (t == typeof(Command)) { return(client.GetCommandCount(userId, token, condition)); } else if (t == typeof(RoleCommand)) { return(client.GetRoleCommandCount(userId, token, condition)); } else if (t == typeof(RoleCommandView)) { return(client.GetRoleCommandViewCount(userId, token, condition)); } else if (t == typeof(User)) { return(client.GetUserCount(userId, token, condition)); } else if (t == typeof(UserApplicationInfo)) { return(client.GetUserInfoCount(userId, token, condition)); } else if (t == typeof(RoomGroup)) { return(client.GetRoomGroupCount(userId, token, condition)); } else if (t == typeof(Room)) { return(client.GetRoomCount(userId, token, condition)); } else if (t == typeof(GiftGroup)) { return(client.GetGiftGroupCount(userId, token, condition)); } else if (t == typeof(Gift)) { return(client.GetGiftCount(userId, token, condition)); } else if (t == typeof(DepositHistory)) { return(client.GetDepositHistoryCount(userId, token, condition)); } else if (t == typeof(ExchangeHistory)) { return(client.GetExchangeHistoryCount(userId, token, condition, false)); } else if (t == typeof(ExchangeRate)) { return(client.GetExchangeRateCount(userId, token, condition)); } else if (t == typeof(RoomRole)) { return(client.GetRoomRoleCount(userId, token, condition)); } } return(-1); }
public IEnumerable <ModelEntity> GetEntities <T>(string page, string pageSize, out int total, string condition) where T : ModelEntity { IEnumerable <ModelEntity> result = new List <ModelEntity>(); total = 0; DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { int start = -1, count = -1; int p = 0, s = 0; if (int.TryParse(page, out p) && int.TryParse(pageSize, out s)) { start = (p - 1) * s + 1; count = s; } var t = typeof(T); if (t == typeof(Application)) { result = client.GetApplications(userId, token, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetApplicationCount(userId, token, condition); } else if (t == typeof(Role)) { result = client.GetRoles(userId, token, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetRoleCount(userId, token, condition); } else if (t == typeof(ImageWithoutBody)) { result = client.GetImages(userId, token, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetImageCount(userId, token, condition); } else if (t == typeof(Command)) { result = client.GetCommands(userId, token, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetCommandCount(userId, token, condition); } else if (t == typeof(RoleCommand)) { result = client.GetRoleCommands(userId, token, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetRoleCommandCount(userId, token, condition); } else if (t == typeof(RoleCommandView)) { result = client.GetRoleCommandViews(userId, token, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetRoleCommandViewCount(userId, token, condition); } else if (t == typeof(UserIdList)) { result = client.GetUserIdLists(userId, token, BuiltIns.AllApplication.Id, condition, start, count).AsEnumerable <ModelEntity>(); total = client.GetUserIdListCount(userId, token, BuiltIns.AllApplication.Id, condition); } else if (t == typeof(UserApplicationInfo)) { result = client.GetUserInfos(userId, token, condition, start, count); total = client.GetUserInfoCount(userId, token, condition); } else if (t == typeof(User)) { result = client.GetUsers(userId, token, condition, start, count); total = client.GetUserCount(userId, token, condition); } else if (t == typeof(RoomGroup)) { result = client.GetRoomGroups(userId, token, condition, start, count); total = client.GetRoomGroupCount(userId, token, condition); } else if (t == typeof(Room)) { result = client.GetRooms(userId, token, condition, start, count); total = client.GetRoomCount(userId, token, condition); } else if (t == typeof(GiftGroup)) { result = client.GetGiftGroups(userId, token, condition, start, count); total = client.GetGiftGroupCount(userId, token, condition); } else if (t == typeof(Gift)) { result = client.GetGifts(userId, token, condition, start, count); total = client.GetGiftCount(userId, token, condition); } else if (t == typeof(DepositHistory)) { result = client.GetDepositHistories(userId, token, condition, start, count); total = client.GetDepositHistoryCount(userId, token, condition); } else if (t == typeof(ExchangeHistory)) { result = client.GetExchangeHistories(userId, token, condition, false, start, count); total = client.GetExchangeHistoryCount(userId, token, condition, false); } else if (t == typeof(BlockType)) { result = client.GetBlockTypes(userId, token, condition, start, count); total = client.GetBlockTypeCount(userId, token, condition); } else if (t == typeof(BlockList)) { result = client.GetBlockLists(userId, token, condition, start, count); total = client.GetBlockListCount(userId, token, condition); } else if (t == typeof(BlockHistory)) { result = client.GetBlockHistory(userId, token, condition, start, count); total = client.GetBlockHistoryCount(userId, token, condition); } else if (t == typeof(ExchangeRate)) { result = client.GetAllExchangeRate(userId, token, condition, start, count); total = client.GetExchangeRateCount(userId, token, condition); } else if (t == typeof(RoomRole)) { result = client.GetRoomRoles(userId, token, condition, start, count); total = client.GetRoomRoleCount(userId, token, condition); } else if (t == typeof(RoomConfig)) { result = client.GetRoomConfigs(userId, token, condition, start, count); total = client.GetRoomConfigCount(userId, token, condition); } } return(result); }
public DataServiceCache(int appId) : base(appId) { dataServiceClient = new DSClient(appId); applicationCondition = "[Application_Id]=" + BuiltIns.AllApplication.Id + " OR [Application_Id]=" + applicationId; }