Can I use a custom connectionstring with Ui-O-Matic so my pocos are read from different database than Umbraco? - umbraco7

I want to keep all my umbraco tables in the default database, but access data in another database for use with UI-O-Matic. Can I specify a custom connectionstring for my UI-O-Matic pocos?

According to Tim (author of UI-O-Matic) then yes:
https://our.umbraco.com/projects/developer-tools/ui-o-matic/computer-says-no/74427-external-database
You can put your own connectionstring in the web.config and then specify the name of it when "initializing" UI-O-Matic on a class:
[UIOMatic("Alias", "Display Name", "Item Name", ConnectionStringName = "YourConnectionName")]

Related

Is there any out of box SNOW(Service Now) api to create catalog item and its variables?

For e.g. , I want to create a catalog items under a category named "Backpack".Let's say I want to create a "Catalog Item" named "American Tourister" under the "Category" named "Backpack".I want to add the attributes like "colour","type" of these catalog items in the form of "Variables".
I have these values stored in my database.And data gets add up in the incremental form in database.
Is there any "Out of the Box API" in ServiceNow to create "Catalog Item" and its "Variables" using that out of box api,so that I can create catalog item and variables using data in my database.
For the latest 2 version (Jakarta and Istanbul) yes there is a set of classes for creating and manipulating catalog items, catalog categories, variable sets and variables, (CatItem, CatCategory, CatalogItemVariable, CatalogItemVariableSet, CatalogItemVariableSetM2M) please visit the official documentation for the server side APIs
I don't know about the other version but in case they are not there you can still make use of the GlideRecord API to manually do all this stuff, for example:
var catItemGr = new GlideRecord('sc_cat_item');
catItemGr.initialize();
catItemGr.setValue('name', 'American Tourister');
catItemGr.setValue('short_description', 'American Tourister Stuff');
catItemGr.setValue('category', 'sys_id for the category Backpack');
catItemGr.insert();
The above snippet can be used to create a new catalog item programmatically, you can set up the variables, variable sets and the relations using the same way
Via the REST API Explorer you can use the Namespace sn_sc to access the Service Catalog API.
Use this path to get to it:
https://.service-now.com/$restapi.do?ns=sn_sc&service=Service Catalog API&version=v1
You'll find the available operations on this page.

Odoo 8 declare view file programmatically

I want to declare my view file that its struct is loaded from database. I know in order I have to declare it on openerp.py file. But I have many user, and I want each of theme when access to my module (form view - for instance) will have difference view (fields), I am mentions to fields on database, not by "how to hide some fields for some user?". Is there any solution for this? Thanks
You can use Field Access Right.
As of OpenERP 7.0, you can create field level access rights. You can achieve this by adding the groups attribute in your field definition in the module:
_columns = { 'my_field': fields.char('My field', groups="base.group_erp_manager,base.group_system") }`
It's still valid in Odoo 8. Check Odoo documentation about security
https://www.odoo.com/documentation/8.0/reference/security.html
There is one solution I'm thinking of but haven't try it yet:
Override _views_get_fnc in 'ir.actions.act_window' model. This function return {action_id: (view_id, view_mode)}. Here you can query for view_id based on the user.

MVC 3 Basic Custom Membership

I am going to try and tackle this Membership system 1 little step at a time...
So, let's say that:
Step 1, I create an SQL database and in that database I have a Users table, very basic, that looks like this:
Users
UserID int, identity, primary key
UserName nvarchar(25)
UserPassword nvarchar (25)
UserEmail nvarchar (75)
Step 2, I create a new ASP.NET MVC3 Web Application
Step 3, I select the Internet Application template with the Razor view engine and check Use HTML 5 semantic markup
Step 4, I add an ADO.NET Entity Data Model
Step 5, In the Entity Data Model Wizard, I choose to Generate from database
Step 6, I select my data connection and select to Save entity connection settings in Web.Config
Step 7, In the Entity Data Model Wizard ==> Choose Your Database Objects, I put a check in Tables and leave the default checks in "Pluralize or singularize generated object names" and "Include foreign key columns in the model" and click Finish
Step 8, I Build Solution
Step 9, I right click in the .edmx file and choose to "Add Code Generation Item..."
Step 10, I add a new ADO.NET DbContext Generator (This then creates all of the table models)
OK, so this is where I don't know how to go any further with using the built-in Account/Membership system with my Users table. For right now, for this particular project anyway, I don't need Roles and what-not, just the [authorize] functionality...
So, what exactly, verbatim compliance, do I need to do in order for when a user comes to the website and registers or logs in, for the application to use my Users table? Ultimately so that when a user does log in, the [authorize] decoration will work for my user base.
EDIT: Thanks to olivehour ... The following changes, additions really, to make this work...
After Step 10: (side note: remove the UserPassword from your Users table, you won't need it)
Step 11, Run the aspnet_regsql.exe tool to add ASP.NET's tables to your database.
Step 12, Open up your Web.config file, copy just the "data source" information from your EntityFramework connectionString, then paste and replace the "ApplicationServices" connectionString "data source" with that of the EntityFramework's.
Step 13, In the Solution Explorer, right click on the Controller directory and Add Controller. At this point go ahead and add your UserController
Step 14, In the AccountController, in the [HttpPost] Register action method, inside of the "if (createStatus == MembershipCreateStatus.Success)" statement, add the following:
TheNameOfYourEntities db = new TheNameOfYourEntities();
User user = new TheNameOfYourProject.User();
user.UserName = model.UserName;
user.UserEmail = model.Email;
db.Users.Add(user);
db.SaveChanges();
Step 15, Build Solution, Save All, Run
We keep the built-in membership provider separate from our application users table.
I suggest using the built-in membership provider to handle user authentication. There are some settings that require you to make some decisions. For example, what will the username be? Do you want to allow email addresses as usernames? If so, you should set the requiresUniqueEmail to true on the provider element in web.config. (We make the user's email address their username. This simplifies things a lot.)
As for your custom Users table that you created using EF, don't use that for login. Use it to store application-specific information about your users. But, give rows in the table the same primary key value as the username in the membership provider db.
So, if a user registers with email address olivehour#stackoverflow.com, you would first do Membership.CreateUser to add them to the provider db, and in the same action, add a row to your users table with a primary key of olivehour#stackoverflow.com.
This way you never have to store any password encryption values in your database... you outsource it to the membership provider. When a user signs in, FormsAuthentication will write a cookie to maintain the login status. In a controller action, you can get the username with the code User.Identity.Name. Use that value as a parameter to select rows from your custom application-specific users table.

MVC3 - Error setting up Controller with Entity framework

The steps I go through...
Add new ADO.NET Entity Data Model > Generate from DB > Setup new connection string to adventureworks db > Next > Select table "DatabaseLog" > Finish. Verify DatabaseLog is visible in the edmx view.
Right click controller > Add controller
TemplateController with read/write actions and views, using Entity
Model class
AdventureWorksDWEntities
Context
New data Context > Accept default name
View
Razor
Click Add.
Produce Error:
"Unable to retrieve metadata for 'DatabaseDocumentor.models.AdventureWorksDWEntities'.
System.Data.Edm.EdmEntityeType: EntityType 'AdventureWorksDWEntities' has no key defined. Define the key for this entitytype.
System.Data.Edm.EdmEntitySet: EntityType: EntitySet 'AdventureWorksDWEntities' is based on type 'AdventureWorksDWEntities' that has no keys defined.
I tried again using AdventureWorks (not AdventureWorksDW) and this time it worked. But, I still don't understand what to pick when generating a controller. I have 3 options:
Template
Here I picked Controller with read/write actions and views, using Entity. This is easy enough to understand. I want to have my tables generated for me so I pick this option.
Model
This is what I want to model. In this case I want to model the "Department" table. So I choose Department.
Context
This one is real fuzzy to me. I chose *Name*Entities. This is the value in the web.config connection strings area. Why do I need to choose my connection string as the context? I only know context as "an object that I use to get to my entities" in C#. So, here it's hard for me to visualize. Do I need to always choose my connection string for the context?
This issue can occur when the Context is not correctly chosen from the dropdown. The context should be the value stored in the web.config
<add name="NamedEntitiesCs1"
that also contains the Model you want to generate.
I found what the issue is...
I have a 3 tiered architiecture I'm using with each of the below projects in one solution.
1.YeagerTech
2.YeagerTechWcfService
3.YeagerTechModel
No matter what, even though my wcf service references my model, the startup project (1) is not "smart" enough to recognize the metadata to create the Controller. In this case, you must include a reference to your project that includes your edmx model.
You must also ensure that the connectionstring also resides in the startup project (1) via the web.config file, in order to get the connection for the metadata.
I found the answer, the model class should have a key, that is an ID property i.e
public int ID { get; set;}
save the changes and the build or rebuild the solution.
That should be able to work out.
your property in your Model for the ID must be declared as public. rebuild and try again, it should work

Dynamics CRM: Create users with specific GUIDs

For integration purposes our users in Dynamics CRM need to have the same GUIDs as in the rest of our environment (several custom web apps built on ASP.NET and SQL Server 2005). But when we try to create a new Dynamics user with a certain GUID, Dynamics just ignores it and creates its own (the pattern of which leads me to believe that it’s using NEWSEQUENTIALID() internally, just as if the user was created through the UI). But for other types (contact for example) Dynamics takes the GUID with no issue.
Am I doing something wrong, or does Dynamics always ignore GUIDs on new user creation?
CrmService service = GetService();
systemuser newUser = new systemuser();
Key newUserId = new Key();
newUserId.Value = new Guid("D630FA8D-A32F-4a37-BFEF-CE36CBA29009");
// The GUID I would like Dynamics to use
newUser.systemuserid = newUserId;
Lookup bu = new Lookup();
bu.Value = new Guid("16B10365-0E18-DF11-B839-005056B60DD4");
// The correct business unit ID. Nothing to see here.
newUser.businessunitid = bu;
newUser.firstname = "John";
newUser.lastname = "Doe";
newUser.domainname = "DOMAIN\\jdoe";
// Valid AD credentials too. Names changed to protect the innocent.
Guid userId = service.Create(newUser);
Console.WriteLine("User created with GUID " + userId.ToString());
// Dynamics creates the user with a completely different GUID. :-(
Edit:
I've now asked this question on Microsoft's CRM forum as well.
I know it is not ideal, but as a workaround you could add a custom attribute to the systemuser entity and store your integration id there.
Without knowing more about your solution I can tell you that you don't need hardcoded quids everywhere like you are trying to do. When I arrived at my current client they were trying to do the same things and it was a serious PITA.
It took me about a day to replace all the code that was using the hardcoded quids for various entities with a simple lookup procedure that gets the entity by whatever key (user name in your case) you want and then get the entity's id from that. No more trying to do something you should be trying to do in the first place.
It took me about a day to replace all the code that was using the hardcoded quids for various entities with a simple lookup procedure that gets the entity by whatever key (user name in your case)
How interesting. You're searchnig John Doe user by 'John','Doe' strings. And what should I do if I got TWO "John Doe" in my company ?

Resources