/// <summary> /// 获取房间预订信息 /// </summary> /// <param name="baseApi"></param> /// <returns></returns> public object Do_RefundBooking(BaseApi baseApi) { BookingIdParam param = JsonConvert.DeserializeObject <BookingIdParam>(baseApi.param.ToString()); if (param == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } if (param.bookingId == null || param.bookingId == "") { throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError"); } string openId = Utils.GetOpenID(baseApi.token); HouseDao houseDao = new HouseDao(); if (houseDao.refundBooking(param.bookingId)) { UserDao userDao = new UserDao(); Booking booking = userDao.getBooking(param.bookingId); if (userDao.updateUserPrice(booking.userPhone, Convert.ToString(0 - Convert.ToDouble(booking.price)))) { return(userDao.getBookingList(booking.userPhone)); } else { throw new ApiException(CodeMessage.AddPaymentError, "AddPaymentError"); } } else { throw new ApiException(CodeMessage.BookingRefundError, "BookingRefundError"); } }
/// <summary> /// 获取房间预订信息 /// </summary> /// <param name="baseApi"></param> /// <returns></returns> public object Do_GetHouseDataTimeInfoListByBeginTime(BaseApi baseApi) { HouseBookingParam param = JsonConvert.DeserializeObject <HouseBookingParam>(baseApi.param.ToString()); if (param == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } if (param.houseId == null || param.houseId == "") { throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError"); } if (param.checkDate == null || param.checkDate == "") { throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError"); } if (param.beginTime == null || param.beginTime == "") { throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError"); } string openId = Utils.GetOpenID(baseApi.token); HouseDao houseDao = new HouseDao(); return(houseDao.getHouseDataTimeInfoListByBeginTime(param)); }
/// <summary> /// 勾选商品 /// </summary> /// <param name="param"></param> /// <returns></returns> public string Do_ChoseGoods(BaseApi baseApi) { MsgResult msg = new MsgResult(); ChoseGoodsParam choseGoodsParam = JsonConvert.DeserializeObject <ChoseGoodsParam>(baseApi.param.ToString()); if (choseGoodsParam.goodsId == "" || choseGoodsParam.goodsId == null) { throw new ApiException(CodeMessage.InvalidGoodsIdCode, "InvalidGoodsIdCode"); } string shopId = Util.GetUserShopId(baseApi.token); ActiveDao activeDao = new ActiveDao(); if (choseGoodsParam.type) { if (!activeDao.InsertActiveGoods(shopId, choseGoodsParam)) { throw new ApiException(CodeMessage.DBAddError, "DBAddError"); } } else { if (!activeDao.DeleteActiveGoods(shopId, choseGoodsParam)) { throw new ApiException(CodeMessage.DBDelError, "DBDelError"); } } return(""); }
/// <summary> /// 商品列表 /// </summary> /// <param name="param"></param> /// <returns></returns> public PageResult Do_GoodsList(BaseApi baseApi) { PageResult pageResult = new PageResult(); ActiveDao activeDao = new ActiveDao(); string shopId = Util.GetUserShopId(baseApi.token); GoodsListParam goodsListParam = JsonConvert.DeserializeObject <GoodsListParam>(baseApi.param.ToString()); if (goodsListParam.current == 0) { goodsListParam.current = 1; } if (goodsListParam.pageSize == 0) { activeDao.DeleteActiveGoods(shopId); goodsListParam.pageSize = 10; } if (goodsListParam.goodsName != null && goodsListParam.goodsName != "") { goodsListParam.goodsName = " and goods_name like '%" + goodsListParam.goodsName + "%'"; } else { goodsListParam.goodsName = ""; } pageResult = activeDao.SelectGoods(goodsListParam, shopId); return(pageResult); }
public object Do_UpdateCart(BaseApi baseApi) { UpdateCartParam updateCartParam = JsonConvert.DeserializeObject <UpdateCartParam>(baseApi.param.ToString()); if (updateCartParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } OrderDao orderDao = new OrderDao(); Goods goods = orderDao.GetGoodsByCartId(updateCartParam.cartId); if (updateCartParam.goodsNum < 0) { throw new ApiException(CodeMessage.ErrorNum, "ErrorNum"); } if (goods == null) { throw new ApiException(CodeMessage.InvalidGoods, "InvalidGoods"); } if (goods.goodsStock < updateCartParam.goodsNum) { throw new ApiException(CodeMessage.NotEnoughGoods, "NotEnoughGoods"); } if (!orderDao.UpdateCart(updateCartParam.cartId, updateCartParam.goodsNum)) { throw new ApiException(CodeMessage.UpdateCartError, "UpdateCartError"); } return(""); }
public static void Publish(string message, Exception ex, BaseApi vaultApi, LogLevelType logLevel, Type declaringType) { if (GlobalEvents.IsListening(logLevel)) { GlobalEvents.RaiseException(null, new LogEventArgs(message, ex, vaultApi, logLevel, declaringType)); } }
public object Do_GetOrderList(BaseApi baseApi) { OrderDao orderDao = new OrderDao(); string memberId = Utils.GetMemberID(baseApi.token); return(orderDao.GetOrderList(memberId)); }
public object Do_GetQBuyList(BaseApi baseApi) { HomePageDao homePageDao = new HomePageDao(); var list = homePageDao.getQBuyList(); return(list); }
public static List <Point> GetTerritoryCells(Fraction owner, JEventBus eventBus = null) { FindTerritoriesCellEvent findTerritoriesCellEvent = new FindTerritoriesCellEvent(owner); BaseApi.SendEvent(eventBus, findTerritoriesCellEvent); return(findTerritoriesCellEvent.Results ?? new List <Point>()); }
public static int GetTerritoryCellsAmount(Fraction owner, JEventBus eventBus = null) { FindTerritoriesCellEvent findTerritoriesCellEvent = new FindTerritoriesCellEvent(owner); BaseApi.SendEvent(eventBus, findTerritoriesCellEvent); return(findTerritoriesCellEvent.Results?.Count ?? 0); }
public static async Task <bool> LoginAsync(string userName, string password) { var auth = new AuthenticationRequest { UserName = userName, Credentials = password, GrantType = "password" }; var uri = $"{GlobalSettings.AuthenticationEndpoint}{"api/login"}"; var authenticationInfo = await BaseApi.Post <AuthenticationResponse>(uri, auth); if (authenticationInfo == null) { return(false); } Settings.UserId = authenticationInfo.UserId; Settings.ProfileId = authenticationInfo.ProfileId; Settings.AccessToken = authenticationInfo.AccessToken; if (authenticationInfo.UserId != 0) { Settings.UserProfile = await ProfileService.GetCurrentProfileAsync(); Device.IO.File("Session.txt").WriteAllText(authenticationInfo.UserId.ToString()); return(true); } return(false); }
public object Do_GetExchangeScanCode(BaseApi baseApi) { string memberId = Utils.GetMemberID(baseApi.token); string scanCode = ""; using (var md5 = MD5.Create()) { var result = md5.ComputeHash(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())); var strResult = BitConverter.ToString(result); scanCode = "EXCHANGE_" + strResult.Replace("-", ""); } ScanExchangeCodeParam scanExchangeCodeParam = new ScanExchangeCodeParam { code = scanCode, }; ExchangeCode exchangeCode = new ExchangeCode { code = scanCode, memberId = memberId, Unique = scanExchangeCodeParam.GetUnique(), }; Utils.SetCache(exchangeCode, 0, 0, 30); return(scanCode); }
public object Do_ReloadScanCode(BaseApi baseApi) { MemberDao memberDao = new MemberDao(); string memberId = Utils.GetMemberID(baseApi.token); string scanCode = ""; using (var md5 = MD5.Create()) { var result = md5.ComputeHash(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())); var strResult = BitConverter.ToString(result); scanCode = "CHECK_" + strResult.Replace("-", ""); } if (!memberDao.UpdateScanCode(memberId, scanCode)) { throw new ApiException(CodeMessage.UpdateScanCodeError, "UpdateScanCodeError"); } MemberCheckStoreCodeParam memberCheckStoreCodeParam = new MemberCheckStoreCodeParam { code = scanCode, }; MemberCheckStoreCode memberCheckStoreCode = new MemberCheckStoreCode { code = scanCode, memberId = memberId, Unique = memberCheckStoreCodeParam.GetUnique(), }; Utils.SetCache(memberCheckStoreCode, 0, 0, 30); return(scanCode); }
/// <summary> /// 登陆 /// </summary> /// <param name="param"></param> /// <returns></returns> public object Do_UserLogin(BaseApi baseApi) { UserLoginParam userLoginParam = JsonConvert.DeserializeObject <UserLoginParam>(baseApi.param.ToString()); if (userLoginParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } if (userLoginParam.userName == null || userLoginParam.userName == "") { throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError"); } if (userLoginParam.password == null || userLoginParam.password == "") { throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError"); } string password = MD5Manager.MD5Encrypt32(userLoginParam.password); UserDao userDao = new UserDao(); UserLoginItem userLoginItem = new UserLoginItem(); userLoginItem = userDao.UserLogin(userLoginParam.userName, password); string token = Util.SaveUserMessage(userLoginItem); if (token != "") { userLoginItem.token = token; userLoginItem.isonload = true; return(userLoginItem); } else { throw new ApiException(CodeMessage.ErrorLogin, "ErrorLogin"); } }
public object Do_PayOrder(BaseApi baseApi) { PayOrderParam payOrderParam = JsonConvert.DeserializeObject <PayOrderParam>(baseApi.param.ToString()); if (payOrderParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } PreOrder preOrder = Utils.GetCache <PreOrder>(payOrderParam.preOrderId); if (preOrder == null) { throw new ApiException(CodeMessage.InvalidPreOrderId, "InvalidPreOrderId"); } string memberId = Utils.GetMemberID(baseApi.token); string orderCode = preOrder.storeCode + memberId.PadLeft(6, '0') + DateTime.Now.ToString("yyyyMMddHHmmss"); OrderDao orderDao = new OrderDao(); if (orderDao.InsertOrder(memberId, orderCode, preOrder, payOrderParam.remark, preOrder.addr, 0)) { Utils.DeleteCache(payOrderParam.preOrderId); Order order = orderDao.GetOrderInfoByCode(orderCode); if (order == null) { throw new ApiException(CodeMessage.CreateOrderError, "CreateOrderError"); } return(order); } else { throw new ApiException(CodeMessage.CreateOrderError, "CreateOrderError"); } }
public object Do_GetMemberInfo(BaseApi baseApi) { MemberDao memberDao = new MemberDao(); string memberId = Utils.GetMemberID(baseApi.token); return(memberDao.GetMemberInfo(memberId)); }
public object Do_GetActiveConsume(BaseApi baseApi) { HomePageDao homePageDao = new HomePageDao(); var list = homePageDao.getActiveConsumeListByActiveType(); return(list); }
public object Do_GetHomeShopInfo(BaseApi baseApi) { HomeShopParam homeShopParam = JsonConvert.DeserializeObject <HomeShopParam>(baseApi.param.ToString()); if (homeShopParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } HomeDao homeDao = new HomeDao(); HomeShopInfo homeShopInfo = Utils.GetCache <HomeShopInfo>(homeShopParam); if (homeShopInfo == null) { homeShopInfo = homeDao.GetHomeShopInfo(homeShopParam.id); if (homeShopInfo == null) { throw new ApiException(CodeMessage.InvalidHomePageInfoShop, "InvalidHomePageInfoShop"); } else { homeShopInfo.Unique = homeShopParam.GetUnique(); Utils.SetCache(homeShopInfo); } } return(homeShopInfo); }
private void Flow() { try { isRunning = true; instance = (IExtension)Activator.CreateInstance(extensionType); SendSignal(Signals.ON_CREATED, new ExtensionArgs(this, Wrapper)); ExitCode = instance.Main(Data); } catch (ThreadAbortException) { ExitCode = (int)ExtensionExitCodes.Killed; } catch (Exception e) { ExitCode = (int)ExtensionExitCodes.Exception; SendSignal(Signals.ON_EXCEPTION, e); string fmt = App.GetPublicResouce <string>("OpenFxExceptionMsgTitleFmt"); fmt = string.Format(fmt, Wrapper.Info.Name); string sketch = App.GetPublicResouce <string>("OpenFxExceptionSketch"); Ux.RunOnUIThread(() => { BaseApi.ShowException(fmt, sketch, e.ToString()); }); } finally { SendSignal(Signals.COMMAND_DESTORY); isRunning = false; Finished?.Invoke(this, new ThreadFinishedEventArgs(this)); } }
public object Do_GetHomePageData(BaseApi baseApi) { GetHomePageParam getHomePageParam = JsonConvert.DeserializeObject <GetHomePageParam>(baseApi.param.ToString()); if (getHomePageParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } //HomePageData homePageData = Utils.GetCache<HomePageData>(getHomePageParam); //if (homePageData == null) //{ DashboardDao dashboardDao = new DashboardDao(); string shopId = getHomePageParam.shopId; PartSalesHP partSalesHP = dashboardDao.HomePageGetPartSalesHP(shopId); SalesTrendDataHP salesTrendData = dashboardDao.HomePageGetSalesTrendData(shopId); SalesShareDataHP SalesShareData = dashboardDao.HomePageGetSalesShareData(shopId); HomePageData homePageData = new HomePageData(); homePageData.partSales = partSalesHP; homePageData.salesTrendData = salesTrendData; homePageData.SalesShareData = SalesShareData; // Utils.SetCache(homePageData, 0, 1, 0); //} return(homePageData); }
/// <inheritdoc /> public Task <WebResponse> Previous(string deviceId = null) { return(ApiClient.PostAsync <object>( BaseApi.MakeUri($"me/player/previous{BaseApi.AddDeviceId("?", deviceId)}"), null, this.Token)); }
/// <inheritdoc /> public Task <WebResponse> SetVolume(int volumePercent, string deviceId = null) { return(ApiClient.PutAsync <object>( BaseApi.MakeUri($"me/player/volume?volume_percent={volumePercent}{BaseApi.AddDeviceId("&", deviceId)}"), null, this.Token)); }
/// <inheritdoc /> public Task <WebResponse> PausePlayback(string deviceId = null) { return(ApiClient.PutAsync <object>( BaseApi.MakeUri($"me/player/pause{BaseApi.AddDeviceId("?", deviceId)}"), null, this.Token)); }
/// <inheritdoc /> public Task <WebResponse> Seek(int positionMs, string deviceId = null) { return(ApiClient.PutAsync <object>( BaseApi.MakeUri($"me/player/seek?position_ms={positionMs}{BaseApi.AddDeviceId("&", deviceId)}"), null, this.Token)); }
/// <inheritdoc /> public Task <WebResponse> SetShuffle(bool state, string deviceId = null) { return(ApiClient.PutAsync <object>( BaseApi.MakeUri($"me/player/shuffle?state={state.ToString().ToLower()}{BaseApi.AddDeviceId("&", deviceId)}"), null, this.Token)); }
public object Do_PickupOrderGoods(BaseApi baseApi) { PickupOrderGoodsParam pickupOrderGoodsParam = JsonConvert.DeserializeObject <PickupOrderGoodsParam>(baseApi.param.ToString()); if (pickupOrderGoodsParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } OpenDao openDao = new OpenDao(); StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token)); StoreDao storeDao = new StoreDao(); if (!storeDao.UpdateOrderState(pickupOrderGoodsParam.orderId, storeUser.storeUserId)) { throw new ApiException(CodeMessage.PickupGoodsError, "PickupGoodsError"); } WsPayStateParam wsPayStateParam = new WsPayStateParam { scanCode = pickupOrderGoodsParam.code, }; WsPayState wsPayState = new WsPayState { wsType = WsType.ORDER, Unique = wsPayStateParam.GetUnique(), }; Utils.SetCache(wsPayState, 0, 0, 10); return(""); }
public object Do_UpdateConfig(BaseApi baseApi) { UpdateConfigParam updateConfigParam = JsonConvert.DeserializeObject <UpdateConfigParam>(baseApi.param.ToString()); if (updateConfigParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } ConfigDao configDao = new ConfigDao(); var list = configDao.GetConfigList(updateConfigParam.env, updateConfigParam.group); if (list.Count > 0) { if (!Global.ConfigList.ContainsKey(updateConfigParam.env)) { Global.ConfigList.Add(updateConfigParam.env, new Dictionary <string, ConfigGroup>()); } if (!Global.ConfigList[updateConfigParam.env].ContainsKey(updateConfigParam.group)) { Global.ConfigList[updateConfigParam.env].Add(updateConfigParam.group, new ConfigGroup(updateConfigParam.group)); } Global.ConfigList[updateConfigParam.env][updateConfigParam.group].list = list; topic(updateConfigParam.env, updateConfigParam.group); return(Global.ConfigList[updateConfigParam.env][updateConfigParam.group]); } throw new ApiException(CodeMessage.InvalidEnvAndGroup, "InvalidEnvAndGroup"); }
public object Do_ScanOrderCode(BaseApi baseApi) { ScanOrderCodeParam scanOrderCodeParam = JsonConvert.DeserializeObject <ScanOrderCodeParam>(baseApi.param.ToString()); if (scanOrderCodeParam == null) { throw new ApiException(CodeMessage.InvalidParam, "InvalidParam"); } StoreGoodsCode storeGoodsCode = Utils.GetCache <StoreGoodsCode>(scanOrderCodeParam); if (storeGoodsCode == null) { throw new ApiException(CodeMessage.InvalidOrderCode, "InvalidOrderCode"); } StoreDao storeDao = new StoreDao(); string storeId = storeDao.GetStoreId(storeGoodsCode.order.storeCode); OpenDao openDao = new OpenDao(); StoreUser storeUser = openDao.GetStoreUser(Utils.GetOpenID(baseApi.token)); if (storeUser.storeId != storeId) { throw new ApiException(CodeMessage.NotStoreUserOrder, "NotStoreUserOrder"); } Utils.DeleteCache <StoreGoodsCode>(scanOrderCodeParam); return(storeGoodsCode.order); }
/// <summary>Obtém acesso na API via Auth basic</summary> /// <param name="usuario">usuario</param> /// <param name="password">password</param> /// <returns> /// <c>string</c> Token da autenticação /// </returns> public async Task <string> LoginAsync(string usuario, string password) { string Token = ""; var grant = $"grant_type=password&username={usuario}&password={password}"; var objectContent = new StringContent(grant, Encoding.UTF8, "application/x-www-form-urlencoded"); await TryCatchAsync(async() => { using (var client = BaseApi.HttpClient()) { var response = await client.PostAsync("api/authentication", objectContent); var resultJson = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <TokenModel>(resultJson); if (response.IsSuccessStatusCode) { //Insere o Token Gerado pela API Token = result.AccessToken; } else { throw new Exception(result.ErrorDescription); } //Retorno ao try catch return(response); } }); return(Token); }
/// <summary> /// 店员列表 /// </summary> /// <param name="param"></param> /// <returns></returns> public PageResult Do_EmployeeLogon(BaseApi baseApi) { PageResult pageResult = new PageResult(); EmployeeLogonParam employeeLogonParam = JsonConvert.DeserializeObject <EmployeeLogonParam>(baseApi.param.ToString()); if (employeeLogonParam.current == 0) { employeeLogonParam.current = 1; } if (employeeLogonParam.pageSize == 0) { employeeLogonParam.pageSize = 9; } pageResult.pagination = new Page(employeeLogonParam.current, employeeLogonParam.pageSize); string shopId = Util.GetUserShopId(baseApi.token); string power = Util.GetUserPower(baseApi.token); if (power != "1") { throw new ApiException(CodeMessage.InsufficientAuthority, "InsufficientAuthority"); } EmployeeDao employeeDao = new EmployeeDao(); pageResult = employeeDao.EmployeeLogon(shopId, employeeLogonParam); return(pageResult); }
public LogEventArgs(string message, Exception ex, BaseApi api, LogLevelType logLevel, Type declaringType) { this.Exception = ex; this.Message = message; this.Api = api; this.LogLevel = logLevel; this.DateTime = DateTime.Now; this.DeclaringType = declaringType; }
public virtual void Initialize() { string subscriptionId = "[YOUR SUBSCRIPTION ID]"; string certThumbprint = "[YOUR MANAGEMENT CERT THUMBPRINT]"; // Instantiate the subscription subscription = new AzureSubscription(subscriptionId, certThumbprint); // Instantiate a base service management class baseApi = new BaseApi(subscription); }
public static void Publish(string message, Exception ex, BaseApi api, LogLevelType logLevel) { if (GlobalEvents.IsListening(logLevel)) { Type declaringType = GetDeclaringType(); GlobalEvents.RaiseException(null, new LogEventArgs(message, ex, api, logLevel, declaringType)); } }