Exemple #1
0
        //methods

        public void SetContextId(string ContextId)
        {
            this.ContextId = ContextId;
            for (int i = 0; i < Controls.Count; i++)
            {
                EbControl control = Controls[i];
                control.ContextId = ContextId;
                if (control is EbControlContainer)
                {
                    (control as EbControlContainer).SetContextId(ContextId);
                }
            }
        }
Exemple #2
0
        public virtual string GetWrapedCtrlHtml4bot(ref EbControl ChildObj)// for builder side JS contructor
        {
            string bareHTML    = ChildObj.DesignHtml4Bot ?? ChildObj.GetBareHtml(),
                   innerHTML   = @" <div class='ctrl-wraper' @style@> @barehtml@ </div>".Replace("@barehtml@", bareHTML),
                   ResHTML     = string.Empty,
                   type        = ChildObj.GetType().Name.Substring(2, ChildObj.GetType().Name.Length - 2),
                   LabelHTML   = @"
						<div class='msg-cont'>
						  <div class='bot-icon'></div>
						  <div class='msg-cont-bot'>
							 <div ui-label class='msg-wraper-bot'>
								@Label@
								<div class='msg-time'>3:44pm</div>
							 </div>
						  </div>
					   </div>"                    ,
                   ControlHTML = @"
							<div class='msg-cont'>
									<div class='msg-cont-bot'>
										<div class='msg-wraper-bot' style='@style@ border: none; background-color: transparent; width: 99%; padding-right: 3px;'>
										@innerHTML@
										</div>
									</div>
								</div>"                                ;

            if (type == "Labels")
            {
                ControlHTML = string.Empty;
                LabelHTML   = bareHTML;
            }
            if (type == "Label")
            {
                ControlHTML = string.Empty;
            }
            innerHTML = (!ChildObj.IsFullViewContol) ? (@"<div class='chat-ctrl-cont'>" + innerHTML + "</div>") : innerHTML.Replace("@style@", "style='width:100%;border:none;'");
            ResHTML   = @"
<div class='Eb-ctrlContainer iw-mTrigger' ctype='@type@'  eb-type='@type@' ebsid='@ebsid@'>
   @LabelHTML@
   @ControlHTML@
</div>"
                        .Replace("@type@", type)
                        .Replace("@LabelHTML@", LabelHTML)
                        .Replace("@ebsid@", this.EbSid_CtxId)
                        .Replace("@ControlHTML@", ControlHTML)
                        .Replace("@innerHTML@", innerHTML)
                        .Replace("@style@", (ChildObj.IsFullViewContol ? "margin-left:12px;" : string.Empty)).RemoveCR();
            return(ResHTML);
        }
Exemple #3
0
        public static SingleColumn GetSingleColumn(EbControl _this, User UserObj, Eb_Solution SoluObj, object Value)
        {
            object _formattedData = Value;
            string _displayMember = Value == null ? string.Empty : Value.ToString();

            if (_this.EbDbType == EbDbTypes.Decimal || _this.EbDbType == EbDbTypes.Int32)
            {
                if (Value == null)
                {
                    _formattedData = 0;
                    _displayMember = "0";
                }
                else
                {
                    _displayMember = Convert.ToString(Value);
                    if (double.TryParse(_displayMember, out double _t))
                    {
                        _formattedData = _t;
                    }
                    else
                    {
                        throw new Exception($"Invalid numeric value({_displayMember}) for '{_this.Name}'");
                    }
                }
            }
            else if (_this.EbDbType == EbDbTypes.String && _formattedData != null)
            {
                _formattedData = Convert.ToString(_formattedData);
            }

            return(new SingleColumn()
            {
                Name = _this.Name,
                Type = (int)_this.EbDbType,
                Value = _formattedData,
                Control = _this,
                ObjType = _this.ObjType,
                F = _displayMember
            });
        }
Exemple #4
0
        //foreach (EbControl control in Controls)
        //{
        //    if (control is EbControlContainer)
        //    {
        //        EbControlContainer Cont = control as EbControlContainer;
        //        if (Cont.TableName.IsNullOrEmpty()|| Cont.TableName.Trim() == string.Empty)
        //        {
        //            Cont.TableName = TableName;
        //        }
        //    }
        //}

        //public virtual string GetSelectQuery(string _parentTblName)
        //{
        //	string ColoumsStr = Get1stLvlColNames();
        //	string qry = string.Empty;
        //	if (ColoumsStr.Length > 0)
        //	{
        //		if (TableName == _parentTblName)
        //			qry = string.Format("SELECT id, {0} FROM {1} WHERE {3} = {2};", ColoumsStr, TableName, TableRowId, "id");
        //		else
        //			qry = string.Format("SELECT id, {0} FROM {1} WHERE {3}={2};", ColoumsStr, TableName, TableRowId, _parentTblName + "_id");

        //	}

        //	foreach (EbControl control in Controls)
        //	{
        //		if (control is EbControlContainer)
        //		{
        //			EbControlContainer _control = (control as EbControlContainer);
        //			if (_control.TableName.IsNullOrEmpty())
        //			{
        //				_control.TableName = TableName;
        //			}
        //			//_control.TableName = _control.TableName.IsNullOrEmpty() ? TableName : _control.TableName;
        //			_control.TableRowId = (_control.TableRowId == 0) ? TableRowId : _control.TableRowId;
        //			qry += _control.GetSelectQuery(_parentTblName);
        //		}
        //	}
        //	return qry;
        //}

        public static string GetControlOpsJS(EbControlContainer ebControlContainer, BuilderType FormTypeEnum)
        {
            string JSCode = "var ControlOps = {}";

            Type[] _typeArray = (ebControlContainer.GetType().GetTypeInfo().Assembly.GetTypes());
            Dictionary <string, string> DictControlOps = new Dictionary <string, string>();

            foreach (Type ctrlType in _typeArray)
            {
                try
                {
                    TypeInfo _typeInfo       = ctrlType.GetTypeInfo();
                    var      _enableInBuider = _typeInfo.GetCustomAttribute <EnableInBuilder>();
                    string   TypeName        = ctrlType.Name.Substring(2, ctrlType.Name.Length - 2);

                    if (_enableInBuider != null && _enableInBuider.BuilderTypes.Contains(FormTypeEnum))
                    {
                        object ctrlObj = Activator.CreateInstance(ctrlType);
                        if (
                            //(!_typeInfo.IsDefined(typeof(HideInToolBox))) && // temp
                            ctrlObj is EbControl)
                        {
                            if (!DictControlOps.ContainsKey(TypeName))
                            {
                                EbControl _ctrlObj = (ctrlObj as EbControl);
                                string    opFnsJs  = string.Empty;
                                opFnsJs += GetOpFnJs("getValue", _ctrlObj.GetValueJSfn, TypeName);
                                opFnsJs += GetOpFnJs("getValueFromDOM", _ctrlObj.GetValueFromDOMJSfn, TypeName);
                                opFnsJs += GetOpFnJs("getDisplayMember", _ctrlObj.GetDisplayMemberJSfn, TypeName);
                                opFnsJs += GetOpFnJs("getDisplayMemberFromDOM", _ctrlObj.GetDisplayMemberFromDOMJSfn, TypeName);
                                opFnsJs += GetOpFnJs("isRequiredOK", _ctrlObj.IsRequiredOKJSfn, TypeName);
                                opFnsJs += GetOpFnJs("isEmpty", _ctrlObj.IsEmptyJSfn, TypeName);
                                opFnsJs += GetOpFnJs("setValue", _ctrlObj.SetValueJSfn, TypeName);
                                opFnsJs += GetOpFnJs("setDisplayMember", _ctrlObj.SetDisplayMemberJSfn, TypeName);
                                opFnsJs += GetOpFnJs("justSetValue", _ctrlObj.JustSetValueJSfn, TypeName);
                                opFnsJs += GetOpFnJs("hide", _ctrlObj.HideJSfn, TypeName);
                                opFnsJs += GetOpFnJs("show", _ctrlObj.ShowJSfn, TypeName);
                                opFnsJs += GetOpFnJs("enable", _ctrlObj.EnableJSfn, TypeName);
                                opFnsJs += GetOpFnJs("disable", _ctrlObj.DisableJSfn, TypeName);
                                opFnsJs += GetOpFnJs("reset", _ctrlObj.ResetJSfn, TypeName);
                                opFnsJs += GetOpFnJs("refresh", _ctrlObj.RefreshJSfn, TypeName);
                                opFnsJs += GetOpFnJs("clear", _ctrlObj.ClearJSfn, TypeName);
                                opFnsJs += GetOpFnJs("addInvalidStyle", _ctrlObj.AddInvalidStyleJSFn, TypeName);
                                opFnsJs += GetOpFnJs("removeInvalidStyle", _ctrlObj.RemoveInvalidStyleJSFn, TypeName);
                                opFnsJs += GetOpFnJs("bindOnChange", _ctrlObj.OnChangeBindJSFn, TypeName);

                                if (_ctrlObj.ObjType == "DGPowerSelectColumn")
                                {
                                    opFnsJs += GetOpFnJs("getColumn", _ctrlObj.GetColumnJSfn, TypeName);
                                }

                                string fn = string.Concat("function ", TypeName, "(jsonObj){ $.extend(this, jsonObj);", opFnsJs, "}");//.RemoveCR();

                                JSCode += string.Concat(@"
                                                        ControlOps.", TypeName, " = ", fn);;

                                DictControlOps.Add(TypeName, "fn placeholder");
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            return(JSCode);
        }
Exemple #5
0
 public void SetFormRelated(string tbl, User usr, EbControl webForm)
 {
     this.tbl     = tbl;
     this.usr     = usr;
     this.webForm = webForm;
 }
Exemple #6
0
 //get data model of the control(formatted) // Value = null => to get default SingleColumn
 public virtual SingleColumn GetSingleColumn(User UserObj, Eb_Solution SoluObj, object Value, bool Default)
 {
     return(EbControl.GetSingleColumn(this, UserObj, SoluObj, Value));
 }
Exemple #7
0
        private void GetJsObject(object obj)
        {
            this.CtrlCounters += obj.GetType().GetTypeInfo().Name.Substring(2) + "Counter : 0,";
            string _props = string.Empty;

            PropertyInfo[] props = obj.GetType().GetAllProperties();

            //if (obj is EbControlContainer)
            //    _props += @"this.IsContainer = true;";

            foreach (PropertyInfo prop in props)
            {
                IEnumerable <Attribute> propattrs = prop.GetCustomAttributes();////////////////

                if (prop.IsDefined(typeof(EnableInBuilder), false) &&
                    prop.GetCustomAttribute <EnableInBuilder>().BuilderTypes.Contains(this.BuilderType))
                {
                    _props += JsVarDecl(prop, obj);
                }
            }


            this.AllMetas += @"
'@Name'  : @MetaCollection,"
                             .Replace("@Name", obj.GetType().Name)
                             .Replace("@MetaCollection", JsonConvert.SerializeObject(this.GetMetaCollection(obj)));
            try
            {
                EbObject  EbO_obj       = (obj as EbObject);
                bool      isEbObject    = obj is EbObject;
                EbControl sampOBJ       = (obj as EbControl);
                string    AssemblyQname = obj.GetType().AssemblyQualifiedName;

                this.JsObjects += @"
EbObjects.@Name = function @Name(id, jsonObj) {
    this.$type = '@Type';
    this.EbSid = id;
    @Props
    this.EbSid_CtxId = id;
    @InitFunc
    @4botHtml
    this.$Control = $( @html.replace(/@id/g, this.EbSid) );
    this.BareControlHtml = `@bareHtml`.replace(/@id/g, this.EbSid);
	this.DesignHtml = @html;
    var MyName = this.constructor.name;
    this.RenderMe = function () { 
var NewHtml = this.$BareControl.outerHTML(), me = this, metas = AllMetas[MyName];
    $.each(metas, function (i, meta) { 
        var name = meta.name;
        if (meta.IsUIproperty){
            NewHtml = NewHtml.replace('@' + name + ' ', me[name]);
        }
    });
    if(!this.IsContainer)
        $('#' + id).html($(NewHtml).html());
};
    if (jsonObj){
        jsonObj.RenderMe  = this.RenderMe;
        jsonObj.Html  = this.Html;
        jsonObj.Init   = this.Init;
        $.extend(this, jsonObj);
        //_.mergeWith(
	       // {}, this, jsonObj,
        //  (a, b) => b === null ? a : undefined
        //)
        if(jsonObj.IsContainer)
            this.Controls  = new EbControlCollection( {} );
        //if(this.Init)
        //    jsonObj.Init(id);
    }
    else{
        if(this.Init)
            this.Init(id);
    }
};"
                                  .Replace("@Name", obj.GetType().Name)
                                  .Replace("@Type", AssemblyQname.Split(",")[0] + "," + AssemblyQname.Split(",")[1])
                                  .Replace("@Props", _props)
                                  .Replace("@InitFunc", isEbObject ? EbO_obj.GetJsInitFunc() : string.Empty)
                                  .Replace("@html", isEbObject ? EbO_obj.GetDesignHtml() : "``")
                                  .Replace("@4botHtml", (obj is EbControl) ? ("this.$WrapedCtrl4Bot = $(`" + (obj as EbControl).GetWrapedCtrlHtml4bot(ref sampOBJ) + "`);") : string.Empty)
                                  .Replace("@bareHtml", isEbObject ? EbO_obj.GetBareHtml() : string.Empty);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.ToString());
            }
        }
Exemple #8
0
        private string GetToolBoxHtml()
        {
            string _ToolsHtml                   = string.Empty;
            string _controlsHtml                = string.Empty;
            string _containerControlsHtml       = string.Empty;
            string _specialContainerControlHtml = string.Empty;
            string _placeHolderControlsHtml     = string.Empty;
            string _componentsHtml              = string.Empty;

            foreach (Type tool in this.TypeArray)
            {
                if (tool.GetTypeInfo().IsSubclassOf(this.TypeOfTopEbObjectParent) ||
                    (tool.GetTypeInfo().IsDefined(typeof(UsedWithTopObjectParent)) &&
                     (tool.GetCustomAttribute <UsedWithTopObjectParent>().TopObjectParentTypes.Contains(this.TypeOfTopEbObjectParent))) ||
                    ((this.TypeOfTopEbObjectParent2 != null) ? tool.GetTypeInfo().IsSubclassOf(this.TypeOfTopEbObjectParent2) : false))
                {
                    if (!tool.IsAbstract)
                    {
                        try
                        {
                            TypeInfo        _typeInfo       = tool.GetTypeInfo();
                            EnableInBuilder _enableInBuider = _typeInfo.GetCustomAttribute <EnableInBuilder>();

                            if (_enableInBuider != null && _enableInBuider.BuilderTypes.Contains(this.BuilderType))
                            {
                                object toolObj = Activator.CreateInstance(tool);

                                if (toolObj is EbControl &&
                                    (!_typeInfo.IsDefined(typeof(HideInToolBox)) || _typeInfo.IsDefined(typeof(ShowInToolBox)))) // ShowInToolBox should override HideInToolBox( in a case where HideInToolBox inherit from parent class)
                                {
                                    EbControl ControlObj = toolObj as EbControl;

                                    if (toolObj is IEbPlaceHolderControl)
                                    {
                                        _placeHolderControlsHtml += ControlObj.GetToolHtml();
                                    }
                                    else if (toolObj is IEbSpecialContainer)
                                    {
                                        _specialContainerControlHtml += ControlObj.GetToolHtml();
                                    }
                                    else if (toolObj is IEbComponent)
                                    {
                                        _componentsHtml += ControlObj.GetToolHtml();
                                    }
                                    else if (toolObj is EbControlContainer)
                                    {
                                        _containerControlsHtml += ControlObj.GetToolHtml();
                                    }
                                    else
                                    {
                                        _controlsHtml += ControlObj.GetToolHtml();
                                    }
                                }
                                //ToolBoxHtml += this.GetToolHtml(tool.Name.Substring(2));
                                this.TypeRegister += string.Format(@"
                                    if (jsonObj['$type'].includes('{0}')) 
                                        return new EbObjects.{1}(jsonObj.EbSid, jsonObj); ", toolObj.GetType().FullName, toolObj.GetType().Name);
                                this.GetJsObject(toolObj);
                                if (toolObj is EbControl)
                                {
                                    this.EbOnChangeUIfns += String.IsNullOrEmpty((toolObj as EbControl).UIchangeFns) ? string.Empty : ("EbOnChangeUIfns." + (toolObj as EbControl).UIchangeFns + ";");
                                }
                            }
                        }
                        catch (Exception ee)
                        {
                            Console.WriteLine("Exception: " + ee.ToString());
                            throw new Exception(ee.Message);
                        }
                    }
                }
            }
            if (!_controlsHtml.IsEmpty())
            {
                _ToolsHtml += HtmlConstants.TOOL_HTML.Replace("@id@", "toolb_basic_ctrls").Replace("@label@", "Basic Controls") + _controlsHtml + "</div>";
            }
            if (!_containerControlsHtml.IsEmpty())
            {
                _ToolsHtml += HtmlConstants.TOOL_HTML.Replace("@id@", "toolb_cont_ctrls").Replace("@label@", "Layout Controls") + _containerControlsHtml + "</div>";
            }
            if (!_specialContainerControlHtml.IsEmpty())
            {
                _ToolsHtml += HtmlConstants.TOOL_HTML.Replace("@id@", "toolb_sp_cont_ctrls").Replace("@label@", "Advanced Controls") + _specialContainerControlHtml + "</div>";
            }
            if (!_placeHolderControlsHtml.IsEmpty())
            {
                _ToolsHtml += HtmlConstants.TOOL_HTML.Replace("@id@", "toolb_ph_cont_ctrls").Replace("@label@", "Platform Controls") + _placeHolderControlsHtml + "</div>";
            }
            if (!_componentsHtml.IsEmpty())
            {
                _ToolsHtml += HtmlConstants.TOOL_HTML.Replace("@id@", "toolb_ph_cont_ctrls").Replace("@label@", "Components") + _componentsHtml + "</div>";
            }


            //_ToolsHtml = _controlsHtml + "</div>" + _containerControlsHtml + "</div>" + _specialContainerControlHtml + "</div>" + _placeHolderControlsHtml + "</div>";
            return(_ToolsHtml);
        }