oP = CREATEOBJECT("a.CachStandard.API.oneClass","","") public lnport && ignore public declaration etc - only for testing in command window lnport = 5000 && an example port llResult = op.connect(lnport) && returns a valid connection *--oP now exists and I can view it in the object browser and see interfaces, methods, props, etc.I can view the interfaces and members like so:
otlb=otli.TypeLibInfoFromFile("a.CachStandard.API.oneClass.tlb") FOR each oCoClass in otlb.CoClasses ?" ",oCoClass.name *now each interface associated with this CoClass for each oInterface in oCoClass.Interfaces ?" ",oInterface.name endfor endfor ? ?"Interfaces" FOR each oInterface in otlb.Interfaces ?" ",oInterface.name ENDFOR ? ?"Interface Members for 1st interface" FOR each oMember IN otlb.Interfaces(1).Members ?" ", oMember.name FOR each oParm in oMember.Parameters ?" ",oParm.name ENDFOR ENDFORSo I know it exists and is accessible from vfp. Now I need to pass information to one of its methods but the parameter is an object which contains many props and collections.
public class CACHSessionClass { bool _Connected; string _IP; int _Port; Guid _aCallID; aClass _aRCalls; aScriptClass _aScript; aLogClassCollection _aLog; aRecommendationClass _aRecom; aImageClassCollection _aImages; aStatusEnum _aStatus; string _aTypeCode; then:Now the problem: some of the members of the above CACHSessionClass are classes or collections. For example, here is aClass:
[Serializable] public class aClass { public aClass(); public aClass(int PSAP, int aPosition, DateTime aCallDateTime); public aClass(string aName, string aTeleNumber, double aLatitude, string aLocation, ); public aClassCollection AliFields { get; set; } public int aPosition { get; set; } public Guid aCallID { get; set; } public string aTeleNumber { get; set; } public DateTime aCallDateTime { get; set; } public string aLocation { get; set; } public double aAltitude { get; set; } public string aName { get; set; } public int PSAP { get; set; } public bool IsEqual(aClass ANIALI); }and in turn, the aClassCollection in the above is a collection:
[Serializable] public class aClassCollection : CollectionBase { public aClassCollection(); public aField this[int index] { get; set; } public int Add(aField value); public void Clear(); public bool Contains(aField value); public aField FindByFieldName(string FieldName); public int IndexOf(aField obj); public void Insert(int index, aField value); public void Remove(aField obj); public void RemoveAt(int index); }and in turn, afield in aClassCollection above is like so:
[Serializable] public class aField { public aField(); public aField(string Name, string Value); public string Name { get; set; } public string Value { get; set; } }and on and on and on...
private void CreateSampleaClass() { aClass call0 = new aClass(); call0.ID = Guid.NewGuid().ToString(); call0.CACHCallID = Guid.Empty; call0.aCallDateTime = DateTime.Now; call0.aFields = new aClassCollection(); call0.aName= "A"; call0.aTeleNumber= "23465723463"; call0.aLocation= "location"; etc.......Can anyone help me get started? I think I need to create a session probably like so:
PUBLIC oaClass oaClass = NEWOBJECT('aClass',"a.CachStandard.API.oneClass.tlb") DEFINE CLASS aClass AS session OLEPUBLIC IMPLEMENTS aClass IN "a.CachStandard.API.oneClass.tlb" ENDDEFINEBut that returns the error: "Class cannot be instantiated because Member 'aClass_get_ToString' does not exist.
Public loAPI as a.CachStandard.API.oneClass.aClass loAPI = CREATEOBJECT("a.CachStandard.API.oneClass.aClass","","") loAPI.ID = '00000000-0000-0000-0000-000000000000' loAPI.aTeleNumber = '1234567890' loAPI.alocation = '100 N Main St;HP'But I still need to set objects and collections and pass them...