public bool UpdateFranchiseeTenantLicenceExtentsion(FranchisseNameAndLicenseDto franchiseeData) { var franchiseeTenant = _franchiseeTenantRepository.FirstOrDefault( o => o.LicenseKey.Equals(franchiseeData.LicenseKey) && o.Name.Equals(franchiseeData.FranchiseeName)); if (franchiseeTenant != null) { //franchiseeTenant.StartActiveDate = DateTime.UtcNow; if (franchiseeTenant.CurrentPackageId % 2 == 0) { franchiseeTenant.EndActiveDate = DateTime.UtcNow.AddMonths(1); } else { franchiseeTenant.EndActiveDate = DateTime.UtcNow.AddMonths(12); } franchiseeTenant.CloseDate = null; franchiseeTenant.DescriptionClose = null; franchiseeTenant.QuestionClose = null; franchiseeTenant.StartDateSuccess = null; franchiseeTenant.EndDateSuccess = null; _franchiseeTenantRepository.Update(franchiseeTenant); franchiseeTenant.IsActive = true; _franchiseeTenantRepository.Commit(); return(true); } return(false); }
public int GetRequestCurrentId(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = _franchiseeTenantRepository.FirstOrDefault( o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey); return(_packageHistoryRepository.GetCurrentRequestId(franchisee.Id)); }
public ActionResult Index(string keyCode) { if (string.IsNullOrEmpty(keyCode)) { return(Redirect("/")); } var password = string.Empty; var userName = GetKeyAuthenticationDecrypt(keyCode, ref password); var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "", LicenseKey = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "" }; var franchiseeTenantPackageInfo = _webApiUserService.GetPackageCurrentId(objFranchiseeAndLicense); //TODO: franchiseeTenantPackageInfo.Active == false update franchiseeTenantPackageInfo.Active == true when deploy if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password) || franchiseeTenantPackageInfo == null || franchiseeTenantPackageInfo.Active) { return(Redirect("/")); } return(View(new LicenceExtensionData { KeyCode = keyCode, UserName = userName })); }
public PackageHistoryDto GetPackageCurrentNoToken(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = _franchiseeTenantRepository.FirstOrDefault( o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey); return(_packageHistoryRepository.GetPackageCurrent(franchisee.Id)); }
public JsonResult GetDisplayAlertExtended() { if (ConstantValue.DeploymentMode == DeploymentMode.Camino) { return(Json(new { data = false }, JsonRequestBehavior.AllowGet)); } var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "", LicenseKey = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "" }; var check = false; var info = _webApiUserService.GetInfoFranchiseeNoToken(objFranchiseeAndLicense); double totalDay = 0; if (info != null && info.AlertExtendedPackage != null) { if (info.NextBillingDate != null) { totalDay = Math.Ceiling((info.NextBillingDate.GetValueOrDefault() - DateTime.UtcNow).TotalDays); } check = info.AlertExtendedPackage == true; } return(Json(new { data = check, totaldDay = totalDay }, JsonRequestBehavior.AllowGet)); }
public List <PackageHistoryDto> GetListPackageChange(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = _franchiseeTenantRepository.FirstOrDefault( o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey); return(_packageHistoryRepository.GetListPackageChange(franchisee.Id)); }
public JsonResult QuickspatchSignIn(string userName, string password, bool rememberMe, string returnUrl) { var isCamino = true; // Check if system is the franchisse, login to the web api to verify the license if (ConstantValue.DeploymentMode == DeploymentMode.Franchisee) { isCamino = false; var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { //FranchiseeName = ConstantValue.FranchiseeName, //LicenseKey = ConstantValue.LicenseKey FranchiseeName = franchiseeConfiguration != null?franchiseeConfiguration.Name:"", LicenseKey = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "", }; //Get Key Authentication for exeption Licence Invalid. var keyAuthentication = GetKeyAuthentication(userName, password); SignInToWebApi(objFranchiseeAndLicense, keyAuthentication); // Get list module for franchisee var franchiseeData = _webApiUserService.GetModuleForFranchisee(objFranchiseeAndLicense); MenuExtractData.Instance.ModuleForFranchisee = franchiseeData; MenuExtractData.Instance.NumberOfCourier = franchiseeData.NumberOfCourier; } password = PasswordHelper.HashString(password, userName); _authenticationService.SignIn(userName, password, rememberMe, ConstantValue.DeploymentMode.ToString()); return(Json(new { isCamino }, JsonRequestBehavior.AllowGet)); }
//get data for franchisee configuration public JsonResult GetInfoFranchiseeIndex() { var model = new FranchiseeInfoShareViewModel(); var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); if (franchiseeConfiguration != null) { var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { FranchiseeName = franchiseeConfiguration.Name, LicenseKey = franchiseeConfiguration.LicenseKey }; var startDate = ""; var endDate = ""; var activeDate = _webApiUserService.GetActiveDateLicenseKey(objFranchiseeAndLicense); if (activeDate.StartActiveDate != null) { startDate = ((DateTime)activeDate.StartActiveDate).ToClientTime("MM/dd/yyyy"); } if (activeDate.EndActiveDate != null) { endDate = ((DateTime)activeDate.EndActiveDate).ToClientTime("MM/dd/yyyy"); } model = new FranchiseeInfoShareViewModel { FranchiseeId = franchiseeConfiguration.Id.ToString(), Logo = franchiseeConfiguration.Logo != null ? "data:image/jpg;base64," + Convert.ToBase64String(franchiseeConfiguration.Logo) : "", Name = franchiseeConfiguration.Name, OfficePhone = franchiseeConfiguration.OfficePhone.ApplyFormatPhone(), FaxNumber = franchiseeConfiguration.FaxNumber.ApplyFormatPhone(), Address = franchiseeConfiguration.Address1 == "N/A" ? "N/A" : (franchiseeConfiguration.Address1 + (franchiseeConfiguration.Address2 == null ? "" : ", " + franchiseeConfiguration.Address2) + ", " + franchiseeConfiguration.City + ", " + franchiseeConfiguration.State + ", " + franchiseeConfiguration.Zip), FranchiseeContact = franchiseeConfiguration.FranchiseeContact, PrimaryContactPhone = franchiseeConfiguration.PrimaryContactPhone.ApplyFormatPhone(), PrimaryContactEmail = franchiseeConfiguration.PrimaryContactEmail, PrimaryContactFax = franchiseeConfiguration.FaxNumber.ApplyFormatPhone(), PrimaryContactCellNumber = franchiseeConfiguration.PrimaryContactCellNumber.ApplyFormatPhone(), StartActiveDate = startDate, EndActiveDate = endDate, LicenseKey = franchiseeConfiguration.LicenseKey, }; var clientsJson = Json(model, JsonRequestBehavior.AllowGet); return(clientsJson); } var clientsJson1 = Json(model, JsonRequestBehavior.AllowGet); return(clientsJson1); }
public JsonResult GetListTransaction(TransactionQueryInfo queryInfo) { var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "", LicenseKey = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "" }; var listHistoryPackages = _webApiUserService.GetListPackageChange(objFranchiseeAndLicense); var listTransaction = new List <PaymentTransactionItemViewModel>(); var listRequestId = new List <int>();// { 1075,1078 }; foreach (var item in listHistoryPackages) { listRequestId.Add(item.RequestId); } var transaction = new TransactionDto { FromDate = DateTime.Now.AddMonths(-1), ToDate = DateTime.Now, RequestId = listRequestId }; var getTransaction = _webApiPaymentService.GetListTransaction(transaction); foreach (var item in getTransaction.PaymentTransactionItems) { listTransaction.Add(new PaymentTransactionItemViewModel { TransactionId = item.TransactionId, SubmittedOnUtc = item.SubmittedOnUtc, RequestId = item.RequestId }); } if (queryInfo.SearchString == null) { queryInfo.SearchString = ""; } if (queryInfo.RequestId > 0) { var listSearch = listTransaction.Where(o => o.RequestId == queryInfo.RequestId).OrderByDescending(b => b.SubmittedOnUtc).ToList(); var data = new { Data = listSearch, TotalRowCount = listSearch.Count }; var clientsJson = Json(data, JsonRequestBehavior.AllowGet); return(clientsJson); } else { var data = new { Data = listTransaction.OrderByDescending(b => b.SubmittedOnUtc).ToList(), TotalRowCount = listTransaction.Count }; var clientsJson = Json(data, JsonRequestBehavior.AllowGet); return(clientsJson); } }
private bool SignInToWebApi(FranchisseNameAndLicenseDto objFranchiseeAndLicense, string keyAuthentication) { //var claimExceptiona = new InvalidClaimsException("InvalidLicenseKey", keyAuthentication) //{ // QuickspatchUserName = string.Empty //}; //throw claimExceptiona; // Get token if (ConstantValue.DeploymentMode == DeploymentMode.Camino) { return(true); } // Get token var objTokenStore = _webApiUserService.GetToken(objFranchiseeAndLicense); if (objTokenStore == null) { var claimException = new InvalidClaimsException("InvalidLicenseKey", keyAuthentication) { QuickspatchUserName = string.Empty }; throw claimException; } if (!string.IsNullOrEmpty(objTokenStore.AccessToken)) { // Store token to cookie var accessTokenCookie = new HttpCookie(ClaimsDeclaration.TokenClaim, objTokenStore.AccessToken) { HttpOnly = true, Expires = DateTime.UtcNow.AddDays(7) }; if (HttpContext.Response.Cookies[ClaimsDeclaration.TokenClaim] != null) { HttpContext.Response.Cookies.Remove(ClaimsDeclaration.TokenClaim); } HttpContext.Response.Cookies.Add(accessTokenCookie); var refreshTokenCookie = new HttpCookie(ClaimsDeclaration.RefreshTokenClaim, objTokenStore.RefreshToken) { HttpOnly = true, Expires = DateTime.UtcNow.AddYears(1) }; if (HttpContext.Response.Cookies[ClaimsDeclaration.RefreshTokenClaim] != null) { HttpContext.Response.Cookies.Remove(ClaimsDeclaration.RefreshTokenClaim); } HttpContext.Response.Cookies.Add(refreshTokenCookie); } return(false); }
public bool CheckFranchiseIsExpire(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = _franchiseeTenantRepository.FirstOrDefault( o => o.LicenseKey == franchiseeData.LicenseKey && o.Name == franchiseeData.FranchiseeName); if (franchisee != null) { if (franchisee.EndActiveDate.GetValueOrDefault() > DateTime.UtcNow) { return(true); } } return(false); }
public ActionResult Package(string keyCode) { var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "", LicenseKey = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "" }; var franchiseeTenantPackageInfo = _webApiUserService.GetPackageCurrentId(objFranchiseeAndLicense); if (franchiseeTenantPackageInfo == null || franchiseeTenantPackageInfo.Active) { return(Redirect("/")); } return(View(new LicenceExtensionData { KeyCode = keyCode, UserName = string.Empty, PackageId = franchiseeTenantPackageInfo.PackageId })); }
public bool UpdateFranchiseeTenantCancelAccount(FranchisseNameAndLicenseDto franchiseeData) { var tenent = _franchiseeTenantRepository.FirstOrDefault( o => o.Name.ToLower().Equals(franchiseeData.FranchiseeName.ToLower()) && o.LicenseKey.Equals(franchiseeData.LicenseKey)); if (tenent != null) { tenent.CloseDate = null; tenent.DescriptionClose = null; tenent.QuestionClose = null; _franchiseeTenantRepository.Update(tenent); _franchiseeTenantRepository.Commit(); return(true); } return(false); }
public ActiveDateLicenseKeyDto GetActiveDateLicenseKey(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = GetAll() .FirstOrDefault( o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey); if (franchisee == null) { return(null); } var objResult = new ActiveDateLicenseKeyDto { StartActiveDate = franchisee.StartActiveDate, EndActiveDate = franchisee.EndActiveDate }; return(objResult); }
public FranchiseeTernantCurrentPackageDto GetPackageCurrentId(FranchisseNameAndLicenseDto franchiseeData) { var franchiseeTenant = _franchiseeTenantRepository.FirstOrDefault( o => o.LicenseKey.Equals(franchiseeData.LicenseKey) && o.Name.Equals(franchiseeData.FranchiseeName)); if (franchiseeData != null) { return(new FranchiseeTernantCurrentPackageDto { Id = franchiseeTenant.Id, PackageId = franchiseeTenant.CurrentPackageId.GetValueOrDefault(), Active = franchiseeTenant.IsActive && franchiseeTenant.EndActiveDate.GetValueOrDefault() >= DateTime.UtcNow, AccountNumber = franchiseeTenant.AccountNumber, Amount = franchiseeTenant.RemainingAmount }); } return(null); }
public JsonResult GetListChangePackage(QueryInfo queryInfo) { var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration(); var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto { FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "", LicenseKey = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : "" }; var lists = _webApiUserService.GetListPackageChange(objFranchiseeAndLicense); if (queryInfo.SearchString == null) { queryInfo.SearchString = ""; } var listSearch = lists.Where( o => o.OldPackageName.ToLower().Contains(queryInfo.SearchString) || o.PackageName.ToLower().Contains(queryInfo.SearchString)).ToList(); var data = new { Data = listSearch, TotalRowCount = listSearch.Count }; var clientsJson = Json(data, JsonRequestBehavior.AllowGet); return(clientsJson); }
public IHttpActionResult CheckConnection(CheckConnectDto checkConnectDto) { var franchisee = _franchiseeConfigurationService.FirstOrDefault(); var franchiseeData = new FranchisseNameAndLicenseDto() { LicenseKey = franchisee.LicenseKey, FranchiseeName = franchisee.Name }; var objTokenStore = _webApiConsumeUserService.GetToken(franchiseeData); if (objTokenStore != null) { int checkConnectValue = _courierService.CheckConnection(checkConnectDto); return(Ok(new DtoBase { Id = checkConnectValue })); } return(Ok(new DtoBase { Id = 10 })); }
//get info franchisee public FranchiseeTernantDto GetInfoFranchisee(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = GetAll() .FirstOrDefault( o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey); if (franchisee == null) { return(null); } var objResult = new FranchiseeTernantDto { Id = franchisee.Id, FranchiseeId = franchisee.Id.ToString(), Name = franchisee.Name, Address1 = franchisee.Address1, Address2 = franchisee.Address2, City = franchisee.City, Zip = franchisee.Zip, OfficePhone = franchisee.OfficePhone, FaxNumber = franchisee.FaxNumber, IndustryId = franchisee.IndustryId, NumberOfCourier = franchisee.NumberOfCourier, StartActiveDate = franchisee.StartActiveDate, EndActiveDate = franchisee.EndActiveDate, AccountNumber = franchisee.AccountNumber, CloseDate = franchisee.CloseDate, Amount = franchisee.RemainingAmount, NextBillingDate = franchisee.NextBillingDate, PackageNextBillingDate = franchisee.PackageNextBillingDate, AlertExtendedPackage = franchisee.AlertExtendedPackage }; return(objResult); }
public ModuleForFranchiseeDto GetModuleForFranchisee(FranchisseNameAndLicenseDto franchiseeData) { var franchisee = GetAll() .FirstOrDefault( o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey); if (franchisee == null) { return(null); } var listModule = from o in franchisee.FranchiseeModule select new { ModuleId = o.ModuleId, ListModuleOperation = o.Module.ModuleDocumentTypeOperations }; var objResult = new ModuleForFranchiseeDto { NumberOfCourier = franchisee.NumberOfCourier, ListModuleId = new List <int>(), ListModuleDocumentTypeOperations = new List <ModuleDocumentTypeOperationDto>() }; foreach (var item in listModule) { objResult.ListModuleId.Add(item.ModuleId); foreach (var moduleOper in item.ListModuleOperation) { var objAdd = new ModuleDocumentTypeOperationDto { DocumentTypeId = moduleOper.DocumentTypeId, ModuleId = moduleOper.ModuleId, OperationId = moduleOper.SercurityOperationId }; objResult.ListModuleDocumentTypeOperations.Add(objAdd); } } return(objResult); }
public IHttpActionResult UpdateFranchiseeTenantLicenceExtentsion(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_franchiseeTenantService.UpdateFranchiseeTenantLicenceExtentsion(franchiseeData))); }
public IHttpActionResult GetRequestCurrentId(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_packageHistoryService.GetRequestCurrentId(franchiseeData))); }
public ActiveDateLicenseKeyDto GetActiveDateLicenseKey(FranchisseNameAndLicenseDto franchiseeData) { return(_franchiseeTenantRepository.GetActiveDateLicenseKey(franchiseeData)); }
public IHttpActionResult UpdateFranchiseeTenantCancelAccount(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_franchiseeTenantService.UpdateFranchiseeTenantCancelAccount(franchiseeData))); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { switch (context.ClientId) { case QuickspatchWebClient: { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); var franchisseService = GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IFranchiseeTenantService)) as IFranchiseeTenantService; FranchiseeTenant franchisee = null; if (franchisseService != null) { franchisee = franchisseService.CheckFranchiseeWithNameAndLicenseKey(context.UserName, context.Password); if (franchisee == null) { context.Rejected(); return; } } if (franchisee == null) { context.Rejected(); return; } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim(ClaimsDeclaration.IdClaim, franchisee.Id.ToString())); identity.AddClaim(new Claim(ClaimsDeclaration.QuickspatchClientType, ((int)QuickspatchClientType.WebClient).ToString())); // create metadata to pass on to refresh token provider var props = new AuthenticationProperties(new Dictionary <string, string> { { "as:client_id", context.ClientId } }); //var diagnosticService = new DiagnosticService(); var ticket = new AuthenticationTicket(identity, props); context.Validated(ticket); //bool b = context.Validated(ticket); //diagnosticService.Debug(string.Format("Validated ticket with user{0}:{1}", context.UserName, b)); return; } case QuickspatchMobileClient: { var franchiseeConfigurationService = GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IFranchiseeConfigurationService)) as IFranchiseeConfigurationService; var webApiConsumeUserService = GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IWebApiConsumeUserService)) as IWebApiConsumeUserService; if (franchiseeConfigurationService != null && webApiConsumeUserService != null) { var franchisee = franchiseeConfigurationService.FirstOrDefault(); var franchiseeData = new FranchisseNameAndLicenseDto() { LicenseKey = franchisee.LicenseKey, FranchiseeName = franchisee.Name }; var objTokenStore = webApiConsumeUserService.GetToken(franchiseeData); if (objTokenStore != null) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); var userService = GlobalConfiguration.Configuration.DependencyResolver.GetService(typeof(IUserService)) as IUserService; User user = null; //verify is expire or not if (userService != null) { user = userService.GetUserByUserNameAndPass(context.UserName, context.Password); if (user == null) { context.Rejected(); return; } } if (user == null) { context.Rejected(); return; } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim(ClaimsDeclaration.IdClaim, user.Id.ToString())); identity.AddClaim(new Claim(ClaimsDeclaration.QuickspatchClientType, ((int)QuickspatchClientType.MobileClient).ToString())); // create metadata to pass on to refresh token provider var props = new AuthenticationProperties(new Dictionary <string, string> { { "as:client_id", context.ClientId } }); var ticket = new AuthenticationTicket(identity, props); context.Validated(ticket); return; } else { context.Response.StatusCode = 99; context.SetError("Invalid license"); //context.Rejected(); return; } } return; } default: return; } }
public IHttpActionResult GetInfoFranchisee(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_franchiseeTenantService.GetInfoFranchisee(franchiseeData))); }
public IHttpActionResult CheckIsExpire(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_franchiseeTenantService.CheckFranchiseIsExpire(franchiseeData))); }
public FranchiseeTernantDto GetInfoFranchiseeNoToken(FranchisseNameAndLicenseDto franchiseeData) { return(_franchiseeTenantRepository.GetInfoFranchisee(franchiseeData)); }
public IHttpActionResult GetPackageCurrentNoToken(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_packageHistoryService.GetPackageCurrentNoToken(franchiseeData))); }
public ModuleForFranchiseeDto GetModuleForFranchisee(FranchisseNameAndLicenseDto franchiseeData) { return(_franchiseeTenantRepository.GetModuleForFranchisee(franchiseeData)); }
public IHttpActionResult GetRequest(FranchisseNameAndLicenseDto franchiseeData) { return(Ok(_franchiseeTenantService.GetModuleForFranchisee(franchiseeData))); }