public async Task <ServiceResultMessage> AddSecurePolicy(string userId, string id, SecurePolicyModel model) { try { var daoresult = await SecureDao.Add2Account(userId, new SecurePolicyEntity() { Id = id, Name = model.Name, AuthPlayUrl = model.AuthPlayUrl, AuthPublishUrl = model.AuthPublishUrl, AuthCloseUrl = model.AuthCloseUrl, AuthUnPublishUrl = model.AuthUnPublishUrl, AuthStopUrl = model.AuthStopUrl, AuthConnectUrl = model.AuthConnectUrl, AuthDvrUrl = model.AuthDvrUrl, NotifyHlsUrl = model.NotifyHlsUrl }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
//todo:UnFinish public async Task <ServiceResultMessage> UpdateSecurePolicy(string userId, string id, SecurePolicyModel model) { try { //todo:1.保存设置 2.上传水印图片 3.重新生成配置文件 4.上传配置文件 5.重启SRS服务 var daoresult = await SecureDao.UpdateSecurePolicyEntity(id, new SecurePolicyEntity() { Name = model?.Name, AuthPlayUrl = model?.AuthPlayUrl, AuthPublishUrl = model?.AuthPublishUrl, AuthCloseUrl = model.AuthCloseUrl, AuthUnPublishUrl = model.AuthUnPublishUrl, AuthStopUrl = model.AuthStopUrl, AuthConnectUrl = model.AuthConnectUrl, AuthDvrUrl = model.AuthDvrUrl, NotifyHlsUrl = model.NotifyHlsUrl }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async Task <ServiceResultMessage> UpdateServerNode(string userId, string id, ServerNodeModel model) { try { var Option = new LiveServiceConfig { Host = model.Ip, HostUrl = model.Url, SshPort = model.SshPort, UserName = model.UserName, Password = model.Password, ApiPort = model.ApiPort, HttpPort = model.HttpPort, RtmpPort = model.RtmpPort, }; //todo:1.保存设置 3.重新生成配置文件 4.上传配置文件 5.重启SRS服务 var daoresult = await ServerDao.UpdateServerEntity(id, new ServerEntity() { Name = model?.Name, Ip = model?.Ip, Url = model?.Url, UserName = model?.UserName, Password = model?.Password, Option = JsonConvert.SerializeObject(Option), }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public ServiceErrorResult(ServiceResultBase result) { ModelState = new ModelStateDictionary(); Notifications = new Dictionary <string, ICollection <string> >(); AddNotifications(result.Notifications); AddErrors(result.Errors); }
private static void AddErrors(ServiceResultBase result, IEnumerable <ValidationFailure> errors) { foreach (var error in errors) { result.AddNotification(NotificationType.Error, error.ErrorMessage); } }
private static void ServiceLayerUsage() { // has error var result = ServiceResultBase.Error("Some error message"); if (result.IsError) { Console.WriteLine(result.ErrorMessage); } // no error Console.WriteLine(ServiceResultBase.Success); }
public async Task <ServiceResultMessage> RemoveAsync(string userId, string id) { try { var daoresult = await ServerDao.DeleteServerEntity(id); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async Task <ServiceResultMessage> RemoveAsync(string userId, string id) { try { //todo:1.保存设置 3.重新生成配置文件 4.上传配置文件 5.重启SRS服务 var daoresult = await RecordDao.DeleteRecordTemplateEntity(id); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async Task <ServiceResultMessage> RemoveAsync(string userId, string id) { try { //todo:1.保存设置 2.删除水印图片 3.重新生成配置文件 4.上传配置文件 5.重启SRS服务 var daoresult = await DomainDao.DeleteDomainById(id); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
//todo:UnFinish public async Task <ServiceResultMessage> UpdateLogeTemplate(string userId, string id, TranscodeTemplateModel model) { try { //todo:1.保存设置 3.重新生成配置文件 4.上传配置文件 5.重启SRS服务 var daoresult = await TranscodeDao.UpdateTranscodeTemplateEntity(id, new TranscodeTemplateEntity() { Name = model?.Name, AppName = model?.AppName, AudioOption = JsonConvert.SerializeObject(model?.AudioOption), VideoOption = JsonConvert.SerializeObject(model?.AudioOption) }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async Task <ServiceResultMessage> AddLogeTemplate(string userId, string id, TranscodeTemplateModel model) { try { var daoresult = await TranscodeDao.Add2Account(userId, new TranscodeTemplateEntity() { Id = id, Name = model?.Name, AppName = model?.AppName, AudioOption = JsonConvert.SerializeObject(model?.AudioOption), VideoOption = JsonConvert.SerializeObject(model?.AudioOption) }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async Task <ServiceResultMessage> AddLogeTemplate(string userId, string id, RecordTemplateModel model) { try { var daoresult = await RecordDao.Add2Account(userId, new RecordTemplateEntity() { Id = id, Name = model?.Name, Description = model?.Description, NamePolicy = model?.NamePolicy, UploadUrl = model?.UploadUrl, }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
//todo:UnFinish public async Task <ServiceResultMessage> UpdateLogeTemplate(string userId, string id, RecordTemplateModel model) { try { //todo:1.保存设置 3.重新生成配置文件 4.上传配置文件 5.重启SRS服务 var daoresult = await RecordDao.UpdateRecordTemplateEntity(id, new RecordTemplateEntity() { Name = model?.Name, Description = model?.Description, NamePolicy = model?.NamePolicy, UploadUrl = model?.UploadUrl, }); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async Task <ServiceResultMessage> CreateLiveRoom(string userId, BoardCastRoomModel model) { if (model == null) { return new ServiceResultMessage() { code = ServiceResultCode.UnDefineError, Message = "传入对象为空,请检查参数.." } } ; try { // var domain = DomainDao.GetDomainCount(userId);//通过Domain 确定是否存在DomainNode var entity = new BoardCastRoomEntity() { Id = model.Id, Domain = model.Domain, Name = model.Name, AppName = string.IsNullOrEmpty(model.AppName) ? "live" : model.AppName, ExpireTime = model.ExpireTime.Equals(new DateTime()) ? DateTime.Now.AddDays(2) : model.ExpireTime, PlayEndNotifyUrl = model.PlayEndUrl, PlayNotifyUrl = model.PlayNotifyUrl, PublishEndNotifyUrl = model.PublishEndUrl, PublishNotifyUrl = model.PublishNotifyUrl, StreamName = model.StreamName.ToLower(), State = 1, }; DaoResultMessage daoresult = await BoardcastRoomDao.CreateRoom(entity); return((ServiceResultMessage)ServiceResultBase.DaoResult2ServiceResult(daoresult)); } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public async void CheckEndpointCommand_Execute() { if (String.IsNullOrEmpty(WebsiteOrEndpointUrl)) { return; } StatusText = ""; Uri uri; try { uri = new Uri(WebsiteOrEndpointUrl); } catch { // TODO make use of ErrorInfo return; } IsBusy = true; try { // ServiceResultBase sr = await _serviceDiscovery.DiscoverService(uri); if (sr == null) { return; } if (sr is ServiceResultErr) { // TODO ErrorInfo //(sr as ServiceResultErr).Err return; } if (sr is ServiceResultAtomFeed) { //(sr as ServiceResultAtomFeed).AtomFeedUrl } //ServiceResultAuthRequired //ServiceResultAtomPub //ServiceResultXmlRpc //ServiceResultAtomAPI //sr.EndpointUri /* * switch (sr.Service) * { * case ServiceTypes.AtomPub: * // * break; * case ServiceTypes.AtomPub_Hatena: * // * break; * case ServiceTypes.XmlRpc_WordPress: * // * break; * case ServiceTypes.XmlRpc_MovableType: * // * break; * case ServiceTypes.AtomApi: * // * break; * case ServiceTypes.AtomApi_GData: * // * break; * case ServiceTypes.Unknown: * // * break; * * } * */ } finally { IsBusy = false; } }
public async Task <ServiceResultMessage> RemoveAsync(string userId, string id) { ServiceResultMessage message = new ServiceResultMessage(); try { var daoResult = await LogoDao.DeleteLogoTemplate(id); if (daoResult.Code == DaoResultCode.Success) { var logo = daoResult.para as LogoTemplateEntity; if (logo != null && File.Exists(logo.FilePath)) { try { File.Delete(logo.FilePath); } catch (Exception e) { LogHelper.Error($"删除Logo文件失败: 路径:{logo.FilePath}"); } } var serverEntities = await ServerDao.GetServerEntitys(userId); foreach (ServerEntity entity in serverEntities) { try { var config = JsonConvert.DeserializeObject <LiveServiceConfig>(entity.Option); var liveService = new DjLiveService(config); liveService.RemoveLogoFile(id); } catch (Exception e) { message.ErrorId += (" " + LogHelper.ErrorWithId($"删除服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}", e)); message.Message += $"删除服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}"; } } var updateResult = await ServerNodeService.UpdateSrsConf(userId); message = updateResult; if (updateResult.code == ServiceResultCode.Warning) { message.code = ServiceResultCode.Success; } await ServerNodeService.UpdateSrsConf(userId); } else { message = ServiceResultBase.DaoResult2ServiceResult(daoResult); } return(message); } catch (Exception e) { message.code = ServiceResultCode.UnExceptError; message.Message = e.Message; message.ErrorId = LogHelper.ErrorWithId(e.Message, e); return(message); } }
public async Task <ServiceResultMessage> AddLogeTemplate(string userId, string id, LogoTemplateModel logoTemplateModel) { ServiceResultMessage message = new ServiceResultMessage(); try { string filePath = string.Concat(ConfigurationValue.TempLogoPath, $"{id}"); var options = JsonConvert.SerializeObject(new LogoOption() { Height = logoTemplateModel.Height, Width = logoTemplateModel.Width, }); var path = EncryptUtils.Base64SaveImg(logoTemplateModel.Base64String, filePath); if (path == null) { message.code = ServiceResultCode.ImageTranscodeError; message.Message = "base64转 图片失败."; return(message); } var daoresult = await LogoDao.Add2Account(userId, new LogoTemplateEntity() { Id = id, Name = logoTemplateModel.Name, Base64Vale = logoTemplateModel.Base64String, FilePath = path, Option = options, }); if (daoresult.Code == DaoResultCode.Success) { var serverEntities = await ServerDao.GetServerEntitys(userId); foreach (ServerEntity entity in serverEntities) { try { var config = JsonConvert.DeserializeObject <LiveServiceConfig>(entity.Option); var liveService = new DjLiveService(config); liveService.UploadLogoFile(id, path); } catch (Exception e) { message.ErrorId += (" " + LogHelper.ErrorWithId($"上传服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}", e)); message.Message += $"上传服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}"; } } await ServerNodeService.UpdateSrsConf(userId); return(message); } else { message = ServiceResultBase.DaoResult2ServiceResult(daoresult); } return(message); } catch (NullReferenceException e) { message.code = ServiceResultCode.SaveFileError; message.Message = e.Message; message.ErrorId = LogHelper.ErrorWithId(e.Message, e); return(message); } catch (Exception e) { message.code = ServiceResultCode.UnExceptError; message.Message = e.Message; message.ErrorId = LogHelper.ErrorWithId(e.Message, e); return(message); } }