Exemplo n.º 1
0
        public virtual ServiceResult Invoke(string featureId = "")
        {
            var result = new ServiceResult <List <DataCenterInfoOutput> >();

            try
            {
                bool   flag = DataCenterService.IsDeployAsPublicCloud(this.KDContext.Session.AppContext);
                string host = flag ? this.KDContext.WebContext.Context.Request.Url.Host : string.Empty;

                var infos = DataCenterService.GetDataCentersFromMC(string.Empty, Context.DataBaseCategory.Normal, string.Empty, host);
                if (!featureId.IsNullOrEmptyOrWhiteSpace() && infos.Any())
                {
                    var ctx = this.KDContext.Session.AppContext;
                    ctx = ctx.CreateAdministratorFromCache(infos.First().Id);
                    FeatureVerifier.CheckFeature(ctx, featureId);
                }//end if

                result.Code    = (int)ResultCode.Success;
                result.Message = ResultCode.Success.ToString();
                result.Data    = infos.Select(db => new DataCenterInfoOutput
                {
                    Id     = db.Id,
                    Number = db.Number,
                    Name   = db.Name
                }).ToList();
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }
            return(result);
        } //end method
Exemplo n.º 2
0
        public ServiceResult Invoke(string featureId = "")
        {
            var result = new ServiceResult <bool>();

            try
            {
                var ctx = this.KDContext.Session.AppContext;
                if (!featureId.IsNullOrEmptyOrWhiteSpace() && ctx != null)
                {
                    FeatureVerifier.CheckFeature(ctx, featureId);
                }//end if

                result.Code    = (int)ResultCode.Success;
                result.Message = (ctx != null).ToString();
                result.Data    = ctx != null;
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }

            return(result);
        } //end method