예제 #1
0
        public async Task <WebbuilderViewInfo> ShowData(bool isPreview)
        {
            WebBuilderController  objWebController      = new WebBuilderController();
            WebbuilderViewGetInfo webbuilderViewGetInfo = new WebbuilderViewGetInfo()
            {
                Culture     = GetCurrentCulture,
                PageName    = PageName_,
                PreviewMode = isPreview
            };
            ReuseableParams    objReuseableParams = GetReuseableParams(_memoryCache);
            WebbuilderViewInfo webbuilderViewInfo = await objWebController.GetPageViewDOM(webbuilderViewGetInfo, objReuseableParams, GetSiteID);

            if (webbuilderViewInfo != null)
            {
                webbuilderViewInfo.PageName    = PageName_;
                webbuilderViewInfo.HostURL     = HostUrl;
                webbuilderViewInfo.PreviewMode = isPreview;
                CommonCbuilder commonCbuilder = new CommonCbuilder();
                Task           loadComponents = GetComponent(!isPreview);
                Task           loadpackages   = CombinePackagejs();
                Task           loadlibraries  = commonCbuilder.CombineWebbuilderLibrary("*-view.js", "webbuilderView.js");
                await Task.WhenAll(loadComponents, loadpackages, loadlibraries);
            }
            AddJS("packagesjs", FolderName.CbuilderAssets + "/js/packages.js");
            return(webbuilderViewInfo);
        }
예제 #2
0
        public async Task <IActionResult> Index()
        {
            objReuseableParams = GetReuseableParams(_memoryCache);
            cbuilderView       = await LoadData();

            AssignSettings();
            cbuilderView.TempPageName = PageName;
            await LoadPages(cbuilderView.PageList, cbuilderView.DashboardPages);

            InitData();
            cbuilderView.IsDevelopmentMode = CurrentHostEnvironment.IsDevelopment;
            await CombineFiles();

            cbuilderView.Applicationname = string.Empty;
            cbuilderView.EnableHeader    = "true";
            //cbuilderView.TempPageName = "webbuildertemppagename";
            cbuilderView.Version = string.Empty;
            cbuilderView.Webbuildermodulepath = "/modules/webbuilder";
            cbuilderView.HostURL         = HostUrl;
            cbuilderView.ParamString     = QueryParamString;
            cbuilderView.Culture         = GetCurrentCulture;
            cbuilderView.CultureURL      = CultureURL;
            cbuilderView.CultureLanguage = settingValues[SettingKeys.CultureLanguage];
            LoadAssets();
            return(View(cbuilderView));
        }
예제 #3
0
        private async Task <string> InitializeAPI(string tempPageName, ReuseableParams reuseableParams, int siteID)
        {
            ControllerInoker        objCntrlInvoker            = new ControllerInoker();
            List <ControllerDetail> lstApsExtraCompsInvoker    = new List <ControllerDetail>();
            Dictionary <string, ControllerDetail> objAPIResult = await objCntrlInvoker.EditLoadAPI(tempPageName, reuseableParams, lstApsExtraCompsInvoker, siteID);

            Newtonsoft.Json.JsonSerializerSettings jss = new Newtonsoft.Json.JsonSerializerSettings
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            };
            return(Newtonsoft.Json.JsonConvert.SerializeObject(objAPIResult, jss));
        }
예제 #4
0
        private object[] ParamsToArgsObject(string parameters, ReuseableParams objReuseableParams)
        {
            List <object> objList = ParamsToArgsList(parameters, objReuseableParams);

            if (objList.Count == 0)
            {
                return(null);
            }
            else
            {
                return(objList.ToArray());
            }
        }
예제 #5
0
        private List <object> ParamsToArgsList(string parameters, ReuseableParams objReuseableParams)
        {
            List <object> objList = new List <object>();

            if (!string.IsNullOrEmpty(parameters))
            {
                string[] args = parameters.Split(',');
                for (int i = 0, length = args.Length; i < length; i++)
                {
                    //if (args[i].Length > 0)
                    //{
                    object arg = ParseARGs(args[i], objReuseableParams);
                    objList.Add(arg);
                    //}
                }
            }
            return(objList);
        }
예제 #6
0
        private object ParseARGs(string args, ReuseableParams objReuseableParams)
        {
            object arg = args;

            switch (args.ToLower())
            {
            case "%username%":
                arg = objReuseableParams.UserName;
                break;

            case "%hosturl%":
                arg = objReuseableParams.HostURL;
                break;

            case "%userimage%":
                arg = objReuseableParams.UserImage;
                break;

            case "$siteid$":
                arg = objReuseableParams.SiteID.ToString();
                break;

            case "%siteid%":
                arg = objReuseableParams.SiteID.ToString();
                break;

            case "%currentroleids%":
                arg = objReuseableParams.CurrentRoleIDs;
                break;

            case "%culturecode%":
                arg = objReuseableParams.Culture;
                break;

            case "%httpcontextaccessor%":
                arg = objReuseableParams.HttpContextAccessor;
                break;

            case "%cache%":
                arg = objReuseableParams.MemoryCache;
                break;
            }
            return(arg);
        }
예제 #7
0
        private async Task <string> APIStringResult(bool isPreview, string pageName, ReuseableParams objReuseableParams, List <ControllerDetail> lstApsExtraCompsInvoker, int siteID)
        {
            ControllerInoker objCntrlInvoker = new ControllerInoker();
            Dictionary <string, ControllerDetail> objAPIResult;

            if (isPreview)
            {
                objAPIResult = await objCntrlInvoker.ViewLoadAPI(pageName, objReuseableParams, lstApsExtraCompsInvoker, siteID);
            }
            else
            {
                objAPIResult = await objCntrlInvoker.ViewLoadAPIPublished(pageName, objReuseableParams, lstApsExtraCompsInvoker, siteID);
            }
            Newtonsoft.Json.JsonSerializerSettings jss = new Newtonsoft.Json.JsonSerializerSettings
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            };
            return(Newtonsoft.Json.JsonConvert.SerializeObject(objAPIResult, jss));
        }
예제 #8
0
        public async Task <CbuilderView> GetEditDOMByID(WebBuilderInfo webBuilderInfo, ReuseableParams reuseableParams, bool localizationEnabled)
        {
            WebBuilderDataProvider objDataProvider = new WebBuilderDataProvider();
            CbuilderView           cbuilderView    = await objDataProvider.GetEditDOMByID(webBuilderInfo);

            if (cbuilderView != null)
            {
                Task <IList <WebBuilderPages> > pagesList      = objDataProvider.GetPageList(webBuilderInfo.SiteID);
                Task <IList <WebBuilderPages> > dashboardPages = objDataProvider.GetDashboardPageList(webBuilderInfo.SiteID);
                Task <IList <WebBuilderPages> > forbiddenPages = objDataProvider.GetForbiddenPageList(webBuilderInfo.SiteID);
                Task <string> componentList    = GetComponent(objDataProvider, webBuilderInfo.SiteID);
                Task <string> bucketComponents = GetBucketCompoent(objDataProvider, webBuilderInfo.SiteID);
                Task <IList <ApplicationDetail> > applicationNames = objDataProvider.GetApplicationNames(webBuilderInfo.SiteID);
                Task <string> apiResultString          = InitializeAPI(webBuilderInfo.PageName, reuseableParams, webBuilderInfo.SiteID);
                Task <IList <LanguageList> > languages = null;
                if (localizationEnabled)
                {
                    languages = GetLanguageLists(webBuilderInfo.SiteID);
                }
                //  await Task.WhenAll(pagesList, dashboardPages, componentList, bucketComponents, applicationNames, apiResultString, forbiddenPages, languages);
                cbuilderView.PageList         = await pagesList;
                cbuilderView.DashboardPages   = await dashboardPages;
                cbuilderView.ComponentList    = await componentList;
                cbuilderView.BucketComponents = await bucketComponents;
                //cbuilderView.ApplicationName = await objDataProvider.GetApplicationName().ApplicationName;
                cbuilderView.ApplicationNames = await applicationNames;
                cbuilderView.APIResultString  = await apiResultString;
                cbuilderView.ForbiddenPage    = await forbiddenPages;
                if (localizationEnabled)
                {
                    cbuilderView.Languages = await languages;
                }
            }
            return(cbuilderView);
        }
예제 #9
0
        public async Task <WebbuilderViewInfo> GetPageViewDOM(WebbuilderViewGetInfo webbuilderViewGetInfo, ReuseableParams reuseableParams, int siteID)
        {
            WebBuilderDataProvider objDataProvider    = new WebBuilderDataProvider();
            WebbuilderViewInfo     webbuilderViewInfo = await objDataProvider.GetPageViewDOM(webbuilderViewGetInfo);

            if (webbuilderViewInfo != null)
            {
                List <ControllerDetail> lstApsExtraCompsInvoker = new List <ControllerDetail>();
                Task <string>           apiResultString         = APIStringResult(webbuilderViewGetInfo.PreviewMode, webbuilderViewGetInfo.PageName, reuseableParams, lstApsExtraCompsInvoker, siteID);
                Task <string>           appsExtraComponent      = GetAppsExtraComponent(lstApsExtraCompsInvoker, webbuilderViewGetInfo.PageName, siteID);
                //await Task.WhenAll(apiResultString, appsExtraComponent);
                webbuilderViewInfo.APIResultString    = await apiResultString;
                webbuilderViewInfo.AppsExtraComponent = await appsExtraComponent;
            }
            return(webbuilderViewInfo);
        }
예제 #10
0
        private Task <Dictionary <string, ControllerDetail> > ResultInvoke(IList <ControllerDetail> objControllers, ReuseableParams objReuseableParams, List <ControllerDetail> lstApsExtraCompsInvoker)
        {
            Dictionary <string, ControllerDetail> result = new Dictionary <string, ControllerDetail>();
            MethodInvoke methodInvoke = new MethodInvoke();

            foreach (ControllerDetail item in objControllers)
            {
                ControllerDetail controllerDetail = methodInvoke.Execute(item, objReuseableParams, lstApsExtraCompsInvoker);
                if (!result.ContainsKey(controllerDetail.ComponentID.Trim()))
                {
                    result.Add(controllerDetail.ComponentID.Trim(), item);
                }
            }
            return(Task.FromResult(result));
        }
예제 #11
0
        public async Task <Dictionary <string, ControllerDetail> > ViewLoadAPIPublished(string pageName, ReuseableParams objReuseableParams, List <ControllerDetail> lstApsExtraCompsInvoker, int siteID)
        {
            WebBuilderDataProvider  objDataProvider    = new WebBuilderDataProvider();
            List <ControllerDetail> objControllersList = objDataProvider.GetAPIListPublished(pageName, siteID);

            return(await ResultInvoke(objControllersList, objReuseableParams, lstApsExtraCompsInvoker));
        }
예제 #12
0
        public async Task <Dictionary <string, ControllerDetail> > EditLoadAPI(string pageName, ReuseableParams objReuseableParams, List <ControllerDetail> lstApsExtraCompsInvoker, int siteID)
        {
            WebBuilderDataProvider   objDataProvider    = new WebBuilderDataProvider();
            IList <ControllerDetail> objControllersList = await objDataProvider.GetAPIList(pageName, siteID);

            //objReuseableParams.UrlParameters = objReuseableParams?.UrlParameters?.Skip(1).ToArray();
            return(await ResultInvoke(objControllersList, objReuseableParams, lstApsExtraCompsInvoker));
        }
예제 #13
0
        public ControllerDetail Execute(ControllerDetail controllerDetail, ReuseableParams objReuseableParams, List <ControllerDetail> lstApsExtraCompsInvoker)
        {
            string[] urlParams = objReuseableParams.UrlParameters;
            try
            {
                switch (controllerDetail?.Type)
                {
                case "URL":
                {
                    List <object> objList = new List <object>();
                    if (!string.IsNullOrEmpty(controllerDetail.Parameters))
                    {
                        string[] allParameters = controllerDetail.Parameters.Split('#');
                        if (allParameters.Length > 0 && !string.IsNullOrEmpty(allParameters[0]))
                        {
                            string[] para   = allParameters[0].Split(',');
                            int      urlLen = urlParams == null ? 0 : urlParams.Length;
                            int      argLen = para.Length;
                            for (int j = 0; j < argLen; j++)
                            {
                                object arg      = string.Empty;
                                int    position = -1;
                                bool   parsed   = int.TryParse(para[j], out position);
                                if (parsed)
                                {
                                    for (int i = 0; i < urlLen; i++)
                                    {
                                        if (i == position)
                                        {
                                            arg = urlParams[i];
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    arg = ParseARGs(para[j].ToString(), objReuseableParams);
                                }
                                objList.Add(arg);
                            }
                        }
                        if (allParameters.Length == 2)
                        {
                            objList.AddRange(ParamsToArgsList(allParameters[1], objReuseableParams));
                        }
                    }
                    if (objList.Count == 0)
                    {
                        controllerDetail.Args = null;
                    }
                    else
                    {
                        controllerDetail.Args = objList.ToArray();
                    }
                }
                break;

                case "method":
                {
                    controllerDetail.Args = ParamsToArgsObject(controllerDetail.Parameters, objReuseableParams);
                }
                break;
                }
                if (controllerDetail?.ComponentID?.Trim() == "apps_extra_components")
                {
                    lstApsExtraCompsInvoker.Add(controllerDetail);
                }
                else
                {
                    object resultInvoke = Invoke(controllerDetail);
                    if (resultInvoke != null)
                    {
                        controllerDetail.ErrorOccured = false;
                        controllerDetail.Result       = new object[1];
                        controllerDetail.Result[0]    = resultInvoke;
                        controllerDetail.Args         = null;// set Null after invocation. if serialization not work for http context
                    }
                }
            }
            catch (Exception ex)
            {
                controllerDetail.ErrorOccured = true;
                controllerDetail.Error        = new object[1];
                controllerDetail.Error[0]     = ex.ToString();
            }
            return(controllerDetail);
        }