[mapguide-users] Re: Create feature source

VOLZ Mark (FN) Mark.Volz at ergon.com.au
Tue Nov 23 23:47:48 EST 2010


Lee,

I'm using this in Autocad map which means a lot of the class names are
different but they are basically they are the same you just need to
replace the AcMap<class> with Mg<class>

                        AcMapResourceService rs;
                        rs =
AcMapServiceFactory.GetService(MgServiceType.ResourceService) as
AcMapResourceService;
                        AcMapFeatureService fs;
                        fs =
AcMapServiceFactory.GetService(MgServiceType.FeatureService) as
AcMapFeatureService;
                        FeatureSourceType fstype = new
FeatureSourceType();
                        //show loading form
                        Loading loadform = new Loading();
                        loadform.StartPosition =
FormStartPosition.CenterScreen;
                        loadform.Text = "connecting to " + fdo;
 
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(load
form);
                        //create the connection
                        string xmlstring = null;
                        MgResourceIdentifier fsId = new
MgResourceIdentifier(librarypath);
                        //set fdo details
                        fstype.Provider = fdo;
                        NameValuePairType param1 = new
NameValuePairType();
                        param1.Name = "Password";
                        param1.Value = fdo_password;
                        NameValuePairType param2 = new
NameValuePairType();
                        param2.Name = "Service";
                        param2.Value = datasource;
                        NameValuePairType param3 = new
NameValuePairType();
                        param3.Name = "Username";
                        param3.Value = fdo_user;
                        NameValuePairType param4 = new
NameValuePairType();
                        param4.Name = "DataStore";
                        param4.Value = para1;
                        NameValuePairType param5 = new
NameValuePairType();
                        param5.Name = "LongTransaction";
                        param5.Value = para2;
                        fstype.Parameter = new NameValuePairType[] {
param1, param2, param3, param4, param5 };
                        //serialize the featuresource object model to
xml string
                        using (StringWriter writer = new StringWriter())
                        {
                            XmlSerializer xs = new
XmlSerializer(fstype.GetType());
                            xs.Serialize(writer, fstype);
                            xmlstring = writer.ToString();
                        }
                        //convert unicode string to utf8 bytes for
resource service
                        byte[] unicodeBytes =
Encoding.Unicode.GetBytes(xmlstring);
                        byte[] utf8Bytes =
Encoding.Convert(Encoding.Unicode, Encoding.UTF8, unicodeBytes);
                        //create byte reader of xml feature source def.
& store in repository
                        MgByteSource XmlSource = new
MgByteSource(utf8Bytes, utf8Bytes.Length);
                        try
                        {
                            rs.SetResource(fsId, XmlSource.GetReader(),
null);
                            fs.DescribeSchema(fsId, para1);
                            loadform.Dispose();
                        }
                        catch (MgException ex)
                        {
                            MessageBox.Show("error creating " + fdo + "
connection. \nError reads:\n" + ex);
                        }

The real trick with the autodesk Fdo is the LongTransaction parameter if
you are not using oracle workspaces (oracle versioning) simply set this
to Live if you are using workspaces let me know and I can run through
how to find a version. 

Hope this helps.

Mark

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Lee
Sent: Wednesday, 24 November 2010 2:33 PM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] Re: Create feature source


Thanks Mark, I am using Autodesk FDO. I would really appreciate some
example c# .net code would help me a lot.

Lee
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Create-feature-source-tp5768882p5
769213.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users









---------------------------------------------------------------------
To report this email as spam, please forward to spam at mailcontrol.com
---------------------------------------------------------------------

 
*************************************************************************
This e-mail (including any attachments) may contain confidential or
privileged information and is intended for the sole use of the person(s) to
whom it is addressed. If you are not the intended recipient, or the person
responsible for delivering this message to the intended recipient, please
notify the sender of the message or send an e-mail to
mailto:help.desk at ergon.com.au immediately, and delete all copies. Any
unauthorised review, use, alteration, disclosure or distribution of this
e-mail by an unintended recipient is prohibited. Ergon Energy accepts no
responsibility for the content of any e-mail sent by an employee which is of
a personal nature.

Ergon Energy Corporation Limited      ABN 50 087 646 062
*************************************************************************


More information about the mapguide-users mailing list