Trouble with Events.CFunction.GetFunctions Method

What exactly does the 2nd argument need? CEvent parent?? This is my C#: CFunction[] FuncResults = CFunction.GetFunctions(user, ??????); I've tried evrything I can think of.

public static Hashtable GetFunctions(
IiMISUser user,
CEvent parent
)

Thanks for your help
Tom

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The CEvent for which the CFunctions are requested

It is supposed to be the CEvent for which a Hashtable of CFunctions is returned. Is it not working for you? Or do I misunderstand your question?

Richard Kaskan

CFunction[] FuncResults =

CFunction[] FuncResults = CFunction.GetFunctions(user, CEvent);

This is what I tried and it says:

Error 10 'Asi.iBO.Events.CEvent' is a 'type' but is used like a 'variable'

I tried [] and still not work.

You need an instance of a CEvent

You need to supply an instance of a CEvent:


CEvent myEvent = /* obtain reference to your event... */
Hashtable functionList = CFunction.GetFunctions(myUser, myEvent);

CFunction.GetFunctions

As you can see, I'm trying to place the results "FuncResults" into a formview and this is the code so far. I just got back into .net and I'm very rusty. The first two lines here are the rub. The 1st line is still throwing errors. Do I or should I be using the hashtable as you outlined in line two?

CEvent myEvent = CEvent;
CFunction[] FuncResults = CFunction.GetFunctions(user, myEvent);
if (FuncResults.Length > 0)
{
CFunctionSorter sorter = new CFunctionSorter(FunctionSortBy.BeginDateTime);
Array.Sort(results, sorter);

// bind the array to the formview
ViewFuncResults.DataSource = FuncResults;
ViewFuncResults.DataBind();
//ViewResults.DataItem..Focus();

// show the formview
ViewFuncResults.Visible = true;
}
// if we did not get any...
else
{
// hide the formview
ViewFuncResults.Visible = false;
}

Something like this, perhaps...

In the first line you need to get a reference to some CEvent of interest. In the second line you are correct that you need to use a Hashtable or some interface that Hashtable implements. Something like this, perhaps:


CEvent myEvent = new CEvent(loginUser, "EVENT1");
Hashtable functions = CFunction.GetFunctions(loginUser, myEvent);
foreach (CFunction function in functions)
{
// do something
}

HashTable

I built a hashtable with the GetFunctions method, but not sure how to get all of the info back. The key appears to be the functionCode, but the value appears as the Class?? Wouldn't all the CFunction properties be available here? I so could someone help me with the syntax.

This is the code in C#:
string eventCode = Session["strEventID"] as string;
CEvent myEvent = new CEvent(user, eventCode);

Hashtable functions = new Hashtable();
functions = CFunction.GetFunctions(user, myEvent);
// Displays the properties and values of the Hashtable.
foreach (DictionaryEntry function in functions)
{
{
Response.Write(function.Key.ToString() + "
");
Response.Write(function.Value.ToString() + "
");
}
}

This is the display:

Z-01-012
Asi.iBO.Events.CFunction
Z-03
Asi.iBO.Events.CFunction
Z-02-007
Asi.iBO.Events.CFunction
Z-02-001
Asi.iBO.Events.CFunction
CAL-B
Asi.iBO.Events.CFunction
CAL-M
Asi.iBO.Events.CFunction
RT
Asi.iBO.Events.CFunction
Z-01-007
Asi.iBO.Events.CFunction
S2
Asi.iBO.Events.CFunction
Z-02-002
Asi.iBO.Events.CFunction
Z-03-001
Asi.iBO.Events.CFunction
Z-02-005
Asi.iBO.Events.CFunction
Z-01-013
Asi.iBO.Events.CFunction
S3
Asi.iBO.Events.CFunction
Z-02-004
Asi.iBO.Events.CFunction
S1
Asi.iBO.Events.CFunction
RG
Asi.iBO.Events.CFunction
Z-01-005
Asi.iBO.Events.CFunction
G01
Asi.iBO.Events.CFunction
Z-03-003
Asi.iBO.Events.CFunction
Z-01-011
Asi.iBO.Events.CFunction
Z-01-008
Asi.iBO.Events.CFunction
Z-01-006
Asi.iBO.Events.CFunction
Z-02-003
Asi.iBO.Events.CFunction
Z-02-006
Asi.iBO.Events.CFunction
Z-01
Asi.iBO.Events.CFunction
Z-02
Asi.iBO.Events.CFunction
Z-02-009
Asi.iBO.Events.CFunction
CAL
Asi.iBO.Events.CFunction
Z-02-008
Asi.iBO.Events.CFunction
Z-01-003
Asi.iBO.Events.CFunction
Z-01-002
Asi.iBO.Events.CFunction
Z-01-004
Asi.iBO.Events.CFunction
S4
Asi.iBO.Events.CFunction
Z-01-009
Asi.iBO.Events.CFunction
Z-03-004
Asi.iBO.Events.CFunction
Z-03-002
Asi.iBO.Events.CFunction
T10
Asi.iBO.Events.CFunction
Z-01-010
Asi.iBO.Events.CFunction
Z-01-001
Asi.iBO.Events.CFunction

You need to cast the result

The ToString() method of CFunction is the default implementation, which just displays the name of the class. You need to cast the Hashtable values to the CFunction type; then you ought to be able to access them:

foreach (DictionaryEntry entry in functions)
{
    CFunction function = entry.Value as CFunction;
    if (function != null)
    {
          // do what you like...
          if (function.ActualAttendance > 0)
          {
                    // whatever
           }
    }
}

Thanks

Thanks for your patience. My experience has been pulling data directly from the database for years. Now I've got to use the bussiness object along with other objects that I need to use to pull the data from the Bus obj. Dot net is the best way to go but it may take me a while to get settled in. If you know of any classes that deal with dot.net and the imis ibo.net, let me know.

Thanks again : )
Tom