public MainWindow() { InitializeComponent(); _equipmentService = new EquipmentService(); _brandService = new BrandService(); _toolService = new ToolService(); }
public ActionResult Unsubscribe(string hash) { var id = ToolService.GetIdBHash(hash); if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var objNewsletter = Newsletter.Load(id.Value); if (objNewsletter == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var model = new NewsletterUnsubscribeViewModel { //Base Title = "Descadastrar e-mail - Massa News", Description = "Estamos tristes, mas esperamos que volte algum dia.", Robots = "noindex, nofollow", Canonical = $"{Constants.UrlWeb}/newsletter/descadastrar", //Model UserHash = hash, UserNewsletter = objNewsletter }; ViewBag.ActiveNav = "Descadastrar"; return(View(model)); }
public SelectPageController(ILogger <SelectPageController> logger, ToolService toolService, RoomService roomService, IHttpContextAccessor httpContextAccessor) { _logger = logger; _toolService = toolService; _roomService = roomService; _httpContextAcessor = httpContextAccessor; }
public HomeController( IHubContext <MsgHUB> hubContext, ToolService toolService) { _hubContext = hubContext; _toolService = toolService; }
public ActionResult Reportar(ReportModel model) { try { var body = $@"<!DOCTYPE html> <html lang='pt-br'> <head> <meta charset='UTF-8'> <title>{model.Title}</title> </head> <body> <div> <span class='HOEnZb'> <font color='#888888'><h3>Massa News | Reportar erro</h3> <strong>Nome:</strong> {model.Nome}<br> <strong>E-mail:</strong> <a href='mailto:{model.Email}' target='_blank'>{model.Email}</a><br> <strong>Data do contato:</strong> {DateTime.Now}<br> <strong>URL:</strong> <a href='{model.Url}' target='_blank'>{model.Url}</a><br> <strong>Mensagem:</strong> <br> {model.Mensagem}. </font> </span> </div> </body> </html>"; ToolService.SendEmail("Massa News | Reportar erro", body, "*****@*****.**"); return(Json("ok")); } catch (Exception ex) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } }
/// <summary> /// Get a Tool from the Database specified by the parameter id /// </summary> /// <param name="id">The id of the Tool to return from the Database</param> /// <returns></returns> public IHttpActionResult Get(int id) { ToolService toolService = CreateToolService(); var tool = toolService.GetFullToolDetailByID(id); return(Ok(tool)); }
public SelectEquipmentController(ILogger <SelectEquipmentController> logger, ToolService toolService, HistoryService historyService, IHttpContextAccessor httpContextAccessor) { _logger = logger; _toolService = toolService; _historyService = historyService; _httpContextAcessor = httpContextAccessor; }
/// <summary> /// Get Tools that are of a particular type and located in a particular zip /// </summary> /// <param name="type">The type of Tool to be returned from the Database</param> /// <param name="zip">The zip code for the tools we want returned</param> /// <returns></returns> public IHttpActionResult Get(int type, int zip) { ToolService toolService = CreateToolService(); var tool = toolService.GetToolsByTypeAndZip(type, zip); return(Ok(tool)); }
/// <summary> /// Get all Tool objects stored in the Database /// </summary> /// <returns></returns> public IHttpActionResult GetAllTools() { ToolService toolService = CreateToolService(); var tool = toolService.GetAllTools(); return(Ok(tool)); }
public HomeAdminController(ILogger <HomeAdminController> logger, UserService userService, HistoryService historyService, RoomService roomService, ToolService toolService, IHttpContextAccessor httpContextAcessor) { _logger = logger; _userService = userService; _historyService = historyService; _roomService = roomService; _toolService = toolService; }
private void Control_AddDB_RefreshDBNameListHandler() { this.Invoke(new MethodInvoker(delegate { IToolService tool = new ToolService(); tool.RefreshConfigFile(); RefreshTreeHandler(); })); }
public ActionResult Create() { ViewBag.Tools = ToolService.GetToolsListItems(AppContext.Tools.ToList(), optional: true); return(View(new CreateOrderModel() { ContractNumber = orderService.SuggestContractNumber().ToString() })); }
public static void StartToolService() { if (MainToolService == null) { MainToolService = new ToolService(MainToolServiceName, MainWindow); MainWindow.DocumentChangedEvent += DocumentChangedEventHandler; MainToolService.RunAsync(); } }
public ActionResult CriarComentario(int respostaId, string comentario) { var usuario = Usuario.Load(CurrentUser.Data.SubjectId); var resposta = ComunidadeResposta.Load(respostaId); var topico = ComunidadeTopico.Load(resposta.ComunidadePergunta.ComunidadeTopicoId); var objComentario = new ComunidadeComentario { Comentario = comentario, Data = DateTime.Now, StatusPublicacaoId = topico.AtivaModeracao ? StatusComunidade.Pendente.Id : StatusComunidade.Publicada.Id, UsuarioId = usuario.Id, ComunidadeRespostaId = resposta.Id }; objComentario.Save(); if (topico.AtivaModeracao) { var body = $@"<!DOCTYPE html> <html lang='pt-br'> <head> <meta charset='UTF-8'> <title>Comunidades Virtuais - Negócio da Terra - {topico.Titulo}</title> </head> <body> <table bgcolor='#ffffff' width='600' border='0' cellpadding='0' cellspacing='0' align='center' style='font-family: Arial, sans-serif; font-size: 14px; color: #4f4f4f;'> <tr> <td style='text-align: center;'> <a href='https://massanews.com/negocios-da-terra' target='_blank'><img src='https://cdn.massanews.com/static/images/logos/negocios-da-terra-horiz.png' alt='Negócio da Terra'></a> <h3>Comentário criado aguardando aprovação:</h3> <h4>{comentario}</h4> </td> </tr> </table> </body> </html>"; foreach (var item in topico.EmailsNotificacao.Split(';')) { BackgroundJob.Enqueue(() => ToolService.SendEmail($"Comentário criado - Comunidades Virtuais - {topico.Titulo} ", body, item)); } } //return RedirectToAction("TopicosRespostas",topico.Slug,resposta.ComunidadePergunta.Slug); return(RedirectToRoute(new { controller = "Comunidades", action = "TopicosRespostas", slugtopico = topico.Slug, slugpergunta = resposta.ComunidadePergunta.Slug })); //return Json("ok"); }
private ToolService CreateToolRatingService() { // this is the userID for the person initiating the Post //var userId = Guid.Parse(User.Identity.GetUserId()); string userId = User.Identity.GetUserId(); var ToolService = new ToolService(); return(ToolService); }
public async Task <ActionResult> Edit(string id) { Maintain maintain = await FindMaintainAsync(id); if (maintain == null) { Logger.LogInformation("Edit: Item not found {0}", id); return(NotFound()); } ViewBag.Tools = ToolService.GetToolsListItems(AppContext.Tools.ToList(), optional: true); return(View(maintain)); }
public ActionResult Unsubscribe(NewsletterUnsubscribe model) { var id = ToolService.GetIdBHash(model.Hash); var objNewsletter = Newsletter.Load(id.Value); objNewsletter.Ativo = false; objNewsletter.MotivoId = model.Reason; objNewsletter.Save(); return(Json("ok")); }
public void testGetToollistFromToolService() { string output = @"{""toollist"":[{""toolID"":10,""toolLabel"":""this is a label""}]}"; var toolProviderMock = Substitute.For <IToolServiceProvider>(); toolProviderMock.GetToolListAsync(1).Returns(Task.FromResult(output)); ToolService target = new ToolService(toolProviderMock); ToolList list = target.GetToolList(1).Result; toolProviderMock.Received().GetToolListAsync(1); Assert.AreEqual(1, list.toollist.Count, "List Should have 1 object"); Assert.AreEqual("this is a label", list.toollist[0].toolLabel, "Tool label is incorrect"); }
private void btn_OK_Click(object sender, EventArgs e) { if (DBName.Count != 0) { se.ServerDBName = new List <string>(DBName); IToolService tool = new ToolService(); tool.WriteXml(se); this.Close(); } else { MessageBox.Show("请先进行连接测试"); } }
public Example() { InitializeComponent(); ToolService toolService = this.xDiagram.ServiceLocator.GetService <IToolService>() as ToolService; if (toolService != null) { // Adding additional ConnectorAddTool to add connectors on Shift + Ctrl + MouseDown over shape. toolService.ToolList.Add(new CustomConnectorAddTool()); // Replacing the default Connection Tool. toolService.ToolList[5] = new CustomConnectionTool(); } }
public void getTypesCommandReturnsToolListCorrectly() { string output = @"{""toollist"":[{""toolID"":10,""toolLabel"":""this is a label""}]}"; var toolProviderMock = Substitute.For <IToolServiceProvider>(); toolProviderMock.GetToolListAsync(1).Returns(Task.FromResult(output)); ToolService toolservice = new ToolService(toolProviderMock); ToolList toollist = new ToolList(); ToolListViewModel target = new ToolListViewModel(toollist, toolservice); target.GetToolList.Execute(1); Assert.AreEqual(1, target.ToolList.toollist.Count, "Toollist should have 1 element"); Assert.AreEqual(10, target.ToolList.toollist[0].toolID, "ToolID should be 10"); }
private void bTool_Click(object sender, EventArgs e) { if (!_techProcess.Material.CheckNotNull("Материал")) { return; } if (ToolService.SelectTool(_techProcess.MachineType.Value) is Tool tool) { _techProcess.Tool = tool; tbTool.Text = tool.ToString(); _techProcess.Frequency = ToolService.CalcFrequency(tool, _techProcess.MachineType.Value, _techProcess.Material.Value); sectionProfileTechProcessBindingSource.ResetBindings(false); } }
public async Task <ActionResult> Edit(string id, string backPage) { Order order = await FindOrderAsync(id); if (order == null) { Logger.LogInformation("Edit: Item not found {0}", id); return(NotFound()); } ViewBag.Tools = ToolService.GetToolsListItems(AppContext.Tools.ToList(), optional: false, selectedId: order.ToolID); ViewBag.backPage = backPage; return(View(order)); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ToolListView view = new ToolListView(); ToolList toolList = new ToolList(); HttpClient httpClient = new HttpClient(); ToolServiceProvider serviceProvider = new ToolServiceProvider(httpClient); ToolService toolService = new ToolService(serviceProvider); ToolListViewModel viewModel = new ToolListViewModel(toolList, toolService); view.DataContext = viewModel; view.Show(); }
public ActionResult Update(string hash) { var id = ToolService.GetIdBHash(hash); if (!id.HasValue) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var objNewsletter = Newsletter.Load(id.Value); if (objNewsletter == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var goback = false; if (!objNewsletter.Ativo) { goback = true; objNewsletter.Ativo = true; objNewsletter.MotivoId = null; objNewsletter.Save(); } var model = new NewsletterUpdateViewModel { //Base Title = "Atualizar preferências de e-mail - Massa News", Description = "Atualize suas preferências e receba e-mails personalizados para você.", Robots = "noindex, nofollow", Canonical = $"{Constants.UrlWeb}/newsletter/atualizar", //Model UserHash = hash, GoBack = goback, PreferenceGroups = PreferenceGroup.GetAll(), UserNewsletter = objNewsletter }; ViewBag.ActiveNav = "Preferências de e-mail"; ViewBag.CityLetter = new SelectList(Cidade.GetAllToDictionary(), "Key", "Value", objNewsletter.CidadeId); return(View(model)); }
public void verifyNotificationOfToolListChangeOccurs() { string output = @"{""toollist"":[{""toolID"":10,""toolLabel"":""this is a label""}]}"; var toolProviderMock = Substitute.For <IToolServiceProvider>(); toolProviderMock.GetToolListAsync(1).Returns(Task.FromResult(output)); ToolService toolservice = new ToolService(toolProviderMock); ToolList toollist = new ToolList(); ToolListViewModel target = new ToolListViewModel(toollist, toolservice); bool eventWasRaised = false; target.PropertyChanged += (sender, e) => eventWasRaised = e.PropertyName == "ToolList"; target.GetToolList.Execute(1); Assert.IsTrue(eventWasRaised, "Event for toollist change should have been raised"); }
public ActionResult Update(NewsletterUpdate model) { var id = ToolService.GetIdBHash(model.Hash); var objNewsletter = Newsletter.Load(id.Value); objNewsletter.Nome = model.Name; objNewsletter.Celular = model.CellPhone; objNewsletter.CidadeId = model.City; objNewsletter.PeriodoId = model.Period; if (model.Preferences != null) { objNewsletter.SelectedPreferences = model.Preferences.ToList(); } objNewsletter.Save(); return(Json("ok")); }
public async Task <ActionResult> Create(CreateOrderModel model) { try { if (ModelState.IsValid) { model.Save(User, AppContext); await AppContext.SaveChangesAsync(); return(RedirectToAction("ActiveOrders")); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Не удалось сохранить изменения: " + ex.ToString()); } ViewBag.Tools = ToolService.GetToolsListItems(AppContext.Tools.ToList(), optional: true); return(View(model)); }
private ToolService CreateToolService() { var ToolService = new ToolService(); return(ToolService); }
private ActionResult LoadIndexNews(string editorialUrl, string categoryUrl, string blogurl, string newsUrl, bool isPreview = false) { try { // redirect where curitiba if (editorialUrl == "where-curitiba") { return(new RedirectResult("http://www.wherecuritiba.com.br", true)); } var newsId = ToolService.GetIdByUrl(Request.Url.ToString()); //Get the news object var objNoticia = null as Noticia; if (newsId.HasValue) { objNoticia = Noticia.Load(newsId.Value); } if (objNoticia == null) { objNoticia = Noticia.GetByUrl(newsUrl); } #region Validations //Redirect 301 to new url if (!isPreview) { #region Redirect var originUrl = Request.RawUrl.Remove(Request.RawUrl.Length - 5); if (objNoticia != null) { if (originUrl != objNoticia.UrlFull) { return(new RedirectResult($"{objNoticia.UrlFull}.html", true)); } } else { var redirectUrl = UrlRedirect.GetByUrl(originUrl); if (!string.IsNullOrEmpty(redirectUrl)) { return(new RedirectResult($"{redirectUrl}.html", true)); } } #endregion } if (objNoticia == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } if (objNoticia.Autores != null && objNoticia.Autores.Count() > 0) { //19 = Estadão, 65 = Folhapress var objAutorGoogleNews = objNoticia.Autores.Where(a => a.Id == 19 || a.Id == 65).FirstOrDefault(); ViewBag.isAutorGoogleNews = objAutorGoogleNews != null ? true : false; } //Caso a noticia for inativa responde com redirect permanente para a home if ((objNoticia.StatusId == Status.Inativa.Id || !objNoticia.Categoria.Status) && !isPreview) { return(new RedirectResult("/", true)); } //Caso a noticia for diferente de publicada responde com 404 if (objNoticia.StatusId != Status.Publicada.Id && !isPreview) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } #endregion //Recupera a origem var urlReferrer = Request.UrlReferrer?.AbsolutePath.TrimEnd('/') ?? string.Empty; //Ultimas Notícias var lastestNews = new List <Noticia>(); //Get the location id var locationId = CookieFx.GetLocationId(Request); //Get the user city var objCidade = Cidade.Load(locationId); //getTemperature(locationId); if (urlReferrer.StartsWith("/tag")) { var tagUrl = urlReferrer.Split('/').Last(); var tag = Tag.GetByUrl(tagUrl); if (tag == null) { return(null); } var isNewsWithTag = false; var newsWithTag = NoticiaSrv.GetTagsByNewsIdCached(objNoticia.Id); foreach (var item in newsWithTag) { if (item.Id == tag.Id) { isNewsWithTag = true; break; } } if (isNewsWithTag) { lastestNews = GetValuesOfTag(urlReferrer, objNoticia).ToList(); } else if (editorialUrl == "blogs") { lastestNews = GetValuesOfBlogCategory(objNoticia).ToList(); } else if (objNoticia.CidadeId.HasValue && objNoticia.CategoriaUrl.Equals("plantao")) { if (objNoticia.Cidade.MicroregiaoId == objCidade.MicroregiaoId) { lastestNews = GetValuesOfMyRegion(objCidade.MicroregiaoId, objNoticia).ToList(); } else if (objNoticia.Cidade.MicroregiaoId != objCidade.MicroregiaoId) { lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } } else if (!objNoticia.CidadeId.HasValue && objNoticia.CategoriaUrl.Equals("plantao")) { lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } else { lastestNews = GetValuesOfCategory(objNoticia).ToList(); } } else if (urlReferrer.StartsWith("/fotos")) { lastestNews = GetValuesOfGallery().ToList(); } else if (editorialUrl == "blogs") { lastestNews = GetValuesOfBlogCategory(objNoticia).ToList(); } else { if (objNoticia.CidadeId.HasValue) { //If the news has the category 'plantao' if (objNoticia.CategoriaUrl.Equals("plantao")) { if (objNoticia.Cidade.MicroregiaoId == objCidade.MicroregiaoId) { //Sua Região lastestNews = GetValuesOfMyRegion(objCidade.MicroregiaoId, objNoticia).ToList(); } else if (objNoticia.Cidade.MicroregiaoId != objCidade.MicroregiaoId) { //Paraná lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } } else { //If the news is's category 'plantao lastestNews = GetValuesOfCategory(objNoticia).ToList(); } } else { //If the news has the category 'plantao' if (objNoticia.CategoriaUrl.Equals("plantao")) { //Paraná lastestNews = GetValuesOfParana(objCidade.MicroregiaoId, objNoticia).ToList(); } else { //If the news is's category 'plantao lastestNews = GetValuesOfCategory(objNoticia).ToList(); } } } //Habilita Comentários ViewBag.AllowComments = !isPreview; //Caso a notícia exista na lista é removida para evitar duplicidade if (lastestNews.Any(n => n.Id == objNoticia.Id)) { lastestNews.Remove(lastestNews.Single(n => n.Id == objNoticia.Id)); } //insere noticia na lista de notícias lastestNews.Insert(0, objNoticia); ViewBag.NavItems = lastestNews.Select(n => new NoticiaNavItem(n, lastestNews.IndexOf(n).Equals(0))); ViewBag.Lastest4News = lastestNews.Take(4).ToList(); //Set the list of categories if (objNoticia.Categoria.EditorialId == 4 && ViewBag.NavigationType == "categoria") { ViewBag.Categorias = NoticiaSrv.GetCategoriasByEditorial(objNoticia.Categoria.EditorialId); ViewBag.MenuCategoriaId = objNoticia.Categoria.CategoriaPaiId.HasValue ? objNoticia.Categoria.CategoriaPaiId : objNoticia.Categoria.Id; } ViewBag.AmpLink = $"{Constants.UrlWeb}/amp{objNoticia.UrlFull}.html"; /* base model defaults */ var model = new NoticiaModel { //Title = $"{objNoticia.Titulo} - Massa News {objNoticia.Cidade.Nome}", Description = $"{(objNoticia.Conteudo.Length > 220 ? Text.RemoveHtmlTags(objNoticia.Conteudo.Substring(0, 220) + "... Leia mais no Massa News!") : Text.RemoveHtmlTags(objNoticia.Conteudo) + " Leia no Massa News!")}", Robots = isPreview ? "noindex, nofollow" : "index, follow", Canonical = $"{Constants.UrlWeb}{objNoticia.UrlFull}.html", News = new NewsItemViewModel(objNoticia, ControllerContext) }; if (objNoticia.Cidade != null && !string.IsNullOrEmpty(objNoticia.Cidade.Nome)) { model.Title = $"{objNoticia.Titulo} - Massa News {objNoticia.Cidade.Nome}"; } else if (objNoticia.Blog != null && !string.IsNullOrEmpty(objNoticia.Blog.Titulo)) { model.Title = $"{objNoticia.Titulo} - {objNoticia.Blog.Titulo} - Massa News"; } else { model.Title = $"{objNoticia.Titulo} - Massa News"; } if (!string.IsNullOrEmpty(objNoticia.ImgLg)) { model.ImgOpenGraph = $"{Constants.UrlDominioEstaticoUploads}/{"noticias"}/{objNoticia.ImgLg}"; } else if (objNoticia.Blog != null) { model.ImgOpenGraph = $"{Constants.UrlWeb}/content/images/avatar/blogs/{objNoticia.Blog.Url}.jpg"; } // Página ViewBag.Pagina = "interna"; // ID ViewBag.Id = objNoticia.Id; // Editoria ViewBag.EditoriaUrl = objNoticia.Categoria.Editorial.Url; ViewBag.EditoriaTitulo = objNoticia.Categoria.Editorial.Titulo; // Categoria ViewBag.Categoria = objNoticia.CategoriaUrl; //Formata Noticia Site Antigo Negocio da Terra if (editorialUrl == "negocios-da-terra" && objNoticia.DataPublicacao < new DateTime(2017, 09, 12)) { var aux = model.News.News.Conteudo.Split('\n'); model.News.News.Conteudo = ""; foreach (var item in aux) { if (!String.IsNullOrEmpty(item)) { model.News.News.Conteudo = model.News.News.Conteudo + "<p>" + item + "</p>"; } } } return(View("index", model)); } catch (Exception ex) { var vars = new Dictionary <string, string> { { "Editorial", editorialUrl }, { "Category", categoryUrl }, { "NewsUrl", newsUrl } }; NewRelic.Api.Agent.NewRelic.NoticeError(ex, vars); throw; } }