Hi,
I am having an issue where my app service is being run multiple times. It is inconsistently running 1 - 4 times on a single start. I need it to run one time
Here is the service -
using BridgeMlsPinApi;
using OrganizeRe.Crg.Listing;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using AutoMapper.Internal.Mappers;
using CsvHelper;
using OrganizeRe.Crg.TeamMembers;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Newtonsoft.Json;
using Volo.Abp.Application.Services;
using Microsoft.Extensions.Hosting;
using OrganizeRe.Crg.MlsPostLogs;
namespace OrganizeRe.Crg
{
public class MlsActivityAppService : ApplicationService, IMlsActivityAppService
{
protected ITeamMemberRepository _teamMembersRepository;
protected IMlsPostLogRepository _mlsPostLogRepository;
protected MlsPostLogManager _mlsPostLogManager;
public MlsActivityAppService(ITeamMemberRepository teamMembersRepository,
IMlsPostLogRepository mlsPostLogRepository, MlsPostLogManager mlsPostLogManager)
{
_teamMembersRepository = teamMembersRepository;
_mlsPostLogRepository = mlsPostLogRepository;
_mlsPostLogManager = mlsPostLogManager;
}
public async Task<string> ProcessActivityAsync()
{
MlsFetch mlsFetch = new MlsFetch("mls_key");
List<TeamMember> teamMembers = await _teamMembersRepository.GetListAsync();
teamMembers = teamMembers.Where(x => x.AutopostMlsSold == true).ToList();
HashSet<ProcessDto> listingToProcess = new HashSet<ProcessDto>();
//Get all the listings for the agents in list and add to process list
foreach (var agent in teamMembers)
{
if (agent.MlsId != null)
{
Debug.WriteLine("Processing listings for agent ID " + agent);
//Get listings for each agent from MLSPin
var listings = await mlsFetch.GetLIstingsByAgentAsync(agent.MlsId);
foreach (var listing in listings)
{
var listingExist = await _mlsPostLogRepository.FindAsync(e => e.MlsId == listing.ListingId
&& e.MlsStatus == listing.MlsStatus);
if (listingExist == null)
{
//filter out all but New and check if agent has New checked
if (listing.MlsStatus == "New" && agent.AutopostMlsNew)
{
Console.WriteLine(listing.ListingId + " | " + listing.MlsStatus);
listingToProcess.Add(new ProcessDto() { Agent = agent, Listing = listing });
}
//filter out all but UAG and check if agent has New checked
if (listing.MlsStatus == "Under Agreement" && agent.AutopostMlsSold)
{
Console.WriteLine(listing.ListingId + " | " + listing.MlsStatus);
listingToProcess.Add(new ProcessDto() { Agent = agent, Listing = listing });
}
//filter out all but Sold and check if agent has New checked
if (listing.MlsStatus == "Sold" && agent.AutopostMlsSold)
{
Console.WriteLine(listing.ListingId + " | " + listing.MlsStatus);
listingToProcess.Add(new ProcessDto() { Agent = agent, Listing = listing });
}
}
}
}
}
// Process the list and create graphics
var fileName = string.Empty;
var gm = new GraphicsMillUtil();
foreach (var listing in listingToProcess)
{
fileName = await gm.CreateSoldGraphics(listing);
// invisible line break -
var postMessage = $"{listing.Listing.MlsStatus} by {listing.Agent.Name} \\u2063\\n" +
$"{listing.Listing.StreetNumber} {listing.Listing.StreetName} \\u2063\\n" +
$"{listing.Listing.City}, {listing.Listing.StateOrProvince} {listing.Listing.PostalCode} \\u2063\\n" +
$"\\u2063\\n" +
$"{listing.Listing.PublicRemarks} \\u2063\\n" +
$"\\u2063\\n" +
$"https://idx.mlspin.com/MLS.SocialMedia/Listing/{listing.Listing.ListingId}";
// Post to social via AyrShare
AyrshareService ayrshare = new AyrshareService("as_key");
var results = ayrshare.CreatePost(postMessage, "https://crg.organizere.com/images/" + fileName, includeFacebook: true,
includeInstagram: true);
// Insert into log
var mlsPostLog = await _mlsPostLogManager.CreateAsync(
listing.Listing.ListingId, listing.Listing.MlsStatus
);
}
Debug.WriteLine("------- End of Post Job ---------");
return "Done";
}
}
}
-------- And starting with a simple api call but would like to execute with hangfire when this does not repeat ------
[Route("/test")]
public async Task Test()
{
await _testAppService.ProcessActivityAsync();
}
---- And the hangfire job -----
using System.Threading.Tasks;
using Hangfire;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.DependencyInjection;
namespace OrganizeRe.Crg
{
[Queue("alpha")]
public class MlsActivityJob : AsyncBackgroundJob<string>, ITransientDependency
{
private readonly IMlsActivityAppService _mlsActivityAppService;
public MlsActivityJob(IMlsActivityAppService mlsActivityAppService)
{
_mlsActivityAppService = mlsActivityAppService;
}
public override async Task ExecuteAsync(string args)
{
await _mlsActivityAppService.ProcessActivityAsync();
}
}
}
Forms module would greatly benefit from a file upload option.
Public website template without Redis (to complicated and expensive for indies like myself)
Thanks!!!!
This article I found has resolved the issue with the same errors I was receiving. I suggest the same as the article does to update the documentation and/or code to fix this issue. This solution worked on both Azure and my stand-alone web server. Thanks for all the help!
https://codejack.com/2022/12/deploying-abp-io-to-an-azure-appservice/
Hi,
I am back with this issue but this time it's happening when deployed on the server. I have followed the instructions here but I am unsure of where the Authserver is on an MVC project to place the certificate as in these instructions "Also, please remember to copy authserver.pfx to the Content Root Folder of the AuthServer website"
Deleting the Dotnet Tools folder resolved this after installing everything again.
dotnet-ef 6.0.3 dotnet-ef volo.abp.cli 7.3.2 abp volo.abp.suite 7.3.2 abp-suite
This is a cut and paste from the CMD. First was no info and the second shows only one CLI version????
Thanks for your help again Maliming!
I am trying to update the CLI and I am receiving an error: **Tool 'volo.abp.cli' has multiple versions installed and cannot be updated." I am also receiving similar errors about having mulitple install when trying to remove. Please let me know how I can clean this up and update to the newest CLI and Suite.
Thanks, Gary
RESOLVED:
I have resolved the issue by doing the following. I updated Visual Studio to the newest version after reading that .NET 7 requires the newest version. I don't think this fixed it.
I believe there is an issue with WSL install and the server wasn't running correctly. After downloading redis-latest.zip from the Github repo - https://github.com/ServiceStack/redis-windows/tree/master/downloads and running redis-server.exe it is running in IIS directly from VS2022.
Still no resoloution?