Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Moving user controls from on environment to another. View modes: 
User avatar
Member
Member
vcarter - 10/15/2013 11:02:17 AM
   
Moving user controls from on environment to another.
We are working for a company that has deployed kentico in an Azure environment. A need has arisen for some custom filters, so I created some user controls locally. What is the correct process for implementing these local controls into their environment?

I assume simply sending them the controls and having them dropped into the CMSWebParts folder is not going to work.

Any thoughts and help would be appreciated.

User avatar
Member
Member
vcarter - 10/15/2013 11:08:29 AM
   
RE:Moving user controls from on environment to another.
1              Could not find schema information for the element 'http://schemas.microsoft.com/.NetConfiguration/v2.0:configuration'. C:\TFS\Kentico\KenticoCMS\Web.config


This is the primary error they are getting when they try to build after adding my user controls.

using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using CMS.Controls;
using CMS.EventLog;
using CMS.GlobalHelper;
using CMS.IO;
using CMS.PortalControls;
using CMS.ExtendedControls;

/// <summary>
/// Connects to a generic filter webPart and set's the where condition for custom query data
/// </summary>
public partial class CMSWebParts_Filters_LogoFilter : CMSAbstractQueryFilterControl
{
/// <summary>
/// Child control creation.
/// </summary>
protected override void OnInit(EventArgs e)
{
SetupControl();

base.OnInit(e);

// the Click event of the Button control.
btnFilter.Click += new EventHandler(this.FilterBtn_Click);
}

/// <summary>
/// Setup the inner controls.
/// </summary>
private void SetupControl()
{
drpUsage.Visible = false;
lblUsage.Visible = false;
drpFormat.Visible = false;
lblFormat.Visible = false;
if (this.StopProcessing)
{
this.Visible = false;
}
else if (!RequestHelper.IsPostBack())
{
// Load teams options into Business Unit drop-down list
InitializeUsage();

// Load teams options into Regions drop-down list
Intializetype();

InitializeFormat();

}
}

protected void showExtras(object sender, EventArgs e)
{
if(drpType.SelectedValue != "1"){
drpUsage.Visible = true;
lblUsage.Visible = true;
drpFormat.Visible = true;
lblFormat.Visible = true;
}else{
drpUsage.Visible = false;
lblUsage.Visible = false;
drpFormat.Visible = false;
lblFormat.Visible = false;
}



}


private void Intializetype()
{
// Get administrator uder
UserInfo admin = UserInfoProvider.GetUserInfo("administrator");
if (admin != null)
{
// Get custom table provider
CustomTableItemProvider ctip = new CustomTableItemProvider(admin);
if (ctip != null)
{
// Get all mediaTypes
DataSet mediaTypes = ctip.GetItems("media.mediaTypes", null, "ItemID, ItemOrder ASC");
if (!DataHelper.DataSourceIsEmpty(mediaTypes))
{
// Bind mediaTypes to drop-down list
this.drpType.DataSource = mediaTypes.Tables[0];
this.drpType.DataTextField = "MediaTypeName";
this.drpType.DataValueField = "ItemID";
this.drpType.DataBind();
}
}
}
}

private void InitializeUsage()
{
// Initialize options
this.drpUsage.Items.Add(new ListItem("Print", "1"));
this.drpUsage.Items.Add(new ListItem("Web", "2"));
this.drpUsage.Items.Add(new ListItem("Print/Web", "3"));

}

private void InitializeFormat()
{
// Get administrator uder
UserInfo admin = UserInfoProvider.GetUserInfo("administrator");
if (admin != null)
{
// Get custom table provider
CustomTableItemProvider ctip = new CustomTableItemProvider(admin);
if (ctip != null)
{
// Get all mediaformats
DataSet mediaformats = ctip.GetItems("media.mediaformat", null, "ItemID, ItemOrder ASC");
if (!DataHelper.DataSourceIsEmpty(mediaformats))
{
// Bind mediaTypes to drop-down list
this.drpFormat.DataSource = mediaformats.Tables[0];
this.drpFormat.DataTextField = "FormatName";
this.drpFormat.DataValueField = "ItemID";
this.drpFormat.DataBind();
}
}
}

}

private void FilterBtn_Click(Object sender, EventArgs e)
{
int tp = ValidationHelper.GetInteger(this.drpType.SelectedValue, 0);
int us = ValidationHelper.GetInteger(this.drpUsage.SelectedValue, 0);
int fm = ValidationHelper.GetInteger(this.drpFormat.SelectedValue, 0);

if (tp = 1){
string where = "View_cp_mediaasset_Joined.MediaFileID = View_cp_mediaasset_Joined.MediaFileID";

if(txtSearch.Text.Length > 0 ){
where = where + " AND (View_cp_mediaasset_Joined.documentName LIKE '%" + txtSearch.Text + "%'";
}

}else{
string where = "View_cp_mediafileasset_Joined.MediafileassetID = View_cp_mediafileasset_Joined.MediafileassetID";
if(txtSearch.Text.Length > 0 ){
where = where + " AND (View_cp_mediafileasset_Joined.documentName LIKE '%" + txtSearch.Text + "%' AND View_cp_mediafileasset_Joined.mediaUsage = " + us + " AND View_cp_mediafileasset_Joined.mediaFormat = " + fm ;
}else{
where = where + " AND View_cp_mediafileasset_Joined.mediaUsage = " + us + " AND View_cp_mediafileasset_Joined.mediaFormat = " + fm ;
}
}

if (where != null)
{
// Set where condition
this.WhereCondition = where;
}
this.RaiseOnFilterChanged();
}

}


This is one of my controls.

They are on version 7 and my dev environment is version 6, but I did not think I was using anything that would cause a conflict.

User avatar
Member
Member
vcarter - 10/15/2013 11:09:36 AM
   
RE:Moving user controls from on environment to another.
These are based off of Karol's filter example. BTW.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 10/16/2013 8:11:45 AM
   
RE:Moving user controls from on environment to another.
I'm not 100% sure on this but there may be a different way to deploy those files to your test and live environments from your local dev envrionment vs. simply coping the files. In fact, I know the Kentico Azure Guide has specific deployment guidelines for the website as a whole but not sure how individual files like this are handled.

User avatar
Member
Member
vcarter - 10/16/2013 10:28:00 AM
   
RE:Moving user controls from on environment to another.
When we just tried adding one of the controls we got this error:

Error      1              The type or namespace name 'UserInfo' could not be found (are you missing a using directive or an assembly reference?)    D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs                70           9                CMSApp
Error 2 The name 'UserInfoProvider' does not exist in the current context D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 70 26 CMSApp
Error 3 The type or namespace name 'CustomTableItemProvider' could not be found (are you missing a using directive or an assembly reference?) D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 74 13 CMSApp
Error 4 The type or namespace name 'CustomTableItemProvider' could not be found (are you missing a using directive or an assembly reference?) D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 74 48 CMSApp
Error 5 The type or namespace name 'UserInfo' could not be found (are you missing a using directive or an assembly reference?) D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 97 9 CMSApp
Error 6 The name 'UserInfoProvider' does not exist in the current context D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 97 26 CMSApp
Error 7 The type or namespace name 'CustomTableItemProvider' could not be found (are you missing a using directive or an assembly reference?) D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 101 13 CMSApp
Error 8 The type or namespace name 'CustomTableItemProvider' could not be found (are you missing a using directive or an assembly reference?) D:\Kentico\TFS\Kentico\KenticoCMS\CMSWebParts\Filters\NewsFilter.ascx.cs 101 48 CMSApp


It looks like a piece of the code I used from the filter example is in conflict with version 7. At least that is my assumption since it works on 6. I will look into that guide Froggeye, thank you.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 10/16/2013 11:47:57 AM
   
RE:Moving user controls from on environment to another.
You're missing a using statement:
using CMS.SiteProvider;
That is the namespace for the UserInfo, UserInfoProvider and CustomTableItemProvider objects.

User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 10/16/2013 3:05:38 PM
   
RE:Moving user controls from on environment to another.
Does the import in site manager work? I would imagine that if this works you could specify to import the files. I am not sure about the rules for azure, but this could be an option unless the import is disabled for azure solutions.

User avatar
Member
Member
vcarter - 10/18/2013 10:08:29 AM
   
RE:Moving user controls from on environment to another.
Froggeye was right. When making adjustments for Version 7 I dropped some needed class declarations. Silly me.