I want to create a database for testing using nuke targets. I can set the connection string using the SetConnection method. But I`m interested in getting it from my JSON file in the project. In what way can I do it? Thanks.
Related
I am working on ASP.NET Core 6.0 WebAPI and I need to get data from a CRM system (Sales Logix) using Sage SData API. We have different CRM environments (Production, Staging, Development) and I want to be able to connect (or test) any environment from my WebAPI project.
For that to work, I would like to add a configuration key (to indicate a particular CRM environment) either in appsettings.json (or launchsetting.json). For example when setting is "crmEnvironment": "Development", I want to include a custom json file, named crm-dev.json. Similarly for "crmEnvironment": "Staging", I want to include crm-staging.json.
Each custom json file ideally contains the CRM Url, Username and Password.
Please tell me how can I conditionally add json config files as mentioned above, or is there any better approach of achieving similar results, considering security in mind. Best if I could have custom config files encrypted without having to shift away from the standards, just like we did for Web.Config files by inheriting ProtectedConfigurationProvider.
My questions is similar to How can I add a custom JSON file into IConfiguration?. But since Program.cs no longer uses the Main() method, I am wondering what would be the correct way to add custom json config files.
If this may work, I use this approach.
.AddJsonFile($"Config\\appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true)
And I will have the Json file created for each environment. You can set the environment variable value either via IHost context or may be, simplifying your need by using Environment variable values from your respective environment.
I am trying to build a bot using the BOT Framework that tells jokes when the user feels sad. I have scraped some data from a website and made an XML file. I have converted the XML file to JSON. I want the bot to extract data from this JSON file.
Is there any way to do it? Is there a way to add a file to the bot from which it extracts data. I tried building a bot using BOT composer. But could not find a way to extract data from a file or add a file to it.
What I understand is we can make HTTP requests. Should i build an API and then do it?
Is there a way to implement this using bot framework SDK in C#?
Please help. I am really stuck and cannot move forward.
Yes , you can write the custom action(API) to extract data from the file or If the JSON file you can directly read from the file( you can assgin to property to read the value ( Ref here how to read from the JSON file https://learn.microsoft.com/en-us/composer/tutorial/tutorial-get-weather?tabs=v2x ))
I have a project based on the Chris Hammond, Christoc, module template. I have a ton of code that I use to access data an external database. In my repositories I change the database from the default to whichever I need for that particular object. I do so with code that looks like this:
using (IDataContext ctx = DataContext.Instance(MyModuleSettingsBase.DATABASE_CONNECTION_STRING_KEY))
{
var rep = ctx.GetRepository<Product>();
products = rep.Get().ToList();
}
The default database is switched in the call to .Instance(). The repositories are used by my custom DNN modules. The repository is part of the solution that contains multiple custom modules. When I compile and install using the Extensions part of DNN, everything works well. In the code above, MyModuleSettingsBase.DATABASE_CONNECTION_STRING_KEY is found in a file MyModuleSettingsBase.cs file of my module solution. It is set to a simple string like "ProductDatabase". In the solution for the base DNN install (not the module solution), within the web.config file, there is a value in <connectionStrings> with name="ProductDatabase" which contains the actual connection string. This all links up fine on the DNN website.
Now I am writing a console application that does some monitoring of the site. I want to access the database to check values in the product table. I would like to reuse all of the repository code I have written. In an attempt to do so, I added a reference to the MyModules.dll file so I would only have one copy of the base code. This works to give me access to all the objects and the associated repositories but when I attempt to query data it fails. When debugging I can see that it fails on the line:
using (IDataContext ctx = DataContext.Instance(MyModuleSettingsBase.DATABASE_CONNECTION_STRING_KEY))
When viewed in a debugger, the string value MyModuleSettingsBase.DATABASE_CONNECTION_STRING_KEY is correctly set to "ProductDatabase" but the code is unable to link this with the actual connection string. I don't know where it would be checking for the connections string when running from my console application. I attempted to put a <connectionStrings> section into my App.config file but this didn't do the trick.
Is it possible to have MyModuleSettingsBase.DATABASE_CONNECTION_STRING_KEY map to the connection string in an external application which references the DLL?
If so, where can I set the value of my connection string so it matches up to the key value stored in MyModuleSettingsBase.DATABASE_CONNECTION_STRING_KEY?
I was faced similar problem 3 months ago, at that time I want to use DNN core libraries in my console application but I was failed.
I placed my queries in DNN official forum website and I got a valid response from Wes Tatters (DNN MVP).
Here is the post link: Reference URL
As your requirement of monitoring, I suggest you to create DNN Schedule Application. You can schedule it within DNN (Host->AdvancedSettings->Schedule), even good point is that you can use your repositories (DNN Libraries) in that schedule application.
I hope it solved your problem. Let me know if you have any questions.
I am trying to connect to Magento API using C#. I am using Magento Go service and from what I've read I am able to use their API - I hope I am not wrong here. So here is what I did:
I added a Service Reference to http://mydomain.gostorego.com/api/v2_soap?wsdl=1, and just adding a service worked fine. Now I created a test class with GetStuff() method, which looks like this:
using ww.Feeds.MagnetoGoService;
public static string GetStuff()
{
MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient s = new MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient();
var login = s.login("username here", "key here");
return login.ToString();
}
When I run the program I get an error in first line saying:
Could not find default endpoint element that references contract 'MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortType' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Any ideas what this may be? Do I have to set something up in my Magento Go settings? Or maybe using Magento Go is not allowing API access?
Thanks a lot.
Forget SOAP with c# you will pull your hair out. Download Charls Cook's xml-rpc api libary for c# and use the xml-rpc method. You won't get all the snazzy intellisense but at least it will work. There's also c# solution from ez.newsletter they released with Cook's library demonstrating how to use 80% of the magento api calls.
Cook's library xml-rpc.net
http://www.xml-rpc.net/
ez.newsletter solution
http://code.google.com/p/csharlibformagexmlrpcapi/
If anyone ever has problems with this, my solution was this:
I used the reference in one project, but I actually called the class and had main program in another project. You need your Service reference to be in each project wherever you're using it. That fixed it! Alternatively you can create a new BasicHttpBinding() and putt all the options from app.config/web.config into that binder, then you don't need to reference to Service everywhere. I hope that helps!
My NHibernate configuration is set up using hibernate.cfg.xml, and now I am trying to implement Rhino.Seucrity, and for its configuration I need to retrieve a NHibernate.Cfg.Configuration instance. Now i was wondering if it is possible to retrieve the configuration instance that hibernate.cfg.xml produces?
Well, somewhere in your code you must be creating the Configuration object and building the ISessionFactory. Get it from there...