How do I configure an existing website or create a new one in WiX? - iis

I'm creating a wix installer to install multiple web applications, I give the user the option to select an existing website or create a new one. So far, I have implemented the user interface and queried the IIS for the existing websites, but the problem is that I don't know how to configure these two options. I tried using conditional components where I check for a property I set in a custom action but the issue with this scenario is that I end up placing the website element inside a component which I don't want to do in case the user chose an existing website(to avoid it from getting deleted on uninstall)..I found solutions on the web for installing to an existing website or creating a new one but never the both..Can anyone help me with this?

You can create Custom action for that and set the result of it to wix property.
string result ;
session["RESULT"] = result;
then in your wxs :
<Custom Action="InstallWebsite" After='InstallFinalize'>NOT Install AND (<![CDATA[RESULT<>"Existing"]]>)</Custom>

You can create Custom action for that and set the result of it to wix property.
string result ;
session["RESULT"] = result;
then in your wxs :

Related

How to Upload images from local folder to Sitecore

`webClient.UploadFile("http://www.myurl.com/~/media/DCF92BB74CDA4D558EEF2D3C30216E30.ashx", #"E:\filesImage\Item.png");
I'm trying to upload images to sitecore using webclient.uploadfile() method by sending my sitecore address and the path of my local images.But I'm not able to upload it.I have to do this without any API's and Sitecore Instances.
The upload process would be the same as with any ASP.net application. However, once the file has been uploaded you need to create a media item programtically. You can do this from an actual file in the file system, or from a memory stream.
The process involves using a MediaCreator object and using its CreateFromFile method.
This blog post outlines the whole process:
Adding a file to the Sitecore Media Library programatically
If you're thinking simply about optimizing your developer workflow you could use the Sitecore PowerShell Extensions using the Remoting API as described in this this blog post
If you want to use web service way than you can use number of ways which are as follows:
a) Sitecore Rocks WebService (If you are allowed to install that or it is already available).
b) Sitecore Razl Service(It is third party which need license).
c) Sitecore Powershell Remoting (This needs Sitecore PowerShell extensions to be installed on Sitecore Server).
d) You can also use Sitecore Service which you can find under sitecore\shell\WebService\Service.asmx (But this is legacy of new SitecoreItemWebAPI)
e) Last is my enhanced SitecoreItemWebAPI (This also need SitecoreItemWebApi 1.2 as a pre-requisite).
But in end except option d you need to install some or other thing in order to upload the image using HTTP, you should also know the valid credentials to use any of above stated methods.
If your customers upload the image on the website, you need to create the item in your master database. (needs access and write right on the master database) depend on your security you might consider not build it with custom code.
But using the Sitecore webforms for marketers module With out of the box file upload. Create a form with upload field and using the WFFM webservices.
If you dont want to use Sitecore API, then you can do the following:
Write a code that uploads images into this folder : [root]/upload/
You might need to create folder structure that represent how the images are stored in Sitecore, eg: your images uploaded into [root]/upload/Import/ will be stored in /sitecore/media library/Import
Sitecore will automatically upload these images into Media library
Hope this helps
Option: You can use Item Web API for it. No reference to any Sitecore dll is needed. You will only need access to the host and be able to enable the Item Web API.
References:
Upload the files using it: http://www.sitecoreinsight.com/how-create-media-items-using-sitecore-item-web-api/
Enable Item Web Api: http://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/sitecore_item_web_api_developer_guide_sc66-71-a4.pdf#search=%22item%22
I guess that is pretty much what you need, but as Jay S mentioned, if you put more details on your question helps on finding the best option to your particular case.
private void CreateImageIteminSitecore()
{
filePath = #"C:\Sitecore\Website\ImageTemp\Pic.jpg;
using (new SecurityDisabler())
{
Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
Sitecore.Resources.Media.MediaCreatorOptions options = new Sitecore.Resources.Media.MediaCreatorOptions();
options.FileBased = true;
options.AlternateText = Path.GetFileNameWithoutExtension(filePath);
options.Destination = "/sitecore/media library/Downloads/";
options.Database = masterDb;
options.Versioned = false; // Do not make a versioned template
options.KeepExisting = false;
Sitecore.Data.Items.MediaItem mediaitemImage = new Sitecore.Resources.Media.MediaCreator().CreateFromFile(filePath, options);
Item ImageItem = masterDb.GetItem(mediaitemImage.ID.ToString());
ImageItem.Editing.BeginEdit();
ImageItem.Name = Path.GetFileNameWithoutExtension(filePath);
ImageItem.Editing.EndEdit();
}
}

Register/ Login/ Membership module in Orchard

I can't figure out how to add Register/Login functionality to a site in Orchard. Is there a Membership module or some configuration I need to enable?
EDIT: What I had in mind were modules along the lines of these that extend the existing User model with registration/profile functionality:
Extended Registration module: http://extendedregistration.codeplex.com/
Orchard Profile module: http://orchardprofile.codeplex.com/
It's under settings/users in the admin ui.
In the Dashboard scroll down to Settings and select Users.
Make sure "Users can create new accounts on the site" is checked and click "Save".
Once this is done log out.
Then click log in, and bellow your username and password field there will be a small text with a blue link to Register.
You don't actually need the extended registration and profile for this. Those are for adding additional information to the registration form.
This can also be done programmatically:
var registrationSettings = _services.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
registrationSettings.UsersCanRegister = true;
However this will not work if you're doing it from Migrations because you won't be able to use WorkContext.
For migrations you can use IRepository for RegistrationSettingsPartRecord:
RegistrationSettingsPartRecord currentSetting = _registrationSettingRepository.Table.First();
currentSetting.UsersCanRegister = true;
_registrationSettingRepository.Update(currentSetting);
However this will no longer work as of Orchard version 1.8 as the record no longer exists. As of 1.8 one way I know of would be using ISiteService:
var site = _siteService.GetSiteSettings();
var regsettings = site.As<RegistrationSettingsPart>();
regsettings.UsersCanRegister = true;

Is it possible to add Bamboo Web Parts to a web part page programmatically in SharePoint?

Can't find much information on how to do this at all - how can I add in a web part and then configure the settings for it?
Here's a code snippet that will do that for you. In this example, I put a Content Editor Web Part on the page and set the content of it programmatically. If you want to find out what properties your web part has, you can manually put it on a page and export it. Examine the exported file for the property names.
In your case, must must reference the 3rd party DLL, and use the name on the desired web part instead of the ContentEditorWebPart. You can find out the name by either using the Object Browser or Reflector.
SPFile spPageFile = web.GetFile(targetFilePath);
using (SPLimitedWebPartManager theMan = spPageFile.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
ContentEditorWebPart cewp = new ContentEditorWebPart();
cewp.ChromeType = PartChromeType.None;
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlEl = xmlDoc.CreateElement("NewCEWP");
xmlEl.InnerText = string.Format(#"<h2>Blah blah blah...</h2>");
cewp.Content = xmlEl;
theMan.AddWebPart(cewp, "Main", 0);
theMan.SaveChanges(wp);
}
Hope this helps.
Load the page you want to add the web part to via object model.
Get the SPLimitedWebPartManager for this page.
Add the web part you want via the AddWebPart() method.
If your web part uses the normal web part configuration then you can access the settings via the web parts properties.

Cannot use SPWeb, database login failed

We have an archive site that is an exact copy of the "live" site, but uses a different service account. I have built an EditControlBlock extension that redirects a user to a page in the _layouts folder. The page has some text on it and an Ok button.
Edit: The SPWeb i am trying to use is in a different WebApplication. I am trying to move file x to the archive site.
When the Ok buttons is clicked, it should execute the following code:
using (var archive = new SPSite(archiveurl, SPContext.Current.Web.CurrentUser.UserToken))
{
using (var newsArchive = archive.RootWeb.Webs[SPContext.Current.Web.Name])
{
//move file
}
}
The weird thing is, it breaks on line 2: using (var newsArchive = archive.RootWeb.Webs[SPContext.Current.Web.Name]) Which is weird, because the first line DOES work.
The error I get is:
login failed for user x on database y
Anyone have an idea here? Is code on a page derived from LayoutsPageBase always run as the web app apppool account or something?
I have set the Database ights for the moment on the target database. I had to make the apppool user of the source web app a member of the db_owner group in the target database. Not to sure if this is the way to go. Anyone with a better idea please tell me.

WSS 3.0 Site Provisioning

Is there any way to do WSS 3.0 site provisioning? My client's requirement is attributes as variables that will be defined in XML format: Organization Name, Logo, Address, User and Role information. The client should be able to install this web application to any WSS production server by just defining the attributes in the XML file.
Is it possible to to write a utility to parse that well defined XML and provision the site accordingly?
It's possible to provision sites from the object model, but creating entirely customized sites is beyond the scope of a single question. To get you started, you should take a look at the SPWebCollection.Add as well as the SPSiteCollection.Add.
To create a site collection and some subsites into one of your web applications, you could use something like this:
var farm = SPFarm.Local;
var solution = farm.Solutions.GetValue<SPSolution>("YourSolution.wsp");
var application = solution.DeployedWebApplications.First();
var sites = application.Sites;
using(var site = sites.Add("/", "Root Site", "Description", 1033, "YOURTEMPLATE#1", "YOURDOMAIN\SiteCollectionAdmin", "Site Collection Admin", "admin#yourcompany.example")) {
using(var rootWeb = site.RootWeb) {
// Code customizing root site goes here
using (var subSite = rootWeb.Webs.Add("SubSite", "Sub Site", "Description", 1033, "YOURTEMPLATE#2", false, false)) {
// Code customizing sub site goes here
}
}
}
Yes, there are more than one.
Take a look at SharePoint Solution Generator which is in Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions.
You may create a site with all requirements of yours (pages, lists, document libraries...) and then generate a VS project that will create a SharePoint feature with all of your site. Then you may deploy that feature to any WSS production server.
You may alter the VS project to implement the logic to read your attributes from an additional xml file.
If the structure of your site is plain or you can save it as a template you may also write a small console application that reads the attribute xml file and create the site.
Create a regular solution, or use the aforementioned solution generator to generate the .wsp file. Then create a small console application, that expects the variables you mentioned as parameters.
With the code listed above, provision the new sitecollection from that solution, and store the entered parameters (Company name etc.) in the site in a list, or in the SPSite.Properties propertybag, from which you can then read them in custom webparts etc..
The SharePoint Data Population Tool available on CodePlex allows you to define sites with XML.

Resources