public Task SendDataRequestResultAsync(Keccak depositId, DataRequestResult result) => _notifier.NotifyAsync(new Notification("data_request_result", new { depositId, result = result.ToString() }));
public DataRequestResult File_GetCrC32() { var result_ = new DataRequestResult(); var result = GetResult((UInt16)CommandType.FILE_GetHashSumOfFile); if (result.IsEmpty) { result_.Status = WriteReadFileHandleResult.Fail; } if (result.Data[0] != 0) { switch (result.Data[0]) { case (1): result_.Status = WriteReadFileHandleResult.CantReadData; result_.ErrorByteIndex = BitConverter.ToUInt32(result.Data, 1); return(result_); default: result_.Status = WriteReadFileHandleResult.Fail; return(result_); } } result_.Result = new byte[result.Data.Length - 1]; Buffer.BlockCopy(result.Data, 1, result_.Result, 0, result.Data.Length - 1); result_.Status = WriteReadFileHandleResult.OK; return(result_); }
public DataRequestResult File_Read(UInt32 offset, UInt32 length) { var result_ = new DataRequestResult(); byte[] data_ = new byte[8]; Buffer.BlockCopy(BitConverter.GetBytes(offset), 0, data_, 0, 4); Buffer.BlockCopy(BitConverter.GetBytes(length), 0, data_, 4, 4); var result = GetResult((UInt16)CommandType.File_GetFileData, data_); if (result.IsEmpty) { result_.Status = WriteReadFileHandleResult.Fail; return(result_); } if (result.Data.Length == 1 && result.Status == AnswerStatus.Error) { switch (result.Data[0]) { case (1): result_.Status = WriteReadFileHandleResult.FileNotOpened; return(result_); case (2): result_.Status = WriteReadFileHandleResult.CantReadData; return(result_); default: result_.Status = WriteReadFileHandleResult.Fail; return(result_); } } result_.Result = result.Data; result_.Status = WriteReadFileHandleResult.OK; return(result_); }
public override async Task <object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) { #region 建立查詢物件 DataRequest dataRequest = new DataRequest() { Skip = dataManagerRequest.Skip, Take = dataManagerRequest.Take, }; if (dataManagerRequest.Search != null && dataManagerRequest.Search.Count > 0) { var keyword = dataManagerRequest.Search[0].Key; dataRequest.Search = keyword; } if (CurrentSortCondition != null) { dataRequest.Sorted = CurrentSortCondition; } #endregion #region 發出查詢要求 DataRequestResult <MenuRoleAdapterModel> adaptorModelObjects = await Service.GetAsync(dataRequest); var item = dataManagerRequest.RequiresCounts ? new DataResult() { Result = adaptorModelObjects.Result, Count = adaptorModelObjects.Count } : (object)adaptorModelObjects.Result; await Task.Yield(); return(item); #endregion }
public async Task <DataRequestResult <WorkingLogDetailAdapterModel> > GetByHeaderIDAsync(int id, DataRequest dataRequest) { List <WorkingLogDetailAdapterModel> data = new List <WorkingLogDetailAdapterModel>(); DataRequestResult <WorkingLogDetailAdapterModel> result = new DataRequestResult <WorkingLogDetailAdapterModel>(); var DataSource = context.WorkingLogDetail .AsNoTracking() .Include(x => x.Project) .Where(x => x.WorkingLogId == id); #region 進行分頁 // 取得記錄總數量,將要用於分頁元件面板使用 result.Count = DataSource.Cast <WorkingLogDetail>().Count(); DataSource = DataSource.Skip(dataRequest.Skip); if (dataRequest.Take != 0) { DataSource = DataSource.Take(dataRequest.Take); } #endregion #region 在這裡進行取得資料與與額外屬性初始化 List <WorkingLogDetailAdapterModel> adapterModelObjects = Mapper.Map <List <WorkingLogDetailAdapterModel> >(DataSource); foreach (var adapterModelItem in adapterModelObjects) { await OhterDependencyData(adapterModelItem); } #endregion result.Result = adapterModelObjects; await Task.Yield(); return(result); }
public void SendDataRequestResult(Keccak depositId, DataRequestResult result) { if (Logger.IsTrace) { Logger.Trace($"{Session.RemoteNodeId} NDM sending: datarequestresult"); } Send(new DataRequestResultMessage(depositId, result)); }
private CaptureInfo GetCapture(ScannerType scannerType, CancellationToken token) { Log.DebugFormat("GetCapture(scannerType={0}, token={1}) called", scannerType, token); CaptureInfo captureInfo = null; DataRequestResult result = DataRequestResult.None; bool isRunning = true; int attempts = 0; while (isRunning) { // Check if cancellation requested token.ThrowIfCancellationRequested(); // First query the database to get an image file name. CaptureDb captureCandidate = GetCaptureFromDatabase(scannerType); if (captureCandidate != null) { // Try to find an image file using the file name. byte[] imageData; bool isFound = TryGetImageFromName(captureCandidate.HumanId, out imageData); if (isFound) { // Matching file found. Log.DebugFormat("Matching file found for capture={0}", captureCandidate.HumanId); isRunning = false; captureInfo = new CaptureInfo( captureCandidate.Id, imageData, captureCandidate.GoldTemplate); result = DataRequestResult.Success; } else { // Give up if the number of attemps exceeds limit. attempts++; if (attempts > MAX_OPEN_FILE_ATTEMPTS) { Log.WarnFormat("Exceeded maximum number of file searches (attempts={0})", attempts); isRunning = false; result = DataRequestResult.Failed; } } } else { // Queries are not returning any more candidates, give up immediately. Log.Warn("No candidate filename obtained from the database"); result = DataRequestResult.Failed; break; } } IntegrityCheck.AreNotEqual(DataRequestResult.None, result); return(captureInfo); }
public static DataRequestResult ToDataRequestResult(this RequestResult res) { var output = new DataRequestResult(); output.CommentText = res.CommentText; output.Link = res.Link; output.UserId = res.UserId; output.VictimsId = res.VictimsId; output.PostId = res.PostId; output.Type = res.Type; return(output); }
/// <summary> /// Initializes a new instance of the <see cref="GetCaptureCompleteEventArgs"/> class in /// the case where the request was successful. /// </summary> /// <param name="capture">The capture.</param> /// <param name="requestId">The request unique identifier.</param> public GetCaptureCompleteEventArgs(CaptureInfo capture, Guid requestId, DataRequestResult result) { IntegrityCheck.IsNotNull(requestId); IntegrityCheck.IsNotNull(result); if (result == DataRequestResult.Success) { IntegrityCheck.IsNotNull(capture); } m_Capture = capture; m_RequestId = requestId; m_Result = result; }
private void DoTestInitialisationFailed(Guid identifier, DataRequestResult result) { using (Fake.CreateScope()) { // EXECUTE: m_DataController.InitialisationComplete += Raise.With( new InitialisationCompleteEventArgs(InitialisationResult.Error, identifier, result)); // ASSERT: // Assert public state of ViewModel Assert.AreEqual(Activity.Fault, m_ViewModel.CurrentActivity); Assert.IsFalse(m_ViewModel.IsTemplating); Assert.IsNotNull(m_ViewModel.Exception); Assert.AreEqual(m_ViewModel.Exception.Message, m_ViewModel.PromptText); // Assert that ViewModel made no calls to other fake objects AssertNoCallsToDataController(); AssertNoCallsToSettingsValidator(); AssertNoCallsToSettingsViewModel(); AssertNoCallsToTemplatingViewModel(); AssertNoCallsToWindowService(); AssertNoCallsToDispatcherHelper(); } }
public async Task <DataRequestResult <WorkingLogDetailAdapterModel> > GetAsync(DataRequest dataRequest) { List <WorkingLogDetailAdapterModel> data = new List <WorkingLogDetailAdapterModel>(); DataRequestResult <WorkingLogDetailAdapterModel> result = new DataRequestResult <WorkingLogDetailAdapterModel>(); var DataSource = context.WorkingLogDetail .AsNoTracking() .Include(x => x.Project) .AsQueryable(); #region 進行搜尋動作 if (!string.IsNullOrWhiteSpace(dataRequest.Search)) { DataSource = DataSource .Where(x => x.Title.Contains(dataRequest.Search) || x.Summary.Contains(dataRequest.Search) || x.Project.Name.Contains(dataRequest.Search)); } #endregion #region 進行排序動作 if (dataRequest.Sorted != null) { SortCondition CurrentSortCondition = dataRequest.Sorted; switch (CurrentSortCondition.Id) { case (int)WorkingLogDetailSortEnum.TitleDescending: DataSource = DataSource.OrderByDescending(x => x.Title); break; case (int)WorkingLogDetailSortEnum.TitleAscending: DataSource = DataSource.OrderBy(x => x.Title); break; case (int)WorkingLogDetailSortEnum.HoursDescending: DataSource = DataSource.OrderByDescending(x => x.Hours); break; case (int)WorkingLogDetailSortEnum.HoursAscending: DataSource = DataSource.OrderBy(x => x.Hours); break; default: DataSource = DataSource.OrderBy(x => x.Id); break; } } #endregion #region 進行分頁 // 取得記錄總數量,將要用於分頁元件面板使用 result.Count = DataSource.Cast <WorkingLogDetail>().Count(); DataSource = DataSource.Skip(dataRequest.Skip); if (dataRequest.Take != 0) { DataSource = DataSource.Take(dataRequest.Take); } #endregion #region 在這裡進行取得資料與與額外屬性初始化 List <WorkingLogDetailAdapterModel> adapterModelObjects = Mapper.Map <List <WorkingLogDetailAdapterModel> >(DataSource); foreach (var adapterModelItem in adapterModelObjects) { await OhterDependencyData(adapterModelItem); } #endregion result.Result = adapterModelObjects; await Task.Yield(); return(result); }
public SaveTemplateEventArgs(Guid requestId, DataRequestResult result) { m_RequestId = requestId; m_Result = result; }
public async Task <ResultWrapper <string> > ndm_sendDataRequest(Keccak depositId) { DataRequestResult result = await _consumerService.SendDataRequestAsync(depositId); return(ResultWrapper <string> .Success(result.ToString())); }
private async Task PerformAppMaintenanceAsync() { IDataService backendService = this.GetService <IDataService>(x => x.DataSource == DataSource.Online); ILocalCacheService cacheService = Services.GetService <ILocalCacheService>(); Task <DataRequestResult <WellknownData> > wellknownTask = backendService.GetWellknownDataAsync(); try { DataRequestResult <StudentInfo> studentInfo = await backendService.GetStudentInfoAsync(); await cacheService.SetStudentInfoAsync(studentInfo.Resource); } catch (BackendRequestFailedException ex) { Crashes.TrackError(ex); return; } catch (LocalCacheRequestFailedException ex) { Crashes.TrackError(ex); } Task <DataRequestResult <Schedule> > scheduleTask = backendService.GetScheduleAsync(); Task <DataRequestResult <ExamSchedule> > examsTask = backendService.GetExamsAsync(); Task <DataRequestResult <ScoreSet> > majorScoreTask = backendService.GetScoreAsync(false); Task <DataRequestResult <ScoreSet> > secondMajorScoreTask = backendService.GetScoreAsync(true); try { DataRequestResult <WellknownData> wellknown = await wellknownTask; await cacheService.SetWellknownDataAsync(wellknown.Resource); } catch (Exception ex) when(ex is BackendRequestFailedException || ex is LocalCacheRequestFailedException) { Crashes.TrackError(ex); } try { DataRequestResult <Schedule> schedule = await scheduleTask; await cacheService.SetScheduleAsync(schedule.Resource); } catch (Exception ex) when(ex is BackendRequestFailedException || ex is LocalCacheRequestFailedException) { Crashes.TrackError(ex); } try { DataRequestResult <ExamSchedule> exams = await examsTask; await cacheService.SetExamsAsync(exams.Resource); } catch (Exception ex) when(ex is BackendRequestFailedException || ex is LocalCacheRequestFailedException) { Crashes.TrackError(ex); } try { DataRequestResult <ScoreSet> majorScore = await majorScoreTask; await cacheService.SetScoreAsync(majorScore.Resource); } catch (Exception ex) when(ex is BackendRequestFailedException || ex is LocalCacheRequestFailedException) { Crashes.TrackError(ex); } try { DataRequestResult <ScoreSet> secondMajorScore = await secondMajorScoreTask; await cacheService.SetScoreAsync(secondMajorScore.Resource); } catch (Exception ex) when(ex is BackendRequestFailedException || ex is LocalCacheRequestFailedException) { Crashes.TrackError(ex); } }
/// <summary> /// Constructor. /// </summary> /// <param name="Result">Outcome Of The Data Request.</param> /// <param name="Exception">Any System.Exception That May Have Occured During The Data Request.</param> public DataRequestEventArgs(DataRequestResult Result, Exception Exception = null) { this.Exception = Exception; this.Result = Result; }
public async Task <DataRequestResult <CalendarSubscription> > GetCalendarSubscriptionIdAsync() { DataRequestResult <StudentInfo> info = await GetStudentInfoAsync(); return(new DataRequestResult <CalendarSubscription>(new CalendarSubscription(info.Resource.CalendarSubscriptionId), null)); }
public async Task <DataRequestResult <LeaveCategoryAdapterModel> > GetAsync(DataRequest dataRequest) { List <LeaveCategoryAdapterModel> data = new List <LeaveCategoryAdapterModel>(); DataRequestResult <LeaveCategoryAdapterModel> result = new DataRequestResult <LeaveCategoryAdapterModel>(); var DataSource = context.LeaveCategory .AsNoTracking(); #region 進行搜尋動作 if (!string.IsNullOrWhiteSpace(dataRequest.Search)) { DataSource = DataSource .Where(x => x.Name.Contains(dataRequest.Search)); } #endregion #region 進行排序動作 if (dataRequest.Sorted != null) { SortCondition CurrentSortCondition = dataRequest.Sorted; switch (CurrentSortCondition.Id) { case (int)LeaveCategorySortEnum.NameDescending: DataSource = DataSource.OrderByDescending(x => x.Name); break; case (int)LeaveCategorySortEnum.NameAscending: DataSource = DataSource.OrderBy(x => x.Name); break; case (int)LeaveCategorySortEnum.OrderNumberDescending: DataSource = DataSource.OrderByDescending(x => x.OrderNumber); break; case (int)LeaveCategorySortEnum.OrderNumberAscending: DataSource = DataSource.OrderBy(x => x.OrderNumber); break; default: DataSource = DataSource.OrderBy(x => x.Id); break; } } #endregion #region 進行分頁 // 取得記錄總數量,將要用於分頁元件面板使用 result.Count = DataSource.Cast <LeaveCategory>().Count(); DataSource = DataSource.Skip(dataRequest.Skip); if (dataRequest.Take != 0) { DataSource = DataSource.Take(dataRequest.Take); } #endregion #region 在這裡進行取得資料與與額外屬性初始化 List <LeaveCategoryAdapterModel> adapterModelObjects = Mapper.Map <List <LeaveCategoryAdapterModel> >(DataSource); foreach (var adapterModelItem in adapterModelObjects) { await OhterDependencyData(adapterModelItem); } #endregion result.Result = adapterModelObjects; await Task.Yield(); return(result); }
public DataRequestResultMessage(Keccak depositId, DataRequestResult result) { DepositId = depositId; Result = result; }
public InitialisationCompleteEventArgs(InitialisationResult result, Guid requestId, DataRequestResult requestResult) { m_Result = result; m_RequestId = requestId; m_RequestResult = requestResult; }