コード例 #1
0
 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);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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);
 }
コード例 #6
0
		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());
		}
コード例 #7
0
 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);
 }
コード例 #8
0
		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;
		}
コード例 #9
0
 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);
 }
コード例 #10
0
 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);
 }
コード例 #11
0
        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); 
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 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);
 }
コード例 #14
0
ファイル: Cache.cs プロジェクト: wangws556/duoduo-chat
        public DataServiceCache(int appId)
            : base(appId)
        {
			dataServiceClient = new DSClient(appId);
			applicationCondition = "[Application_Id]=" + BuiltIns.AllApplication.Id + " OR [Application_Id]=" + applicationId;
        }
コード例 #15
0
        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);
        }
コード例 #16
0
 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);
 }
コード例 #17
0
 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);
 }