private void btn_updatelate_Click(object sender, RoutedEventArgs e) { ContentUpdate.Hide(); Thread thread = new Thread(TestConnect); thread.Start(); }
void CheckForUpdates() { Thread.Sleep(1500); Dispatcher.Invoke(() => ContentCheckingUpdate.ShowAsync()); WebClient web = new WebClient(); try { string Act = web.DownloadString("https://raw.githubusercontent.com/TheCrazyWolf/RegistrantCore/master/Registrant/ActualVer.txt"); string ActualText = web.DownloadString("https://raw.githubusercontent.com/TheCrazyWolf/RegistrantCore/master/Registrant/ActualTextDesc.txt"); Act = Act.Replace("\n", ""); Act = Act.Replace(".", ","); string currentstring = Settings.App.Default.AppVersion; currentstring = currentstring.Replace(".", ","); decimal Current = decimal.Parse(currentstring); decimal Actual = decimal.Parse(Act); Dispatcher.Invoke(() => ContentCheckingUpdate.Hide()); if (Actual > Current) { Dispatcher.Invoke(() => ContentUpdate.ShowAsync()); Dispatcher.Invoke(() => txt_currver.Text = Current.ToString()); Dispatcher.Invoke(() => txt_newver.Text = Act.ToString()); Dispatcher.Invoke(() => txt_desc.Text = ActualText); string CanRefuse = web.DownloadString("https://raw.githubusercontent.com/TheCrazyWolf/RegistrantCore/master/Registrant/ActualVerCanRefuse.txt"); CanRefuse = CanRefuse.Replace("\n", ""); if (CanRefuse == "No") { Dispatcher.Invoke(() => btn_updatelate.Visibility = Visibility.Hidden); Dispatcher.Invoke(() => txt_desc.Text = txt_desc.Text + "\n\nЭто обновление нельзя отложить, т.к. содержит\nкритические правки в коде"); Dispatcher.Invoke(() => ContentUpdate.Background = new SolidColorBrush(Color.FromRgb(255, 195, 195))); } } else { TestConnect(); } } catch (Exception ex) { Dispatcher.Invoke(() => ContentCheckingUpdate.Hide()); TestConnect(); } }
public async Task <IActionResult> UpdateContentStatus(ContentUpdate contentUpdate) { try { VerifierDataAccess _verifierDataAccess = new VerifierDataAccess(_configuration); DatabaseResponse response = await _verifierDataAccess.UpdateContentStatus(contentUpdate); if (response.ResponseCode == (int)DbReturnValue.UpdateSuccess) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.UpdateSuccess), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.UpdationFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.NotExists), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public async Task <DatabaseResponse> UpdateContentStatus(ContentUpdate contentUpdate) { try { SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.Int), new SqlParameter("@ContentId", SqlDbType.Int), new SqlParameter("@ContentType", SqlDbType.Int), new SqlParameter("@Status", SqlDbType.Int) }; parameters[0].Value = contentUpdate.UserId; parameters[1].Value = contentUpdate.ContentId; parameters[2].Value = contentUpdate.ContentType; parameters[3].Value = contentUpdate.Status; _DataHelper = new DataAccessHelper("spu_ContentStatus", parameters, _configuration); DataTable dt = new DataTable(); int result = await _DataHelper.RunAsync(dt); return(new DatabaseResponse { ResponseCode = result, Results = null }); } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); throw; } finally { _DataHelper.Dispose(); } }
private IEnumerable <UpdateWithTargetContainer <ContentType, ItemType> > getOldItemUpdateContainerIterator(ICollectionChange <ItemType, ContentType> change) { if (change.Action == NotifyCollectionChangedAction.Replace) { var oldItems = change.OldItems ?? throw new ArgumentException("The old item-item-items were not given that can be processed as collection change"); var newItems = change.NewItems ?? throw new ArgumentException("The new item-item-items were not given that can be processed as collection change"); var oldItemsEnumerator = oldItems.GetEnumerator(); var newItemsEnumerator = newItems.GetEnumerator(); while (oldItemsEnumerator.MoveNext() && newItemsEnumerator.MoveNext()) { var oldItem = oldItemsEnumerator.Current; var newItem = newItemsEnumerator.Current; var oldItemUpdate = new ContentUpdate <ContentType>(newItem, this); var oldItemUpdateContainer = new UpdateWithTargetContainer <ContentType, ItemType>(oldItemUpdate, oldItem); yield return(oldItemUpdateContainer); } } }
public UpdateWithTargetContainer(ContentUpdate <UpdateContentType> update, TargetType target) { Update = update; Target = target; }