private void InitParameters(Parse headerCells)
        {
            Dictionary <String, DbParameterAccessor> allParams =
                dbEnvironment.GetAllProcedureParameters(procedureName);

            columnAccessors = new ColumnAccessors();
            for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
            {
                String paramName = NameNormaliser.NormaliseName(headerCells.Text);
                try
                {
                    DbParameterAccessor accessor = DbParameterAccessor.CloneWithSameParameter(allParams[paramName]);
                    accessor.IsBoundToCheckOperation = BindingFactory.CheckIsImpliedBy(headerCells.Text);
                    // sql server quirk. if output parameter is used in an input column, then
                    // the param should be remapped to IN/OUT
                    if ((!accessor.IsBoundToCheckOperation) &&
                        accessor.DbParameter.Direction == ParameterDirection.Output)
                    {
                        accessor.DbParameter.Direction = ParameterDirection.InputOutput;
                    }
                    columnAccessors.Assign(paramName, accessor);
                    accessors.Add(accessor);
                }
                catch (KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find parameter " + paramName);
                }
            }
        }
Exemplo n.º 2
0
        // this method will initialise accessors array from the parameters that
        // really go into the insert command and columnAccessors for all columns
        private void InitParameters(Parse headerCells)
        {
            Dictionary <String, DbParameterAccessor> allParams =
                dbEnvironment.GetAllColumns(parameterTableType);

            columnAccessors = new ColumnAccessors();
            isOutputColumn  = new bool[headerCells.Size];
            var paramAccessors = new List <DbParameterAccessor>();

            for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
            {
                String paramName = NameNormaliser.NormaliseName(headerCells.Text);
                DbParameterAccessor currentColumn;
                try
                {
                    currentColumn = allParams[paramName];
                }
                catch (KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find column " + paramName);
                }
                isOutputColumn[i] = BindingFactory.CheckIsImpliedBy(headerCells.Text);
                currentColumn.IsBoundToCheckOperation = isOutputColumn[i];
                columnAccessors.Assign(paramName, currentColumn);
                if (isOutputColumn[i])
                {
                    if (dbEnvironment.SupportsReturnOnInsert)
                    {
                        currentColumn.DbParameter.Direction = ParameterDirection.Output;
                        paramAccessors.Add(currentColumn);
                    }
                    else // don't add to paramAccessors
                    {
                        //columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType));
                        columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType, parameterTableType));
                    }
                }
                else // not output
                {
                    currentColumn.DbParameter.Direction = ParameterDirection.Input;
                    paramAccessors.Add(currentColumn);
                }

                table.Columns.Add(currentColumn.DbFieldName, currentColumn.DotNetType);
            }
            accessors = paramAccessors.ToArray();
        }
Exemplo n.º 3
0
        private void InitParameters(Parse headerCells)
        {
            Dictionary <String, DbParameterAccessor> allParams =
                dbEnvironment.GetAllColumns(tableName);

            columnAccessors = new ColumnAccessors();
            IList <DbParameterAccessor> selectAccList = new List <DbParameterAccessor>();
            IList <DbParameterAccessor> updateAccList = new List <DbParameterAccessor>();

            for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
            {
                String paramName = NameNormaliser.NormaliseName(headerCells.Text);
                try
                {
                    DbParameterAccessor acc = allParams[paramName];
                    acc.DbParameter.Direction = ParameterDirection.Input;
                    // allow same column to be used in both sides:
                    // remap update parameters to u_paramname and select to s_paramname
                    acc = DbParameterAccessor.Clone(acc, dbEnvironment);
                    if (headerCells.Text.EndsWith("="))
                    {
                        acc.DbParameter.ParameterName = acc.DbParameter.ParameterName + "_u";
                        updateAccList.Add(acc);
                        columnAccessors.Assign(paramName + "=", acc);
                    }
                    else
                    {
                        acc.DbParameter.ParameterName = acc.DbParameter.ParameterName + "_s";
                        selectAccList.Add(acc);
                        columnAccessors.Assign(paramName, acc);
                    }
                }
                catch (KeyNotFoundException)
                {
                    Wrong(headerCells);
                    throw new ApplicationException("Cannot find column for " + paramName);
                }
            }
            selectAccessors = new DbParameterAccessor[selectAccList.Count];
            selectAccList.CopyTo(selectAccessors, 0);
            updateAccessors = new DbParameterAccessor[updateAccList.Count];
            updateAccList.CopyTo(updateAccessors, 0);
        }
 public override void DoRows(Parse rows)
 {
     if (String.IsNullOrEmpty(procedureName))
     {
         procedureName = Args[0];
     }
     if (rows != null)
     {
         InitParameters(rows.Parts);
         InitCommand();
         base.DoRows(rows);
     }
     else
     {
         columnAccessors = new ColumnAccessors();
         InitCommand();
         command.ExecuteNonQuery();
     }
 }
Exemplo n.º 5
0
        private static GridRow CreateRow(Grouping grouping, Object o, int indent)
        {
            IXenObject ixmo = o as IXenObject;

            if (ixmo != null)
            {
                bool    isFolderRow = (o is Folder);
                GridRow _row        = NewGroupRow(ixmo.opaque_ref, ixmo, isFolderRow ? FOLDER_ROW_HEIGHT : ROW_HEIGHT, 0);

                foreach (ColumnNames column in Enum.GetValues(typeof(ColumnNames)))
                {
                    GridItemBase item = ColumnAccessors.Get(column).GetGridItem(ixmo);
                    if (item != null)
                    {
                        if (column == XenAdmin.XenSearch.ColumnNames.name)
                        {
                            EventHandler onDoubleClickDelegate = isFolderRow ?
                                                                 (EventHandler) delegate
                            {
                                Program.MainWindow.DoSearch(Search.SearchForFolder(ixmo.opaque_ref));
                            } :
                            (EventHandler) delegate
                            {
                                if (Program.MainWindow.SelectObject(ixmo) &&
                                    Program.MainWindow.TheTabControl.TabPages.Contains(Program.MainWindow.TabPageGeneral))
                                {
                                    Program.MainWindow.SwitchToTab(MainWindow.Tab.Settings);
                                }
                            };
                            GridImageItem _statusItem = new GridImageItem(
                                "foo",
                                new ImageDelegate(delegate()
                            {
                                return(Images.GetImage16For(ixmo));
                            }),
                                HorizontalAlignment.Left, VerticalAlignment.Top, true,
                                onDoubleClickDelegate);
                            _row.AddItem("name", NewNameItem(_statusItem, item, 16, indent));
                        }
                        else
                        {
                            _row.AddItem(column.ToString(), item);
                        }
                    }
                }

                AddCustomFieldsToRow(ixmo, _row);

                return(_row);
            }

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


            GridRow row = NewGroupRow(String.Format("{0}: {1}", grouping.GroupingName, o), null, ROW_HEIGHT, 0);

            GridImageItem statusItem = new GridImageItem(
                grouping.GroupingName,
                new ImageDelegate(delegate()
            {
                return(Images.GetImage16For(grouping.GetGroupIcon(o)));
            }),
                HorizontalAlignment.Left, VerticalAlignment.Top, true);

            GridVerticalArrayItem nameItem = NewDoubleRowItem(grouping, o);

            row.AddItem("name", NewNameItem(statusItem, nameItem, 16, indent));

            return(row);
        }