コード例 #1
0
ファイル: Shop.cs プロジェクト: Holy87/circuminfo
        public static bool getProductStatus()
        {
            LicenseInformation license = CurrentApp.LicenseInformation;
            ProductLicense     product = license.ProductLicenses[prodotto];

            return(product.IsActive);
        }
コード例 #2
0
 /// <summary>
 /// Method will be used to remove product key from databse.
 /// </summary>
 public static void RemoveKey()
 {
     try
     {
         ProductLicense_Blogic BLogic_Product   = new ProductLicense_Blogic();
         ProductLicense        Property_Product = new ProductLicense();
         DataSet ds = new DataSet();
         ds = GetProductInfo();
         string OldCode = string.Empty;
         if (ds != null & ds.Tables.Count > 0)
         {
             if (ds.Tables[0].Rows.Count > 0)
             {
                 OldCode = ds.Tables[0].Rows[0]["Code"].ToString();
             }
         }
         Property_Product.Code       = string.Empty;
         Property_Product.ProductKey = string.Empty;
         Property_Product.Oldcode    = OldCode;
         BLogic_Product.BAL_Product_Insert_Update(Property_Product);
     }
     catch (Exception ex)
     {
         WebMsg.Show(ex.Message);
     }
 }
コード例 #3
0
 public void New2()
 {
     PropertyBag["accounttype"] = typeof(Account);
     PropertyBag.Add("licenses", ProductLicense.FindAll());
     PropertyBag.Add("permissions", AccountPermission.FindAll());
     PropertyBag.Add("users", User.FindAll());
 }
コード例 #4
0
        public void LoadSaveLicense()
        {
            string publicXmlKey = KeyHelpers.GetPrivateKey();
            ProductLicenseManager licenseManager = new ProductLicenseManager(null, publicXmlKey,
                                                                             new MockLicenseStore(),
                                                                             new MachineIdentifierProviderMock(),
                                                                             new UserInformationProviderMock()
            {
                Username = "******",
                Company  = "Company",
                Email    = "*****@*****.**"
            });
            ProductLicense license = licenseManager.LoadLicense("MyProductName");

            string productKey       = GenerateProductKey(123, 456, 0, "C", "toto", "Company", "*****@*****.**");
            var    licenseActivated = GetProductActivated(productKey);

            Assert.AreEqual(LicenseStatus.NotFound, license.Status, license.StatusReason);

            license = licenseManager.ActivateProduct(licenseActivated);
            licenseManager.SaveLicense("MyProductName", license);
            license = licenseManager.LoadLicense("MyProductName");

            Assert.AreEqual(LicenseStatus.Licensed, license.Status, license.StatusReason);
            Assert.AreEqual(123, license.ProductID);
            Assert.AreEqual(456, license.ProductFeatures);
            Assert.AreEqual(0, license.TrialDays);
        }
コード例 #5
0
        /// <summary>
        /// Tries to fulfill a Gold IAP with the given amount.
        /// </summary>
        /// <param name="productLicense">The store product license.</param>
        private async Task TryFulfillGold(ProductLicense productLicense)
        {
            if (productLicense.IsConsumable && productLicense.IsActive)
            {
                var receipt = await CurrentAppProxy.RequestProductPurchaseAsync(productLicense.ProductId);

                // Fulfill on PhotoSharingApp servers
                var user = await _photoService.FulfillGold(receipt.ReceiptXml);

                // If previous step was successful, fulfill in Store
                await CurrentAppProxy.ReportConsumableFulfillmentAsync(productLicense.ProductId, receipt.TransactionId);

                // Now update local gold balance
                AppEnvironment.Instance.CurrentUser.GoldBalance = user.GoldBalance;

                _telemetryClient.TrackEvent(TelemetryEvents.PurchaseGoldSuccess);
            }
            else
            {
                _telemetryClient.TrackEvent(TelemetryEvents.PurchaseGoldFail,
                                            new Dictionary <string, string>
                {
                    { TelemetryProperties.ProductId, productLicense.ProductId }
                });
            }
        }
コード例 #6
0
        public override List <ProductLicense> GetProductLicenseList()
        {
            List <ProductLicense> list = new List <ProductLicense>();

            using (SqlConnection connection = this.GetSqlConnection())
            {
                string     cmdText = "select * from SuCommerce_vw_Licenses";
                SqlCommand command = new SqlCommand(cmdText, connection)
                {
                    CommandType = CommandType.Text
                };
                connection.Open();
                using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    ProductLicense license = null;
                    while (reader.Read())
                    {
                        license = new ProductLicense();
                        CommerceDataProvider.PopulateProductLicenseList(reader, license);
                        list.Add(license);
                    }
                    reader.Close();
                    connection.Close();
                }
            }
            return(list);
        }
コード例 #7
0
        /// <summary>
        /// Returns true if the requested feature is available
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public bool Available(String ID)
        {
            // return true;

            try
            {
                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                if (localSettings.Values.Keys.Contains(ID))
                {
                    bool Result = ((bool)localSettings.Values[ID]);
                    return(Result);
                }
                else
                {
#if DEBUG
                    ProductLicense license = CurrentAppSimulator.LicenseInformation.ProductLicenses[ID];
#else
                    ProductLicense license = CurrentApp.LicenseInformation.ProductLicenses[ID];
#endif
                    if (license.IsActive)
                    {
                        Unlock(ID);
                    }

                    return(license.IsActive);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Purchases: " + e.Message);
            }

            return(false);
        }
コード例 #8
0
        public async void restoreCompletedTransactions(string args)
        {
            try
            {
                // get all in-app products for current app
                ListingInformation productList = await CurrentApp.LoadListingInformationAsync();

                foreach (KeyValuePair <string, ProductListing> product in productList.ProductListings)
                {
                    ProductLicense productLicense = null;
                    if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(product.Key, out productLicense))
                    {
                        if (productLicense.IsActive)
                        {
                            this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, product.Key));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Unknown Error"));
            }
        }
コード例 #9
0
 public static void PopulateProductLicenseList(IDataReader dr, ProductLicense _productLicense)
 {
     _productLicense.LicenseID              = (int)dr["licenseid"];
     _productLicense.LicenseTypeID          = (int)dr["licensetypeid"];
     _productLicense.LicenseTypeDescription = dr["licensetypedescription"] as string;
     _productLicense.UserID                       = (int)dr["userid"];
     _productLicense.DatePurchased                = (DateTime)dr["datepurchased"];
     _productLicense.PurchasedVersion             = (decimal)dr["purchasedversion"];
     _productLicense.UserName                     = dr["username"] as string;
     _productLicense.DisplayName                  = dr["displayname"] as string;
     _productLicense.Email                        = dr["email"] as string;
     _productLicense.MembershipID                 = DataHelper.GetGuid(dr, "membershipid");
     _productLicense.ForumUserID                  = (int)dr["forumuserid"];
     _productLicense.BoardID                      = (int)dr["boardid"];
     _productLicense.License                      = dr["license"] as string;
     _productLicense.PackageTypeCode              = dr["packagetypecode"] as string;
     _productLicense.PackageTypeDescription       = dr["packagetypedescription"] as string;
     _productLicense.CartLinkID                   = (int)dr["cartlinkid"];
     _productLicense.PackageTypeID                = (int)dr["packagetypeid"];
     _productLicense.Version                      = (decimal)dr["version"];
     _productLicense.ProductID                    = (int)dr["productid"];
     _productLicense.PurchaseID                   = (int)dr["purchaseid"];
     _productLicense.PurchaseKey                  = dr["purchasekey"] as string;
     _productLicense.TransactionXID               = dr["transactionxid"] as string;
     _productLicense.Price                        = (decimal)dr["price"];
     _productLicense.MajorVersion                 = dr.GetMajorVersion((decimal)dr["version"]);
     _productLicense.CustomLicenseTypeDescription = dr.GetCustomLicenseTypeDescription(_productLicense.LicenseTypeDescription);
 }
コード例 #10
0
        protected void GenerateProductKey_Click(object sender, EventArgs e)
        {
            var productPackage = CommerceCommon.GetProductPackage(base.CurrentSueetieProduct.ProductID);
            var purchase2      = new ProductPurchase
            {
                UserID      = base.CurrentSueetieUserID,
                CartLinkID  = CommerceCommon.GetCartLinkList(base.CurrentSueetieProduct.ProductID).Find(p => p.LicenseTypeID == 1).CartLinkID,
                ProductID   = base.CurrentSueetieProduct.ProductID,
                PurchaseKey = CommerceCommon.GeneratePurchaseKey(),
                ActionID    = 2
            };

            var productPurchase = purchase2;
            var num             = Purchases.RecordPurchase(productPurchase);
            var spt             = (SueetiePackageType)Enum.ToObject(typeof(SueetiePackageType), productPackage.PackageTypeID);

            var productLicense = new ProductLicense
            {
                License       = LicensingCommon.CreateLicenseKey(SueetieLicenseType.Free, spt),
                PackageTypeID = productPackage.PackageTypeID,
                LicenseTypeID = 1,
                Version       = productPackage.Version,
                UserID        = base.CurrentSueetieUserID,
                CartLinkID    = productPurchase.CartLinkID,
                PurchaseID    = num
            };

            Licenses.CreateProductLicense(productLicense);

            this.ltLicenseGeneration.Text = SueetieLocalizer.GetMarketplaceString("license_created_message");
            this.ltNewLicense.Text        = productLicense.License;
            this.SetActivePanel(this.pnlLicenseGeneration);
        }
コード例 #11
0
ファイル: IActiveLock.cs プロジェクト: soda3x/ACTIVELOCK
 /// <summary>
 /// <para>LockCode - Interface Method. Computes a lock code corresponding to the specified Lock Types, License Class, etc.</para>
 /// <para>Optionally, if a product license is specified, then a lock string specific to that license is returned.</para>
 /// </summary>
 /// <param name="Lic">Optional - ByRef Lic As ProductLicense - Product License for which to compute the lock code.</param>
 /// <returns>String - Lock code</returns>
 /// <remarks></remarks>
 public string LockCode(
     [
         System.Runtime.InteropServices.OptionalAttribute,
         System.Runtime.InteropServices.DefaultParameterValueAttribute(null)
     ] ref ProductLicense Lic)
 {
     return(string.Empty);
 }
コード例 #12
0
ファイル: Globals3.cs プロジェクト: soda3x/ACTIVELOCK
    //===============================================================================
    // Name: Function CreateProductLicense
    // Input:
    //   ByVal name As String - Product/Software Name
    //   ByVal Ver As String - Product version
    //   ByVal Code As String - Product/Software Code
    //   ByVal Flags As ActiveLock3.LicFlags - License Flag
    //   ByVal LicType As ActiveLock3.ALLicType - License type
    //   ByVal Licensee As String - Registered party for which the license has been issued
    //   ByVal RegisteredLevel As String - Registered level
    //   ByVal Expiration As String - Expiration date
    //   ByVal LicKey As String - License key
    //   ByVal RegisteredDate As String - Date on which the product is registered
    //   ByVal Hash1 As String - Hash-1 code
    //   ByVal MaxUsers As Integer - Maximum number of users allowed to use this license
    // Output:
    //   ProductLicense - License object
    // Purpose: Instantiates a new ProductLicense object from the specified parameters.
    // <p>If <code>LicType</code> is <i>Permanent</i>, then <code>Expiration</code> date parameter will be ignored.
    // Remarks: None
    //===============================================================================
    public ProductLicense CreateProductLicense(string Name, string Ver, string Code, ProductLicense.LicFlags Flags, ProductLicense.ALLicType LicType, string Licensee, string RegisteredLevel, string Expiration, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")] // ERROR: Optional parameters aren't supported in C#
                                               string LicKey, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")]                                                                                                                                                     // ERROR: Optional parameters aren't supported in C#
                                               string RegisteredDate,
                                               [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")]                                                                                                                                                                    // ERROR: Optional parameters aren't supported in C#
                                               string Hash1, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute(1)]                                                                                                                                                       // ERROR: Optional parameters aren't supported in C#
                                               short MaxUsers, [System.Runtime.InteropServices.OptionalAttribute, System.Runtime.InteropServices.DefaultParameterValueAttribute("")]                                                                                                                                                    // ERROR: Optional parameters aren't supported in C#
                                               string LicCode)
    {
        ProductLicense NewLic = new ProductLicense();

        {
            NewLic.ProductName = Name;
            NewLic.ProductKey  = Code;
            NewLic.ProductVer  = Ver;
            //If LicType = allicNetwork Then
            //    .LicenseClass = alfMulti
            //Else
            NewLic.LicenseClass = GetClassString(ref Flags);
            //End If
            NewLic.LicenseType     = LicType;
            NewLic.Licensee        = Licensee;
            NewLic.RegisteredLevel = RegisteredLevel;
            NewLic.MaxCount        = MaxUsers;
            // ignore expiration date if license type is "permanent"
            if (LicType != ProductLicense.ALLicType.allicPermanent)
            {
                NewLic.Expiration = Expiration;
            }
            //IsMissing() was changed to IsNothing()
            if ((LicKey != null))
            {
                NewLic.LicenseKey = LicKey;
            }
            //IsMissing() was changed to IsNothing()
            if ((RegisteredDate != null))
            {
                NewLic.RegisteredDate = RegisteredDate;
            }
            //IsMissing() was changed to IsNothing()
            if ((Hash1 != null))
            {
                NewLic.Hash1 = Hash1;
            }
            // New in v3.1
            // LicenseCode is appended to the end so that we can know
            // Alugen specified the hardware keys, and LockType
            // was not specified by the protected app
            //IsMissing() was changed to IsNothing()
            if ((LicCode != null))
            {
                if (!string.IsNullOrEmpty(LicCode))
                {
                    NewLic.LicenseCode = LicCode;
                }
            }
        }
        return(NewLic);
    }
コード例 #13
0
ファイル: UserManager.cs プロジェクト: vikramwadhawan/C3
        private static async Task <string> SaveUser(string userId, int organizationId, string tenantID, string productName, bool userExists)
        {
            string         status         = string.Empty;
            ProductUser    productUser    = null;
            ProductLicense productLicense = null;
            Product        product        = await ColligoO365RMOManager <Product> .FirstOrDefaultAsync(x => x.Name == productName);

            SystemUser user = null;

            if (!userExists)
            {
                user = new SystemUser();
                user.EmailAddress         = userId;
                user.FirstName            = GetNameFromMail(userId);
                user.LastName             = GetNameFromMail(userId, true);
                user.DisplayName          = user.FirstName + " " + user.LastName;
                user.OrganizationMasterId = organizationId;
                user.IsActive             = true;
                user.CreatedBy            = 1;
                user.CreatedOn            = System.DateTime.Now;
            }
            else
            {
                user = await ColligoO365RMOManager <SystemUser> .FirstOrDefaultAsync(x => x.EmailAddress == userId);
            }


            //Check and Update organization product licenes
            productLicense = await ColligoO365RMOManager <ProductLicense> .FirstOrDefaultAsync(x => x.OrganizationMasterId == organizationId && x.OrganizationMasterId == organizationId && x.ProductId == product.ProductId);

            //organization doesn't have license to access the product
            if (productLicense == null)
            {
                return("NoProductLicense");
            }
            if (productLicense.LicenseCount == productLicense.LicenseUsed)
            {
                status = "LicenseFinished";
                return(status);
            }
            else
            {
                productLicense.LicenseUsed = productLicense.LicenseUsed + 1;
                //Assgin product to new user
                productUser = new ProductUser();
                productUser.OrganizationMasterId = organizationId;
                productUser.ProductId            = product.ProductId;
                productUser.CreatedBy            = 1;
                productUser.CreatedOn            = System.DateTime.Now;
                productUser.IsActive             = true;
                var message = new UserDataManager().SaveUser(user, productLicense, productUser);
                if (message == "success")
                {
                    status = "UserCreated";
                }
            }
            return(status);
        }
コード例 #14
0
        /// <summary>
        /// Check the license information if we have a valid license either trial or real the application
        /// will continue to work. If there is no valid license and the warehouse was created less than 30 days before
        /// the application will work.
        /// </summary>
        public static void InitializeLicenseManager()
        {
            Nullable <LicenseStatus> previous;
            Nullable <short>         previousProductFeatures;

            if (productLicense != null)
            {
                previous = productLicense.Status;
                previousProductFeatures = productLicense.ProductFeatures;
            }
            else
            {
                previous = null;
                previousProductFeatures = null;
            }
            string publicXmlKey = RetrievePublicKey(@"RSAKeys\PublicKey.xml");

            productLicenseManager = new ProductLicenseManager(publicXmlKey);
            if (!Directory.Exists(licensePath))
            {
                CreatePath(licensePath);
            }
            productLicenseManager.SaveMachineKey(Path.Combine(licensePath, "EasyBuilder"));
            productLicense = productLicenseManager.LoadLicense(Path.Combine(licensePath, "EasyBuilder"));
            StringBuilder licenseText = new StringBuilder();

            if (CheckProduct(productLicense))
            {
                licenseText = SwitchLicenseStatus(licenseText);
            }
            else
            {
                LicenseProperties.IsActivated = false;
                licenseText.AppendLine("LIC_WrongProductLicense");
            }

            if (LicenseProperties.ActivatedFeatures.HasFlag(LicenseFeatures.Normal))
            {
                licenseText.Append("LIC_DevelopementFeature");
            }

            if (productLicense.ProductFeatures == 5)
            {
                licenseText.Append("LIC_APPSSTANDARDDEVELOPER");
            }

            LicenseProperties.LicenseTextResult = licenseText.ToString();
            if ((previous.HasValue && previous.Value != productLicense.Status) || (previousProductFeatures.HasValue && previousProductFeatures.Value != productLicense.ProductFeatures))
            {
                EventHandler handler = LicenseChanged;
                if (handler != null)
                {
                    handler(null, EventArgs.Empty);
                }
            }
        }
コード例 #15
0
        public void Edit2(int id)
        {
            if (!Flash.Contains("account"))
            {
                PropertyBag["account"] = ActiveRecordMediator <Account> .FindByPrimaryKey(id);
            }

            PropertyBag.Add("licenses", ProductLicense.FindAll());
            PropertyBag.Add("permissions", AccountPermission.FindAll());
            PropertyBag.Add("users", User.FindAll());
        }
コード例 #16
0
        public static async void Donate(string productId, bool isConsurable = false)
        {
            try
            {
                PopupMessage popupMessage = new PopupMessage();
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    var listing = await CurrentApp.LoadListingInformationAsync();

                    var myProduct = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == productId);
                    if (!CurrentApp.LicenseInformation.ProductLicenses[myProduct.Value.ProductId].IsActive)
                    {
                        await CurrentApp.RequestProductPurchaseAsync(productId, false);

                        var            productLicenses = CurrentApp.LicenseInformation.ProductLicenses;
                        ProductLicense tokenLicense    = productLicenses[productId];
                        if (tokenLicense.IsActive)
                        {
                            if (isConsurable)//если продукт расходуемый
                            {
                                CurrentApp.ReportProductFulfillment(productId);
                            }
                            var    settings = IsolatedStorageSettings.ApplicationSettings;
                            string product  = "product" + productId;
                            if (!settings.Contains(product))
                            {
                                settings.Add(product, true);
                                settings.Save();
                            }
                            //popupMessage.Show("Thank you for your purchase!");//en
                            //popupMessage.Show(AppResources.ThankYouForPurchase);//it
                            popupMessage.Show("Thank you for your purchase!");
                        }
                    }
                    else
                    {
                        //popupMessage.Show("You have already bought this product!");//en
                        //popupMessage.Show(AppResources.ProductExitsts);//it
                        popupMessage.Show("You have already bought this product!");
                    }
                }
                else
                {
                    //popupMessage.Show("Пожалуйста, проверьте подключение к сети Интернет!");//ru
                    //popupMessage.Show("Please check the connection to the Internet!");//en
                    //popupMessage.Show(AppResources.NoInternet);//it
                    popupMessage.Show("Please check the connection to the Internet!");
                }
            }
            catch (Exception ex)
            {
            }
        }
コード例 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (WebUtils.productLicense(Session) == null)
        {
            currentProductKey = new ProductLicense();
            currentProductKey.LoadProductLicense(dbConn);
        }
        else
        {
            currentProductKey = WebUtils.productLicense(Session);
        }

        if (!IsPostBack)
        {
            if (Request.UrlReferrer != null)
            {
                PreviousURL.Value = "Default.aspx";
//                PreviousURL.Value = Request.UrlReferrer.AbsoluteUri;
            }
            else
            {
                PreviousURL.Value = "Default.aspx";
            }
            txtProductKey.Text  = currentProductKey.ProductKey;//ESystemParameter.getParameter(ESystemParameter.PARAM_CODE_PRODUCTKEY);
            txtRequestCode.Text = currentProductKey.getRequestCode();
        }
        HROne.Common.WebUtility.WebControlsLocalization(this, this.Controls);

        if (!currentProductKey.IsValidAuthorizationCode())
        {
            if (currentProductKey.LastTrialDate < AppUtils.ServerDateTime().Date)
            {
                Prompt.Text    = "Trial Period Expiry.<br/>";
                Cancel.Visible = false;
            }
            else
            {
                Prompt.Text = string.Format(HROne.Translation.PageMessage.PRODUCT_TRIAL_WILL_EXPIRE, ((TimeSpan)currentProductKey.LastTrialDate.Subtract(AppUtils.ServerDateTime().Date)).Days) + "<br/>";
            }
        }

        string dbTitle = HROne.Lib.Entities.ESystemParameter.getParameter(dbConn, HROne.Lib.Entities.ESystemParameter.PARAM_CODE_DB_TITLE);

        if (!string.IsNullOrEmpty(dbTitle))
        {
            Page.Title += " (" + dbTitle + ")";
        }

        this.form1.Attributes.Add("AUTOCOMPLETE", "OFF");

        HROne.Common.WebUtility.AddBrowserCompatibilityMeta(Page);
    }
コード例 #18
0
        public void Update([ARDataBind("pl", AutoLoad = AutoLoadBehavior.Always)] ProductLicense pl)
        {
            var errorList = BoundInstanceErrors[pl];

            PropertyBag.Add("errorlist", errorList);

            if (errorList.Count == 0)
            {
                pl.Update();

                PropertyBag.Add("pl", pl);
            }
        }
コード例 #19
0
ファイル: IAPManager.cs プロジェクト: xmshaka/slash-framework
        public static bool HasFeature(string key)
        {
            if (licenseInformation == null)
            {
                throw new InvalidOperationException("IAP manager not initialized. Call Init() first.");
            }

            ProductLicense productLicense = licenseInformation.ProductLicenses[key];

            if (productLicense == null)
            {
                throw new ArgumentException("Unknown product: " + key, "key");
            }

            return(productLicense.IsActive);
        }
コード例 #20
0
        /// <summary>
        /// Tries to fulfill a Gold IAP with the given amount.
        /// </summary>
        /// <param name="productLicense">The store product license.</param>
        private async Task TryFulfillGold(ProductLicense productLicense)
        {
            if (productLicense.IsConsumable && productLicense.IsActive)
            {
                var receipt = await CurrentAppProxy.RequestProductPurchaseAsync(productLicense.ProductId);

                // Fulfill on PhotoSharingApp servers
                var user = await _photoService.FulfillGold(receipt.ReceiptXml);

                // If previous step was successful, fulfill in Store
                await CurrentAppProxy.ReportConsumableFulfillmentAsync(productLicense.ProductId, receipt.TransactionId);

                // Now update local gold balance
                AppEnvironment.Instance.CurrentUser.GoldBalance = user.GoldBalance;
            }
        }
コード例 #21
0
        public async void CommandHandlers(IUICommand commandLabel)
        {
            var Actions = commandLabel.Label;

            if (this.resourceLoader.GetString("StaticButtonBuy") == Actions)
            {
                if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                {
                    ListingInformation listing = await CurrentApp.LoadListingInformationAsync();

                    var superweapon = listing.ProductListings.FirstOrDefault(p => p.Value.ProductId == Constant.IAP_PREMIUN);

                    try
                    {
                        ListingInformation LicensePremiumID = await Windows.ApplicationModel.Store.CurrentApp.LoadListingInformationByProductIdsAsync(new string[] { Constant.IAP_PREMIUN });

                        string x = await CurrentApp.RequestProductPurchaseAsync(LicensePremiumID.ProductListings.ToList()[0].Value.ProductId, false);

                        var            productLicenses = CurrentApp.LicenseInformation.ProductLicenses;
                        ProductLicense tokenLicense    = productLicenses[Constant.IAP_PREMIUN];

                        if (tokenLicense.IsActive)
                        {
                            LocalProperties.SaveToLP(LocalProperties.LP_active_premium, "true");
                            new MessageDialog("Платный функционал успешно активирован").ShowAsync();
                        }
                        else
                        {
                            new MessageDialog("Не удалось активировать!").ShowAsync();
                        }
                    }
                    catch (Exception ex)
                    {
                        new MessageDialog("Неизвестная ошибка").ShowAsync();
                    }
                }
                else
                {
                    new MessageDialog(resourceLoader.GetString("Error_InternetConnection"), resourceLoader.GetString("Error")).ShowAsync();
                }
            }
            else
            {
                this.resourceLoader.GetString("StaticButtonCancel");
            }
        }
コード例 #22
0
        public async void makePurchase(string args)
        {
            try
            {
                string InAppProductKey = JsonHelper.Deserialize <string[]>(args)[0];


                // get specific in-app product by ID
                ListingInformation products = await CurrentApp.LoadListingInformationByProductIdsAsync(new string[] { InAppProductKey });

                ProductListing productListing = null;
                if (!products.ProductListings.TryGetValue(InAppProductKey, out productListing))
                {
                    this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Could not find product information"));
                    return;
                }

                // RequestProductPurchaseAsync requires use of the UI thread, so we use the dispatcher
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(async() => {
                    try
                    {
                        await CurrentApp.RequestProductPurchaseAsync(productListing.ProductId, false);

                        ProductLicense productLicense = null;
                        if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(InAppProductKey, out productLicense))
                        {
                            if (productLicense.IsActive)
                            {
                                this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "PaymentTransactionStatePurchased"));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        //User cancelled the purchase
                        //this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Unknown Error"));
                    }
                });
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Unknown Error"));
            }
        }
コード例 #23
0
        public void ActivateProductMachineMismatch()
        {
            MachineIdentifierProviderMock machineMock = new MachineIdentifierProviderMock(false);
            string productKey       = GenerateProductKey(123, 456, 0, "C", "toto", "Company", "*****@*****.**");
            var    licenseActivated = GetProductActivated(productKey);

            string publicXmlKey = KeyHelpers.GetPrivateKey();
            ProductLicenseManager licenseManager = new ProductLicenseManager(null, publicXmlKey, null, machineMock,
                                                                             new UserInformationProviderMock()
            {
                Username = "******",
                Company  = "Company",
                Email    = "*****@*****.**"
            });
            ProductLicense license = licenseManager.ActivateProduct(licenseActivated);

            Assert.AreEqual(LicenseStatus.MachineHashMismatch, license.Status, license.StatusReason);
        }
コード例 #24
0
        public void ActivateProductWrongUserInfo()
        {
            string productKey       = GenerateProductKey(123, 456, 0, "C", "toto", "Company", "*****@*****.**");
            var    licenseActivated = GetProductActivated(productKey);

            string publicXmlKey = KeyHelpers.GetPrivateKey();
            ProductLicenseManager licenseManager = new ProductLicenseManager(null, publicXmlKey,
                                                                             new MockLicenseStore(),
                                                                             new MachineIdentifierProviderMock(),
                                                                             new UserInformationProviderMock()
            {
                Username = "******",
                Company  = "Company",
                Email    = "*****@*****.**"
            });
            ProductLicense license = licenseManager.ActivateProduct(licenseActivated);

            Assert.AreEqual(LicenseStatus.Invalid, license.Status, license.StatusReason);
        }
コード例 #25
0
    public int BAL_Product_Insert_Update(ProductLicense PL)
    {
        int t1 = 0;

        try
        {
            this.DAL_License  = new DataAccess();
            this.arrParameter = new ArrayList();
            this.arrParameter.Add(new parameter("Code", PL.Code));
            this.arrParameter.Add(new parameter("ProductKey", PL.ProductKey));
            this.arrParameter.Add(new parameter("OldCode", PL.Oldcode));
            t1 = this.DAL_License.DAL_InsertUpdate_Return("Proc_Insert_Product_Registration", this.arrParameter);
        }
        catch (Exception ex)
        {
            WebMsg.Show(ex.Message);
        }
        return(t1);
    }
コード例 #26
0
 public override void CreateProductLicense(ProductLicense productLicense)
 {
     using (SqlConnection connection = this.GetSqlConnection())
     {
         using (SqlCommand command = new SqlCommand("SuCommerce_License_Add", connection))
         {
             command.CommandType = CommandType.StoredProcedure;
             command.Parameters.Add("@UserID", SqlDbType.Int, 4).Value        = productLicense.UserID;
             command.Parameters.Add("@PackageTypeID", SqlDbType.Int, 4).Value = productLicense.PackageTypeID;
             command.Parameters.Add("@LicenseTypeID", SqlDbType.Int, 4).Value = productLicense.LicenseTypeID;
             command.Parameters.Add("@Version", SqlDbType.Decimal, 5).Value   = productLicense.Version;
             command.Parameters.Add("@License", SqlDbType.NVarChar, 60).Value = DataHelper.StringOrNull(productLicense.License);
             command.Parameters.Add("@CartLinkID", SqlDbType.Int, 4).Value    = productLicense.CartLinkID;
             command.Parameters.Add("@PurchaseID", SqlDbType.Int, 4).Value    = productLicense.PurchaseID;
             connection.Open();
             command.ExecuteNonQuery();
             connection.Close();
         }
     }
 }
コード例 #27
0
        /// <summary>
        /// Returns true if the purchase is successful
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public async Task <bool> Purchase(string ID)
        {
            try
            {
            #if DEBUG
                ProductLicense license = CurrentAppSimulator.LicenseInformation.ProductLicenses[ID];

                if (!license.IsActive)
                {
                    PurchaseResults Results = await CurrentAppSimulator.RequestProductPurchaseAsync(ID);

                    if (Results.Status == ProductPurchaseStatus.Succeeded)
                    {
                        Unlock(ID);
                    }
                }
            #else
                ProductLicense license = CurrentApp.LicenseInformation.ProductLicenses[ID];

                if (!license.IsActive)
                {
                    PurchaseResults Results = await CurrentApp.RequestProductPurchaseAsync(ID);

                    if (Results.Status == ProductPurchaseStatus.Succeeded)
                    {
                        Unlock(ID);
                    }
                }
            #endif
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Purchases: " + e.Message);

                return(false);
            }

            return(true);
        }
コード例 #28
0
        // Private Methods (4) 

        /// <summary>
        /// Checks product Id
        /// </summary>
        /// <param name="LicenseProduct">License</param>
        /// <returns>true if the license fits the product ,false otherwise</returns>
        private static bool CheckProduct(ProductLicense LicenseProduct)
        {
            //Check Product ID and Features
            switch (LicenseProduct.ProductFeatures)
            {
            case 5:
                LicenseProperties.ActivatedFeatures = LicenseFeatures.AppsStandardDeveloper;
                break;

            default:
                LicenseProperties.ActivatedFeatures = LicenseFeatures.Normal;
                break;
            }

            bool result = LicenseProduct.ProductID == ProductId &&
                          LicenseProperties.ActivatedFeatures.HasFlag(LicenseFeatures.Normal);

            if (LicenseProperties.ActivatedFeatures.HasFlag(LicenseFeatures.Normal))
            {
                LicenseProperties.CurrentGrants |= LicenseGrants.Any;
            }
            return(result);
        }
コード例 #29
0
        protected override void CreateTestData()
        {
            lic1 = new ProductLicense();
            lic2 = new ProductLicense();

            perm1 = new AccountPermission("Permission 1");
            perm2 = new AccountPermission("Permission 2");

            user1 = new User("John Doe");
            user2 = new User("Mary Jane");

            ActiveRecordMediator <ProductLicense> .Create(lic1);

            ActiveRecordMediator <ProductLicense> .Create(lic2);

            ActiveRecordMediator <AccountPermission> .Create(perm1);

            ActiveRecordMediator <AccountPermission> .Create(perm2);

            ActiveRecordMediator <User> .Create(user1);

            ActiveRecordMediator <User> .Create(user2);
        }
コード例 #30
0
ファイル: IAPManager.cs プロジェクト: xmshaka/slash-framework
        public static bool BuyFeature(string key)
        {
            ProductLicense productLicense = licenseInformation.ProductLicenses[key];

            if (productLicense == null)
            {
                throw new ArgumentException("Unknown product: " + key, "key");
            }

            if (!productLicense.IsActive)
            {
                // The customer doesn't own this feature, so show the purchase dialog.
                if (Debug)
                {
                    var handler = OnSimulateBuyFeature;
                    if (handler != null)
                    {
                        handler(key);
                    }
                }
                else
                {
                    var handler = OnBuyFeature;
                    if (handler != null)
                    {
                        handler(key);
                    }
                }


                // Check the license state to determine if the in-app purchase was successful.
                return(HasFeature(key));
            }

            return(true);
        }
コード例 #31
0
ファイル: Functions.cs プロジェクト: CarverLab/Oyster
        internal ProductLicense AcquireAvailableLicense(string ProductName, int UserId, string UserSessionID,string ProductVersionID)
        {
            try
            {
                ClearTimedOutLicenses();
                int ProductID = GetProductIdByName(ProductName);
                int NumberOfLicenses = GetNumberOfProductLicenses(ProductID);

                string sSQL = "SELECT * FROM tblLogin WHERE UserId = " + UserId;

                int numrecs = ExecuteQueryResults(sSQL);
                if(numrecs > 0)
                {
                    if(!HasLicenseTimedOut(ProductID,UserId,UserSessionID,ProductVersionID))
                    {
                        throw new OysterLicenseException("User already logged in..");
                    }
                }

                if(NumberOfLicenses > 0)
                {
                    sSQL = "SELECT * FROM tblLogin WHERE ProductId = " + ProductID;
                    numrecs = ExecuteQueryResults(sSQL);
                    if(numrecs >= NumberOfLicenses)
                        throw new OysterLicenseException("Maximum number of licenses exceeded. All user login slots are in use at this time.");
                }

                sSQL = "INSERT INTO tblLogin(ProductId,UserId,UserSessionId,ProductVersionId) VALUES(" + ProductID +
                    "," + UserId +
                    ",'" + UserSessionID + "'" +
                    ",'" + ProductVersionID  + "')";
                numrecs = ExecuteNonQuery(sSQL);

                ProductLicense PL = new ProductLicense();
                PL.mvarProductId = ProductID;
                PL.mvarProductName = ProductName;
                PL.mvarUserId = UserId;
                PL.mvarUserSessionId = UserSessionID;
                PL.mvarProductVersionId = ProductVersionID;
                PL.mvarMaxLicenseCount = NumberOfLicenses;
                PL.mvarTimer.Enabled = true;
                PL.HasALicense = true;
                return PL;
            }
            catch(SqlException Err)
            {
                throw new Exception(Err.Message);
            }
        }
コード例 #32
0
        public static void AddProductListing(string key, ProductListing productListing)
        {
            CheckIfInitialized();

            if (_appListingInformation == null)
                throw new Exception("A call to SetListingInformation is required before calling this method");

            if (allProducts == null)
                allProducts = new Dictionary<string, ProductListing>();

            allProducts.Add(key, productListing);

            var store = new MockReceiptStore();
            Dictionary<string, string> receipts = store.EnumerateReceipts();

            // add a license for this item as well. 
            var license = new ProductLicense
                              {
                                  ExpirationDate = DateTimeOffset.Now,
                                  IsActive = receipts.ContainsKey(productListing.ProductId),
                                  IsConsumable = productListing.ProductType == ProductType.Consumable,
                                  ProductId = productListing.ProductId
                              };

            _appLicenseInformation.ProductLicenses.Add(productListing.ProductId, license);
        }