Example #1
0
        public void Select(string sql, string key, string value, OnKeyValue handler)
        {
            Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql);
            using (dynamic connection = connectionFactory.GetConnection())
            {
                Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection);
                using (DbDataReader reader = command.ExecuteReader())
                {
                    System.Collections.ObjectModel.ReadOnlyCollection <DbColumn> columns = reader.GetColumnSchema();
                    IEnumerator <DbColumn> colsNumerator = columns.GetEnumerator();

                    while (reader.Read())
                    {
                        string attrKeyValue = null;
                        string attrValValue = null;
                        while (colsNumerator.MoveNext())
                        {
                            if (key.Equals(colsNumerator.Current.ColumnName, StringComparison.Ordinal))
                            {
                                int indx = columns.IndexOf(colsNumerator.Current);
                                attrKeyValue = getWrappedValue(reader.GetValue(indx), reader.GetFieldType(indx));
                            }
                            else if (value.Equals(colsNumerator.Current.ColumnName, StringComparison.Ordinal))
                            {
                                int indx = columns.IndexOf(colsNumerator.Current);
                                attrValValue = getWrappedValue(reader.GetValue(indx), reader.GetFieldType(indx));
                            }
                        }
                        colsNumerator.Reset();

                        if (attrKeyValue != null)
                        {
                            handler(attrKeyValue, attrValValue);
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Method used to add a element into a sorted collection without destroying the sorting order.
        /// </summary>
        /// <param name="typeIndex">Index in the collection at which the link type's elements start.</param>
        /// <param name="collection">Sorted collection to add the new view models to.</param>
        /// <param name="link">Embedding relationship including the model element as the child (target).</param>
        /// <param name="c">View model representing the model element to be added to the collection.</param>
        protected virtual void InsertElement(int typeIndex, DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection <DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c)
        {
            System.Collections.ObjectModel.ReadOnlyCollection <DslModeling::ElementLink> lllinks = DslModeling::DomainRoleInfo.GetElementLinks <DslModeling::ElementLink>(parent.Element, DslEditorModeling::DomainModelElement.GetSourceDomainRole(link.GetDomainRelationship()).Id);
            int indexOfLink = lllinks.IndexOf(link) + typeIndex;

            if (indexOfLink >= collection.Count)
            {
                collection.Add(c);
            }
            else
            {
                collection.Insert(indexOfLink, c);
            }
        }
Example #3
0
        internal static Orbit findNextEncounter(this ManeuverNode node)
        {
            System.Collections.ObjectModel.ReadOnlyCollection <Orbit> plan = node.solver.flightPlan.AsReadOnly();
            Orbit curOrbit = node.patch;             // FlightGlobals.ActiveVessel.orbit;

            for (int k = plan.IndexOf(node.patch); k < plan.Count; k++)
            {
                Orbit o = plan[k];
                if (curOrbit.referenceBody.name != o.referenceBody.name && !o.referenceBody.isSun())
                {
                    return(o);
                }
            }
            return(null);
        }
        protected void Grid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            var parameters         = e.Parameters.Split(';');
            var index              = int.Parse(parameters[0]);
            var fieldName          = parameters[1];
            var isGroupRowSelected = bool.Parse(parameters[2]);

            System.Collections.ObjectModel.ReadOnlyCollection <GridViewDataColumn> groupedCols = PurchaseOrdersGrid.GetGroupedColumns();

            if (groupedCols[groupedCols.Count - 1].FieldName == fieldName)
            {
                //  Check groupcolumn is the lowest level group column.

                PurchaseOrdersGrid.ExpandRow(index, true); // ensures consistent behavior
                for (int i = 0; i < PurchaseOrdersGrid.GetChildRowCount(index); i++)
                {
                    var row = (usp_GetPurchaseOrderList_Result)PurchaseOrdersGrid.GetChildRow(index, i);
                    PurchaseOrdersGrid.Selection.SetSelectionByKey(row.PurchaseOrderNumber, isGroupRowSelected);
                }
            }
            else
            {
                //  Checked row is not the lowest group column.   Recursively iterate (requires row expansion).
                int gidx = -1;
                foreach (var gcol in groupedCols)
                {
                    if (gcol.FieldName == fieldName)
                    {
                        gidx = groupedCols.IndexOf(gcol);
                        break;
                    }
                }

                var    checkedDataRow            = (usp_GetPurchaseOrderList_Result)PurchaseOrdersGrid.GetRow(index);
                var    parentFieldnameValuesDict = new Dictionary <string, object>();
                string parentFieldName;
                object parentKeyValue;
                for (int i = gidx; i >= 0; i--)
                {
                    var pcol = groupedCols[i];
                    parentFieldName = pcol.FieldName;
                    parentKeyValue  = GetPropValue(checkedDataRow, parentFieldName);
                    parentFieldnameValuesDict.Add(parentFieldName, parentKeyValue);
                }

                bool isRowChildOfClickedGroup;
                PurchaseOrdersGrid.ExpandRow(index, true);
                for (int i = 0; i <= PurchaseOrdersGrid.VisibleRowCount - 1; i++)
                {
                    var row = (usp_GetPurchaseOrderList_Result)PurchaseOrdersGrid.GetRow(i);

                    isRowChildOfClickedGroup = true;
                    //  Check if row belongs to checked group.
                    foreach (var kvp in parentFieldnameValuesDict)
                    {
                        parentFieldName = kvp.Key;
                        parentKeyValue  = kvp.Value;
                        if (GetPropValue(row, parentFieldName).Equals(parentKeyValue) == false)
                        {
                            isRowChildOfClickedGroup = false;
                            break;
                        }
                    }

                    if (isRowChildOfClickedGroup)
                    {
                        //  Row meets all criteria for belonging to the clicked group, change selected state.
                        PurchaseOrdersGrid.Selection.SetSelectionByKey(row.PurchaseOrderNumber, isGroupRowSelected);
                    }
                }
            }
            UpdatePOSelection();
        }