Beispiel #1
0
        /// <summary>
        /// The reason this is not in the constructor is solely for the purpose of exception handling.
        /// If you leave this in the controller and someone who is not authenticated calls the API you will not get a tenantId not found error.
        /// The error will be ugly and be hard to figure out you are not authorized.
        /// This way if the all methods have the ClaimsAuthorize attribute on them they will first be authenticated if not get a nice error message of not authorized.
        /// </summary>
        /// <exception cref="System.Exception">No Tenant Id Found.</exception>
        private void Setup()
        {
            //var isAllowed = ClaimsAuthorization.CheckAccess("Get", "CustomerId", "00");
            //isAllowed = true;
            //Get the current claims principal
            var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
            var tenant   = identity.Claims.Where(c => c.Type == ClaimsConstants.TenantIdClaimType).Select(c => c.Value).SingleOrDefault();

            if (string.IsNullOrEmpty(tenant))
            {
                throw new Exception("No Tenant Id Found.");
            }

            _tenantId    = Guid.Parse(tenant);
            _user        = identity.Identity.Name;
            _serviceName = DispatcherServiceFactory.RetrieveServiceName(_tenantId);

            _iProvisioningEngineService = ProvisioningEngineServiceFactory.Create(_tenantId);
            _iOrderService = OrderServiceFactory.Create(_tenantId);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var tenantId  = Guid.Parse(ConfigurationManager.AppSettings["tenantId"]);
            int companyId = int.Parse(ConfigurationManager.AppSettings["companyId"]);

            BootStrapper.Initialize();

            HostFactory.Run(x =>
            {
                x.RunAsLocalSystem();

                x.SetDescription(DispatcherServiceFactory.RetrieveServiceDisplayName(tenantId));
                x.SetDisplayName(DispatcherServiceFactory.RetrieveServiceDisplayName(tenantId));
                x.SetServiceName(DispatcherServiceFactory.RetrieveServiceName(tenantId));
                x.Service(factory =>
                {
                    return(DispatcherServiceFactory.Create(tenantId, companyId));
                });
            });

            System.Console.ReadLine();
        }
Beispiel #3
0
        public HttpResponseMessage RetrieveProvisioningEngineStatus(string externalCompanyId)
        {
            try
            {
                Setup();

                _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in " + _name), LogLevelType.Info);

                string serviceName = DispatcherServiceFactory.RetrieveServiceName(_tenantId);
                int    companyId   = _iOrderService.RetrieveCompanyIdByExtCompanyId(externalCompanyId);
                var    status      = _iProvisioningEngineService.RetrieveProvisioningEngineStatus(companyId, serviceName);

                return(this.Request.CreateResponse(HttpStatusCode.OK, status));
            }
            catch (Exception ex)
            {
                _logger.WriteLogEntry(_tenantId.ToString(), new List <object> {
                    ex.RetrieveEntityExceptionDataAsObjectList()
                },
                                      string.Format(MethodBase.GetCurrentMethod().Name + " in " + _name), LogLevelType.Error, ex.GetInnerMostException());
                throw;
            }
        }