Exemplo n.º 1
0
        public override void Render(string requesterUniqueID)
        {
            Basics.Domain.IDomain instance = null;
            InstanceRequested?.Invoke(ref instance);

            this._IDAccessTree = instance.IDAccessTree;
            this._CacheID      =
                CacheObject.ProvideUniqueCacheID(this, ref instance);

            CacheObject cacheObject = null;

            CachePool.Current.Get(this._IDAccessTree, this._CacheID, out cacheObject);

            if (cacheObject != null)
            {
                this.RenderedValue = cacheObject.Content;

                return;
            }

            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            string blockContent = contentDescription.Parts[0];

            this.Parse(blockContent);
            base.Render(requesterUniqueID);
        }
Exemplo n.º 2
0
        public override void Render(string requesterUniqueID)
        {
            if (this.IsUpdateBlockController)
            {
                throw new Exception.RequestBlockException();
            }

            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            string blockContent          = contentDescription.Parts[0];
            string renderOnRequestMarker = "!RENDERONREQUEST";

            if (blockContent.IndexOf(renderOnRequestMarker) == 0)
            {
                if (string.Compare(this.ControlID, this.Mother.ProcessingUpdateBlockControlID) != 0)
                {
                    this.RenderedValue = string.Format("<div id=\"{0}\"></div>", this.ControlID);

                    return;
                }

                blockContent = blockContent.Replace(renderOnRequestMarker, string.Empty);
            }

            this.Parse(blockContent);
            base.Render(requesterUniqueID);
        }
Exemplo n.º 3
0
        private void RenderInternal(string requesterUniqueID)
        {
            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            string blockContent = contentDescription.Parts[0];

            // InLineStatement does not have any ContentArguments, That's why it copies it's parent Arguments
            if (this.Parent != null)
            {
                this.ContentArguments.Replace(this.Parent.ContentArguments);
            }

            this.Parse(blockContent);
            base.Render(requesterUniqueID);
        }
Exemplo n.º 4
0
        public override void Render(string requesterUniqueID)
        {
            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            string blockContent = contentDescription.Parts[0];

            this.Parse(blockContent);

            if (this.Mother.MessageResult != null)
            {
                this.ContentArguments.AppendKeyWithValue("MessageType", this.Mother.MessageResult.Type);
                this.ContentArguments.AppendKeyWithValue("Message", this.Mother.MessageResult.Content);
            }

            base.Render(requesterUniqueID);
        }
Exemplo n.º 5
0
        public override void Render(string requesterUniqueID)
        {
            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            // EncodedExecution does not have any ContentArguments, That's why it copies it's parent Arguments
            if (this.Parent != null)
            {
                this.ContentArguments.Replace(this.Parent.ContentArguments);
            }

            string blockContent = contentDescription.Parts[0];

            this.Parse(blockContent);

            if (string.IsNullOrEmpty(blockContent))
            {
                throw new Exception.EmptyBlockException();
            }

            base.Render(requesterUniqueID);
        }
Exemplo n.º 6
0
        protected override void RenderControl(string requesterUniqueID)
        {
            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            string blockContent = contentDescription.Parts[0];

            // Call Related Function and Exam It
            IController leveledController = this;
            int         level             = this.Leveling.Level;

            do
            {
                if (level == 0)
                {
                    break;
                }

                leveledController = leveledController.Parent;

                if (leveledController is Renderless)
                {
                    leveledController = leveledController.Parent;
                }

                level -= 1;
            } while (leveledController != null);

            // Execution preparation should be done at the same level with it's parent. Because of that, send parent as parameters
            this.Bind.Parameters.Prepare(
                (parameter) =>
            {
                Property property           = new Property(0, parameter.Query, (leveledController.Parent == null ? null : leveledController.Parent.ContentArguments));
                property.Mother             = leveledController.Mother;
                property.Parent             = leveledController.Parent;
                property.InstanceRequested += (ref IDomain instance) => InstanceRequested?.Invoke(ref instance);
                property.Setup();

                property.Render(requesterUniqueID);

                return(property.ObjectResult);
            }
                );

            Basics.Execution.InvokeResult <Basics.ControlResult.VariableBlock> invokeResult =
                Manager.AssemblyCore.InvokeBind <Basics.ControlResult.VariableBlock>(Basics.Helpers.Context.Request.Header.Method, this.Bind, Manager.ExecuterTypes.Control);

            if (invokeResult.Exception != null)
            {
                throw new Exception.ExecutionException(invokeResult.Exception.Message, invokeResult.Exception.InnerException);
            }
            // ----

            if (!this.Leveling.ExecutionOnly)
            {
                this.ContentArguments.Replace(leveledController.ContentArguments);
            }

            if (invokeResult.Result != null)
            {
                foreach (string key in invokeResult.Result.Keys)
                {
                    this.ContentArguments.AppendKeyWithValue(key, invokeResult.Result[key]);
                }
            }

            // Just parse the children to be accessable in search
            this.Parse(blockContent);

            if (!this.Leveling.ExecutionOnly)
            {
                this.RenderedValue =
                    ControllerHelper.RenderSingleContent(blockContent, leveledController, this.ContentArguments, requesterUniqueID);
            }
            else
            {
                this.RenderedValue =
                    ControllerHelper.RenderSingleContent(blockContent, this, this.ContentArguments, requesterUniqueID);
            }

            this.Mother.Scheduler.Fire(this.ControlID);
        }
Exemplo n.º 7
0
        protected override void RenderControl(string requesterUniqueID)
        {
            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            // ConditionalStatment does not have any ContentArguments, That's why it copies it's parent Arguments
            if (this.Parent != null)
            {
                this.ContentArguments.Replace(this.Parent.ContentArguments);
            }

            string contentTrue  = contentDescription.Parts[0];
            string contentFalse = string.Empty;

            if (contentDescription.Parts.Count > 1)
            {
                contentFalse = contentDescription.Parts[1];
            }

            // Call Related Function and Exam It
            IController leveledController = this;
            int         level             = this.Leveling.Level;

            do
            {
                if (level == 0)
                {
                    break;
                }

                leveledController = leveledController.Parent;

                if (leveledController is Renderless)
                {
                    leveledController = leveledController.Parent;
                }

                level -= 1;
            } while (leveledController != null);

            // Execution preparation should be done at the same level with it's parent. Because of that, send parent as parameters
            this.Bind.Parameters.Prepare(
                (parameter) =>
            {
                Property property           = new Property(0, parameter.Query, (leveledController.Parent == null ? null : leveledController.Parent.ContentArguments));
                property.Mother             = leveledController.Mother;
                property.Parent             = leveledController.Parent;
                property.InstanceRequested += (ref IDomain instance) => InstanceRequested?.Invoke(ref instance);
                property.Setup();

                property.Render(requesterUniqueID);

                return(property.ObjectResult);
            }
                );

            Basics.Execution.InvokeResult <Basics.ControlResult.Conditional> invokeResult =
                Manager.AssemblyCore.InvokeBind <Basics.ControlResult.Conditional>(Basics.Helpers.Context.Request.Header.Method, this.Bind, Manager.ExecuterTypes.Control);

            if (invokeResult.Exception != null)
            {
                throw new Exception.ExecutionException(invokeResult.Exception.Message, invokeResult.Exception.InnerException);
            }
            // ----

            if (invokeResult.Result != null)
            {
                switch (invokeResult.Result.Result)
                {
                case Basics.ControlResult.Conditional.Conditions.True:
                    if (!string.IsNullOrEmpty(contentTrue))
                    {
                        if (!this.Leveling.ExecutionOnly)
                        {
                            this.ContentArguments.Replace(leveledController.ContentArguments);
                            // Just parse the children to be accessable in search
                            this.Parse(contentTrue);
                            this.RenderedValue =
                                ControllerHelper.RenderSingleContent(contentTrue, leveledController, this.ContentArguments, requesterUniqueID);
                        }
                        else
                        {
                            // Just parse the children to be accessable in search
                            this.Parse(contentTrue);
                            this.RenderedValue =
                                ControllerHelper.RenderSingleContent(contentTrue, this, this.ContentArguments, requesterUniqueID);
                        }
                    }

                    break;

                case Basics.ControlResult.Conditional.Conditions.False:
                    if (!string.IsNullOrEmpty(contentFalse))
                    {
                        if (!this.Leveling.ExecutionOnly)
                        {
                            this.ContentArguments.Replace(leveledController.ContentArguments);
                            // Just parse the children to be accessable in search
                            this.Parse(contentFalse);
                            this.RenderedValue =
                                ControllerHelper.RenderSingleContent(contentFalse, leveledController, this.ContentArguments, requesterUniqueID);
                        }
                        else
                        {
                            // Just parse the children to be accessable in search
                            this.Parse(contentFalse);
                            this.RenderedValue =
                                ControllerHelper.RenderSingleContent(contentFalse, this, this.ContentArguments, requesterUniqueID);
                        }
                    }

                    break;

                case Basics.ControlResult.Conditional.Conditions.Unknown:
                    // Reserved For Future Uses

                    break;
                }
            }

            this.Mother.Scheduler.Fire(this.ControlID);
        }
Exemplo n.º 8
0
        private void RenderObjectFeed(string requesterUniqueID, Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult, Global.ContentDescription contentDescription)
        {
            object[] objectList =
                (object[])invokeResult.Result.GetResult();

            Global.ArgumentInfoCollection dataListArgs =
                new Global.ArgumentInfoCollection();

            if (invokeResult.Result.Message != null)
            {
                Basics.Helpers.VariablePool.Set(this.ControlID, new Global.DataListOutputInfo(this.UniqueID, 0, 0));

                if (!contentDescription.HasMessageTemplate)
                {
                    this.RenderedValue = invokeResult.Result.Message.Content;
                }
                else
                {
                    dataListArgs.AppendKeyWithValue("MessageType", invokeResult.Result.Message.Type);
                    dataListArgs.AppendKeyWithValue("Message", invokeResult.Result.Message.Content);

                    this.RenderedValue =
                        ControllerHelper.RenderSingleContent(
                            contentDescription.MessageTemplate, this, dataListArgs, requesterUniqueID);
                }

                return;
            }

            Basics.Helpers.VariablePool.Set(this.ControlID, new Global.DataListOutputInfo(this.UniqueID, invokeResult.Result.Count, invokeResult.Result.Total));

            StringBuilder renderedContent = new StringBuilder();
            int           contentIndex = 0, rC = 0;

            foreach (object current in objectList)
            {
                dataListArgs.Reset();

                dataListArgs.AppendKeyWithValue("_sys_ItemIndex", rC);
                dataListArgs.AppendKeyWithValue("ItemIndex", rC);

                dataListArgs.AppendKeyWithValue("CurrentObject", current);

                contentIndex = rC % contentDescription.Parts.Count;

                string renderedRow =
                    ControllerHelper.RenderSingleContent(
                        contentDescription.Parts[contentIndex], this, dataListArgs, requesterUniqueID);

                renderedContent.Append(renderedRow);

                rC += 1;
            }

            this.RenderedValue = renderedContent.ToString();
        }
Exemplo n.º 9
0
        protected override void RenderControl(string requesterUniqueID)
        {
            Global.ContentDescription contentDescription =
                new Global.ContentDescription(this.Value);

            // Reset Variables
            Basics.Helpers.VariablePool.Set(this.ControlID, null);

            // Call Related Function and Exam It
            IController leveledController = this;
            int         level             = this.Leveling.Level;

            do
            {
                if (level == 0)
                {
                    break;
                }

                leveledController = leveledController.Parent;

                if (leveledController is Renderless)
                {
                    leveledController = leveledController.Parent;
                }

                level -= 1;
            } while (leveledController != null);

            // Execution preparation should be done at the same level with it's parent. Because of that, send parent as parameters
            this.Bind.Parameters.Prepare(
                (parameter) =>
            {
                Property property           = new Property(0, parameter.Query, (leveledController.Parent == null ? null : leveledController.Parent.ContentArguments));
                property.Mother             = leveledController.Mother;
                property.Parent             = leveledController.Parent;
                property.InstanceRequested += (ref IDomain instance) => InstanceRequested?.Invoke(ref instance);
                property.Setup();

                property.Render(requesterUniqueID);

                return(property.ObjectResult);
            }
                );

            Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult =
                Manager.AssemblyCore.InvokeBind <Basics.ControlResult.IDataSource>(Basics.Helpers.Context.Request.Header.Method, this.Bind, Manager.ExecuterTypes.Control);

            if (invokeResult.Exception != null)
            {
                throw new Exception.ExecutionException(invokeResult.Exception.Message, invokeResult.Exception.InnerException);
            }

            Basics.Helpers.VariablePool.Set(this.ControlID, new Global.DataListOutputInfo(this.UniqueID, 0, 0));

            switch (invokeResult.Result.Type)
            {
            case Basics.ControlResult.DataSourceTypes.DirectDataAccess:
                this.RenderDirectDataAccess(requesterUniqueID, invokeResult, contentDescription);

                break;

            case Basics.ControlResult.DataSourceTypes.ObjectFeed:
                this.RenderObjectFeed(requesterUniqueID, invokeResult, contentDescription);

                break;

            case Basics.ControlResult.DataSourceTypes.PartialDataTable:
                this.RenderPartialDataTable(requesterUniqueID, invokeResult, contentDescription);

                break;
            }
            // ----

            this.Mother.Scheduler.Fire(this.ControlID);
        }
Exemplo n.º 10
0
        private void RenderDirectDataAccess(string requesterUniqueID, Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult, Global.ContentDescription contentDescription)
        {
            IDbCommand dbCommand =
                (IDbCommand)invokeResult.Result.GetResult();

            Global.ArgumentInfoCollection dataListArgs =
                new Global.ArgumentInfoCollection();

            if (dbCommand == null)
            {
                if (invokeResult.Result.Message != null)
                {
                    if (!contentDescription.HasMessageTemplate)
                    {
                        this.RenderedValue = invokeResult.Result.Message.Content;
                    }
                    else
                    {
                        dataListArgs.AppendKeyWithValue("MessageType", invokeResult.Result.Message.Type);
                        dataListArgs.AppendKeyWithValue("Message", invokeResult.Result.Message.Content);

                        this.RenderedValue =
                            ControllerHelper.RenderSingleContent(
                                contentDescription.MessageTemplate, this, dataListArgs, requesterUniqueID);
                    }

                    Helper.EventLogger.Log(string.Format("DirectDataAccess [{0}] failed! DatabaseCommand must not be null!", this.ControlID));
                }
                else
                {
                    throw new NullReferenceException(string.Format("DirectDataAccess [{0}] failed! DatabaseCommand must not be null!", this.ControlID));
                }

                return;
            }

            IDataReader dbReader = null;

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

                CultureInfo compareCulture = new CultureInfo("en-US");

                StringBuilder renderedContent = new StringBuilder();
                int           contentIndex = 0, rC = 0;
                bool          isItemIndexColumnExists = false;

                if (!dbReader.Read())
                {
                    if (invokeResult.Result.Message != null)
                    {
                        if (!contentDescription.HasMessageTemplate)
                        {
                            this.RenderedValue = invokeResult.Result.Message.Content;
                        }
                        else
                        {
                            dataListArgs.AppendKeyWithValue("MessageType", invokeResult.Result.Message.Type);
                            dataListArgs.AppendKeyWithValue("Message", invokeResult.Result.Message.Content);

                            this.RenderedValue =
                                ControllerHelper.RenderSingleContent(
                                    contentDescription.MessageTemplate, this, dataListArgs, requesterUniqueID);
                        }
                    }

                    return;
                }

                do
                {
                    dataListArgs.Reset();

                    for (int cC = 0; cC < dbReader.FieldCount; cC++)
                    {
                        if (compareCulture.CompareInfo.Compare(dbReader.GetName(cC), "ItemIndex", CompareOptions.IgnoreCase) == 0)
                        {
                            isItemIndexColumnExists = true;
                        }

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

                    contentIndex = rC % contentDescription.Parts.Count;

                    string renderedRow =
                        ControllerHelper.RenderSingleContent(
                            contentDescription.Parts[contentIndex], this, dataListArgs, requesterUniqueID);

                    renderedContent.Append(renderedRow);

                    rC += 1;
                } while (dbReader.Read());

                Basics.Helpers.VariablePool.Set(this.ControlID, new Global.DataListOutputInfo(this.UniqueID, rC, rC));
                this.RenderedValue = renderedContent.ToString();
            }
            catch (System.Exception ex)
            {
                Basics.Helpers.VariablePool.Set(this.ControlID, new Global.DataListOutputInfo(this.UniqueID, 0, 0));

                if (invokeResult.Result.Message == null)
                {
                    throw new Exception.DirectDataAccessException(ex);
                }

                if (!contentDescription.HasMessageTemplate)
                {
                    this.RenderedValue = invokeResult.Result.Message.Content;
                }
                else
                {
                    dataListArgs.AppendKeyWithValue("MessageType", invokeResult.Result.Message.Type);
                    dataListArgs.AppendKeyWithValue("Message", invokeResult.Result.Message.Content);

                    this.RenderedValue =
                        ControllerHelper.RenderSingleContent(
                            contentDescription.MessageTemplate, this, dataListArgs, requesterUniqueID);
                }

                Helper.EventLogger.Log(ex);
            }
            finally
            {
                if (dbReader != null)
                {
                    dbReader.Close();
                    dbReader.Dispose();
                    GC.SuppressFinalize(dbReader);
                }

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

                    dbCommand.Dispose();
                    GC.SuppressFinalize(dbCommand);
                }
            }
        }
Exemplo n.º 11
0
        private void RenderPartialDataTable(string requesterUniqueID, Basics.Execution.InvokeResult <Basics.ControlResult.IDataSource> invokeResult, Global.ContentDescription contentDescription)
        {
            DataTable repeaterList =
                (DataTable)invokeResult.Result.GetResult();

            Global.ArgumentInfoCollection dataListArgs =
                new Global.ArgumentInfoCollection();

            if (invokeResult.Result.Message != null)
            {
                if (!contentDescription.HasMessageTemplate)
                {
                    this.RenderedValue = invokeResult.Result.Message.Content;
                }
                else
                {
                    dataListArgs.AppendKeyWithValue("MessageType", invokeResult.Result.Message.Type);
                    dataListArgs.AppendKeyWithValue("Message", invokeResult.Result.Message.Content);

                    this.RenderedValue =
                        ControllerHelper.RenderSingleContent(
                            contentDescription.MessageTemplate, this, dataListArgs, requesterUniqueID);
                }

                return;
            }

            Basics.Helpers.VariablePool.Set(this.ControlID, new Global.DataListOutputInfo(this.UniqueID, invokeResult.Result.Count, invokeResult.Result.Total));

            CultureInfo compareCulture = new CultureInfo("en-US");

            StringBuilder renderedContent = new StringBuilder();
            int           contentIndex = 0, rC = 0;
            bool          isItemIndexColumnExists = false;

            foreach (DataColumn dC in repeaterList.Columns)
            {
                if (compareCulture.CompareInfo.Compare(dC.ColumnName, "ItemIndex", CompareOptions.IgnoreCase) == 0)
                {
                    isItemIndexColumnExists = true;
                }

                dataListArgs.AppendKey(dC.ColumnName);
            }
            dataListArgs.AppendKey("_sys_ItemIndex");
            repeaterList.Columns.Add("_sys_ItemIndex", typeof(int));
            // this is for user interaction
            if (!isItemIndexColumnExists)
            {
                dataListArgs.AppendKey("ItemIndex");
                repeaterList.Columns.Add("ItemIndex", typeof(int));
            }

            foreach (DataRow dR in repeaterList.Rows)
            {
                object[] dRValues = dR.ItemArray;

                if (!isItemIndexColumnExists)
                {
                    dRValues[dRValues.Length - 2] = rC;
                    dRValues[dRValues.Length - 1] = rC;
                }
                else
                {
                    dRValues[dRValues.Length - 1] = rC;
                }

                dataListArgs.Reset(dRValues);

                contentIndex = rC % contentDescription.Parts.Count;

                string renderedRow =
                    ControllerHelper.RenderSingleContent(
                        contentDescription.Parts[contentIndex], this, dataListArgs, requesterUniqueID);

                renderedContent.Append(renderedRow);

                rC += 1;
            }

            this.RenderedValue = renderedContent.ToString();
        }