Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public int GetRequestCurrentId(FranchisseNameAndLicenseDto franchiseeData)
        {
            var franchisee = _franchiseeTenantRepository.FirstOrDefault(
                o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey);

            return(_packageHistoryRepository.GetCurrentRequestId(franchisee.Id));
        }
Exemplo n.º 3
0
        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
            }));
        }
Exemplo n.º 4
0
        public PackageHistoryDto GetPackageCurrentNoToken(FranchisseNameAndLicenseDto franchiseeData)
        {
            var franchisee = _franchiseeTenantRepository.FirstOrDefault(
                o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey);

            return(_packageHistoryRepository.GetPackageCurrent(franchisee.Id));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        public List <PackageHistoryDto> GetListPackageChange(FranchisseNameAndLicenseDto franchiseeData)
        {
            var franchisee = _franchiseeTenantRepository.FirstOrDefault(
                o => o.Name == franchiseeData.FranchiseeName && o.LicenseKey == franchiseeData.LicenseKey);

            return(_packageHistoryRepository.GetListPackageChange(franchisee.Id));
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        //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);
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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
            }));
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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
            }));
        }
Exemplo n.º 18
0
        //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);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
 public IHttpActionResult UpdateFranchiseeTenantLicenceExtentsion(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_franchiseeTenantService.UpdateFranchiseeTenantLicenceExtentsion(franchiseeData)));
 }
Exemplo n.º 21
0
 public IHttpActionResult GetRequestCurrentId(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_packageHistoryService.GetRequestCurrentId(franchiseeData)));
 }
Exemplo n.º 22
0
 public ActiveDateLicenseKeyDto GetActiveDateLicenseKey(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(_franchiseeTenantRepository.GetActiveDateLicenseKey(franchiseeData));
 }
Exemplo n.º 23
0
 public IHttpActionResult UpdateFranchiseeTenantCancelAccount(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_franchiseeTenantService.UpdateFranchiseeTenantCancelAccount(franchiseeData)));
 }
Exemplo n.º 24
0
        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;
            }
        }
Exemplo n.º 25
0
 public IHttpActionResult GetInfoFranchisee(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_franchiseeTenantService.GetInfoFranchisee(franchiseeData)));
 }
Exemplo n.º 26
0
 public IHttpActionResult CheckIsExpire(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_franchiseeTenantService.CheckFranchiseIsExpire(franchiseeData)));
 }
Exemplo n.º 27
0
 public FranchiseeTernantDto GetInfoFranchiseeNoToken(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(_franchiseeTenantRepository.GetInfoFranchisee(franchiseeData));
 }
Exemplo n.º 28
0
 public IHttpActionResult GetPackageCurrentNoToken(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_packageHistoryService.GetPackageCurrentNoToken(franchiseeData)));
 }
Exemplo n.º 29
0
 public ModuleForFranchiseeDto GetModuleForFranchisee(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(_franchiseeTenantRepository.GetModuleForFranchisee(franchiseeData));
 }
Exemplo n.º 30
0
 public IHttpActionResult GetRequest(FranchisseNameAndLicenseDto franchiseeData)
 {
     return(Ok(_franchiseeTenantService.GetModuleForFranchisee(franchiseeData)));
 }