SharePoint 2013 - Getting SPSite.Url from SharePoint DB - database

I'm working directly against the SharePoint DB (I know it is highly not recommended but I need to, for several reasons).
I'm trying to get the SPSite.Url property ("http://baseurl/sites/somename") but can't figure out how to do that. I can only find and get the second part ("sites/somename") for each site.
Does any one know which stored procedures I need to use in order to get that?

The way to do that is: Retrieving the Farm Id--> Retrieving the Alternate URL Collection Ids--> Retrieving the Alternate URL Collections--> Alternate URL Matching
You can find in this link: [MS-WSSFO3]: Windows SharePoint Services (WSS): File Operations Database Communications Version 3 Protocol documentation with detailed explanation under this section:
Site Collection Lookup

Related

Where to find the OSB Business service configuration details in the underlying database?

In OSB Layer when the endpoint uri is changed, I need to alert the core group that the endpoint has changed and to review it. I tried SLA Alert rules but it does not have options for it. My question is, the endpoint uri should be saved somewhere in the underlying database. If so what is the schema and the table name to query it.
URI or in fact any other part of OSB artifact is not stored in relational database but rather kept in memory in it's original XML structure. It can be only accessed thru dedicated session management API. Interfaces you will need to use are part o com.bea.wli.sb.management.configuration and com.bea.wli.sb.management.query packages. Unfortunately it is not as straightforward as it sounds, in short, to extract URI information you will need to:
Create session instance(SessionManagementMBean)
Obtain ALSBConfigurationMBean instance that operates on SessionManagementMBean
Create Query object instance(BusinessServiceQuery) an run it on ALSBConfigurationMBean to get ref object to osb artifact of your interest
Invoke getServiceDefinition on your ref object to get XML service
definition
Extract URI from XML service definition with XPath
Downside of this approach is that you are basically pooling configuration each time you want to check if anything has changed.
More information including JAVA/WLST examples can be found in Oracle Fusion Middleware Java API Reference for Oracle Service Bus
There is also a good blog post describing OSB customization with WLST ALSB/OSB customization using WLST
The information about services and all its properties can be obtained via Java API. The API documentation contains sample code, so you can get it up and running quite quickly, see the Querying resources paragraph when following the given link.
We use the API to read the service (both proxy and business) configuration and for simple management.
As long as you only read the properties you do not need to handle management sessions. Once you change the values, you need to start a session and activate it once you are done -- a very similar approach to Service bus console.

Access Sitecore DB from API in Console application

I would like to accesss the sitecore DB and items from console application like
Sitecore.Data.Database db = Sitecore.Context.Database
or
Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("master")
how do I configure and setup my console application to access the DB as above?
Thanks Everyone for the suggestion, I am really interested in config changes, I used webservice, but it has very limited methods. For example, if I would like create an Item with the template and insert the item with prepopulated value, there is no such option. The reason I am looking for the console apporach is I would like to import the contents from XML or excel sheet and push those to the sitecore tree, eventually use the scheduled task to run the console app periodically. I do not want to copy the entire web.config and app_config. If anyone has already done this, could you please post your steps and necessary config changes?
You have two options I think:
1) Import the Sitecore bits of a website's web.config into your console application's app.config, so that the Sitecore API "just works"
I'm sure I read a blog post about this, but I can't find the reference right now. (I will have another look) But I think the simple but long winded approach is to copy all of the <sitecore/> element and all the separate files it references. I'm fairly sure you can whittle this down to a subset of the config required for data access with a bit of thinking.
2) Don't use the Sitecore API directly, connect to a web service that exposes access to it remotely.
There are a few of these that already exist. Sitecore itself exposes one, Sitecore Rocks has one, and Hedgehog TDS has one too. And you can always write your own (since any web service running inside the Sitecore ASP.Net app can make database calls and report values back and forth - just remember to consider security if this web service might end up exposed externally for any reason)
John West links to some relevant stuff here:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Getting-Data-Out-of-the-Sitecore-ASPNET-CMS.aspx
-- Edited to add --
I've not found the blog post I remember. But I came across this SO thread:
Accessing Sitecore API from a CLI tool
which refers to this blog post:
http://www.experimentsincode.com/?p=232
which I think gives the info you'll need for option 1.
(And it reminds me that, of course, when you copy the config stuff you have to copy the Sitecore binaries into your app's folder as well)
I would just like to expand on #JermDavis' post and note that Sitecore isn't a big fan of being accessed when not in a web application. However, if you still want to do this, you will need to make sure that you have all of the necessary configuration settings from the web.config and App_Config of your site in your console application's app.config file.
Moreover, you will never be able to call Sitecore.Context in a console application, as the Sitecore Context sits on top of the HttpContext which means that it must be an application and have a valid request for you to use it. What you are looking for is something more along the lines of Sitecore.Configuration.Factory.GetDatabase("master").
Good luck and happy coding :)
This sounds like a job for the Sitecore Item Web API. I use the Sitecore Item Web API whenever I need to access Sitecore data from the master database outside the context of the Content Management server or outside of the context of the Sitecore application. The Web API definitely does not allow you to do everything that the standard Sitecore API does but it can act as a good base and I now extend upon the Web API instead of writing my own custom web services whenever possible.
Thanks to JemDavis's advise.
After I copied the configuration and made changes to config section to get rid of conflicts. I copied almost all of Sitrecore, analytics and lucene dlls, it worked great.
Only thing you have to remember is, copy the app_config folder to the same location where your dlls are.
Thanks again JemDavis....

Accessing SSDT data for programmatic manipulation

I have an MSSQL 2012 Reporting server set up, and many, many reports made in Sequel Server Data Tools. I would like to have access to the data returned in those reports through C#/ASP.NET.
The end result is to display the data in the KendoUI DataViz suite, but first I need to convert the reports into JSON on the server side.
Is this possible?
Edit: To be clear, I need to know how to access the report data from the web server. Converting data into JSON format is not what I need assistance with.
Yes it is possible. I suggest you to take a look how to return JSON with ASP.NET MVC and how it works.
Since I asked the question, I've learned I can use the atom feed button on the reports to download a .atom file, which contains a URL that provides report data in XML.
You'll need to replace the & in the URL with '&', and then you have a working URL.

Need advice for my Server part

I'm stuck on my server part.
I thing it would be fine if I make an REST architecture but I'm not sure.
My application is that an identitied user edit his name, age, hobbies...and I want to stock all the informations of all the users on my data server. Then, I could send the information of a user to another in a ListView with an adaptater.
Any idea to help me?
Thanks in advance
I have recently added a series of posts to my blog that may help. It covers creating a RESTful service using Java EE technologies on the GlassFish server. The example produces consumes XML, but could easily be adapted to handle JSON.
Part 1 - The Database Model
Part 2 - Mapping the Database Model to JPA Entities
Part 3 - Mapping JPA Entities to XML using JAXB
Part 4 - The RESTful Service

How to create a website which uploads/ download data from/ to Database and Excel files

I am afraid to ask this kind of question as it has many factors to consider and its not easy for others to give suggestions.
But, I have to do this task and couldnt trace out the possible way to do this. One requirement I know is with the help of AJAX controls and Update panel ( I never worked on them) I have to do this.
Please please some ideas and suggstions, of how to start and soem pinpoints to get there.
it will be an internal portal site and users can access the data from this website which I have uploaded to the database and download data using UI I have.
hoping some help on this.
Thank you,
Ramm
You will need 2 components
1. Excel VBA : for retrieving data from web service and sending data to web service
2. Web Service : for providing data to excel vba and receiving data from excel vba for saving to database
I currently working for a project with this kind of mechanism, which involved database as backend and excel as user interface.
Here's a simple example in PHP using MySQL - http://www.w3schools.com/PHP/php_ajax_database.asp
You're right. That's way too much for anyone to try to answer. But here are some links that should help:
Microsoft ASP.NET Ajax: http://www.asp.net/learn/ajax/
Db-driven ASP.NET App Tutorial: http://www.asp.net/learn/3.5-videos/video-363.aspx

Resources