public ActionResultVM GetToken(string AppId, string AppKey) { var vm = new ActionResultVM(); try { if (string.IsNullOrWhiteSpace(AppId) || string.IsNullOrWhiteSpace(AppKey)) { vm.Set(ARTag.lack); vm.Msg = "参数缺失"; } else { if (!(Core.CacheTo.Get(AppKey) is ActionResultVM cvm)) { vm = FileServerService.GetToken(AppId, AppKey); if (vm.Code == 200) { //Token缓存 Core.CacheTo.Set(AppKey, vm, GlobalTo.GetValue <int>("Safe:TokenCache"), false); } } else { vm = cvm; } }
public ActionResultVM GetAppList(int pageNumber = 1, int pageSize = 20, string password = "******") { var vm = new ActionResultVM(); try { if (GlobalTo.GetValue <bool>("Safe:IsDev")) { if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:CreateAppPassword")) { vm.Set(ARTag.unauthorized); vm.Msg = "密码错误"; } else { vm = FileServerService.GetAppList(pageNumber, pageSize); } } else { vm.Set(ARTag.refuse); } } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
public ActionResultVM CreateApp(string password) { var vm = new ActionResultVM(); try { if (GlobalTo.GetValue <bool>("Safe:IsDev")) { if (!string.IsNullOrWhiteSpace(password) && password == GlobalTo.GetValue("Safe:CreateAppPassword")) { vm = FileServerService.CreateApp(); } else { vm.Set(ARTag.unauthorized); vm.Msg = "密码错误"; } } else { vm.Set(ARTag.refuse); } } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
public IActionResult RemoverFoto(Foto foto) { foto = _fotoService.Buscar(foto.Id); _fotoService.Deletar(foto.Id); FileServerService.DeleteFile(InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, foto.FotoUrl.Substring(62).Split("_")[0].ToString()); _session.SetString("Alertas", "Muito bem!!!|Você acabou de excluir uma foto!"); return(RedirectToAction("Index")); }
public IActionResult RemoverFoto(Foto foto) { var token = _apiIdentificacao.Login(_session.GetString("username"), _session.GetString("password")).Result; foto = _apiCoreFoto.BuscarFoto(foto.Id, token).Result; _apiCoreFoto.Deletar(foto, token); FileServerService.DeleteFile(InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, foto.FotoUrl.Substring(62).Split("_")[0].ToString()); _session.SetString("Alertas", "Muito bem!!!|Você acabou de excluir uma foto!"); return(RedirectToAction("Index")); }
public CustomerService(IBusControl bus, IConfiguration configuration) { _bus = bus; _fileServerService = new FileServerService(configuration.GetValue <string>("FileServerUrl")); _customers = new Dictionary <Guid, CustomerModel>() { { new Guid("ceb58785-56f6-4ef6-8591-577eb00b42d5"), new CustomerModel() { Id = new Guid("ceb58785-56f6-4ef6-8591-577eb00b42d5"), Name = "Otávio Juliano Nielsen Silva", } } }; }
public Server(ServerSettings settings) { this.fileServerMetaStorage = new FileServerMetaStorage(); this.fileServerService = new FileServerService(new FileServerServiceSettings() { ListenIP = settings.FileServerServiceIP, Port = settings.FileServerServicePort, FileServerMetaStorage = this.fileServerMetaStorage }); this.clientService = new ClientService(new ClientServiceSettings() { IP = settings.FileClientServiceIP, Port = settings.FileClientServicePort, FileServerMetaStorage = this.fileServerMetaStorage }); }
public ActionResultVM GetAppInfo(string AppId, string AppKey) { var vm = new ActionResultVM(); try { vm = FileServerService.GetAppInfo(AppId, AppKey); } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
public ActionResultVM CreateApp(string owner, string password = "******") { var vm = new ActionResultVM(); try { if (GlobalTo.GetValue <bool>("Safe:IsDev")) { if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:CreateAppPassword")) { vm.Set(ARTag.unauthorized); vm.Msg = "密码错误"; } else if (string.IsNullOrWhiteSpace(owner)) { vm.Set(ARTag.refuse); vm.Msg = "owner 不能为空"; } else if (new Regex(@"\W").Match(owner).Success) { vm.Msg = "owner 仅为字母、数字"; } else { vm = FileServerService.CreateApp(owner); if (vm.Code == -1 && vm.Msg.Contains("UNIQUE")) { vm.Set(ARTag.exist); vm.Msg = "owner 用户已经存在"; } } } else { vm.Set(ARTag.refuse); } } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
/// <summary> /// Starts the server. /// </summary> public void Start() { Uri baseAddress = new Uri("http://localhost:" + this.serverPort); FileServerService service = new FileServerService(); WebHttpBinding httpBinding = new WebHttpBinding(); httpBinding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly; httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; this.host = new WebServiceHost(service, baseAddress); this.host.AddServiceEndpoint(typeof(IFileServerService), httpBinding, baseAddress); this.host.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new UserCustomAuthentication(this.username, this.password); this.host.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom; ((FileServerService)this.host.SingletonInstance).Initialize(this.serverPhysicalPath, this.serverVirtualPath); this.host.Open(); }
//public IActionResult IndexSelect() //{ // var albuns = _albumService.BuscarTodosDoCliente(_session.Get<Cliente>("cliente")); // ViewBag.FotosPreSelecionadas = _session.Get<List<Foto>>("FotosPreSelecionadas"); // ViewBag.FotosSelecionadas = _session.Get<List<Foto>>("FotosSelecionadas"); // if (ViewBag.FotosPreSelecionadas == null) // { // List<Foto> fotos = new List<Foto>(); // foreach (var album in albuns) // { // fotos.AddRange(_fotoService.ReadAllPreselect(album)); // } // ViewBag.FotosPreSelecionadas = fotos; // } // if (ViewBag.FotosSelecionadas == null) // { // List<Foto> fotos = new List<Foto>(); // foreach (var album in albuns) // { // fotos.AddRange(_fotoService.ReadAllSelect(album)); // } // ViewBag.FotosSelecionadas = fotos; // } // _session.Set<List<Foto>>("FotosPreSelecionadas", (List<Foto>)ViewBag.FotosPreSelecionadas); // _session.Set<List<Foto>>("FotosSelecionadas", (List<Foto>)ViewBag.FotosSelecionadas); // return View(); //} //public IActionResult SelectFoto(Guid select) //{ // ViewBag.FotosPreSelecionadas = _session.Get<List<Foto>>("FotosPreSelecionadas"); // ViewBag.FotosSelecionadas = _session.Get<List<Foto>>("FotosSelecionadas"); // List<Foto> fotosPreSelecionadas = ViewBag.FotosPreSelecionadas; // List<Foto> fotosSelecionadas = ViewBag.FotosSelecionadas; // foreach (var foto in fotosPreSelecionadas) // { // if(foto.Id == select) // { // foto.Situacao = 1; // fotosSelecionadas.Add(foto); // } // } // foreach (var foto in fotosSelecionadas) // { // fotosPreSelecionadas.Remove(foto); // } // ViewBag.FotosPreSelecionadas= fotosPreSelecionadas; // ViewBag.FotosSelecionadas= fotosSelecionadas; // _session.Set<List<Foto>>("FotosPreSelecionadas", (List<Foto>)ViewBag.FotosPreSelecionadas); // _session.Set<List<Foto>>("FotosSelecionadas", (List<Foto>)ViewBag.FotosSelecionadas); // return View("IndexSelect"); //} //public IActionResult UnSelectFoto(Guid select) //{ // ViewBag.FotosPreSelecionadas = _session.Get<List<Foto>>("FotosPreSelecionadas"); // ViewBag.FotosSelecionadas = _session.Get<List<Foto>>("FotosSelecionadas"); // List<Foto> fotosPreSelecionadas = ViewBag.FotosPreSelecionadas; // List<Foto> fotosSelecionadas = ViewBag.FotosSelecionadas; // foreach (var foto in fotosSelecionadas) // { // if (foto.Id == select) // { // foto.Situacao = 0; // fotosPreSelecionadas.Add(foto); // } // } // foreach (var foto in fotosPreSelecionadas) // { // fotosSelecionadas.Remove(foto); // } // ViewBag.FotosPreSelecionadas = fotosPreSelecionadas; // ViewBag.FotosSelecionadas = fotosSelecionadas; // _session.Set<List<Foto>>("FotosPreSelecionadas", (List<Foto>)ViewBag.FotosPreSelecionadas); // _session.Set<List<Foto>>("FotosSelecionadas", (List<Foto>)ViewBag.FotosSelecionadas); // return View("IndexSelect"); //} //public IActionResult CadastrarSelecaoFotos() //{ // ViewBag.FotosPreSelecionadas = _session.Get<List<Foto>>("FotosPreSelecionadas"); // ViewBag.FotosSelecionadas = _session.Get<List<Foto>>("FotosSelecionadas"); // List<Foto> fotosPreSelecionadas = ViewBag.FotosPreSelecionadas; // List<Foto> fotosSelecionadas = ViewBag.FotosSelecionadas; // foreach (var foto in fotosSelecionadas) // { // _fotoService.AtualizarSituacao(foto); // } // foreach (var foto in fotosPreSelecionadas) // { // _fotoService.AtualizarSituacao(foto); // } // _session.Set<List<Foto>>("FotosPreSelecionadas", null); // _session.Set<List<Foto>>("FotosSelecionadas", null); // _session.SetString("Alertas", "Parabéns!!!| Você acabou de cadastrar a seleção de fotos do seu album."); // return RedirectToAction("SistemaCliente","Default"); //} public async Task <IActionResult> CadastrarNovo(Foto foto, IFormFile imagem) { byte[] miniImagemByte; byte[] imagemByte; using (var memoryStream = new MemoryStream()) { await imagem.CopyToAsync(memoryStream); miniImagemByte = EditorDeImagem.DrawSize(memoryStream.ToArray(), 256); imagemByte = EditorDeImagem.AddWaterMark(memoryStream.ToArray()); } var token = _apiIdentificacao.Login(_session.GetString("username"), _session.GetString("password")).Result; foto.FotoUrl = FileServerService.UploadFile("_Foto", new MemoryStream(imagemByte), BrunaPhotographSystem.InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, imagem.ContentType, foto.Album.Id.ToString()); foto.MiniFotoUrl = FileServerService.UploadFile("_MiniFoto", new MemoryStream(miniImagemByte), BrunaPhotographSystem.InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, imagem.ContentType, foto.Album.Id.ToString()); _apiCoreFoto.Criar(foto, token); _session.SetString("Alertas", "Muito bem!!!|Você acabou de cadastrar uma foto!"); return(RedirectToAction("Index")); }
public ActionResultVM GetAppList(int pageNumber = 1, int pageSize = 20) { var vm = new ActionResultVM(); try { if (GlobalTo.GetValue <bool>("Safe:IsDev")) { vm = FileServerService.GetAppList(pageNumber, pageSize); } else { vm.Set(ARTag.refuse); } } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
public ActionResultVM CreateApp(string password, string owner) { var vm = new ActionResultVM(); try { if (!Fast.ParsingTo.IsLinkPath(owner)) { vm.Msg = "owner 必填,仅为字母、数字"; } else if (owner.ToLower() == GlobalTo.GetValue("StaticResource:TmpDir").ToLower()) { vm.Msg = "owner 与临时目录冲突"; } else if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:AdminPassword")) { vm.Set(ARTag.unauthorized); vm.Msg = "密码错误或已关闭管理接口"; } else { vm = FileServerService.CreateApp(owner); if (vm.Code == -1 && vm.Msg.Contains("UNIQUE")) { vm.Set(ARTag.exist); vm.Msg = "owner 用户已经存在"; } } } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
public async Task <IActionResult> AdicionarFotoDropZone(Guid id) { byte[] miniImagemByte; foreach (var imagem in Request.Form.Files) { using (var memoryStream = new MemoryStream()) { await imagem.CopyToAsync(memoryStream); miniImagemByte = EditorDeImagem.DrawSize(memoryStream.ToArray(), 256); } Foto foto = new Foto(); foto.Id = Guid.NewGuid(); foto.Album.Id = id; foto.Descricao = String.Empty; foto.Nome = String.Empty; foto.FotoUrl = FileServerService.UploadFile("_Foto", imagem.OpenReadStream(), BrunaPhotographSystem.InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, imagem.ContentType, foto.Album.Id.ToString()); foto.MiniFotoUrl = FileServerService.UploadFile("_MiniFoto", new MemoryStream(miniImagemByte), BrunaPhotographSystem.InfraStructure.AzureStorage.Properties.Resources.AzureBlobContainer, imagem.ContentType, foto.Album.Id.ToString()); _fotoService.CriarComId(foto); } return(Ok()); }
public ActionResultVM GetAppList(string password, int pageNumber = 1, int pageSize = 20) { var vm = new ActionResultVM(); try { if (string.IsNullOrWhiteSpace(password) || password != GlobalTo.GetValue("Safe:AdminPassword")) { vm.Set(ARTag.unauthorized); vm.Msg = "密码错误或已关闭管理接口"; } else { vm = FileServerService.GetAppList(pageNumber, pageSize); } } catch (Exception ex) { vm.Set(ex); Core.ConsoleTo.Log(ex); } return(vm); }
public ResizeConsumer(IConfiguration configuration) { _fileServerService = new FileServerService(configuration.GetValue <string>("FileServerUrl")); }