/// <summary>
        /// دیتای جدول مدل را بر میگرداند
        /// </summary>
        /// <typeparam name="B"></typeparam>
        /// <returns></returns>
        public virtual IDataTable GetDataTable(T p)
        {
            using (var db = new EngineContext())
            {
                var dt = db.Set <T>();
                db.Configuration.ProxyCreationEnabled = false;

                //    var dt = Search(p, set.ToList().AsQueryable());

                IDataTable dataTable = new ObjectDataTable <T>
                {
                    Records     = dt,
                    RecordsList = dt.ToList(),
                    Headers     = GetPropertyNames <T>()
                };
                db.Configuration.ProxyCreationEnabled = true;
                return(dataTable);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Combines polygons with polygons and keeps all geometry. Union acts
        /// like the Boolean OR operation and can be used only with polygons.
        /// </summary>
        /// <param name="sourceTopologyName">[in] The source topology name.</param>
        /// <param name="overlayTopologyName">[in] The overlay topology name.</param>
        /// <returns>  
        /// Returns true if successful.
        /// </returns>
        //�������Ϊ�����Ӷ�������˺͵��Ӷ��������
        private bool Union(string sourceTopologyName, string overlayTopologyName)
        {
            // ��������ģ�Ͷ���
            TopologyModel sourceTopology = null;

            // �����������ݶ��󼯺�
            OverlayDataCollection sourceDataCollection = null;

            MapApplication mapApp = HostMapApplicationServices.Application;
            //��ȡ��ǰ���̵�����ģ��
            Topologies topos = mapApp.ActiveProject.Topologies;

            // Does the Source Topology exist to get information from
            //�жϴ���������ģ���Ƿ����
            if (topos.Exists(sourceTopologyName))
            {
                sourceTopology = topos[sourceTopologyName];
            }
            else
            {
                Utility.AcadEditor.WriteMessage(string.Format("\nERROR: The topology {0} doesn't exist.", sourceTopologyName));
                return false;
            }

            // �������Ӷ��������ģ�Ͷ���
            TopologyModel overlayTopology = null;

            // �����������ݶ��󼯺�
            OverlayDataCollection overlayDataCollection = new OverlayDataCollection();
            string expression = "";
            expression = string.Format(":AREA@TPMCNTR_{0}", overlayTopologyName);
            OverlayData data = new OverlayData(expression, "PolygonArea", Autodesk.Gis.Map.Constants.DataType.Real);
            overlayDataCollection.Add(data);

            // �жϵ�������ģ���Ƿ����
            if (topos.Exists(overlayTopologyName))
            {
                overlayTopology = topos[overlayTopologyName];
            }
            else
            {
                Utility.AcadEditor.WriteMessage(string.Format("\nERROR: The topology {0} doesn't exist.", overlayTopologyName));
                return false;
            }

            try
            {
                // ��Դ����ģ�ͣ�����ȡ
                sourceTopology.Open(Autodesk.Gis.Map.Topology.OpenMode.ForRead);

                // �򿪵�������ģ�ͣ�����ȡ
                overlayTopology.Open(Autodesk.Gis.Map.Topology.OpenMode.ForRead);

                // ���ýڵ㴴������
                PointCreationSettings nodeCreationSettings = new PointCreationSettings(
                    "result",           // layer name
                    1,				    // color, by layer
                    true,			    // create new node
                    "ACAD_POINT");      // block name

                //���ýڵ㴴��
                sourceTopology.SetNodeCreationSettings(nodeCreationSettings);

                //�����˵�����
                string newTopologyName = "Result";
                //�����˵�����
                string newTopologyDesc = "Result topology of an Union operation";

                //���������˵Ķ������ݱ�
                ObjectDataTable resultDataTable = new ObjectDataTable();
                resultDataTable.ODTableName = "UnionResult";
                resultDataTable.ODTableDescription = "The result of the Union Overlay";

                // ��
                sourceTopology.Union(overlayTopology,
                    newTopologyName,
                    newTopologyDesc,
                    resultDataTable,
                    sourceDataCollection,
                    overlayDataCollection);

                TopologyModel newTopology = topos[newTopologyName];
                newTopology.Open(Autodesk.Gis.Map.Topology.OpenMode.ForRead);
                newTopology.ShowGeometry(5);
                newTopology.Close();

                return true;
            }
            catch (MapException e)
            {
                if (2001 == e.ErrorCode)
                {
                    Utility.AcadEditor.WriteMessage("\nERROR: Topology Result already exists.");
                }
                else
                {
                    Utility.AcadEditor.WriteMessage(string.Format("\nERROR: Operation failed with error code: {0}.",  e.ErrorCode));
                }
                return false;
            }
            finally
            {
                // Close the topologys
                sourceTopology.Close();
                overlayTopology.Close();
            }
        }