private void OnCollisionExit(Collision collision) { if (UtilExtensions.IsLayerInLayerMask(BuildController.BuildLayerMask, collision.gameObject.layer)) { isGrounded = false; } }
public void UtilFailureTest() { Assert.Throws <ArgumentException>(() => UtilExtensions.GetPropertyInfo((TestClass a) => a.TestMethod())); var testClass = new TestClass(); Assert.Throws <ArgumentException>(() => Expression.Field(Expression.Constant(testClass), "TestField").GetPropertyInfo()); }
private void OnCollisionStay(Collision collision) { if (!isGrounded && UtilExtensions.IsLayerInLayerMask(BuildController.BuildLayerMask, collision.gameObject.layer)) { isGrounded = true; } }
private void OnCollisionEnter(Collision collision) { if (canDetectBuildingBlocks && !hasHitBuildingBlock && UtilExtensions.IsLayerInLayerMask(buildingBlockLayerMask, collision.gameObject.layer)) { hasHitBuildingBlock = true; StartCoroutine("LightFuse"); } }
private void ContentControlHolder_OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { // When window is not loaded we don't want the animation as we don't have all the measurements to do it if (UtilExtensions.GetAnimationAllowed(MainStackPanel) && IsLoaded) { var sb = (Storyboard)FindResource("DataContextChanged"); sb.Begin(); } }
public override T Save <T>(T model) { /* Preparing object to be saved. */ var modelPrepared = UtilExtensions.ConvertTo <EventData>(model); modelPrepared.PrepareModel(); /* Casting back to T before saving. */ return(base.Save(modelPrepared.ConvertTo <T>())); }
// GET: Celula public ActionResult Index(Celula celula, string ordenacao, int?pagina, FormCollection collection) { try { //var _celulaViewModel = Mapper.Map<IEnumerable<Celula>, IEnumerable<CelulaViewModel>>(_celulaBL.GetAll()); //CARREGANDO DADOS celula.Nome = String.IsNullOrEmpty(Request.QueryString["FiltrarNome"]) ? String.Empty : Request.QueryString["FiltrarNome"]; var _celulas = from c in _celulaBL.GetAll().Where(c => c.Nome.Contains(celula.Nome)) select c; //ORDENAÇÃO DOS DADOS ordenacao = (String.IsNullOrEmpty(ordenacao) ? "Nome_Asc" : ordenacao); switch (ordenacao) { case ("Nome_Desc"): _celulas = _celulas.OrderByDescending(c => c.Nome); break; default: _celulas = _celulas.OrderBy(c => c.Nome); break; } //PAGINAÇÃO //TODO: PEGAR VALOR DO PARâMETRO int _tamanhoPagina = 5; pagina = pagina == null ? 1 : pagina; pagina = pagina < 1 ? 1 : pagina; pagina = _tamanhoPagina >= _celulas.Count() ? 1 : pagina; int _numeroPagina = (pagina ?? 1); IPagedList model = _celulas.ToPagedList(_numeroPagina, _tamanhoPagina); _numeroPagina = model.PageNumber; //VIEWBAGS ViewBag.OrdemPor = (ordenacao == "Nome_Asc" || String.IsNullOrEmpty(ordenacao) ? "Nome_Desc" : "Nome_Asc"); ViewBag.Ordenacao = ordenacao; ViewBag.PaginaAtual = _numeroPagina; ViewBag.NomeCorrente = celula.Nome; ViewBag.NomeAplicacao = "NetDocs® 1997-2015"; ViewBag.TotalRegistros = UtilExtensions.GetPageInfo(_celulas.Count(), model); return(View(_celulas.ToPagedList(_numeroPagina, _tamanhoPagina))); } catch (Exception ex) { this.AddNotification(@Resources.Resource1.FalhaOperacao + " - " + ex.Message, NotificationType.ERROR); return(View()); } }
public void AutenticaUsuario(UsuarioViewModel usuario) { Session.Add("LOGADO", "S"); Session.Add("SESSION_ID", Session.SessionID); Session.Add("USUARIO_NOME", string.Format("{0} {1}", usuario.Nome, usuario.Sobrenome)); Session.Add("USUARIO_LOGIN", usuario.Login); Session.Add("USUARIO_SENHA", usuario.Senha); Session.Add("WEB_API_TOKEN", UtilExtensions.GetToken(usuario.Login, usuario.Senha)); ViewBag.NomeFacebook = Session["USUARIO_NOME"]; FormsAuthentication.SetAuthCookie(usuario.Login, false); if (Session["FACEBOOK_ACCESS_TOKEN"] != null) { //TODO: Guardar no banco //VERIFICAR SE USUÁRIO JÁ EXISTE //SENÃO EXISTE, INCLUIR //SE EXISTE, RESGATAR DADOS } }
[Authorize]// GET: Celulas public ActionResult Index(string ordenacao, int?pagina) { try { IEnumerable <CelulaViewModel> _celulas = Models.CelulaModel.GetAll(UtilExtensions.GetToken(Session["USUARIO_LOGIN"].ToString(), Session["USUARIO_SENHA"].ToString(), Session["WEB_API_TOKEN"].ToString())); //ORDENAÇÃO DOS DADOS ordenacao = (String.IsNullOrEmpty(ordenacao) ? "Nome_Asc" : ordenacao); switch (ordenacao) { case ("Nome_Desc"): _celulas = _celulas.OrderByDescending(c => c.Nome); break; default: _celulas = _celulas.OrderBy(c => c.Nome); break; } //PAGINAÇÃO int _tamanhoPagina = UtilExtensions.GetTamanhoPagina(); pagina = pagina == null ? 1 : pagina; pagina = pagina < 1 ? 1 : pagina; pagina = _tamanhoPagina >= _celulas.Count() ? 1 : pagina; int _numeroPagina = (pagina ?? 1); IPagedList _model = _celulas.ToPagedList(_numeroPagina, _tamanhoPagina); _numeroPagina = _model.PageNumber; //VIEWBAGS ViewBag.OrdemPor = (ordenacao == "Nome_Asc" || String.IsNullOrEmpty(ordenacao) ? "Nome_Desc" : "Nome_Asc"); ViewBag.Ordenacao = ordenacao; ViewBag.NomeCorrente = string.Empty; ViewBag.PaginaAtual = _numeroPagina; ViewBag.TotalRegistros = UtilExtensions.GetPageInfo(_celulas.Count(), _model); return(View(_celulas.ToPagedList(_numeroPagina, _tamanhoPagina))); } catch (Exception ex) { this.AddNotification(@Resources.Resource1.FalhaOperacao + " - " + ex.Message, NotificationType.ERROR); return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { if (!ModelState.IsValid) { return(View()); } try { Celula cliente = _celulaBL.GetById(id); _celulaBL.Remove(cliente); this.AddNotification(@Resources.Resource1.RegistroExcluido, NotificationType.SUCCESS); return(RedirectToAction("Index", "Celula", UtilExtensions.GetRoutValues("Index", "Celula", collection))); } catch (Exception ex) { this.AddNotification(@Resources.Resource1.FalhaOperacao + " - " + ex.Message, NotificationType.ERROR); return(View("Index")); } }
public Models.IResult <bool> CreateExcelReport(System.Data.DataTable dtData) { if (dtData == null) { return(new Result <bool>(new System.ArgumentNullException("dtData"))); } using (var package = new ExcelPackage()) { int rowStart = 2; int columnEnd = dtData.Columns.Count; //.Workbooks.Add() ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(_ExcelOptions.WorksheetName); try { rowStart = InitWorksheet(worksheet, rowStart, columnEnd); AddPageSetup(worksheet, rowStart); //load data: //expression.CopyFromRecordset (Data, MaxRows, MaxColumns) rowStart++; AddData(worksheet, dtData, rowStart); worksheet.Cells[1, 1, worksheet.Dimension.End.Row, worksheet.Dimension.End.Column].Style.Font.SetFromFont(_ExcelOptions.DefaultWorksheetFont); worksheet.Cells[2, 1].Style.Font.SetFromFont(_ExcelOptions.TitleFont); //freeze worksheet.View.FreezePanes(rowStart, columnEnd); var file = UtilExtensions.GetFileInfo(_ExcelOptions.FileName); package.SaveAs(file); } catch (Exception ex) { return(new Result <bool>(ex)); } } return(new Result <bool>(true)); }
private void ChasePointer() { int uiElementsUnderMouse = int.MaxValue; bool follow = false; #if UNITY_STANDALONE uiElementsUnderMouse = UtilExtensions.UIRaycastResults(Input.mousePosition, uiBuildingBlockQuickMenuTag).Count; follow = Input.GetMouseButton(0); #elif UNITY_IOS || UNITY_ANDROID uiElementsUnderMouse = UtilExtensions.UIRaycastResults(Input.mousePosition, uiBuildingBlockQuickMenuTag).Count; follow = Input.touchCount > 0; #endif if (follow && uiElementsUnderMouse == 0) { MoveConstructionBuildingBlock(GetPointerRay()); } else { UpdateConstructionBuildingBlockAltitude(); } }
private void OnCollisionEnter(Collision collision) { if (!collisionDetected) { StopLaunchSoundEffect(); PlayCollisionSoundEffect(); PlayCollisionEffect(collision); spin.Stop(); trailParticleSystem.Stop(); } if (UtilExtensions.IsLayerInLayerMask(ProjectileController.Singleton.StructureLayerMask, collision.gameObject.layer) && !hitStructure) { hitStructure = true; if (collision.gameObject.GetComponent <BuildingBlockCopy>() is BuildingBlockCopy) { ChallengesController.BlocksHitByProjectiles++; } } collisionDetected = true; }
private void OnCollisionEnter(Collision collision) { if (!UtilExtensions.IsLayerInLayerMask(VehicleController.Singleton.GroundLayerMask, collision.gameObject.layer)) // If the collision is with NOT the ground, then execute: { if (!collisionDetected) // Check if we've already collided. { PlayCollisionSoundEffect(); PlayCollisionEffect(collision); StopWheelDustEffect(); collisionDetected = true; } if (UtilExtensions.IsLayerInLayerMask(VehicleController.Singleton.StructureLayerMask, collision.gameObject.layer) && !hitStructure) { RoundController.Singleton.EndRound(); hitStructure = true; ChallengesController.VehicleHitStructure = true; } } }
private void FillIsNumeric() { IsNumeric = UtilExtensions.IsNumeric(Valor); }
/// <summary> /// Asynchronously produces e-mails and notification messages for all intended recipients based on the specified event type. /// </summary> /// <param name="args">An object that holds issue-related event data.</param> /// <param name="cancellationToken">The token used to cancel an ongoing async operation.</param> /// <returns></returns> public override async Task ProcessAsync(SysEventArgs args, CancellationToken cancellationToken = default(CancellationToken)) { // give a chance to the base message producer to process the event await base.ProcessAsync(args, cancellationToken); if (!(args is SysEventArgs <Issue> e)) { throw new ArgumentException($"Must be of type {nameof(SysEventArgs<Issue>)}.", nameof(args)); } var issue = e.Data ?? throw new ArgumentNullException("Data"); var user = (e.User as AppUser) ?? throw new ArgumentNullException("User"); var settings = e.ObjectState as EmailSettingsViewModel ?? throw new ArgumentNullException("ObjectState", $"ObjectState must be of type {nameof(EmailSettingsViewModel)}"); var notifs = settings.Notifications; _emailNotificationsEnabled = notifs.Enabled ?? false; try { if (issue.User == null && e.EventType != SysEventType.IssueDeleted) { issue = await _issueRepo.All(q => q.QueryIssues(id: issue.Id, withIncludes: true)).SingleOrDefaultAsync(); } var fullName = user.FullName(); var userName = user.UserName; var notify = false; var outgoing = settings.Outgoing; var from = outgoing.FromDisplay; var useFromNameForAll = outgoing.UseFromNameForAll ?? false; var replyToAddrList = new InternetAddressList(); if (!string.IsNullOrWhiteSpace(outgoing.ReplyTo)) { replyToAddrList.AddRange(outgoing.ReplyTo); } EmailTemplate temp; var templates = settings.Templates; switch (e.EventType) { case SysEventType.IssueCreated: { // Sent to technicians when a new ticket arrives. All technicians that have permissions to the category get one of these. // Ticket confirmation notification (the one users get after submitting a new ticket)? notify = notifs.TicketConfirmationNotification ?? false; if (notify && user.SendEmail && user.EmailConfirmed) { // "Ticket confirmation" email template: Sent to the ticket-submitter after the app received his ticket. temp = templates.TicketConfirmation; var m = CreateMessage( temp.ReplaceSubject(issue.Subject).ToString(), temp.ReplaceBody(issue.Body, issue.Subject) .Replace("#Numero_ticket#", $"{issue.Id}") .Replace("#Articles_Base_Connaissances#", string.Empty) //.Replace("#Suggested_KB_articles#", string.Empty) .ToString(), from, to: user.Email ); m.ReplyTo.AddRange(replyToAddrList); Enqueue(WrapMessage(m, user.Id)); } temp = templates.NewTicket; var subj = temp.ReplaceSubject(issue.Subject).ToString(); var body = temp.ReplaceBody(issue.Body, issue.Subject).Replace("#Numero_ticket#", $"{issue.Id}").ToString(); from = user.GetEmailAddress(); // notify all admins? if (notifs.NotifyAllAdmins ?? false) { var qry = _userRepo.All(q => q.NotDisabled().Admins().Not(user.Id).CanReceiveEmails()); await ForUsersAsync(qry, subj, body, from, replyToAddrList, cancellationToken); } // notify techs in their categories? if (notifs.NotifyTechs ?? false) { var qry = _userRepo.All(q => q.NotDisabled().Techs().Not(user.Id).CanReceiveEmails()); await ForUsersAsync(qry, subj, body, from, replyToAddrList, cancellationToken); } } break; case SysEventType.IssueAssigned: { // Notify ALL technicians in a category when another technician TAKES a ticket temp = await TemplateForUpdate($"{fullName} a pris en charge la résolution du ticket #{issue.Id}."); if (user.IsTech && (notifs.NotifyAllTechsOnTechTakeOver ?? false)) { await NotifyTechs(temp); } // notify ticket owner NotifyOwner(temp); } break; case SysEventType.IssueUpdated: { // Sent to both technicians and ticket-submitter (and all ticket-subscribers if any) when a new reply is added to the ticket temp = await TemplateForUpdate($"Le ticket #{issue.Id} a été mis à jour par {fullName}."); if (issue.UpdatedByUser) { from = user.GetEmailAddress(); var techsNotified = false; // Notify ALL technicians in a category when a customer updates a ticket // (not just the ticket-technician and ticket-subscribers)? if (issue.UpdatedForTechView || (notifs.NotifyAllTechsOnCustomerUpdate ?? false)) { await NotifyTechs(temp); techsNotified = true; } await NotifyAssignee(temp); // send to all subscribers but the submitter var qry = _subsRepo.All(q => q.QueryIssueSubscribers(issue.Id).But(user.Id)); if (techsNotified) { qry = qry.NotTechs(); // exclude the techs who've been notified previously } await ForSubscribersAsync(qry, temp.Subject, temp.Body, from, replyToAddrList, cancellationToken); } else { // send to submitter NotifyOwner(temp); // send to subscribers except the owner and updater var qry = _subsRepo.All(q => q.QueryIssueSubscribers(issue.Id).But(user.Id).But(issue.User.Id)); await ForSubscribersAsync(qry, temp.Subject, temp.Body, from, replyToAddrList, cancellationToken); } } break; case SysEventType.IssueClosed: { // Sent to subscribers when a ticket is closed. Note that "Ticket closed notifications" setting has to be on. if (notifs.TicketClosedNotification ?? false) { temp = await TemplateForUpdate($"Le ticket #{issue.Id} a été fermé par {fullName}."); NotifyOwner(temp); } } break; case SysEventType.IssueReopened: // no template for this scenario? break; case SysEventType.IssueDeleted: // no template for this scenario? break; default: // definitely no template for this scenario! break; } Consumer.Notify(); async Task <EmailTemplate> TemplateForUpdate(string whatHappened) { var comments = await _commentRepo.GetAsync(q => q.QueryCommentsForIssue(issue.Id).Skip(0).Take(3).ToArray()); var recent = string.Empty; if (comments.Length > 0) { try { recent = await _emailTemplatesViewRender.RenderToStringAsync(TEMPLATE_RECENT_COMMENTS, comments); } catch (Exception ex) { Logger.LogWarning(ex, "An error occured while rendering the recent comments e-mail template."); var sb = new StringBuilder("<h3>Messages récents</h3>"); foreach (var c in comments) { sb.AppendLine(); sb.AppendLine(c.Body); } recent = sb.ReplaceLineBreaks().ToString().Trim(); } } temp = templates.TicketUpdated; var subj = temp.ReplaceSubject(issue.Subject).ToString(); var body = temp .ReplaceBody(issue.Body, issue.Subject) .Replace("#Quoi_De_Neuf#", whatHappened) .Replace("#Messages_recents#", recent) .Replace("#Categorie#", issue.Category?.Name) .Replace("#Statut#", issue.Status?.Name) .Replace("#Priorite#", UtilExtensions.PriorityName(issue.Priority)) //.Replace("#What_Happened#", whatHappened) //.Replace("#Recent_messages#", recent) //.Replace("#Category#", catname) //.Replace("#Status#", statname) //.Replace("#Priority#", priority) .ToString(); return(new EmailTemplate { Body = body, Subject = subj }); } async Task NotifyTechs(EmailTemplate et) { var qry = _userRepo.All(q => q.NotDisabled().Techs().Not(user.Id).CanReceiveEmails()); await ForUsersAsync(qry, et.Subject, et.Body, from, replyToAddrList, cancellationToken); } async Task NotifyAssignee(EmailTemplate et) { if (issue.IsAssigned()) { var owner = await _userRepo.GetAsync(q => q.Find(issue.AssignedToUserId)); if (owner != null) { EnqueueTemplate(et, owner); } } } void NotifyOwner(EmailTemplate et) { var owner = issue.User; if (owner.SendEmail && owner.Id != user.Id) { EnqueueTemplate(et, owner); } } void SetFromName(AppUser u) { if (!useFromNameForAll) { from = user.GetEmailAddress(); } } void EnqueueTemplate(EmailTemplate et, AppUser owner) { SetFromName(owner); Enqueue(WrapMessage(CreateMessage(et.Subject, et.Body, from, owner.Email), owner.Id)); } } catch (Exception ex) { Logger.LogError(ex, $"Error while producing issue e-mails in {nameof(ProcessAsync)}."); } }