Esempio n. 1
0
 /// <summary></summary>
 public static async Task InsertByTagIdAsync(
     Guid readerId,
     string tagId,
     HistoryStatus status)
 {
     await Db.DbFactory.GetInstance().NonQueryAsync(
         (db, conn, trans) => InsertByTagIdAsync(db, conn, trans, readerId, tagId, status));
 }
Esempio n. 2
0
 /// <summary></summary>
 public static async Task InsertAsync(
     Guid readerId,
     int employeeId,
     HistoryStatus status)
 {
     await Db.DbFactory.GetInstance().NonQueryAsync(
         (db, conn, trans) => InsertAsync(db, conn, trans, readerId, employeeId, status));
 }
Esempio n. 3
0
 private void agrupaPorPeriodo(HistoryStatus hs, StatusHistoryRsponse STR, ref DateTime data, double[] dadosAgroup, int[] contadores, bool[] NotNull, string dataFormat)
 {
     STR.Data.Add(String.Format(dataFormat, hs.recvTime));
     data = hs.recvTime;
     if (NotNull[0])
     {
         STR.pH.Add(null);
     }
     else
     {
         STR.pH.Add(dadosAgroup[0] / contadores[0]);
     }
     if (NotNull[1])
     {
         STR.luminosidade.Add(null);
     }
     else
     {
         STR.luminosidade.Add(dadosAgroup[1] / contadores[1]);
     }
     if (NotNull[2])
     {
         STR.tempSolo.Add(null);
     }
     else
     {
         STR.tempSolo.Add(dadosAgroup[2] / contadores[2]);
     }
     if (NotNull[3])
     {
         STR.tempAmbiente.Add(null);
     }
     else
     {
         STR.tempAmbiente.Add(dadosAgroup[3] / contadores[3]);
     }
     if (NotNull[4])
     {
         STR.humidSolo.Add(null);
     }
     else
     {
         STR.humidSolo.Add(dadosAgroup[4] / contadores[4]);
     }
     if (NotNull[5])
     {
         STR.humidAmbiente.Add(null);
     }
     else
     {
         STR.humidAmbiente.Add(dadosAgroup[5] / contadores[5]);
     }
     zeraVetores(dadosAgroup, contadores, NotNull);
 }
 public static void AddHistoryEntry(
     this CarePackage package, string description,
     HistoryStatus status = HistoryStatus.PackageInformation, string moreInformation = null)
 {
     package.Histories.Add(new CarePackageHistory
     {
         Status                 = status,
         Description            = description,
         RequestMoreInformation = moreInformation
     });
 }
Esempio n. 5
0
 /// <summary></summary>
 public static async Task InsertAsync(
     IDb db,
     IDbConnection connection,
     IDbTransaction transaction,
     Guid readerId,
     int employeeId,
     HistoryStatus status)
 {
     await connection.ExecuteAsync(
         sql :         "insert into histories(reader_id, employee_id, status) values(@readerId, @employeeId, @status);",
         transaction : transaction,
         param :       new { readerId = readerId, employeeId = employeeId, status = status });
 }
Esempio n. 6
0
 /// <summary>
 /// Converts the gazette operation into a entity history entry.
 /// </summary>
 /// <returns>Corresponding history entry.</returns>
 public override HistoryEntryBase ConvertToHistory()
 {
     if (this.old == EntityType.SaphaTambon && this.@new == EntityType.TAO)
     {
         var historyCreate = new HistoryCreate();
         historyCreate.type = this.@new;
         return(historyCreate);
     }
     else
     {
         var historyStatus = new HistoryStatus();
         historyStatus.old  = this.old;
         historyStatus.@new = this.@new;
         return(historyStatus);
     }
 }
Esempio n. 7
0
        public async Task <IActionResult> Edit(RepairUpdateDTO repairUpdateDTO)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Repair repair = await _repairService.GetAsync(repairUpdateDTO.Id);

                    if (repair != null)
                    {
                        HistoryStatus historyStatus = new HistoryStatus
                        {
                            Date           = DateTime.Now,
                            RepairId       = repair.Id,
                            RepairStatusId = repair.RepairStatusId,
                            Result         = repair.Result
                        };
                        await _historyStatusService.CreateAsync(historyStatus);

                        repair.MasterId       = repairUpdateDTO.MasterId;
                        repair.OwnerId        = repairUpdateDTO.OwnerId;
                        repair.RepairStatusId = repairUpdateDTO.RepairStatusId;
                        repair.Result         = repairUpdateDTO.Result;
                        repair.Сause          = repairUpdateDTO.Сause;

                        var result = await _repairService.UpdateAsync(repair);

                        if (result == -1)
                        {
                            await GetSelected();

                            ModelState.AddModelError("", "Error update");
                            return(View(repairUpdateDTO));
                        }
                        return(RedirectToAction("Index"));
                    }
                }
                await GetSelected();

                return(View(repairUpdateDTO));
            }
            catch (Exception ex)
            {
                return(View("Error", ex));
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Creates a history record from the given working record and status.
 /// </summary>
 /// <param name="working">The working record to create the history record for.</param>
 /// <param name="status">The status to create the history record with.</param>
 /// <returns>A history record.</returns>
 internal static HistoryRecord CreateHistory(WorkingRecord working, HistoryStatus status)
 {
     return(new HistoryRecord()
     {
         ApplicationName = working.ApplicationName,
         Data = working.Data,
         FinishedOn = DateTime.UtcNow,
         JobName = working.JobName,
         JobType = working.JobType,
         QueuedOn = working.QueuedOn,
         QueueName = working.QueueName,
         ScheduleId = working.ScheduleId,
         StartedOn = working.StartedOn,
         Status = status,
         TryNumber = working.TryNumber,
         WorkerId = working.WorkerId
     });
 }
Esempio n. 9
0
 /// <summary></summary>
 public static async Task InsertByTagIdAsync(
     IDb db,
     IDbConnection connection,
     IDbTransaction transaction,
     Guid readerId,
     string tagId,
     HistoryStatus status)
 {
     await connection.ExecuteAsync(
         sql :         "insert into histories(reader_id, employee_id, status) select @readerId, id, @status from employees where tag_id = @tagId limit 1;",
         transaction : transaction,
         param :       new {
         readerId = readerId,
         tagId    = tagId,
         status   = status
     }
         );
 }
Esempio n. 10
0
        public void HistoryStatusTest()
        {
            // Arrange
            int      random  = new Random().Next(111);
            int      random2 = new Random().Next(111);
            DateTime now     = DateTime.Now;
            // Act
            HistoryStatus     historyStatus = this.CreateHistoryStatus();
            StatusInformation StatusOrder   = new StatusInformation();

            StatusOrder.Id            = random;
            historyStatus.Id          = random;
            historyStatus.Created     = now;
            historyStatus.StatusOrder = StatusOrder;
            // Assert
            Assert.IsTrue(historyStatus.Id == random);
            Assert.IsTrue(historyStatus.Created == now);
            Assert.IsTrue(historyStatus.StatusOrder.Id == StatusOrder.Id);
        }
Esempio n. 11
0
        public async Task <IActionResult> Edit(RepairUpdateDTO repairUpdateDTO)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                Repair repair = await _repairService.GetAsync(repairUpdateDTO.Id);

                if (repair != null)
                {
                    HistoryStatus historyStatus = new HistoryStatus
                    {
                        Date           = DateTime.Now,
                        RepairId       = repair.Id,
                        RepairStatusId = repair.RepairStatusId,
                        Result         = repair.Result
                    };
                    await _historyStatusService.CreateAsync(historyStatus);

                    repair.MasterId       = repairUpdateDTO.MasterId;
                    repair.OwnerId        = repairUpdateDTO.OwnerId;
                    repair.RepairStatusId = repairUpdateDTO.RepairStatusId;
                    repair.Result         = repairUpdateDTO.Result;
                    repair.Сause          = repairUpdateDTO.Сause;

                    var result = await _repairService.UpdateAsync(repair);

                    if (result == -1)
                    {
                        return(BadRequest("Error update"));
                    }
                    return(Ok(repair));
                }
                return(BadRequest("Error update"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 12
0
        async void AddHistoryFrom(string selected_path, int skip_count)
        {
            if (_gitRepository.TryGetTarget(out IGitRepository gitRepository) == false)
            {
                return;
            }
            var waiter  = gitRepository.GetGitWrapper().GetHistory(selected_path, skip_count, /*max_count=*/ 20);
            var commits = await waiter;

            foreach (var commit in commits)
            {
                HistoryStatus status = new HistoryStatus();
                status.Graph         = commit.Graph;
                status.LocalDateTime = commit.LocalTimeDate;
                if (commit.Sha != null)
                {
                    status.CommitId = commit.Sha.Substring(0, 7);
                }
                else
                {
                    status.CommitId = null;
                }
                status.Sha     = commit.Sha;
                status.Author  = commit.Author;
                status.Message = commit.Message;
                status.ListMessage_RefNames = commit.RefNames?.Trim();
                status.ListMessage          = status.Message;
                status.Comment = commit.Message;
                status.Detail  = MakeDetail(commit);
                status.historyTabViewModel_ = this;
                status.FontWeight           = FontWeights.Normal;
                if (commit.RefNames != null && commit.RefNames.Contains(string.Format("HEAD -> {0}", CurrentBranchName)))
                {
                    status.FontWeight = FontWeights.Bold;
                }
                HistoryList.Add(status);
            }

            NotifyPropertyChanged("HistoryList");
        }
Esempio n. 13
0
        /// <summary>
        /// Revert to this version
        /// </summary>
        /// <param name="obj"></param>
        private void DoRevertToThisRevisionCommand(object obj)
        {
            if (null != SelectedHistoryRow)
            {
                var svnManager = _editSite.Host.GetSharedExportedValue <SvnManagerPlugin>();
                var success    = svnManager.ReverseMerge(FilePath, HistoryStatus.First().Revision, SelectedHistoryRow.Revision);
                var debugHost  = _editSite.Host.GetSharedExportedValue <IDebugHost>();
                if (success)
                {
                    ////TODO: needs to be addressed before go live
                    ////This will revert a file once, but you have to close and reopen in order to revert the same file a second time.
                    ////If open, you also have to manually close the file and reopen to see the reversion.
                    //var referencedFile = envoy.GetReferencedFileService();
                    //referencedFile.RefreshReferencedFileAsync();

                    debugHost.LogMessage(new DebugMessage("Svn", DebugMessageSeverity.Information, $"Revert to revision {SelectedHistoryRow.Revision} {FilePath}"));
                }
                else
                {
                    debugHost.LogMessage(new DebugMessage("Svn", DebugMessageSeverity.Error, $"Failed to revert revision {SelectedHistoryRow.Revision} {FilePath}"));
                }
            }
        }
Esempio n. 14
0
        private unsafe void UpdateInternal(ClusterOperationContext context, string guid, string type, long index, long term, HistoryStatus status, object result, Exception exception)
        {
            var table = context.Transaction.InnerTransaction.OpenTable(LogHistoryTable, LogHistorySlice);

            TableValueReader reader;

            using (Slice.From(context.Allocator, guid, out var guidSlice))
            {
                if (table.ReadByKey(guidSlice, out reader) == false)
                {
                    return;
                }
            }

            if (TypeConverter.IsSupportedType(result) == false)
            {
                throw new RachisApplyException("We don't support type " + result.GetType().FullName + ".");
            }

            using (Slice.From(context.Allocator, guid, out var guidSlice))
                using (Slice.From(context.Allocator, type, out var typeSlice))
                    using (table.Allocate(out TableValueBuilder tvb))
                    {
                        tvb.Add(guidSlice);
                        tvb.Add(Bits.SwapBytes(index));
                        tvb.Add(Bits.SwapBytes(GetUniqueTicks(context.Transaction.InnerTransaction)));
                        tvb.Add(*(long *)reader.Read((int)(LogHistoryColumn.Term), out _));
                        tvb.Add(term);
                        tvb.Add(typeSlice);
                        tvb.Add((byte)status);
                        if (result == null)
                        {
                            tvb.Add(Slices.Empty);
                        }
                        else
                        {
                            var blittableResult = context.ReadObject(new DynamicJsonValue {
                                ["Result"] = result
                            }, "set-history-result");
                            tvb.Add(blittableResult.BasePointer, blittableResult.Size);
                        }

                        if (exception == null)
                        {
                            tvb.Add(Slices.Empty);
                            tvb.Add(Slices.Empty);
                        }
                        else
                        {
                            var exceptionType = context.GetLazyString(exception.GetType().AssemblyQualifiedName);
                            var exceptionMsg  = context.GetLazyString(exception.ToString());
                            tvb.Add(exceptionType.Buffer, exceptionType.Size);
                            tvb.Add(exceptionMsg.Buffer, exceptionMsg.Size);
                        }

                        table.Set(tvb);
                    }
        }
        public static HistoryChange Create(Guid?inRequestId, Guid?outRequestId, Guid?adjustmentId, Guid assetId, string nameAsset, double stockAsset, double price,
                                           Guid creatorid, DateTime createDateTime, string companyName, double previousQty, HistoryStatus status)
        {
            var @historyChange = new HistoryChange
            {
                Id            = Guid.NewGuid(),
                InRequestId   = inRequestId,
                OutRequestId  = outRequestId,
                AdjustmentId  = adjustmentId,
                AssetId       = assetId,
                NameAsset     = nameAsset,
                StockAsset    = stockAsset,
                PreviousQty   = previousQty,
                Status        = status,
                Price         = price,
                CreationTime  = createDateTime,
                CreatorUserId = creatorid,
                CompanyName   = companyName,
                Url           = "",
                IsDeleted     = false
            };

            return(@historyChange);
        }
Esempio n. 16
0
        /// <summary>
        /// 一定時間経過後のタグ情報を処理
        /// 3[s] 以上検出されなかったタグを処理
        /// </summary>
        private static async void OnIntervalTimerElapsed(object source, System.Timers.ElapsedEventArgs e)
        {
            KeyValuePair <string, List <TagInfo> >[] targets;

            lock (oLock) {
                targets = tagBuffer
                          .Where(kvp => (DateTime.Now - kvp.Value.Max(info => info.DetectedAt)).TotalSeconds >= 3)
                          .ToArray();

                foreach (var target in targets)
                {
                    // 最大検出時刻から 3[s] 以上経過したタグ情報をバッファから削除を行い.
                    // 必要な処理を行う.

                    // タグ情報の削除
                    tagBuffer.Remove(target.Key);

#if DEBUG
                    Console.Error.WriteLine($"Debug  deleted {target.Key}, number of infos #{target.Value.Count}");
#endif
                }
            }

            var readerId = readerSettings?.Id;
            if (readerId == null)
            {
                return;
            }


            // XXX
            // 極端にデータが少ないものは対象外
            foreach (var target in targets.Where(t => t.Value.Count >= 4))
            {
                // NOTE: リーダに接続するアンテナが互いに干渉しない環境下を想定.
                // より正確に検出を行わせる場合は, List 内のデータを正常に処理させる必要がある.
                var firstStatus = insideNumbers.Any(value => (ushort)value == target.Value.First().AntennaId)
          ? InOutStatus.Inside
          : InOutStatus.Outside;

                var lastStatus = outsideNumbers.Any(value => (ushort)value == target.Value.Last().AntennaId)
          ? InOutStatus.Outside
          : InOutStatus.Inside;

                // 入退室状態が同値でない場合が正常.
                // 入口, 出口付近を通過した際にどちらか一方のみで検出される可能性がある.
                if (firstStatus != lastStatus)
                {
                    HistoryStatus historyStatus = (firstStatus == InOutStatus.Inside)
            ? HistoryStatus.Leaving // 内側から先に検出し, 外側へ状態の遷移: 退室
            : HistoryStatus.Entry;  // 外側から先に検出し, 内側へ状態の遷移: 入室

                    // データ追加処理
                    try {
#if DEBUG
                        Console.Error.WriteLine($"Debug Reader:{readerId.Value}, Tag: {target.Key}, Status:{historyStatus}");
#endif

                        await entleaving.Db.DAO.History.InsertByTagIdAsync(
                            readerId : readerId.Value,
                            tagId :    target.Key,
                            status :   historyStatus);
                    } catch (Exception except) {
                        Console.Error.WriteLine($"Debug {except.GetType().Name} {except.Message} {except.StackTrace}");
                    }
                }
            }
        }
Esempio n. 17
0
        private unsafe void UpdateInternal(ClusterOperationContext context, BlittableJsonReaderObject cmd, string guid, string type, long index, long term, HistoryStatus status, object result, Exception exception)
        {
            var table = context.Transaction.InnerTransaction.OpenTable(LogHistoryTable, LogHistorySlice);

            TableValueReader reader;

            using (Slice.From(context.Allocator, guid, out var guidSlice))
            {
                if (table.ReadByKey(guidSlice, out reader) == false)
                {
                    return;
                }
            }

            if (TypeConverter.IsSupportedType(result) == false)
            {
                throw new RachisApplyException("We don't support type " + result.GetType().FullName + ".");
            }

            var ticks = GetUniqueTicks(context.Transaction.InnerTransaction);

            if (RachisStateMachine.EnableDebugLongCommit)
            {
                var previous = Bits.SwapBytes(*(long *)reader.Read((int)(LogHistoryColumn.Ticks), out _));
                var diff     = TimeSpan.FromTicks(ticks - previous);
                if (diff > TimeSpan.FromSeconds(2))
                {
                    Console.WriteLine($"Command {type} at index:{index}, term:{term} took {diff} to commit (result:{result}, exception:{exception}){Environment.NewLine}{cmd}");
                }
            }
            using (Slice.From(context.Allocator, guid, out var guidSlice))
                using (Slice.From(context.Allocator, type, out var typeSlice))
                    using (table.Allocate(out TableValueBuilder tvb))
                    {
                        tvb.Add(guidSlice);
                        tvb.Add(Bits.SwapBytes(index));
                        tvb.Add(Bits.SwapBytes(ticks));
                        tvb.Add(*(long *)reader.Read((int)(LogHistoryColumn.Term), out _));
                        tvb.Add(term);
                        tvb.Add(typeSlice);
                        tvb.Add((byte)status);
                        if (result == null)
                        {
                            tvb.Add(Slices.Empty);
                        }
                        else
                        {
                            var blittableResult = context.ReadObject(new DynamicJsonValue {
                                ["Result"] = result
                            }, "set-history-result");
                            tvb.Add(blittableResult.BasePointer, blittableResult.Size);
                        }

                        if (exception == null)
                        {
                            tvb.Add(Slices.Empty);
                            tvb.Add(Slices.Empty);
                        }
                        else
                        {
                            var exceptionType = context.GetLazyString(exception.GetType().AssemblyQualifiedName);
                            var exceptionMsg  = context.GetLazyString(exception.ToString());
                            tvb.Add(exceptionType.Buffer, exceptionType.Size);
                            tvb.Add(exceptionMsg.Buffer, exceptionMsg.Size);
                        }

                        table.Set(tvb);
                    }
        }
Esempio n. 18
0
 /// <summary>
 /// Creates a history record from the given working record and status.
 /// </summary>
 /// <param name="working">The working record to create the history record for.</param>
 /// <param name="status">The status to create the history record with.</param>
 /// <returns>A history record.</returns>
 internal static HistoryRecord CreateHistory(WorkingRecord working, HistoryStatus status)
 {
     return new HistoryRecord()
     {
         ApplicationName = working.ApplicationName,
         Data = working.Data,
         FinishedOn = DateTime.UtcNow,
         JobName = working.JobName,
         JobType = working.JobType,
         QueuedOn = working.QueuedOn,
         QueueName = working.QueueName,
         ScheduleId = working.ScheduleId,
         StartedOn = working.StartedOn,
         Status = status,
         TryNumber = working.TryNumber,
         WorkerId = working.WorkerId
     };
 }
Esempio n. 19
0
        internal void RunLoop()
        {
            while (true)
            {
                bool          working = false, needsRest = true;
                WorkingRecord record = null;
                IJob          job    = null;
                Exception     ex     = null;

                try
                {
                    // Find out if we're supposed to be doing work.
                    lock (this.statusLocker)
                    {
                        working = this.Status == WorkerStatus.Working;
                    }

                    if (working)
                    {
                        // Dequeue a new job to work on.
                        record = this.DequeueRecord();

                        // If a record exists, we have work to do.
                        if (record != null)
                        {
                            // Try to de-serialize a job.
                            try
                            {
                                job = JobSerializer.Deserialize(record.JobType, record.Data);
                                this.logger.Debug("Worker {0} ({1}) de-serialized a job instance for '{2}'.", this.name, this.id, record.JobType);
                            }
                            catch (Exception sx)
                            {
                                ex = sx;
                                this.logger.Warn("Worker {0} ({1}) failed to de-serialize a job instane for '{2}'.", this.name, this.id, record.JobType);
                            }

                            // If we failed to de-serialize, fail the job.
                            if (job == null)
                            {
                                HistoryRecord history = CreateHistory(record, HistoryStatus.Failed);

                                if (ex != null)
                                {
                                    history.Exception = new ExceptionXElement(ex).ToString();
                                }

                                using (IRepository repository = this.repositoryFactory.Create())
                                {
                                    using (IDbTransaction transaction = repository.BeginTransaction())
                                    {
                                        repository.DeleteWorking(record.Id.Value, transaction);
                                        history = repository.CreateHistory(history, transaction);
                                        transaction.Commit();
                                    }
                                }
                            }
                            else
                            {
                                // Update this instance's current record so we can interrupt
                                // execution if necessary.
                                lock (this.runLocker)
                                {
                                    this.currentRecord = record;
                                }

                                // Execute the job.
                                bool success = this.ExecuteJob(job, out ex);

                                // Acquire the run lock and move the job from the working
                                // state to the history state, including the execution results.
                                lock (this.runLocker)
                                {
                                    HistoryStatus status          = HistoryStatus.Succeeded;
                                    string        exceptionString = null;

                                    if (success)
                                    {
                                        this.logger.Info("Worker {0} ({1}) executed '{2}' successfully.", this.name, this.id, this.currentRecord.JobName);
                                    }
                                    else
                                    {
                                        if (ex as TimeoutException != null)
                                        {
                                            status = HistoryStatus.TimedOut;
                                            this.logger.Warn("Worker {0} ({1}) timed out '{2}'.", this.name, this.id, this.currentRecord.JobName);
                                        }
                                        else
                                        {
                                            status = HistoryStatus.Failed;

                                            if (ex != null)
                                            {
                                                exceptionString = new ExceptionXElement(ex).ToString();
                                            }

                                            this.logger.Warn("Worker {0} ({1}) encountered an exception during execution of '{2}'.", this.name, this.id, this.currentRecord.JobName);
                                        }
                                    }

                                    HistoryRecord history = CreateHistory(this.currentRecord, status);
                                    history.Exception = exceptionString;

                                    using (IRepository repository = this.repositoryFactory.Create())
                                    {
                                        using (IDbTransaction transaction = repository.BeginTransaction())
                                        {
                                            repository.DeleteWorking(this.currentRecord.Id.Value, transaction);
                                            history = repository.CreateHistory(history, transaction);

                                            // Re-try?
                                            if ((status == HistoryStatus.Failed ||
                                                 status == HistoryStatus.Interrupted ||
                                                 status == HistoryStatus.TimedOut) &&
                                                (job.Retries == 0 || job.Retries >= this.currentRecord.TryNumber))
                                            {
                                                repository.CreateQueued(CreateQueueRetry(this.currentRecord), transaction);
                                            }

                                            transaction.Commit();
                                        }
                                    }

                                    this.currentRecord = null;
                                }
                            }

                            needsRest = false;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception rx)
                {
                    this.logger.Error(rx, "Exception thrown during the run loop for worker {0} ({1}).", this.name, this.id);
                }

                if (working)
                {
                    // Take a breather real quick.
                    if (needsRest)
                    {
                        this.logger.Debug("Worker {0} ({1}) is resting before trying to de-queue another job.", this.name, this.id);
                        Thread.Sleep(this.heartbeat.Randomize());
                    }
                    else
                    {
                        this.logger.Debug("Worker {0} ({1}) will immediately try to de-queue another job.", this.name, this.id);
                    }
                }
            }
        }
Esempio n. 20
0
        void AddHistoryFrom(string selected_path, Int32 skip_count)
        {
            var commits = git_.GetHistory(selected_path, skip_count, /*max_count=*/20);

            foreach (var commit in commits)
            {
                HistoryStatus status = new HistoryStatus();
                status.Graph = commit.Graph;
                status.LocalDateTime = commit.LocalTimeDate;
                if (commit.Sha != null)
                {
                    status.CommitId = commit.Sha.Substring(0, 7);
                }
                else
                {
                    status.CommitId = null;
                }
                status.Sha = commit.Sha;
                status.Author = commit.Author;
                status.Message = commit.Message;
                status.ListMessage = commit.RefNames + " " + status.Message;
                status.Comment = commit.Message;
                status.Detail = MakeDetail(commit);
                status.IsSelected = false;
                status.view_model_ = this;

                HistoryList.Add(status);
            }

            PropertyChanged(this, new PropertyChangedEventArgs("HistoryList"));
        }
Esempio n. 21
0
        public async Task ShouldChangePackageStatus(string endpoint, PackageStatus packageStatus, HistoryStatus historyStatus)
        {
            var package = packageStatus == PackageStatus.Approved ? _generator.CreateCarePackage(status: PackageStatus.SubmittedForApproval) : _generator.CreateCarePackage();

            var request = new CarePackageChangeStatusRequest
            {
                Notes = "Test"
            };

            var response = await _fixture.RestClient
                           .PostAsync <CarePackagePlainResponse>($"api/v1/care-packages/{package.Id}/{endpoint}", request);

            package = _fixture.DatabaseContext.CarePackages
                      .FirstOrDefault(p => p.Id == package.Id);
            var carePackageHistory = _fixture.DatabaseContext.CarePackageHistories
                                     .FirstOrDefault(h => h.CarePackageId == package.Id);

            response.Message.StatusCode.Should().Be(HttpStatusCode.OK);

            package?.Should().NotBeNull();
            package?.Status.Should().Be(packageStatus);

            carePackageHistory?.Should().NotBeNull();
            carePackageHistory?.Description.Should().Be(historyStatus.GetDisplayName());
            carePackageHistory?.RequestMoreInformation.Should().Be(request.Notes);
            carePackageHistory?.Status.Should().Be(historyStatus);
        }
Esempio n. 22
0
 public async Task <int> UpdateAsync(HistoryStatus historyStatus)
 {
     return(await _historyStatusRepository.UpdateAsync(historyStatus));
 }