/// <summary> /// 系统赠送,暂行方案:1个金币/人/天 /// </summary> /// <param name="username"></param> /// <param name="funName"></param> /// <returns></returns> public string SaveUserLevelByEnumSource(string username, string funName) { if (string.IsNullOrWhiteSpace(username)) { return(ReturnResult(false, "登录标识不能为空字符串,请检查", null)); } try { var user = Membership.GetUser(username); if (user == null) { return(ReturnResult(false, "登录标识无效,请检查", null)); } var userId = user.ProviderUserKey; EnumHelper eh = new EnumHelper(); var funCode = eh.GetValue(typeof(EnumData.FunCode), funName, 0); if (funCode < 1) { return(ReturnResult(false, "参数funName值【" + funName + "】无效,请检查", null)); } var enumSource = (int)EnumData.UserLevelSource.Encourage; UserLevelProduce ulpBll = new UserLevelProduce(); if (ulpBll.IsExist(userId, funCode, enumSource)) { return(ReturnResult(true, "调用成功", 0)); } //金币、元宝、颜色、积分、等级队列服务 UserBaseQueueClient ubQueueClient = new UserBaseQueueClient(); TygaSoft.Services.HnztcQueueService.UserLevelInfo userLevelInfo = new Services.HnztcQueueService.UserLevelInfo(); userLevelInfo.UserId = Guid.Parse(userId.ToString()); userLevelInfo.FunCode = funCode; userLevelInfo.EnumSource = (int)EnumData.UserLevelSource.Encourage; userLevelInfo.TotalGold = 1; ubQueueClient.SaveUserLevel(userLevelInfo); return(ReturnResult(true, "调用成功", 1)); } catch (Exception ex) { new CustomException("SaveUserLevelByEnumSource(string username,string funName)", ex); return(ReturnResult(false, ex.Message, 0)); } }
static void Main(string[] args) { //HnztcTeamClient teamClient = new HnztcTeamClient(); #region 知识竞猜测试 //string sGetQuestionList = teamClient.GetQuestionList("Manager"); //string sGetQXCLotteryInfo = teamClient.GetQXCLotteryInfo("Manager"); //继续添加你要测试的回调方法 //string sGetTopicList = teamClient.GetTopicInfo("D3F0FE03-3507-4033-9D5A-1A8732CEB86E"); #endregion #region 彩票 #endregion #region 摇奖 //string sIsExistErnieLatest = teamClient.IsExistErnieLatest(); #endregion #region 用户信息 Console.WriteLine("用户基本信息相关接口------------------------------------------"); /* * * //头像上传接口 * string filePath = @"D:\2.jpg"; * string fileName = Path.GetFileName(filePath); * string imgBase64 = ""; * using (var fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) * { * var buffer = new byte[fs.Length]; * fs.Read(buffer, 0, (int)fs.Length); * imgBase64 = Convert.ToBase64String(buffer); * } * * //imgBase64 = @""; * * var sUpdateHeadPicture = teamClient.UpdateHeadPicture("13647544790", imgBase64, fileName); * * //修改昵称 * //var sUpdateUserBaseModel = teamClient.UpdateUserBaseModel("13647544790", "陈老大"); * */ Console.WriteLine("用户基本信息相关接口------------------------------------------"); #endregion #region 安全服务 /* * * WebSecurityClient wsClient = new WebSecurityClient(); * string sGetRandomNumber = wsClient.GetRandomNumber(); * */ #endregion #region 消息队列服务 UserBaseQueueClient ubQueueClient = new UserBaseQueueClient(); //金币、元宝、颜色、等级 TygaSoft.Services.HnztcQueueService.UserLevelInfo userLevelInfo = new TygaSoft.Services.HnztcQueueService.UserLevelInfo(); userLevelInfo.UserId = Guid.Parse("60286733-AC08-4C0D-B800-B53E1A7DF01A"); userLevelInfo.IsReduce = false; userLevelInfo.TotalGold = 4; userLevelInfo.TotalSilver = 5; userLevelInfo.TotalIntegral = 2; ubQueueClient.SaveUserLevel(userLevelInfo); #endregion }
private void GetBetResult(HttpContext context) { var list = ErnieDataProxy.GetLatest(); if (list == null || list.Count == 0) { int index = 0; while (true) { Thread.Sleep(5000); list = ErnieDataProxy.GetLatest(); if (list.Count > 0) { break; } index++; if (index > 5) { break; } } } if (list != null && list.Count > 0) { var ernieModel = list[0]; if (!((DateTime.Now >= ernieModel.StartTime) && (DateTime.Now <= ernieModel.EndTime))) { context.Response.Write("{\"success\": true,\"message\": \"\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}"); return; } var userId = WebCommon.GetUserId(); if (userId.Equals(Guid.Empty)) { context.Response.Write("{\"success\": false,\"message\": \"请先登录\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}"); return; } UserErnie ueBll = new UserErnie(); Dictionary <string, string> dic = new Dictionary <string, string>(); var listT = list.ToList(); var g = listT.GroupBy(m => m.NumType); foreach (var gk in g) { var keyList = listT.FindAll(m => m.NumType == gk.Key); var ga = keyList.GroupBy(m => m.AppearRatio); GLBfb[] arrGLBfb = new GLBfb[ga.Count()]; int i = 0; foreach (var gak in ga) { arrGLBfb[i] = new GLBfb(); arrGLBfb[i].Bfb = (int)(gak.Key * 100); var currList = keyList.FindAll(m => m.AppearRatio == gak.Key); foreach (var model in currList) { var numArr = model.Num.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var num in numArr) { arrGLBfb[i].SjsList.Add(num); } } i++; } RandomForWeight rdfw = new RandomForWeight(arrGLBfb); dic.Add(gk.Key, rdfw.GetGLNumber()); } string gold = "0"; string silver = "0"; string times = "0"; foreach (KeyValuePair <string, string> kvp in dic) { switch (kvp.Key) { case "倍数": times = kvp.Value; break; case "金币": gold = kvp.Value; break; case "元宝": silver = kvp.Value; break; default: break; } } int remainTimes = 0; using (TransactionScope scope = new TransactionScope()) { var totalBetCount = ueBll.GetTotalBetCount(userId, ernieModel.ErnieId); remainTimes = ernieModel.UserBetMaxCount - totalBetCount; if (remainTimes < 0) { totalBetCount = 0; } if (remainTimes < 1) { context.Response.Write("{\"success\": false,\"message\": \"摇奖机会还剩 " + 0 + " 次\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\",\"remainTimes\":\"0\"}"); return; } UserErnieInfo ueModel = new UserErnieInfo(); ueModel.UserId = userId; ueModel.ErnieId = ernieModel.ErnieId; ueModel.LastUpdatedDate = DateTime.Now; ueModel.WinGold = int.Parse(gold) * int.Parse(times); ueModel.WinSilver = int.Parse(silver) * int.Parse(times); ueBll.Insert(ueModel); UserBaseQueueClient ubqClient = new UserBaseQueueClient(); TygaSoft.Services.HnztcQueueService.UserLevelInfo userLevelInfo = new TygaSoft.Services.HnztcQueueService.UserLevelInfo(); userLevelInfo.UserId = userId; userLevelInfo.IsReduce = false; userLevelInfo.TotalGold = ueModel.WinGold; userLevelInfo.TotalSilver = ueModel.WinSilver; userLevelInfo.TotalIntegral = 0; ubqClient.SaveUserLevel(userLevelInfo); scope.Complete(); remainTimes = remainTimes - 1; } context.Response.Write("{\"success\": true,\"message\": \"摇奖机会还剩 " + remainTimes + " 次\",\"gold\": \"" + gold + "\",\"silver\": \"" + silver + "\",\"times\": \"" + times + "\",\"remainTimes\":\"" + remainTimes + "\"}"); } else { context.Response.Write("{\"success\": true,\"message\": \"\",\"gold\": \"0\",\"silver\": \"0\",\"times\": \"0\"}"); } }
static void Main(string[] args) { int totalRecords = 0; #region 电子商务 //ECShopClient shopClient = new ECShopClient(); //string sGetCategoryTreeJson = shopClient.GetCategoryTreeJson(); //string sGetBrandTreeJson = shopClient.GetBrandTreeJson(); //string sGetBrandListByParentId = shopClient.GetBrandListByParentId("5FFF281C-BFAB-429D-88E2-F901DBDBE813"); //string sGetBrandListByCategoryId = shopClient.GetBrandListByCategoryId("F3312568-F286-47DE-B575-B5385812D5FE"); //string sGetProductDetail = shopClient.GetProductDetail(Guid.Parse("c3f0c0fb-b54f-4c84-bf50-2a32bf380132")); #region 商品相关 //string sGetProductListByPage = shopClient.GetProductListByPage(out totalRecords,1,10); //string sGetProductListByCategory = shopClient.GetProductListByCategory(out totalRecords,1,10,Guid.Empty); //string GetProductListByBrand = shopClient.GetProductListByBrand(out totalRecords, 1, 10, Guid.Empty); //string GetProductListByMenu = shopClient.GetProductListByMenu(out totalRecords, 1, 10, Guid.Parse("6ba12a33-a572-424d-99f0-cd6316764898")); //3B6A37FE-225E-49BD-A89F-07FD1109CC06 #endregion //Console.WriteLine("sGetProductListByPage--" + sGetProductListByPage); #endregion #region 海南直通车 HnztcClient hnztcClient = new HnztcClient(); //Console.WriteLine("公告相关接口------------------------------------------"); //var sGetAnnouncementList = hnztcClient.GetAnnouncementList(1, 10); //var sGetAnnouncementModel = hnztcClient.GetAnnouncementModel(Guid.Parse("22194a75-0d05-4b45-9fde-dc13f3da895a")); //Console.WriteLine("公告相关接口------------------------------------------"); //Console.WriteLine("广告相关接口------------------------------------------"); //var sGetSiteFunList = hnztcClient.GetSiteFunList(); //获取广告区列表 //var sGetAdvertisementList = hnztcClient.GetAdvertisementList(1, 10, Guid.Parse("6cc0b6e9-308a-4292-8af2-038b71613794")); //获取当前广告区的所有广告 //var sGetAdvertisementModel = hnztcClient.GetAdvertisementModel(Guid.Parse("11464a42-219b-4fa7-825c-5ccf49b240bc")); //Console.WriteLine("公告相关接口------------------------------------------"); //Console.WriteLine("服务相关接口------------------------------------------"); //string sGetServiceList = hnztcClient.GetServiceList("283335746", 1, 10); //string sGetServiceListByServiceItemId = hnztcClient.GetServiceListByServiceItemId("283335746", 1, 10, Guid.Parse("DFE52420-DD38-4427-AB44-106F067CC83D")); //string sGetServiceVoteById = hnztcClient.GetServiceVoteById(Guid.Parse("3d295a81-f5f9-4f29-be12-e672156b1da9")); //string sGetServiceContentById = hnztcClient.GetServiceContentById(Guid.Parse("266386c6-1ee9-422d-8842-ea2d16a89312")); //string sGetServiceLinkById = hnztcClient.GetServiceLinkById(Guid.Parse("0cf233f8-d40f-499e-b3f0-194e522dca70")); //string sSaveServiceUserPraise = hnztcClient.SaveServiceUserPraise("283335746", Guid.Parse("5360AC13-8399-4DD7-909F-E0F9193F25A2")); //Console.WriteLine("商城菜单相关接口------------------------------------------"); //string sGetShopMenuListByRoot = hnztcClient.GetShopMenuListByRoot(); //6ba12a33-a572-424d-99f0-cd6316764898 //string sGetContentTypeChildListByParentId = hnztcClient.GetContentTypeChildListByParentId(Guid.Parse("53A15F04-B5DA-4A71-A1F9-1053CE830B2D")); //Console.WriteLine("用户基本信息相关接口------------------------------------------"); ////头像上传接口 //string fileName = @"E:\上传文件测试用\20150510222831_6719.jpg"; //string imgBase64 = ""; //using (var fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)) //{ // var buffer = new byte[fs.Length]; // fs.Read(buffer, 0, (int)fs.Length); // imgBase64 = Convert.ToBase64String(buffer); //} //imgBase64 = @""; //var sUpdateHeadPicture = hnztcClient.UpdateHeadPicture("13647544790", imgBase64, "20150510222831_6719.jpg"); //修改昵称 //var sUpdateUserBaseModel = hnztcClient.UpdateUserBaseModel("13647544790", "陈老大"); Console.WriteLine("用户基本信息相关接口------------------------------------------"); #endregion #region 安全服务 WebSecurityClient wsClient = new WebSecurityClient(); //string sRegister = wsClient.Register("User3", "123456","张三"); string sLogin = wsClient.Login("13687590736", "999999"); //var userId = wsClient.GetUserId("Manager"); //string sGetUserInfo = wsClient.GetUserInfo("13647544790"); //string sGetRandomNumber = wsClient.GetRandomNumber(); //StringBuilder sb = new StringBuilder(); //for (int i = 0; i < 10000; i++) //{ // string s = wsClient.GetRandomNumber(); // sb.Append(s); //} //Console.WriteLine(sb.ToString()); //string sUpdatePassword = wsClient.UpdatePassword("13687590736", "123456"); //string sChangePassword = wsClient.ChangePassword("13687590736", "999999", "123456"); //Console.WriteLine(sChangePassword); #endregion #region 系统日志服务 HnztcSysClient sysClient = new HnztcSysClient(); //TygaSoft.Services.HnztcSysService.SyslogInfo sysLogInfo = new Services.HnztcSysService.SyslogInfo(); //sysLogInfo.AppName = "海南直通车系统日志服务"; //sysLogInfo.MethodName = "TygaSoft.WcfClient.Main"; //sysLogInfo.Message = "首次测试"; //sysLogInfo.LastUpdatedDate = DateTime.Now; //sysClient.InsertSysLog(sysLogInfo); #endregion #region 消息队列服务 UserBaseQueueClient ubQueueClient = new UserBaseQueueClient(); ////金币、元宝、颜色、等级 TygaSoft.Services.HnztcQueueService.UserLevelInfo userLevelInfo = new Services.HnztcQueueService.UserLevelInfo(); userLevelInfo.UserId = Guid.Parse("60286733-AC08-4C0D-B800-B53E1A7DF01A"); SysHelper.EnumHelper eh = new SysHelper.EnumHelper(); var funCode = eh.GetValue(typeof(SysHelper.EnumData.FunCode), "fw", 0); userLevelInfo.FunCode = funCode; userLevelInfo.EnumSource = 0; userLevelInfo.IsReduce = false; userLevelInfo.TotalGold = 4; userLevelInfo.TotalSilver = 5; userLevelInfo.TotalIntegral = 2; ubQueueClient.SaveUserLevel(userLevelInfo); #endregion Console.WriteLine("客户端调用执行完毕!"); Console.WriteLine("按任意键结束程序"); Console.ReadLine(); }