public ApiMessage GetProductsWastageDetail() { ApiMessage data = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); try { int[] products = base.ConvertToIntArrar(request["product_ids"]); data.Item = stockManager.GetProductsWastageDetail(products); } catch (KMJXCException kex) { data.Status = "failed"; data.Message = kex.Message; } catch (Exception ex) { data.Status = "failed"; data.Message = "未知错误"; } return(data); }
public PQGridData GetPropertiesT() { string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); ApiMessage message = new ApiMessage(); BUser user = userMgr.CurrentUser; ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int categoryId = 0; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; int.TryParse(request["cid"], out categoryId); string sortBy = ""; string dir = ""; if (request["sortBy"] != null) { sortBy = request["sortBy"]; } if (request["dir"] != null) { sortBy = request["dir"]; } List <BProperty> properties = cateMgr.GetProperties(categoryId, 0, sortBy, dir); PQGridData grid = new PQGridData(); grid.curPage = 1; grid.totalRecords = properties.Count; grid.data = properties; message.Item = grid; message.Status = "ok"; return(grid); }
public ApiMessage SetCorpInfo() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; try { SystemAdmin admin = new SystemAdmin(int.Parse(user_id)); Corp_Info info = new Corp_Info() { About = request["about"], Contact = request["contact"], Help = request["help"] }; admin.SetCorpInfo(info); } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } return(message); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public ApiMessage <string> GetCode(string id) { var api = new ApiMessage <string>(); api.Data = DateCode.GetCode(id); return(api); }
public ApiMessage <List <sysoption> > GetOptByType(string t) { var api = new ApiMessage <List <sysoption> >(); api.Data = dal.GetOptByType(t); return(api); }
public ApiMessage HandleAddChildRequest() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int reqId = 0; int status = 0; int.TryParse(request["reqId"], out reqId); int.TryParse(request["status"], out status); try { shopManager.HandleAddChildRequest(reqId, status); } catch (KMJXCException kex) { message.Message = kex.Message; message.Status = "failed"; } catch { } finally { } return(message); }
public async Task <IActionResult> GetBanners() { var apiMsg = await ApiMessage.Wrap(async() => { var topNews = await contentBusiness.GetLatestNews(); var topPostEntry = await postEntryBusiness.GetHotPostEntry(); var bannerList = await bannersBusienss.GetList() ?? new List <Banners>(); if (topNews != null) { bannerList.Add(new Banners { CreateTime = topNews.CreateTime, Image = topNews.MediaResource?[0]?.ActualPath, Link = "news:" + topNews.Id, Title = topNews.Title }); } if (topPostEntry != null) { bannerList.Add(new Banners { CreateTime = topPostEntry.CreateTime, Image = topPostEntry.PostEntryFileList?[0]?.ActualPath, Link = "postentry:" + topPostEntry.Id, Title = topPostEntry.TextContent }); } return(bannerList); }); return(Json(apiMsg)); }
public ApiMessage <string> Alipay(PayModel pm) { var api = new ApiMessage <string>(); IAopClient client = new DefaultAopClient(URL, APPID, APP_PRIVATE_KEY, "json", "1.0", RSA2, ALIPAY_PUBLIC_KEY, CHARSET, false); AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); var res = bll.CkeckData(pm, UserInfo); if (!res.Success) { api.Success = false; api.Msg = res.Msg; return(api); } var oData = res.Data; model.Body = oData.Body; model.Subject = oData.Subject; model.TotalAmount = oData.TotalAmount.ToString(); model.ProductCode = "QUICK_MSECURITY_PAY"; model.OutTradeNo = oData.OutTradeNo; AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); request.SetBizModel(model); request.SetNotifyUrl(ConfigHelper.WebSiteUrl + "/api/payment/updateorder/alipay"); AlipayTradeAppPayResponse response = client.SdkExecute(request); api.Data = response.Body; return(api); }
public ApiMessage RemoveSupplierProducts() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; SupplierManager supplierManager = new SupplierManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int supplier_id = 0; string products = request["products"]; int[] product_ids = null; int.TryParse(request["id"], out supplier_id); try { product_ids = base.ConvertToIntArrar(products); supplierManager.RemoveSupplierProducts(product_ids, supplier_id); } catch (KMJXCException ex) { message.Status = "failed"; message.Message = ex.Message; } catch { message.Status = "failed"; message.Message = "未知错误"; } return(message); }
public ApiMessage <string, LoginModel> Login(ApiMessage <string, LoginModel> user, IUnitOfWork unitOfWork) { ApiMessage <string, LoginModel> returnMessage = null; Dictionary <string, LoginModel> loggedUsers = (Dictionary <string, LoginModel>)_cacheManager.Get("LoggedUsers"); // This lock handles multiple fast same-parameter logins lock (lockk) { User userToLogin; if ((userToLogin = unitOfWork.UserRepository.Find(u => u.Username == user.Data.Username && u.Password == user.Data.Password).FirstOrDefault()) != null) { if (!userToLogin.IsBanned) { string hash = _hashGenerator.GenerateHash(user.Data); user.Data.Role = ((Role)unitOfWork.UserRepository.Find(u => u.Username == user.Data.Username).FirstOrDefault().Role).ToString(); if (!loggedUsers.ContainsKey(hash)) { if (loggedUsers.Values.FirstOrDefault(u => u.Username == user.Data.Username) == null) { loggedUsers.Add(hash, user.Data); returnMessage = new ApiMessage <string, LoginModel>(); returnMessage.Key = hash; returnMessage.Data = user.Data; _cacheManager.Set(key, loggedUsers, 24); } } } } } return(returnMessage); }
protected override void CreateInstance() { message = new ApiMessage(CommandTypes.CmdSerialApiTest, TestCmd, (byte)(TestDelay >> 8), (byte)TestDelay, TestPayloadLength, (byte)(TestCount >> 8), (byte)TestCount, (byte)TxOptions, (byte)TestNodeMask.Length); message.AddData(TestNodeMask); message.SetSequenceNumber(SequenceNumber); messageStop = new ApiMessage(CommandTypes.CmdSerialApiTest, 0, 0, 0, 0, 0, 0, 0, 0); handlerRetFailed = new ApiHandler(CommandTypes.CmdSerialApiTest); handlerRetFailed.AddConditions(new ByteIndex(0)); handlerCallback = new ApiHandler(FrameTypes.Request, CommandTypes.CmdSerialApiTest); }
public ApiMessage <string> Del(PriceEx p) { var api = new ApiMessage <string>(); if (string.IsNullOrEmpty(p.ID)) { api.Success = false; api.Msg = "该商品不存在价格"; return(api); } var old = new oldprice(); old.ID = Guid.NewGuid().ToString(); old.PriceID = p.ID; old.ProductID = p.ProductID; old.Price = p.Price; old.MemberPrice = p.MemberPrice; old.LimitNum = p.LimitNum; old.StaffName = p.StaffName; old.ProductName = p.Name; old.CreatDate = DateTime.Now; var msg = _dal.Del(old); api.Success = msg; api.Msg = msg ? "操作成功" : "操作失败"; return(api); }
public JsonResult <ApiBaseResponse> SendMessage([FromBody] ApiMessage message) { var result = new ApiBaseResponse(); try { var messageId = ServicesHost.GetService <IMessagesProvider>().Save(message); message = ServicesHost.GetService <IMessagesProvider>().GetById(messageId); var contact = ServicesHost.GetService <IContactsProvider>().GetById(message.ContactId); var receiverUser = UserManager.FindByPhoneNumber(contact.PhoneNumber); if (receiverUser == null) { var smsMessageText = message.GetSmsMessageText(message); ServicesHost.GetService <ISmsService>().SendSmsMessage(contact.PhoneNumber, smsMessageText); } else { var userDeviceTokens = ServicesHost.GetService <IDevicesProvider>().GetUserDevices(receiverUser.Id).Select(d => d.Token); var messagesCount = ServicesHost.GetService <IMessagesProvider>().UnreadUserMessagesCount(receiverUser.Id); var messageText = message.GetPushNotificationText(); Task.Run(() => ServicesHost.GetService <IApplePushNotificationService>().SendPushNotifications(userDeviceTokens, messageText, messagesCount, messageId.ToString())); } } catch (Exception ex) { result.Status = ApiStatusCode.SystemError; result.Error = ex.Message; } return(Json(result)); }
public ApiMessage UpdateProductsWastage() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); try { string ws = request["wastages"]; if (string.IsNullOrEmpty(ws)) { message.Status = "failed"; message.Message = "输入错误"; return(message); } ws = HttpUtility.UrlDecode(ws); JArray ps = (JArray)JArray.Parse(ws); if (ps != null && ps.Count > 0) { List <BProduct> products = new List <BProduct>(); for (int i = 0; i < ps.Count; i++) { BProduct product = new BProduct(); JObject json = (JObject)ps[i]; if (json["product_id"] != null) { product.ID = (int)json["product_id"]; } if (json["quantity"] != null) { product.Quantity = (int)json["quantity"]; } if (json["parent_id"] != null) { product.ParentID = (int)json["parent_id"]; } products.Add(product); } stockManager.UpdateProductsWastage(products); } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } return(message); }
protected override void CreateInstance() { messageStart = new ApiMessage(SerialApiCommands[0], new byte[] { (byte)mInitMode, (byte)NodeId }); messageStart.SetSequenceNumber(SequenceNumber); messageStop = new ApiMessage(SerialApiCommands[0], new byte[] { (byte)Modes.NodeStop }); messageStop.SetSequenceNumber(SequenceNumber); messageStopFailed = new ApiMessage(SerialApiCommands[0], new byte[] { (byte)Modes.NodeStopFailed }); messageStopFailed.SetSequenceNumber(0); //NULL FuncId messageStopDone = new ApiMessage(SerialApiCommands[0], new byte[] { (byte)Modes.NodeStop }); messageStopDone.SetSequenceNumber(0); //NULL FuncId handlerDone = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerDone.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.Done)); handlerNodeFound = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerNodeFound.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.NodeFound)); handlerRemovingController = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerRemovingController.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.AddingRemovingController)); handlerRemovingSlave = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerRemovingSlave.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.AddingRemovingSlave)); handlerLearnReady = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerLearnReady.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.LearnReady)); handlerFailed = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerFailed.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.Failed)); handlerNotPrimary = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerNotPrimary.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)NodeStatuses.NotPrimary)); }
public ApiMessage <object> LoginByToken(userinfo user) { var userData = _bll.LoginByToken(user); var outData = new ApiMessage <object> { Success = userData.Success, Msg = userData.Msg, MsgCode = userData.MsgCode }; if (!userData.Success) { return(outData); } var currentUser = UserVModel.FormatUser(userData.Data); var key = Encrypt.MD5(currentUser.Id + "_" + currentUser.UserType); outData.Data = new { Token = key, currentUser.UserName, currentUser.UserCode, currentUser.ImageUrl, currentUser.Id, currentUser.Phone, currentUser.IsMember, currentUser.PointAmount }; CacheHelper.SetCache(key, currentUser, new TimeSpan(0, 30, 0)); return(outData); }
public ApiMessage SetDefaultExpress() { ApiMessage message = new ApiMessage(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; ShopManager shopManager = new ShopManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission, userMgr); int expId = 0; int.TryParse(request["express_id"], out expId); try { shopManager.SetDefaultExpress(expId); message.Status = "ok"; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { } finally { } return(message); }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <returns></returns> public ApiMessage <string> EditPassWord(UserInfoEx user) { var api = new ApiMessage <string>(); var gCode = CacheHelper.GetCache("VCode_" + user.UserCode); if (gCode == null) { api.Success = false; api.Msg = "验证码已过期"; return(api); } if (gCode.ToString() != user.VerifyCode) { api.Success = false; api.Msg = "验证码有误"; return(api); } var dbModel = _dal.GetByPhone(user.UserCode); if (!dbModel.Success) { api.Success = false; api.Msg = "账号不存在"; return(api); } var dbUser = dbModel.Data; dbUser.PassWord = Encrypt.MD5(user.PassWord); return(_dal.Edit(dbUser)); }
public ApiMessage GetAdminActions() { ApiMessage message = new ApiMessage() { Status = "ok" }; List <BAdminCategoryAction> actions = new List <BAdminCategoryAction>(); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); int role_id = 0; int.TryParse(request["role"], out role_id); try { actions = permissionMgt.GetActionsByCategory(role_id); message.Item = actions; } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch { } finally { } return(message); }
/// <summary> /// /// </summary> /// <returns></returns> public ApiMessage <string> VerifyCode(string strPhone) { var api = new ApiMessage <string>() { Msg = "发送成功" }; var gCode = CacheHelper.GetCache("GCode_" + strPhone); if (gCode != null) { api.Success = false; api.Msg = "已经发送过验证码,不能重复获取"; return(api); } gCode = CacheHelper.GetCache("VCode_" + strPhone); if (gCode == null) { var random = new Random().Next(100000, 999999); CacheHelper.SetCache("VCode_" + strPhone, random.ToString(), new TimeSpan(0, 10, 0)); SendMsg.Send(strPhone, random.ToString()); } else { SendMsg.Send(strPhone, gCode.ToString()); } CacheHelper.SetCache("GCode_" + strPhone, strPhone, DateTime.Now.AddMinutes(3)); return(api); }
public async Task <IActionResult> ProjectPut(Guid?Id) { var apiMsg = await ApiMessage.Wrap(async() => { var dataJsonStr = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync(); //var dataJson = JsonConvert.SerializeObject(dataJsonStr); var hasProject = await dbClient.Queryable <Project>().AnyAsync(x => x.Id == Id); if (!hasProject) { var userIdString = HttpContext.Session.GetString(UserAuthBusiness.UserAuthFrontendKey); var userId = Guid.Parse(userIdString); var userInfo = await userAuthBusiness.GetUser(userId); InitProject(Id.Value, userInfo); } else { var projectInfo = await dbClient.Queryable <Project>().FirstAsync(x => x.Id == Id); projectInfo.Thumbnail = "//scratchasset.pagetechs.com/thumb/" + Id + ".jpg"; projectInfo.Data = dataJsonStr; await dbClient.Updateable <Project>(projectInfo).ExecuteCommandAsync(); } }); return(Json(apiMsg)); }
public async Task <IActionResult> HasLogin() { await HttpContext.Session.LoadAsync(); byte[] sessionValueBytes; var apiMsg = new ApiMessage(); if (HttpContext.Session.TryGetValue(UserAccountBusiness.UserAccountSessionkey, out sessionValueBytes)) { var sessionValue = Encoding.UTF8.GetString(sessionValueBytes); if (!string.IsNullOrEmpty(sessionValue)) { apiMsg.Data = sessionValue; } else { apiMsg.SetFault("Can not find UserAccount"); } } else { apiMsg.SetFault("Can not find UserAccount"); } return(Json(apiMsg)); }
public static void RescheduleMessage(ApiMessage message) { TimeSpan timeSpan = Properties.Settings.Default.RescheduleRate; Scheduler.ScheduleMessage(message, timeSpan); DismissMessage(message); }
public async Task <IActionResult> CreateUser([FromBody] CaRegisterModel model) { ApiMessage apiMsg; //if (model.InviteOrigin != "LnnInvite") //{ // apiMsg = new ApiMessage(); // apiMsg.SetFault("邀请码不能为空"); //} //else //{ apiMsg = await ApiMessage.Wrap(async() => { var resultTuple = await userAccountBusiness.RegisterUserNamePwd(model); HttpContext.Session.Set (UserAccountBusiness.UserAccountSessionkey, Encoding.UTF8.GetBytes(resultTuple.Item3)); await HttpContext.Session.CommitAsync(); await SetAuth(resultTuple.Item3); return(resultTuple.Item3); }); //} return(Json(apiMsg)); }
protected override void CreateInstance() { messageStart = new ApiMessage(SerialApiCommands[0], ReplacedNodeId); messageStart.SetSequenceNumber(SequenceNumber); handlerRemoveStarted = new ApiHandler(SerialApiCommands[0]); handlerRemoveStarted.AddConditions(new ByteIndex((byte)FailedNodeRetValues.ZW_FAILED_NODE_REMOVE_STARTED)); handlerNotPrimary = new ApiHandler(SerialApiCommands[0]); handlerNotPrimary.AddConditions(new ByteIndex((byte)FailedNodeRetValues.ZW_NOT_PRIMARY_CONTROLLER)); handlerNoCallback = new ApiHandler(SerialApiCommands[0]); handlerNoCallback.AddConditions(new ByteIndex((byte)FailedNodeRetValues.ZW_NO_CALLBACK_FUNCTION)); handlerNotFound = new ApiHandler(SerialApiCommands[0]); handlerNotFound.AddConditions(new ByteIndex((byte)FailedNodeRetValues.ZW_FAILED_NODE_NOT_FOUND)); handlerRemoveBusy = new ApiHandler(SerialApiCommands[0]); handlerRemoveBusy.AddConditions(new ByteIndex((byte)FailedNodeRetValues.ZW_FAILED_NODE_REMOVE_PROCESS_BUSY)); handlerRemoveFail = new ApiHandler(SerialApiCommands[0]); handlerRemoveFail.AddConditions(new ByteIndex((byte)FailedNodeRetValues.ZW_FAILED_NODE_REMOVE_FAIL)); handlerNodeOk = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerNodeOk.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)FailedNodeStatuses.ZW_NODE_OK)); handlerRemoved = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerRemoved.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)FailedNodeStatuses.ZW_FAILED_NODE_REMOVED)); handlerNotRemoved = new ApiHandler(FrameTypes.Request, SerialApiCommands[0]); handlerNotRemoved.AddConditions(ByteIndex.AnyValue, new ByteIndex((byte)FailedNodeStatuses.ZW_FAILED_NODE_NOT_REMOVED)); }
public async Task <IActionResult> ApiLogin([FromBody] CaUserLoginModel caUserLoginModel) { var apiMsg = new ApiMessage(); try { var resultTuple = await userAccountBusiness.LoginUserNamePwd(caUserLoginModel); if (resultTuple.Item1) { var accessToken = Guid.NewGuid().ToString(); var redisDoc = new RedisDocument <string>(); redisDoc.ExpireTime = DateTime.Now.AddDays(30); redisDoc.SetTime = DateTime.Now; redisDoc.Value = resultTuple.Item3; redisDoc.Key = accessToken; await distributedCache.SetValue(redisDoc); apiMsg.Data = accessToken; } else { apiMsg.SetFault(resultTuple.Item2); } } catch (Exception exc) { apiMsg.SetFault(exc); } return(Json(apiMsg)); }
public ApiMessage BatchUpdatePropertiesCategory() { ApiMessage message = new ApiMessage() { Status = "ok", Message = "" }; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; Shop MainShop = userMgr.Main_Shop; ShopCategoryManager cateMgr = new ShopCategoryManager(userMgr.CurrentUser, MainShop, userMgr.CurrentUserPermission); HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; int[] props = null; int category_id = 0; try { int.TryParse(request["category_id"], out category_id); props = base.ConvertToIntArrar(request["props"]); cateMgr.BatchUpdatePropertiesCategory(props, category_id); } catch (KM.JXC.Common.KMException.KMJXCException kex) { message.Message = kex.Message; } catch (Exception ex) { } return(message); }
/// <summary> /// Logs the API message. /// </summary> /// <param name="message">The message.</param> public void LogApiMessage(ApiMessage message) { if (message != null) { Task.Factory.StartNew(() => InternalLogMessage(message)); } }
public ApiMessage UpdatePassword() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; int uid = 0; try { int.TryParse(request["uid"], out uid); SystemAdmin admin = new SystemAdmin(int.Parse(user_id)); string password = request["password"]; if (!admin.UpdatePassword(password, uid)) { message.Status = "failed"; message.Message = "密码修改失败"; } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } return(message); }
protected override void CreateInstance() { message = new ApiMessage(SerialApiCommands[0], RxAckTimeout, RxByteTimeout); message.SetSequenceNumber(SequenceNumber); handler = new ApiHandler(SerialApiCommands[0]); }