Beispiel #1
0
        private void RenderObjectFeed(ref Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult)
        {
            object[] objectList =
                (object[])invokeResult.Result.GetResult();

            ArgumentCollection dataListArgs =
                new ArgumentCollection();

            for (int index = 0; index < objectList.Length; index++)
            {
                dataListArgs.Reset();

                dataListArgs.AppendKeyWithValue("CurrentObject", objectList[index]);
                dataListArgs.AppendKeyWithValue("_sys_ItemIndex", index);
                dataListArgs.AppendKeyWithValue("ItemIndex", index);

                this.RenderRow(index, dataListArgs);
            }

            this._Parent.Parent.Arguments.AppendKeyWithValue(
                this._Parent.DirectiveId,
                new DataListOutputInfo(this._Parent.UniqueId, invokeResult.Result.Count, invokeResult.Result.Total, false)
                );
        }
Beispiel #2
0
        private void RenderPartialDataTable(ref Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult)
        {
            ArgumentCollection dataListArgs =
                new ArgumentCollection();
            bool isItemIndexColumnExists = false;

            DataTable repeaterList =
                (DataTable)invokeResult.Result.GetResult();

            foreach (DataColumn dC in repeaterList.Columns)
            {
                isItemIndexColumnExists =
                    string.Compare(dC.ColumnName, "ItemIndex", StringComparison.InvariantCultureIgnoreCase) == 0;

                dataListArgs.AppendKey(dC.ColumnName);
            }

            for (int index = 0; index < repeaterList.Rows.Count; index++)
            {
                dataListArgs.Reset(
                    repeaterList.Rows[index].ItemArray);
                dataListArgs.AppendKeyWithValue("_sys_ItemIndex", index);
                // this is for user interaction
                if (!isItemIndexColumnExists)
                {
                    dataListArgs.AppendKeyWithValue("ItemIndex", index);
                }

                this.RenderRow(index, dataListArgs);
            }

            this._Parent.Parent.Arguments.AppendKeyWithValue(
                this._Parent.DirectiveId,
                new DataListOutputInfo(this._Parent.UniqueId, invokeResult.Result.Count, invokeResult.Result.Total, false)
                );
        }
Beispiel #3
0
        private void RenderDirectDataAccess(ref Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult)
        {
            IDbCommand dbCommand =
                (IDbCommand)invokeResult.Result.GetResult();

            if (dbCommand == null)
            {
                throw new NullReferenceException(
                          $"DirectDataAccess [{this._Parent.DirectiveId}] failed! DatabaseCommand must not be null!");
            }

            IDataReader dbReader = null;

            try
            {
                dbCommand.Connection.Open();
                dbReader = dbCommand.ExecuteReader();

                ArgumentCollection dataListArgs =
                    new ArgumentCollection();
                bool isItemIndexColumnExists = false;

                int count = 0; long total = -1;

                while (dbReader.Read())
                {
                    dataListArgs.Reset();

                    for (int cC = 0; cC < dbReader.FieldCount; cC++)
                    {
                        if (string.Compare(dbReader.GetName(cC), "_sys_Total", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            total = dbReader.GetInt64(cC);
                        }

                        isItemIndexColumnExists =
                            string.Compare(dbReader.GetName(cC), "ItemIndex", StringComparison.InvariantCultureIgnoreCase) == 0;

                        dataListArgs.AppendKeyWithValue(dbReader.GetName(cC), dbReader.GetValue(cC));
                    }
                    dataListArgs.AppendKeyWithValue("_sys_ItemIndex", count);
                    // this is for user interaction
                    if (!isItemIndexColumnExists)
                    {
                        dataListArgs.AppendKeyWithValue("ItemIndex", count);
                    }

                    this.RenderRow(count, dataListArgs);

                    count++;
                }

                this._Parent.Parent.Arguments.AppendKeyWithValue(
                    this._Parent.DirectiveId,
                    new DataListOutputInfo(this._Parent.UniqueId, count, total == -1 ? count : total, false)
                    );
            }
            catch (Exception ex)
            {
                this.RenderError(Basics.ControlResult.Message.Types.Error, ex.Message);

                Basics.Console.Push("Execution Exception...", ex.Message, ex.ToString(), false, true, type: Basics.Console.Type.Error);
            }
            finally
            {
                if (dbReader != null)
                {
                    dbReader.Close();
                    dbReader.Dispose();
                }

                if (dbCommand.Connection.State == ConnectionState.Open)
                {
                    dbCommand.Connection.Close();
                }

                dbCommand.Dispose();
            }
        }