Esempio 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
Esempio n. 2
0
        }//end constructor

        /// <summary>
        /// 获取业务数据中心。
        /// </summary>
        /// <returns>返回服务端结果。</returns>
        public virtual ServiceResult <List <object> > GetDataCenterList()
        {
            var result = new ServiceResult <List <object> >();

            try
            {
                var infos = DataCenterService.GetDataCentersFromMC(string.Empty, Context.DataBaseCategory.Normal);

                result.Code    = (int)ResultCode.Success;
                result.Message = string.Format("成功返回{0}个数据中心!", infos.Count);
                result.Data    = infos.Select(db => new
                {
                    Id     = db.Id,
                    Number = db.Number,
                    Name   = db.Name
                }).Cast <object>().ToList();
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Fail;
                result.Message = ex.Message;
            }
            return(result);
        } //end method