예제 #1
0
        /// <summary>
        ///     Gets a dictionary of the fields that are assigned the <paramref name="modelNames" /> organized by the model name
        ///     followed by the field indexes.
        ///     specified <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class</param>
        /// <param name="modelNames">The model names.</param>
        /// <returns>
        ///     Returns the  <see cref="Dictionary{Key, Value}" /> representing the field model name for the field indexes.
        /// </returns>
        /// <exception cref="ArgumentNullException">modelNames</exception>
        public static Dictionary <string, List <int> > GetFieldIndexes(this IObjectClass source, params string[] modelNames)
        {
            if (source == null)
            {
                return(null);
            }
            if (modelNames == null)
            {
                throw new ArgumentNullException("modelNames");
            }

            Dictionary <string, List <int> > indexes = new Dictionary <string, List <int> >(StringComparer.Create(CultureInfo.CurrentCulture, true));

            foreach (var modelName in modelNames)
            {
                var list = new List <int>();

                if (indexes.ContainsKey(modelName))
                {
                    list = indexes[modelName];
                }
                else
                {
                    indexes.Add(modelName, list);
                }

                list.AddRange(source.GetFields(modelName).Select(field => source.FindField(field.Name)));
            }

            return(indexes);
        }
예제 #2
0
        /// <summary>
        ///     Gets all of the fields that has been assigned the <paramref name="modelNames" /> that is within the
        ///     specified <paramref name="source" />.
        /// </summary>
        /// <param name="source">The object class to check for model names</param>
        /// <param name="modelNames">The model names.</param>
        /// <returns>
        ///     Returns the  <see cref="IEnumerable{IField}" /> that has been assigned the model name.
        /// </returns>
        public static IEnumerable <IField> GetFields(this ITable source, params string[] modelNames)
        {
            if (source == null)
            {
                return(null);
            }
            IObjectClass table = source as IObjectClass;

            if (table == null)
            {
                return(null);
            }

            return(table.GetFields(modelNames));
        }
예제 #3
0
 /// <summary>
 ///     Gets all of the fields that has been assigned the <paramref name="modelNames" /> that is within the
 ///     specified <paramref name="source" />.
 /// </summary>
 /// <param name="source">The object class to check for model names</param>
 /// <param name="modelNames">The model names.</param>
 /// <returns>
 ///     Returns the  <see cref="IEnumerable{IField}" /> that has been assigned the model name.
 /// </returns>
 /// <exception cref="ArgumentNullException">modelNames</exception>
 public static IEnumerable <IField> GetFieldsAsync(this IObjectClass source, params string[] modelNames)
 {
     return(Task.Wait(() => source.GetFields(modelNames)));
 }
예제 #4
0
        private static List <Plan> SelectPlans(IDataSource ds, string WhereClause)
        {
            List <Plan> list   = new List <Plan>();
            IFdeCursor  cursor = null;
            IRowBuffer  row    = null;

            try
            {
                if (ds == null)
                {
                    return(list);
                }
                IFeatureDataSet fds = ds.OpenFeatureDataset("UP_PlanLibDs_Indication");
                if (fds == null)
                {
                    return(list);
                }
                IObjectClass class2 = fds.OpenObjectClass("UP_Plan");
                if (class2 != null)
                {
                    IQueryFilter filter = new QueryFilter
                    {
                        WhereClause = WhereClause
                    };
                    IFieldInfoCollection fiCol = class2.GetFields();
                    cursor = class2.Search(filter, true);
                    while ((row = cursor.NextRow()) != null)
                    {
                        Plan plan = new Plan
                        {
                            PlanID        = (row.IsNull(fiCol.IndexOf("oid"))) ? -1 : Convert.ToInt32(row.GetValue(fiCol.IndexOf("oid"))),
                            PlanGuid      = (row.IsNull(fiCol.IndexOf("planGuid"))) ? "" : row.GetValue(fiCol.IndexOf("planGuid")).ToString(),
                            PlanName      = (row.IsNull(fiCol.IndexOf("planName"))) ? "" : row.GetValue(fiCol.IndexOf("planName")).ToString(),
                            PlanCode      = (row.IsNull(fiCol.IndexOf("planCode"))) ? "" : row.GetValue(fiCol.IndexOf("planCode")).ToString(),
                            PlanDesigner  = (row.IsNull(fiCol.IndexOf("planDesigner"))) ? "" : row.GetValue(fiCol.IndexOf("planDesigner")).ToString(),
                            PlanState     = (row.IsNull(fiCol.IndexOf("planState"))) ? PlanState.None : (PlanState)row.GetValue(fiCol.IndexOf("planState")),
                            ProjectID     = (row.IsNull(fiCol.IndexOf("projectID"))) ? -1 : Convert.ToInt32(row.GetValue(fiCol.IndexOf("projectID"))),
                            XOffset       = (row.IsNull(fiCol.IndexOf("xOffset"))) ? double.NaN : Convert.ToDouble(row.GetValue(fiCol.IndexOf("xOffset"))),
                            YOffset       = (row.IsNull(fiCol.IndexOf("yOffset"))) ? double.NaN : Convert.ToDouble(row.GetValue(fiCol.IndexOf("yOffset"))),
                            Creator       = (row.IsNull(fiCol.IndexOf("creator"))) ? "" : row.GetValue(fiCol.IndexOf("creator")).ToString(),
                            CreateTime    = (row.IsNull(fiCol.IndexOf("createTime"))) ? DateTime.MinValue : (DateTime)row.GetValue(fiCol.IndexOf("createTime")),
                            AbandonReason = (row.IsNull(fiCol.IndexOf("abandonReason"))) ? "" : row.GetValue(fiCol.IndexOf("abandonReason")).ToString(),
                            Description   = (row.IsNull(fiCol.IndexOf("description"))) ? "" : row.GetValue(fiCol.IndexOf("description")).ToString(),
                            Bound         = (row.IsNull(fiCol.IndexOf("Bound"))) ? "" : row.GetValue(fiCol.IndexOf("Bound")).ToString(),
                            ConnType      = (row.IsNull(fiCol.IndexOf("ConnType"))) ? PlanType.None : (PlanType)row.GetValue(fiCol.IndexOf("ConnType"))
                        };
                        if (plan.ConnType == PlanType.Network)
                        {
                            list.Add(new NetWorkPlan(plan));
                        }
                        else
                        {
                            list.Add(new LocalPlan(plan));
                        }
                    }
                }
                return(list);
            }
            catch (Exception exception)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
            return(list);
        }