/// <summary> /// Register user action /// </summary private void RegisterNewUser(object param) { if (!string.IsNullOrEmpty(LName) && !string.IsNullOrEmpty(FName) && !string.IsNullOrEmpty(Organization) && !string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password)) { var userLogic = new LoginLogic(); //Validate Email var status = userLogic.ValidateEmail(user.Email); if (status) { userLogic.CreateUserInfo(user); string licenseType = param.ToString(); if (licenseType == "Trial") { var logic = new LicenseLogic(); SingletonLicense.Instance.SelectedSubscription = logic.GetTrialLicense(); logic.ActivateSubscription(); } var dict = new Dictionary <string, string>(); dict.Add("licenseType", licenseType); if (NavigateNextPage != null) { NavigateNextPage(null, dict); } } else { MessageBox.Show("Email Address already Exist"); } } }
public static async Task Connect() { if (!connectionRequested) { string _myAccessToken = Startup.GeneralSettings.SocketSecret; connection = new HubConnectionBuilder() .WithUrl(Startup.GeneralSettings.SocketUrl + _myAccessToken, options => { options.AccessTokenProvider = () => Task.FromResult(_myAccessToken); }) .Build(); connection.Closed += async(error) => { Connected = false; await Task.Delay(new Random().Next(0, 5) * 1000); await tryUntilConnected(); }; connection.On <string, string>("GenerateLicense", async(licenseKey, registrationContent) => { LicenseLogic.ConnectionString = Startup.GeneralSettings.DatabaseConnection; var signedLicense = LicenseLogic.GenerateLicense(JsonConvert.DeserializeObject <RegistrationModel>(registrationContent)); await connection.InvokeAsync("SendMessage", licenseKey, signedLicense); }); await tryUntilConnected(); } connectionRequested = true; }
/// <summary> /// Time consuming operations go here /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_oWorker_DoWork(object sender, DoWorkEventArgs e) { //time consuming operation for (int i = 0; i < 80; i++) { if (i < 60) { Thread.Sleep(50); } m_oWorker.ReportProgress(i); //If cancel button was pressed while the execution is in progress //Change the state from cancellation ---> cancel'ed if (m_oWorker.CancellationPending) { e.Cancel = true; m_oWorker.ReportProgress(0); return; } } LicenseLogic logic = new LicenseLogic(); logic.ActivateSubscription(); //Report 100% completion on operation completed m_oWorker.ReportProgress(100); }
public TeamBO() { userLogic = new UserLogic(); logic = new TeamMemberLogic(); teamLogic = new TeamLogic(); teamLicenseLogic = new TeamLicenseLogic(); userLicLogic = new UserLicenseLogic(); licLogic = new LicenseLogic(); }
public void UpdateUserSubscription(List <UserSubscriptionData> userSubscriptionData) { List <SubscriptionType> typeList = new List <SubscriptionType>(); foreach (var data in userSubscriptionData) { var tempObj = data.Subscription.SubscriptionType; tempObj.ProductIdList = tempObj.Products.Select(p => (dynamic) new { Id = p.Id, ProductCode = p.ProductCode }).ToList(); typeList.Add(tempObj); UserSubscription sub = new UserSubscription(); sub.Quantity = data.Quantity; sub.SubscriptionDate = data.SubscriptionDate; sub.RenewalDate = data.RenewalDate; sub.SubscriptionId = data.SubscriptionId; sub.UserId = data.UserId; var userSubscriptionId = userSubLogic.CreateSubscription(sub); List <License.DataModel.LicenseData> licenseDataList = new List <DataModel.LicenseData>(); foreach (var lic in data.LicenseKeys) { License.DataModel.LicenseData licenseData = new DataModel.LicenseData() { LicenseKey = lic.LicenseKey, ProductId = lic.ProductId, UserSubscriptionId = userSubscriptionId }; licenseDataList.Add(licenseData); } LicenseLogic licenseLogic = new LicenseLogic(); licenseLogic.CreateLicenseData(licenseDataList); } try { if (typeList.Count > 0) { Logic.BusinessLogic.SubscriptionBO proSubLogic = new Logic.BusinessLogic.SubscriptionBO(); proSubLogic.SaveToFile(typeList); } } catch (Exception ex) { Logger.Logger.Error(ex); } }
public void UpdateSubscriptionRenewal(List <UserSubscriptionData> subscriptionData, string userId) { var userSubscriptioList = userSubLogic.GetSubscription(userId); List <UserSubscription> userSubscriptions = new List <UserSubscription>(); foreach (var data in subscriptionData) { var userSubscription = userSubscriptioList.FirstOrDefault(u => u.SubscriptionId == data.SubscriptionId); LicenseLogic licenseLogic = new LicenseLogic(); licenseLogic.UpdateRenewalLicenseKeys(data.LicenseKeys, userSubscription.Id); userSubscription.RenewalDate = data.RenewalDate; userSubscriptions.Add(userSubscription); } if (userSubscriptions.Count > 0) { userSubLogic.UpdateSubscriptions(userSubscriptions); } }
private void KiemTraInsertMayTram() { try { GlobalSettings.MaDatabase = Base.KiemTraLicense.LayThongTinMaDatabase(); LICENSE _license = LicenseLogic.Select(GlobalSettings.MaDatabase); if (_license == null) //Insert { LICENSE _insert = new LICENSE(); _insert.DataKey = GlobalSettings.MaDatabase; _insert.LicenseKey = O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Encrypt("", true); LicenseLogic.Insert(_insert); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); } }
private void HienThiThongTinVeLicense() { try { MaDatabase = Base.KiemTraLicense.LayThongTinMaDatabase(); txtMaMay.Text = MaDatabase; txtMaMay.ReadOnly = true; LICENSE license = LicenseLogic.Select(MaDatabase); if (license != null) { txtKeyKichHoat.Text = license.LicenseKey; } txtKeyKichHoat.Focus(); btnLicenseKiemTra.PerformClick(); } catch (Exception ex) { O2S_Common.Logging.LogSystem.Warn(ex); } }
private void btnLicenseLuu_Click(object sender, EventArgs e) { try { LICENSE _license = new LICENSE(); _license.DataKey = txtMaMay.Text; _license.LicenseKey = txtKeyKichHoat.Text.Trim(); try { LicenseLogic.Update(_license); O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao("Lưu mã kích hoạt thành công!"); frmthongbao.Show(); } catch (Exception) { O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA); frmthongbao.Show(); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Warn(ex); } }
internal static void KiemTraLicenseHopLe() { try { GlobalSettings.KiemTraLicenseSuDung = false; //Load License tu DB ra string license_keydb = LicenseLogic.Select(GlobalSettings.MaDatabase).LicenseKey ?? null; if (license_keydb != null) { //Giai ma string makichhoat_giaima = O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Decrypt(license_keydb, true); //Tach ma kich hoat: string mamay_keykichhoat = ""; string mabanquyenkhongthoihan = ""; long datetimenow = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd")); //lay thoi gian may chu database: neu khong lay duoc thi lay thoi gian tren may client try { string sql_dateDB = "SELECT FORMAT(SYSDATETIME(),'yyyyMMdd') as 'yyyyMMdd';"; DataView dtdatetime = new DataView(condb.GetDataTable(sql_dateDB)); if (dtdatetime != null && dtdatetime.Count > 0) { datetimenow = O2S_Common.TypeConvert.Parse.ToInt64(dtdatetime[0]["yyyyMMdd"].ToString()); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); } if (!String.IsNullOrEmpty(makichhoat_giaima)) { string[] makichhoat_tach = makichhoat_giaima.Split('$'); if (makichhoat_tach.Length == 4) { mamay_keykichhoat = makichhoat_tach[1]; //Thoi gian hien tai datetimenow = Convert.ToInt64(DateTime.Now.ToString("yyyyMMdd")); //Kiem tra License hop le if (mamay_keykichhoat == GlobalSettings.MaDatabase && datetimenow <= Convert.ToInt64(makichhoat_tach[3].ToString().Trim() ?? "0")) { GlobalSettings.KiemTraLicenseSuDung = true; } } else if (makichhoat_tach.Length == 3) { mamay_keykichhoat = makichhoat_tach[1]; mabanquyenkhongthoihan = makichhoat_tach[2]; if (mamay_keykichhoat == GlobalSettings.MaDatabase && mabanquyenkhongthoihan == KeyTrongPhanMem.BanQuyenKhongThoiHan) { GlobalSettings.KiemTraLicenseSuDung = true; } } } } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Warn("Kiem tra license " + ex.ToString()); } }
/// <summary> /// To load subscription collection. /// </summary> private void LoadSubscriptionList() { LicenseLogic logic = new LicenseLogic(); SubscriptionList = logic.GetSubscriptionDetails(); }
public List <SubscriptionDetails> GetSubscriptionList(string adminId, string userId = "") { List <SubscriptionDetails> lstSsubscriptionDetail = new List <SubscriptionDetails>(); var usersubList = userSubLogic.GetSubscription(adminId); SubscriptionBO psLogic = new SubscriptionBO(); var subList = psLogic.GetSubscriptionFromFile(); List <int> proList = new List <int>(); if (!String.IsNullOrEmpty(userId)) { bool isAdmin = adminId == userId; TeamBO teamBo = new TeamBO(); proList = teamBo.GetTeamProductByUserId(userId, isAdmin); } foreach (var userSub in usersubList) { var subType = subList.FirstOrDefault(s => s.Id == userSub.SubscriptionId); if (subType != null) { SubscriptionDetails model = new SubscriptionDetails() { Id = subType.Id, UserSubscriptionId = userSub.Id, Name = subType.Name }; LicenseLogic licDataLogic = new LicenseLogic(); var userlicList = licDataLogic.GetLicenseList(userSub.Id); foreach (var pro in subType.Products) { if (!proList.Contains(pro.Id)) { var licList = userlicList.Where(p => p.ProductId == pro.Id).ToList(); var proObj = new ProductDetails() { Id = pro.Id, Name = pro.Name, ProductCode = pro.ProductCode, TotalLicenseCount = licList.Count, UsedLicenseCount = licList.Where(l => l.IsMapped == true).Count() }; proObj.IsDisabled = proObj.TotalLicenseCount == proObj.UsedLicenseCount; model.Products.Add(proObj); } } lstSsubscriptionDetail.Add(model); } } if (!String.IsNullOrEmpty(userId)) { UserLicenseLogic logic = new UserLicenseLogic(); var data = logic.GetUserLicense(userId); if (data != null && data.Count > 0) { data = data.Where(p => p.IsTeamLicense == false).ToList(); } foreach (var obj in data) { var subObj = lstSsubscriptionDetail.FirstOrDefault(f => f.UserSubscriptionId == obj.License.UserSubscriptionId); if (subObj != null) { var pro = subObj.Products.FirstOrDefault(f => f.Id == obj.License.ProductId); if (pro != null) { pro.IsSelected = true; pro.InitialState = true; } } } } return(lstSsubscriptionDetail); }