/// <summary> /// 新增或修改 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="t"></param> /// <returns></returns> public R SaveOrUpdate <T>(T t, string cols, bool needReturn, VerifyData <T> @delegateVerify) { R result = null; Type type = t.GetType(); int count = 0; //获取属性特性【特性里面包括其属性】 PrimaryKeyAttribute primaryKeyAttribute = type.GetPrimaryKey(); if (primaryKeyAttribute == null) { return(new R() { Successful = false, ResultHint = "获取主键发生错误" }); } //委托方法存在 直接调用 主要是验证是否可以新增或修改 if (@delegateVerify != null) { VerifyMessage verifyMessage = @delegateVerify.Invoke(t); if (verifyMessage.ExistError) { //MessageBox.Show("错误信息:" + verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(new R() { Successful = false, ResultHint = verifyMessage.ErrorInfo }); } } object primaryKey = primaryKeyAttribute.Prop.GetValue(t); //新增 ==》实际是主键不存在 if (primaryKey == null || "0".Equals(primaryKey.ToString())) { count = baseDAL.Insert(t, cols, needReturn); if (needReturn) { primaryKeyAttribute.Prop.SetValue(t, count);//设置主键的值 } } else { //修改 count = baseDAL.Update(t, cols, null, WhereType.SQL, false); } result = count > 0 ? new R() { Successful = true, ResultValue = t }: new R() { Successful = false, ResultHint = "操作失败" }; return(result); }
public IActionResult Verify() { VerifyData verifyData = Payment.GetFormVerifyData(Request.Form); try { VerifyResponse paymentResponse = Payment.Verify(new VerifyRequest { api = myApi, transId = verifyData.transId }); if (paymentResponse.status == 1) { ViewBag.transId = verifyData.transId; ViewBag.amount = paymentResponse.amount; return(View(true)); } ViewBag.Error = "خطای \"" + paymentResponse.errorCode + "\": " + paymentResponse.errorMessage; } catch { ViewBag.Error = "متاسفانه پرداخت ناموفق بوده است."; } return(View(false)); }
//开始计算按钮被点击 private void BeginCalculateButton_Click() { //去除首尾空格,转化为小写 String data = VerifyData.GetText().ToLower().Trim(); //如果数据不正确,则显示信息框提示 if (!VerifyTheData(data)) { WarningText.Text = "校验数据输入格式错误!"; BeginStoryboard((Storyboard)this.Resources["WarningBoxAppear"]); //清空校验码 VerifyCodeTB.Text = String.Empty; return; } //数据为16进制,需要转化为2进制 if (data.Contains("0x")) { char[] temp = data.ToCharArray(); StringBuilder binBulider = new StringBuilder(); for (int counter = 2; counter < temp.Length; counter++) { binBulider.Append(HexToBin(temp[counter])); } data = binBulider.ToString(); } switch (SelectParameter) { case ParameterEnum.ITU4: VerifyCodeTB.Text = CalculateVerifyCode("10011", 4, data); break; case ParameterEnum.ITU5: VerifyCodeTB.Text = CalculateVerifyCode("110101", 5, data); break; case ParameterEnum.ITU6: VerifyCodeTB.Text = CalculateVerifyCode("1000011", 6, data); break; case ParameterEnum.ITU8: VerifyCodeTB.Text = CalculateVerifyCode("100000111", 8, data); break; case ParameterEnum.NONE: VerifyCodeTB.Text = String.Empty; WarningText.Text = "参数模型未选择!!"; BeginStoryboard((Storyboard)this.Resources["WarningBoxAppear"]); break; } }
internal List <SortedDictionary <string, string> > AddOrderDetailPageItmesTodic(string purchasedItemNumber, List <SortedDictionary <string, string> > mergedScAndCartWidgetListWithOrderNum) { var orderDetailPageItemsList = new List <SortedDictionary <string, string> >(); var orderDetailPageItemsDic = new SortedDictionary <string, string>(); var productCount = BrowserInit.Driver.FindElements(By.XPath("(.//*[contains(@class,'item-start')])")); Assert.IsTrue(productCount.Count.ToString().Trim().Equals(purchasedItemNumber)); foreach (var hostingProductName in BrowserInit.Driver.FindElements(By.XPath("(.//*[contains(@class,'details-start')]/preceding-sibling::tr[not(contains(@class,'details-start'))] //h3[not(contains(concat(' ',normalize-space(.),' '),'Domain'))])"))) { orderDetailPageItemsDic.Add(EnumHelper.HostingKeys.ProductName.ToString(), hostingProductName.Text.Trim()); orderDetailPageItemsList.Add(orderDetailPageItemsDic); } foreach (var dic in orderDetailPageItemsList) { var hostingPlan = dic[EnumHelper.HostingKeys.ProductName.ToString()].Trim(); var xpath = ".//h3[.=" + hostingPlan + "']//following:td"; var productDuration = BrowserInit.Driver.FindElement(By.XPath(xpath + "[2]//p")).Text.Trim(); dic.Add(EnumHelper.HostingKeys.ProductDuration.ToString(), productDuration); var oldPrice = BrowserInit.Driver.FindElement(By.XPath(xpath + "[4]//p")).Text.Trim(); dic.Add(EnumHelper.HostingKeys.ProductPrice.ToString(), oldPrice); var productStatus = BrowserInit.Driver.FindElement(By.XPath(xpath + "[5]/p/span")).Text.Trim(); Assert.IsTrue(productStatus.Equals("Success", StringComparison.OrdinalIgnoreCase), hostingPlan + " Status is incorrect expected Success But Actual is " + productStatus); } AVerify verifingTwoListOfDic = new VerifyData(); verifingTwoListOfDic.VerifyTwoListOfDic(orderDetailPageItemsList, mergedScAndCartWidgetListWithOrderNum); var domaincount = mergedScAndCartWidgetListWithOrderNum[Convert.ToInt32(EnumHelper.HostingKeys.ProductDomainName.ToString())].Count; var billingListDomainCount = BrowserInit.Driver.FindElements( By.XPath("(.//*[contains(@class,'item-start')]//h3[contains(normalize-space(),'Domain')])")).Count; Assert.IsTrue(domaincount.Equals(billingListDomainCount), "Domain registration count should be equal Expected:- Domain Registration Count is " + domaincount + " But Actual In History Page is " + billingListDomainCount); var whoisCountInDic = mergedScAndCartWidgetListWithOrderNum.Count(dicwhois => dicwhois.ContainsKey(EnumHelper.ShoppingCartKeys.WhoisGuardForDomainStatus.ToString())); Assert.IsTrue(PageInitHelper <ValidateDomainOrderInBillingPage> .PageInit.WhoisCountInProductPage.Count.Equals(whoisCountInDic), "Who is Gaurd count should be equal Expected:- Who is Gaurd Count is " + whoisCountInDic + " But Actual In History Page is " + PageInitHelper <ValidateDomainOrderInBillingPage> .PageInit.WhoisCountInProductPage); var subtotalAmount = Regex.Replace( BrowserInit.Driver.FindElement( By.XPath("(.//*[contains(@class,'subtotal')]/td[contains(@class,'price')])[1]/p")).Text.Trim(), @"[^\d..][^\w\s]*", ""); var subtotalCharged = Regex.Replace( BrowserInit.Driver.FindElement( By.XPath("(.//*[contains(@class,'subtotal')]/td[contains(@class,'price')])[2]/p")).Text.Trim(), @"[^\d..][^\w\s]*", ""); var cultureInfo = new CultureInfo("en-US"); Assert.IsTrue(string.Format(cultureInfo, "{0:C}", subtotalAmount).Equals(string.Format(cultureInfo, "{0:C}", subtotalCharged))); return(orderDetailPageItemsList); }
public void VerifyPurchasedOrderInBillingHistoryPage( List <SortedDictionary <string, string> > listOfDicNameToBeVerified) { var purchasedItemNumber = PageInitHelper <ValidateDomainOrderInBillingPage> .PageInit.OrderSummaryPageVerification( listOfDicNameToBeVerified); var orderdetaipageList = PageInitHelper <ValidateDomainOrderInBillingPage> .PageInit.AddOrderDetailPageItemsTodic( purchasedItemNumber, listOfDicNameToBeVerified); AVerify verifingTwoListOfDic = new VerifyData(); verifingTwoListOfDic.VerifyTwoListOfDic(orderdetaipageList, listOfDicNameToBeVerified); }
/// <summary> /// 获得所有匹配的字符串 /// </summary> /// <param name="InputStr">要验证的字符串</param> /// <param name="REGStr">验证正则表达式</param> /// <param name="Perfect">验证整个字符串</param> /// <returns></returns> public static MatchCollection GetVerifyStr(string InputStr, string REGStr, bool Perfect = false) { if (VerifyInputStr(InputStr, REGStr)) { if (Perfect) { return(Regex.Matches(InputStr, VerifyData.GetPerfectRegStr(REGStr))); } else { return(Regex.Matches(InputStr, REGStr)); } } return(null); }
/// <summary> /// 验证字符串 /// </summary> /// <param name="InputStr">要验证的字符串</param> /// <param name="REGStr">验证正则表达式</param> /// <param name="Perfect">验证整个字符串</param> /// <returns></returns> public static bool VerifyStr(string InputStr, string REGStr, bool Perfect = false) { if (!string.IsNullOrEmpty(InputStr) && !string.IsNullOrEmpty(REGStr)) { if (Perfect) { return(Regex.IsMatch(InputStr, VerifyData.GetPerfectRegStr(REGStr))); } else { return(Regex.IsMatch(InputStr, REGStr)); } } return(false); }
public List <SortedDictionary <string, string> > AddShoppingCartItemsToDic(List <SortedDictionary <string, string> > cartWidgetList, string whois, string premiumDns) { // PageInitHelper<AddProductShoppingCartItems>.PageInit.MessageAndAlertVerification(); var shoppingcartItemList = PageInitHelper <AddProductShoppingCartItems> .PageInit.AddShoppingCartItemsToDictionaries(cartWidgetList, whois, premiumDns); AVerify verifingTwoListOfDic = new VerifyData(); verifingTwoListOfDic.VerifyTwoListOfDic(shoppingcartItemList, cartWidgetList); AMerge mergeTWoListOfDic = new MergeData(); var mergedScAndCartWidgetDic = mergeTWoListOfDic.MergingTwoListOfDic(shoppingcartItemList, cartWidgetList); PageInitHelper <ShoppingCartPageFactory> .PageInit.ConfirmOrderBtn.Click(); return(mergedScAndCartWidgetDic); }
protected void AddPhoneNo_Click(object sender, EventArgs e) { string errorNumber = ""; if (txtPhoneNo.Text.Trim().Length > 0) { string[] strP = txtPhoneNo.Text.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); ListBox lstP = new ListBox(); foreach (string str in strP) { lstP.Items.Add(str); } foreach (ListItem item in lstP.Items) { if (VerifyData.VerifyNumber(item.Text)) { if (!xlstPerson.Items.Contains(item)) { xlstPerson.Items.Add(item); } } else { errorNumber += item.Text + "、"; } } xlblPersonNumber.Text = xlstPerson.Items.Count.ToString(); txtPhoneNo.Text = ""; if (errorNumber.Length > 0) { JSHelper.Alert(UpdatePanel2, this, "下列号码非法:" + errorNumber.Substring(0, errorNumber.Length - 1) + @"\n注:小灵通要加区号,手机号码为11位。"); } } else { JSHelper.Alert(UpdatePanel2, this, "请输入电话号码,多个号码之间用空格隔开!"); } }
public List <SortedDictionary <string, string> > CartWidgetValidation(List <SortedDictionary <string, string> > searchResultDomainsList) { var subTotal = 0.00M; var icannfees = 0.00M; var domainValidity = string.Empty; var domainPrice = 0.00M; var domainName = string.Empty; var moreclass = BrowserInit.Driver.FindElement( By.XPath( "((.//*[contains(@class,'cart spacer-bottom')]//ul/li[@class='subtotal'] | //ul/li[@class='transfer'] | .//*[@class='cart-widget']/ul/li)/preceding-sibling::li)[last()]")) .GetAttribute(UiConstantHelper.AttributeClass); if (moreclass.Contains("more")) { var moretext = Regex.Replace(BrowserInit.Driver.FindElement(By.XPath(".//*[(contains(@class,'more'))]/a")).Text, "[^0-9.]", string.Empty).Trim(); if (!moretext.Equals(string.Empty)) { BrowserInit.Driver.FindElement(By.XPath(".//*[(contains(@class,'more'))]/a")).Click(); } } var cartWidgetList = new List <SortedDictionary <string, string> >(); var cartWidgetWindowItems = PageInitHelper <CartWidgetPageFactory> .PageInit.ProductListCount; SortedDictionary <string, string> cartWidgetDic; for (var itemIndex = cartWidgetWindowItems.Count + 1; itemIndex-- > 1;) { var xpath = "((.//*[contains(@class,'cart spacer-bottom')]//ul/li[@class='register'] | //ul/li[@class='transfer'] | .//*[@class='cart-widget']/ul/li)[not(contains(@class,'subtotal'))][not(contains(@class,'more'))])[" + itemIndex + "]"; var ele = BrowserInit.Driver.FindElement(By.XPath(xpath)); PageInitHelper <PageNavigationHelper> .PageInit.ScrollToElement(ele); cartWidgetDic = new SortedDictionary <string, string>(); var cItemClass = ele.GetAttribute("class"); if (cItemClass.Contains(string.Empty) | cItemClass.IndexOf("register", StringComparison.CurrentCultureIgnoreCase) >= 0 | cItemClass.IndexOf("transfer", StringComparison.CurrentCultureIgnoreCase) >= 0) { var widgetItemDomainName = BrowserInit.Driver.FindElement(By.XPath(xpath + "//strong")).Text; if (widgetItemDomainName.Contains(".")) { domainName = widgetItemDomainName.Trim(); } var domainValidityDetails = BrowserInit.Driver.FindElements(By.XPath(xpath + "/ul/li/p")); for (var i = 1; i <= domainValidityDetails.Count; i++) { var spanCount = BrowserInit.Driver.FindElements(By.XPath(xpath + "/ul/li/p/span")); for (var j = 1; j <= spanCount.Count; j++) { var spanclass = BrowserInit.Driver.FindElement(By.XPath("(" + xpath + "/ul/li/p/span)[" + j + "]")) .GetAttribute(UiConstantHelper.AttributeClass); if (spanclass.Contains("item")) { var spantext = BrowserInit.Driver.FindElement(By.XPath("(" + xpath + "/ul/li/p/span)[" + j + "]")) .Text; if (spantext.IndexOf("registration", StringComparison.CurrentCultureIgnoreCase) >= 0) { domainValidity = Regex.Replace(spantext, "registration", string.Empty).Trim(); } else if (spantext.IndexOf("transfer", StringComparison.CurrentCultureIgnoreCase) >= 0) { domainValidity = Regex.Replace(spantext, "transfer", string.Empty).Trim(); } else if (spantext.IndexOf("FreeDNS", StringComparison.CurrentCultureIgnoreCase) >= 0) { cartWidgetDic.Add("Domaintype", spantext.Trim()); } } else if (spanclass.Contains("price")) { var spantext = BrowserInit.Driver.FindElement(By.XPath("(" + xpath + "/ul/li/p/span)[" + j + "]/../span[1]")).Text; var spanPrice = BrowserInit.Driver.FindElement(By.XPath("(" + xpath + "/ul/li/p/span)[" + j + "]")).Text; if (spantext.IndexOf("registration", StringComparison.CurrentCultureIgnoreCase) >= 0 | spantext.IndexOf("transfer", StringComparison.CurrentCultureIgnoreCase) >= 0) { domainPrice = Convert.ToDecimal(Regex.Replace(spanPrice, @"[^\d..][^\w\s]*", string.Empty).Trim()); } else if (spantext.Contains("ICANN fee")) { icannfees = Convert.ToDecimal(Regex.Replace(spanPrice, @"[^\d..][^\w\s]*", string.Empty).Trim()); } else if (spantext.IndexOf("FreeDNS", StringComparison.CurrentCultureIgnoreCase) >= 0) { domainPrice = Convert.ToDecimal(0.00M); } } } } } cartWidgetDic.Add(EnumHelper.DomainKeys.DomainName.ToString(), domainName.Trim()); if (domainValidity != string.Empty) { cartWidgetDic.Add(EnumHelper.DomainKeys.DomainDuration.ToString(), domainValidity); } cartWidgetDic.Add(EnumHelper.DomainKeys.DomainPrice.ToString(), domainPrice.ToString(CultureInfo.InvariantCulture)); cartWidgetDic.Add(EnumHelper.CartWidget.IcanPrice.ToString(), icannfees.ToString(CultureInfo.InvariantCulture)); subTotal = subTotal + domainPrice + icannfees; cartWidgetList.Add(cartWidgetDic); domainName = string.Empty; domainValidity = string.Empty; domainPrice = 0.00M; icannfees = 0.00M; } cartWidgetDic = new SortedDictionary <string, string> { { EnumHelper.CartWidget.SubTotal.ToString(), subTotal.ToString(CultureInfo.InvariantCulture) } }; cartWidgetList.Add(cartWidgetDic); var subtotaldiv = PageInitHelper <CartWidgetPageFactory> .PageInit.SubTotal; PageInitHelper <PageNavigationHelper> .PageInit.ScrollToElement(subtotaldiv); var widgetSubTotalText = subtotaldiv.Text; var widgetSubTotal = Convert.ToDecimal(Regex.Replace(widgetSubTotalText, @"[^\d..][^\w\s]*", string.Empty).Trim()); Assert.IsTrue(widgetSubTotal.Equals(Convert.ToDecimal(cartWidgetDic[EnumHelper.CartWidget.SubTotal.ToString()])), "Cart Widget domain subtotal mismatching with subtotal values Expected - " + Convert.ToDecimal(cartWidgetDic[EnumHelper.CartWidget.SubTotal.ToString()]) + ", but actual subtotal shown as - " + widgetSubTotal); AVerify verifingTwoListOfDic = new VerifyData(); verifingTwoListOfDic.VerifyTwoListOfDic(searchResultDomainsList, cartWidgetList); AMerge mergeTWoListOfDic = new MergeData(); mergeTWoListOfDic.MergingTwoListOfDic(searchResultDomainsList, cartWidgetList); PageInitHelper <CartWidgetPageFactory> .PageInit.ViewCartButton.Click(); return(cartWidgetList); }
public async Task Verify([Remainder] string encoded) { JwtSecurityToken token; Claim userData; Claim altaId; TownUser user = Database.GetUser(Context.User); try { token = new JwtSecurityToken(encoded); userData = token.Claims.FirstOrDefault(item => item.Type == "user_data"); altaId = token.Claims.FirstOrDefault(item => item.Type == "UserId"); } catch { await ReplyAsync(Context.User.Mention + ", " + "Invalid verification token."); await Context.Message.DeleteAsync(); return; } if (userData == null || altaId == null) { await ReplyAsync(Context.User.Mention + ", " + "Invalid verification token."); await Context.Message.DeleteAsync(); } else { try { VerifyData result = JsonConvert.DeserializeObject <VerifyData>(userData.Value); string test = result.discord.ToLower(); string expected = Context.User.Username.ToLower() + "#" + Context.User.Discriminator; string alternate = Context.User.Username.ToLower() + " #" + Context.User.Discriminator; if (test != expected.ToLower() && test != alternate.ToLower()) { await ReplyAsync(Context.User.Mention + ", " + "Make sure you correctly entered your account info! You entered: " + result.discord + ". Expected: " + expected); await Context.Message.DeleteAsync(); return; } int id = int.Parse(altaId.Value); bool isValid = await AltaApi.ApiClient.ServicesClient.IsValidShortLivedIdentityTokenAsync(token); if (isValid) { await Link(Context.User, user, id); if (user.AltaInfo.Identifier == id) { await ReplyAsync(Context.User.Mention + ", " + "Already connected!"); await Context.Message.DeleteAsync(); await AccountService.UpdateAsync(user, (SocketGuildUser)Context.User); return; } if (user.AltaInfo.Identifier != 0) { await ReplyAsync(Context.User.Mention + ", " + $"Unlinking your Discord from {user.AltaInfo.Username}..."); await Context.Message.DeleteAsync(); user.AltaInfo.Unlink(); } if (Database.Users.Exists(x => x.AltaInfo != null && x.AltaInfo.Identifier == id && x.UserId != Context.User.Id)) { var oldUsers = Database.Users.Find(x => x.AltaInfo.Identifier == id && x.UserId != Context.User.Id); foreach (var x in oldUsers) { var olddiscorduser = Context.Client.GetUser(x.UserId); await ReplyAsync(Context.User.Mention + ", " + $"Unlinking your Alta account from {olddiscorduser.Mention}..."); await Context.Message.DeleteAsync(); x.AltaInfo.Unlink(); } } user.AltaInfo.Identifier = id; await AccountService.UpdateAsync(user, (SocketGuildUser)Context.User); await ReplyAsync(Context.User.Mention + ", " + $"Successfully linked to your Alta account! Hey there {user.AltaInfo.Username}!"); await Context.Message.DeleteAsync(); } else { await ReplyAsync(Context.User.Mention + ", " + "Invalid token! Try creating a new one!"); await Context.Message.DeleteAsync(); } } catch (Exception e) { await ReplyAsync(Context.User.Mention + ", " + "Invalid verification token : " + e.Message); } } }
public List <SortedDictionary <string, string> > CartWidgetValidation(List <SortedDictionary <string, string> > domainListValidation) { var cartBelongsTo = PageInitHelper <CartWidgetPageFactory> .PageInit.CartContent.GetAttribute(UiConstantHelper .AttributeId); Assert.IsTrue(cartBelongsTo.Contains("productUl")); var cartWidgetList = new List <SortedDictionary <string, string> >(); var cartWidgetDic = new SortedDictionary <string, string>(); foreach (var cartItem in PageInitHelper <CartWidgetPageFactory> .PageInit.CartWidgetWindowItems.Select((value, i) => new { i, value })) { var subitemvalue = cartItem.value; var subitemindex = cartItem.i + 1; var cItemClass = subitemvalue.GetAttribute("class"); if (!cItemClass.Equals(string.Empty)) { continue; } if (BrowserInit.Driver.FindElement(By.XPath("((.//*[contains(@class,'cart spacer-bottom')]//ul/li[@class='register'] | //ul/li[@class='transfer'] | .//*[@class='cart-widget']/ul/li|(//ul/li[not(@class)]/strong[contains(@class,'product')]/..)| .//*[@class='cart-widget']/ul/li)[not(contains(@class,'subtotal'))][not(contains(@class,'more'))])[" + subitemindex + "]/..")) .GetAttribute(UiConstantHelper.AttributeClass) .Contains("WhoisGuard")) { var pCount = subitemvalue.FindElements(By.TagName("p")); foreach (var spanClass in from itemTxt in pCount let pClassText = itemTxt.GetAttribute(UiConstantHelper.AttributeClass) where pClassText.Equals(string.Empty) select itemTxt.FindElements(By.TagName("span")) into spanCount from spanClass in spanCount select spanClass) { if (spanClass.GetAttribute(UiConstantHelper.AttributeClass).Contains("item")) { cartWidgetDic.Add(EnumHelper.ShoppingCartKeys.WhoisGuardForDomainDuration.ToString(), spanClass.Text.Replace("subscription", "").Trim()); } else if (spanClass.GetAttribute(UiConstantHelper.AttributeClass) .Contains("price")) { var priceText = spanClass.Text.Equals("FREE") ? "0.00" : Regex.Replace(spanClass.Text, @"[^\d..][^\w\s]*", ""); cartWidgetDic.Add(EnumHelper.ShoppingCartKeys.WhoisGuardForDomainPrice.ToString(), priceText.Trim()); } } } else { var strongClassName = subitemvalue.FindElement(By.TagName("strong")) .GetAttribute(UiConstantHelper.AttributeClass); var productName = subitemvalue.FindElement(By.TagName("strong")).Text; if (strongClassName.Equals("productname".Trim()) && !productName.Contains(".")) { if (subitemvalue.Text.Contains("Xeon")) { var dServers = Regex.Split(subitemvalue.Text, "(,)")[0]; var dedicatedServers = dServers.Split(' ')[0] + " " + dServers.Split(' ')[1] + " " + dServers.Split(' ')[2]; cartWidgetDic.Add(EnumHelper.HostingKeys.ProductName.ToString(), dedicatedServers); } else { cartWidgetDic.Add(EnumHelper.HostingKeys.ProductName.ToString(), subitemvalue.FindElement(By.TagName("strong")).Text); } var pCount = subitemvalue.FindElements(By.TagName("p")); foreach (var itemTxt in pCount) { var pClassText = itemTxt.GetAttribute(UiConstantHelper.AttributeClass); if (pClassText.Equals(string.Empty)) { var spanCount = itemTxt.FindElements(By.TagName("span")); foreach (var spanClass in spanCount) { if (spanClass.GetAttribute(UiConstantHelper.AttributeClass).Contains("item")) { cartWidgetDic.Add(EnumHelper.HostingKeys.ProductDuration.ToString(), spanClass.Text.Replace("subscription", "").Trim()); } else if (spanClass.GetAttribute(UiConstantHelper.AttributeClass) .Contains("price")) { cartWidgetDic.Add(EnumHelper.HostingKeys.ProductPrice.ToString(), Regex.Replace(spanClass.Text, @"[^\d..][^\w\s]*", "").Trim()); } } } if (!pClassText.EndsWith("addon")) { continue; } { var spanCount = itemTxt.FindElements(By.TagName("span")); var associatedDicKey = ""; var associatedDicValue = ""; for (var i = 0; i < spanCount.Count; i++) { if (i == 0) { string associatedDicKeyTxt = spanCount[i].Text; associatedDicKey = associatedDicKeyTxt.Contains("transfer") ? associatedDicKeyTxt.Replace("transfer", "").Trim() : associatedDicKeyTxt; } else { associatedDicValue = spanCount[i].Text; } } var priceText = associatedDicValue.Equals("FREE") ? "0.00" : Regex.Replace(associatedDicValue, @"[^\d..][^\w\s]*", ""); cartWidgetDic.Add(associatedDicKey.Trim(), priceText.Trim()); } } } else if (strongClassName.Contains("productname domain".Trim()) || productName.Contains(".")) { cartWidgetDic.Add(EnumHelper.HostingKeys.ProductDomainName.ToString(), subitemvalue.FindElement(By.TagName("strong")).Text); var pCount = subitemvalue.FindElements(By.TagName("p")); foreach (var itemTxt in pCount) { var spanCount = itemTxt.FindElements(By.TagName("span")); foreach (var spanClass in spanCount.Select((value, i) => new { i, value })) { if (spanClass.value.GetAttribute(UiConstantHelper.AttributeClass) .Contains("item") && spanClass.value.Text != "ICANN fee") { cartWidgetDic.Add(EnumHelper.HostingKeys.ProductDomainDuration.ToString(), spanClass.value.Text.Replace("registration", string.Empty).Replace("transfer", string.Empty).Trim()); } else if (spanClass.value.GetAttribute(UiConstantHelper.AttributeClass) .Contains("price") && pCount.IndexOf(itemTxt) != 1) { cartWidgetDic.Add(EnumHelper.HostingKeys.ProductDomainPrice.ToString(), decimal.Parse(Regex.Replace(spanClass.value.Text, @"[^\d..][^\w\s]*", "").Trim()).ToString(CultureInfo.InvariantCulture)); } else if (spanClass.i.ToString() == "1") { if (spanClass.value.GetAttribute(UiConstantHelper.AttributeClass) .Contains("price")) { cartWidgetDic.Add(EnumHelper.CartWidget.IcanPrice.ToString(), decimal.Parse(Regex.Replace(spanClass.value.Text, @"[^\d..][^\w\s]*", "").Trim()).ToString(CultureInfo.InvariantCulture)); } } } } } } } var subTotal = cartWidgetDic.Where(dicCartWidgetItem => dicCartWidgetItem.Value.Contains(".") && !dicCartWidgetItem.Key.Equals(EnumHelper.HostingKeys.ProductDomainName.ToString()) && !dicCartWidgetItem.Key.Equals(EnumHelper.HostingKeys.ProductName.ToString())).Aggregate(0.0m, (current, dicCartWidgetItem) => current + decimal.Parse(dicCartWidgetItem.Value)); cartWidgetDic.Add(EnumHelper.CartWidget.SubTotal.ToString(), subTotal.ToString(CultureInfo.InvariantCulture)); cartWidgetList.Add(cartWidgetDic); var widgetSubTotal = decimal.Parse(Regex.Replace( PageInitHelper <CartWidgetPageFactory> .PageInit.CartWidgetSubTotal.Text, @"[^\d..][^\w\s]*", "")); var dictWithKey = cartWidgetList.First(d => d.ContainsKey(EnumHelper.CartWidget.SubTotal.ToString())); var dicSubTotalValue = decimal.Parse( Regex.Replace(dictWithKey[EnumHelper.CartWidget.SubTotal.ToString()], "\"[^\"]*\"", "") .Trim()); Assert.IsTrue(dicSubTotalValue.Equals(widgetSubTotal), "Sub total is miss matching with widget sub total"); AVerify verifingTwoListOfDic = new VerifyData(); verifingTwoListOfDic.VerifyTwoListOfDic(domainListValidation, cartWidgetList); AMerge mergeTWoListOfDic = new MergeData(); cartWidgetList = mergeTWoListOfDic.MergingTwoListOfDic(domainListValidation, cartWidgetList); PageInitHelper <CartWidgetPageFactory> .PageInit.ViewCartButton.Click(); if (!PageInitHelper <CartWidgetPageFactory> .PageInit.ShoppingCartHeadingTxt.Text.Trim().Equals("Shopping Cart")) { PageInitHelper <CartWidgetPageFactory> .PageInit.ViewCartButton.Click(); } return(cartWidgetList); }
public async Task Verify([Remainder] string encoded) { JwtSecurityToken token; Claim userData; Claim altaId; TownUser user = Database.GetUser(Context.User); try { token = new JwtSecurityToken(encoded); userData = token.Claims.FirstOrDefault(item => item.Type == "user_data"); altaId = token.Claims.FirstOrDefault(item => item.Type == "UserId"); } catch { await ReplyAsync(Context.User.Mention + ", " + "Invalid verification token."); await Context.Message.DeleteAsync(); return; } if (userData == null || altaId == null) { await ReplyAsync(Context.User.Mention + ", " + "Invalid verification token."); await Context.Message.DeleteAsync(); } else { try { VerifyData result = JsonConvert.DeserializeObject <VerifyData>(userData.Value); string test = result.discord.ToLower(); string expected = Context.User.Username.ToLower() + "#" + Context.User.Discriminator; string alternate = Context.User.Username.ToLower() + " #" + Context.User.Discriminator; if (test != expected.ToLower() && test != alternate.ToLower()) { await ReplyAsync(Context.User.Mention + ", " + "Make sure you correctly entered your account info! You entered: " + result.discord + ". Expected: " + expected); await Context.Message.DeleteAsync(); return; } int id = int.Parse(altaId.Value); bool isValid = await AltaApi.ApiClient.ServicesClient.IsValidShortLivedIdentityTokenAsync(token); if (isValid) { await Link(Context.User, user, id, encoded); } else { await ReplyAsync(Context.User.Mention + ", " + "Invalid token! Try creating a new one!"); await Context.Message.DeleteAsync(); } } catch (Exception e) { await ReplyAsync(Context.User.Mention + ", " + "Invalid verification token : " + e.Message); } } }
public async Task Verify([Remainder] string encoded) { JwtSecurityToken token; Claim userData; Claim altaId; await DeleteCommand(); try { token = new JwtSecurityToken(encoded); userData = token.Claims.FirstOrDefault(item => item.Type == "user_data"); altaId = token.Claims.FirstOrDefault(item => item.Type == "UserId"); } catch { await ReplyMentionAsync("Invalid verification token."); return; } if (userData == null || altaId == null) { await ReplyMentionAsync("Invalid verification token."); } else { try { VerifyData result = JsonConvert.DeserializeObject <VerifyData>(userData.Value); string test = result.discord.ToLower(); string expected = Context.User.Username.ToLower() + "#" + Context.User.Discriminator; string alternate = Context.User.Username.ToLower() + " #" + Context.User.Discriminator; if (test != expected.ToLower() && test != alternate.ToLower()) { await ReplyMentionAsync("Make sure you correctly entered your account info! You entered: " + result.discord + ". Expected: " + expected); return; } int id = int.Parse(altaId.Value); bool isValid = await ApiAccess.ApiClient.ServicesClient.IsValidShortLivedIdentityTokenAsync(token); if (isValid) { if (database.altaIdMap.TryGetValue(id, out ulong connected)) { if (connected == Context.User.Id) { await ReplyMentionAsync("Already connected!"); await UpdateAsync(database.accounts[connected], (SocketGuildUser)Context.User); return; } AccountInfo old = database.accounts[database.altaIdMap[id]]; SocketGuildUser oldUser = Program.GetGuild().GetUser(old.discordIdentifier); await ReplyMentionAsync($"Unlinking your Alta account from {oldUser.Mention}..."); database.accounts.Remove(database.altaIdMap[id]); database.expiryAccounts.Remove(old); } database.altaIdMap[id] = Context.User.Id; AccountInfo account; if (database.accounts.TryGetValue(Context.User.Id, out account)) { await ReplyMentionAsync($"Unlinking your Discord from {account.username}..."); } else { account = new AccountInfo() { discordIdentifier = Context.User.Id }; database.accounts.Add(account.discordIdentifier, account); } account.altaIdentifier = id; await UpdateAsync(account, (SocketGuildUser)Context.User); await ReplyMentionAsync($"Successfully linked to your Alta account! Hey there {account.username}!"); isChanged = true; } else { await ReplyMentionAsync("Invalid token! Try creating a new one!"); } } catch (Exception e) { await ReplyMentionAsync("Invalid verification token : " + e.Message); } } }
public List <SortedDictionary <string, string> > AddShoppingCartItemsToDic(List <SortedDictionary <string, string> > cartWidgetList, string whois, string premiumDns) { var certificateQtyinSc = string.Empty; var certificateDurationinSc = string.Empty; var certificatePriceinSc = 0.00M; var shoppingcartItemList = new List <SortedDictionary <string, string> >(); const string productGroupsXpath = "(.//*[@class='product-group'])"; var productGroups = BrowserInit.Driver.FindElements(By.XPath(productGroupsXpath)); var i = 0; foreach (var productGroup in productGroups) { i = i + 1; var shoppingCartItemsDic = new SortedDictionary <string, string>(); var certificateNameinSc = Regex.Replace(productGroup.FindElement(By.TagName("strong")).Text.Trim(), "UPDATE", string.Empty); var cerQty = productGroup.FindElements(By.ClassName("qty")).Count > 0; if (cerQty) { certificateQtyinSc = productGroup.FindElement(By.XPath("//*[contains(@class,'qty')]/input")).GetAttribute(UiConstantHelper.AttributeValue).Trim(); } var certificateDurationcount = productGroup.FindElement(By.XPath("//*[contains(@class,'Duration')]")); foreach (var certificateDuration in certificateDurationcount.FindElements(By.TagName("span")).Where(certificateDuration => certificateDuration.Text.Contains("Year"))) { certificateDurationinSc = certificateDuration.Text.Trim(); break; } if (BrowserInit.Driver.FindElements(By.XPath("(" + productGroupsXpath + "[" + i + "]/../div/div/*)")).Count == 4) { var extraCount = BrowserInit.Driver.FindElements( By.XPath("(" + productGroupsXpath + "[" + i + "]/../div/div/*)[2]//*")); foreach (var extradomainPrice in from extraDomain in extraCount where extraDomain.GetAttribute(UiConstantHelper.AttributeClass).Contains("price") select decimal.Parse(Regex.Replace(extraDomain.Text, @"[^\d..][^\w\s]*", string.Empty).Trim())) { shoppingCartItemsDic.Add("Extra domain price", extradomainPrice.ToString(CultureInfo.InvariantCulture)); break; } } var cerPriceCount = BrowserInit.Driver.FindElements(By.XPath("(" + productGroupsXpath + "[" + i + "]//div[3]/span)")); foreach (var cerPrice in cerPriceCount.Where(cerPrice => cerPrice.GetAttribute(UiConstantHelper.AttributeClass).Contains("amount"))) { certificatePriceinSc = decimal.Parse(Regex.Replace(cerPrice.Text, @"[^\d..][^\w\s]*", string.Empty).Trim()); } shoppingCartItemsDic.Add(EnumHelper.Ssl.CertificateName.ToString(), certificateNameinSc); shoppingCartItemsDic.Add(EnumHelper.Ssl.CertificatePrice.ToString(), certificatePriceinSc.ToString(CultureInfo.InvariantCulture)); shoppingCartItemsDic.Add(EnumHelper.Ssl.CertificateDuration.ToString(), certificateDurationinSc); if (certificateQtyinSc != string.Empty) { shoppingCartItemsDic.Add("Certificate Qty", certificateQtyinSc); } shoppingcartItemList.Add(shoppingCartItemsDic); } AVerify verifingTwoListOfDic = new VerifyData(); verifingTwoListOfDic.VerifyTwoListOfDic(shoppingcartItemList, cartWidgetList); AMerge mergeTWoListOfDic = new MergeData(); var mergedScAndCartWidgetDic = mergeTWoListOfDic.MergingTwoListOfDic(shoppingcartItemList, cartWidgetList); PageInitHelper <ShoppingCartPageFactory> .PageInit.ConfirmOrderBtn.Click(); return(mergedScAndCartWidgetDic); }