public HistoryResult Get(QueryHistory q) { char[] delimiterChars = { ',' }; DateTime from = DateTime.Parse(Request.QueryString["from"]); DateTime to = DateTime.Parse(Request.QueryString["to"]); //string[] statusesString = Request.QueryString["statuses"].Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); TaskRunningStatus[] status = Array.ConvertAll(Request.QueryString["statuses"].Split(','), s => (TaskRunningStatus)Enum.Parse(typeof(TaskRunningStatus), s)); List <TaskRunningStatus> statuses = new List <TaskRunningStatus>(status); //Console.WriteLine(HttpUtility.UrlDecode(Request.QueryString["bs"])); string[] bs = base.Request.QueryString["bs"].Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); string sizeOperator = Request.QueryString["sizeOperator"]; long size = long.Parse(Request.QueryString["size"]); //tasksList = (List<P2PBackup.Common.Task>)remoteOperation.GetTasksHistory(bs, from, to); int offset = 0; int limit = 20; int.TryParse(base.Request.QueryString["start"], out offset); int.TryParse(base.Request.QueryString["limit"], out limit); var hr = new HistoryResult(); int totalCount = 0; hr.Items = (List <P2PBackup.Common.Task>)RemotingManager.GetRemoteObject().GetTasksHistory(bs, from, to, statuses, sizeOperator, size, limit, offset, out totalCount); hr.TotalCount = totalCount; return(hr); //RemotingManager.GetRemoteObject().GetTasksHistory }
public object GetHistoryBacktest(object json) { var body = JsonConverter.Decode(json); int strategy_id = int.Parse(body["strategy_id"]); var user_id = body["user_id"]; using (var ctx = new quantEntities()) { List <backtest> bts = ctx.backtest.Where(a => a.strategy_id == strategy_id).ToList(); List <HistoryResult> list = new List <HistoryResult>(); foreach (var bt in bts) { HistoryResult hr = new HistoryResult( bt.backtest_id, bt.sy, bt.nsy, bt.hc, bt.xp, bt.report_path, bt.time); list.Add(hr); } var ordered_list = list.OrderBy(a => a.time); var data = new { history_result = ordered_list }; return(Helper.JsonConverter.BuildResult(data)); } }
public override async Task RunHistory(Empty request, IServerStreamWriter <HistoryResponse> responseStream, ServerCallContext context) { var bigDatas = await File.ReadAllLinesAsync("BigData.txt"); var processedBigData = new List <string>(); for (int i = 0; i < bigDatas.Length; i++) { await Task.Delay(TimeSpan.FromSeconds(0.2)); var data = bigDatas[i]; _logger.LogInformation("Adding {data}", data); processedBigData.Add(data); var progress = (i + 1) / (double)bigDatas.Length; await responseStream.WriteAsync(new HistoryResponse { Progress = Convert.ToInt32(progress * 100) }); } _logger.LogInformation("History complete. Returning {Count} BigDatas", processedBigData.Count); var historyResult = new HistoryResult(); historyResult.Items.Add(processedBigData); await responseStream.WriteAsync(new HistoryResponse { Result = historyResult }); }
public virtual IEnumerable ViewDetails(PXAdapter adapter) { if (this.History.Current != null && this.Filter.Current != null) { HistoryResult res = this.History.Current; ARStatementDetails graph = PXGraph.CreateInstance <ARStatementDetails>(); ARStatementDetails.ARStatementDetailsParameters filter = graph.Filter.Current; filter.StatementCycleId = res.StatementCycleId; filter.StatementDate = res.StatementDate; graph.Filter.Update(filter); filter = graph.Filter.Select(); throw new PXRedirectRequiredException(graph, "Statement Details"); } return(Filter.Select()); }
//private static ResponseProgress<HistoryResult,int> ServerStreamingCallExample(Progressor.ProgressorClient client,IProgress<int> progress) //{ // var call = client.RunHistory(new Google.Protobuf.WellKnownTypes.Empty()); // var historyResponse = call.ResponseStream;//as IAsyncStreamReader<IProgressMessage<HistoryResult, int>>; // return GrpcProgress.Create(historyResponse, progress); //} //private static ResponseProgress<HistoryResult, int> ServerStreamingCallExample( // Progressor.ProgressorClient client, // IProgress<int> progress) //{ // var call = client.RunHistory(new Empty()); // Debug.Assert(call.ResponseStream is IAsyncStreamReader<HistoryResponse>, "response stream historyResponse"); // var result = call.ResponseStream is IAsyncStreamReader<IProgressMessage<HistoryResult, int>>; // Debug.Assert(result, "response stream IAsyncStreamReader<IProgressMessage<HistoryResult, int>>"); // //if(call.ResponseStream is IAsyncStreamReader<IProgressMessage<HistoryResult, int>>) // //{ // // Console.WriteLine("response stream IAsyncStreamReader<IProgressMessage<HistoryResult, int>>"); // //} // //return new ResponseProgress<HistoryResult, int>(call.ResponseStream as IAsyncStreamReader<IProgressMessage<HistoryResult, int>>, progress); //} private static async Task ServerStreamingCallExample( Progressor.ProgressorClient client, IProgress <int> progress) { var call = client.RunHistory(new Empty()); var resultTask = Task.Run(async() => { HistoryResult result = null; await foreach (var item in call.ResponseStream.ReadAllAsync()) { var progressMessage = item as IProgressMessage <HistoryResult, int>; if (progressMessage == null) { Console.WriteLine("Server write is not Progress Message"); continue; } if (progressMessage.IsProgress) { progress?.Report(progressMessage.Progress); continue; } if (progressMessage.IsResult) { result = progressMessage.Result; } } //throw new Exception("Call completed without a result."); return(result); }); var result = await resultTask; if (result == null) { Console.WriteLine("not result."); return; } Console.WriteLine("Preparing results..."); await Task.Delay(TimeSpan.FromSeconds(2)); foreach (var item in result.Items) { Console.WriteLine(item); } }
private double GetDifference(int position, HistoryResult current, HistoryResult previous, HistoryResult last) { var currentValue = current.Balls[position]; var previousValue = previous.Balls[position]; var lastValue = last.Balls[position]; double curentMinusPrevious = Math.Abs(currentValue - previousValue); double previousMinusLast = Math.Abs(previousValue - lastValue); if (curentMinusPrevious == 0 || previousMinusLast == 0) { return(0); } var result = curentMinusPrevious / previousMinusLast; return(curentMinusPrevious); }
public JsonResult GetInformationAccount(int accountId) { string functionName = System.Reflection.MethodBase.GetCurrentMethod().Name; try { //Check id account exist in the database if (!_accountRepository.AccountExists(accountId)) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.accountNotFound)); return(Json(MessageResult.GetMessage(MessageType.ACCOUNT_NOT_FOUND))); } if (!ModelState.IsValid) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.notFound)); return(Json(MessageResult.GetMessage(MessageType.NOT_FOUND))); } //Get list all history by id account List <HistoryEntity> list = _historyRepository.getHistoryByAccount(accountId); List <HistoryResult> listResult = new List <HistoryResult>(); foreach (var history in list) { HistoryResult result = new HistoryResult(); ExamEntity exam = _examRepository.GetExamById(history.ExamId); GroupEntity group = _groupRepository.GetGroupById(history.GroupId); result.nameExam = exam.Name; result.nameGroup = group.Name; listResult.Add(result); } return(Json(listResult)); } catch (Exception ex) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(ex.Message)); return(Json(MessageResult.ShowServerError(ex.Message))); } }
public QuantumRandomNumber GenerateNumber(HistoryResult program, string HistoryResultId) { var items = program.GetHistoryResults().Result; if (items.Count == 0) { return(null); } var result = program.GetQubitResultStatesById(items, HistoryResultId); if (result != null) { var quantum_number = new QuantumRandomNumber(); result = (from t in result orderby t.Index ascending select t).ToList(); short[] quantum_values = new short[result.Count]; for (int i = 0; i < result.Count; i++) { quantum_values[i] = (short)(result[i].One % 100); } quantum_number.SetQuantumNumber(quantum_values); return(quantum_number); } return(null); }
public override async Task RunHistory(Empty request, IServerStreamWriter <HistoryResponse> responseStream, ServerCallContext context) { var monarches = await File.ReadAllLinesAsync("Monarchs-of-England.txt"); var processedMonarches = new List <string>(); for (int i = 0; i < monarches.Length; i++) { // Simulate complex work await Task.Delay(TimeSpan.FromSeconds(0.2)); var monarch = monarches[i]; // Add monarch to final results _logger.LogInformation("Adding {Monarch}", monarch); processedMonarches.Add(monarch); // Calculate and send progress var progress = (i + 1) / (double)monarches.Length; await responseStream.WriteAsync(new HistoryResponse { Progress = Convert.ToInt32(progress * 100) }); } _logger.LogInformation("History complete. Returning {Count} monarchs.", processedMonarches.Count); // Send final result var historyResult = new HistoryResult(); historyResult.Items.AddRange(processedMonarches); await responseStream.WriteAsync(new HistoryResponse { Result = historyResult }); }
protected static void Copy(Dictionary <string, string> aDest, HistoryResult aSrc) { aDest[ARStatementReportParams.Parameters.StatementCycleID] = aSrc.StatementCycleId; aDest[ARStatementReportParams.Parameters.StatementDate] = aSrc.StatementDate.Value.ToString("d", CultureInfo.InvariantCulture); }
protected virtual IEnumerable history() { this.History.Cache.Clear(); ARStatementHistoryParameters header = Filter.Current; if (header == null) { yield break; } int? prevCustomerID = null; string prevCuryID = null; HistoryResult prevRec = null; PXResultset <ARStatement> res; List <object> stored = new List <object>(); PXSelectBase <ARStatement> select = new PXSelectJoin <ARStatement, LeftJoin <ARStatementCycle, On <ARStatementCycle.statementCycleId, Equal <ARStatement.statementCycleId> >, LeftJoin <Customer, On <Customer.bAccountID, Equal <ARStatement.statementCustomerID> > > >, Where <ARStatement.statementCustomerID, Equal <ARStatement.customerID>, And <ARStatement.statementDate, GreaterEqual <Required <ARStatement.statementDate> >, And <ARStatement.statementDate, LessEqual <Required <ARStatement.statementDate> >, And <Where <ARStatement.statementCycleId, Equal <Required <ARStatement.statementCycleId> >, Or <Required <ARStatement.statementCycleId>, IsNull> > > > > >, OrderBy <Asc <ARStatement.statementCycleId, Asc <ARStatement.statementDate, Asc <ARStatement.customerID, Asc <ARStatement.curyID> > > > > >(this); using (new PXFieldScope(select.View, typeof(ARStatement.branchID), typeof(ARStatement.statementCycleId), typeof(ARStatement.statementDate), typeof(ARStatement.customerID), typeof(ARStatement.statementCustomerID), typeof(ARStatement.curyID), typeof(ARStatement.dontPrint), typeof(ARStatement.dontEmail), typeof(ARStatement.printed), typeof(ARStatement.emailed), typeof(ARStatementCycle.descr), typeof(Customer.printCuryStatements))) { res = select.Select(header.StartDate, header.EndDate, header.StatementCycleId, header.StatementCycleId); } foreach (PXResult <ARStatement, ARStatementCycle, Customer> item in res) { stored.Add(item); ARStatement st = item; ARStatementCycle cycle = item; Customer cust = item; HistoryResult rec = new HistoryResult { StatementCycleId = st.StatementCycleId, StatementDate = st.StatementDate, Descr = cycle.Descr, DontPrintCount = 0, DontEmailCount = 0, PrintedCount = 0, EmailedCount = 0, NoActionCount = 0 }; rec = (HistoryResult)this.History.Cache.Locate(rec) ?? this.History.Insert(rec); if (rec != null) { if (prevRec != rec) { prevCustomerID = null; prevCuryID = null; } if (prevCustomerID != st.CustomerID || (cust.PrintCuryStatements == true && prevCuryID != st.CuryID)) { rec.NumberOfDocuments += 1; rec.DontPrintCount += st.DontPrint == true ? 1 : 0; rec.DontEmailCount += st.DontEmail == true ? 1 : 0; rec.NoActionCount += st.DontEmail == true && st.DontPrint == true ? 1 : 0; rec.PrintedCount += st.Printed == true ? 1 : 0; rec.EmailedCount += st.Emailed == true ? 1 : 0; } prevRec = rec; prevCustomerID = st.CustomerID; prevCuryID = st.CuryID; } } select.StoreCached(new PXCommandKey(new object[] { header.StartDate, header.EndDate, header.StatementCycleId, header.StatementCycleId }), stored); this.History.Cache.IsDirty = false; foreach (HistoryResult ret in this.History.Cache.Inserted) { yield return(ret); } }
protected virtual IEnumerable history() { this.History.Cache.Clear(); ARStatementHistoryParameters header = Filter.Current; if (header == null) { yield break; } Dictionary <string, Dictionary <DateTime, int> > result = new Dictionary <string, Dictionary <DateTime, int> >(); Dictionary <string, string> dictARStatementCycle = new Dictionary <string, string>(); int? prevCustomerID = null; string prevCuryID = null; HistoryResult prevRec = null; foreach (PXResult <ARStatement, ARStatementCycle, Customer> item in PXSelectJoin <ARStatement, LeftJoin <ARStatementCycle, On <ARStatementCycle.statementCycleId, Equal <ARStatement.statementCycleId> >, LeftJoin <Customer, On <Customer.bAccountID, Equal <ARStatement.customerID> > > >, Where <ARStatement.statementDate, GreaterEqual <Required <ARStatement.statementDate> >, And <ARStatement.statementDate, LessEqual <Required <ARStatement.statementDate> >, And <Where <ARStatement.statementCycleId, Equal <Required <ARStatement.statementCycleId> >, Or <Required <ARStatement.statementCycleId>, IsNull> > > > >, OrderBy <Asc <ARStatement.statementCycleId, Asc <ARStatement.statementDate, Asc <ARStatement.customerID, Asc <ARStatement.curyID> > > > > > .Select(this, header.StartDate, header.EndDate, header.StatementCycleId, header.StatementCycleId)) { ARStatement st = item; Customer cust = item; HistoryResult rec = new HistoryResult(); rec.StatementCycleId = st.StatementCycleId; rec.StatementDate = st.StatementDate; rec.Descr = ((ARStatementCycle)item).Descr; rec.DontPrintCount = 0; rec.DontEmailCount = 0; rec.PrintedCount = 0; rec.EmailedCount = 0; rec.NoActionCount = 0; rec = (HistoryResult)this.History.Cache.Locate(rec) ?? this.History.Insert(rec); if (rec != null) { if (prevRec != rec) { prevCustomerID = null; prevCuryID = null; } if (prevCustomerID != st.CustomerID || (cust.PrintCuryStatements == true && prevCuryID != st.CuryID)) { rec.NumberOfDocuments += 1; rec.DontPrintCount += ((st.DontPrint ?? false) == true) ? 1 : 0; rec.DontEmailCount += ((st.DontEmail ?? false) == true) ? 1 : 0; rec.NoActionCount += ((st.DontEmail ?? false) == true && (st.DontPrint ?? false) == true) ? 1 : 0; rec.PrintedCount += ((st.Printed ?? false) == true) ? 1 : 0; rec.EmailedCount += ((st.Emailed ?? false) == true) ? 1 : 0; } prevRec = rec; prevCustomerID = st.CustomerID; prevCuryID = st.CuryID; } /* * if (result.ContainsKey(((ARStatement)st).StatementCycleId)) * { * if (result[((ARStatement)st).StatementCycleId].ContainsKey(((ARStatement)st).StatementDate ?? DateTime.MinValue)) * { * result[((ARStatement)st).StatementCycleId][((ARStatement)st).StatementDate ?? DateTime.MinValue] = result[((ARStatement)st).StatementCycleId][((ARStatement)st).StatementDate ?? DateTime.MinValue] + 1; * } * else * { * result[((ARStatement)st).StatementCycleId].Add(((ARStatement)st).StatementDate ?? DateTime.MinValue, 1); * } * } * else * { * Dictionary<DateTime, int> dictValue = new Dictionary<DateTime, int>(); * dictValue.Add(((ARStatement)st).StatementDate ?? DateTime.MinValue, 1); * result.Add(((ARStatement)st).StatementCycleId, dictValue); * } * if(dictARStatementCycle.ContainsKey (((ARStatement)st).StatementCycleId) == false) * dictARStatementCycle.Add(((ARStatement)st).StatementCycleId, ((ARStatementCycle)st).Descr); */ } this.History.Cache.IsDirty = false; foreach (HistoryResult ret in this.History.Cache.Inserted) { yield return(ret); } /* * foreach (string statementCycleId in result.Keys) * { * foreach (DateTime statementDate in result[statementCycleId].Keys) * { * HistoryResult res = new HistoryResult(); * res.StatementCycleId = statementCycleId; * res.StatementDate = statementDate; * res.NumberOfDocuments = result[statementCycleId][statementDate]; * res.Descr = dictARStatementCycle[statementCycleId]; * yield return res; * } * } */ }
private void OnHistoryCommand(BotShell bot, CommandArgs e) { if (bot.GetUserID(e.Args[0]) < 100) { bot.SendReply(e, "No such user: "******"'s History »» Gathering Data..."); HistoryResult history = XML.GetHistory(e.Args[0].ToLower(), bot.Dimension); if (history == null || history.Items == null) { bot.SendReply(e, "Unable to gather information on that user " + this.TimeoutError); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Auno.org Player History"); window.AppendHighlight("Character: "); window.AppendNormal(Format.UppercaseFirst(e.Args[0])); window.AppendLineBreak(); window.AppendHighlight("Entries: "); window.AppendNormal(history.Items.Length.ToString()); window.AppendLineBreak(); window.AppendHighlight("URL: "); window.AppendNormal(string.Format(this.CharAunoWebsite, (int)bot.Dimension, e.Args[0].ToLower())); window.AppendLineBreak(2); window.AppendHighlightStart(); window.AppendString("Date "); window.AppendString("LVL "); window.AppendString("DR "); window.AppendColorString("000000", "'"); window.AppendString("Faction "); window.AppendString("Organization"); window.AppendColorEnd(); window.AppendLineBreak(); foreach (HistoryResult_Entry entry in history.Items) { window.AppendNormalStart(); window.AppendString(entry.Date); window.AppendHighlight(" | "); window.AppendString(entry.Level.ToString("000")); window.AppendHighlight(" | "); window.AppendString(entry.DefenderLevel.ToString("00")); window.AppendHighlight(" | "); switch (entry.Faction.ToLower()) { case "clan": window.AppendString("Clan "); break; case "omni": window.AppendString("Omni "); break; case "neutral": window.AppendString("Neutral"); break; default: window.AppendString("Unknown"); break; } window.AppendHighlight(" | "); if (entry.Organization != null && entry.Organization != String.Empty) { window.AppendString(entry.Rank); window.AppendString(" of "); window.AppendString(entry.Organization); } window.AppendColorEnd(); window.AppendLineBreak(); } bot.SendReply(e, Format.UppercaseFirst(e.Args[0]) + "'s History »» ", window); }
private void HandleResult(ITestWorker testWorker, TestResult testResult) { if (testWorker.WorkItem != null && (testResult.TestState == TestState.Error || testResult.TestState == TestState.ErrorRepeat) && testWorker.WorkItem.RunCount < RegtestingServerConfiguration.MaxRunCount) { _testPool.ReAddWorkItem(testWorker.WorkItem); testWorker.WorkItem = null; return; } WorkItem workItem = testWorker.WorkItem; workItem.TestState = testResult.TestState; string imagefile = null; if (!String.IsNullOrEmpty(testResult.Screenshot)) { string folder = RegtestingServerConfiguration.Screenshotsfolder; string subFolder = DateTime.Now.Year + "-" + DateTime.Now.Month + "\\"; string fileName = "screen" + Helper.GetScreenshotString() + ".png"; Directory.CreateDirectory(folder + subFolder); imagefile = subFolder + fileName; Screenshot screenshot = new Screenshot(testResult.Screenshot); screenshot.SaveAsFile(folder + imagefile, ImageFormat.Png); } Result result = _resultRepository.Get(workItem.Testsystem, workItem.Testcase, workItem.Browser, workItem.Language); result.ResultCode = testResult.TestState; result.DetailLog = CreateLog(testResult.Log); result.Error = testResult.Error; result.Testtime = DateTime.Now; result.ScreenshotFile = imagefile; if (result.ResultCode == TestState.Error || result.ResultCode == TestState.ErrorRepeat || result.ResultCode == TestState.KnownError) { if (result.ErrorCount == null) { result.ErrorCount = 1; result.ErrorSince = result.Testtime; } else { result.ErrorCount = result.ErrorCount + 1; } } else { result.ErrorSince = null; result.ErrorCount = null; } _resultRepository.Store(result); workItem.Result = result; foreach (ITestJobManager testJobManager in workItem.TestJobManagers) { HistoryResult historyResult = Mapper.Map <HistoryResult>(workItem); historyResult.DetailLog = CreateLog(testResult.Log); historyResult.ResultCode = testResult.TestState; historyResult.Error = testResult.Error; historyResult.Testtime = DateTime.Now; historyResult.TestJob = testJobManager.TestJob; historyResult.ScreenshotFile = imagefile; _historyResultRepository.Store(historyResult); } lock (TestsystemSummariesCache.Cache.GetLock(workItem.Testsystem.ID)) { TestsystemSummariesCache.Cache.Set(workItem.Testsystem.ID, null); } testWorker.WorkItem = null; _testPool.WorkItemFinished(workItem); }