public static void MainTeste(string[] args)
        {
            ISearchApp searchApp = new SearchAppByName(new SearchAppByLink(null));
            IGetApp    getApp    = new GetApp();

            IEnumerable <App> searchResult = searchApp.Search("whatsapp", "us");

            foreach (var app in searchResult)
            {
                Console.WriteLine($"Name = {app.Name}");
                Console.WriteLine($"Description = {app.Description}");
                Console.WriteLine($"Icon = {app.Icon}");
                Console.WriteLine($"Link = {app.Link}");

                Console.WriteLine();

                var appDetails = getApp.Get(app.Link, "us");

                Console.WriteLine($"Name = {appDetails.Name}");
                Console.WriteLine($"Description = {appDetails.Description}");
                Console.WriteLine($"Icon = {appDetails.Icon}");
                Console.WriteLine($"Link = {appDetails.Link}");
                Console.WriteLine($"Category = {appDetails.Category}");
                Console.WriteLine($"Category Ranking = {(appDetails.RankingCategory == -1 ? "60+" : appDetails.RankingCategory.ToString())}");
                Console.WriteLine($"Category Overall = {(appDetails.PositionOverall == -1 ? "100+" : appDetails.PositionOverall.ToString())}");

                Console.WriteLine();
                Console.WriteLine("====================================================");
                Console.WriteLine();
            }

            Console.ReadKey();
        }
Beispiel #2
0
        internal void RemoveAppInTenantAndEav(int appId, ITenant tenant)
        {
            var zoneId = ZoneRuntime.ZoneId;

            // check portal assignment and that it's not the default app
            if (zoneId != CmsZones.Env.ZoneMapper.GetZoneId(tenant.Id))
            {
                throw new Exception("This app does not belong to portal " + tenant.Id);
            }

            if (appId == ZoneRuntime /*new ZoneRuntime(zoneId, parentLog)*/.DefaultAppId)
            {
                throw new Exception("The default app of a zone cannot be removed.");
            }

            // Prepare to Delete folder in dnn - this must be done, before deleting the app in the DB
            var sexyApp  = GetApp.LightWithoutData(tenant, zoneId, appId, null);
            var folder   = sexyApp.Folder;
            var physPath = sexyApp.PhysicalPath;

            // now remove from DB. This sometimes fails, so we do this before trying to clean the files
            // as the db part should be in a transaction, and if it fails, everything should stay as is
            new ZoneManager(zoneId, Log).DeleteApp(appId);

            // now really delete the files - if the DB didn't end up throwing an error
            if (!string.IsNullOrEmpty(folder) && Directory.Exists(physPath))
            {
                Directory.Delete(physPath, true);
            }
        }
        public object Get(GetApp request)
        {
            string id = request.SteamId + request.Name + request.ID;
            string cacheKey = UrnId.Create<App>(id);
            return Request.ToOptimizedResultUsingCache(
                base.Cache,
                cacheKey,
                TimeSpan.FromMinutes(20),
                () =>
                {
                    App app = null;
                    if (request.ID > 0)
                    {
                        app = Db.SingleById<App>(request.ID);
                    }

                    if (request.SteamId > 0)
                    {
                        // app = session.Query<App>().SingleOrDefault(u => u.SteamId == request.SteamId);
                    }

                    if (!string.IsNullOrWhiteSpace(request.Name))
                    {
                        // app = session.Query<App>().SingleOrDefault(u => u.Name == request.Name);

                        // return session.Query<App>().Single(u => string.Compare(u.Name,request.Name, StringComparison.InvariantCultureIgnoreCase) == 0);
                    }

                    return app;
                });
        }
        public string TemplatesRoot(int zoneId, int appId)
        {
            var app = GetApp.LightWithoutData(new DnnTenant(PortalSettings.Current), zoneId, appId, false, Log);

            // Copy all files in 2sexy folder to (portal file system) 2sexy folder
            var templateRoot = HttpContext.Current.Server.MapPath(TemplateHelpers.GetTemplatePathRoot(Settings.TemplateLocations.PortalFileSystem, app));

            return(templateRoot);
        }
        public void RequestCompleteTest()
        {
            var app = new GetApp();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["type"] = "1";
            var data = app.GetData(parameters, true);

            Console.WriteLine(data);
        }
Beispiel #6
0
        public override XmlExporter Init(int zoneId, int appId, AppRuntime appRuntime, bool appExport, string[] attrSetIds, string[] entityIds, ILog parentLog)
        {
            var tenant = new DnnTenant(PortalSettings.Current);
            var app    = GetApp.LightWithoutData(tenant, zoneId, appId, parentLog: Log);

            AdamAppContext = new AdamAppContext(tenant, app, null, 10, Log);
            Constructor(zoneId, appRuntime, app.AppGuid, appExport, attrSetIds, entityIds, parentLog);

            // this must happen very early, to ensure that the file-lists etc. are correct for exporting when used externally
            InitExportXDocument(PortalSettings.Current.DefaultLanguage, Settings.ModuleVersion);

            return(this);
        }
Beispiel #7
0
        public void Invoke_ForInvalidId_ReturnsNulledModel()
        {
            // prepare
            var findByResult        = new List <DataAccess.Models.App>();
            var mockedAppRepository = new Mock <IAppRepository>();

            mockedAppRepository.Setup(r => r.FindBy(It.IsAny <Expression <Func <DataAccess.Models.App, bool> > >()))
            .Returns(findByResult.AsQueryable);
            var action = new GetApp(mockedAppRepository.Object);

            // action
            var app = action.Invoke(999);

            // check
            Assert.Null(app);
        }
Beispiel #8
0
        private AssetEditor GetAssetEditorOrThrowIfInsufficientPermissions(int appId, int templateId, bool global, string path)
        {
            var wrapLog = Log.Call <AssetEditor>($"{appId}, {templateId}, {global}, {path}");
            var isAdmin = UserInfo.IsInRole(PortalSettings.AdministratorRoleName);
            var app     = BlockBuilder.App;

            if (appId != 0 && appId != app.AppId)
            {
                app = GetApp.LightWithoutData(new DnnTenant(PortalSettings.Current), appId, Log);
            }
            var assetEditor = (templateId != 0 && path == null)
                ? new AssetEditor(app, templateId, UserInfo.IsSuperUser, isAdmin, Log)
                : new AssetEditor(app, path, UserInfo.IsSuperUser, isAdmin, global, Log);

            assetEditor.EnsureUserMayEditAssetOrThrow();
            return(wrapLog(null, assetEditor));
        }
        private string ResolveAppPath(int appId, bool global, bool allowFullAccess)
        {
            var thisApp = GetApp.LightWithoutData(new DnnTenant(PortalSettings.Current), appId, Log);

            if (global && !allowFullAccess)
            {
                throw new NotSupportedException("only host user may access global files");
            }

            var appPath = TemplateHelpers.GetTemplatePathRoot(
                global
                    ? Settings.TemplateLocations.HostFileSystem
                    : Settings.TemplateLocations.PortalFileSystem
                , thisApp); // get root in global system

            appPath = global::System.Web.Hosting.HostingEnvironment.MapPath(appPath);
            return(appPath);
        }
Beispiel #10
0
        public dynamic GetManyForEditing([FromBody] List <ItemIdentifier> items, int appId)
        {
            var wrapLog = Log.Call($"get many a#{appId}, items⋮{items.Count}");

            // before we start, we have to convert the indexes into something more useful, because
            // otherwise in content-list scenarios we don't have the type
            var appForSecurityChecks = GetApp.LightWithoutData(new DnnTenant(PortalSettings), SystemRuntime.ZoneIdOfApp(appId), appId, Log);

            items = new ContentGroupList(BlockBuilder, Log).ConvertListIndexToId(items, appForSecurityChecks);

            // to do full security check, we'll have to see what content-type is requested
            var permCheck = new MultiPermissionsTypes(BlockBuilder, appId, items, Log);

            if (!permCheck.EnsureAll(GrantSets.WriteSomething, out var exception))
            {
                throw exception;
            }

            var list = new EntityApi(appId, permCheck.EnsureAny(GrantSets.ReadDraft), Log).GetEntitiesForEditing(appId, items);

            // Reformat to the Entity-WithLanguage setup
            var listAsEwH = list.Select(p => new BundleWithHeader <EntityWithLanguages>
            {
                Header = p.Header,
                Entity = p.Entity != null
                    ? EntityWithLanguages.Build(appId, p.Entity)
                    : null
            }).ToList();

            // 2018-09-26 2dm
            // if we're giving items which already exist, then we must verify that edit/read is allowed.
            // important, this code is shared/duplicated in the UiController.Load
            if (list.Any(set => set.Entity != null))
            {
                if (!permCheck.EnsureAll(GrantSets.ReadSomething, out exception))
                {
                    throw exception;
                }
            }

            wrapLog($"will return items⋮{list.Count}");
            return(listAsEwH);
        }
Beispiel #11
0
        public bool Create([FromUri] int appId, [FromUri] string path, [FromBody] ContentHelper content, bool global = false)
        {
            Log.Add($"create a#{appId}, path:{path}, global:{global}, cont-length:{content.Content?.Length}");
            path = path.Replace("/", "\\");

            var thisApp = GetApp.LightWithoutData(new DnnTenant(PortalSettings.Current), appId, Log);

            if (content.Content == null)
            {
                content.Content = "";
            }

            path = SanitizePathAndContent(path, content);

            var isAdmin     = UserInfo.IsInRole(PortalSettings.AdministratorRoleName);
            var assetEditor = new AssetEditor(thisApp, path, UserInfo.IsSuperUser, isAdmin, global, Log);

            assetEditor.EnsureUserMayEditAssetOrThrow(path);
            return(assetEditor.Create(content.Content));
        }
Beispiel #12
0
        public void Invoke_ReturnsCorrectModel()
        {
            // prepare
            var dataApp = new DataAccess.Models.App()
            {
                Id = 1234, Name = "TestApp"
            };
            var findByResult = new List <DataAccess.Models.App> {
                dataApp
            };
            var mockedAppRepository = new Mock <IAppRepository>();

            mockedAppRepository.Setup(r => r.FindBy(It.IsAny <Expression <Func <DataAccess.Models.App, bool> > >()))
            .Returns(findByResult.AsQueryable);
            var action = new GetApp(mockedAppRepository.Object);

            // action
            var app = action.Invoke(1234);

            // check
            Assert.Equal(1234, app.Id);
            Assert.Equal("TestApp", app.Name);
        }