public ActionResult SaveData(IList <TransactionAttributes> transactionAttributes) { try { int index = 0; String result = String.Empty; int daId = transactionAttributes.First().daId; TempData["daId"] = daId; TransactionAttributes transactionAttribute = new TransactionAttributes(); index = transactionAttribute.SaveData(transactionAttributes, daId); if (index > 0) { result = "1"; } else { result = "0"; } return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(ex); return(View("Error")); } }
internal static MPTransactionAttributes ConvertToMpTransactionAttributes(TransactionAttributes transactionAttributes) { var bindingTransactions = new MPTransactionAttributes(); bindingTransactions.TransactionId = transactionAttributes.TransactionId; bindingTransactions.Affiliation = transactionAttributes.Affiliation; bindingTransactions.CouponCode = transactionAttributes.CouponCode; bindingTransactions.Shipping = transactionAttributes.Shipping.HasValue ? transactionAttributes.Shipping.Value : 0; bindingTransactions.Tax = transactionAttributes.Tax.HasValue ? transactionAttributes.Tax.Value : 0; bindingTransactions.Revenue = transactionAttributes.Revenue.HasValue ? transactionAttributes.Revenue.Value : 0; return(bindingTransactions); }
private static IntPtr[] Begin(string transactionName, TransactionAttributes attributes) { int hTransaction; IntPtr hChangeOfOwnerEvent; uint ret = NativeMethods.MsiBeginTransaction(transactionName, (int)attributes, out hTransaction, out hChangeOfOwnerEvent); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } return(new IntPtr[] { (IntPtr)hTransaction, hChangeOfOwnerEvent }); }
/// <summary> /// Makes the current process the owner of the multi-package installation transaction. /// </summary> /// <param name="attributes">Select optional behavior when joining the transaction.</param> /// <exception cref="InvalidHandleException">The transaction handle is not valid.</exception> /// <exception cref="InstallerException">The transaction could not be joined.</exception> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msijointransaction.asp">MsiJoinTransaction</a> /// </p></remarks> public void Join(TransactionAttributes attributes) { IntPtr hChangeOfOwnerEvent; uint ret = NativeMethods.MsiJoinTransaction((int)this.Handle, (int)attributes, out hChangeOfOwnerEvent); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } this.ownerChangeEvent = hChangeOfOwnerEvent; if (this.ownerChangeEvent != IntPtr.Zero && this.ownerChangeListeners.Count >= 1) { new Thread(this.WaitForOwnerChange).Start(); } }
internal AndroidJavaObject ConvertToMpTransactionAttributes(TransactionAttributes attributes) { AndroidJavaObject javaAttributes = new AndroidJavaObject("com.mparticle.commerce.TransactionAttributes", attributes.TransactionId); javaAttributes.Call <AndroidJavaObject>("setCouponCode", attributes.CouponCode); if (attributes.Tax.HasValue) { javaAttributes.Call <AndroidJavaObject>("setTax", doubleClass.CallStatic <AndroidJavaObject>("valueOf", attributes.Tax)); } if (attributes.Shipping.HasValue) { javaAttributes.Call <AndroidJavaObject>("setShipping", doubleClass.CallStatic <AndroidJavaObject>("valueOf", attributes.Shipping)); } if (attributes.Revenue.HasValue) { javaAttributes.Call <AndroidJavaObject>("setRevenue", doubleClass.CallStatic <AndroidJavaObject>("valueOf", attributes.Revenue)); } return(javaAttributes.Call <AndroidJavaObject>("setAffiliation", attributes.Affiliation)); }
public void Refund(TransactionAttributes transactionAttributes, bool clear) { _cart.Refund(Utils.ConvertToMpTransactionAttributes(transactionAttributes), clear); }
public void Purchase(TransactionAttributes transactionAttributes, bool clear = false) { _cart.Purchase(Utils.ConvertToMpTransactionAttributes(transactionAttributes), clear); }
public static void MakeTestCalls() { var mparticle = MParticle.Instance; Console.WriteLine(mparticle.Environment); mparticle.SetOptOut(false); mparticle.LogEvent("AppEvent of type location", EventType.Location, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type navigation", EventType.Navigation, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type other", EventType.Other, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type search", EventType.Search, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type social", EventType.Social, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type transaction", EventType.Transaction, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type usercontent", EventType.UserContent, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.LogEvent("AppEvent of type userpreference", EventType.UserPreference, new Dictionary <string, string>() { { "Cool", "Beans" } }); mparticle.Upload(); var product = new Product("Chicken", "SomeSku", 123.43, 22.14) { Brand = "mybrand", Category = "mycategory", CouponCode = "mycoupon", Variant = "myvariant", Position = 12, customAttributes = new Dictionary <string, string>() { { "Tk1", "Tv1" }, { "Tk2", "Tv2" } } }; var product2 = new Product("Noodles", "CoolSku", 12.4, 52.4) { Brand = "mybrand2", Category = "mycategory2", CouponCode = "mycoupon2", Variant = "myvariant2", Position = 3, customAttributes = new Dictionary <string, string>() { { "NTk1", "NTv1" }, { "NTk2", "NTv2" } } }; var products = new Product[] { product, product2 }; var transactionAttributes = new TransactionAttributes("transactionId123") { Affiliation = "Some Affiliation", CouponCode = "Winner", Revenue = 400.21, Tax = 434.98, Shipping = 5.13 }; mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.AddToCart, products) { Currency = "AUD" }); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.Purchase, products, transactionAttributes) { CustomAttributes = new Dictionary <string, string> { { "TestCommerceAttr", "TestCommerceVal" } } }); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.Checkout, products, transactionAttributes) { CheckoutStep = 2 }); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.Refund, products, transactionAttributes) { ScreenName = "Goodbye" }); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.RemoveFromCart, products) { NonInteractive = true }); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.ViewDetail, products) { CheckoutOptions = "-very -good" }); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.AddToWishlist, products)); mparticle.LogCommerceEvent(new CommerceEvent(ProductAction.RemoveFromWishlist, products)); mparticle.LogCommerceEvent(new CommerceEvent(new Impression[] { new Impression("testIMpression", products), new Impression("testIMpression2", products) })); mparticle.LogCommerceEvent(new CommerceEvent(PromotionAction.View, new Promotion[] { new Promotion("someid", "somename", "somecreative", 123) })); mparticle.LogScreen("Home Screen", new Dictionary <string, string>() { { "EventAttributeKey", "EventAttributeValue" } }); mparticle.LogScreen("Another screen"); mparticle.LeaveBreadcrumb("crumble"); #if __ANDROID__ // This is highly discouraged and we make no guarantees about this but just to show it is possible. //var unsafeNativeSDK = mparticle.GetBindingInstance(); //unsafeNativeSDK.GetType().GetMethod("setOptOut").Invoke(unsafeNativeSDK, new object[] { true }); #endif }
/// <summary> /// [MSI 4.5] Begins transaction processing of a multi-package installation. /// </summary> /// <param name="name">Name of the multi-package installation.</param> /// <param name="attributes">Select optional behavior when beginning the transaction.</param> /// <exception cref="InstallerException">The transaction could not be initialized.</exception> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msibegintransaction.asp">MsiBeginTransaction</a> /// </p></remarks> public Transaction(string name, TransactionAttributes attributes) : this(name, Transaction.Begin(name, attributes), true) { }
private static IntPtr[] Begin(string transactionName, TransactionAttributes attributes) { int hTransaction; IntPtr hChangeOfOwnerEvent; uint ret = NativeMethods.MsiBeginTransaction(transactionName, (int) attributes, out hTransaction, out hChangeOfOwnerEvent); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } return new IntPtr[] { (IntPtr) hTransaction, hChangeOfOwnerEvent }; }
/// <summary> /// Makes the current process the owner of the multi-package installation transaction. /// </summary> /// <param name="attributes">Select optional behavior when joining the transaction.</param> /// <exception cref="InvalidHandleException">The transaction handle is not valid.</exception> /// <exception cref="InstallerException">The transaction could not be joined.</exception> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msijointransaction.asp">MsiJoinTransaction</a> /// </p></remarks> public void Join(TransactionAttributes attributes) { IntPtr hChangeOfOwnerEvent; uint ret = NativeMethods.MsiJoinTransaction((int) this.Handle, (int) attributes, out hChangeOfOwnerEvent); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } this.ownerChangeEvent = hChangeOfOwnerEvent; if (this.ownerChangeEvent != IntPtr.Zero && this.ownerChangeListeners.Count >= 1) { new Thread(this.WaitForOwnerChange).Start(); } }
public ActionResult Index(int?id) { try { TransactionAttributes transactionAttributes = new TransactionAttributes(); if (id == null) { id = (int)TempData["daId"]; } IList <TransactionAttributes> transactionAttributesList = transactionAttributes.GetTransactionAttributes((int)id); CommonFunctions comfuns = new CommonFunctions(); var da = comfuns.FindDA((int)id); transactionAttributes.daId = (int)id; transactionAttributes.ModuleId = da.ModuleId; transactionAttributes.daName = da.DAName; TempData["daId"] = transactionAttributes.daId; int clientId; int projectId; int applicationId; string projectName; string appName; string modName; comfuns.GetModuleName(transactionAttributes.ModuleId, out applicationId, out modName); transactionAttributes.ApplicationID = applicationId; transactionAttributes.ModuleName = modName; comfuns.GetApplicationName(applicationId, out projectId, out appName); transactionAttributes.ProjectID = projectId; transactionAttributes.ApplicationName = appName; comfuns.GetProjectName(projectId, out clientId, out projectName); transactionAttributes.ClientID = clientId; transactionAttributes.ProjectName = projectName; transactionAttributes.ClientName = comfuns.GetClientName(clientId); ViewData["ClientId"] = clientId; ViewData["ClientName"] = transactionAttributes.ClientName; ViewData["ProjectName"] = transactionAttributes.ProjectName; ViewData["ProjectID"] = transactionAttributes.ProjectID; ViewData["ApplicationName"] = transactionAttributes.ApplicationName; ViewData["ApplicationID"] = transactionAttributes.ApplicationID; ViewData["ModuleName"] = transactionAttributes.ModuleName; ViewData["ModuleId"] = transactionAttributes.ModuleId; ViewData["daName"] = transactionAttributes.daName; ViewData["daId"] = transactionAttributes.daId; AttributeListViewModel attributeListViewModel = new AttributeListViewModel(); ViewData["AttributeList"] = attributeListViewModel.GetAttributeList(transactionAttributes.daId); return(View(transactionAttributesList)); } catch (Exception ex) { errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(ex); return(View("Error")); } }
/// <summary> /// [MSI 4.5] Begins transaction processing of a multi-package installation. /// </summary> /// <param name="name">Name of the multi-package installation.</param> /// <param name="attributes">Select optional behavior when beginning the transaction.</param> /// <exception cref="InstallerException">The transaction could not be initialized.</exception> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msibegintransaction.asp">MsiBeginTransaction</a> /// </p></remarks> public Transaction(string name, TransactionAttributes attributes) : this(name, Transaction.Begin(name, attributes), true) { }
internal static Android.CommerceBinding.TransactionAttributes ConvertToMpTransactionAttributes(TransactionAttributes attributes) { var bindingTransaction = new Android.CommerceBinding.TransactionAttributes(attributes.TransactionId); bindingTransaction.SetCouponCode(attributes.CouponCode); bindingTransaction.SetAffiliation(attributes.Affiliation); if (attributes.Tax.HasValue) { bindingTransaction.SetTax(new Java.Lang.Double(attributes.Tax.Value)); } if (attributes.Shipping.HasValue) { bindingTransaction.SetShipping(new Java.Lang.Double(attributes.Shipping.Value)); } if (attributes.Revenue.HasValue) { bindingTransaction.SetRevenue(new Java.Lang.Double(attributes.Revenue.Value)); } return(bindingTransaction); }