Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' #3

Closed
zBestData opened this issue Aug 22, 2019 · 12 comments
Closed

Comments

@zBestData
Copy link

I downloaded your project, added my info to the appsettings.json file and ran the application. When it hits this line, an error is thrown.

        // Get instance of the IRetsClient from the IoC
        IRetsClient client = Container.GetService<IRetsClient>();

System.InvalidOperationException: 'Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'CrestApps.RetsSdk.Services.RetsSession'.'

2019-08-22 (1)

@mkorsukov
Copy link

@zBestData As a temporary workaround you can do this: add custom logger to your DI container (for instance, services.AddSingleton<ILogger, TempLogger>();), where TempLogger can be:

internal sealed class TempLogger : ILogger
{
    public IDisposable BeginScope<TState>(TState state)
    {
        return new NoopDisposable();
    }

    public bool IsEnabled(LogLevel logLevel)
    {
        return true;
    }

    public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
    {
        Console.WriteLine(formatter(state, exception));
    }

    private class NoopDisposable : IDisposable
    {
        public void Dispose()
        { }
    }
}

@zBestData
Copy link
Author

@mkorsukov. Thanks! I've been working on it and with some modifications have been able to connect and pull the metadata from 5 or 6 different mls's. Now working those that require a UserAgentPassword and having dfficulty getting it to connect in the initial request.

@mkorsukov
Copy link

@zBestData May I ask a couple of questions?

1. Do you know how to search for property in multiple classes (residential etc.)?

var searchRequest = new SearchRequest("PROPERTY", "RES");
searchRequest.Limit = 1;
searchRequest.ParameterGroup.AddParameter(new QueryParameter("MLNUMBER", mlsId));

I have tried different combinations (in "RES"), but can't find the right one.


2. Do you use a similar pattern for searching by city?

if (!string.IsNullOrEmpty(city))
{
    var cities = await _client.GetLookupValues("PROPERTY", "CITY");
    var cityReference = cities.Get().FirstOrDefault(x => string.Equals(x.LongValue, city, StringComparison.OrdinalIgnoreCase))?.Value;

    if (!string.IsNullOrEmpty(cityReference))
    {
        searchRequest.ParameterGroup.AddParameter(new QueryParameter("CITY", cityReference));
    }
}

3. RetsConnector library updates

I'm not sure if this github repo is in active support. I can see a very old PR here, which is not updated or merged. At the same time I have (localy) lots of internal updates to this library:

  • better HttpClient setup (+ use of HttpClientFacftory)
  • HashSet instead of List
  • all Dictionaries are case-insensitive by-default
  • some async improvements (XML load, parse all photos at a time)
  • no dependency on logger (it had a very limited support in code, I switched to exceptions)
  • etc...

Should we create a new library with all updates/improvements?

@zBestData
Copy link
Author

zBestData commented Sep 3, 2019

@mkorsukov My problem isn't searching the data, but LOGGING into the RETS Server so that I CAN search the data. Every MLS operates independantly, and there up to 4 different paramenters that can be required for access(UserName, UserPassword, UserAgent, UserAgentPassword). So far, I have been able to login and pull data from 8 different MLS's. There is only one left that I have not been able to connect to.

I have attached an updated copy of the project with my revisions. With some help, the ILogger issue has been fixed and I can now retrieve data when only the UserName and Password are requried. However, I can not login when the UserAgent and UserAgentPassword are also required. Not sure why. I have also added a pdf containing the Specs to version 1.8 of RETS.

If anyone would like to help, Email or PM me directly for login credentials of the MLS I am having difficulty with.

Thanks!
RetsConnector-zBestData.zip

@zBestData
Copy link
Author

I have fixed several issues in regards to logging in an tried to submit a pull request, but it appears that I lack the needed permissions. The project should now connect to the MLS's regardless of Basic or Digest Authentication. As of this post, I am able to log into these MLS and Data Providers:

MLS - Data Provider

  • Flagler, FL(FCMLS) - Navica MLS
  • My Florida - Stellar MLS
  • Garden State, NJ(self hosted)
  • Seattle Washington(SAR) - Paragon
  • NC Regional(NCRMLS) - Flex
  • Maine - MLSPIN

Happy Coding!

Graham

RetsConnector-master-zBestData-09-23-2019.zip

@mkorsukov
Copy link

@zBestData Thank you for update! May I ask a question? The issues you found because of different MLS versions or different MLS implementations?

@zBestData
Copy link
Author

I will try to explain..... There are several different ways an mls may require you to login. Each MLS operates independently, so the requirements can vary from one mls to the next. In addition to just the user name and password, they may also require you to provide a userAgentName and UserAgentPassword, which adds another layer. Though TLS1.2 is supposed to be the current standard for RETS, some MLS may require a different encryptions. I can get confusing.

@MikeAlhayek
Copy link
Owner

It's been a while since I worked on this project. However, I have apps that depend on it and are being used every day.

I just made some updates to fix the Loggin errors and improve a few other things. For the folks that want to contribute, please send is your pull request. Version 2.0.0 was just released.

@zBestData
Copy link
Author

I will download the update and take a look. I would love to see this evolve a bit more. Even though they are now starting to push MATRIX, I don't see RETS going away anytime soon, and the NAR's libRETS is no longer being supported as it once was.

@MikeAlhayek
Copy link
Owner

@zBestData Thanks for your response. When I published this package, I did not realize people would be interested in using it. As previously mentioned, this library is used every day by a project of mine so I'll always support it (at least as much as my project requires it or if it gains lots of interest from the community)

Please share your feedback with me. Also, feel free to contribute via pull requests.

@zBestData
Copy link
Author

Thanks! Feel free to connect with me on LinkedIn as well.

We are pulling from multiple mls's and have had our hands were tied waiting for an update to libRETS. Would like to just move it all to .NET Core so to not have to worry about it. We are delivering MLS Data via a .Net Core Api to this Real Estate Platform https://zbestpropertymanager.com/

@MikeAlhayek
Copy link
Owner

@zBestData Let me know when you convert to using .Net Core and this project. Let me know if you run into any issues.
Also, when possible please contact me at mike@crestapps.com for a quick chat

@WaltMit WaltMit mentioned this issue Jan 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants