public static void Init(params object[] utils) { foreach (var u in utils) { if (u is FileUtil) fileUtil = u as FileUtil; else if (u is ImageUtil) imgUtil = u as ImageUtil; else if (u is HUDPopup) hudPopup = u as HUDPopup; else if (u is ThreadUtil) threadUtil = u as ThreadUtil; else if (u is SQLiteUtil) sqlUtil = u as SQLiteUtil; else if (u is LogUtil) logUtil = u as LogUtil; } }
/// <summary> /// 支付 /// </summary> public ActionResult Pay() { //订单id列表 string oidList = WebHelper.GetQueryString("oidList"); LogUtil.WriteLog("oidList:" + oidList); decimal allSurplusMoney = 0M; List <OrderInfo> orderList = new List <OrderInfo>(); foreach (string oid in StringHelper.SplitString(oidList)) { //订单信息 OrderInfo orderInfo = Orders.GetOrderByOid(TypeHelper.StringToInt(oid)); if (orderInfo != null && orderInfo.OrderState == (int)OrderState.WaitPaying) { orderList.Add(orderInfo); } else { return(Redirect("/mob")); } allSurplusMoney += orderInfo.SurplusMoney; } if (orderList.Count < 1 || allSurplusMoney == 0M) { return(Redirect("/mob")); } string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { string code_url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state=lk#wechat_redirect", PayConfig.AppId, string.Format("http://{0}/mob/wechat/pay?oidList=" + oidList, BMAConfig.MallConfig.SiteUrl)); LogUtil.WriteLog("code_url:" + code_url); return(Redirect(code_url)); } LogUtil.WriteLog(" ============ 开始 获取微信用户相关信息 ====================="); #region 获取支付用户 OpenID================ string url = string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", PayConfig.AppId, PayConfig.AppSecret, code); string returnStr = HttpUtil.Send("", url); LogUtil.WriteLog("Send 页面 returnStr 第一个:" + returnStr); OpenModel openModel = JsonConvert.DeserializeObject <OpenModel>(returnStr); url = string.Format("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1}", PayConfig.AppId, openModel.refresh_token); returnStr = HttpUtil.Send("", url); openModel = JsonConvert.DeserializeObject <OpenModel>(returnStr); LogUtil.WriteLog("Send 页面 access_token:" + openModel.access_token); LogUtil.WriteLog("Send 页面 openid=" + openModel.openid); //url = string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", obj.access_token, obj.openid); //returnStr = HttpUtil.Send("", url); //LogUtil.WriteLog("Send 页面 returnStr:" + returnStr); #endregion LogUtil.WriteLog(" ============ 结束 获取微信用户相关信息 ====================="); LogUtil.WriteLog("============ 单次支付开始 ==============="); #region 支付操作============================ #region 基本参数=========================== //商户订单号 string outTradeNo = oidList.Replace(',', 's') + Randoms.CreateRandomValue(10, true); //订单名称 string subject = BMAConfig.MallConfig.SiteTitle + "购物"; //付款金额 string totalFee = ((int)(allSurplusMoney * 100)).ToString(); //openId string openId = openModel.openid; //时间戳 string timeStamp = TenpayUtil.getTimestamp(); //随机字符串 string nonceStr = TenpayUtil.getNoncestr(); //服务器异步通知页面路径 string notifyUrl = string.Format("http://{0}/mob/wechat/notify", BMAConfig.MallConfig.SiteUrl); LogUtil.WriteLog("totalFee" + totalFee); //创建支付应答对象 RequestHandler packageReqHandler = new RequestHandler(System.Web.HttpContext.Current); //初始化 packageReqHandler.init(); //设置package订单参数 具体参数列表请参考官方pdf文档,请勿随意设置 packageReqHandler.setParameter("body", subject); //商品信息 127字符 packageReqHandler.setParameter("appid", PayConfig.AppId); packageReqHandler.setParameter("mch_id", PayConfig.MchId); packageReqHandler.setParameter("nonce_str", nonceStr.ToLower()); packageReqHandler.setParameter("notify_url", notifyUrl); packageReqHandler.setParameter("openid", openId); packageReqHandler.setParameter("out_trade_no", outTradeNo); //商家订单号 packageReqHandler.setParameter("spbill_create_ip", Request.UserHostAddress); //用户的公网ip,不是商户服务器IP packageReqHandler.setParameter("total_fee", totalFee); //商品金额,以分为单位(money * 100).ToString() packageReqHandler.setParameter("trade_type", "JSAPI"); //if (!string.IsNullOrEmpty(this.Attach)) // packageReqHandler.setParameter("attach", this.Attach);//自定义参数 127字符 #endregion #region sign=============================== string sign = packageReqHandler.CreateMd5Sign("key", PayConfig.AppKey); LogUtil.WriteLog("WeiPay 页面 sign:" + sign); #endregion #region 获取package包====================== packageReqHandler.setParameter("sign", sign); string data = packageReqHandler.parseXML(); LogUtil.WriteLog("WeiPay 页面 package(XML):" + data); string prepayXml = HttpUtil.Send(data, "https://api.mch.weixin.qq.com/pay/unifiedorder"); LogUtil.WriteLog("WeiPay 页面 package(Back_XML):" + prepayXml); //获取预支付ID string prepayId = ""; string package = ""; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(prepayXml); XmlNode xn = xdoc.SelectSingleNode("xml"); XmlNodeList xnl = xn.ChildNodes; if (xnl.Count > 7) { prepayId = xnl[7].InnerText; package = string.Format("prepay_id={0}", prepayId); LogUtil.WriteLog("WeiPay 页面 package:" + package); } #endregion #region 设置支付参数 输出页面 该部分参数请勿随意修改 ============== RequestHandler paySignReqHandler = new RequestHandler(System.Web.HttpContext.Current); paySignReqHandler.setParameter("appId", PayConfig.AppId); paySignReqHandler.setParameter("timeStamp", timeStamp); paySignReqHandler.setParameter("nonceStr", nonceStr); paySignReqHandler.setParameter("package", package); paySignReqHandler.setParameter("signType", "MD5"); string paySign = paySignReqHandler.CreateMd5Sign("key", PayConfig.AppKey); LogUtil.WriteLog("WeiPay 页面 paySign:" + paySign); #endregion #endregion Dictionary <string, string> model = new Dictionary <string, string>(); model.Add("oidList", oidList); model.Add("timeStamp", timeStamp); model.Add("nonceStr", nonceStr); model.Add("package", package); model.Add("paySign", paySign); return(PartialView("~/plugins/BrnMall.PayPlugin.WeChat/views/wechat/pay.cshtml", model)); }
public bool MoveDownProductCategoryAttribute(string productCategoryId, string productAttributeId, out string message) { bool result = false; message = "操作失败,请与管理员联系"; Dictionary <string, ProductCategoryAttributesModel> dict = GetProductCategoryAttributeList(productCategoryId, false); if (dict == null) { message = "操作失败,不存在的产品类型ID"; return(false); } ProductCategoryAttributesModel currInfo = GetProductCategoryAttributeById(productCategoryId, productAttributeId); if (currInfo == null) { message = "操作失败,不存在的产品类型属性ID"; return(false); } if (currInfo.SortOrder == dict.Count) { message = "操作失败,当前产品类型属性已经是最下序列"; return(false); } ProductCategoryAttributesModel downInfo = null; foreach (ProductCategoryAttributesModel item in dict.Values) { if (item.SortOrder == currInfo.SortOrder + 1) { downInfo = item; break; } } currInfo.SortOrder = currInfo.SortOrder + 1; downInfo.SortOrder = downInfo.SortOrder - 1; try { BeginTransaction(); if (Update(currInfo) == 1 && Update(downInfo) == 1) { CommitTransaction(); GetProductCategoryAttributeList(productCategoryId, true); result = true; message = "成功下移选中产品类型属性"; } else { RollbackTransaction(); result = false; message = "操作失败,下移选中产品类型属性失败"; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("下移选中产品类型属性异常", ex); result = false; message = "操作失败,下移选中产品类型属性异常"; } return(result); }
public bool UpdateProductCategoryAttribute(ProductCategoryAttributesModel attInfo, out string message) { bool result = false; message = "操作失败,请与管理员联系"; Dictionary <string, ProductCategoryAttributesModel> dict = GetProductCategoryAttributeList(attInfo.ProductCategoryId, false); if (dict == null) { message = "操作失败,不存在的产品类型ID"; return(false); } ProductCategoryInfoModel catInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(attInfo.ProductCategoryId); if (catInfo == null) { message = "操作失败,不存在的产品类型ID"; return(false); } foreach (ProductCategoryAttributesModel item in dict.Values) { if (item.AttributeName == attInfo.AttributeName && item.CategoryAttributeId != attInfo.CategoryAttributeId) { message = "操作失败,本产品类型存在相同名称属性"; return(false); } } ProductCategoryAttributesModel oldAttInfo = ProductCategoryAttributesService.Instance.GetProductCategoryAttributeById(attInfo.ProductCategoryId, attInfo.CategoryAttributeId); if (attInfo.FieldType != oldAttInfo.FieldType || attInfo.AttributeName != oldAttInfo.AttributeName) { message = "更改产品属性将直接影响现有本类型产品信息,系统暂不提供该功能,请与管理员联系使用其他方式实现"; return(false); } try { BeginTransaction(); //if (attInfo.AttributeName != oldAttInfo.AttributeName) //{ // string renameFieldSQL = DTableUtil.GetRenameFieldSQL(catInfo.TableName, oldAttInfo.AttributeName, attInfo.AttributeName); // ExecuteNonQuery(renameFieldSQL); //} if (Update(attInfo) == 1) { GetProductCategoryAttributeList(attInfo.ProductCategoryId, true); message = "成功更新产品类型属性"; result = true; CommitTransaction(); } else { RollbackTransaction(); message = "更新产品类型属性失败,请与管理员联系"; result = false; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("更新产品类型属性异常", ex); throw ex; } return(result); }
/// <summary> /// 根据类型名字获取Client /// </summary> /// <param name="typeName">类型名字</param> /// <returns></returns> public static RpcClient GetClient(string typeName) { LogUtil.Debug($"TypeName:{typeName}"); return(GetClient("127.0.0.1", 11025)); }
/// <summary> /// Debugログを出力する /// </summary> protected void LogDebug(string message) { LogUtil.WritePLog(logger.LogDebug, this.HttpContext, message); }
/// <summary> /// 连接失败时回调 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void Conn_ConnectionFailed(object sender, ConnectionFailedEventArgs e) { LogUtil.Error($"redis连接时发生错误,{e.EndPoint}{e.Exception.ToErrMsg()}", loggerName: "ConnectionMultiplexerFactory"); }
public OwnApiBaseController() { LogUtil.SetTrackId(); }
/// <summary> /// Method navigates user to the Background Check page by button in Home menu /// </summary> public void GoToBackgroundCheckPage() { commonMethods.GetElementByWithLogs(driver, BackgroundCheckButtonLocator, "Can NOT click on 'Background Check' button").Click(); LogUtil.WriteDebug("Go to Background Check page"); }
/// <summary> /// Method navigates user to the Partnership page by button in Home menu /// </summary> public void GoToPartnershipPage() { commonMethods.GetElementByWithLogs(driver, PartnershipButtonLocator, "Can NOT click on 'Partnership' button").Click(); LogUtil.WriteDebug("Go to Partnership page"); }
/// <summary> /// Method navigates user to the Service Request page by button in Home menu /// </summary> public void GoToServiceRequestPage() { commonMethods.GetElementByWithLogs(driver, ServiceRequestButtonLocator, "Can NOT click on 'Service Request' button").Click(); LogUtil.WriteDebug("Go to Service Request page"); }
/// <summary> /// Method navigates user to the Dashboard page by button in Home menu /// </summary> public void GoToDashboardPage() { commonMethods.GetElementByWithLogs(driver, DashboardButtonLocator, "Can NOT click on 'Dashboard' button").Click(); LogUtil.WriteDebug("Go to Dashboard page"); }
/// <summary> /// Method WAITS UNTIL Home page appears /// </summary> public void WaitUntilHomePageAppears() { commonMethods.GetElementByWithLogs(driver, HomeMenuLocator, "Home page did not open"); LogUtil.WriteDebug("Waiting for Home page "); }
/// <summary> /// Method checks if the User Menu is present /// </summary> public bool IsUserProfileMenuPresent() { LogUtil.WriteDebug("Check if User Menu present"); return(commonMethods.IsElementPresent(UserMenuLocator)); }
public static void setLogonTypeUI() { LoginScript script = OtherData.s_loginScript; // 更新的部分 if (ShieldThirdLogin.isShield(OtherData.s_channelName)) { GameUtil.showGameObject(script.m_button_guanfang.gameObject); script.m_button_guanfang.transform.localPosition = new Vector3(0, -194.1f, 0); GameUtil.hideGameObject(script.m_button_qq.gameObject); GameUtil.hideGameObject(script.m_button_wechat.gameObject); GameUtil.hideGameObject(script.m_button_defaultLogin.gameObject); GameUtil.hideGameObject(script.m_button_3rdLogin.gameObject); return; } bool is3RdLogin = ChannelHelper.Is3RdLogin(); string channelAllName = ChannelHelper.GetChannelAllName(); LogUtil.Log("渠道号:" + OtherData.s_channelName + ",渠道名:" + channelAllName); bool isThirdLogin = PlatformHelper.IsThirdLogin(); if (is3RdLogin && isThirdLogin) { return; } else { { int defaultLoginType = PlayerPrefs.GetInt("DefaultLoginType", (int)OtherData.s_defaultLoginType); switch (defaultLoginType) { case (int)OtherData.DefaultLoginType.DefaultLoginType_Default: { GameUtil.showGameObject(script.m_button_guanfang.gameObject); GameUtil.showGameObject(script.m_button_qq.gameObject); GameUtil.showGameObject(script.m_button_wechat.gameObject); GameUtil.hideGameObject(script.m_button_defaultLogin.gameObject); GameUtil.hideGameObject(script.m_button_3rdLogin.gameObject); } break; case (int)OtherData.DefaultLoginType.DefaultLoginType_GuanFang: { GameUtil.hideGameObject(script.m_button_guanfang.gameObject); GameUtil.hideGameObject(script.m_button_qq.gameObject); GameUtil.hideGameObject(script.m_button_wechat.gameObject); GameUtil.hideGameObject(script.m_button_3rdLogin.gameObject); GameUtil.showGameObject(script.m_button_defaultLogin.gameObject); script.m_button_defaultLogin.transform.Find("Text_LoginType").GetComponent <Text>().text = "账号登录"; } break; case (int)OtherData.DefaultLoginType.DefaultLoginType_QQ: { GameUtil.hideGameObject(script.m_button_guanfang.gameObject); GameUtil.hideGameObject(script.m_button_qq.gameObject); GameUtil.hideGameObject(script.m_button_wechat.gameObject); GameUtil.hideGameObject(script.m_button_3rdLogin.gameObject); GameUtil.showGameObject(script.m_button_defaultLogin.gameObject); script.m_button_defaultLogin.transform.Find("Text_LoginType").GetComponent <Text>().text = "QQ登录"; } break; case (int)OtherData.DefaultLoginType.DefaultLoginType_WeChat: { GameUtil.hideGameObject(script.m_button_guanfang.gameObject); GameUtil.hideGameObject(script.m_button_qq.gameObject); GameUtil.hideGameObject(script.m_button_wechat.gameObject); GameUtil.hideGameObject(script.m_button_3rdLogin.gameObject); GameUtil.showGameObject(script.m_button_defaultLogin.gameObject); script.m_button_defaultLogin.transform.Find("Text_LoginType").GetComponent <Text>().text = "微信登录"; } break; } } } }
/// <summary> /// Initializes the ClientContext. /// </summary> public void InitClientContext() { try { LogUtil.LogMessage("Initializing site collection (ClientContext) for {0}.", this.Url); // Set client context this.ClientContext = new SPClient.ClientContext(this.Url); this.ClientContext.ApplicationName = ProductUtil.GetProductName(); // Set authentication mode and credentials switch (this.Authentication) { case AuthenticationMode.Default: this.ClientContext.AuthenticationMode = ClientAuthenticationMode.Default; if (this.UseCurrentCredentials) { LogUtil.LogMessage("Using current user credentials for user '{0}\\{1}'.", Environment.UserDomainName, Environment.UserName); this.ClientContext.Credentials = CredentialCache.DefaultNetworkCredentials; } else { LogUtil.LogMessage("Using custom credentials for user '{0}'.", this.UserName); this.ClientContext.Credentials = new NetworkCredential(this.UserName, this.Password); } break; case AuthenticationMode.SharePointOnline: LogUtil.LogMessage("Using SharePoint Online credentials for user '{0}'.", this.UserName); this.ClientContext.AuthenticationMode = ClientAuthenticationMode.Default; this.ClientContext.Credentials = new SharePointOnlineCredentials(this.UserName, this.Password.GetSecureString()); break; case AuthenticationMode.Anonymous: LogUtil.LogMessage("Using anonymous access."); this.ClientContext.AuthenticationMode = ClientAuthenticationMode.Anonymous; break; case AuthenticationMode.Forms: LogUtil.LogMessage("Using Forms Based authentication for user '{0}'.", this.UserName); this.ClientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication; this.ClientContext.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo(this.UserName, this.Password); break; case AuthenticationMode.Claims: LogUtil.LogMessage("Using Claims authentication."); bool isCancelled = false; this.ClientContext = ClaimClientContext.GetAuthenticatedContext(this.Url.ToString(), out isCancelled); if (isCancelled) { throw new Exception("Could not load site. Please retry.", new Exception("Loading site cancelled by user.")); } break; default: throw new NotImplementedException("Current authentication mode not supported."); } LogUtil.LogMessage("Valide (execute) the ClientContext."); // Try connection, to ensure site is available SPClient.Site site = this.ClientContext.Site; this.ClientContext.Load(site); this.ClientContext.ExecuteQuery(); // After succes set variables this.IsLoaded = true; this.LoadDate = DateTime.Now; LogUtil.LogMessage("ClientContext successful loaded."); LogUtil.LogMessage("ClientContext technical data. ServerVersion: {0}. ServerSchemaVersion: {1}. ServerLibraryVersion: {2}. RequestSchemaVersion: {3}. TraceCorrelationId: {4}", this.ClientContext.ServerVersion, this.ClientContext.ServerSchemaVersion, this.ClientContext.ServerLibraryVersion, this.ClientContext.RequestSchemaVersion, this.ClientContext.TraceCorrelationId); //Try retrieving the SharePoint Server build version this.BuildVersion = TryGetServerVersion(site.Url); } catch (FileNotFoundException ex) { LogUtil.LogException(string.Format("File '{0}' not found, check log file {1} for detailed information.", ex.FileName, ex.FusionLog), ex); throw; } }
/// <summary> /// Method navigates user to the Organization page by button in Home menu /// </summary> public void GoToOrganizationPage() { commonMethods.GetElementByWithLogs(driver, OrganizationButtonLocator, "Can NOT click on 'Organization' button").Click(); LogUtil.WriteDebug("Go to Organization page"); }
/// <summary> /// redis内部发生错误时回掉 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void Conn_ErrorMessage(object sender, RedisErrorEventArgs e) { LogUtil.Debug($"redis内部发生错误,{e.EndPoint}:{e.Message}", loggerName: "ConnectionMultiplexerFactory"); }
/// <summary> /// Method navigates user to the Site Config page by button in Home menu /// </summary> public void GoToSiteConfigPage() { commonMethods.GetElementByWithLogs(driver, SiteConfigButtonLocator, "Can NOT click on 'Site Config' button").Click(); LogUtil.WriteDebug("Go to Site Config page"); }
/// <summary> /// Infomationログを出力する /// </summary> protected void LogInformation(string message) { LogUtil.WritePLog(logger.LogInformation, this.HttpContext, message); }
/// <summary> /// Method navigates user to the Disciplinary page by button in Home menu /// </summary> public void GoToDisciplinaryPage() { commonMethods.GetElementByWithLogs(driver, DisciplinaryButtonLocator, "Can NOT click on 'Disciplinary' button").Click(); LogUtil.WriteDebug("Go to Disciplinary page"); }
/// <summary> /// 计算式结果显示输出 /// </summary> /// <param name="formulas">计算式</param> public void ConsoleFormulas(IList <LearnLengthUnitFormula> formulas) { LogUtil.LogDebug(MessageUtil.GetMessage(() => MsgResources.I0004T, "認識長度單位")); formulas.ToList().ForEach(d => { StringBuilder format = new StringBuilder(); switch (d.LengthUnitTransType) { // 米轉換為分米 case LengthUnitTransformType.M2D: format.AppendFormat("({0})米 = ({1})分米 填空項目:{2}", d.LengthUnitItme.Meter, d.LengthUnitItme.Decimetre, (d.Gap == GapFilling.Left) ? "米" : "分米"); break; // 米轉換為釐米 case LengthUnitTransformType.M2C: format.AppendFormat("({0})米 = ({1})釐米 填空項目:{2}", d.LengthUnitItme.Meter, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "米" : "釐米"); break; // 米轉換為毫米 case LengthUnitTransformType.M2MM: format.AppendFormat("({0})米 = ({1})毫米 填空項目:{2}", d.LengthUnitItme.Meter, d.LengthUnitItme.Millimeter, (d.Gap == GapFilling.Left) ? "米" : "毫米"); break; // 分米轉換為米 case LengthUnitTransformType.D2M: format.AppendFormat("({0})分米 = ({1})米 填空項目:{2}", d.LengthUnitItme.Decimetre, d.LengthUnitItme.Meter, (d.Gap == GapFilling.Left) ? "分米" : "米"); break; // 分米轉換為釐米 case LengthUnitTransformType.D2C: format.AppendFormat("({0})分米 = ({1})釐米 填空項目:{2}", d.LengthUnitItme.Decimetre, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "分米" : "釐米"); break; // 分米轉換為毫米 case LengthUnitTransformType.D2MM: format.AppendFormat("({0})分米 = ({1})毫米 填空項目:{2}", d.LengthUnitItme.Decimetre, d.LengthUnitItme.Millimeter, (d.Gap == GapFilling.Left) ? "分米" : "毫米"); break; // 分米到米分米 case LengthUnitTransformType.D2MExt: format.AppendFormat("({0})分米 = ({1})米({2})分米 填空項目:{3}", d.LengthUnitItme.Decimetre, d.LengthUnitItme.Meter, d.RemainderDecimetre, (d.Gap == GapFilling.Left) ? "分米" : "米,分米"); break; // 分米到米釐米 case LengthUnitTransformType.D2MC: format.AppendFormat("({0})分米 = ({1})米({2})釐米 填空項目:{3}", d.LengthUnitItme.Decimetre, d.LengthUnitItme.Meter, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "分米" : "米,釐米"); break; // 釐米到米 case LengthUnitTransformType.C2M: format.AppendFormat("({0})釐米 = ({1})米 填空項目:{2}", d.LengthUnitItme.Centimeter, d.LengthUnitItme.Meter, (d.Gap == GapFilling.Left) ? "釐米" : "米"); break; // 釐米到分米 case LengthUnitTransformType.C2D: format.AppendFormat("({0})釐米 = ({1})分米 填空項目:{2}", d.LengthUnitItme.Centimeter, d.LengthUnitItme.Decimetre, (d.Gap == GapFilling.Left) ? "釐米" : "分米"); break; // 釐米到毫米 case LengthUnitTransformType.C2MM: format.AppendFormat("({0})釐米 = ({1})毫米 填空項目:{2}", d.LengthUnitItme.Centimeter, d.LengthUnitItme.Millimeter, (d.Gap == GapFilling.Left) ? "釐米" : "毫米"); break; // 釐米到米分米 case LengthUnitTransformType.C2MD: format.AppendFormat("({0})釐米 = ({1})米({2})分米 填空項目:{3}", d.LengthUnitItme.Centimeter, d.LengthUnitItme.Meter, d.LengthUnitItme.Decimetre, (d.Gap == GapFilling.Left) ? "釐米" : "米,分米"); break; // 釐米到分米毫米 case LengthUnitTransformType.C2DMM: format.AppendFormat("({0})釐米 = ({1})分米({2})毫米 填空項目:{3}", d.LengthUnitItme.Centimeter, d.LengthUnitItme.Decimetre, d.LengthUnitItme.Millimeter, (d.Gap == GapFilling.Left) ? "釐米" : "分米,毫米"); break; // 釐米到米分米釐米 case LengthUnitTransformType.C2MDExt: format.AppendFormat("({0})釐米 = ({1})米({2})分米({3})釐米 填空項目:{4}", d.LengthUnitItme.Centimeter, d.LengthUnitItme.Meter, d.LengthUnitItme.Decimetre, d.RemainderCentimeter, (d.Gap == GapFilling.Left) ? "釐米" : "米,分米,釐米"); break; default: break; // 毫米到米 case LengthUnitTransformType.MM2M: format.AppendFormat("({0})毫米 = ({1})米 填空項目:{2}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Meter, (d.Gap == GapFilling.Left) ? "毫米" : "米"); break; // 毫米到分米 case LengthUnitTransformType.MM2D: format.AppendFormat("({0})毫米 = ({1})分米 填空項目:{2}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Decimetre, (d.Gap == GapFilling.Left) ? "毫米" : "分米"); break; // 毫米到釐米 case LengthUnitTransformType.MM2C: format.AppendFormat("({0})毫米 = ({1})釐米 填空項目:{2}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "毫米" : "釐米"); break; // 毫米到米分米 case LengthUnitTransformType.MM2MD: format.AppendFormat("({0})毫米 = ({1})米({2})分米 填空項目:{3}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Meter, d.LengthUnitItme.Decimetre, (d.Gap == GapFilling.Left) ? "毫米" : "米,分米"); break; // 毫米到米分米釐米 case LengthUnitTransformType.MM2MDC: format.AppendFormat("({0})毫米 = ({1})米({2})分米({3})釐米 填空項目:{4}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Meter, d.LengthUnitItme.Decimetre, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "毫米" : "米,分米,釐米"); break; // 毫米到米分米釐米 case LengthUnitTransformType.MM2DC: format.AppendFormat("({0})毫米 = ({1})分米({2})釐米 填空項目:{3}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Decimetre, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "毫米" : "分米,釐米"); break; // 毫米到米釐米 case LengthUnitTransformType.MM2MC: format.AppendFormat("({0})毫米 = ({1})米({2})釐米 填空項目:{3}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Meter, d.LengthUnitItme.Centimeter, (d.Gap == GapFilling.Left) ? "毫米" : "米,釐米"); break; // 毫米到米分米釐米毫米 case LengthUnitTransformType.MM2MDCExt: format.AppendFormat("({0})毫米 = ({1})米({2})分米({3})釐米({4})毫米 填空項目:{5}", d.LengthUnitItme.Millimeter, d.LengthUnitItme.Meter, d.LengthUnitItme.Decimetre, d.LengthUnitItme.Centimeter, d.RemainderMillimeter, (d.Gap == GapFilling.Left) ? "毫米" : "米,分米,釐米,毫米"); break; } Console.WriteLine(format); }); }
/// <summary> /// Method navigates user to the Time page by button in Home menu /// </summary> public void GoToTimePage() { commonMethods.GetElementByWithLogs(driver, TimeButtonLocator, "Can NOT click on 'Time' button").Click(); LogUtil.WriteDebug("Go to Time page"); }
public bool DeleteProductCategoryAttribute(string productCategoryId, string productAttributeId, out string message) { bool result = false; message = "操作失败,请与管理员联系"; Dictionary <string, ProductCategoryAttributesModel> dict = GetProductCategoryAttributeList(productCategoryId, false); if (dict == null) { message = "操作失败,不存在的产品类型ID"; return(false); } ProductCategoryAttributesModel currInfo = GetProductCategoryAttributeById(productCategoryId, productAttributeId); if (currInfo == null) { message = "操作失败,不存在的产品类型属性ID"; return(false); } ProductCategoryInfoModel catInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(currInfo.ProductCategoryId); if (catInfo == null) { message = "操作失败,不存在的产品类型ID"; return(false); } try { BeginTransaction(); foreach (ProductCategoryAttributesModel item in dict.Values) { if (item.SortOrder > currInfo.SortOrder) { item.SortOrder = item.SortOrder + 1; if (Update(item) != 1) { message = "更新产品属性排序索引失败,请与管理员联系"; RollbackTransaction(); return(false); } } } string deleteFieldSQL = DTableUtil.GetDeleteFieldSQL(catInfo.TableName, currInfo.AttributeName); ExecuteNonQuery(deleteFieldSQL); if (Delete(currInfo.CategoryAttributeId) == 1) { CommitTransaction(); message = "成功删除选中产品属性"; GetProductCategoryAttributeList(currInfo.ProductCategoryId, true); result = true; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("删除选中产品类型属性异常", ex); result = false; message = "操作失败,删除选中产品类型属性异常"; } return(result); }
/// <summary> /// Method navigates user to the Logs page by button in Home menu /// </summary> public void GoToLogsPage() { commonMethods.GetElementByWithLogs(driver, LogsButtonLocator, "Can NOT click on 'Logs' button").Click(); LogUtil.WriteDebug("Go to Logs page"); }
public bool CreateProductCategoryAttribute(ProductCategoryAttributesModel attInfo, out string message) { bool result = false; message = "操作失败,请与管理员联系"; if (attInfo.FieldType.ToLower() == "string") { if (attInfo.FieldMinLength <= 1 || attInfo.FieldMaxLength <= 1 || attInfo.FieldMaxLength <= attInfo.FieldMinLength) { message = "属性字段长度有误,请检查输入"; return(false); } } ProductCategoryInfoModel catInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(attInfo.ProductCategoryId); if (catInfo == null) { message = "失败失败,不存在此产品类型ID"; return(false); } Dictionary <string, ProductCategoryAttributesModel> dict = GetProductCategoryAttributeList(attInfo.ProductCategoryId, false); if (dict == null) { message = "操作失败,不存在的产品类型ID"; return(false); } foreach (ProductCategoryAttributesModel item in dict.Values) { if (item.AttributeName == attInfo.AttributeName) { message = "操作失败,本产品类型存在相同名称属性"; return(false); } } attInfo.CategoryAttributeId = Guid.NewGuid().ToString(); attInfo.SortOrder = dict.Count + 1; attInfo.NodeId = 0; attInfo.ParentNode = 0; attInfo.IsDisplay = 0; FieldInfo fieldInfo = new FieldInfo(); fieldInfo.FieldName = attInfo.AttributeName; if (attInfo.FieldType == "string" || attInfo.FieldType == "custom") { fieldInfo.FieldType = "varchar"; fieldInfo.MinLength = Convert.ToInt32(attInfo.FieldMinLength); fieldInfo.MaxLength = Convert.ToInt32(attInfo.FieldMaxLength); } else { fieldInfo.FieldType = attInfo.FieldType; fieldInfo.MinLength = Convert.ToInt32(attInfo.FieldMinLength); fieldInfo.MaxLength = Convert.ToInt32(attInfo.FieldMaxLength); } if (fieldInfo.MinLength < 0 && fieldInfo.FieldType == "varchar") { fieldInfo.MinLength = 50; } if (fieldInfo.MaxLength < 0 && fieldInfo.FieldType == "varchar") { fieldInfo.MaxLength = 50; } if (attInfo.FieldType == "text") { fieldInfo.FieldType = "varchar"; fieldInfo.MaxLength = -1; } fieldInfo.DefaultValue = attInfo.DefaultValue; fieldInfo.Description = attInfo.Description; fieldInfo.IsNull = (attInfo.IsRequest == 0); string addFieldSQL = DTableUtil.GetAddFieldSQL(catInfo.TableName, fieldInfo); try { BeginTransaction(); ExecuteNonQuery(addFieldSQL); if (Create(attInfo) == 1) { GetProductCategoryAttributeList(attInfo.ProductCategoryId, true); message = "成功创建产品类型属性"; result = true; CommitTransaction(); } else { RollbackTransaction(); result = false; message = "创建产品类型属性失败,请与管理员联系"; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("创建产品类型属性异常", ex); throw ex; } return(result); }
public async Task TradeAsync([Summary("Trade Code")] int code, [Summary("Showdown Set")][Remainder] string content) { content = ReusableActions.StripCodeBlock(content); var set = new ShowdownSet(content); var template = AutoLegalityWrapper.GetTemplate(set); if (set.InvalidLines.Count != 0) { var msg = $"Unable to parse Showdown Set:\n{string.Join("\n", set.InvalidLines)}"; await ReplyAsync(msg).ConfigureAwait(false); return; } try { var sav = AutoLegalityWrapper.GetTrainerInfo <T>(); var pkm = sav.GetLegal(template, out var result); if (pkm.Species == 132) { TradeExtensions <T> .DittoTrade(pkm); } if (pkm.Nickname.ToLower() == "egg" && Breeding.CanHatchAsEgg(pkm.Species)) { TradeExtensions <T> .EggTrade(pkm); } var la = new LegalityAnalysis(pkm); var spec = GameInfo.Strings.Species[template.Species]; pkm = EntityConverter.ConvertToType(pkm, typeof(T), out _) ?? pkm; bool memes = Info.Hub.Config.Trade.Memes && await TradeAdditionsModule <T> .TrollAsync(Context, pkm is not T || !la.Valid, pkm).ConfigureAwait(false); if (memes) { return; } if (pkm is not T pk || !la.Valid) { var reason = result == "Timeout" ? $"That {spec} set took too long to generate." : $"I wasn't able to create a {spec} from that set."; var imsg = $"Oops! {reason}"; if (result == "Failed") { imsg += $"\n{AutoLegalityWrapper.GetLegalizationHint(template, sav, pkm)}"; } await ReplyAsync(imsg).ConfigureAwait(false); return; } pk.ResetPartyStats(); var sig = Context.User.GetFavor(); await AddTradeToQueueAsync(code, Context.User.Username, pk, sig, Context.User).ConfigureAwait(false); } catch (Exception ex) { LogUtil.LogSafe(ex, nameof(TradeModule <T>)); var msg = $"Oops! An unexpected problem happened with this Showdown Set:\n```{string.Join("\n", set.GetSetLines())}```"; await ReplyAsync(msg).ConfigureAwait(false); } }
/// <summary> /// 通知调用 /// </summary> public ActionResult Notify() { //创建ResponseHandler实例 ResponseHandler resHandler = new ResponseHandler(System.Web.HttpContext.Current); resHandler.setKey(PayConfig.AppKey); //判断签名 try { string error = ""; if (resHandler.isWXsign(out error)) { #region 协议参数===================================== //--------------协议参数-------------------------------------------------------- //SUCCESS/FAIL此字段是通信标识,非交易标识,交易是否成功需要查 string return_code = resHandler.getParameter("return_code"); //返回信息,如非空,为错误原因签名失败参数格式校验错误 string return_msg = resHandler.getParameter("return_msg"); //微信分配的公众账号 ID string appid = resHandler.getParameter("appid"); //以下字段在 return_code 为 SUCCESS 的时候有返回-------------------------------- //微信支付分配的商户号 string mch_id = resHandler.getParameter("mch_id"); //微信支付分配的终端设备号 string device_info = resHandler.getParameter("device_info"); //微信分配的公众账号 ID string nonce_str = resHandler.getParameter("nonce_str"); //业务结果 SUCCESS/FAIL string result_code = resHandler.getParameter("result_code"); //错误代码 string err_code = resHandler.getParameter("err_code"); //结果信息描述 string err_code_des = resHandler.getParameter("err_code_des"); //以下字段在 return_code 和 result_code 都为 SUCCESS 的时候有返回--------------- //-------------业务参数--------------------------------------------------------- //用户在商户 appid 下的唯一标识 string openid = resHandler.getParameter("openid"); //用户是否关注公众账号,Y-关注,N-未关注,仅在公众账号类型支付有效 string is_subscribe = resHandler.getParameter("is_subscribe"); //JSAPI、NATIVE、MICROPAY、APP string trade_type = resHandler.getParameter("trade_type"); //银行类型,采用字符串类型的银行标识 string bank_type = resHandler.getParameter("bank_type"); //订单总金额,单位为分 string total_fee = resHandler.getParameter("total_fee"); //货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY string fee_type = resHandler.getParameter("fee_type"); //微信支付订单号 string transaction_id = resHandler.getParameter("transaction_id"); //商户系统的订单号,与请求一致。 string out_trade_no = resHandler.getParameter("out_trade_no"); //商家数据包,原样返回 string attach = resHandler.getParameter("attach"); //支 付 完 成 时 间 , 格 式 为yyyyMMddhhmmss,如 2009 年12 月27日 9点 10分 10 秒表示为 20091227091010。时区为 GMT+8 beijing。该时间取自微信支付服务器 string time_end = resHandler.getParameter("time_end"); #endregion //支付成功 if (!out_trade_no.Equals("") && return_code.Equals("SUCCESS") && result_code.Equals("SUCCESS")) { LogUtil.WriteLog("Notify 页面 支付成功,支付信息:商家订单号:" + out_trade_no + "、支付金额(分):" + total_fee + "、自定义参数:" + attach); /** * 这里输入用户逻辑操作,比如更新订单的支付状态 * * **/ List <OrderInfo> orderList = new List <OrderInfo>(); string oidList = StringHelper.SubString(out_trade_no, out_trade_no.Length - 10); foreach (string oid in StringHelper.SplitString(oidList, "s")) { OrderInfo orderInfo = Orders.GetOrderByOid(TypeHelper.StringToInt(oid)); orderList.Add(orderInfo); } decimal allSurplusMoney = 0M; foreach (OrderInfo orderInfo in orderList) { allSurplusMoney += orderInfo.SurplusMoney; } if (orderList.Count > 0 && allSurplusMoney <= TypeHelper.StringToDecimal(total_fee)) { foreach (OrderInfo orderInfo in orderList) { if (orderInfo.SurplusMoney > 0 && orderInfo.OrderState == (int)OrderState.WaitPaying) { Orders.PayOrder(orderInfo.Oid, OrderState.Confirming, transaction_id, "wechatpay", "微信支付", DateTime.Now); OrderActions.CreateOrderAction(new OrderActionInfo() { Oid = orderInfo.Oid, Uid = orderInfo.Uid, RealName = "本人", ActionType = (int)OrderActionType.Pay, ActionTime = TypeHelper.StringToDateTime(time_end), ActionDes = "你使用微信支付订单成功,微信交易号为:" + transaction_id }); } } } LogUtil.WriteLog("============ 单次支付结束 ==============="); return(Content("success")); } else { LogUtil.WriteLog("Notify 页面 支付失败,支付信息 total_fee= " + total_fee + "、err_code_des=" + err_code_des + "、result_code=" + result_code); return(new EmptyResult()); } } else { LogUtil.WriteLog("Notify 页面 isWXsign= false ,错误信息:" + error); return(new EmptyResult()); } } catch (Exception ee) { LogUtil.WriteLog("Notify 页面 发送异常错误:" + ee.Message); return(new EmptyResult()); } }
static AES_Crypt() { ilog_0 = LogUtil.GetLogger <AES_Crypt>(); }
public static void ComPressProductPic() { bool IsFtpServer = bool.Parse(ConfigurationManager.AppSettings["IsFtpServer"]); int Num_i = Convert.ToInt16(ConfigurationManager.AppSettings["NumOnceDeal"]); int SleepTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SleepTime"]); IList <ConfigPicComPressEntity> picconfig = ConfigPicComPressBLL.Instance.GetConfigListByPicSource((int)SourcePicTypeEnum.Product); while (true) { IList <ProductStylePicsEntity> _piclist = new List <ProductStylePicsEntity>(); _piclist = ProductStylePicsBLL.Instance.GetStylePicsNoComPress(Num_i); if (_piclist != null && _piclist.Count > 0) { //ParallelOptions po = new ParallelOptions(); //po.MaxDegreeOfParallelism = 15; //最多并发50个任务 string FtpServerPath = ""; string ImagePath = ""; if (IsFtpServer) { FtpServerPath = ConfigurationManager.AppSettings["FtpServerPathPrefix"].ToString(); } ImagePath = ConfigurationManager.AppSettings["ImagePath"].ToString(); if (picconfig != null && picconfig.Count > 0) { string allids = "0"; string successids = "0"; string failids = "0"; string error = "1"; foreach (ProductStylePicsEntity o in _piclist) { allids = allids + "," + o.Id.ToString(); string filepath = FtpServerPath + ImagePath.Replace("/", "\\") + o.PicUrl.Replace("/", "\\") + "." + o.PicSuffix; try { if (IsFtpServer) { foreach (ConfigPicComPressEntity en in picconfig) { Image sourceImg = Image.FromFile(filepath); ImageFormat _imgf = sourceImg.RawFormat; string savepath = FtpServerPath + ImagePath.Replace("/", "\\") + o.PicUrl.Replace("/", "\\") + en.PicName + "." + o.PicSuffix; int Width = en.Width; int Height = en.Height; using (Image ThumbImgl = PicTool.GetImageThumb(sourceImg, Width, Height)) { ThumbImgl.Save(savepath, _imgf); ThumbImgl.Dispose(); } sourceImg.Dispose(); } } else { FtpUtil _ftp = new FtpUtil(); string downloadpath = ImagePath + o.PicUrl + "." + o.PicSuffix; byte[] _byt = _ftp.DownloadFile(downloadpath); Image sourceImg = PicTool.GetImageByBytes(_byt); foreach (ConfigPicComPressEntity en in picconfig) { int Width = en.Width; int Height = en.Height; string uploadpath = ImagePath + o.PicUrl + "/" + en.PicName + "." + o.PicSuffix; using (Image ThumbImgl = PicTool.GetImageThumb(sourceImg, Width, Height)) { byte[] _byts = PicTool.GetByteByImage(ThumbImgl); _ftp.UploadFile(uploadpath, _byts, false); ThumbImgl.Dispose(); } } sourceImg.Dispose(); } successids = successids + "," + o.Id.ToString(); } catch (Exception ex) { LogUtil.Log(ex); failids = failids + "," + o.Id.ToString(); } } ProductStylePicsBLL.Instance.ComPressComplete(allids, successids, failids); } Thread.Sleep(SleepTime); } } }
public void AttachPool(IMiningPool pool) { pools[pool.Config.Id] = new PoolContext(pool, LogUtil.GetPoolScopedLogger(typeof(ShareRecorder), pool.Config)); pool.Shares.Subscribe(x => { queue.Add(x.Share); }); }