public HomeController(IHostingEnvironment env, UserData ud, Models.Impl.StaticData sd, BrowserData bd) { _env = env; _ud = ud; _sd = sd; _bd = bd; }
private void customizeContextMenuForSelection() { int count = this.GetBrowser().Form.Grid.SelectedItems.Count; bool itemsSelected = count > 0; bool create = true; bool saveAs = count == 1; bool delete = count == 1; if (count == 1) { BrowserData item = (BrowserData)this.GetBrowser().Form.Grid.SelectedItem; List <Right> rights = null; PrivilegeObserver observer = new PrivilegeObserver(); if (!ApplicationManager.User.IsAdmin()) { RightService service = ApplicationManager.ControllerFactory.ServiceFactory.GetRightService(); rights = service.getUserRights(this.SubjectType.label, item.oid); } saveAs = RightsUtil.HasRight(Domain.RightType.SAVE_AS, rights); delete = RightsUtil.HasRight(Domain.RightType.DELETE, rights); create = observer.hasPrivilege(this.FunctionalityCode, Domain.RightType.CREATE); } this.GetBrowser().Form.Grid.NewMenuItem.IsEnabled = create; this.GetBrowser().Form.Grid.OpenMenuItem.IsEnabled = itemsSelected; //this.GetBrowser().Form.Grid.RenameMenuItem.IsEnabled = saveAs && count == 1; this.GetBrowser().Form.Grid.SaveAsMenuItem.IsEnabled = saveAs && count == 1; //this.GetBrowser().Form.Grid.CopyMenuItem.IsEnabled = itemsSelected && create; //this.GetBrowser().Form.Grid.PasteMenuItem.IsEnabled = create; this.GetBrowser().Form.Grid.DeleteMenuItem.IsEnabled = itemsSelected && delete; customizeContextMenu(); }
public GpApi3DSecureTests() { // Create card data card = new CreditCardData { ExpMonth = expMonth, ExpYear = expYear, CardHolderName = "John Smith" }; // Shipping address shippingAddress = new Address { StreetAddress1 = "Apartment 852", StreetAddress2 = "Complex 741", StreetAddress3 = "no", City = "Chicago", PostalCode = "5001", State = "IL", CountryCode = "840" }; // Browser data browserData = new BrowserData { AcceptHeader = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,*/*;q=0.8", ColorDepth = ColorDepth.TWENTY_FOUR_BITS, IpAddress = "123.123.123.123", JavaEnabled = true, Language = "en", ScreenHeight = 1080, ScreenWidth = 1920, ChallengeWindowSize = ChallengeWindowSize.WINDOWED_600X400, Timezone = "0", UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" }; }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Controller objects automation = new Automation(); navigation = new Navigation(); htmlDoc = new HTMLDoc(); dataGrid = new Controller.DataGrid(); webMiner = new WebMiner(); rnd = new Random(); // Layered prediction statisticalPrediction = new StatisticalPrediction(); uIComponent = new UIContexter(); userRule = new UserRule(); // Model Objects browserData = new BrowserData(); dBAccess = new SQLiteAccess(); formData = new FormData(); // View objects //browserView = new BrowserView(); Application.Run(formNavi = new FormNavi()); }
// Receives the browser data from the javascript script and splits it into its components. // Sets browserdata. public void ProcessBrowserData(string data) { if (data != null) { // Constructor from string to split. browser = new BrowserData(data); } }
//TODO - unncomment before official release public static void LogBrowser(BrowserData bd) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); int browserLogId = bld.LogBrowser(bd); foreach (System.Collections.DictionaryEntry kvp in bd.Capabilities) { bld.LogBrowserCapability(browserLogId, kvp.Key.ToString(), kvp.Value.ToString()); } }
public GpApi3DSecure2Tests() { // Create card data card = new CreditCardData { Number = GpApi3DSTestCards.CARD_CHALLENGE_REQUIRED_V2_1, ExpMonth = expMonth, ExpYear = expYear, CardHolderName = "John Smith" }; // Shipping address shippingAddress = new Address { StreetAddress1 = "Apartment 852", StreetAddress2 = "Complex 741", StreetAddress3 = "no", City = "Chicago", PostalCode = "5001", State = "IL", CountryCode = "840" }; // Browser data browserData = new BrowserData { AcceptHeader = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,*/*;q=0.8", ColorDepth = ColorDepth.TWENTY_FOUR_BITS, IpAddress = "123.123.123.123", JavaEnabled = true, Language = "en", ScreenHeight = 1080, ScreenWidth = 1920, ChallengeWindowSize = ChallengeWindowSize.WINDOWED_600X400, Timezone = "0", UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" }; // Mobile data mobileData = new MobileData { EncodedData = "ew0KCSJEViI6ICIxLjAiLA0KCSJERCI6IHsNCgkJIkMwMDEiOiAiQW5kcm9pZCIsDQoJCSJDMDAyIjogIkhUQyBPbmVfTTgiLA0KCQkiQzAwNCI6ICI1LjAuMSIsDQoJCSJDMDA1IjogImVuX1VTIiwNCgkJIkMwMDYiOiAiRWFzdGVybiBTdGFuZGFyZCBUaW1lIiwNCgkJIkMwMDciOiAiMDY3OTc5MDMtZmI2MS00MWVkLTk0YzItNGQyYjc0ZTI3ZDE4IiwNCgkJIkMwMDkiOiAiSm9obidzIEFuZHJvaWQgRGV2aWNlIg0KCX0sDQoJIkRQTkEiOiB7DQoJCSJDMDEwIjogIlJFMDEiLA0KCQkiQzAxMSI6ICJSRTAzIg0KCX0sDQoJIlNXIjogWyJTVzAxIiwgIlNXMDQiXQ0KfQ0K" , ApplicationReference = "f283b3ec-27da-42a1-acea-f3f70e75bbdc" , SdkInterface = SdkInterface.BOTH , EphemeralPublicKey = JsonDoc.Parse("{" + "\"kty\":\"EC\"," + "\"crv\":\"P-256\"," + "\"x\":\"WWcpTjbOqiu_1aODllw5rYTq5oLXE_T0huCPjMIRbkI\",\"y\":\"Wz_7anIeadV8SJZUfr4drwjzuWoUbOsHp5GdRZBAAiw\"" + "}" ) , MaximumTimeout = 50 , ReferenceNumber = "3DS_LOA_SDK_PPFU_020100_00007" , SdkTransReference = "b2385523-a66c-4907-ac3c-91848e8c0067" }; mobileData.SetSdkUiTypes(SdkUiType.OOB); }
private static CategoryContentItem CreteCategoryItem(BrowserData modelData, NavigateToMediaCommand navigationCommand, int level, bool isInternalModeEnable, Action <CategoryItem> selectCategoryAction) { if (modelData.Type == BrowserDataType.Media) { return(new MediaItem(modelData.Media, navigationCommand, isInternalModeEnable)); } else { var children = modelData.Children.OrderBy(x => x.Order).ThenBy(x => x.Name).Select(md => CreteCategoryItem(md, navigationCommand, level + 1, isInternalModeEnable, selectCategoryAction)); return(new CategoryItem(level, modelData.ID, modelData.Name, isInternalModeEnable, selectCategoryAction, children.ToList())); } }
/// <summary> /// Rajoute une inputTable /// </summary> /// <param name="inputTable">L'inputTable à modifier</param> public void AddTreeLoop(TransformationTreeItem treeLoop) { BrowserData data = new BrowserData(); if (treeLoop.oid.HasValue) { data.oid = treeLoop.oid.Value; } data.name = treeLoop.name; this.liste.Add(treeLoop); this.cvs.DeferRefresh(); }
/// <summary> /// Rajoute une design /// </summary> /// <param name="inputTable">L'design à modifier</param> public void AddDesign(Design design) { BrowserData data = new BrowserData(); if (design.oid.HasValue) { data.oid = design.oid.Value; } data.name = design.name; data.group = design.group.name; this.liste.Add(data); this.cvs.DeferRefresh(); }
/// <summary> /// Rajoute un retport /// </summary> /// <param name="inputTable">L'design à modifier</param> public void AddStructuredReport(StructuredReport retport) { BrowserData data = new BrowserData(); if (retport.oid.HasValue) { data.oid = retport.oid.Value; } data.name = retport.name; data.group = retport.group.name; this.liste.Add(data); this.cvs.DeferRefresh(); }
public HomeController(ILogger <HomeController> logger, IHostingEnvironment env, UserData ud, IAgriConfigurationRepository sd, BrowserData bd, IOptions <AppSettings> appSettings) { _logger = logger; _env = env; _ud = ud; _sd = sd; _bd = bd; _appSettings = appSettings; }
/// <summary> /// Rajoute une grille /// </summary> /// <param name="grille">La grille à modifier</param> public void AddTemplate(ReconciliationFilterTemplate template) { BrowserData data = new BrowserData(); if (template.oid.HasValue) { data.oid = template.oid.Value; } data.name = template.name; if (template.group != null) { data.group = template.group.name; } this.liste.Add(data); this.cvs.DeferRefresh(); }
/// <summary> /// Rajoute une inputTable /// </summary> /// <param name="inputTable">L'inputTable à modifier</param> public void AddTransformationTree(TransformationTree transformationTree) { BrowserData data = new BrowserData(); if (transformationTree.oid.HasValue) { data.oid = transformationTree.oid.Value; } data.name = transformationTree.name; if (transformationTree.group != null) { data.group = transformationTree.group.name; } this.liste.Add(data); this.cvs.DeferRefresh(); }
/// <summary> /// Rajoute une inputTable /// </summary> /// <param name="inputTable">L'inputTable à modifier</param> public void AddPresentation(Presentation presentation) { BrowserData data = new BrowserData(); if (presentation.oid.HasValue) { data.oid = presentation.oid.Value; } data.name = presentation.name; if (presentation.group != null) { data.group = presentation.group.name; } this.liste.Add(data); this.cvs.DeferRefresh(); }
/// <summary> /// Rajoute une grille /// </summary> /// <param name="grille">La grille à modifier</param> public void AddGrille(Grille grille) { BrowserData data = new BrowserData(); if (grille.oid.HasValue) { data.oid = grille.oid.Value; } data.name = grille.name; if (grille.group != null) { data.group = grille.group.name; } this.liste.Add(data); this.cvs.DeferRefresh(); }
protected void CustomizeView(BrowserData data, String fuctionalityCode) { this.oid = data.oid; NavigationToken token = NavigationToken.GetModifyViewToken(fuctionalityCode, data.oid); Run run1 = new Run(data.name); Hyperlink hyperLink = new Hyperlink(run1) { NavigateUri = new Uri("http://localhost//" + data.name), DataContext = token }; this.TextBlock.Inlines.Add(hyperLink); this.TextBlock.ToolTip = data.name; hyperLink.RequestNavigate += OnRequestNavigate; this.CheckBox.ToolTip = data.name; this.CheckBox.Tag = token; this.PreviewMouseRightButtonDown += BeforeContextMenu; }
public GpEcomSecure3dServiceExemptionTests() { GatewayConfig config = new GpEcomConfig { MerchantId = "myMerchantId", AccountId = "ecomeos", SharedSecret = "secret", MethodNotificationUrl = "https://www.example.com/methodNotificationUrl", ChallengeNotificationUrl = "https://www.example.com/challengeNotificationUrl", Secure3dVersion = Secure3dVersion.Any, }; ServicesContainer.ConfigureService(config); // create card data card = new CreditCardData { Number = "4263970000005262", ExpMonth = 12, ExpYear = 2025, CardHolderName = "John Smith" }; // stored card stored = new RecurringPaymentMethod( "20190809-Realex", "20190809-Realex-Credit" ); // shipping address shippingAddress = new Address { StreetAddress1 = "Apartment 852", StreetAddress2 = "Complex 741", StreetAddress3 = "no", City = "Chicago", PostalCode = "5001", State = "IL", CountryCode = "840" }; // billing address billingAddress = new Address { StreetAddress1 = "Flat 456", StreetAddress2 = "House 789", StreetAddress3 = "no", City = "Halifax", PostalCode = "W5 9HR", CountryCode = "826" }; // browser data browserData = new BrowserData { AcceptHeader = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,*/*;q=0.8", ColorDepth = ColorDepth.TWENTY_FOUR_BITS, IpAddress = "123.123.123.123", JavaEnabled = true, Language = "en", ScreenHeight = 1080, ScreenWidth = 1920, ChallengeWindowSize = ChallengeWindowSize.WINDOWED_600X400, Timezone = "0", UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" }; }
protected override bool HasDimensionKey(IVisitAggregationContext context) { BrowserData browser = context.Visit.Browser; return(!string.IsNullOrEmpty(browser.BrowserMajorName) && !string.IsNullOrEmpty(browser.BrowserVersion)); }
protected override string GetKey(IVisitAggregationContext context) { BrowserData browser = context.Visit.Browser; return(browser.BrowserMajorName + "-" + browser.BrowserVersion); }
public Transaction ProcessSecure3d(Secure3dBuilder builder) { TransactionType transType = builder.TransactionType; IPaymentMethod paymentMethod = builder.PaymentMethod; ISecure3d secure3d = (ISecure3d)paymentMethod; string timestamp = DateTime.Now.ToString("yyyy-MM-dd'T'hh:mm:ss.ffffff"); JsonDoc request = new JsonDoc(); if (transType.Equals(TransactionType.VerifyEnrolled)) { request.Set("request_timestamp", timestamp); request.Set("merchant_id", MerchantId); request.Set("account_id", AccountId); request.Set("method_notification_url", MethodNotificationUrl); string hashValue = string.Empty; if (paymentMethod is CreditCardData cardData) { request.Set("number", cardData.Number); request.Set("scheme", MapCardScheme(cardData.CardType.ToUpper())); hashValue = cardData.Number; } else if (paymentMethod is RecurringPaymentMethod storedCard) { request.Set("payer_reference", storedCard.CustomerKey); request.Set("payment_method_reference", storedCard.Key); hashValue = storedCard.CustomerKey; } string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, hashValue); SetAuthHeader(hash); string rawResponse = DoTransaction(HttpMethod.Post, "protocol-versions", request.ToString()); return(MapResponse(rawResponse)); } else if (transType.Equals(TransactionType.VerifySignature)) { string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, builder.ServerTransactionId); SetAuthHeader(hash); var queryValues = new Dictionary <string, string>(); queryValues.Add("merchant_id", MerchantId); queryValues.Add("request_timestamp", timestamp); string rawResponse = DoTransaction(HttpMethod.Get, string.Format("authentications/{0}", builder.ServerTransactionId), null, queryValues); return(MapResponse(rawResponse)); } else if (transType.Equals(TransactionType.InitiateAuthentication)) { string orderId = builder.OrderId; if (string.IsNullOrEmpty(orderId)) { orderId = GenerationUtils.GenerateOrderId(); } ThreeDSecure secureEcom = secure3d.ThreeDSecure; request.Set("request_timestamp", timestamp); request.Set("authentication_source", builder.AuthenticationSource.ToString()); request.Set("authentication_request_type", builder.AuthenticationRequestType.ToString()); request.Set("message_category", builder.MessageCategory.ToString()); request.Set("message_version", "2.1.0"); request.Set("server_trans_id", secureEcom.ServerTransactionId); request.Set("merchant_id", MerchantId); request.Set("account_id", AccountId); request.Set("challenge_notification_url", ChallengeNotificationUrl); request.Set("method_url_completion", builder.MethodUrlCompletion.ToString()); request.Set("merchant_contact_url", MerchantContactUrl); request.Set("merchant_initiated_request_type", builder.MerchantInitiatedRequestType?.ToString()); request.Set("whitelist_status", builder.WhitelistStatus); request.Set("decoupled_flow_request", builder.DecoupledFlowRequest); request.Set("decoupled_flow_timeout", builder.DecoupledFlowTimeout); request.Set("decoupled_notification_url", builder.DecoupledNotificationUrl); request.Set("enable_exemption_optimization", builder.EnableExemptionOptimization); // card details string hashValue = string.Empty; JsonDoc cardDetail = request.SubElement("card_detail"); if (paymentMethod is CreditCardData cardData) { hashValue = cardData.Number; cardDetail.Set("number", cardData.Number); cardDetail.Set("scheme", cardData.CardType.ToUpper()); cardDetail.Set("expiry_month", cardData.ExpMonth.ToString()); cardDetail.Set("expiry_year", cardData.ExpYear.ToString().Substring(2)); cardDetail.Set("full_name", cardData.CardHolderName); if (!string.IsNullOrEmpty(cardData.CardHolderName)) { string[] names = cardData.CardHolderName.Split(' '); if (names.Length >= 1) { cardDetail.Set("first_name", names[0]); } if (names.Length >= 2) { cardDetail.Set("last_name", string.Join(" ", names.Skip(1))); } } } else if (paymentMethod is RecurringPaymentMethod storedCard) { hashValue = storedCard.CustomerKey; cardDetail.Set("payer_reference", storedCard.CustomerKey); cardDetail.Set("payment_method_reference", storedCard.Key); } // order details JsonDoc order = request.SubElement("order"); order.Set("amount", builder.Amount.ToNumericCurrencyString()); order.Set("currency", builder.Currency); order.Set("id", orderId); order.Set("address_match_indicator", builder.AddressMatchIndicator ? "true" : "false"); order.Set("date_time_created", builder.OrderCreateDate?.ToString("yyyy-MM-dd'T'hh:mm'Z'")); order.Set("gift_card_count", builder.GiftCardCount); order.Set("gift_card_currency", builder.GiftCardCurrency); order.Set("gift_card_amount", builder.GiftCardAmount.ToNumericCurrencyString()); order.Set("delivery_email", builder.DeliveryEmail); order.Set("delivery_timeframe", builder.DeliveryTimeframe?.ToString()); order.Set("shipping_method", builder.ShippingMethod?.ToString()); order.Set("shipping_name_matches_cardholder_name", builder.ShippingNameMatchesCardHolderName); order.Set("preorder_indicator", builder.PreOrderIndicator?.ToString()); order.Set("reorder_indicator", builder.ReorderIndicator?.ToString()); order.Set("transaction_type", builder.OrderTransactionType?.ToString()); order.Set("preorder_availability_date", builder.PreOrderAvailabilityDate?.ToString("yyyy-MM-dd")); // shipping address Address shippingAddress = builder.ShippingAddress; if (shippingAddress != null) { JsonDoc shippingAddressElement = order.SubElement("shipping_address"); shippingAddressElement.Set("line1", shippingAddress.StreetAddress1); shippingAddressElement.Set("line2", shippingAddress.StreetAddress2); shippingAddressElement.Set("line3", shippingAddress.StreetAddress3); shippingAddressElement.Set("city", shippingAddress.City); shippingAddressElement.Set("postal_code", shippingAddress.PostalCode); shippingAddressElement.Set("state", shippingAddress.State); shippingAddressElement.Set("country", shippingAddress.CountryCode); } // payer JsonDoc payer = request.SubElement("payer"); payer.Set("email", builder.CustomerEmail); payer.Set("id", builder.CustomerAccountId); payer.Set("account_age", builder.AccountAgeIndicator?.ToString()); payer.Set("account_creation_date", builder.AccountCreateDate?.ToString("yyyy-MM-dd")); payer.Set("account_change_indicator", builder.AccountChangeIndicator?.ToString()); payer.Set("account_change_date", builder.AccountChangeDate?.ToString("yyyy-MM-dd")); payer.Set("account_password_change_indicator", builder.PasswordChangeIndicator?.ToString()); payer.Set("account_password_change_date", builder.PasswordChangeDate?.ToString("yyyy-MM-dd")); payer.Set("payment_account_age_indicator", builder.PaymentAgeIndicator?.ToString()); payer.Set("payment_account_creation_date", builder.PaymentAccountCreateDate?.ToString("yyyy-MM-dd")); payer.Set("purchase_count_last_6months", builder.NumberOfPurchasesInLastSixMonths); payer.Set("transaction_count_last_24hours", builder.NumberOfTransactionsInLast24Hours); payer.Set("transaction_count_last_year", builder.NumberOfTransactionsInLastYear); payer.Set("provision_attempt_count_last_24hours", builder.NumberOfAddCardAttemptsInLast24Hours); payer.Set("shipping_address_creation_indicator", builder.ShippingAddressUsageIndicator?.ToString()); payer.Set("shipping_address_creation_date", builder.ShippingAddressCreateDate?.ToString("yyyy-MM-dd")); // suspicious activity if (builder.PreviousSuspiciousActivity != null) { payer.Set("suspicious_account_activity", builder.PreviousSuspiciousActivity.Value ? "SUSPICIOUS_ACTIVITY" : "NO_SUSPICIOUS_ACTIVITY"); } // home phone if (!string.IsNullOrEmpty(builder.HomeNumber)) { payer.SubElement("home_phone") .Set("country_code", builder.HomeCountryCode) .Set("subscriber_number", builder.HomeNumber); } // work phone if (!string.IsNullOrEmpty(builder.WorkNumber)) { payer.SubElement("work_phone") .Set("country_code", builder.WorkCountryCode) .Set("subscriber_number", builder.WorkNumber); } // payer login data if (builder.HasPayerLoginData) { request.SubElement("payer_login_data") .Set("authentication_data", builder.CustomerAuthenticationData) .Set("authentication_timestamp", builder.CustomerAuthenticationTimestamp?.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")) .Set("authentication_type", builder.CustomerAuthenticationMethod?.ToString()); } // prior authentication data if (builder.HasPriorAuthenticationData) { request.SubElement("payer_prior_three_ds_authentication_data") .Set("authentication_method", builder.PriorAuthenticationMethod?.ToString()) .Set("acs_transaction_id", builder.PriorAuthenticationTransactionId) .Set("authentication_timestamp", builder.PriorAuthenticationTimestamp?.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")) .Set("authentication_data", builder.PriorAuthenticationData); } // recurring authorization data if (builder.HasRecurringAuthData) { request.SubElement("recurring_authorization_data") .Set("max_number_of_instalments", builder.MaxNumberOfInstallments) .Set("frequency", builder.RecurringAuthorizationFrequency) .Set("expiry_date", builder.RecurringAuthorizationExpiryDate?.ToString("yyyy-MM-dd")); } // billing details Address billingAddress = builder.BillingAddress; if (billingAddress != null) { JsonDoc billingAddressElement = payer.SubElement("billing_address"); billingAddressElement.Set("line1", billingAddress.StreetAddress1); billingAddressElement.Set("line2", billingAddress.StreetAddress2); billingAddressElement.Set("line3", billingAddress.StreetAddress3); billingAddressElement.Set("city", billingAddress.City); billingAddressElement.Set("postal_code", billingAddress.PostalCode); billingAddressElement.Set("state", billingAddress.State); billingAddressElement.Set("country", billingAddress.CountryCode); } // mobile phone if (!string.IsNullOrEmpty(builder.MobileNumber)) { JsonDoc mobilePhone = payer.SubElement("mobile_phone"); mobilePhone.Set("country_code", builder.MobileCountryCode); mobilePhone.Set("subscriber_number", builder.MobileNumber); } // browser_data BrowserData broswerData = builder.BrowserData; if (broswerData != null) { JsonDoc browserDataElement = request.SubElement("browser_data"); browserDataElement.Set("accept_header", broswerData.AcceptHeader); browserDataElement.Set("color_depth", broswerData.ColorDepth.ToString()); browserDataElement.Set("ip", broswerData.IpAddress); browserDataElement.Set("java_enabled", broswerData.JavaEnabled); browserDataElement.Set("javascript_enabled", broswerData.JavaScriptEnabled); browserDataElement.Set("language", broswerData.Language); browserDataElement.Set("screen_height", broswerData.ScreenHeight); browserDataElement.Set("screen_width", broswerData.ScreenWidth); browserDataElement.Set("challenge_window_size", broswerData.ChallengeWindowSize.ToString()); browserDataElement.Set("timezone", broswerData.Timezone); browserDataElement.Set("user_agent", broswerData.UserAgent); } // mobile fields if (builder.HasMobileFields) { JsonDoc sdkInformationElement = request.SubElement("sdk_information") .Set("application_id", builder.ApplicationId) .Set("ephemeral_public_key", builder.EphemeralPublicKey) .Set("maximum_timeout", builder.MaximumTimeout) .Set("reference_number", builder.ReferenceNumber) .Set("sdk_trans_id", builder.SdkTransactionId) .Set("encoded_data", builder.EncodedData) ; // device render options if (builder.SdkInterface != null || builder.SdkUiTypes != null) { var dro = sdkInformationElement.SubElement("device_render_options"); dro.Set("sdk_interface", builder.SdkInterface?.ToString()); if (builder.SdkUiTypes != null) { var uiTypes = new List <string>(); foreach (var sdkuiType in builder.SdkUiTypes) { uiTypes.Add(sdkuiType.ToString()); } dro.Set("sdk_ui_type", uiTypes.ToArray()); } } } string hash = GenerationUtils.GenerateHash(SharedSecret, timestamp, MerchantId, hashValue, secureEcom.ServerTransactionId); SetAuthHeader(hash); string rawResponse = DoTransaction(HttpMethod.Post, "authentications", request.ToString()); return(MapResponse(rawResponse)); } throw new ApiException(string.Format("Unknown transaction type {0}.", transType)); }
protected BrowserData GetBrowserData() { BrowserData bd = new BrowserData(); System.Web.HttpBrowserCapabilitiesBase browser = HttpContext.Request.Browser; bd.ActiveXControls = browser.ActiveXControls; bd.AOL = browser.AOL; bd.BackgroundSounds = browser.BackgroundSounds; bd.Beta = browser.Beta; bd.Browser = browser.Browser; bd.Browsers = browser.Browsers; bd.CanCombineFormsInDeck = browser.CanCombineFormsInDeck; bd.CanInitiateVoiceCall = browser.CanInitiateVoiceCall; bd.CanRenderAfterInputOrSelectElement = browser.CanRenderAfterInputOrSelectElement; bd.CanRenderEmptySelects = browser.CanRenderEmptySelects; bd.CanRenderInputAndSelectElementsTogether = browser.CanRenderInputAndSelectElementsTogether; bd.CanRenderMixedSelects = browser.CanRenderMixedSelects; bd.CanRenderOneventAndPrevElementsTogether = browser.CanRenderOneventAndPrevElementsTogether; bd.CanRenderPostBackCards = browser.CanRenderPostBackCards; bd.CanRenderSetvarZeroWithMultiSelectionList = browser.CanRenderSetvarZeroWithMultiSelectionList; bd.CanSendMail = browser.CanSendMail; bd.Capabilities = browser.Capabilities; bd.CDF = browser.CDF; bd.ClrVersion = browser.ClrVersion.ToString(); bd.Cookies = browser.Cookies; bd.Crawler = browser.Crawler; bd.DefaultSubmitButtonLimit = browser.DefaultSubmitButtonLimit; bd.EcmaScriptVersion = browser.EcmaScriptVersion.ToString(); bd.Frames = browser.Frames; bd.GatewayMajorVersion = browser.GatewayMajorVersion; bd.GatewayMinorVersion = browser.GatewayMinorVersion; bd.GatewayVersion = browser.GatewayVersion; bd.HasBackButton = browser.HasBackButton; bd.HidesRightAlignedMultiselectScrollbars = browser.HidesRightAlignedMultiselectScrollbars; bd.HtmlTextWriter = browser.HtmlTextWriter; bd.Id = browser.Id; bd.InputType = browser.InputType; bd.IsColor = browser.IsColor; bd.IsMobileDevice = browser.IsMobileDevice; bd.JavaApplets = browser.JavaApplets; bd.JScriptVersion = browser.JScriptVersion.ToString(); bd.MajorVersion = browser.MajorVersion; bd.MaximumHrefLength = browser.MaximumHrefLength; bd.MaximumRenderedPageSize = browser.MaximumRenderedPageSize; bd.MaximumSoftkeyLabelLength = browser.MaximumSoftkeyLabelLength; bd.MinorVersion = browser.MinorVersion; bd.MinorVersionString = browser.MinorVersionString; bd.MobileDeviceManufacturer = browser.MobileDeviceManufacturer; bd.MobileDeviceModel = browser.MobileDeviceModel; bd.MSDomVersion = browser.MSDomVersion.ToString(); bd.NumberOfSoftkeys = browser.NumberOfSoftkeys; bd.Platform = browser.Platform; bd.PreferredImageMime = browser.PreferredImageMime; bd.PreferredRenderingMime = browser.PreferredRenderingMime; bd.PreferredRenderingType = browser.PreferredRenderingType; bd.PreferredRequestEncoding = browser.PreferredRequestEncoding; bd.PreferredResponseEncoding = browser.PreferredResponseEncoding; bd.RendersBreakBeforeWmlSelectAndInput = browser.RendersBreakBeforeWmlSelectAndInput; bd.RendersBreaksAfterHtmlLists = browser.RendersBreaksAfterHtmlLists; bd.RendersBreaksAfterWmlAnchor = browser.RendersBreaksAfterWmlAnchor; bd.RendersBreaksAfterWmlInput = browser.RendersBreaksAfterWmlInput; bd.RendersWmlDoAcceptsInline = browser.RendersWmlDoAcceptsInline; bd.RendersWmlSelectsAsMenuCards = browser.RendersWmlSelectsAsMenuCards; bd.RequiredMetaTagNameValue = browser.RequiredMetaTagNameValue; bd.RequiresAttributeColonSubstitution = browser.RequiresAttributeColonSubstitution; bd.RequiresContentTypeMetaTag = browser.RequiresContentTypeMetaTag; bd.RequiresControlStateInSession = browser.RequiresControlStateInSession; bd.RequiresDBCSCharacter = browser.RequiresDBCSCharacter; bd.RequiresHtmlAdaptiveErrorReporting = browser.RequiresHtmlAdaptiveErrorReporting; bd.RequiresLeadingPageBreak = browser.RequiresLeadingPageBreak; bd.RequiresNoBreakInFormatting = browser.RequiresNoBreakInFormatting; bd.RequiresOutputOptimization = browser.RequiresOutputOptimization; bd.RequiresPhoneNumbersAsPlainText = browser.RequiresPhoneNumbersAsPlainText; bd.RequiresSpecialViewStateEncoding = browser.RequiresSpecialViewStateEncoding; bd.RequiresUniqueFilePathSuffix = browser.RequiresUniqueFilePathSuffix; bd.RequiresUniqueHtmlCheckboxNames = browser.RequiresUniqueHtmlCheckboxNames; bd.RequiresUniqueHtmlInputNames = browser.RequiresUniqueHtmlInputNames; bd.RequiresUrlEncodedPostfieldValues = browser.RequiresUrlEncodedPostfieldValues; bd.ScreenBitDepth = browser.ScreenBitDepth; bd.ScreenCharactersHeight = browser.ScreenCharactersHeight; bd.ScreenCharactersWidth = browser.ScreenCharactersWidth; bd.ScreenPixelsHeight = browser.ScreenPixelsHeight; bd.ScreenPixelsWidth = browser.ScreenPixelsWidth; bd.SupportsAccesskeyAttribute = browser.SupportsAccesskeyAttribute; bd.SupportsBodyColor = browser.SupportsBodyColor; bd.SupportsBold = browser.SupportsBold; bd.SupportsCacheControlMetaTag = browser.SupportsCacheControlMetaTag; bd.SupportsCallback = browser.SupportsCallback; bd.SupportsCss = browser.SupportsCss; bd.SupportsDivAlign = browser.SupportsDivAlign; bd.SupportsDivNoWrap = browser.SupportsDivNoWrap; bd.SupportsEmptyStringInCookieValue = browser.SupportsEmptyStringInCookieValue; bd.SupportsFontColor = browser.SupportsFontColor; bd.SupportsFontName = browser.SupportsFontName; bd.SupportsFontSize = browser.SupportsFontSize; bd.SupportsImageSubmit = browser.SupportsImageSubmit; bd.SupportsIModeSymbols = browser.SupportsIModeSymbols; bd.SupportsInputIStyle = browser.SupportsInputIStyle; bd.SupportsInputMode = browser.SupportsInputMode; bd.SupportsItalic = browser.SupportsItalic; bd.SupportsJPhoneMultiMediaAttributes = browser.SupportsJPhoneMultiMediaAttributes; bd.SupportsJPhoneSymbols = browser.SupportsJPhoneSymbols; bd.SupportsQueryStringInFormAction = browser.SupportsQueryStringInFormAction; bd.SupportsRedirectWithCookie = browser.SupportsRedirectWithCookie; bd.SupportsSelectMultiple = browser.SupportsSelectMultiple; bd.SupportsUncheck = browser.SupportsUncheck; bd.SupportsXmlHttp = browser.SupportsXmlHttp; bd.Tables = browser.Tables; bd.Type = browser.Type; bd.UseOptimizedCacheKey = browser.UseOptimizedCacheKey; bd.VBScript = browser.VBScript; bd.Version = browser.Version; bd.W3CDomVersion = browser.W3CDomVersion.ToString(); bd.Win16 = browser.Win16; bd.Win32 = browser.Win32; return(bd); }
public Secure3dBuilder WithBrowserData(BrowserData value) { BrowserData = value; return(this); }
public async void Example() { #pragma warning disable 0168 using (Client client = GetClient()) { Card card = new Card(); card.CardNumber = "4567350000427977"; card.CardholderName = "Wile E. Coyote"; card.Cvv = "123"; card.ExpiryDate = "1220"; RedirectionData redirectionData = new RedirectionData(); redirectionData.ReturnUrl = "https://hostname.myownwebsite.url"; ThreeDSecure threeDSecure = new ThreeDSecure(); threeDSecure.AuthenticationFlow = "browser"; threeDSecure.ChallengeCanvasSize = "600x400"; threeDSecure.ChallengeIndicator = "challenge-requested"; threeDSecure.ExemptionRequest = "none"; threeDSecure.RedirectionData = redirectionData; threeDSecure.SkipAuthentication = false; CardPaymentMethodSpecificInput cardPaymentMethodSpecificInput = new CardPaymentMethodSpecificInput(); cardPaymentMethodSpecificInput.Card = card; cardPaymentMethodSpecificInput.IsRecurring = false; cardPaymentMethodSpecificInput.MerchantInitiatedReasonIndicator = "delayedCharges"; cardPaymentMethodSpecificInput.PaymentProductId = 1; cardPaymentMethodSpecificInput.ThreeDSecure = threeDSecure; cardPaymentMethodSpecificInput.TransactionChannel = "ECOMMERCE"; AmountOfMoney amountOfMoney = new AmountOfMoney(); amountOfMoney.Amount = 2980L; amountOfMoney.CurrencyCode = "EUR"; Address billingAddress = new Address(); billingAddress.AdditionalInfo = "b"; billingAddress.City = "Monument Valley"; billingAddress.CountryCode = "US"; billingAddress.HouseNumber = "13"; billingAddress.State = "Utah"; billingAddress.Street = "Desertroad"; billingAddress.Zip = "84536"; CompanyInformation companyInformation = new CompanyInformation(); companyInformation.Name = "Acme Labs"; companyInformation.VatNumber = "1234AB5678CD"; ContactDetails contactDetails = new ContactDetails(); contactDetails.EmailAddress = "*****@*****.**"; contactDetails.FaxNumber = "+1234567891"; contactDetails.PhoneNumber = "+1234567890"; BrowserData browserData = new BrowserData(); browserData.ColorDepth = 24; browserData.JavaEnabled = false; browserData.ScreenHeight = "1200"; browserData.ScreenWidth = "1920"; CustomerDevice device = new CustomerDevice(); device.AcceptHeader = "texthtml,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; device.BrowserData = browserData; device.IpAddress = "123.123.123.123"; device.Locale = "en-US"; device.TimezoneOffsetUtcMinutes = "420"; device.UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15"; PersonalName name = new PersonalName(); name.FirstName = "Wile"; name.Surname = "Coyote"; name.SurnamePrefix = "E."; name.Title = "Mr."; PersonalInformation personalInformation = new PersonalInformation(); personalInformation.DateOfBirth = "19490917"; personalInformation.Gender = "male"; personalInformation.Name = name; Customer customer = new Customer(); customer.AccountType = "none"; customer.BillingAddress = billingAddress; customer.CompanyInformation = companyInformation; customer.ContactDetails = contactDetails; customer.Device = device; customer.Locale = "en_US"; customer.MerchantCustomerId = "1234"; customer.PersonalInformation = personalInformation; OrderInvoiceData invoiceData = new OrderInvoiceData(); invoiceData.InvoiceDate = "20140306191500"; invoiceData.InvoiceNumber = "000000123"; OrderReferences references = new OrderReferences(); references.Descriptor = "Fast and Furry-ous"; references.InvoiceData = invoiceData; references.MerchantOrderId = 123456L; references.MerchantReference = "AcmeOrder0001"; PersonalName shippingName = new PersonalName(); shippingName.FirstName = "Road"; shippingName.Surname = "Runner"; shippingName.Title = "Miss"; AddressPersonal address = new AddressPersonal(); address.AdditionalInfo = "Suite II"; address.City = "Monument Valley"; address.CountryCode = "US"; address.HouseNumber = "1"; address.Name = shippingName; address.State = "Utah"; address.Street = "Desertroad"; address.Zip = "84536"; Shipping shipping = new Shipping(); shipping.Address = address; IList <LineItem> items = new List <LineItem>(); AmountOfMoney item1AmountOfMoney = new AmountOfMoney(); item1AmountOfMoney.Amount = 2500L; item1AmountOfMoney.CurrencyCode = "EUR"; LineItemInvoiceData item1InvoiceData = new LineItemInvoiceData(); item1InvoiceData.Description = "ACME Super Outfit"; item1InvoiceData.NrOfItems = "1"; item1InvoiceData.PricePerItem = 2500L; LineItem item1 = new LineItem(); item1.AmountOfMoney = item1AmountOfMoney; item1.InvoiceData = item1InvoiceData; items.Add(item1); AmountOfMoney item2AmountOfMoney = new AmountOfMoney(); item2AmountOfMoney.Amount = 480L; item2AmountOfMoney.CurrencyCode = "EUR"; LineItemInvoiceData item2InvoiceData = new LineItemInvoiceData(); item2InvoiceData.Description = "Aspirin"; item2InvoiceData.NrOfItems = "12"; item2InvoiceData.PricePerItem = 40L; LineItem item2 = new LineItem(); item2.AmountOfMoney = item2AmountOfMoney; item2.InvoiceData = item2InvoiceData; items.Add(item2); ShoppingCart shoppingCart = new ShoppingCart(); shoppingCart.Items = items; Order order = new Order(); order.AmountOfMoney = amountOfMoney; order.Customer = customer; order.References = references; order.Shipping = shipping; order.ShoppingCart = shoppingCart; CreatePaymentRequest body = new CreatePaymentRequest(); body.CardPaymentMethodSpecificInput = cardPaymentMethodSpecificInput; body.Order = order; try { CreatePaymentResponse response = await client.Merchant("merchantId").Payments().Create(body); } catch (DeclinedPaymentException e) { HandleDeclinedPayment(e.CreatePaymentResult); } catch (ApiException e) { HandleApiErrors(e.Errors); } } #pragma warning restore 0168 }
public IActionResult IniciarAuth([FromQuery] Tarjeta detalles, [FromQuery] NavegadorCliente navClient, [FromQuery] RespuestaVersion3DS2 responseACSVersion) { // Configuramos los datos de nuestro comercio. Los datos son proporcionados por el equipo de Addon Payments, // en caso de duda debe llamar al 914 353 028 e indicar su número de comercio o Merchant ID ServicesContainer.ConfigureService(new GatewayConfig { MerchantId = "addonnettest", AccountId = "3ds2", SharedSecret = "secret", MethodNotificationUrl = "https://dominio.com/notificacion3ds", ChallengeNotificationUrl = "https://dominio.com/notificacionAcs", MerchantContactUrl = "https://www.dominio.com/about", Secure3dVersion = Secure3dVersion.Two }); // Tarjetas de prueba // Frictionless: 4263970000005262 // Challenge: 4012001038488884 var card = new CreditCardData { Number = detalles.cardNumber, ExpMonth = detalles.month, ExpYear = detalles.year, Cvn = detalles.cvn, CardHolderName = detalles.cardholderName }; // Indicamos la dirección de facturación Address billingAddress = new Address { StreetAddress1 = "Apartment 852", StreetAddress2 = "Complex 741", StreetAddress3 = "Unit 4", City = "Chicago", PostalCode = "50001", State = "IL", CountryCode = "840" }; // Indicamos la dirección de envío Address shippingAddress = new Address { StreetAddress1 = "Flat 456", StreetAddress2 = "House 789", StreetAddress3 = "Basement Flat", City = "Halifax", PostalCode = "W5 9HR", CountryCode = "826" }; // Indicamos los datos del navegaddor del cliente BrowserData browserData = new BrowserData { AcceptHeader = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,/;q=0.8", ColorDepth = navClient.colorDepth, IpAddress = "123.123.123.123", JavaEnabled = navClient.javaEnabled, Language = navClient.browserLanguage, ScreenHeight = navClient.screenHeight, ScreenWidth = navClient.screenWidth, ChallengeWindowSize = ChallengeWindowSize.FULL_SCREEN, Timezone = navClient.browserTimezoneZoneOffset, UserAgent = navClient.userAgent }; ThreeDSecure threeDSecureData = new ThreeDSecure { ServerTransactionId = responseACSVersion.serverTransactionId }; try { threeDSecureData = Secure3dService.InitiateAuthentication(card, threeDSecureData) .WithAmount(10.01m) .WithCurrency("EUR") .WithOrderCreateDate(DateTime.Parse("2019-09-09T11:19:12")) .WithCustomerEmail("*****@*****.**") .WithAddress(billingAddress, AddressType.Billing) .WithAddress(shippingAddress, AddressType.Shipping) .WithBrowserData(browserData) .WithMethodUrlCompletion(MethodUrlCompletion.YES) .WithMobileNumber("44", "7123456789") .Execute(); // Informamos al cliente RespuestaVersion3DS2 respuesta = new RespuestaVersion3DS2 { acsEndVersion = threeDSecureData.AcsEndVersion, acsStartVersion = threeDSecureData.AcsStartVersion, acsTransactionId = threeDSecureData.AcsTransactionId, algorithm = threeDSecureData.Algorithm, authenticationSource = threeDSecureData.AuthenticationSource, authenticationType = threeDSecureData.AuthenticationType, authenticationValue = threeDSecureData.AuthenticationValue, cardHolderResponseInfo = threeDSecureData.CardHolderResponseInfo, cavv = threeDSecureData.Cavv, challengeMandated = threeDSecureData.ChallengeMandated, criticalityIndicator = threeDSecureData.CriticalityIndicator, directoryServerEndVersion = threeDSecureData.DirectoryServerEndVersion, directoryServerStartVersion = threeDSecureData.DirectoryServerStartVersion, directoryServerTransactionId = threeDSecureData.DirectoryServerTransactionId, eci = threeDSecureData.Eci, enrolled = threeDSecureData.Enrolled, issuerAcsUrl = threeDSecureData.IssuerAcsUrl, messageCategory = threeDSecureData.MessageCategory, messageExtensionId = threeDSecureData.MessageExtensionId, messageExtensionName = threeDSecureData.MessageExtensionName, messageVersion = threeDSecureData.MessageVersion, payerAuthenticationRequest = threeDSecureData.PayerAuthenticationRequest, paymentDataSource = threeDSecureData.PaymentDataSource, paymentDataType = threeDSecureData.PaymentDataType, sdkInterface = threeDSecureData.SdkInterface, sdkUiType = threeDSecureData.SdkUiType, serverTransactionId = threeDSecureData.ServerTransactionId, status = threeDSecureData.Status, statusReason = threeDSecureData.StatusReason, xid = threeDSecureData.Xid }; return(Ok(respuesta)); } catch (ApiException exce) { return(BadRequest(exce)); // TODO: agregue su control de excepciones aquí } }
protected virtual void OnCellValueChanged(object sender, CellValueChangedEventArgs args) { GridItem item = (GridItem)this.gridControl.SelectedItem; if (item == null) { item = (GridItem)this.gridControl.CurrentItem; } if (item != null) { int? oid = item.GetOid(); GridColumn col = args.Column; GrilleColumn column = this.Grille.GetColumn(col.FieldName); string oldValue = item.Datas[column.position] != null ? item.Datas[column.position].ToString() : ""; string newValue = args.Value != null?args.Value.ToString() : ""; GrilleEditedElement element = new GrilleEditedElement(); element.column = column; element.oid = oid; //if (newValue.Equals(oldValue)) return; if (column.type.Equals(ParameterType.MEASURE.ToString())) { decimal val = 0; if (string.IsNullOrWhiteSpace(newValue)) { val = 0; } else if (decimal.TryParse(newValue, out val)) { element.measure = val; } else if (decimal.TryParse(newValue.Replace(".", ","), out val)) { element.measure = val; } else { MessageDisplayer.DisplayError("Wrong measure", "'" + newValue + "'" + " is not a decimal!"); args.Handled = true; //args.Value = args.OldValue; return; } } else if (column.type.Equals(ParameterType.SCOPE.ToString())) { if (string.IsNullOrWhiteSpace(newValue)) { element.value = null; } else { BrowserData data = column.getValue(newValue); if (!AllowUnknowValueForScope && data == null) { MessageDisplayer.DisplayError("Wrong value", "Unknow value : '" + newValue + "'"); args.Handled = true; return; } else { element.value = data; } } } if (column.type.Equals(ParameterType.PERIOD.ToString())) { DateTime date; if (string.IsNullOrWhiteSpace(newValue)) { element.date = null; } else if (DateTime.TryParse(newValue, out date)) { element.date = date.ToShortDateString(); } else { MessageDisplayer.DisplayError("Wrong date", "'" + newValue + "'" + " is not a date!"); args.Handled = true; return; } } if (this.EditEventHandler != null) { GrilleEditedResult result = EditEventHandler(element); if (result.isError) { MessageDisplayer.DisplayError("Wrong value", result.error); args.Handled = true; return; } else { if (result.datas == null) { args.Handled = true; } else { item.Datas = result.datas; } Refresh(); //this.grid.SelectedItem = item; } } } }
public DashboradBlockItem(BrowserData data, String fuctionalityCode) : this() { CustomizeView(data, fuctionalityCode); }
public void TestInitialize() { ServicesContainer.ConfigureService(new GpApiConfig { AppId = "v2yRaFOLwFaQc0fSZTCyAdQCBNByGpVK", AppKey = "oKZpWitk6tORoCVT", Channel = Channel.CardNotPresent, Environment = Environment.TEST, Country = "GB", AccessTokenInfo = new AccessTokenInfo { TransactionProcessingAccountName = "LinkManagement" }, RequestLogger = new RequestConsoleLogger(), EnableLogging = true }); payLink = new PayLinkData { Type = PayLinkType.PAYMENT, UsageMode = PaymentMethodUsageMode.Single, AllowedPaymentMethods = new[] { PaymentMethodName.Card }, UsageLimit = 1, Name = "Mobile Bill Payment", IsShippable = true, ShippingAmount = 1.23m, ExpirationDate = DateTime.UtcNow.AddDays(10), //date('Y-m-d H:i:s') + 10; Images = new string[] { "test", "test2", "test3" }, ReturnUrl = "https://www.example.com/returnUrl", StatusUpdateUrl = "https://www.example.com/statusUrl", CancelUrl = "https://www.example.com/returnUrl" }; card = new CreditCardData { Number = "4263970000005262", ExpMonth = expMonth, ExpYear = expYear, Cvn = "123", CardPresent = true }; shippingAddress = new Address { StreetAddress1 = "Apartment 852", StreetAddress2 = "Complex 741", StreetAddress3 = "no", City = "Chicago", PostalCode = "5001", State = "IL", CountryCode = "840" }; browserData = new BrowserData { AcceptHeader = "text/html,application/xhtml+xml,application/xml;q=9,image/webp,img/apng,*/*;q=0.8", ColorDepth = ColorDepth.TWENTY_FOUR_BITS, IpAddress = "123.123.123.123", JavaEnabled = true, Language = "en", ScreenHeight = 1080, ScreenWidth = 1920, ChallengeWindowSize = ChallengeWindowSize.WINDOWED_600X400, Timezone = "0", UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64, x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" }; }
/// <summary> /// This is an example to show how you might transform the data results. Typically this stuff is pushed further back into a business layer or in a repository of some sort. /// </summary> /// <param name="instance"></param> /// <returns></returns> public DataTableWrapper <BrowserDataTableWrap> GetCollectionByDataTable(IList <KeyValue <string, object> > instance) { if (instance == null) { throw new WebFaultException <string>("there are no vars being passed in for the action", HttpStatusCode.BadRequest); } var hasGlobalSearch = instance.FirstOrDefault(i => i.Key.Contains(DataItemCollectionNames.SSearch.Replace("_", string.Empty))); var hasEcho = instance.FirstOrDefault(i => i.Key.Contains(DataItemPropertyNamesFrontEnd.Echo)); var hasColSorted = instance.FirstOrDefault(i => i.Key.Contains(DataItemCollectionNames.SSortCol)); var hasDisplayStart = instance.FirstOrDefault(i => i.Key.Contains(DataItemPropertyNamesFrontEnd.DisplayStart)); var hasDisplayLength = instance.FirstOrDefault(i => i.Key.Contains(DataItemPropertyNamesFrontEnd.DisplayLength)); // This may seem like a lot, but typically you set up 'defaults' in an IOC like Ninject, StructureMap, or Unity var trans = new DataTableRequestCollection { Echo = hasEcho != null?hasEcho.Value.ToString() : string.Empty, GlobalSearch = hasGlobalSearch != null?hasGlobalSearch.Value.ToString() : string.Empty, DataProperties = new Dictionary <string, string>(), ColumnSortable = new Dictionary <string, bool>(), ColumnRegExpression = new Dictionary <string, bool>(), ColumnSearch = new Dictionary <string, string>(), ColumnSearchable = new Dictionary <string, bool>(), ColumnSortDirection = new Dictionary <string, string>(), ColumnSorted = hasColSorted != null?int.Parse(hasColSorted.Value.ToString()) : 0, DisplayStart = hasDisplayStart != null?int.Parse(hasDisplayStart.Value.ToString()) : 0, DisplayLength = hasDisplayLength != null?int.Parse(hasDisplayLength.Value.ToString()) : 0, }; foreach (var i in instance.Where(i => i.Key.Contains(DataItemCollectionNames.MdataProp))) { trans.DataProperties.Add(new KeyValuePair <string, string>(i.Key, i.Value.ToString())); } var browserData = new BrowserData(); var collectionByDataTable = !string.IsNullOrEmpty(trans.GlobalSearch) ? browserData.GetGlobalFiltered(trans.GlobalSearch) : browserData.GetFiltered(trans.SortedColumnSearchName, trans.SortedColumnSearchValue, trans.SortedColumnDirectionValue.ToLower() == "asc"); // it's a cheat that says count all the data var totalRecords = GetAll().Count; // this is another cheat that says count all the filtered results var totalDisplay = collectionByDataTable.Count; // now we start to transform this class to a the one that implements the IDataTableSerializer var transformed = new List <BrowserDataTableWrap>(); // simple loop foreach (var browser in browserData.Reduce(collectionByDataTable, trans.DisplayStart, trans.DisplayLength)) { var browserDataTableWrap = new BrowserDataTableWrap { Engine = browser.Engine, Grade = browser.Grade, Name = browser.Name, Platform = browser.Platform, Version = browser.Version, }; transformed.Add(browserDataTableWrap); } // finally, input the results into the datatable var dataTableWrapper = new DataTableWrapper <BrowserDataTableWrap>(trans, transformed) { TotalRecords = totalRecords, // typically this total would be return in database TotalDisplayRecords = totalDisplay // this is the max amount of filtererd matches }; return(dataTableWrapper); }