public void HandleError(ErrorBase errorToHandle) { if (errorToHandle != null) { Errors.Add(errorToHandle); } }
protected async Task SearchTextChanged() { var text = _tag.Text; if (_previousQuery == text || text.Length == 1) { return; } _previousQuery = text; _tagsList.ScrollToPosition(0); _tagPickerFacade.Clear(); ErrorBase error = null; if (text.Length == 0) { error = await _tagPickerFacade.TryGetTopTags(); } else if (text.Length > 1) { error = await _tagPickerFacade.TryLoadNext(text); } if (IsInitialized) { return; } Activity.ShowAlert(error); }
protected void ShowAlert(ErrorBase error) { if (error == null || error is CanceledError) { return; } var message = error.Message; if (string.IsNullOrWhiteSpace(message)) { return; } var lm = AppSettings.LocalizationManager; if (!lm.ContainsKey(message)) { if (error is BlockchainError blError) { AppSettings.Reporter.SendMessage($"New message: {blError.Message}{Environment.NewLine}{blError.FullMessage}"); } else { AppSettings.Reporter.SendMessage($"New message: {message}"); } message = nameof(LocalizationKeys.UnexpectedError); } var alert = UIAlertController.Create(null, Regex.Replace(message, @"[^\w\s-]", "", RegexOptions.None), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(AppSettings.LocalizationManager.GetText(LocalizationKeys.Ok), UIAlertActionStyle.Cancel, null)); PresentViewController(alert, true, null); }
public override List <byte> CreateNewProfile(profileNode node, string[] profile) { List <byte> newProfile = new List <byte>(profile.Length); for (int i = 0; i < profile.Length; i++) { string state = profile[i]; if (node.ContainsState(state)) { if (Convert.ToInt32(state, System.Globalization.CultureInfo.InvariantCulture) > 255) { state = "255"; } } if (node.ContainsState(state)) { newProfile.Add(node.GetCodedState(node.states[state], true)); } else { ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!"); } } return(newProfile); }
public static void ShowAlert(this Context context, ErrorBase error, ToastLength length) { if (error == null || error is CanceledError) { return; } var message = error.Message; if (string.IsNullOrWhiteSpace(message)) { return; } var lm = AppSettings.LocalizationManager; if (!lm.ContainsKey(message)) { if (error is BlockchainError blError) { AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(blError.Message)}{Environment.NewLine}Full Message:{blError.FullMessage}"); } else { AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(message)}"); } message = nameof(LocalizationKeys.UnexpectedError); } Toast.MakeText(context, lm.GetText(message), length).Show(); }
private async void SearchTextChanged() { if (_previousQuery == _tagField.Text || _tagField.Text.Length == 1) { return; } _tagField.Loader.StartAnimating(); _previousQuery = _tagField.Text; ErrorBase error = null; if (_tagField.Text.Length == 0) { error = await _presenter.TryGetTopTags(); } else if (_tagField.Text.Length > 1) { error = await _presenter.TryLoadNext(_tagField.Text, showUnknownTag : true); } if (!(error is CanceledError)) { _tagField.Loader.StopAnimating(); } ShowAlert(error); }
private async Task SearchTextChanged() { if (_previousQuery == _tag.Text || _tag.Text.Length == 1) { return; } _previousQuery = _tag.Text; _tagsList.ScrollToPosition(0); Presenter.Clear(); ErrorBase error = null; if (_tag.Text.Length == 0) { error = await Presenter.TryGetTopTags(); } else if (_tag.Text.Length > 1) { error = await Presenter.TryLoadNext(_tag.Text); } if (IsInitialized) { return; } Activity.ShowAlert(error); }
public string AddPDB(string fileName, PDBMODE flag, CHAIN_MODE flagChain = CHAIN_MODE.SINGLE) { string name = Path.GetFileName(fileName); if (molDic != null && molDic.ContainsKey(name)) { return(name); } try { MolData molD = new MolData(fileName, flag, mode, flagChain); if ((molD.mol == null || molD.mol.Chains == null || molD.mol.Chains.Count == 0)) { ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration it looks that it has wrong format"); return(null); } molDic.Add(name, molD); return(name); } catch (IncorrectSideChainException ex) { ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration because\n" + ex.Message); } catch (Exception ee) { ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration because\n" + ee.Message); } return(null); }
//Flag true only CA will be readed public MolData(string fileName, PDBMODE flag, INPUTMODE mode, CHAIN_MODE chainFlag = CHAIN_MODE.SINGLE) { using (StreamReader rr = new StreamReader(fileName)) { switch (mode) { case INPUTMODE.PROTEIN: mol = new Molecule(flag, chainFlag); break; case INPUTMODE.RNA: mol = new MoleculeRNA(flag); break; } bool res = mol.ReadMolecule(rr); if (!res) { return; } if (mol.Chains.Count == 0) { ErrorBase.AddErrors("Error in reading file: " + fileName + "\nCannot find residues, file will not be considered!"); rr.Close(); return; } molLength = mol.Chains[0].chainSequence.Length; } //CenterMol(); }
private static string GetMsg(ErrorBase error) { var message = error.Message; if (string.IsNullOrWhiteSpace(message)) { return(message); } var lm = AppSettings.LocalizationManager; if (!lm.ContainsKey(message)) { if (error is BlockchainError blError) { AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(blError.Message)}{Environment.NewLine}Full Message:{blError.FullMessage}"); } else { AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(message)}"); } message = nameof(LocalizationKeys.UnexpectedError); } return(lm.GetText(message)); }
protected void ShowDialog(ErrorBase error, LocalizationKeys leftButtonText, LocalizationKeys rightButtonText, Action <UIAlertAction> leftButtonAction = null, Action <UIAlertAction> rightButtonAction = null) { if (error == null || error is CanceledError) { return; } var message = error.Message; if (string.IsNullOrWhiteSpace(message)) { return; } var lm = AppSettings.LocalizationManager; if (!lm.ContainsKey(message)) { if (error is BlockchainError blError) { AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(blError.Message)}{Environment.NewLine}Full Message:{blError.FullMessage}"); } else { AppSettings.Reporter.SendMessage($"New message: {LocalizationManager.NormalizeKey(message)}"); } message = nameof(LocalizationKeys.UnexpectedError); } var alert = UIAlertController.Create(null, lm.GetText(message), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(lm.GetText(leftButtonText), UIAlertActionStyle.Cancel, leftButtonAction)); alert.AddAction(UIAlertAction.Create(lm.GetText(rightButtonText), UIAlertActionStyle.Default, rightButtonAction)); PresentViewController(alert, true, null); }
public static void ShowAlert(this Context context, ErrorBase error, ToastLength length) { if (error == null) { return; } ShowAlert(context, error.Message, length); }
protected void ShowAlert(ErrorBase error) { if (error == null) { return; } ShowAlert(error.Message); }
public static void ShowAlert(this Context context, ErrorBase error) { if (error == null) { return; } Show(context, error.Message); }
/// <summary> /// Adds the line. /// </summary> /// <param name="line">The line.</param> public void AddLine(IOrderLine <IProduct> line) { ErrorBase.CheckArgIsNull(line, nameof(line), nameof(line).GetArgumentNullErrorMessage(nameof(AddLine))); //Hp --> Note: Here interface IOrderLine is covariant of type IProduct. //Which means user is allowed to add any concreate class object which impelements IProduct. lines.Add(line); }
private IActionResult PrepareFailureResult(ErrorBase error) { return(error switch { BadRequestError _ => BadRequest(error), AuthorizationError _ => Unauthorized(error), DataNotFoundError _ => NotFound(error), _ => StatusCode(StatusCodes.Status500InternalServerError) });
/// <summary> /// Returns the <paramref name="error" /> as a <typeparamref name="TException" />. /// </summary> /// <typeparam name="TException">The type of the exception.</typeparam> /// <param name="error">The error to convert.</param> /// <param name="exceptionFactory">The exception factory.</param> /// <returns><typeparamref name="TException" /> instance.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="exceptionFactory" /> is null.</exception> public static TException ToException <TException>(this ErrorBase error, Func <ErrorBase, TException> exceptionFactory) where TException : Exception { if (exceptionFactory == null) { throw new ArgumentNullException("exceptionFactory"); } return(exceptionFactory.Invoke(error)); }
private static string ResultBuilder(MdsCheckFinalResult result, ErrorBase error) { StringBuilder sBuilder = new StringBuilder(); sBuilder.AppendLine(error.errorDesc); sBuilder.AppendLine(error.errorCause.IsNullOrWhiteSpace() ? string.Empty : error.errorCause); sBuilder.AppendLine(error.errorAction.IsNullOrWhiteSpace() ? string.Empty : error.errorAction); sBuilder.AppendLine(); return(sBuilder.ToString()); }
/* public override bool ReadMolecule() * { * return this.ReadAtoms(pdbStream); * }*/ internal override bool ReadAtoms(StreamReader pdbStream) { this.atoms = new List <Atom>(); // using (StreamReader pdbReader = new StreamReader(pdbStream)) // { string pdbLine = pdbStream.ReadLine(); while (pdbLine != null) { if (pdbLine.StartsWith("ENDMDL") || pdbLine.StartsWith("TER") || pdbLine.StartsWith("END")) { break; } if (pdbLine.StartsWith("ATOM")) { if (pdbLine.Contains("\t")) { ErrorBase.AddErrors("ATOM line containes tab what is not allowed"); return(false); } AtomRNA atom = new AtomRNA(); string error = atom.ParseAtomLine(this, pdbLine, flag); if (error == null) { if (flag == PDBMODE.ONLY_P || flag == PDBMODE.ONLY_P_AND_C4) { if (atom.AtomName == "P") { this.atoms.Add(atom); } if (atom.AtomName == "C4*" || atom.AtomName == "C4'") { this.atoms.Add(atom); } } else { this.atoms.Add(atom); } } else { ErrorBase.AddErrors("Error in file: " + ((FileStream)pdbStream.BaseStream).Name + " " + error); } } pdbLine = pdbStream.ReadLine(); } // } return(true); }
/// <summary> /// Removes the line. /// </summary> /// <param name="line">The line.</param> public void RemoveLine(IOrderLine <IProduct> line) { ErrorBase.CheckArgIsNull(line, nameof(line), nameof(line).GetArgumentNullErrorMessage(nameof(RemoveLine))); var comparer = Utility.GetEqualityComparer <IOrderLine <IProduct> >(); if (lines.Contains(line, comparer)) { lines.RemoveAll(L => L.Id == line.Id); } }
private void UpdateListBox(string item, bool errorFlag, bool finishAll) { if (dataGridView1.InvokeRequired) { dataGridView1.Invoke(new RemoveListBoxItem(UpdateListBox), new object[] { item, errorFlag, finishAll }); } else { if (finishAll) { TimeInterval.Stop(); } if (ErrorBase.GetErrors().Count > 0) { toolStripButton1.Enabled = true; } if (manager.clOutput.Count != 0) { UpdateProgress(null, null); TimeSpan span = DateTime.Now.Subtract(DateTime.Now); if (manager.clOutput.ContainsKey(item)) { int remIndex = 0; // vis = new ClusterGraphVis(manager.clOutput[item]); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if ((string)dataGridView1.Rows[i].Cells[0].Value == item) { dataGridView1.Rows[i].DefaultCellStyle.ForeColor = Color.Green; dataGridView1.Rows[i].Cells[4].Value = manager.clOutput[item].time; dataGridView1.Rows[i].Cells[1].Value = manager.clOutput[item].clusterType; dataGridView1.Rows[i].Cells[2].Value = manager.clOutput[item].measure; dataGridView1.Rows[i].Cells[5].Value = manager.clOutput[item].peekMemory; dataGridView1.Rows[i].Cells[6].Value = 100; remIndex = i; } } dataGridView1.Rows[remIndex].Selected = true; } } else { for (int i = 0; i < dataGridView1.Rows.Count; i++) { dataGridView1.Rows[i].DefaultCellStyle.ForeColor = Color.Red; dataGridView1.Rows[i].Cells[4].Value = "Error"; dataGridView1.Rows[i].Cells[5].Value = "Error"; } } } }
public static void ShowAlert(this Context context, ErrorBase error, ToastLength length) { if (error == null || error is CanceledError) { return; } var message = GetMsg(error); if (string.IsNullOrWhiteSpace(message)) { return; } Toast.MakeText(context, message, length).Show(); }
public void SerializeError_TEST() { var jstruct = new ErrorBase { Error = "f**k", ErrorCode = 20000, ErrorDescription = "sb", ErrorUri = "hh", Request = "2333" }; var json = JsonConvert.SerializeObject(jstruct); var result = "{\"error\":\"f**k\",\"error_code\":20000,\"request\":\"2333\",\"error_uri\":\"hh\",\"error_description\":\"sb\"}"; Assert.Equal(result, json); var jstruct2 = new ErrorBase { Error = "f**k", ErrorCode = 20000, Request = "2333" }; var json2 = JsonConvert.SerializeObject(jstruct2); var result2 = "{\"error\":\"f**k\",\"error_code\":20000,\"request\":\"2333\"}"; Assert.Equal(result2, json2); }
public virtual List <byte> CreateNewProfile(profileNode node, string [] profile) { List <byte> newProfile = new List <byte>(profile.Length); for (int i = 0; i < profile.Length; i++) { string state = profile[i]; if (node.ContainsState(state)) { newProfile.Add(node.GetCodedState(node.states[state])); } else { ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!"); } } return(newProfile); }
public static void ShowAlert(this Context context, ErrorBase error) { if (error == null || error is CanceledError) { return; } var message = GetMsg(error); if (string.IsNullOrWhiteSpace(message)) { return; } var btnOk = AppSettings.LocalizationManager.GetText(LocalizationKeys.Ok); CreateAndShowDialog(context, message, btnOk); }
private void PDBSAlign(object o) { Params p = (Params)o; List <string> toRemove = new List <string>(); MAlignment align = new MAlignment(refSeq.Length); DebugClass.WriteMessage("Started"); foreach (var item in auxFiles[p.k]) { molDic[item].indexMol = new int[refSeq.Length]; MAlignment.alignSeq alignRes = align.Align(refSeq, molDic[item].mol.Chains[0].chainSequence); if (alignRes.seq1.Contains('-')) { ErrorBase.AddErrors("Reference structure " + refStuctName + " cannot be used as reference to " + item + " structure because after alignment gaps to referense structure must be added what is not allowed"); toRemove.Add(item); continue; } //string ss = align.Align(molDic[refStuctName].mol.Chains[0].chainSequence, molDic[item].mol.Chains[0].chainSequence).seq2; string ss = alignRes.seq2; for (int j = 0, count = 0; j < ss.Length; j++) { if (ss[j] != '-') { molDic[item].indexMol[j] = count++; } else { molDic[item].indexMol[j] = -1; } } } DebugClass.WriteMessage("Almost done"); foreach (var item in toRemove) { molDic.Remove(item); } resetEvents[p.k].Set(); }
public string AddPDB(MemoryStream stream, PDBMODE flag, string modelName) { try { MolData molD = new MolData(); if (!molD.ReadMolData(stream, flag, modelName)) { return(null); } molDic.Add(modelName, molD); return(modelName); } catch (IncorrectSideChainException ex) { ErrorBase.AddErrors("PDB reading: file " + modelName + " is removed from consideration because\n" + ex.Message); } return(null); }
public IHttpActionResult GetCameraLastThumbPrint(long deviceID) { using (var dbContext = new DataContext()) { var camera = dbContext.Cameras.Find(deviceID); if (camera == null) { return(this.BadRequestEx(Error.DeviceNotFound)); } var cameraLastStatistic = dbContext.CameraLastStatistics.SingleOrDefault(f => f.CameraID == deviceID); if (cameraLastStatistic == null) { return(this.BadRequestEx(ErrorBase.PopulateUnexpectedException(new Exception("Statistic for device does not exist.")))); } if (string.IsNullOrWhiteSpace(cameraLastStatistic.LastInfingementTime) || cameraLastStatistic.LastInfingementTime.Contains("--")) { return(this.BadRequestEx(ErrorBase.PopulateUnexpectedException(new Exception("No last Infrngement time recorded.")))); } var ipAddress = ExtractIpAddress(camera.ConfigJson); var lastInfringementTime = cameraLastStatistic.ModifiedTimeStamp.ToString("yyyy-MM-dd") + " " + cameraLastStatistic.LastInfingementTime; var model = new CameraThumbNailModel(); model.DeviceID = deviceID; // Do a 3s delay check for (var x = 0; x < 3; x++) { var epoch = GetLatestEpoch(lastInfringementTime, x); var document = GetImageAsBase64Url(string.Format("http://{0}/timestamp_thumb.jpg?{1}", ipAddress, epoch)); if (!string.IsNullOrWhiteSpace(document)) { model.Document = document; return(Ok(model)); } } return(Ok(model)); } }
public static void ShowInteractiveMessage(this Context context, ErrorBase error, EventHandler <DialogClickEventArgs> tryAgainAction, EventHandler <DialogClickEventArgs> forgetAction) { if (error == null || error is CanceledError) { return; } var message = GetMsg(error); if (string.IsNullOrWhiteSpace(message)) { return; } var lm = AppSettings.LocalizationManager; var pBtn = lm.GetText(LocalizationKeys.TryAgain); var nBtn = lm.GetText(LocalizationKeys.Forget); CreateAndShowDialog(context, message, pBtn, tryAgainAction, nBtn, forgetAction); }
private void CreateResidues() { List <Residue> auxRes = new List <Residue>(); List <Atom> localAtoms = new List <Atom>(); //this.residues = new List<Residue>(); Residue residue = null; foreach (Atom atom in this.atoms) { //if (residue == null || atom.ResidueSequenceNumber != residue.ResidueSequenceNumber|| if (residue == null || atom.tabParam[2] != residue.ResidueSequenceNumber || atom.tabParam[1] != residue.ChainIdentifier) //atom.ChainIdentifier != residue.ChainIdentifier) { residue = new Residue(this, atom, flag); auxRes.Add(residue); } else { bool test = false; foreach (var item in residue.Atoms) { if (atom.AtomName == item.AtomName) { ErrorBase.AddErrors("Residue " + residue.ResidueName + " has two the same atoms " + atom.AtomName); test = true; } } if (!test) { residue.Atoms.Add(atom); } //residue.AddAtom(atom); } atom.tabParam = null; } this.residues = new List <Residue>(auxRes); auxRes = null; }
public bool ReadMolData(MemoryStream stream, PDBMODE flag, string modelName) { StreamReader rr = new StreamReader(stream); mol = new Molecule(flag); bool res = mol.ReadMolecule(rr); if (!res) { return(false); } if (mol.Chains.Count == 0) { ErrorBase.AddErrors("Error in reading file: " + modelName + "\nCannot find residues, file will not be considered!"); return(false); } molLength = mol.Chains[0].chainSequence.Length; return(true); //CenterMol(); }
public void AddError(ErrorBase error) { lock (_Errors) _Errors.Add(error); }
public void HandleError(ErrorBase errorPassed) { if (errorPassed != null) { Errors.Add(errorPassed); } }