public async Task SelectAudio(Audio audio) { string fileName = Path.GetFileName(audio.FileName); string folderName = Path.GetDirectoryName(audio.FileName); IFolder folder = await FileSystem.Current.GetFolderFromPathAsync(folderName); bool exist = await fileName.IsFileExistAsync(folder); if (exist == true) { IFile file = await folder.GetFileAsync(fileName); await CrossMediaManager.Current.Play(audio.FileName); } if (exist == false) { var audioFile = await FilesService.GetItemAsync(audio.Id); folder = FileSystem.Current.LocalStorage; IFile file = await folder.CreateFileAsync(audio.Id.ToString(), CreationCollisionOption.ReplaceExisting); var stream = await file.OpenAsync(FileAccess.ReadAndWrite); await stream.WriteAsync(audioFile.FileData, 0, audioFile.FileData.Length); stream.Dispose(); } await AudiosRepository.UpdateItemAsync(audio); }
public AudiosViewModel() { Title = "Audios"; Audios = new ObservableCollection <Audio>(); LoadAudiosCommand = new Command(async() => await ExecuteLoadAudiosCommand()); MessagingCenter.Subscribe <NewAudioPage>(this, "AddAudio", async(obj) => { try { IsBusy = true; var audio = AudioTagHelper.Read(obj.PickedFile.FilePath, obj.PickedFile.DataArray); var isAudioAdded = await AudiosRepository.AddItemAsync(audio); if (isAudioAdded) { Audios.Add(audio); var audioFile = new AudioFile(audio.Id, obj.PickedFile.DataArray); var isFileAdded = await FilesService.AddItemAsync(audioFile); } } catch (Exception ex) { } finally { IsBusy = false; } }); }
public async Task <ActionResult <ActionResult <List <string> > > > AddFile(IFormFile[] file) { try { List <string> urls = null; if (file[0] == null) { return(NotFound(("Bad Request"))); } else { foreach (var item in file) { if (urls == null) { urls = new List <string>(); } FilesService service = new FilesService(); string url = await service.UploadFile(item); urls.Add(url); } return(Ok(urls)); } } catch (Exception ex) { return(StatusCode(500, ex.Message.ToString())); } }
public ProjectsController(ProjectsService projectsService, FilesService filesService, UsersService usersService, UserManager <ApplicationUser> userManager) { _userManager = userManager; _projectsService = projectsService; _filesService = filesService; _usersService = usersService; }
protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { var fileName = FilesService.getFullFilePath("request", "request"); using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { Byte[] address = new UTF8Encoding(true).GetBytes(JsonConvert.SerializeObject(request.RequestUri)); await fs.WriteAsync(address, 0, address.Length, cancellationToken); byte[] newline = Encoding.ASCII.GetBytes(Environment.NewLine); fs.Write(newline, 0, newline.Length); fs.Write(newline, 0, newline.Length); foreach (var httpRequestHeader in request.Headers) { Byte[] headers = new UTF8Encoding(true).GetBytes(JsonConvert.SerializeObject(httpRequestHeader)); await fs.WriteAsync(headers, 0, headers.Length, cancellationToken); fs.Write(newline, 0, newline.Length); } fs.Write(newline, 0, newline.Length); fs.Write(newline, 0, newline.Length); Byte[] content = await request.Content.ReadAsByteArrayAsync(); await fs.WriteAsync(content, 0, content.Length, cancellationToken); } return(await base.SendAsync(request, cancellationToken)); }
public ActionResult Create(string id, string nid) { if (string.IsNullOrEmpty(id)) { return(Content("<script>alert(\"参数错误\");location.href=\"/\"</script>", "text/html")); } Class ml = new Class(); if (CheckRoleService.instance().CheckRole_ClassID(new Guid(id), UserDateTicket.UID)) { ml = ClassService.instance().GetEnumByID(new Guid(id)).FirstOrDefault(); } else { return(Content("<script>alert(\"没有权限\")</script>", "text/html")); } News m = new News(); if (string.IsNullOrEmpty(nid)) { m = new News(); } else { m = NewsService.instance().GetEnumByID(new Guid(nid)).FirstOrDefault(); Files file = FilesService.instance().Single(new Guid(nid)); ViewBag.filepath = file == null ? "" : file.FilePath; } ViewBag.ClassID = id; return(View(m)); }
public AuthenticationController(SignInManager <BlogUserIdentity> signInManager, UserManager <BlogUserIdentity> userManager, MyContext myContext, FilesService fileservice) { _signInManager = signInManager; _userManager = userManager; _appContext = myContext; _filesService = fileservice; }
public FilesControllerTests() { //TODO NInject or some other resolvers. var fileServices = new EnvironmentBuilder("FileServicesClient:Username", "FileServicesClient:Password", "FileServicesClient:Url"); var lookupServices = new EnvironmentBuilder("LookupServicesClient:Username", "LookupServicesClient:Password", "LookupServicesClient:Url"); var locationServices = new EnvironmentBuilder("LocationServicesClient:Username", "LocationServicesClient:Password", "LocationServicesClient:Url"); var lookupServiceClient = new LookupCodeServicesClient(lookupServices.HttpClient); var locationServiceClient = new LocationServicesClient(locationServices.HttpClient); var fileServicesClient = new FileServicesClient(fileServices.HttpClient); _fileServicesClient = fileServicesClient; var lookupService = new LookupService(lookupServices.Configuration, lookupServiceClient, new CachingService()); var locationService = new LocationService(locationServices.Configuration, locationServiceClient, new CachingService()); _agencyIdentifierId = fileServices.Configuration.GetNonEmptyValue("Request:AgencyIdentifierId"); _partId = fileServices.Configuration.GetNonEmptyValue("Request:PartId"); var claims = new[] { new Claim(CustomClaimTypes.JcParticipantId, _partId), new Claim(CustomClaimTypes.JcAgencyCode, _agencyIdentifierId), }; var identity = new ClaimsIdentity(claims, "Cookies"); var principal = new ClaimsPrincipal(identity); var filesService = new FilesService(fileServices.Configuration, fileServicesClient, new Mapper(), lookupService, locationService, new CachingService(), principal); //TODO fake this. var vcCivilFileAccessHandler = new VcCivilFileAccessHandler(new ScvDbContext()); _controller = new FilesController(fileServices.Configuration, fileServices.LogFactory.CreateLogger <FilesController>(), filesService, vcCivilFileAccessHandler); _controller.ControllerContext = HttpResponseTest.SetupMockControllerContext(fileServices.Configuration); }
public ChatService( IChatDataProvider chatDataProvider, IUsersRepository usersRepository, IUsersConversationsRepository usersConversationsRepository, IConversationRepository conversationRepository, ILastMessagesRepository lastMessagesRepository, IDhPublicKeysRepository dh, IChatRolesRepository rolesRepository, FilesService filesService, UnitOfWork unitOfWork, BansService bansService, MessagesService messagesService, IComparer <Shared.DTO.Conversations.Chat> chatComparer, IRolesRepository staticRolesRepo) { this.chatDataProvider = chatDataProvider; this.usersRepository = usersRepository; this.usersConversationsRepository = usersConversationsRepository; this.conversationRepository = conversationRepository; this.lastMessagesRepository = lastMessagesRepository; publicKeys = dh; this.rolesRepository = rolesRepository; this.filesService = filesService; this.unitOfWork = unitOfWork; this.bansService = bansService; this.messagesService = messagesService; this.chatComparer = chatComparer; this.staticRolesRepo = staticRolesRepo; }
public MediaObjectInfo NewMediaObject(String blogId, String userName, String password, MediaObject mediaObject) { using (var db = new DataService()) { if (!db.PublisherAccessAllowed(userName, password)) { return(new MediaObjectInfo()); } // Try to upload this file Uri uri = FilesService.Upload(mediaObject.Name, mediaObject.Bits); // Error if (uri == null) { return(new MediaObjectInfo()); } // Else return informations return(new MediaObjectInfo() { Id = mediaObject.Name, Name = mediaObject.Name, Type = mediaObject.Type, Url = uri.ToString() }); } }
public override void Context() { XmlService.ResetCalls(); FileSystem.ResetCalls(); HashProvider.ResetCalls(); Service = new FilesService(XmlService.Object, FileSystem.Object, HashProvider.Object); }
public InstructionsController(ApplicationDbContext context, UserManager <ApplicationUser> userManager, FilesService files, InformationService info) { _context = context; _userManager = userManager; _files = files; _info = info; }
public UserController(SignInManager <BlogUserIdentity> signinmanager, UserManager <BlogUserIdentity> usermanager, MyContext context, FilesService fileservice) { _signInManager = signinmanager; _userManager = usermanager; _appContext = context; _filesService = fileservice; }
public int Validate([FromUri] NewWebhookValidate hub) { //hub.verify_token = //03a5cde6-5717-4ec1-910e-ac5f15bbf068 FilesService.CreateFile("web_hook_validate", JsonConvert.SerializeObject(hub), "json"); return(hub.challenge); }
public FilesController(IConfiguration configuration, ILogger <FilesController> logger, FilesService filesService) { _configuration = configuration; _logger = logger; _filesService = filesService; _civilFilesService = filesService.Civil; _criminalFilesService = filesService.Criminal; }
public CourseController(CourseService courseService, ApplicationDbContext context, AccessService access, FilesService files, UserManager <ApplicationUser> userManager) { _context = context; _courseService = courseService; _access = access; _files = files; _userManager = userManager; }
public ActionResult Product(string id) { Product p = ProductService.instance().Single(new Guid(id)); ViewBag.files = FilesService.instance().GetFilesByRelationID(p.ID); ViewBag.cate_ids = ClassService.instance().Single(p.ClassID).cate_id; return(View(p)); }
public void FilesTest() { FilesService fs = new FilesService(@"x:\softedule"); int count = fs.ResourceFiles().Count(); Assert.AreEqual(1, count); }
public FilesController(FilesService filesService, IAuthorizationService authorizationService, IMapper mapper, ILogger <FilesController> logger) { _filesService = filesService; _authorizationService = authorizationService; _mapper = mapper; _logger = logger; }
public AlgoController(ProjectsRepository projectsRepository, ActivityRepository activityRepository, AlgoExecutionService algoExecutionService, FilesService filesService, IHttpContextAccessor accessor) { _projectsRepository = projectsRepository; _activityRepository = activityRepository; _algoExecutionService = algoExecutionService; _filesService = filesService; _accessor = accessor; }
public FilesController(IConfiguration configuration, ILogger <FilesController> logger, FilesService filesService, VcCivilFileAccessHandler vcCivilFileAccessHandler) { _configuration = configuration; _logger = logger; _filesService = filesService; _civilFilesService = filesService.Civil; _criminalFilesService = filesService.Criminal; _vcCivilFileAccessHandler = vcCivilFileAccessHandler; }
public HomeController(NotesService notesService, FilesService filesService, TagsService tagsService, IAuthorizationService authorizationService, ILogger <HomeController> logger) { _notesService = notesService; _filesService = filesService; _tagsService = tagsService; _authorizationService = authorizationService; _logger = logger; }
public JsonResult GetPicPage(int pageIndex, int pageSize, string wheres, string sortorder, string sortname) { int totalcount = 0; IEnumerable <Files> datalist = FilesService.instance().GetPageByDynamic(pageIndex, pageSize, out totalcount, sortname, sortorder, wheres); ResultBase_Page page = new ResultBase_Page(pageIndex, pageSize, totalcount); page.content = datalist.ToList(); return(Json(page, JsonRequestBehavior.AllowGet)); }
public static void Main(string[] args) { //log4net. string var1 = "sugaaaar"; var fs = new FilesService(); fs.Create(var1); Console.WriteLine($"Can you give me {var1}"); }
public SalesController() { db = new DbContext(); customersService = new CustomersService(db); filesService = new FilesService(db); reportsService = new ReportService(db); salesmansService = new SalesmansService(db); salesService = new SalesService(db); }
public StorageService( OSSApiService ossApiService, AppsContainer appsContainer, FilesService filesService) { _ossApiService = ossApiService; _appsContainer = appsContainer; _filesService = filesService; }
/// <summary> /// 获取RelationID的文件信息 /// </summary> /// <param name="RelationID">关联ID</param> /// <returns></returns> public HttpResponseMessage GetRelationFiles(string RelationID) { Guid ID; if (Guid.TryParse(RelationID, out ID)) { return(Util.Utils.ConvertToJson(FilesService.instance().GetFilesByRelationID(ID))); } return(null); }
public FilesController( FilesService filesService, IHubContext <FilesHub> hubContext) { this._filesService = filesService; this._hubContext = hubContext; this._filesService.FileParsingFailed += OnFileParsingFailedAsync; ur = new UserRepository(Settings.GetStringDB()); }
public ResourceFileViewModel(FilesService filesService) { this.filesService = filesService; files = new ObservableCollection <ResourceFile>(filesService.ResourceFiles()); if (files.Count > 0) { selectedFile = files.First(); } }
/// <summary> /// 根据ID获取详细信息 /// </summary> /// <param name="id">ID</param> /// <returns></returns> public HttpResponseMessage Get(string id) { Guid ID; if (Guid.TryParse(id, out ID)) { return(Util.Utils.ConvertToJson(FilesService.instance().Single(ID))); } return(null); }
public async Task <IActionResult> CheckFileInfo(string id, [FromQuery] string access_token) { try { Config.logger.LogDebug("CheckFileInfo: id=" + id); if (string.IsNullOrEmpty(access_token)) { Config.logger.LogError("status:500 accessToken is null"); return(StatusCode(500)); } Dictionary <string, Object> token = AccessTokenVerifier.DecodeJWT(access_token); Dictionary <string, string> user = (Dictionary <string, string>)token["user"]; Dictionary <string, string> metadata = (Dictionary <string, string>)token["metadata"]; if (!AccessTokenVerifier.VerifyAccessToken(id, (string)metadata["id"], (string)token["created"])) { Config.logger.LogError("status:500 accessToken is illegal"); return(StatusCode(500)); //access token is illegal } var sessionContext = Request.Headers["X-WOPI-SessionContext"]; string idToDownload = id; string fileName = Config.Folder + "/" + metadata["id"] + "." + metadata["type"]; Session editSession = Session.GetSessionFromRedis(id); if (editSession == null) { FilesService.DownloadFileFromDrive(idToDownload, fileName, user["authorization"]); editSession = new Session(id, fileName); editSession.SaveToRedis(); editSession.AddSessionToSetInRedis(); Config.logger.LogDebug("New session added to Redis for id=" + id); } if (!editSession.UserIsInSession(user["id"])) { Config.logger.LogDebug("add new user to session"); editSession.AddUser(user["id"], user["authorization"], user["permission"], user["name"]); editSession.SaveToRedis(); Config.logger.LogDebug("Added user {0} to session {1}", user["id"], id); } CheckFileInfo checkFileInfo = editSession.GetCheckFileInfo(user["id"], user["name"], metadata["name"]); return(Ok(checkFileInfo)); } catch (Exception ex) { if (ex is DriveFileNotFoundException) { Config.logger.LogError("status:404 CheckFileInfo Drive Error" + ex.Message); return(StatusCode(404)); } else { Config.logger.LogError("status:500, CheckFileInfo Error:" + ex.Message); return(StatusCode(500)); } } }
public override void TestInit() { this.user = new TestUser(); this.FilesService = new FilesService(); }
public FilesController(IIdentityService identityService, FilesService fileService) { Console.WriteLine("filesController ctor"); this.identityService = identityService; this.filesService = fileService; }