コード例 #1
0
        public ActionResult RevokeLicense(string userId)
        {
            TempData["UserId"] = userId;
            UserLicenseDetails licDetails = OnPremiseSubscriptionLogic.GetUserLicenseDetails(userId, false, false);

            ViewData["UserEmail"] = licDetails.User.Email;
            return(View(licDetails.SubscriptionDetails));
        }
コード例 #2
0
        /// <summary>
        /// Function to get the User License with details  for which user is authorized
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="isFeatureRequired"></param>
        /// <returns></returns>
        public static UserLicenseDetails GetUserLicenseDetails(string userId, bool isFeatureRequired, bool fetchBasedonTeam = true)
        {
            var                   licenseMapModelList = new UserLicenseDetails();
            HttpClient            client = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            FetchUserSubscription subs   = new FetchUserSubscription();

            if (fetchBasedonTeam)
            {
                subs.TeamId = LicenseSessionState.Instance.AppTeamContext.Id;
            }
            subs.UserId            = userId;
            subs.IsFeatureRequired = isFeatureRequired;
            var response = client.PostAsJsonAsync("api/License/GetSubscriptionLicenseByTeam", subs).Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                licenseMapModelList = JsonConvert.DeserializeObject <UserLicenseDetails>(jsonData);
            }
            return(licenseMapModelList);
        }
コード例 #3
0
        public DataTable SaveUserLicenseDetails(UserLicenseDetails userlicense)
        {
            SqlConnection conn = new SqlConnection();
            DataTable     Tbl  = new DataTable();

            try
            {
                //connetionString="Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd1 = new SqlCommand();
                cmd1.CommandType = CommandType.StoredProcedure;
                cmd1.CommandText = "InsUpdDelUserLicense";
                cmd1.Connection  = conn;
                conn.Open();

                SqlParameter vid1 = new SqlParameter();
                vid1.ParameterName = "@UserId";
                vid1.SqlDbType     = SqlDbType.Int;
                vid1.Value         = userlicense.UserId;
                cmd1.Parameters.Add(vid1);

                SqlParameter ccd1 = new SqlParameter();
                ccd1.ParameterName = "@FOId";
                ccd1.SqlDbType     = SqlDbType.Int;
                ccd1.Value         = userlicense.FOId;
                cmd1.Parameters.Add(ccd1);

                SqlParameter pu = new SqlParameter();
                pu.ParameterName = "@LicenseTypeId";
                pu.SqlDbType     = SqlDbType.Int;
                pu.Value         = userlicense.LicenseTypeId;
                cmd1.Parameters.Add(pu);

                SqlParameter pid = new SqlParameter();
                pid.ParameterName = "@GracePeriod";
                pid.SqlDbType     = SqlDbType.Int;
                pid.Value         = userlicense.GracePeriod;
                cmd1.Parameters.Add(pid);

                SqlParameter fd1 = new SqlParameter();
                fd1.ParameterName = "@ActualExpiry";
                fd1.SqlDbType     = SqlDbType.DateTime;
                fd1.Value         = userlicense.ActualExpiry;
                cmd1.Parameters.Add(fd1);

                SqlParameter fid = new SqlParameter();
                fid.ParameterName = "@StartDate";
                fid.SqlDbType     = SqlDbType.DateTime;
                fid.Value         = userlicense.StartDate;
                cmd1.Parameters.Add(fid);

                SqlParameter sid = new SqlParameter();
                sid.ParameterName = "@LastUpdatedOn";
                sid.SqlDbType     = SqlDbType.DateTime;
                sid.Value         = userlicense.LastUpdatedOn;
                cmd1.Parameters.Add(sid);

                SqlParameter td1 = new SqlParameter();
                td1.ParameterName = "@ExpiryOn";
                td1.SqlDbType     = SqlDbType.DateTime;
                td1.Value         = userlicense.ExpiryOn;
                cmd1.Parameters.Add(td1);

                SqlParameter hid = new SqlParameter();
                hid.ParameterName = "@StatusId";
                hid.SqlDbType     = SqlDbType.Int;
                hid.Value         = userlicense.StatusId;
                cmd1.Parameters.Add(hid);


                SqlParameter nActive = new SqlParameter("@Active", SqlDbType.Int);
                nActive.Value = userlicense.Active;
                cmd1.Parameters.Add(nActive);

                SqlParameter yid = new SqlParameter();
                yid.ParameterName = "@RenewFreqTypeId";
                yid.SqlDbType     = SqlDbType.Int;
                yid.Value         = userlicense.RenewFreqTypeId;
                cmd1.Parameters.Add(yid);

                SqlParameter flag = new SqlParameter();
                flag.ParameterName = "@insupddelflag";
                flag.SqlDbType     = SqlDbType.VarChar;
                flag.Value         = userlicense.insupddelflag;
                cmd1.Parameters.Add(flag);


                SqlDataAdapter db = new SqlDataAdapter(cmd1);
                db.Fill(Tbl);
                return(Tbl);
            }
            catch (Exception ex)
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
                string str = ex.Message;
                return(Tbl);
            }
        }
コード例 #4
0
        public UserLicenseDetails GetUserLicenseSubscriptionDetails(FetchUserSubscription model)
        {
            UserLicenseDetails licDetails = new UserLicenseDetails();
            var licenseMapModelList       = new List <SubscriptionDetails>();
            UserLicenseLogic logic        = new UserLicenseLogic();
            SubscriptionBO   proSubLogic  = new SubscriptionBO();

            userLogic.UserManager = UserManager;
            userLogic.RoleManager = RoleManager;

            licDetails.User = userLogic.GetUserById(model.UserId);


            List <UserLicense> data = null;

            if (model.TeamId == 0)
            {
                data = logic.GetUserLicense(model.UserId);
            }
            else
            {
                data = logic.GetUserLicense(model.UserId, model.TeamId);
            }

            var dataList = proSubLogic.GetSubscriptionFromFile();

            if (data.Count > 0)
            {
                var      subsIdList       = data.Select(l => l.License.Subscription.SubscriptionId);
                var      subscriptionList = dataList.Where(s => subsIdList.Contains(s.Id)).ToList();
                DateTime licExpireData    = DateTime.MinValue;
                foreach (var subs in subscriptionList)
                {
                    var userLicLicst             = data.Where(ul => ul.License.Subscription.SubscriptionId == subs.Id).ToList();
                    var proList                  = userLicLicst.Select(u => u.License.ProductId).ToList();
                    SubscriptionDetails mapModel = new SubscriptionDetails()
                    {
                        Name = subs.Name,
                        UserSubscriptionId = data.FirstOrDefault(us => us.License.Subscription.SubscriptionId == subs.Id).License.UserSubscriptionId
                    };
                    foreach (var pro in subs.Products.Where(p => proList.Contains(p.Id)))
                    {
                        var objLic = userLicLicst.FirstOrDefault(f => f.License.ProductId == pro.Id);
                        if (objLic != null)
                        {
                            string licenseKeydata = String.Empty;
                            licenseKeydata = objLic.License.LicenseKey;
                            var splitData   = licenseKeydata.Split(new char[] { '-' });
                            var datakey     = splitData[0];
                            var decryptObj  = LicenseKey.LicenseKeyGen.CryptoEngine.Decrypt(datakey, true);
                            var licdataList = decryptObj.Split(new char[] { '^' });
                            licExpireData = Convert.ToDateTime(licdataList[1]);
                        }
                        ProductDetails prod = new ProductDetails()
                        {
                            Id         = pro.Id,
                            Name       = pro.Name,
                            ExpireDate = licExpireData
                        };
                        if (model.IsFeatureRequired)
                        {
                            foreach (var fet in pro.AssociatedFeatures)
                            {
                                var feature = new Feature()
                                {
                                    Id          = fet.Id,
                                    Name        = fet.Name,
                                    Description = fet.Description,
                                    Version     = fet.Version
                                };
                                prod.Features.Add(feature);
                            }
                        }
                        mapModel.Products.Add(prod);
                    }
                    licenseMapModelList.Add(mapModel);
                }
            }
            licDetails.SubscriptionDetails = licenseMapModelList;
            return(licDetails);
        }