Cant find my global datatype in C#

Topics: General, Troubleshooting, XSLT
Jun 11, 2011 at 1:39 AM

I created a global datatype through the admin console (PMG.Article.ArticleContent).  The settings are the following
Titie: ArticleContent
Type name: ArticleContent
Type namespace: PMG.Article
both has caching and has publishing are not selected.  I have some Fields in there too, but that's not the problem (I don't think).

I created 2 data entries, and I want to query them through a C# method.

I have a class library, PMG.Article, which has a class ArticleFacade in it. 

The problem is, I have no recognition of the PMG.Article.ArticleContent data type from by C#.  I've read a ton of the articles, tried making Demo.User, and I can't see Demo.User either.

using(DataConnection connection = new DataConnection)
{
     var articles = from a in connection.Get<PMG.Article.ArticleContent>()
          a.ArticleId = 1
          select a;
}

I get no intellisense for PMG.Article.ArticleContent.  If anyone at all can throw an idea at me, I'd be forever greatful (until I have another problem that breaks my brain on a Friday). 

Thanks in advance.

~Brian 

Jun 11, 2011 at 3:18 AM

Hi Brian

Try to reference ~/Bin/Composite.Generated.dll, it should contain all the generated interfaces

 

// Dmitry

Jun 11, 2011 at 11:29 AM
Edited Jun 11, 2011 at 11:30 AM

Hi Brian,

we have a bug right now, where ~/Bin/Composite.Generated.dll do not get updated before you restart the webapp - if you use the "Tools | Restart Server" command in the C1 Console yo should force an update on Composite.Generated.dll - and then you should have sweet Intellisense :)

Marcus

Jun 14, 2011 at 12:04 AM

Hey guys, I appreciate the help.  I had already added the reference to Composite.Generated.dll, but reset the server and tried to remove it and add it numerous times, but I'm still not getting the namespace recognized.  Just to be clear, this is a class library, that resides in the same solution, but not the WebSite project.  I have a reference to the class library in my WebSite project, because through XSLT, I'm able to call the methods inside the class library. 

I have references to Composite.Generated in both the WebSite and my class lib.  I've been resetting the server, removing the .generated.dll from my lib and re-adding it, and still, no PMG.Article namespace is found.  Any other ideas?  Or, is there a better way to do what I'm trying to do?  I'm not opposed to moving some things around here and there.  All I'm really doing here is creating a data layer so through the XSLT functions I can call my C#, which will be able to sort the datatype objects and return back what the site is looking for.  I've poured through a bunch of the articles, and they all seemed to point to this being the way you want to do things.

Jun 14, 2011 at 7:13 AM

If you're having your own Class Library where you want to manage your data layer, you should consider defining the datatypes in there as well. That way you will never have any problems references your data type interfaces. These articles show you how to create datatypes directly in your code and not by the WYSIWYG designer.

http://docs.composite.net/C1/Data/Defining-Data-IData-types-in-C1-using-C.aspx

Jun 28, 2011 at 7:59 PM
Edited Jun 28, 2011 at 7:59 PM

Hey guys,

One more question along the same lines.

We were having trouble with the Composite.Generated.  The server restart (and a bunch of other button mashing) would cause the Composite.Generated to be rebuilt on some users' machines, but not on others.  So, recently I've created my datatype entirely in code behind.  I've called the EnsureCreateStore function at startup and have verified that the tables get created in the database.

But, the kicker is that I can't see this datatype anywhere in the CMS.  I need to be able to add it as a global datatype so that my users can add data through the CMS, and that my code behind still has full access to the type.

Any suggestions?

Thanks

Jon

Jun 28, 2011 at 8:34 PM
Edited Jun 28, 2011 at 8:35 PM

I scratched my head on this one the first time as well, but basically you need to create your own TreeDefinition for what is known in C1 terminology as Static Types. The Global Data folder is only for Dynamic Types.

It's VERY easy though... lets say the type is called Departments. Create a departments.xml file under /App_Data/Composite/TreeDefinitions and use content similar to this

 

<?xml version="1.0" encoding="utf-8"?>

<ElementStructure xmlns="http://www.composite.net/ns/management/trees/treemarkup/1.0" xmlns:f="http://www.composite.net/ns/function/1.0">
  <ElementStructure.AutoAttachments>
    <NamedParent Name="Content" Position="Bottom" />
  </ElementStructure.AutoAttachments>

  <ElementRoot>
    <Children>
      <Element Label="Departments" Id="departments" Icon="pagetype-pagetype-rootfolder" OpenedIcon="pagetype-pagetype-rootfolder-open">
        <Actions>
          <AddDataAction Type="gl.sermersooq.Data.Types.IDepartment, gl.sermersooq" Label="Add" Icon="home-add"/>
        </Actions>

        <Children>
          <DataElements Type="gl.sermersooq.Data.Types.IDepartment, gl.sermersooq" Icon="folder">
            <Actions>
              <EditDataAction Label="Edit" Icon="media-edit-media-folder"/>

              <DeleteDataAction Label="Delete" Icon="home-delete"/>
            </Actions>
          </DataElements>
        </Children>
      </Element>
    </Children>    
  </ElementRoot>
</ElementStructure>
Jun 28, 2011 at 8:46 PM

We haven't made a tool that automatically generate the trees and UI for code based data types (custom IData interfaces written in C#) - you need to build this UI also.

The workload can be pretty lightweight though - 2 fairly simple XML files can do it.

  1. A tree definition (documentation, video) - a XML file you create in ~/App_Data/Composite/TreeDefinitions. The content of the XML is a domain specific language for declaring tree structures for the C1 Console and what commands tree elements have.
  2. A form definition (documentation) - a XML file that layout the form for adding and editing data of your type. It declares UI elements like 'textbox' and how they are bound to data.
  3. Optional extension points: types of actions tree definitions can have like a custom aspx files, form workflows, a C# based tree definition, custom asp.net controls and functions running inside existing forms.

A fast way to get your form definition is to create a data type via the C1 Console, add some or all the fields your own type has, setting up widgets to your liking and then use the "Edit Form XML" command on the type to get the form definition xml - this you can use pretty much as is, save to a file and point to it using <AddDataAction Type="MyType" CustomFormMarkupPath="~/MyPathHere" />.

Check out the application samples for inspiration.

Jun 28, 2011 at 8:56 PM

Thanks guys, works like a charm.

I think the conceptual barrier was understanding when you shift from working in code over to working with markup and in the admin console.

From: mawtex [email removed]
Sent: Tuesday, June 28, 2011 12:47 PM
To: jmoss@studiopmg.com
Subject: Re: Cant find my global datatype in C# [CompositeC1:260994]

From: mawtex

We haven't made a tool that automatically generate the trees and UI for code based data types (custom IData interfaces written in C#) - you need to build this UI also.

The workload can be pretty lightweight though - 2 fairly simple XML files can do it.

1. A tree definition (documentation, video) - a XML file you create in ~/App_Data/Composite/TreeDefinitions. The content of the XML is a domain specific language for declaring tree structures for the C1 Console and what commands tree elements have.

2. A form definition (documentation) - a XML file that layout the form for adding and editing data of your type. It declares UI elements like 'textbox' and how they are bound to data.

3. Optional extension points: types of actions tree definitions can have like a custom aspx files, form workflows, a C# based tree definition, custom asp.net controls and functions running inside existing forms.

A fast way to get your form definition is to create a data type via the C1 Console, add some or all the fields your own type has, setting up widgets to your liking and then use the "Edit Form XML" command on the type to get the form definition xml - this you can use pretty much as is, save to a file and point to it using <AddDataAction Type="MyType" CustomFormMarkupPath="~/MyPathHere" />.

Check out the application samples for inspiration.





Confidentiality Notice: This message and its attachments may contain privileged and/or confidential information and is intended only for the individual or entity named in this message. If you are not the intended recipient, you are hereby notified that any disclosure, copying, retention, distribution or use of information contained in this message is strictly prohibited. If you received this message in error, please notify the sender immediately by return email and permanently delete this message and any attachments from your system. Thank you.
Jun 28, 2011 at 9:21 PM

Yes, we have a gap here in our documentation - we will get some 'how to' docs up soon.

Jun 30, 2011 at 2:11 AM

I finally got past this (my problem at least). 

From a post back in October...
http://compositec1.codeplex.com/discussions/232780

1) Create a backup 
2) Stop the related application pool in IIS
3) Rename App_Code to App_Code1
4*) Move dll-s that are using Composite.Generated.dll, from "/Bin" to "/Bin/Temp" folder
5) Delete file /Bin/Composite.Generated.dll
6) Delete all the files under /App_Data/Composite/Cache/Assemblies
7) Start app pool, run composite backend. (It is possible that backend will not be loaded, in this case just wait 20 seconds)
8) Stop app pool
9) Check that file /Bin/Composite.Generated.dll has been created
10*) Move dlls that were moved on step (4) from "/Bin/Temp" to "/Bin"
11) Rename /App_Code1 to /App_Code
12) Start the application pool


It seems that sometimes the Composite.Generated is happy, and sometimes it just decides to not keep in sync.  I don't know the rhyme or reason for it, but after 2 very frustrating weeks and doing a million workarounds, I'll finally now be able to start doing things "the right way".

Jun 30, 2011 at 3:34 AM

We will add this as a blocking issue and have this fixed in our next release. I'm sorry about the inconvenience.

If anyone knows how to reproduce this issue, please post the steps here :)

Jul 1, 2011 at 2:16 PM

@jmoss We have added a compact sample on the topic, with 'read more' links;http://docs.composite.net/StaticIDataTypesInC1Console