Example #1
0
        public BaseModel <string> AddDoamin(DomainDto dto, UserDto owner)
        {
            BaseModel <string> result = new BaseModel <string>();

            if (dto == null || String.IsNullOrWhiteSpace(dto.DomainName))
            {
                return(result.Failed("参数错误,域名不能为空!"));
            }

            dto.DomainName = dto.DomainName.Trim();
            if (DataBaseCache.Domains.Where(p => p.DomainName == dto.DomainName && p.State != 400).Any())
            {
                return(result.Failed("添加失败,已存在相同域名!"));
            }
            dto.Id       = Tools.NewID;
            dto.CreateBy = owner.Id;
            dto.CreateTs = DateTime.Now;
            dto.UpdateBy = owner.Id;
            dto.UpdateTs = DateTime.Now;

            var dbModel = mapper.Map <TbDomain>(dto);

            dbContext.Domains.Add(dbModel);
            var flag = dbContext.SaveChanges() > 0 ? true : false;

            if (flag)
            {
                DataBaseCache.Domains.Add(dbModel);
            }
            return(result.Success("添加成功!"));
        }
Example #2
0
        /// <summary>
        /// Create a domain asynchronously
        /// </summary>
        /// <param name="content">Content to create domain</param>
        /// <returns>an error code and the json response</returns>
        public async Task <ApiResponse> CreateAsync(DomainDto domain)
        {
            StringContent content = new StringContent(JsonConvert.SerializeObject(domain), Encoding.Default, "application/json");
            string        request = "domains";

            return(await RequestPostAsync(request, content));
        }
Example #3
0
    private IDomain ConvertFromDto(DomainDto dto)
    {
        var     factory = new DomainModelFactory();
        IDomain entity  = factory.BuildEntity(dto);

        return(entity);
    }
Example #4
0
        /// <summary>
        /// Create domain
        /// </summary>
        /// <param name="domain">The data of the domain</param>>
        /// <returns>an error code and the json response</returns>
        public DomainCreateResponse Create(DomainDto domain)
        {
            Task <DomainCreateResponse> task = Task.Run(async() => await CreateAsync(domain));

            task.Wait();
            return(task.Result);
        }
        public LinearFunctionParametersDto Convert(LineParametersDto lineSegment)
        {
            ExceptionHelper.CheckArgumentNull(lineSegment, "lineSegment");

            SampleDto sample1 = lineSegment.FirstSample;
            SampleDto sample2 = lineSegment.SecondSample;

            double slope             = (sample2.Value - sample1.Value) / (sample2.Concentration - sample1.Concentration);
            double verticalIntercept = sample1.Value - (slope * sample1.Concentration);
            double minValue;

            if (lineSegment.LeftBounded)
            {
                minValue = this.GetMinOf(sample1.Concentration, sample2.Concentration);
            }
            else
            {
                minValue = double.MinValue;
            }
            double maxValue;

            if (lineSegment.RightBounded)
            {
                maxValue = this.GetMaxOf(sample1.Concentration, sample2.Concentration);
            }
            else
            {
                maxValue = double.MaxValue;
            }
            DomainDto domain = new DomainDto(minValue, maxValue);

            return(new LinearFunctionParametersDto(slope, verticalIntercept, domain));
        }
        public static Dictionary <FacilityDto, List <DomainDto> > LoadAllFacilityDomains()
        {
            Dictionary <FacilityDto, List <DomainDto> > facilityDomains = new Dictionary <FacilityDto, List <DomainDto> >();

            using (ScidynContext ctx = new ScidynContext())
            {
                List <DomainFacility> domainFacilities = ctx.DomainFacilities.Include("Domain").Include("Facility").ToList();

                // Convert list of domains and the facilities they belong to into
                // a list of facilities and what domains contain them.
                foreach (DomainFacility domainFacility in domainFacilities)
                {
                    DomainDto domainDto = domainFacility.Domain.ConvertToDto();

                    FacilityDto key = facilityDomains.Keys.FirstOrDefault(k => k.SiteId == domainFacility.Facility.SiteId);

                    if (key == null)
                    {
                        facilityDomains.Add(domainFacility.Facility.ConvertToDto(), new List <DomainDto> {
                            domainDto
                        });
                    }
                    else
                    {
                        facilityDomains[key].Add(domainDto);
                    }
                }
            }

            return(facilityDomains);
        }
Example #7
0
            public DomainDto BuildDto(IDomain entity)
            {
                var dto = new DomainDto {
                    DefaultLanguage = entity.LanguageId, DomainName = entity.DomainName, Id = entity.Id, RootStructureId = entity.RootContentId
                };

                return(dto);
            }
Example #8
0
 /// <summary>
 /// 转换为域名实体
 /// </summary>
 /// <param name="dto">域名数据传输对象</param>
 public static Domain ToEntity(this DomainDto dto)
 {
     if (dto == null)
     {
         return(new Domain());
     }
     return(dto.MapTo(new Domain(dto.Id.ToGuid())));
 }
        /// <summary>
        /// Create a domain asynchronously
        /// </summary>
        /// <param name="domain">Content to create domain</param>
        /// <returns>an error code and the json response</returns>
        public async Task <DomainCreateResponse> CreateAsync(DomainDto domain)
        {
            ApiResponse resp = await _client.CreateAsync(domain);

            DomainCreateResponse retour = new DomainCreateResponse();

            retour.Load(resp);
            return(retour);
        }
 public PlayStreamProxyDto(String zlServerIp, StreamProxyDto streamProxy, DomainDto domain, ApplicationDto application) : this(zlServerIp)
 {
     this.StreamProxy = streamProxy;
     this.Domain      = domain;
     this.Application = application;
     vHost            = domain.DomainName;
     if (GloableCache.ZLMediaServerConfig.ContainsKey("general.enableVhost") && GloableCache.ZLMediaServerConfig["general.enableVhost"] != "1")
     {
         vHost = "__defaultVhost__";
     }
 }
Example #11
0
    protected override void PersistNewItem(IDomain entity)
    {
        var exists = Database.ExecuteScalar <int>(
            "SELECT COUNT(*) FROM umbracoDomain WHERE domainName = @domainName",
            new { domainName = entity.DomainName });

        if (exists > 0)
        {
            throw new DuplicateNameException(
                      string.Format("The domain name {0} is already assigned", entity.DomainName));
        }

        if (entity.RootContentId.HasValue)
        {
            var contentExists = Database.ExecuteScalar <int>(
                $"SELECT COUNT(*) FROM {Constants.DatabaseSchema.Tables.Content} WHERE nodeId = @id",
                new { id = entity.RootContentId.Value });
            if (contentExists == 0)
            {
                throw new NullReferenceException("No content exists with id " + entity.RootContentId.Value);
            }
        }

        if (entity.LanguageId.HasValue)
        {
            var languageExists = Database.ExecuteScalar <int>(
                "SELECT COUNT(*) FROM umbracoLanguage WHERE id = @id",
                new { id = entity.LanguageId.Value });
            if (languageExists == 0)
            {
                throw new NullReferenceException("No language exists with id " + entity.LanguageId.Value);
            }
        }

        entity.AddingEntity();

        var       factory = new DomainModelFactory();
        DomainDto dto     = factory.BuildDto(entity);

        var id = Convert.ToInt32(Database.Insert(dto));

        entity.Id = id;

        // if the language changed, we need to resolve the ISO code!
        if (entity.LanguageId.HasValue)
        {
            ((UmbracoDomain)entity).LanguageIsoCode = Database.ExecuteScalar <string>(
                "SELECT languageISOCode FROM umbracoLanguage WHERE id=@langId", new { langId = entity.LanguageId });
        }

        entity.ResetDirtyProperties();
    }
Example #12
0
        public IDomain BuildEntity(DomainDto dto)
        {
            var domain = new UmbracoDomain(dto.DomainName, dto.IsoCode)
            {
                Id            = dto.Id,
                LanguageId    = dto.DefaultLanguage,
                RootContentId = dto.RootStructureId,
            };

            // reset dirty initial properties (U4-1946)
            domain.ResetDirtyProperties(false);
            return(domain);
        }
 public DomainModelResponse Add(DomainDto.Role request)
 {
     EntityModel.Role role = new EntityModel.Role()
     {
         RoleCode = request.roleCode,
         RoleDescription = request.roleDescription,
         LastChangedTime = DateTime.UtcNow
     };
     _repRole.Add(role);
     _uow.Commit();
     _roleResponse.addResponse("Add", MessageCodes.InfoCreatedSuccessfully, "Role");
     return _roleResponse;
 }
            public IDomain BuildEntity(DomainDto dto)
            {
                var domain = new UmbracoDomain(dto.DomainName, dto.IsoCode)
                {
                    Id            = dto.Id,
                    LanguageId    = dto.DefaultLanguage,
                    RootContentId = dto.RootStructureId
                };

                //on initial construction we don't want to have dirty properties tracked
                // http://issues.umbraco.org/issue/U4-1946
                domain.ResetDirtyProperties(false);
                return(domain);
            }
        private CloseStreamsResponse StopStreamProxy(StreamProxyDto dto, DomainDto domain = null, ApplicationDto application = null)
        {
            return(null);

            ConsoleHelper.Failed("开始断流:" + dto.StreamName);
            if (domain == null)
            {
                domain = GetDomain(dto.DomainId);
            }
            if (application == null)
            {
                application = GetApplication(dto.AppId);
            }
            return(Tools.ZLClient.closeStreams(null, domain.DomainName, application.App, dto.StreamName, true));
        }
 public DomainModelResponse Update(DomainDto.Role request)
 {
     EntityModel.Role role = _repRole.Get(filter: u => u.RoleCode == request.roleCode).FirstOrDefault();
     if (role == null)
     {
         _roleResponse.addResponse("Update", MessageCodes.ErrDoesnotExist, "role : " + request.roleCode);
         throw _roleResponse;
     }
     role.RoleDescription = request.roleDescription;
     role.LastChangedTime = DateTime.UtcNow;
     _repRole.Update(role);
     _uow.Commit();
     _roleResponse.addResponse("Update", MessageCodes.InfoSavedSuccessfully, "Role");
     return _roleResponse;
 }
Example #17
0
        public IFacadeUpdateResult <DomainData> SaveDomain(DomainDto dto)
        {
            UnitOfWork.BeginTransaction();
            IFacadeUpdateResult <DomainData> result = DomainSystem.SaveDomain(dto);

            if (result.IsSuccessful)
            {
                UnitOfWork.CommitTransaction();
            }
            else
            {
                UnitOfWork.RollbackTransaction();
            }
            return(result);
        }
        protected void ucIDetail_ChildListInstanceRowSaving(object sender, InstanceRowSavingEventArgs e)
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                DomainFacade facade = new DomainFacade(uow);

                switch ((InstanceTypes)Enum.Parse(typeof(InstanceTypes), e.InstanceType))
                {
                case InstanceTypes.DomainMainMenu:
                    DomainMainMenuDto itemDto = e.Instance as DomainMainMenuDto;
                    // Save data
                    IFacadeUpdateResult <DomainData> result1 = facade.SaveDomainMainMenu(CurrentInstance.Id, itemDto);
                    e.IsSuccessful = result1.IsSuccessful;
                    if (result1.IsSuccessful)
                    {
                        // Refresh
                        DomainDto savedParentInstance = result1.ToDto(new DomainConverter());
                        CurrentInstance.DomainMainMenus = savedParentInstance.DomainMainMenus;
                    }
                    else
                    {
                        // Deal with Update result
                        ProcUpdateResult(result1.ValidationResult, result1.Exception);
                    }
                    break;

                case InstanceTypes.DomainSetupMenu:
                    DomainSetupMenuDto itemDto2 = e.Instance as DomainSetupMenuDto;
                    // Save data
                    IFacadeUpdateResult <DomainData> result2 = facade.SaveDomainSetupMenu(CurrentInstance.Id, itemDto2);
                    e.IsSuccessful = result2.IsSuccessful;
                    if (result2.IsSuccessful)
                    {
                        // Refresh
                        DomainDto savedParentInstance = result2.ToDto(new DomainConverter());
                        CurrentInstance.DomainSetupMenus = savedParentInstance.DomainSetupMenus;
                    }
                    else
                    {
                        // Deal with Update result
                        ProcUpdateResult(result2.ValidationResult, result2.Exception);
                    }
                    break;
                }
            }
        }
        public BaseModel <string> EditDoamin(DomainDto dto, UserDto owner)
        {
            BaseModel <string> result = new BaseModel <string>();

            if (dto == null || String.IsNullOrWhiteSpace(dto.DomainName))
            {
                return(result.Failed("参数错误,域名不能为空!"));
            }

            dto.DomainName = dto.DomainName.Trim();
            var dbModel = dbContext.Domains.Where(p => p.Id == dto.Id).FirstOrDefault();

            if (dbModel == null)
            {
                return(result.Failed("参数错误,找不到该域名!"));
            }

            if (DataBaseCache.Domains.Where(p => p.DomainName == dto.DomainName && p.State != 400 && p.Id != dbModel.Id).Any())
            {
                return(result.Failed("域名冲突,已存在相同域名,修改失败!"));
            }
            else
            {
                dbModel.DomainName  = dto.DomainName;
                dbModel.Description = dto.Description;
                dbModel.State       = dto.State;
                dbModel.UpdateBy    = owner.Id;
                dbModel.UpdateTs    = DateTime.Now;
                var flag = dbContext.SaveChanges() > 0 ? true : false;
                if (flag)
                {
                    DataBaseCache.Domains.Remove(DataBaseCache.Domains.Where(p => p.Id == dto.Id).First());
                    DataBaseCache.Domains.Add(dbModel);
                    return(result.Success("修改成功!"));
                }
                else
                {
                    return(result.Failed("修改失败,数据无变化!"));
                }
            }
        }
Example #20
0
        internal IFacadeUpdateResult <DomainData> SaveDomain(DomainDto dto)
        {
            ArgumentValidator.IsNotNull("dto", dto);

            FacadeUpdateResult <DomainData> result = new FacadeUpdateResult <DomainData>();
            IDomainService service  = UnitOfWork.GetService <IDomainService>();
            Domain         instance = RetrieveOrNew <DomainData, Domain, IDomainService>(result.ValidationResult, dto.Id);

            if (result.IsSuccessful)
            {
                instance.Name = dto.Name;
                instance.RelatedSubjectIdField = dto.RelatedSubjectIdField;

                var saveQuery = service.Save(instance);

                result.AttachResult(instance.RetrieveData <DomainData>());
                result.Merge(saveQuery);
            }

            return(result);
        }
        public BaseModel <String> Add(DomainDto dto)
        {
            BaseModel <String> baseModel = new BaseModel <String>();

            try
            {
                if (mediaService.AddDomain(dto, UserInfo))
                {
                    baseModel.Success("保存成功!");
                }
                else
                {
                    baseModel.Failed("保存失败!");
                }
            }
            catch (Exception ex)
            {
                baseModel.Failed(ex.Message);
            }
            return(baseModel);
        }
Example #22
0
        protected void ucIList_InstanceRowSaving(object sender, InstanceRowSavingEventArgs e)
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CRMDataStoreKey))
            {
                DomainDto    instance = e.Instance as DomainDto;
                DomainFacade facade   = new DomainFacade(uow);
                IFacadeUpdateResult <DomainData> result = facade.SaveDomain(instance);
                e.IsSuccessful = result.IsSuccessful;

                if (result.IsSuccessful)
                {
                    // Refresh whole list
                    CurrentInstances = facade.RetrieveAllDomain();
                }
                else
                {
                    // Deal with Update result
                    ProcUpdateResult(result.ValidationResult, result.Exception);
                }
            }
        }
        public bool AddDomain(DomainDto domain, UserDto opera)
        {
            domain.Id       = Tools.NewID;
            domain.CreateBy = opera.Id;
            domain.CreateTs = DateTime.Now;
            domain.UpdateBy = opera.Id;
            domain.UpdateTs = domain.CreateTs;

            var dbModle = mapper.Map <TbDomain>(domain);

            dbContext.TbDomain.Add(dbModle);
            var flag = dbContext.SaveChanges() > 0 ? true : false;

            if (flag)
            {
                domain.CreateByNavigation = opera;
                domain.UpdateByNavigation = opera;
                RedisHelper.Instance.SetHash <DomainDto>(domain.Id.ToString(), domain);
            }
            return(flag);
        }
        public ZLResponse <BodyKey> AddStreamProxy(StreamProxyDto dto, DomainDto domain = null, ApplicationDto application = null)
        {
            if (domain == null)
            {
                domain = GetDomain(dto.DomainId);
            }
            if (application == null)
            {
                application = GetApplication(dto.AppId);
            }
            ConsoleHelper.Warning("开始拉流:" + dto.Name + ",域名[" + domain.DomainName + "],应用:[" + application.App + "],流[" + dto.StreamName + "]");

            var resp = Tools.ZLClient.addStreamProxy(
                domain.DomainName,
                application.App,
                dto.StreamName,
                dto.SourceUrl,
                dto.EnableRtsp,
                dto.EnableRtmp,
                dto.EnableHls,
                dto.EnableMp4,
                (STRealVideo.Lib.RTPPullType)(int) dto.RtpType
                );

            if (resp.code != 0 || resp.data == null || String.IsNullOrWhiteSpace(resp.data.key))
            {
                dto.State = StreamProxyState.Forbid;
                //拉流失败
                EditStreamProxy(dto);
                ConsoleHelper.Failed("拉流失败:" + dto.Name + ",域名[" + domain.DomainName + "],应用:[" + application.App + "],流[" + dto.StreamName + "]");
            }
            else
            {
                ConsoleHelper.Success("拉流成功:" + dto.Name + ",域名[" + domain.DomainName + "],应用:[" + application.App + "],流[" + dto.StreamName + "]");
            }

            return(resp);
        }
        public bool EditDomain(DomainDto domain, UserDto opera)
        {
            var dbModle = dbContext.TbDomain.Include(p => p.CreateByNavigation).Where(predicate => predicate.Id == domain.Id).FirstOrDefault();

            if (dbModle == null)
            {
                return(false);
            }
            dbModle.DomainName = domain.DomainName;
            dbModle.Remark     = domain.Remark;
            dbModle.Status     = (int)domain.Status;
            dbModle.UpdateBy   = opera.Id;
            dbModle.UpdateTs   = DateTime.Now;
            var flag = dbContext.SaveChanges() > 0 ? true : false;

            if (flag)
            {
                var dto = mapper.Map <DomainDto>(dbModle);
                dto.UpdateByNavigation = opera;
                RedisHelper.Instance.SetHash <DomainDto>(domain.Id.ToString(), domain);
            }
            return(flag);
        }
 public BaseModel <String> EditDomain(DomainDto dto)
 {
     return(domainAndAppService.EditDoamin(dto, GetUserDto()));
 }
        public STRealVideo.Lib.ZLResponse <STRealVideo.Lib.Models.BodyKey> StartPullStreamProxy(StreamProxyDto streamProxy, DomainDto domain = null, ApplicationDto application = null)
        {
            STRealVideo.Lib.ZLResponse <STRealVideo.Lib.Models.BodyKey> result = new STRealVideo.Lib.ZLResponse <STRealVideo.Lib.Models.BodyKey>();
            if (!GloableCache.ZLServerOnline)
            {
                return(result.Failed("服务器不在线!"));
            }
            if (domain == null)
            {
                domain = DataBaseCache.Domains.Where(p => p.Id == streamProxy.DomainId).Select(p => mapper.Map <DomainDto>(p)).FirstOrDefault();
            }
            if (application == null)
            {
                application = DataBaseCache.Applications.Where(p => p.Id == streamProxy.ApplicationId).Select(p => mapper.Map <ApplicationDto>(p)).FirstOrDefault();
            }
            if (domain == null || application == null)
            {
                result.Failed("找不到域名或应用!");
            }
            if (domain.State != (int)BaseStatus.Normal)
            {
                result.Failed("域名未启用!");
            }
            if (application.State != (int)BaseStatus.Normal)
            {
                result.Failed("应用未启用!");
            }

            result = GloableCache.ZLClient.addStreamProxy(domain.DomainName, application.AppName, streamProxy.StreamId, streamProxy.PullStreamUrl, streamProxy.EnableHLS, streamProxy.EnableMP4, (STRealVideo.Lib.RTPPullType)((int)streamProxy.RtpType));
            return(result);
        }
        public IActionResult Edit(long id)
        {
            DomainDto dto = mediaService.GetDomain(id);

            return(View(dto));
        }
 private bool isConcentrationInDomain(double concentration, DomainDto domain)
 {
     return(concentration >= domain.MinValue && concentration <= domain.MaxValue);
 }