public async void DeleteWorkTest( Status expectedStatus ) { var developer = EntitiesFactory.NewDeveloper().Save(); var project = EntitiesFactory.NewProject(developerIds: new[] { developer.Id }).Save(); var work = EntitiesFactory.NewWork(Guid.NewGuid(), project.DeveloperProjects.Single().Id).Get(); _workRepository.Setup(d => d.ExistAsync(work.Id)) .ReturnsAsync(expectedStatus != Status.NotFund); _workRepository.Setup(d => d.GetByIdAsync(work.Id)) .ReturnsAsync(work); _mockyRepository.Setup(m => m.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new Result <bool>(expectedStatus != Status.Error)); var service = new WorkService( _workRepository.Object, _developerRepository.Object, _projectRepository.Object, _mockyRepository.Object ); var result = await service.DeleteWorkAsync(work.Id); Assert.Equal(expectedStatus, result.Status); if (expectedStatus == Status.Success) { _workRepository.Verify(d => d.DeleteAsync(work), Times.Once); _mockyRepository.Verify(d => d.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>()), Times.Once); } }
public async Task ShouldChangeDataInContract() { var web3 = await CreateNewWeb3Instance(); var workService = new WorkService(web3, "0xdF597079182391EaFB478412F2352CfAfc7E29A3"); await workService.SetAttributeAsync(Account, WorkSchema.image, "QmY6CYcPbpmvz2R2v5Jfv5DLgTjyyN6HmWPKsBTnG2Ajv7", true, DefaultGas); }
private void setupRowActions() { // Define the context actions var deleteAction = new Xamarin.Forms.MenuItem { Text = "Delete", IsDestructive = true }; // red background deleteAction.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, new Binding("id")); deleteAction.Clicked += async(sender, e) => { var mi = ((Xamarin.Forms.MenuItem)sender); var recId = (int)mi.CommandParameter; TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); await Task.Factory.StartNew(async() => { // Call the webservice for vehicle makes list var deleteResult = await WorkService.delete(recId); if (!deleteResult.isOK) { Device.BeginInvokeOnMainThread(async() => { await App.AppMainWindow.DisplayAlert("Error", "Failed to delete the work record: " + deleteResult.error, "OK"); }); // Done with waiting tcs.SetResult(false); return; } // Done with waiting tcs.SetResult(true); }); // Wait for the delete operation to finish bool result = await tcs.Task; if (result) { var removedData = this.BindingContext as Record; if (removedData == null) { return; } // Acquire the list context WorkListView lvParent = (removedData.context as WorkListView); // Motify the list of changes lvParent.itemDeleted(removedData); } }; // add to the ViewCell's ContextActions property ContextActions.Add(deleteAction); }
public void Init() { _workService = new WorkService(); _workRepository = new WorkRepository(); _path = AppDomain.CurrentDomain.BaseDirectory + "\\resources\\work.csv"; }
public async Task ShouldUpdateWorkFileInContract(string address, string fileHash) { var web3 = await CreateNewWeb3Instance(); var workService = new WorkService(web3, address); await workService.SetAttributeAsync(Account, WorkSchema.audio, fileHash, true, DefaultGas); }
public DIPService() { WorkService workService = new WorkService(new Logger(), new Storage(), new Combiner()); workService.DoWork("ED"); workService.DoWork("Tarnya"); }
public PrivacyModel(ILogger <PrivacyModel> logger) { _logger = logger; IWorkService workService = new WorkService(); workService.addEmployee(5, 1); }
public MetaDataService(StatusService statusService, ExifService exifService, ConfigService config, ImageCache imageCache, WorkService workService) { _statusService = statusService; _configService = config; _exifService = exifService; _imageCache = imageCache; _workService = workService; }
public async Task ShouldDeployContractToMordenAsync() { var workService = new WorkService(new Web3(), "0xdF597079182391EaFB478412F2352CfAfc7E29A3"); await workService.SetAttributeAsync(Account, WorkSchema.name, "Hello", true, DefaultGas); await workService.SetAttributeAsync(Account, WorkSchema.audio, "MP3HASH", true, DefaultGas); await workService.SetAttributeAsync(Account, WorkSchema.image, "QmZTEAwF3f1oidQtZNKqM2VVK79xDdMNDnSDjC632AzZnU", true, DefaultGas); }
public ActionResult Details(int id) { var model = WorkService.GetInstance().GetWork(id); if (model == null) { return(RedirectToAction("Index")); } return(View("Details", model)); }
public ThumbnailService(StatusService statusService, ImageProcessService imageService, ImageCache imageCache, WorkService workService) { _statusService = statusService; _imageProcessingService = imageService; _imageCache = imageCache; _workService = workService; _workService.AddJobSource(this); }
/// <summary> /// Initializes a new instance of the <see cref="MusicBrainzClient"/> class. /// </summary> /// <param name="baseAddress">The base address of the webservice (default = <see cref="ServiceBaseAddress"/>).</param> /// <param name="proxy">The <see cref="IWebProxy"/> used to connect to the webservice.</param> public MusicBrainzClient(string baseAddress, IWebProxy proxy) { var urlBuilder = new UrlBuilder(true); Artists = new ArtistService(this, urlBuilder); Recordings = new RecordingService(this, urlBuilder); Releases = new ReleaseService(this, urlBuilder); ReleaseGroups = new ReleaseGroupService(this, urlBuilder); Work = new WorkService(this, urlBuilder); client = CreateHttpClient(new Uri(baseAddress), true, proxy); }
/// <summary> /// Initializes a new instance of the <see cref="MusicBrainzClient"/> class. /// </summary> /// <param name="httpClient">The <see cref="HttpClient"/> used for request to the webservice.</param> public MusicBrainzClient(HttpClient httpClient) { var urlBuilder = new UrlBuilder(true); Artists = new ArtistService(this, urlBuilder); Recordings = new RecordingService(this, urlBuilder); Releases = new ReleaseService(this, urlBuilder); ReleaseGroups = new ReleaseGroupService(this, urlBuilder); Work = new WorkService(this, urlBuilder); client = httpClient; }
public async void CreateWorkTest( Status expectedStatus, DateTime startTime, DateTime endTime, bool withProject = false, bool withDeveloper = false ) { var developer = EntitiesFactory.NewDeveloper().Get(); var project = EntitiesFactory.NewProject(developerIds: new[] { developer.Id }).Save(); var workDto = new WorkCreateDto { DeveloperId = developer.Id, ProjectId = project.Id, StartTime = startTime, EndTime = endTime, Comment = RandomHelper.RandomString(180), Hours = 10 }; var worksPersisted = new List <Work>(); _projectRepository.Setup(p => p.ExistAsync(project.Id)).ReturnsAsync(withProject); _projectRepository.Setup(p => p.GetDeveloperProjectIdAsync(project.Id, developer.Id)) .ReturnsAsync(project.DeveloperProjects.Single().Id); _projectRepository.Setup(p => p.ExistDeveloperVinculatedAsync(project.Id, developer.Id)) .ReturnsAsync(expectedStatus != Status.NotAllowed); _developerRepository.Setup(p => p.ExistAsync(developer.Id)).ReturnsAsync(withDeveloper); _workRepository.Setup(d => d.CreateAsync(Capture.In(worksPersisted))); _mockyRepository.Setup(m => m.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new Result <bool>(expectedStatus != Status.Error)); var service = new WorkService( _workRepository.Object, _developerRepository.Object, _projectRepository.Object, _mockyRepository.Object ); var result = await service.CreateWorkAsync(workDto); Assert.Equal(expectedStatus, result.Status); if (expectedStatus == Status.Success) { _workRepository.Verify(d => d.CreateAsync(It.IsAny <Work>()), Times.Once); _mockyRepository.Verify(d => d.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>()), Times.Once); var work = worksPersisted.Single(); Assert.Equal(workDto.Comment, work.Comment); Assert.Equal(workDto.StartTime, work.StartTime); Assert.Equal(workDto.EndTime, work.EndTime); Assert.Equal(workDto.Hours, work.Hours); } }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); //INITIALIZE SERVICES UserService.GetInstance(); EventsService.GetInstance(); WorkService.GetInstance(); HousingService.GetInstance(); FoodService.GetInstance(); }
public HomeController( UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, ProjectService svc, MembershopServices membershipsvc, WorkService worksvc) { _userManager = userManager; _signInManager = signInManager; _svc = svc; _membershipSVC = membershipsvc; _WorkSVC = worksvc; }
public async Task GetByIdTest() { _repoWrapper.Setup(r => r.Work.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <Work, bool> > >(), null)).ReturnsAsync(new Work()); var service = new WorkService(_repoWrapper.Object, _mapper.Object); _mapper.Setup(x => x.Map <Work, WorkDTO>(It.IsAny <Work>())).Returns(new WorkDTO()); // Act var result = await service.GetByIdAsync(1); // Assert Assert.NotNull(result); Assert.IsType <WorkDTO>(result); }
public async Task GetAllGroupByPositionTest() { _repoWrapper.Setup(r => r.Work.GetAllAsync(null, null)).ReturnsAsync(new List <Work>().AsQueryable()); var service = new WorkService(_repoWrapper.Object, _mapper.Object); _mapper.Setup(x => x.Map <Work, WorkDTO>(It.IsAny <Work>())).Returns(new WorkDTO()); // Act var result = await service.GetAllGroupByPositionAsync(); // Assert Assert.NotNull(result); Assert.IsAssignableFrom <IEnumerable <WorkDTO> >(result); }
private void button1_Click(object sender, RoutedEventArgs e) { this.button1.IsEnabled = false; this.button1.Content = "已运行"; workService = new WorkService(); workService.LoadDriver(obColl); DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(timer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); dispatcherTimer.Start(); //web启动 workService.StartServer(); }
public IndexingService(StatusService statusService, ImageProcessService imageService, ConfigService config, ImageCache imageCache, FolderWatcherService watcherService, WorkService workService) { _statusService = statusService; _configService = config; _imageProcessService = imageService; _imageCache = imageCache; _workService = workService; _watcherService = watcherService; // Slight hack to work around circular dependencies _watcherService.LinkIndexingServiceInstance(this); }
public void TestDIP() { var loggerMock = new Mock <ILogger>(); Mock <IStorage> storageMock = new Mock <IStorage>(); Mock <ICombiner> combinerMock = new Mock <ICombiner>(); loggerMock.Setup(m => m.log(It.IsAny <string>())); combinerMock.Setup(s => s.Combine(It.IsAny <string>(), It.IsAny <string>())).Returns("FakeString"); WorkService workService = new WorkService(loggerMock.Object, new Storage(), new Combiner()); workService.DoWork("ED"); loggerMock.Verify(x => x.log(It.IsAny <string>()), Times.Exactly(3)); }
/// <summary> /// Записать результат работы службы, после успешной обработки всех запросов /// </summary> public void SaveResultWorkingService(DateTime dateTimeStart) { var timeWork = TimeSpan.FromMilliseconds(TimerRequest.TimeExecutionRequests.ElapsedMilliseconds) .TotalSeconds; var workingService = new WorkService { StartTime = dateTimeStart, StopTime = DateTime.Now, NumberRequests = TimerRequest.Index, TimeExecutionRequests = (int)timeWork }; new WorkingServiceDTO(_dbContext).Save(workingService); }
public async void UpdateWorkTest( Status expectedStatus, DateTime startTime, DateTime endTime ) { var developer = EntitiesFactory.NewDeveloper().Save(); var project = EntitiesFactory.NewProject(developerIds: new[] { developer.Id }).Save(); var work = EntitiesFactory.NewWork( id: Guid.NewGuid(), developerProjectId: project.DeveloperProjects.Single().Id ).Get(); var workDto = new WorkUpdateDto { Id = work.Id, StartTime = startTime, EndTime = endTime, Comment = RandomHelper.RandomString(180), Hours = 250 }; _workRepository.Setup(d => d.ExistAsync(workDto.Id)) .ReturnsAsync(expectedStatus != Status.NotFund); _workRepository.Setup(d => d.GetByIdAsync(workDto.Id)) .ReturnsAsync(work); _mockyRepository.Setup(m => m.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new Result <bool>(expectedStatus != Status.Error)); var service = new WorkService( _workRepository.Object, _developerRepository.Object, _projectRepository.Object, _mockyRepository.Object ); var result = await service.UpdateWorkAsync(workDto); Assert.Equal(expectedStatus, result.Status); if (expectedStatus == Status.Success) { _workRepository.Verify(d => d.UpdateAsync(work), Times.Once); _mockyRepository.Verify(d => d.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>()), Times.Once); Assert.Equal(workDto.Comment, work.Comment); Assert.Equal(workDto.StartTime, work.StartTime); Assert.Equal(workDto.EndTime, work.EndTime); Assert.Equal(workDto.Hours, work.Hours); } }
public async void fetchWork(DateTime start, DateTime end, int user_id) { if (isLoading) { return; // we are already loading something } // No re-entry isLoading = true; this.BeginRefresh(); // Empty the model records.Clear(); // Fetch the data var _recordsList = await WorkService.getAll(start, end, user_id); if (!_recordsList.isOK) { await App.AppMainWindow.DisplayAlert("Error", "Failed to get the records list: " + _recordsList.error, "OK"); return; } // Place new items into the collection foreach (var item in _recordsList.result) { // Before pushing into model, add ourselves // to it for binding puposes var boundItem = new Record(item) { context = this }; // Add to model records.Add(boundItem); } this.EndRefresh(); isLoading = false; }
public async Task <string> DeployContractToModernAsync(string workHash, string workTitle, string coverImageHash, string artistName, string genre) { var contract = await DeployContractAsync(); var web3 = await CreateNewWeb3Instance(); var workService = new WorkService(web3, contract); var keys = new[] { WorkSchema.name, WorkSchema.audio, WorkSchema.genre, WorkSchema.image, WorkSchema.creator }; var values = string.Join("|", workTitle, workHash, genre, coverImageHash, artistName); await workService.BulkSetValueAsync(Account, keys, values, true, DefaultGas); return(contract); }
private void CheckBulkUploadStatus() { #region -- Check if Bulk Upload has been done else do it-- try { bool isBulkUploadCompleted; var bulkUploadSettings = _appSettingsRepository.GetByName(ApplicationConstants.HasFileBeenUploaded); if (string.IsNullOrEmpty(bulkUploadSettings.Value) || bool.TryParse(bulkUploadSettings.Value, out isBulkUploadCompleted)) { return; } var bulkData = new WorkService().LoadAndDataFile(); new WorkRepository().BulkInsert(bulkData); } catch (Exception exception) { _appLogRepository.Log(exception); } #endregion }
public ImageRecognitionService(StatusService statusService, ObjectDetector objectDetector, MetaDataService metadataService, AzureFaceService azureFace, AccordFaceService accordFace, EmguFaceService emguService, ThumbnailService thumbs, ConfigService configService, ImageClassifier imageClassifier, ImageCache imageCache, WorkService workService, ExifService exifService, ImageProcessService imageProcessor) { _thumbService = thumbs; _accordFaceService = accordFace; _azureFaceService = azureFace; _statusService = statusService; _objectDetector = objectDetector; _metdataService = metadataService; _emguFaceService = emguService; _configService = configService; _imageClassifier = imageClassifier; _imageProcessor = imageProcessor; _imageCache = imageCache; _workService = workService; _exifService = exifService; }
public SpeakAPIService(WorkService _workService) { this.workService = _workService; }
public WorkController(WorkService service) { _service = service; ViewBag.Animation = AnimationTypeConstant.Horizontal; }
public WorkController() { _workService = new WorkService(); }