public static ComponentProperty <StatusValues.Values> Deserialize(this IValue <StatusValues.Values> property, string value, List <PropertyParameter> parameters) { ((ComponentProperty <StatusValues.Values>)property).PropertyParameters = parameters; property.Value = StatusValues.ConvertValue(value.RemoveSpaces()); return((ComponentProperty <StatusValues.Values>)property); }
public RotatingStatusService(BaseSocketClient socket, Queue <string> statuses = null) { StatusValues = statuses ?? new Queue <string>(); Socket = socket; rotationTimer = new Timer(async _ => { if (StatusValues.Count <= 0) { return; } var status = StatusValues.Dequeue(); if (status.EqualsIgnoreCase(Socket.Activity?.Name ?? "")) { return; } StatusValues.Enqueue(status); await Socket.SetGameAsync(await VariableFormatting.FormatStatus(Socket, status)); }, null, Timeout.Infinite, Timeout.Infinite); }
public Appointment(DateTime dateAndTime, PatientInfo patient, PatientInfo careGiver, StatusValues val) { DateTime = dateAndTime; Status = val; PatientHCN = patient; CareGiverHCN = careGiver; BillingCodes = new List <string>(); }
public void AddStatus(string status) { if (string.IsNullOrWhiteSpace(status)) { return; } StatusValues.Enqueue(status); }
// alternate constructor public AppointmentRecord(string patient, bool caregiver, DateTime date, TimeSpan time, StatusValues stat) { PatientHCN = patient; Caregiver = caregiver; AppointmentDate = date; AppointmentTime = time; Status = stat; }
} // the appointment status (see enum) // default constructor public AppointmentRecord() { PatientHCN = ""; Caregiver = false; AppointmentDate = DateTime.MinValue; AppointmentTime = TimeSpan.MinValue; Status = StatusValues.AVAILABLE; }
public GraphData(GraphData Original) { void Clone(object CloneFrom, CloneType cloneType) { switch (cloneType) { case CloneType.Status: { if (CloneFrom is ObservableCollection <int> cf) { foreach (int status in cf) { StatusValues.Add(status); } } break; } case CloneType.Latency: { if (CloneFrom is ObservableCollection <int> cf) { foreach (int latency in cf) { LatencyValues.Add(latency); } } break; } case CloneType.TimeStamps: { if (CloneFrom is ObservableCollection <DateTime> cf) { foreach (DateTime dt in cf) { TimeStamps.Add(new DateTime(dt.Ticks)); } } break; } } } GroupName = Original.GroupName; Label = Original.Label; FromHost = Original.FromHost; ToHost = Original.ToHost; Clone(Original.TimeStamps, CloneType.TimeStamps); Clone(Original.StatusValues, CloneType.Status); Clone(Original.LatencyValues, CloneType.Latency); }
private async void Submit() { var hasValidationErrors = ValidateProperties(new Dictionary <string, object>() { { nameof(OrderID), OrderID }, { nameof(OrderDate), OrderDate }, { nameof(OrderTime), OrderTime }, { nameof(Company), Company }, { nameof(Symbol), Symbol }, { nameof(OrderTotal), OrderTotal }, { nameof(Freight), Freight }, { nameof(Status), Status }, { nameof(ShipperName), ShipperName }, { nameof(ShipperPhone), ShipperPhone }, { nameof(ShipTo), ShipTo } }); if (hasValidationErrors) { return; } await _sampleDataService.SaveOrderAsync(new SampleOrder() { OrderID = OrderID, OrderDate = new DateTime(OrderDate.Year, OrderDate.Month, OrderDate.Day, OrderTime.Hours, OrderTime.Minutes, OrderTime.Seconds), ShipperName = ShipperName, ShipperPhone = ShipperPhone, Company = Company, ShipTo = ShipTo, OrderTotal = double.Parse(OrderTotal), Status = Status, Freight = double.Parse(Freight), SymbolCode = Symbol }); // Set default values OrderID = default; OrderDate = DateTime.Now; OrderTime = DateTime.Now.TimeOfDay; ShipperName = string.Empty; ShipperPhone = string.Empty; Company = string.Empty; ShipTo = string.Empty; OrderTotal = default; Freight = default; Status = StatusValues.First(); Symbol = SymbolValues.First(); ClearErrors(); }
/// <summary> /// Call this the method when u want the representation in string of the /// Components properties classes /// </summary> /// <param name="property"></param> /// <returns></returns> public static string StringRepresentation <T>(this ComponentProperty <T> property) { var strBuilder = new StringBuilder(property.Name); foreach (var proParam in property.PropertyParameters) { strBuilder.Append(";"); strBuilder.Append(proParam.Name + "=" + proParam.Value); } strBuilder.Append(":"); if (property is IValue <string> ) { strBuilder.Append(((IValue <string>)property).Value); } else if (property is IValue <IList <string> > ) { var flag = false; foreach (var cat in ((IValue <IList <string> >)property).Value) { if (flag) { strBuilder.Append(','); } strBuilder.Append(cat); flag = true; } } else if (property is IValue <ClassificationValues.ClassificationValue> ) { strBuilder.Append( ClassificationValues.ToString(((IValue <ClassificationValues.ClassificationValue>)property).Value)); } else if (property is IValue <int> ) { strBuilder.Append(((IValue <int>)property).Value); } else if (property is IValue <StatusValues.Values> ) { strBuilder.Append(StatusValues.ToString(((IValue <StatusValues.Values>)property).Value)); } else if (property is IValue <TransparencyValues.TransparencyValue> ) { strBuilder.Append( TransparencyValues.ToString(((IValue <TransparencyValues.TransparencyValue>)property).Value)); } else if (property is IValue <DateTime> ) { var propValue = ((IValue <DateTime>)property).Value; if ( property.PropertyParameters.Count( propertyParameter => propertyParameter.Name == "VALUE" && propertyParameter.Value == "DATE") == 1) { strBuilder.Append(propValue.ToString("yyyyMMdd")); } else { strBuilder.Append(propValue.ToString("yyyyMMddTHHmmss") + (propValue.Kind == DateTimeKind.Utc ? "Z" : "")); } } else if (property is IValue <ActionValues.ActionValue> ) { strBuilder.Append(ActionValues.ToString(((IValue <ActionValues.ActionValue>)property).Value)); } else if (property is IValue <DurationType> ) { strBuilder.Append(((IValue <DurationType>)property).Value); } else if (property is IValue <Period> ) { strBuilder.Append(((IValue <Period>)property).Value); } else if (property is IValue <TimeSpan> ) { strBuilder.Append(((IValue <TimeSpan>)property).Value.ToStringOffset()); } else if (property is IValue <Recur> ) { strBuilder.Append(((IValue <Recur>)property).Value); } else if (property is IValue <IList <DateTime> > ) { var values = ((IValue <IList <DateTime> >)property).Value; var flag = false; var isDate = property.PropertyParameters.Count( propertyParameter => propertyParameter.Name == "VALUE" && propertyParameter.Value == "DATE") == 1; foreach (var value in values) { if (flag) { strBuilder.Append(','); } if (isDate) { strBuilder.Append(value.ToString("yyyyMMdd")); } else { strBuilder.Append(value.ToString("yyyyMMddTHHmmss") + (value.Kind == DateTimeKind.Utc ? "Z" : "")); } flag = true; } } return(strBuilder.SplitLines().ToString()); }
/// <summary> /// updates specified item's description and status if changed /// </summary> /// <param name="itemDto"></param> /// <returns>updated DTO</returns> public async Task <TodoItemDto> UpdateItemAsync(TodoItemDto itemDto) { _logger.LogInformation($"In {nameof(UpdateItemAsync)}"); Guard.NotNull(itemDto, nameof(itemDto)); try { var updateStatus = !string.IsNullOrEmpty(itemDto.CurrentStatus); var updateDescription = !string.IsNullOrEmpty(itemDto.Description); using (var context = TodoContextFactory.Create()) { // try to get requesetd item var todoItem = await context.ToDoItems.FirstOrDefaultAsync(i => i.ItemId == itemDto.ItemId); if (todoItem == null) { throw new ItemNotExistsException(itemDto.ItemId, "Failed to update to-do item."); } // check if discription is changed if (updateDescription && !todoItem.Description.Equals(itemDto.Description, StringComparison.CurrentCultureIgnoreCase)) { todoItem.Description = itemDto.Description; } // check if status has changed if (updateStatus) { // check if new status is valid if (!StatusValues.IsValid(itemDto.CurrentStatus)) { throw new InvalidStatusException(itemDto.CurrentStatus, "Failed to update to-do item status."); } // get current status string from to-do item entity, if exists var currentSavedStatus = string.Empty; if (todoItem.StatusHistory != null) { currentSavedStatus = todoItem.StatusHistory .OrderByDescending(s => s.StatusDateTime) .First() ?.Status; } // check if current saved status is the same as the new status, if not then update status if (string.IsNullOrEmpty(currentSavedStatus) || !currentSavedStatus.Equals(itemDto.CurrentStatus, StringComparison.OrdinalIgnoreCase)) { if (todoItem.StatusHistory == null) { todoItem.StatusHistory = new List <TodoItemStatus>(); } // add new status entry todoItem.StatusHistory.Add(new TodoItemStatus() { ItemId = todoItem.ItemId, Status = itemDto.CurrentStatus, StatusDateTime = DateTime.UtcNow }); } } // save changes await context.SaveChangesAsync(); // return updated to-do item return(todoItem.ToDto()); } } catch (Exception) { throw; } finally { _logger.LogInformation($"Out {nameof(UpdateItemAsync)}"); } }
internal static Status GetStatus(Entities edc, StatusValues value) { return(edc.Status.GetAtIndex <Status>((int)value)); }
public void UpdateStatus(StatusValues newStatus) { // Interface with DAL // throw if error occurs }
public FormViewModel(ISampleDataService sampleDataService) { _sampleDataService = sampleDataService; Status = StatusValues.First(); Symbol = SymbolValues.First(); }
public Task Disconnect() { Stop(); StatusValues.Clear(); return(Task.CompletedTask); }
public string[] GetStatuses() => StatusValues.ToArray();
public async Task <IActionResult> UpdatePost(PostModelEdit postModel) { //Validate value of the model. var post = new Post(); if (postModel != null && postModel.SelectedPost != null) { post = postModel.SelectedPost; } if (!ModelState.IsValid) { return(View("EditPost", postModel)); } //Get values from tempdata (it was set in the Edit action). //This values will no change them in the update process. var postModelData = TempData.Get <PostModelEdit>("postModelEdit"); if (postModelData != null) { post.AuthorId = postModelData.SelectedPost.AuthorId; post.EmailUser = postModelData.SelectedPost.EmailUser; post.Id = postModelData.SelectedPost.Id; post.PublishedDate = postModelData.SelectedPost.PublishedDate; post.UserName = postModelData.SelectedPost.UserName; TempData.Remove("postModelEdit"); } //prepare post. var user = await GetCurrentUserAsync(); post.StatusId = Convert.ToInt32(postModel.SelectedStatus); var status = new PostStatus() { Comment = postModel.Comment, Status = post.StatusId, StatusDescription = StatusValues.GetDescriptionFromValue(post.StatusId), UserId = new Guid(user.Id), StatusDate = DateTime.UtcNow }; post.Statuses = new List <PostStatus>() { status }; //Post message. using (var httpClient = new HttpClient()) { try { httpClient.BaseAddress = new Uri(apiRoutes.BaseUrl + apiRoutes.UpdatePostUrl); //HTTP PUT var postTask = await httpClient.PutAsJsonAsync <Post>("update", post); var result = postTask; if (result.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { ViewBag.Result = MessageValues.ServerError; ModelState.AddModelError(string.Empty, result.ReasonPhrase); return(View("EditPost", postModel)); //TODO: custom error page. } } catch (Exception ex) { ViewBag.Result = MessageValues.ServerError; ModelState.AddModelError(string.Empty, ex.Message); return(View("EditPost", postModel)); } } }