/// <summary> /// Manejar excepcion /// </summary> /// <param name="exception"></param> /// <returns></returns> public HandleExceptionResult HandleException(System.Exception exception) { try { var result = new HandleExceptionResult(); result.TypeResult = TypeResult.Error; result.Message = Mensajes.ErrorGenerico; //Aplicar tuberia de filtros para el tratamiento de errores, basado en la configuraciones foreach (var filter in _filterHanderException) { result = filter.HandleException(exception, result); } _mensaje = result.Message; _typeResultado = result.TypeResult; //Registrar la excepcion en NLog log.Error("Excepcion:", exception); return(result); } catch (System.Exception ex) { if (log != null) { log.Error("Excepcion en ManejadorExcepciones - Exception Original :", exception); //Registrar la excepcion en NLog log.Error("Excepcion en ManejadorExcepciones :", ex); } } return(null); }
public void SetData(TypeObject _object, TypeAction _action, TypeResult _result) { DataForObject _data = dataForObjects.Find(x => x.typeObject == _object); DataWithAction _dataAction = _data.withActions.Find(x => x.typeAction == _action); _dataAction.typeResult = _result; }
public static HtmlString RenderResult(TypeResult typeResult, string strMessage) { var messages = ""; switch (typeResult) { case TypeResult.SUCCESS: messages = "<div class='alert alert-view alert-success text-center'><strong>" + strMessage + "</strong></div>"; break; case TypeResult.FAIL: messages = "<div class='alert alert-view alert-warning text-center'><strong>" + strMessage + "</strong></div>"; break; case TypeResult.ERROR: messages = "<div class='alert alert-view alert-danger text-center'><strong>" + strMessage + "</strong></div>"; break; case TypeResult.ISUSED: messages = "<strong>" + strMessage + "</strong>"; break; } return(new HtmlString(messages)); }
private bool HandleVisitSelectBody(LambdaExpression lambda) { if (lambda.Body.NodeType == ExpressionType.MemberAccess) { MemberExpression tmp = lambda.Body as MemberExpression; if (TypeResult.GetProperty(tmp.Member.Name) != null) { TypeResult = TypeResult.GetProperty(tmp.Member.Name).PropertyType; Visit(lambda.Body); return(true); } } else if (lambda.Body.NodeType == ExpressionType.New) { NewExpression tmp = lambda.Body as NewExpression; if (tmp.Type.GetProperties().All(p => TypeResult.GetProperty(p.Name) != null)) { TypeResult = tmp.Type; Visit(lambda.Body); return(true); } } return(false); }
public SearchResult(string id, string name, string thumbnail, string description, TypeResult type) { Id = id; Name = name; Thumbnail = thumbnail; Description = description; Type = type; }
public async Task UpdatePredictionAsync(Prediction predictionEntity) { //Prediction prediction = await GetPredictionAsync(predictionEntity.GameId, predictionEntity.UserId); TypeResult typeResult = await CheckTypeResult(predictionEntity.PredictedResult); predictionEntity.PredictedTypeResult = typeResult; //prediction.PredictedResult = predictionEntity.; _dbContext.Predictions.Update(predictionEntity); await AutoSaveChangesAsync(); }
public static object SwalResponse(string title, TypeResult type, string mensaje) { var objeto = new { Title = title, Type = type.ToString(), Message = mensaje }; return(objeto); }
public async Task SavePredictionAsync(int gameId, Guid?userId, string predictionString) { TypeResult typeResult = await CheckTypeResult(predictionString); Prediction prediction = new Prediction { GameId = gameId, UserId = userId, PredictedResult = predictionString, PredictedTypeResult = typeResult }; _dbContext.Predictions.Add(prediction); await AutoSaveChangesAsync(); }
private static string AppenderSelector(TypeResult resultType) { switch (resultType) { case TypeResult.video: return "/"; case TypeResult.playlist: return "?listType=playlist&list="; case TypeResult.channel: return "?listType=user_uploads&list="; default: throw new NotSupportedException(); } }
private static string AppenderSelector(TypeResult resultType) { switch (resultType) { case TypeResult.video: return("/"); case TypeResult.playlist: return("?listType=playlist&list="); case TypeResult.channel: return("?listType=user_uploads&list="); default: throw new NotSupportedException(); } }
public override void OnSystemMethodCall(MethodDefinition callingContext, MethodReference methodCall, string callTypeName, string callMethodName) { TypeResult tr = LookupOrCreateType <TypeResult>(m_htTypeFreq, callTypeName); MethodResult mr = LookupOrCreateType <MethodResult>(tr.Methods, callMethodName); // Usage of Types, Usage of Type in App tr.TypeFrequency++; IncrementByOne(tr.AppOccurrence, m_app); // Usage of Methods mr.MethodFrequency++; // Ranked Usage of Methods CountRankedUsage(callingContext, mr); // Usage of Methods in App IncrementByOne(mr.AppOccurrence, m_app); }
private void onResult(TypeResult <LoginResultDto> r) { Debug.Log("onResult: " + r.result.succeed + " " + r.result.response.DataAsText + " " + r.result.errorMsg); if (r.result.succeed) { try { LoginResultDto rDto = r.getBody(); AccountCookie.instance.saveLoginSession(rDto); handler.onLogined(rDto); } catch (Exception e) { Debug.Log("onResult: " + AccountCookie.instance + " e:" + e.ToString()); } } else { handler.onLoginFail(r.result); } }
public static NType GetNType(TypeResult r) { if (r.Generics?.Types?.Count > 0) { //todo make generics type throw new NotImplementedException(); } else { foreach (var nt in GetNonGenericsNTypes()) { if (r.TypeName == nt.TypeCodeName) { return(nt); } } throw new Exception($"Unknown type \"{r.TypeName}\""); } }
public static string GeneralActionMessage(string actionType, TypeResult typeResult) { var strReturn = string.Empty; //Action Type switch (actionType) { case "I": strReturn = "Thêm"; break; case "U": strReturn = "Cập nhật"; break; case "D": strReturn = "Xóa"; break; } switch (typeResult) { case TypeResult.SUCCESS: strReturn += " dữ liệu thành công"; break; case TypeResult.FAIL: strReturn += " chưa được thực hiện thành công. Xin kiểm tra lại"; break; case TypeResult.ERROR: strReturn = "Có lỗi phát sinh khi " + strReturn.ToLower() + " dữ liệu. Xin thử lại hoặc liên hệ Quản trị hệ thống. Xin cảm ơn"; break; case TypeResult.ISUSED: strReturn = "Có lỗi phát sinh khi " + strReturn.ToLower() + " dữ liệu. Dữ liệu này đã được sử dụng, không thể xóa"; break; } return(strReturn); }
public async Task <TypeResult> CheckTypeResult(string result) { TypeResult typeResult = TypeResult.NNB; if (result.Length == 3 && result.Substring(1, 1) == "-") { if (Convert.ToInt32(result.Substring(0, 1)) > Convert.ToInt32(result.Substring(2, 1))) { typeResult = TypeResult.WinTeam1; } else if (Convert.ToInt32(result.Substring(0, 1)) < Convert.ToInt32(result.Substring(2, 1))) { typeResult = TypeResult.WinTeam2; } else if (Convert.ToInt32(result.Substring(0, 1)) == Convert.ToInt32(result.Substring(2, 1))) { typeResult = TypeResult.Draw; } } return(typeResult); }
/// <summary>Scans the location of words in the StreamReader of the file.</summary> /// <param name="material">Material entity.</param> /// <param name="stream">Stream reader for the text file.</param> /// <param name="type">Type of result.</param> private ScanResult ParseFile(Material material, TextReader stream, TypeResult type) { var pattern = new Regex(@"[^\W_\d]([^\W_\d]|[-’`'](?=[^\W_\d]))*([^\W_\d]|['`’])?"); var wordsLocker = new object(); var compositionsLocker = new object(); var fileWords = new List <Word>(); var compositions = new List <Composition>(); var lines = new Dictionary <int, string>(); string currentLine; var counter = 1; while ((currentLine = stream.ReadLine()) != null) { lines.Add(counter, currentLine.ToLower()); counter++; } Parallel.ForEach( lines, line => { var words = pattern.Matches(line.Value); for (var i = 0; i < words.Count; i++) { var scanWord = GetOrCreateScanWord(wordsLocker, fileWords, material, words[i].Value); if (type == TypeResult.CompositionOfWords) { AddWordToCompositions(compositionsLocker, compositions, scanWord, line.Key, words[i].Index + 1); } } }); return(new ScanResult { Words = fileWords, Compositions = compositions }); }
public static string stringFromResult(TypeResult the_enum) { switch (the_enum) { case TypeResult.Result_Hit: return("Hit"); case TypeResult.Result_Miss: return("Miss"); case TypeResult.Result_InvalidCoordinate: return("InvalidCoordinate"); case TypeResult.Result_NotUnderstood: return("NotUnderstood"); case TypeResult.Result_None: return("None"); default: Debug.Assert(false); return(null); } }
/// <summary> /// Execute some change of object in a frame in battlefield /// </summary> /// <param name="objects">Objects are battlefield</param> /// <returns>Result of that frame</returns> public override TypeResult NextFrame(List<ObjectGame> objects) { if (NewResult == TypeResult.BeDestroyed) { return TypeResult.BeDestroyed; } DetectedEnemy(objects); if (EnemyTank != null) { NewResult = TypeResult.Detected; } if (Instruction == null || Instruction.Interruptible) { SetListInstructions(); while (Instruction == null) { if (ListInstructions.Count == 0) { break; } else { if (ListInstructions[0].Condition == null || ListInstructions[0].Condition.GetResult(this, EnemyTank, EnemyBullet)) { Instruction = ListInstructions[0].Clone(); } else { ListInstructions.RemoveAt(0); } } } } NewResult = TypeResult.Normal; ExecuteInstruction(objects); EnemyTank = null; EnemyBullet = null; return TypeResult.Nothing; }
protected override void handle_result(TypeResult result) { top.value.Add(result); }
public void BuildTypeCompletionData(TypeResult tr, ItemVisibility visMod) { var n = tr.ResolvedTypeDefinition; if (n is DClassLike) // Add public static members of the class and including all base classes { var curlevel = tr; var tvisMod = visMod; while (curlevel != null) { foreach (var i in curlevel.ResolvedTypeDefinition) { var dn = i as DNode; if (i != null && dn == null) { CompletionDataGenerator.Add(i); continue; } bool add = false; if (tvisMod.HasFlag(ItemVisibility.All)) { add = true; } else { if (tvisMod.HasFlag(ItemVisibility.ProtectedMembers)) { add = add || dn.ContainsAttribute(DTokens.Protected); } if (tvisMod.HasFlag(ItemVisibility.PublicMembers)) { add = add || dn.IsPublic; } if (tvisMod.HasFlag(ItemVisibility.PublicStaticMembers)) { add = add || (dn.IsPublic && dn.IsStatic); } if (tvisMod.HasFlag(ItemVisibility.StaticMembers)) { add = add || dn.IsStatic; } } if (add) { if (CanItemBeShownGenerally(dn)) { CompletionDataGenerator.Add(dn); } // Add members of anonymous enums else if (dn is DEnum && dn.Name == "") { foreach (var k in dn as DEnum) { CompletionDataGenerator.Add(k); } } } } curlevel = curlevel.BaseClass != null ? curlevel.BaseClass[0] : null; // After having shown all items on the current node level, // allow showing public (static) and/or protected items in the more basic levels then if (tvisMod == ItemVisibility.All) { tvisMod = ItemVisibility.ProtectedMembers | ItemVisibility.PublicMembers; } } } else if (n is DEnum) { var de = n as DEnum; foreach (var i in de) { if (i is DEnumValue) { CompletionDataGenerator.Add(i); } } } }
public void setResult(TypeResult new_value) { flagHasResult = true; storeResult = new_value; }
public static HtmlString RenderResult(TypeResult typeResult, string strMessage) { var messages = string.Empty; var icon = string.Empty; var cssClass = string.Empty; switch (typeResult) { case TypeResult.SUCCESS: cssClass = @"alert-success"; icon = "check"; messages = "Success"; break; case TypeResult.ISUSED: cssClass = @"alert-warning"; icon = "warning"; messages = "Warning"; break; case TypeResult.FAIL: cssClass = @"alert-warning"; icon = "warning"; messages = "Warning"; break; case TypeResult.ERROR: cssClass = @"alert-danger"; icon = "close"; messages = "Error"; break; case TypeResult.INFO: cssClass = @"alert-info"; icon = "info"; messages = "Info"; break; case TypeResult.USER_NOT_EXIST: cssClass = @"alert-warning"; icon = "warning"; messages = "Warning"; break; case TypeResult.USER_EXIST: cssClass = @"alert-warning"; icon = "warning"; messages = "Warning"; break; case TypeResult.INCORRECT_PASS: cssClass = @"alert-warning"; icon = "warning"; messages = "Warning"; break; case TypeResult.LOGINERROR: cssClass = @"alert-warning"; icon = "warning"; messages = "Warning"; break; case TypeResult.SUCCESS_APPROVE: cssClass = @"alert-success"; icon = "check"; messages = "Success"; break; case TypeResult.FAIL_APPROVE: cssClass = @"alert-warning"; icon = "warning"; messages = "warning"; break; case TypeResult.SUCCESS_PUBLISH: cssClass = @"alert-success"; icon = "check"; messages = "Success"; break; case TypeResult.FAIL_PUBLISH: cssClass = @"alert-warning"; icon = "warning"; messages = "warning"; break; case TypeResult.SUCCESS_APPOINTMENT: cssClass = @"alert-success"; icon = "check"; messages = "Success"; break; } messages = @"<div class='alert " + cssClass + @" alert-dismissable alert-view fade in'> <a href = '#' class='close' data-dismiss='alert' aria-label='close'>×</a> <strong><i class='fa fa-" + icon + "'></i> " + messages + ":</strong> " + strMessage + @" </div>"; return(new HtmlString(messages)); }
public static string GeneralActionMessage(string actionType, TypeResult typeResult) { var strReturn = string.Empty; //Action Type if (actionType != null) { switch (actionType) { case "I": //Insert strReturn = "Thêm"; break; case "U": //Update strReturn = "Cập nhật"; break; case "D": //Delete strReturn = "Xóa"; break; case "R": //Read strReturn = "Thống kê"; break; case "S": //Send strReturn = "Gửi"; break; case "C": //Confirm strReturn = "Xác nhận"; break; case "CP": //Change pass strReturn = "Đổi mật khẩu"; break; case "B": //Change pass strReturn = "Đặt lịch hẹn"; break; } } switch (typeResult) { case TypeResult.SUCCESS: strReturn += " dữ liệu thành công"; break; case TypeResult.FAIL: strReturn += " chưa được thực hiện thành công. Xin kiểm tra lại"; break; case TypeResult.ERROR: strReturn = "Có lỗi phát sinh khi " + strReturn.ToLower() + " dữ liệu. Xin thử lại hoặc liên hệ Quản trị hệ thống. Xin cảm ơn"; break; case TypeResult.ISUSED: strReturn = "Có lỗi phát sinh khi " + strReturn.ToLower() + " dữ liệu. Dữ liệu này đã được sử dụng, không thể xóa"; break; case TypeResult.LOGINERROR: strReturn = "Sai tên đăng nhập hoặc mật khẩu, xin thử lại!"; break; case TypeResult.USER_NOT_EXIST: strReturn = "Không tìm thấy thông tin tài khoản."; break; case TypeResult.USER_EXIST: strReturn = "Email bạn đăng ký đã tồn tại, vui lòng nhập địa chỉ email khác."; break; case TypeResult.INCORRECT_PASS: strReturn = "Mật khẩu cũ không đúng, vui lòng nhập lại mật khẩu."; break; case TypeResult.SUCCESS_APPROVE: strReturn = "Bài viết đã được duyệt."; break; case TypeResult.FAIL_APPROVE: strReturn = "Vui lòng nhập ghi chú để duyệt bài viết."; break; case TypeResult.SUCCESS_PUBLISH: strReturn = "Bài viết đã được xuất bản."; break; case TypeResult.FAIL_PUBLISH: strReturn = "Vui lòng nhập ghi chú để xuất bản bài viết."; break; case TypeResult.reCAPTCHA: strReturn = "Captcha không hợp lệ. Xin thử lại."; break; case TypeResult.SUCCESS_APPOINTMENT: strReturn = "Đặt lịch hẹn thành công."; break; } return(strReturn); }
private string UpdateHtml(string id, TypeResult resultType) { //UserNavigationRequest = false; return(string.Format(Html, string.Format("{0}{1}", AppenderSelector(resultType), id))); }
private string UpdateHtml(string id, TypeResult resultType) { //UserNavigationRequest = false; return string.Format(Html, string.Format("{0}{1}", AppenderSelector(resultType), id)); }
/// <summary> /// Constructor /// </summary> /// <param name="image">Image tank</param> public Tank(Image image) : base(image, TypeObject.Tank) { Radius = 0.35f * Image.Width; RadaRange = 300; RadaAngle = 20; RadaColor = Color.FromArgb(31, 255, 255, 255); DamageMin = 10; DamageMax = 20; _damageCur = 0; SpeedMove = 3; SpeedRotate = 5; SpeedFire = 1; HealMax = 100; HealCur = 100; Name = "NewTank"; ListInstructions = new List<Instruction>(); LastResult = TypeResult.Normal; NewResult = TypeResult.Normal; ActionNormal = new List<Instruction>(); ActionCannotMoveForward = new List<Instruction>(); ActionCannotMoveBackward = new List<Instruction>(); ActionDetected = new List<Instruction>(); ActionBeAttacked = new List<Instruction>(); }
public void ExecuteInstruction(List<ObjectGame> objects) { if (Instruction == null) { return; } const float epsilon = 1e-6f; float value; var oldPosition = Position; switch (Instruction.Type) { case TypeInstruction.MoveForward: value = Math.Min(Instruction.Value, SpeedMove); Instruction.Value -= value; MoveForward(value); if (IsInvalidPosition(objects)) { Position = oldPosition; NewResult = TypeResult.CannotMoveForward; } break; case TypeInstruction.MoveBackward: value = Math.Min(Instruction.Value, SpeedMove); Instruction.Value -= value; MoveBackward(value); if (IsInvalidPosition(objects)) { Position = oldPosition; NewResult = TypeResult.CannotMoveBackward; } break; case TypeInstruction.RotateRight: value = Math.Min(Instruction.Value, SpeedRotate); Instruction.Value -= value; RotateRight(value); break; case TypeInstruction.RotateLeft: value = Math.Min(Instruction.Value, SpeedRotate); Instruction.Value -= value; RotateLeft(value); break; case TypeInstruction.Fire: value = Math.Min(Instruction.Value, SpeedFire); Instruction.Value -= value; _damageCur += value; if (Math.Abs(Instruction.Value) < epsilon) { var bullet = new Bullet(Properties.Resources.Bullet_A) { Position = MathProcessor.CalPointPosition(Position, 0.5f * Image.Width, Direction), Direction = Direction, Damage = _damageCur }; _damageCur = 0; objects.Add(bullet); } break; default: break; } if (Math.Abs(Instruction.Value) < epsilon) { Instruction = null; ListInstructions.RemoveAt(0); } }
protected override void handle_result(TypeResult result) { //@@@ Debug.Assert(!have_value); have_value = true; value = result; }
/// <summary> /// Set instructions in each frame (according to LastResult and NewResult) /// </summary> public void SetListInstructions() { if (ListInstructions.Count == 0 || LastResult != NewResult) { Instruction = null; _damageCur = 0; switch (NewResult) { case TypeResult.Normal: ListInstructions = new List<Instruction>(ActionNormal); break; case TypeResult.CannotMoveForward: ListInstructions = new List<Instruction>(ActionCannotMoveForward); break; case TypeResult.CannotMoveBackward: ListInstructions = new List<Instruction>(ActionCannotMoveBackward); break; case TypeResult.Detected: ListInstructions = new List<Instruction>(ActionDetected); break; case TypeResult.BeAttacked: ListInstructions = new List<Instruction>(ActionBeAttacked); break; default: break; } LastResult = NewResult; } }
protected abstract void handle_result(TypeResult result);