Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > TreeProvider.Connection error in kentico 6 View modes: 
User avatar
Member
Member
rafik4000-hotmail - 12/18/2011 11:02:55 PM
   
TreeProvider.Connection error in kentico 6
Hi,

After the changes of codes API in kentico 6, I tried to fix my codes but I am not able to fix a part called TreeProvider.Connection

Here is the line of code contained this :
CMS.DataEngine.IDataClass treeClass = CMS.DataEngine.DataClassFactory.NewDataClass(node.NodeClassName, node.TreeProvider.Connection);

User avatar
Member
Member
kentico_michal - 12/18/2011 11:34:11 PM
   
RE:TreeProvider.Connection error in kentico 6
Hello,

The NewDataClass class does not provide a constructor that accepts a GeneralConnection object. Only following four constructors are allowed to be used:

DataClassFactory.NewDataClass(string className)
DataClassFactory.NewDataClass(string className, DataRow dataRow)
DataClassFactory.NewDataClass(string className, IDataContainer data)
DataClassFactory.NewDataClass(string className, object primaryKeyValue)


Best regards,
Michal Legen

User avatar
Member
Member
rafik4000-hotmail - 12/19/2011 3:09:16 PM
   
RE:TreeProvider.Connection error in kentico 6
Hi,

I have tried to changed but I still not have a luck to make it work.

Can you assit me more to understand this part

here is my code
// Check for the translation option
if (QueryHelper.GetString("translate", "").Equals("google"))
{
// Setup the from and to cultures
string fromCulture = CultureHelper.GetCultureInfo(node.DocumentCulture).TwoLetterISOLanguageName;
string toCulture = CultureHelper.GetCultureInfo(formElem.CultureCode).TwoLetterISOLanguageName;

// Initiate the Google translate client using the current domain
Google.API.Translate.TranslateClient client = new Google.API.Translate.TranslateClient(UrlHelper.GetCurrentDomain());

// Get the class of the new document
CMS.DataEngine.IDataClass treeClass = CMS.DataEngine.DataClassFactory.NewDataClass(node.NodeClassName, node.TreeProvider.Connection);

// Loop through the column names
foreach (string col in treeClass.StructureInfo.ColumnNames)
{
// Check if the column is of type string
if (treeClass.StructureInfo.GetColumnType(col).Name == "String")
{
// Update the value of the field using Google's translating service
DataHelper.SetDataRowValue(formElem.BasicForm.DataRow, col, client.Translate(ValidationHelper.GetString(node.GetValue(col), ""), fromCulture, toCulture));
}
}
}

User avatar
Member
Member
kentico_michal - 12/20/2011 7:24:53 AM
   
RE:TreeProvider.Connection error in kentico 6
Hello,

Sorry, I do not quite understand what issue are you encountering?

Do you receive any error message after executing this code?

This is your custom code so I am not sure what it is supposed to do.

Best regards,
Michal Legen

User avatar
Member
Member
rafik4000-hotmail - 12/20/2011 10:31:11 PM
   
RE:TreeProvider.Connection error in kentico 6
Hi how are you,

I am trying to integrate google service in kentico 6.0

but my issue is this line
 // Get the class of the new document
CMS.DataEngine.IDataClass treeClass = CMS.DataEngine.DataClassFactory.NewDataClass(node.NodeClassName, node.TreeProvider.Connection);

because it doesn't recognize node.TreeProvider.Connection: who is supposed to connection to the database.

I took the codes and work on from this link

http://blogs.jeroenfurst.nl/Blog/May-2011/API--Integrating-the-Google-translation-service

My issue is in the part:
CMSModules\Content\CMSDesk\Edit\Edit.aspx.cs

I hope that I give you all information you need to assist me to understand the new api code for fixing this connection in kentico 6.0.

My best regards

User avatar
Member
Member
kentico_michal - 12/21/2011 3:24:13 AM
   
RE:TreeProvider.Connection error in kentico 6
Hello,

Please try to add the code on a line 307 instead of 297 in Kentico CMS 6.0.

Moreover, please try to use only the following method:
CMS.DataEngine.IDataClass treeClass = CMS.DataEngine.DataClassFactory.NewDataClass(node.NodeClassName);

Best regards,
Michal Legen

User avatar
Member
Member
rafik4000-hotmail - 12/21/2011 12:01:59 PM
   
RE:TreeProvider.Connection error in kentico 6
Hi Michal,

The error I get in visual studio and the web:

Visual Studio show this error in debugging: [BasicForm.DataRow]:
This property can be read only if it was previously initialized through set.

Web: System.Exception: [BasicForm.DataRow]: This property can be read only if it was previously initialized through set.

So what I found out in debugging the following line is the problem when it try to update the value:
DataHelper.SetDataRowValue(formElem.BasicForm.DataRow, col, client.Translate(ValidationHelper.GetString(node.GetValue(col), ""), fromCulture, toCulture));

User avatar
Member
Member
kentico_michal - 12/22/2011 11:08:52 PM
   
RE:TreeProvider.Connection error in kentico 6
Hello,

The BasicForm.DataRow property has been replaced with the BasicForm.Data.

So, please use the following code

IDataContainer row = formElem.BasicForm.Data;

instead of

DataRow row = formElem.BasicForm.DataRow;

and then, you can access all properties as usual:

string fieldValue = ValidationHelper.GetString(row["FieldName"], String.Empty);


Best regards,
Michal Legen