Using Umbraco membership in console application - asp.net-membership

I am creating a console application that needs to access to Umbraco members in order to do some maintenance jobs.
What I want to do is get all the users for a specific role:
Roles.GetUsersInRole("SomeRole");
I added an app.config file and referenced the assemblies I thought were required. I might be missing something, since I get the following error:
Unhandled Exception: System.TypeLoadException: Could not load type 'umbraco.providers.members.UmbracoRoleProvider' from assembly 'System.Web, Version=4.0.0.0
at System.Web.Security.Roles.Initialize()

The Umbraco APIs don't work outside of an HttpContext - it's one of the current limitations that the MVC version, v5, was meant to address (before it was officially mothballed in June 2012).
However, there is a set of web services which may do what you require - check /umbraco/webservices/api/MemberService.asmx in you installation and reference it in your console app - if you reference that, then you can work with the member store outside of a direct HttpContext.

Related

Cannot AzureBlobStorage initialization in Bot Framework 4.9

I am implementing "AzureBlobStorage" by referencing "Microsoft.Bot.Builder.Azure", but when I initialize I get an error with "CloudStorageAccount".
Error CS7069 Reference to type 'CloudStorageAccount' claims it is defined in 'Microsoft.Azure.Storage.Common', but it could not be found QBotSolution
Solution Explorer:
It looks like Visual Studio can't determine which package you're trying to use. If you're just looking to do traditional bot state management, you should remove these packages:
Azure.Storage.Blobs
Microsoft.Azure.Cosmos.Table
Microsoft.Azure.Storage.Blob
Microsoft.Azure.Storage.Common
For bot Blob storage, you should only need Microsoft.Bot.Builder.Azure, so be sure to include using Microsoft.Bot.Builder.Azure; at the top of whatever file you're trying to use this in.
Here's a few good references:
State Management Sample
Write Directly to Storage - Using Blob Storage Docs
State Management Docs

How to access web.config sections in a Web service called from another application?

I'm working on a Web service with Visual Studio, framework 4.7.1. One of its Web methods needs to call another Web service (provided by another company). It converts the parameters it receives (that are consistent with our main application's business logic) into values the other Web service can handle (according to it's own business logic). To do this, it relies heavily on data stored in the Web.config file.
I tested it directly (start the Web service and call the Web methods with automatically generated pages on a Web browser page) and everything worked fine.
Now, I need to build a test application (also in Visual Studio, framework 4.7.1) to call the same Web methods. On first testing it, I noticed that the Web service was trying to access the test application's config file instead of its own (as described in Can't read Web.config with ConfigurationManager.AppSettings ).
So I created an applicationSettings section in the Web.config and moved all the data from appSettings into it. It worked fine.
Now, however, I notice that the same thing happens with the custom sections. One of them looks like this:
<configSections>
<section name="jobTypeLists" type="AdelSoft_WS_FRA.JobTypesSection" />
</configSections>
<jobTypeLists>
<jobTypes>
<jobType codeCustomerType="A" codeJobType="JobForA" />
<jobType codeCustomerType="B" codeJobType="JobForB" />
</jobTypes>
</jobTypeLists>
I can see how such a structure could fit into its own .settings file, but I have another one that is much more complicated. (Like, the text nodes can have up to four ancestors.) To keep this short-ish, I'm not providing it now, but it can easily be arranged.
ConfigurationManager.GetSection("jobTypeLists") returns null when called from the test application. Same with WebConfigurationManager.GetSection("jobTypeLists").
I've also tried accessing the configuration file with ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile), but I can't seem to find my sections in the Configuration object it returns.
I'm not sure it means anything, but the Configuration object's FilePath property contains "C:\Folder\InnerFolder\WebServiceFolder\web.config.config". Why this second ".config"? I tried passing the same string to ConfigurationManager.OpenExeConfiguration(), without the ".config" extension: it returned null. (As it should, I feel.)
The Configuration object has 10 section groups and 22 sections, which I can't make heads or tails from. Likewise, I can list them.
Actually, there are two ways for a Visual Studio project to reference a Web service: as a regular reference (like you would any other project) or as a Web reference.
I was using the former, and therein lay my mistake.
To reference the Web service, I started it, copied the URL from the browser window that it opened, and pasted it into the "URL" text box in the "Add a Web reference" window from my test application. From there on, it worked fine.
(By the way, I have kept the regular reference as well, because I'm using some constants from the Web service to handle return values.)

Asp.Net Core MVC - Can I move Identity and DataAccess to class library

I have created an ASP.NET Core MVC Web application with Individual User Account authentication (Identity).
The template has created one Web project, with a whole bunch of folders, including a "Data" folder which has the migrations for the Identity schema, and ApplicationDbContext.
Now, I have some other projects alongside the web app which will need to consume the data. I don't want them to reference the web project for obvious reasons.
And ideally I don't want my web project to depend directly on EF.
Can I move the data access into a separate class library? And if so, how!?
Create a class library projects.
Move the content from corewebproject/data to class library projects.
Add following from nuget:
Entity Framework
AspNetCore.Identity
AspNetCore.Identity.EntityFramework
Microsoft.entityframeworkcore.SqlServer
Microsoft.entityframeworkcore.Tools
Microsoft.entityframeworkcore.Tools.Dotnet
Build class library projects.
Add as reference to your web project.
Change reference in startup contextdb file location.
If you want to change you sql server from localdb change defaultconnection in appsettings.
Add reference related files.
Build solutions.
Go to nuget package manager console and select your project.
Run next commands:
'Remove-Migration'. it will remove some file including snapmodel file
Add-Migrations "Name"
update database
Check you database: you can see upadated db with aspnetcore individual account related tables.
!!! Enjoy !!!!
Sure, check out the Dev branch on https://github.com/MachUpskillingFY17/JabbR-Core we just moved all data into a separate library including identity. Its still quite a work in progress, but it absolutely works.

Magento API not working with wsdl.exe but works with Soap UI

I'm trying to integrate Magento 1.7 with a C# application.
When I tried to use the "Add Service Reference" function in Visual Studio, it finds the service and all the operations but when I click OK, it doesn't generate anything. i.e. the Reference.cs file is almost empty (only has one line with namespace).
I tried using wsdl.exe to generate the proxy in command prompt and I got the following error:
R2718: A wsdl:binding in a DESCRIPTION MUST have the same set of wsdl:operations as the wsdl:portType to which it refers.
- Operation 'catalogProductAttributeRemove' on portType 'Mage_Api_Model_Server_Wsi_HandlerPortType' from namespace 'urn:Magento' has no matching binding.
For more details on the WS-I Basic Profile v1.1, see the specification
at http://www.ws-i.org/Profiles/BasicProfile-1.1.html.
Error: Unable to import binding 'Mage_Api_Model_Server_Wsi_HandlerBinding' from namespace 'urn:Magento'.
- The operation 'catalogProductAttributeRemove' on portType 'Mage_Api_Model_Server_Wsi_HandlerPortType' from namespace 'urn:Magento' had the following syntax
error: The operation has no matching binding. Check if the operation, input and output names in the Binding section match with the corresponding names in the PortType section.
I then tried using Soap UI to load the same wsdl and it works fine. The proxy was generated and I can make calls without any problems.
The original wsdl file is here: https://gist.github.com/4514723
except I have replaced line 6297 with an example url.
So my questsion is why was Soap UI able to generate the proxies and making calls without any problems but Visual Studio can't? How can I fix it?
See Generate a Web Service Client in WS-I compliance mode .
You will need to modify your Magento code to correct the WS-I compliant WSDL definition in app\code\core\Mage\Catalog\etc\wsi.xml.
The SOAP UI is probably more tolerant of mistakes in WSDLs compared to other .NET/Java tooling.

Pass data/object between assemblies in WP7

The Windows Phone 7 project I'm working on has 2 UIs, and a core 'engine' of functionality with some pages that are common. I'd like my user interface to pass an object into one of these common pages in the core assembly.
Currently I can navigate to pages in the core assembly from the UI assembly. However, it is my understanding that each assembly has it's own Isolated storage, is that correct?
If I can share Isolated storage, I can use that, I'm just not sure how to get the two assemblies to use it together.
What's the best practice?
I tried googling this: 'wp7 pass object between assemblies'
More Info:
This would be 1 application with two assemblies. Something like this:
CustomerUI (project)
- MainPage.xaml
- App.xaml
CoreFuncs (project)
- CustomerData.cs
- EditCustomer.xaml
SalesRepUI (project)
- MainPage.xaml
- App.xaml
Both CustomerUI and SalesRepUI would use the EditCustomer page and customerData object. So, from MainPage a CustomerData object is instantiated, then a user could click 'Edit User' which would navigate to the common EditCustomer.xaml page. We would want to pass in the already instantiated CustomerData object. (For the purpose of this discussion...)
As I know, there is one Isolated storage per application, not per assembly. So you can try pass your objects through it if you like.
It depends are these two separate applications or two assemblies?
Isolated storage is isolated around the running application. This means each app has its own storage that cannot be accessed from a different app. The only ways to share data between two apps are:
A WebService/or TCP service in 7.5: You would upload the data from one app and download the data into a separate application.
User performed tasks: Copy and Paste/Sending an Email
However if this is just one application you will be able to access the isolated storage between the assemblies just by reading and writing to the files. The only thing to be aware of is file locking, make sure you close files any before you attempt to read from them from a separate dll/assembly.
Sorry, Sorry, I found what I wanted, I was thinking too hard.
PhoneApplicationService.Current.State["keyName"] = object; was exactly what I wanted. Not sure if its the best way, but for me, it works. Just throw my settings class or whatever in there, and catch it on the other side in the page.xaml code.
I would recommend using the Messenger class in the MVVM Light toolkit:
http://blog.galasoft.ch/archive/2009/09/27/mvvm-light-toolkit-messenger-v2-beta.aspx
Both of your assemblies can reference a single shared assembly; that assembly can contain a type that you use to hold data passed via the messenger.

Resources