public UnitLock SelectOptimalLockTargetFor(ActiveModule module)
        {
            var locks = GetLocks().OfType <UnitLock>().Where(l =>
            {
                if (l.State != LockState.Locked)
                {
                    return(false);
                }

                var isInOptimalRange = IsInRangeOf3D(l.Target, module.OptimalRange);
                return(isInOptimalRange);
            }).ToArray();

            var primaryLock = locks.FirstOrDefault(l => l.Primary);

            if (module.ED.AttributeFlags.PrimaryLockedTarget)
            {
                return(primaryLock);
            }

            var chance = FastRandom.NextDouble() <= PRIMARY_LOCK_CHANCE_FOR_SECONDARY_MODULE;

            if (primaryLock != null && chance)
            {
                return(primaryLock);
            }

            return(locks.RandomElement());
        }
Beispiel #2
0
        /// <summary>
        /// Get a module by class name
        /// </summary>
        /// <typeparam name="T">Specialised inner interface type for the module</typeparam>
        /// <param name="moduleName">Name of the module class to fetch</param>
        /// <returns>Module reference or null if the module was not found</returns>
        public static T GetModule <T>(string moduleName)
            where T : IMasterServerModule
        {
            lock (repositoryLock)
            {
                // If the module is already in use, increment the usage counter
                if (activeModules.ContainsKey(moduleName))
                {
                    activeModules[moduleName].Count++;
                    return((T)activeModules[moduleName].Module);
                }
                else if (loadedModules.ContainsKey(moduleName))
                {
                    // Mark the module as active and initialise it
                    activeModules[moduleName] = new ActiveModule(loadedModules[moduleName]);

                    try
                    {
                        activeModules[moduleName].Module.Initialise(MasterServer.Instance);
                        activeModules[moduleName].Count++;
                    }
                    catch
                    {
                        activeModules.Remove(moduleName);
                        return(default(T));
                    }

                    return((T)activeModules[moduleName].Module);
                }
            }

            return(default(T));
        }
        public ModuleStateDto GetTemplateState()
        {
            //create tmp TemplateManifest
            //var templateManifest = new FileUri(template).ToTemplateManifest();
            var settings         = ActiveModule.OpenContentSettings();
            var templateManifest = settings.Template;

            if (templateManifest == null)
            {
                return(new ModuleStateDto()
                {
                    Template = ""
                });
            }
            else
            {
                return(new ModuleStateDto()
                {
                    Template = settings.TemplateKey.ToString(),
                    SettingsNeeded = templateManifest.SettingsNeeded(),
                    //templateDefined = templateDefined && (!ddlTemplate.Visible || (settings.Template.Key.ToString() == ddlTemplate.SelectedValue));
                    SettingsDefined = !string.IsNullOrEmpty(settings.Data)
                });
            }
        }
Beispiel #4
0
 public void ShowRelatedResult(int id)
 {
     _currModule = ActiveModule.GOOGLE;
     DisplayActiveModulePanel();
     googleGraphPanel.SetDisplayContent(_lastResults[id]);
     bodyScrollContent.anchoredPosition = Vector2.zero;
 }
Beispiel #5
0
 // Update is called once per frame
 void Update()
 {
     if (_lastResults == null)
     {
         emptyMessage.gameObject.SetActive(true);
     }
     else
     {
         emptyMessage.gameObject.SetActive(false);
     }
     if (_newResults)
     {
         _currModule   = ActiveModule.GOOGLE;
         _newResults   = false;
         _isSlidingOut = false;
         DisplayMainResult(_lastResults[0]);
         SlideInResults();
         HandleRelatedResults(_lastResults);
     }
     if (_isSlidingIn)
     {
         SlideInResults();
     }
     else if (_isSlidingOut)
     {
         SlideOutResults();
     }
     DisplayActiveModulePanel();
 }
        public HttpResponseMessage Form(string key)
        {
            //string template = (string)ActiveModule.ModuleSettings["template"];

            JObject json = new JObject();

            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                if (settings.TemplateAvailable)
                {
                    var formBuilder = new FormBuilder(settings.TemplateDir);
                    json = formBuilder.BuildForm(key);

                    if (UserInfo.UserID > 0 && json["schema"] is JObject)
                    {
                        json["schema"] = FormUtils.InitFields(json["schema"] as JObject, UserInfo);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                LoggingUtils.ProcessApiLoadException(this, exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #7
0
        public HttpResponseMessage Post(string entity, [FromBody] JObject value)
        {
            // Add
            try
            {
                bool index = false;
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                ModuleInfo          module   = ActiveModule;
                if (settings.ModuleId > 0)
                {
                    ModuleController mc = new ModuleController();
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var manifest = settings.Template.Manifest;
                TemplateManifest templateManifest = settings.Template;
                index = settings.Template.Manifest.Index;
                string editRole = manifest.GetEditRole();

                bool listMode        = templateManifest != null && templateManifest.IsListTemplate;
                int  createdByUserid = -1;
                var  ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var  dsContext = new DataSourceContext()
                {
                    ModuleId       = module.ModuleID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Index          = index,
                    UserId         = UserInfo.UserID,
                    PortalId       = module.PortalID,
                    Config         = manifest.DataSourceConfig
                };

                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                //var indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
                ds.Add(dsContext, value.Properties().First().Value as JObject);
                //if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String)
                //{
                //    string moduleTitle = json["form"]["ModuleTitle"].ToString();
                //    OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                //}
                //else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object)
                //{
                //    if (json["form"]["ModuleTitle"][DnnUtils.GetCurrentCultureCode()] != null)
                //    {
                //        string moduleTitle = json["form"]["ModuleTitle"][DnnUtils.GetCurrentCultureCode()].ToString();
                //        OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                //    }
                //}
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #8
0
        public HttpResponseMessage Get(string entity)
        {
            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                ModuleInfo          module   = ActiveModule;
                if (settings.ModuleId > 0)
                {
                    ModuleController mc = new ModuleController();
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var manifest = settings.Manifest;
                TemplateManifest templateManifest = settings.Template;
                if (manifest.AdditionalDataExists(entity))
                {
                    var dataManifest = manifest.AdditionalData[entity];
                    //string scope = AdditionalDataUtils.GetScope(dataManifest, PortalSettings.PortalId, ActiveModule.TabID, module.ModuleID, ActiveModule.TabModuleID);

                    //var templateFolder = string.IsNullOrEmpty(dataManifest.TemplateFolder) ? settings.TemplateDir : settings.TemplateDir.ParentFolder.Append(dataManifest.TemplateFolder);
                    //var fb = new FormBuilder(templateFolder);
                    //JObject json = fb.BuildForm(entity);
                    var res = new JObject();

                    int createdByUserid = -1;
                    var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                    var dsContext = new DataSourceContext()
                    {
                        PortalId       = PortalSettings.PortalId,
                        TabId          = ActiveModule.TabID,
                        ModuleId       = module.ModuleID,
                        TabModuleId    = ActiveModule.TabModuleID,
                        UserId         = UserInfo.UserID,
                        TemplateFolder = settings.TemplateDir.FolderPath,
                        Config         = manifest.DataSourceConfig,
                        //Options = reqOptions
                    };
                    var dsItem = ds.GetData(dsContext, dataManifest.ScopeType, dataManifest.StorageKey ?? entity);
                    if (dsItem != null)
                    {
                        var json = dsItem.Data;
                        createdByUserid = dsItem.CreatedByUserId;
                        JsonUtils.IdJson(json);
                        res[entity] = json;
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, res));
                }
                else
                {
                    return(Get(entity, 0, 100, null, null));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage UpdateBuilder(JObject json)
        {
            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();

                if (json["data"] != null && json["schema"] != null && json["options"] != null)
                {
                    var    key         = json["key"].ToString();
                    string prefix      = string.IsNullOrEmpty(key) ? "" : key + "-";
                    var    schema      = json["schema"].ToString();
                    var    options     = json["options"].ToString();
                    var    view        = json["view"].ToString();
                    var    index       = json["index"].ToString();
                    var    data        = json["data"].ToString();
                    var    datafile    = new FileUri(settings.TemplateDir, $"{prefix}builder.json");
                    var    schemafile  = new FileUri(settings.TemplateDir, $"{prefix}schema.json");
                    var    optionsfile = new FileUri(settings.TemplateDir, $"{prefix}options.json");
                    var    viewfile    = new FileUri(settings.TemplateDir, $"{prefix}view.json");
                    var    indexfile   = new FileUri(settings.TemplateDir, $"{prefix}index.json");
                    try
                    {
                        File.WriteAllText(datafile.PhysicalFilePath, data);
                        File.WriteAllText(schemafile.PhysicalFilePath, schema);
                        File.WriteAllText(optionsfile.PhysicalFilePath, options);
                        File.WriteAllText(viewfile.PhysicalFilePath, view);
                        if (string.IsNullOrEmpty(index))
                        {
                            if (indexfile.FileExists)
                            {
                                File.Delete(indexfile.PhysicalFilePath);
                            }
                        }
                        else
                        {
                            File.WriteAllText(indexfile.PhysicalFilePath, index);
                        }
                    }
                    catch (Exception ex)
                    {
                        string mess = $"Error while saving file [{datafile.FilePath}]";
                        App.Services.Logger.Error(mess, ex);
                        throw new Exception(mess, ex);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    isValid = true
                }));
            }
            catch (Exception exc)
            {
                App.Services.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public List <TemplateDto> GetTemplates(bool advanced)
        {
            var scriptFileSetting = ActiveModule.OpenContentSettings().Template;
            var templates         = OpenContentUtils.ListOfTemplatesFiles(PortalSettings, ActiveModule.ModuleID, scriptFileSetting, App.Config.Opencontent, advanced);

            return(templates.Select(t => new TemplateDto()
            {
                Value = t.Value,
                Text = t.Text
            }).ToList());
        }
Beispiel #11
0
        private void magix_forms_controls_dynamic(object sender, ActiveEventArgs e)
        {
            Node ip = Ip(e.Params);

            if (ShouldInspect(ip))
            {
                Inspect(ip);
                return;
            }

            DynamicPanel ret = new DynamicPanel();

            FillOutParameters(e.Params, ret);

            Node node = ip["_code"].Get <Node>();

            if (node.ContainsValue("tag"))
            {
                ret.Tag = node["tag"].Get <string>();
            }

            if (node.ContainsValue("default"))
            {
                ret.Default = node["default"].Get <string>();
            }

            ret.Reload +=
                delegate(object sender2, DynamicPanel.ReloadEventArgs e2)
            {
                DynamicPanel dynamic = sender2 as DynamicPanel;
                Control      ctrl    = ModuleControllerLoader.Instance.LoadActiveModule(e2.Key);
                if (e2.FirstReload)
                {
                    // Since this is the Initial Loading of our module
                    // We'll need to make sure our Initial Loading procedure is being
                    // called, if Module is of type ActiveModule
                    Node nn = e2.Extra as Node;
                    ctrl.Init +=
                        delegate
                    {
                        ActiveModule module = ctrl as ActiveModule;
                        if (module != null)
                        {
                            module.InitialLoading(nn);
                        }
                    };
                }
                dynamic.Controls.Add(ctrl);
            };

            ip["_ctrl"].Value = ret;
        }
Beispiel #12
0
 public HttpResponseMessage EditData(string key)
 {
     try
     {
         OpenContentSettings settings = ActiveModule.OpenContentSettings();
         ModuleInfo          module   = ActiveModule;
         if (settings.ModuleId > 0)
         {
             ModuleController mc = new ModuleController();
             module = mc.GetModule(settings.ModuleId, settings.TabId, false);
         }
         var manifest = settings.Manifest;
         TemplateManifest templateManifest = settings.Template;
         var dataManifest    = manifest.GetAdditionalData(key);
         var templateFolder  = string.IsNullOrEmpty(dataManifest.TemplateFolder) ? settings.TemplateDir : settings.TemplateDir.ParentFolder.Append(dataManifest.TemplateFolder);
         int createdByUserid = -1;
         var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
         var dsContext = new DataSourceContext()
         {
             PortalId       = PortalSettings.PortalId,
             TabId          = ActiveModule.TabID,
             ModuleId       = module.ModuleID,
             TabModuleId    = ActiveModule.TabModuleID,
             UserId         = UserInfo.UserID,
             TemplateFolder = settings.TemplateDir.FolderPath,
             Config         = manifest.DataSourceConfig,
             //Options = reqOptions
         };
         var dsItem = ds.GetData(dsContext, dataManifest.ScopeType, dataManifest.StorageKey ?? key);
         var json   = ds.GetDataAlpaca(dsContext, true, true, true, key);
         if (dsItem != null)
         {
             json["data"] = dsItem.Data;
             var versions = ds.GetDataVersions(dsContext, dsItem);
             if (versions != null)
             {
                 json["versions"] = versions;
             }
             createdByUserid = dsItem.CreatedByUserId;
         }
         return(Request.CreateResponse(HttpStatusCode.OK, json));
     }
     catch (Exception exc)
     {
         Log.Logger.Error(exc);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }
Beispiel #13
0
 public void SetActiveContentPanel(int module)
 {
     if (module == 0)
     {
         _currModule = ActiveModule.GOOGLE;
     }
     else if (module == 1)
     {
         _currModule = ActiveModule.RELATED;
     }
     else
     {
         _currModule = ActiveModule.HISTORY;
     }
     bodyScrollContent.anchoredPosition = Vector2.zero;
 }
Beispiel #14
0
        public HttpResponseMessage Version(string id, string ticks)
        {
            OpenContentSettings settings = ActiveModule.OpenContentSettings();
            ModuleInfo          module   = ActiveModule;

            if (settings.ModuleId > 0)
            {
                ModuleController mc = new ModuleController();
                module = mc.GetModule(settings.ModuleId, settings.TabId, false);
            }
            var    manifest = settings.Template.Manifest;
            string editRole = manifest.GetEditRole();
            JToken json     = new JObject();

            try
            {
                int createdByUserid = -1;
                var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var dsContext = new DataSourceContext()
                {
                    ModuleId       = module.ModuleID,
                    ActiveModuleId = ActiveModule.ModuleID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Config         = manifest.DataSourceConfig
                };
                var dsItem = ds.Get(dsContext, id);
                if (dsItem != null)
                {
                    var version = ds.GetVersion(dsContext, dsItem, new DateTime(long.Parse(ticks)));
                    if (version != null)
                    {
                        json            = version;
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #15
0
    private string BuildModuleText()
    {
        string modText = "";

        if (module is ActiveModule)
        {
            ActiveModule mod = (ActiveModule)module;
            modText += "PWR: " + mod.Power + " RNG: " + mod.Range + "\n\n";
        }
        List <string> modInfo = module.ModuleInfo;

        foreach (var s in modInfo)
        {
            modText += s + "\n";
        }
        return(modText);
    }
Beispiel #16
0
 public HttpResponseMessage UpdateData(JObject json)
 {
     try
     {
         OpenContentSettings settings = ActiveModule.OpenContentSettings();
         ModuleInfo          module   = ActiveModule;
         if (settings.ModuleId > 0)
         {
             ModuleController mc = new ModuleController();
             module = mc.GetModule(settings.ModuleId, settings.TabId, false);
         }
         var    manifest     = settings.Template.Manifest;
         string key          = json["key"].ToString();
         var    dataManifest = manifest.GetAdditionalData(key);
         var    ds           = DataSourceManager.GetDataSource(manifest.DataSource);
         var    dsContext    = new DataSourceContext()
         {
             PortalId       = PortalSettings.PortalId,
             TabId          = ActiveModule.TabID,
             ModuleId       = module.ModuleID,
             TabModuleId    = ActiveModule.TabModuleID,
             UserId         = UserInfo.UserID,
             TemplateFolder = settings.TemplateDir.FolderPath,
             Config         = manifest.DataSourceConfig,
             //Options = reqOptions
         };
         var dsItem = ds.GetData(dsContext, dataManifest.ScopeType, dataManifest.StorageKey ?? key);
         if (dsItem == null)
         {
             ds.AddData(dsContext, dataManifest.ScopeType, dataManifest.StorageKey ?? key, json["form"]);
         }
         else
         {
             ds.UpdateData(dsContext, dsItem, json["form"]);
         }
         return(Request.CreateResponse(HttpStatusCode.OK, ""));
     }
     catch (Exception exc)
     {
         Log.Logger.Error(exc);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }
        public HttpResponseMessage LoadBuilder(string key)
        {
            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                string  prefix   = string.IsNullOrEmpty(key) ? "" : key + "-";
                JObject json     = new JObject();
                var     dataJson = JsonUtils.LoadJsonFromCacheOrDisk(new FileUri(settings.TemplateDir, $"{prefix}builder.json"));
                if (dataJson != null)
                {
                    json["data"] = dataJson;
                }

                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                App.Services.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #18
0
        public HttpResponseMessage UpdateBuilder(JObject json)
        {
            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();

                if (json["data"] != null && json["schema"] != null && json["options"] != null)
                {
                    var    key         = json["key"].ToString();
                    string prefix      = string.IsNullOrEmpty(key) ? "" : key + "-";
                    var    schema      = json["schema"].ToString();
                    var    options     = json["options"].ToString();
                    var    view        = json["view"].ToString();
                    var    data        = json["data"].ToString();
                    var    datafile    = new FileUri(settings.TemplateDir.UrlFolder + prefix + "builder.json");
                    var    schemafile  = new FileUri(settings.TemplateDir.UrlFolder + prefix + "schema.json");
                    var    optionsfile = new FileUri(settings.TemplateDir.UrlFolder + prefix + "options.json");
                    var    viewfile    = new FileUri(settings.TemplateDir.UrlFolder + prefix + "view.json");
                    try
                    {
                        File.WriteAllText(datafile.PhysicalFilePath, data);
                        File.WriteAllText(schemafile.PhysicalFilePath, schema);
                        File.WriteAllText(optionsfile.PhysicalFilePath, options);
                        File.WriteAllText(viewfile.PhysicalFilePath, view);
                    }
                    catch (Exception ex)
                    {
                        string mess = $"Error while saving file [{datafile.FilePath}]";
                        Log.Logger.Error(mess, ex);
                        throw new Exception(mess, ex);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
 public List <TemplateDto> GetNewTemplates(bool web)
 {
     if (web)
     {
         var templates = GithubTemplateUtils.GetTemplateList(ActiveModule.PortalID).Where(t => t.Type == Components.Github.TypeEnum.Dir).OrderBy(t => t.Name);
         return(templates.Select(t => new TemplateDto()
         {
             Value = t.Path,
             Text = t.Name
         }).ToList());
     }
     else
     {
         var scriptFileSetting = ActiveModule.OpenContentSettings().Template;
         var templates         = OpenContentUtils.GetTemplates(PortalSettings, ActiveModule.ModuleID, scriptFileSetting, App.Config.Opencontent);
         return(templates.Select(t => new TemplateDto()
         {
             Value = t.Value,
             Text = t.Text
         }).ToList());
     }
 }
        public HttpResponseMessage EditQuerySettings()
        {
            string data = (string)ActiveModule.ModuleSettings["query"];

            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                var     fb       = new FormBuilder(settings.TemplateDir);
                JObject json     = fb.BuildQuerySettings(settings.Template.Collection);
                var     dataJson = data.ToJObject("query settings json");
                if (dataJson != null)
                {
                    json["data"] = dataJson;
                }

                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                App.Services.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage EditSettings(string key, bool templateFolder)
        {
            string data = (string)ActiveModule.ModuleSettings[key];

            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                var     fb       = new FormBuilder(templateFolder ? settings.TemplateDir : new FolderUri("~/DesktopModules/OpenContent"));
                JObject json     = fb.BuildForm(key, DnnLanguageUtils.GetCurrentCultureCode());
                var     dataJson = data.ToJObject("Raw settings json");
                if (dataJson != null)
                {
                    json["data"] = dataJson;
                }

                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                App.Services.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #22
0
        public HttpResponseMessage List(RequestDTO req)
        {
            try
            {
                OpenContentModuleInfo module = new OpenContentModuleInfo(ActiveModule);
                JObject reqOptions           = null;
                if (!string.IsNullOrEmpty(req.options))
                {
                    reqOptions = JObject.Parse(req.options);
                }
                if (module.IsListMode())
                {
                    var          indexConfig  = OpenContentUtils.GetIndexConfig(module.Settings.Template);
                    QueryBuilder queryBuilder = new QueryBuilder(indexConfig);
                    bool         isEditable   = ActiveModule.CheckIfEditable(PortalSettings);
                    queryBuilder.Build(module.Settings.Query, !isEditable, UserInfo.UserID, DnnLanguageUtils.GetCurrentCultureCode(), UserInfo.Social.Roles);

                    JplistQueryBuilder.MergeJpListQuery(indexConfig, queryBuilder.Select, req.StatusLst, DnnLanguageUtils.GetCurrentCultureCode());
                    IDataItems dsItems;
                    if (queryBuilder.DefaultNoResults && queryBuilder.Select.IsQueryEmpty)
                    {
                        dsItems = new DefaultDataItems()
                        {
                            Items = new List <DefaultDataItem>(),
                            Total = 0
                        };
                    }
                    else
                    {
                        IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                        var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID, false, reqOptions);
                        dsItems = ds.GetAll(dsContext, queryBuilder.Select);
                    }
                    var mf = new ModelFactoryMultiple(dsItems.Items, module, PortalSettings);
                    mf.Options = reqOptions;
                    var model = mf.GetModelAsJson(false, req.onlyItems);

                    //model["luceneQuery"] = dsItems.DebugInfo;
                    if (LogContext.IsLogActive)
                    {
                        LogContext.Log(ActiveModule.ModuleID, "RequestContext", "IsEditable", isEditable);
                        LogContext.Log(ActiveModule.ModuleID, "RequestContext", "UserRoles", PortalSettings.UserInfo.Social.Roles.Select(r => r.RoleName));
                        LogContext.Log(ActiveModule.ModuleID, "RequestContext", "CurrentUserId", PortalSettings.UserId);
                        var logKey = "Query";
                        LogContext.Log(ActiveModule.ModuleID, logKey, "select", queryBuilder.Select);
                        LogContext.Log(ActiveModule.ModuleID, logKey, "debuginfo", dsItems.DebugInfo);
                        LogContext.Log(ActiveModule.ModuleID, logKey, "model", model);
                        model["Logs"] = JToken.FromObject(LogContext.Current.ModuleLogs(ActiveModule.ModuleID));
                    }
                    var res = new ResultDTO()
                    {
                        data  = model,
                        count = dsItems.Total
                    };
                    return(Request.CreateResponse(HttpStatusCode.OK, res));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "not supported because not in multi items template "));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #23
0
        public HttpResponseMessage Delete(string entity, string id)
        {
            try
            {
                bool index = false;
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                ModuleInfo          module   = ActiveModule;
                if (settings.ModuleId > 0)
                {
                    ModuleController mc = new ModuleController();
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var manifest = settings.Template.Manifest;
                TemplateManifest templateManifest = settings.Template;
                index = settings.Template.Manifest.Index;
                string editRole = manifest.GetEditRole();

                bool listMode        = templateManifest != null && templateManifest.IsListTemplate;
                int  createdByUserid = -1;
                var  ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var  dsContext = new DataSourceContext()
                {
                    ModuleId       = module.ModuleID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Index          = index,
                    UserId         = UserInfo.UserID,
                    PortalId       = module.PortalID,
                    Config         = manifest.DataSourceConfig
                };
                string    itemId = null;
                IDataItem dsItem = null;
                if (listMode)
                {
                    if (id != null)
                    {
                        itemId = id;
                        dsItem = ds.Get(dsContext, itemId);
                        if (dsItem != null)
                        {
                            createdByUserid = dsItem.CreatedByUserId;
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                    if (dsItem != null)
                    {
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
                //var indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
                if (dsItem != null)
                {
                    ds.Delete(dsContext, dsItem);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Get(string entity, int pageIndex, int pageSize, string filter = null, string sort = null)
        {
            try
            {
                var collection = entity;
                //if (entity == "items")
                collection = AppConfig.DEFAULT_COLLECTION; // backward compatibility
                RestSelect restSelect = new RestSelect()
                {
                    PageIndex = pageIndex,
                    PageSize  = pageSize
                };
                if (!string.IsNullOrEmpty(filter))
                {
                    restSelect.Query = JsonConvert.DeserializeObject <RestGroup>(filter);
                }
                if (!string.IsNullOrEmpty(sort))
                {
                    restSelect.Sort = JsonConvert.DeserializeObject <List <RestSort> >(sort);
                }

                ModuleInfo activeModule = ActiveModule;

                OpenContentSettings   settings = activeModule.OpenContentSettings();
                OpenContentModuleInfo module   = new OpenContentModuleInfo(ActiveModule);
                JObject reqOptions             = null;

                if (module.IsListMode())
                {
                    var          indexConfig  = OpenContentUtils.GetIndexConfig(settings.TemplateDir, collection);
                    QueryBuilder queryBuilder = new QueryBuilder(indexConfig);
                    bool         isEditable   = ActiveModule.CheckIfEditable(PortalSettings);
                    queryBuilder.Build(settings.Query, !isEditable, UserInfo.UserID, DnnLanguageUtils.GetCurrentCultureCode(), UserInfo.Social.Roles);

                    RestQueryBuilder.MergeQuery(indexConfig, queryBuilder.Select, restSelect, DnnLanguageUtils.GetCurrentCultureCode());
                    IDataItems dsItems;
                    if (queryBuilder.DefaultNoResults && queryBuilder.Select.IsQueryEmpty)
                    {
                        dsItems = new DefaultDataItems()
                        {
                            Items = new List <DefaultDataItem>(),
                            Total = 0
                        };
                    }
                    else
                    {
                        IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                        var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID, false, reqOptions);
                        dsContext.Collection = collection;
                        dsItems = ds.GetAll(dsContext, queryBuilder.Select);
                    }
                    var mf = new ModelFactoryMultiple(dsItems.Items, module, PortalSettings, collection);
                    mf.Options = reqOptions;
                    var model = mf.GetModelAsJson(false);
                    var res   = new JObject();
                    res["meta"] = new JObject();
                    if (LogContext.IsLogActive)
                    {
                        var logKey = "Query";
                        LogContext.Log(activeModule.ModuleID, logKey, "select", queryBuilder.Select);
                        LogContext.Log(activeModule.ModuleID, logKey, "debuginfo", dsItems.DebugInfo);
                        LogContext.Log(activeModule.ModuleID, logKey, "model", model);
                        res["meta"]["logs"] = JToken.FromObject(LogContext.Current.ModuleLogs(activeModule.ModuleID));

                        if (restSelect != null)
                        {
                            //res["meta"]["select"] = JObject.FromObject(restSelect);
                        }
                    }
                    foreach (var item in model["Items"] as JArray)
                    {
                        item["id"] = item["Context"]["Id"];
                        JsonUtils.IdJson(item);
                    }
                    res[entity]          = model[collection];
                    res["meta"]["total"] = dsItems.Total;
                    return(Request.CreateResponse(HttpStatusCode.OK, res));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "not supported because not in multi items template "));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #25
0
 public HttpResponseMessage Get(string entity, string id)
 {
     try
     {
         //int ModuleId = int.Parse(Request.Headers.GetValues("ModuleId").First());
         //int TabId = int.Parse(Request.Headers.GetValues("TabId").First());
         ModuleController    mc           = new ModuleController();
         ModuleInfo          activeModule = ActiveModule; //mc.GetModule(ModuleId, TabId, false);
         OpenContentSettings settings     = activeModule.OpenContentSettings();
         ModuleInfo          module       = activeModule;
         if (settings.ModuleId > 0)
         {
             //ModuleController mc = new ModuleController();
             module = mc.GetModule(settings.ModuleId, settings.TabId, false);
         }
         var     manifest         = settings.Template.Manifest;
         var     templateManifest = settings.Template;
         JObject reqOptions       = null;
         //if (!string.IsNullOrEmpty(req.options))
         //{
         //    reqOptions = JObject.Parse(req.options);
         //}
         //string editRole = manifest.GetEditRole();
         bool listMode = templateManifest != null && templateManifest.IsListTemplate;
         if (listMode)
         {
             var          indexConfig  = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
             QueryBuilder queryBuilder = new QueryBuilder(indexConfig);
             bool         isEditable   = ActiveModule.CheckIfEditable(PortalSettings);//portalSettings.UserMode != PortalSettings.Mode.Edit;
             queryBuilder.Build(settings.Query, !isEditable, UserInfo.UserID, DnnLanguageUtils.GetCurrentCultureCode(), UserInfo.Social.Roles);
             //if (restSelect != null)
             //{
             //    RestQueryBuilder.MergeJpListQuery(indexConfig, queryBuilder.Select, restSelect);
             //}
             queryBuilder.Select.Query.AddRule(new FilterRule()
             {
                 Field = "$id",
                 Value = new StringRuleValue(id)
             });
             IDataItems dsItems;
             if (queryBuilder.DefaultNoResults && queryBuilder.Select.IsQueryEmpty)
             {
                 dsItems = new DefaultDataItems()
                 {
                     Items = new List <DefaultDataItem>(),
                     Total = 0
                 };
             }
             else
             {
                 var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                 var dsContext = new DataSourceContext()
                 {
                     ModuleId       = module.ModuleID,
                     UserId         = UserInfo.UserID,
                     TemplateFolder = settings.TemplateDir.FolderPath,
                     Config         = manifest.DataSourceConfig,
                     Options        = reqOptions
                 };
                 dsItems = ds.GetAll(dsContext, queryBuilder.Select);
             }
             int          mainTabId = settings.DetailTabId > 0 ? settings.DetailTabId : settings.TabId;
             ModelFactory mf        = new ModelFactory(dsItems.Items, activeModule, PortalSettings, mainTabId);
             mf.Options = reqOptions;
             var model = mf.GetModelAsJson(false);
             var res   = new JObject();
             res["meta"]          = new JObject();
             res["meta"]["total"] = dsItems.Total;
             //model["luceneQuery"] = dsItems.DebugInfo;
             if (LogContext.IsLogActive)
             {
                 var logKey = "Query";
                 LogContext.Log(activeModule.ModuleID, logKey, "select", queryBuilder.Select);
                 LogContext.Log(activeModule.ModuleID, logKey, "result", dsItems);
                 LogContext.Log(activeModule.ModuleID, logKey, "model", model);
                 res["meta"]["logs"] = JToken.FromObject(LogContext.Current.ModuleLogs(activeModule.ModuleID));
             }
             if (model["Items"] is JArray)
             {
                 foreach (var item in (JArray)model["Items"])
                 {
                     item["id"] = item["Context"]["Id"];
                     JsonUtils.IdJson(item);
                 }
             }
             res[entity] = model["Items"];
             return(Request.CreateResponse(HttpStatusCode.OK, res));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "not supported because not in multi items template "));
         }
     }
     catch (Exception exc)
     {
         Log.Logger.Error(exc);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
     }
 }
        public ModuleStateDto SaveTemplate(SaveDto input)
        {
            ModuleController mc = new ModuleController();

            if (!input.otherModule) // this module
            {
                mc.DeleteModuleSetting(ActiveModule.ModuleID, "tabid");
                mc.DeleteModuleSetting(ActiveModule.ModuleID, "moduleid");
            }
            else // other module
            {
                var dsModule = (new ModuleController()).GetTabModule(input.tabModuleId);
                mc.UpdateModuleSetting(ActiveModule.ModuleID, "tabid", dsModule.TabID.ToString());
                mc.UpdateModuleSetting(ActiveModule.ModuleID, "moduleid", dsModule.ModuleID.ToString());
            }
            if (!input.newTemplate) // existing
            {
                mc.UpdateModuleSetting(ActiveModule.ModuleID, "template", input.template);
                ActiveModule.ModuleSettings["template"] = input.template;
            }
            else // new
            {
                try
                {
                    if (!input.fromWeb) // site
                    {
                        string oldFolder = HostingEnvironment.MapPath(input.template);
                        var    template  = OpenContentUtils.CopyTemplate(ActiveModule.PortalID, oldFolder, input.templateName);
                        mc.UpdateModuleSetting(ActiveModule.ModuleID, "template", template);
                        ActiveModule.ModuleSettings["template"] = template;
                    }
                    else  // web
                    {
                        //string fileName = ddlTemplate.SelectedValue;
                        //string template = OpenContentUtils.ImportFromWeb(ModuleContext.PortalId, fileName, tbTemplateName.Text);
                        //mc.UpdateModuleSetting(ModuleContext.ModuleId, "template", template);
                        //ModuleContext.Settings["template"] = template;
                        //string fileName = ddlTemplate.SelectedValue;

                        var template = GithubTemplateUtils.ImportFromGithub(ActiveModule.PortalID, input.template, input.template, input.templateName);

                        mc.UpdateModuleSetting(ActiveModule.ModuleID, "template", template);
                        ActiveModule.ModuleSettings["template"] = template;
                    }
                }
                catch (Exception ex)
                {
                    return(new ModuleStateDto()
                    {
                        Error = ex.Message
                    });
                }
            }
            //mc.UpdateModuleSetting(ActiveModule.ModuleID, "detailtabid", ddlDetailPage.SelectedValue);


            //don't reset settings. Sure they might be invalid, but maybe not. And you can't ever revert.
            //mc.DeleteModuleSetting(ModuleContext.ModuleId, "data");

            var settings         = ActiveModule.OpenContentSettings();
            var templateManifest = settings.Template;

            if (templateManifest.SettingsNeeded())
            {
                var settingsFilename = templateManifest.MainTemplateUri().PhysicalFullDirectory + "\\" + templateManifest.Key.ShortKey + "-data.json";
                if (File.Exists(settingsFilename))
                {
                    var settingContent = File.ReadAllText(settingsFilename);
                    mc.UpdateModuleSetting(ActiveModule.ModuleID, "data", settingContent);
                    ActiveModule.ModuleSettings["data"] = settingContent;
                    settings = ActiveModule.OpenContentSettings();
                }
            }
            bool defaultData = false;

            if (templateManifest.DataNeeded())
            {
                var dataFilename = templateManifest.MainTemplateUri().PhysicalFullDirectory + "\\data.json";
                if (File.Exists(dataFilename))
                {
                    var         module    = OpenContentModuleConfig.Create(ActiveModule, PortalSettings);
                    IDataSource ds        = DataSourceManager.GetDataSource(settings.Manifest.DataSource);
                    var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);
                    ds.Add(dsContext, JObject.Parse(File.ReadAllText(dataFilename)));
                    defaultData = true;
                }
            }

            return(new ModuleStateDto()
            {
                SettingsNeeded = templateManifest.SettingsNeeded(),
                SettingsDefined = !string.IsNullOrEmpty(settings.Data),
                DataNeeded = settings.Template.DataNeeded() && !defaultData,
                Template = settings.TemplateKey.ToString(),
                Error = ""
            });
        }
Beispiel #27
0
 public void Visit(ActiveModule module)
 {
     CheckItemEnablerExtensions(module);
     module.VisitAmmo(this);
 }
Beispiel #28
0
        public HttpResponseMessage LookupData(LookupDataRequestDTO req)
        {
            OpenContentSettings settings = ActiveModule.OpenContentSettings();
            ModuleInfo          module   = ActiveModule;

            if (settings.ModuleId > 0)
            {
                ModuleController mc = new ModuleController();
                module = mc.GetModule(settings.ModuleId, settings.TabId, false);
            }
            var manifest = settings.Template.Manifest;
            TemplateManifest templateManifest = settings.Template;
            string           key       = req.dataKey;
            var dataManifest           = manifest.GetAdditionalData(key);
            List <LookupResultDTO> res = new List <LookupResultDTO>();

            try
            {
                var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                var dsContext = new DataSourceContext()
                {
                    PortalId       = PortalSettings.PortalId,
                    TabId          = ActiveModule.TabID,
                    ModuleId       = module.ModuleID,
                    TabModuleId    = ActiveModule.TabModuleID,
                    UserId         = UserInfo.UserID,
                    TemplateFolder = settings.TemplateDir.FolderPath,
                    Config         = manifest.DataSourceConfig,
                    //Options = reqOptions
                };
                var dsItem = ds.GetData(dsContext, dataManifest.ScopeType, dataManifest.StorageKey ?? key);
                if (dsItem != null)
                {
                    JToken json = dsItem.Data;
                    if (!string.IsNullOrEmpty(req.dataMember))
                    {
                        json = json[req.dataMember];
                    }
                    if (json is JArray)
                    {
                        AddLookupItems(req.valueField, req.textField, req.childrenField, res, json as JArray);
                    }

                    /*
                     * else if (json is JObject)
                     * {
                     *  foreach (var item in json.Children<JProperty>())
                     *  {
                     *      res.Add(new LookupResultDTO()
                     *      {
                     *          value = dataManifest.ModelKey ?? key +"/"+item.Name,
                     *          text = item.Value[req.textField] == null ? "" : item.Value[req.textField].ToString()
                     *      });
                     *  }
                     * }
                     */
                }
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage Update(JObject json)
        {
            try
            {
                var    module          = OpenContentModuleConfig.Create(ActiveModule, PortalSettings);
                string editRole        = module.Settings.Template.Manifest.GetEditRole();
                int    createdByUserid = -1;

                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                IDataItem dsItem = null;
                if (module.IsListMode())
                {
                    if (json["id"] != null)
                    {
                        var itemId = json["id"].ToString();
                        dsItem = ds.Get(dsContext, itemId);
                        if (dsItem != null)
                        {
                            createdByUserid = dsItem.CreatedByUserId;
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                    if (dsItem != null)
                    {
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!DnnPermissionsUtils.HasEditPermissions(module, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                AddNotifyInfo(dsContext);
                try
                {
                    if (dsItem == null)
                    {
                        ds.Add(dsContext, json["form"] as JObject);
                    }
                    else
                    {
                        ds.Update(dsContext, dsItem, json["form"] as JObject);
                    }
                    App.Services.CacheAdapter.SyncronizeCache(module);
                }
                catch (DataNotValidException ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new
                    {
                        isValid = false,
                        validMessage = ex.Message
                    }));
                }

                if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String)
                {
                    string moduleTitle = json["form"]["ModuleTitle"].ToString();
                    ActiveModule.UpdateModuleTitle(moduleTitle);
                }
                else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object)
                {
                    if (json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] != null)
                    {
                        string moduleTitle = json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()].ToString();
                        ActiveModule.UpdateModuleTitle(moduleTitle);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    isValid = true
                }));
            }
            catch (Exception exc)
            {
                App.Services.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Beispiel #30
0
        public HttpResponseMessage List(RequestDTO req)
        {
            try
            {
                OpenContentSettings settings = ActiveModule.OpenContentSettings();
                ModuleInfo          module   = ActiveModule;
                if (settings.ModuleId > 0)
                {
                    ModuleController mc = new ModuleController();
                    module = mc.GetModule(settings.ModuleId, settings.TabId, false);
                }
                var     manifest         = settings.Template.Manifest;
                var     templateManifest = settings.Template;
                JObject reqOptions       = null;
                if (!string.IsNullOrEmpty(req.options))
                {
                    reqOptions = JObject.Parse(req.options);
                }
                //string editRole = manifest.GetEditRole();
                bool listMode = templateManifest != null && templateManifest.IsListTemplate;
                if (listMode)
                {
                    var          indexConfig  = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
                    QueryBuilder queryBuilder = new QueryBuilder(indexConfig);
                    bool         isEditable   = ActiveModule.CheckIfEditable(PortalSettings);//portalSettings.UserMode != PortalSettings.Mode.Edit;
                    queryBuilder.Build(settings.Query, !isEditable, UserInfo.UserID, DnnLanguageUtils.GetCurrentCultureCode(), UserInfo.Social.Roles);

                    JplistQueryBuilder.MergeJpListQuery(indexConfig, queryBuilder.Select, req.StatusLst, DnnLanguageUtils.GetCurrentCultureCode());
                    IDataItems dsItems;
                    if (queryBuilder.DefaultNoResults && queryBuilder.Select.IsQueryEmpty)
                    {
                        dsItems = new DefaultDataItems()
                        {
                            Items = new List <DefaultDataItem>(),
                            Total = 0
                        };
                    }
                    else
                    {
                        var ds        = DataSourceManager.GetDataSource(manifest.DataSource);
                        var dsContext = new DataSourceContext()
                        {
                            ModuleId       = module.ModuleID,
                            ActiveModuleId = ActiveModule.ModuleID,
                            UserId         = UserInfo.UserID,
                            TemplateFolder = settings.TemplateDir.FolderPath,
                            Config         = manifest.DataSourceConfig,
                            Options        = reqOptions
                        };
                        dsItems = ds.GetAll(dsContext, queryBuilder.Select);
                    }
                    int          mainTabId = settings.DetailTabId > 0 ? settings.DetailTabId : settings.TabId;
                    ModelFactory mf        = new ModelFactory(dsItems.Items, ActiveModule, PortalSettings, mainTabId);
                    mf.Options = reqOptions;
                    var model = mf.GetModelAsJson(false);

                    //model["luceneQuery"] = dsItems.DebugInfo;
                    if (LogContext.IsLogActive)
                    {
                        LogContext.Log(ActiveModule.ModuleID, "RequestContext", "IsEditable", isEditable);
                        LogContext.Log(ActiveModule.ModuleID, "RequestContext", "UserRoles", PortalSettings.UserInfo.Social.Roles.Select(r => r.RoleName));
                        LogContext.Log(ActiveModule.ModuleID, "RequestContext", "CurrentUserId", PortalSettings.UserId);
                        var logKey = "Query";
                        LogContext.Log(ActiveModule.ModuleID, logKey, "select", queryBuilder.Select);
                        LogContext.Log(ActiveModule.ModuleID, logKey, "result", dsItems);
                        LogContext.Log(ActiveModule.ModuleID, logKey, "model", model);
                        model["Logs"] = JToken.FromObject(LogContext.Current.ModuleLogs(ActiveModule.ModuleID));
                    }
                    var res = new ResultDTO()
                    {
                        data  = model,
                        count = dsItems.Total
                    };
                    return(Request.CreateResponse(HttpStatusCode.OK, res));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "not supported because not in multi items template "));
                }
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }