public void ProcessRequest(HttpContext context)
        {
            // Get the name of the function to execute by copying the current file name
            // (without the .ashx extension)
            string functionName = Path.GetFileNameWithoutExtension(context.Request.Path);
            // Locate the data culture to use - like en-US or nl-NL
            CultureInfo dataCulture = GetCurrentDataCulture(context);

            using (DataScope dataScope = new DataScope(DataScopeIdentifier.Public, dataCulture))
            {
                // Grab a function object to execute
                IFunction function = FunctionFacade.GetFunction(functionName);

                // Execute the function, passing all query string parameters as input parameters
                object functionResult = FunctionFacade.Execute<object>(function, context.Request.QueryString);

                // output result
                if (functionResult != null)
                {
                    context.Response.Write(functionResult.ToString());
                    if (functionResult is XNode && function.ReturnType != typeof(Composite.Core.Xml.XhtmlDocument))
                        context.Response.ContentType = "text/xml";
                }
            }
        }
        private void step1CodeActivity_InitializeBindings_ExecuteCode(object sender, EventArgs e)
        {
            DataTypeDescriptor dataTypeDescriptor = GetDataTypeDescriptor();

            Type interfaceType = TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName);

            List<CultureInfo> culturesWithData = new List<CultureInfo>();
            foreach (CultureInfo cultureInfo in DataLocalizationFacade.ActiveLocalizationCultures)
            {
                using (DataScope localeScope = new DataScope(cultureInfo))
                {
                    bool dataExists = DataFacade.GetData(interfaceType).ToDataEnumerable().Any();

                    if (dataExists)
                    {
                        culturesWithData.Add(cultureInfo);
                    }
                }
            }

            Dictionary<string, string> culturesDictionary = culturesWithData.ToDictionary(f => f.Name, DataLocalizationFacade.GetCultureTitle);

            this.Bindings.Add("CultureName", culturesDictionary.First().Key);
            this.Bindings.Add("CultureNameList", culturesDictionary);
        }
            public void AuthenticateRequest(object sender, EventArgs e)
            {
                if (SystemSetupFacade.IsSystemFirstTimeInitialized == false) return;

                HttpApplication application = (HttpApplication)sender;
                HttpContext context = application.Context;

                bool adminRootRequest = UrlUtils.IsAdminConsoleRequest(context);

                if (adminRootRequest && UserValidationFacade.IsLoggedIn())
                {
                    _dataScope = new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo);
                }
            }
Exemple #4
0
        public void Pack(PackageCreator creator)
        {
            if (Id == _pagesName)
            {
                #region All Pages
                HashSet<Guid> pages;
                using (var scope = new DataScope(DataScopeIdentifier.Administrated))
                {
                    pages = DataFacade.GetData<IPage>().Select(p => p.Id).ToHashSet();
                }

                creator.AddData(typeof(IPage), DataScopeIdentifier.Public, d => pages.Contains((d as IPage).Id));
                creator.AddData(typeof(IPage), DataScopeIdentifier.Administrated, d => pages.Contains((d as IPage).Id));
                creator.AddData(typeof(IPagePlaceholderContent), DataScopeIdentifier.Public, d => pages.Contains((d as IPagePlaceholderContent).PageId));
                creator.AddData(typeof(IPagePlaceholderContent), DataScopeIdentifier.Administrated, d => pages.Contains((d as IPagePlaceholderContent).PageId));
                creator.AddData(typeof(IPageStructure), DataScopeIdentifier.Public, d => pages.Contains((d as IPageStructure).Id));
                #endregion

            }
            else if (Id == _mediasName)
            {
                creator.AddData(typeof(IMediaFileData));
                creator.AddData(typeof(IMediaFolderData));
                creator.AddFilesInDirectory(@"App_Data\Media\");
            }
            else if (Id == _datatypesName)
            {
                IEnumerable<Type> pageDataTypeInterfaces = PageFolderFacade.GetAllFolderTypes();
                IEnumerable<Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

                foreach (var pageDataType in pageDataTypeInterfaces)
                {
                    creator.AddDataTypeData(pageDataType);
                }
                foreach (var pageMetaType in pageMetaTypeInterfaces)
                {
                    creator.AddDataTypeData(pageMetaType);
                }

            }
            else if (Id == _applicationsName)
            {
                creator.AddData<IDataItemTreeAttachmentPoint>();
            }
            else if (Id == _metatypesName)
            {

                IEnumerable<Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

                foreach (var pageMetaType in pageMetaTypeInterfaces)
                {
                    creator.AddDataTypeData(pageMetaType);
                }

            }
            return;
        }
 public MetaWeblogData(string username, string password)
 {
     scope = new DataScope(DataScopeIdentifier.Administrated, DataLocalizationFacade.DefaultLocalizationCulture);
     Author = GetAuthor(username, password);
 }
 public void EndRequest(object sender, EventArgs e)
 {
     _dataScope?.Dispose();
     _dataScope = null;
 }
        private static void InsertPage(string title)
        {
            using
                (
                  Composite.Data.DataConnection connection = new Composite.Data.DataConnection()
                )
            {
                ////// *** PAGE *** //////

                // PageType Id find
                Guid pageTypeId;
                pageTypeId = connection.Get<Composite.Data.Types.IPageType>().First().Id;
                // Template Page ID find
                //Guid templateId;
                //templateId = connection.Get<IPageTemplate>().First().Id;

                // // make new website
                Guid parentId = Guid.Empty;

                // Culture = Danish
                System.Globalization.CultureInfo pageCulture;
                pageCulture = new System.Globalization.CultureInfo("en-US");
                // test markup
                string pageContentXhtml = "<h1>This is content</h1><p>Hello world!</p>";

                Composite.Data.Types.IPage page;
                page = Composite.Data.DataConnection.New<Composite.Data.Types.IPage>();

                page.Id = Guid.NewGuid();
                page.PageTypeId = Guid.NewGuid();
                page.TemplateId = Guid.NewGuid();
                page.Title = title;
                page.CultureName = pageCulture.Name;
                page.UrlTitle = "Title";
                page.MenuTitle = "Menu";
                page.Description = "Description";
                //page = page.AddPageAtBottom(parentId);

                ////// *** PLACEHOLDER *** //////

                Composite.Data.Types.IPagePlaceholderContent placeholder_content;
                placeholder_content = Composite.Data.DataConnection
                    .New<Composite.Data.Types.IPagePlaceholderContent>();

                placeholder_content.Content = pageContentXhtml;
                placeholder_content.PlaceHolderId = "contentplaceholder";
                placeholder_content.PageId = page.Id;

                using
                    (
                      Composite.Data.DataScope dataScope =
                          new Composite.Data.DataScope
                              (
                                Composite.Data.DataScopeIdentifier.Administrated
                              )
                    )
                {
                    page = connection.Add<Composite.Data.Types.IPage>(page);
                    placeholder_content =
                        connection.Add<Composite.Data.Types.IPagePlaceholderContent>
                                (
                                  placeholder_content
                                );

                    page.PublicationStatus = "published";
                    placeholder_content.PublicationStatus = "published";

                    connection.Update<Composite.Data.Types.IPage>(page);
                    connection.Update<Composite.Data.Types.IPagePlaceholderContent>(placeholder_content);
                }

            }
        }
        public string Push(
			  string datetime
			, string title
			, string article
			)
        {
            string msg =
                //"OK"
                "Date=" + datetime
                + Environment.NewLine +
                "Title=" + title
                + Environment.NewLine +
                "Article=" + article
                ;

            //context.Response.Write(functionResult.ToString());

            using
                (
                  Composite.Data.DataConnection connection = new Composite.Data.DataConnection()
                )
            {
                ////// *** PAGE *** //////

                // PageType Id find
                Guid pageTypeId;
                pageTypeId = connection.Get<Composite.Data.Types.IPageType>().First().Id;

                // Template Page ID find
                //Guid templateId;
                // templateId = connection.Get<Composite.Core.PageTemplates.IPageTemplate>().First().Id;

                // // make new website
                Guid parentId = Guid.Empty;

                // Culture = Danish
                System.Globalization.CultureInfo pageCulture;
                pageCulture = new System.Globalization.CultureInfo("en-US");
                // test markup
                string pageContentXhtml = "<h1>This is content</h1><p>Hello world!</p>";

                Composite.Data.Types.IPage page;
                page = Composite.Data.DataConnection.New<Composite.Data.Types.IPage>();

                page.Id = Guid.NewGuid();
                page.PageTypeId = Guid.NewGuid();
                page.TemplateId = Guid.NewGuid();
                page.Title = title;
                page.CultureName = pageCulture.Name;
                page.UrlTitle = "Title";
                page.MenuTitle = "Menu";
                page.Description = "Description";
                //page = page.AddPageAtBottom(parentId);

                ////// *** PLACEHOLDER *** //////

                Composite.Data.Types.IPagePlaceholderContent placeholder_content;
                placeholder_content = Composite.Data.DataConnection
                    .New<Composite.Data.Types.IPagePlaceholderContent>();

                placeholder_content.Content = pageContentXhtml;
                placeholder_content.PlaceHolderId = "contentplaceholder";
                placeholder_content.PageId = page.Id;

                using
                    (
                      Composite.Data.DataScope dataScope =
                          new Composite.Data.DataScope
                              (
                                Composite.Data.DataScopeIdentifier.Administrated
                              )
                    )
                {
                    page = connection.Add<Composite.Data.Types.IPage>(page);
                    placeholder_content =
                        connection.Add<Composite.Data.Types.IPagePlaceholderContent>
                                (
                                  placeholder_content
                                );

                    page.PublicationStatus = "published";
                    placeholder_content.PublicationStatus = "published";

                    connection.Update<Composite.Data.Types.IPage>(page);
                    connection.Update<Composite.Data.Types.IPagePlaceholderContent>(placeholder_content);
                }

            }

            return msg;
        }
        private void undoCodeActivity_Undo_ExecuteCode(object sender, EventArgs e)
        {
            DataEntityToken dataEntityToken = (DataEntityToken)this.EntityToken;

            List<string> propertyNamesToIgnore = new List<string> { "PublicationStatus" };

            using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope())
            {
                IPage administrativePage = (IPage)dataEntityToken.Data;
                IPage publicPage = DataFacade.GetDataFromOtherScope<IPage>(administrativePage, DataScopeIdentifier.Public).Single();

                List<IData> administrativeCompositions = administrativePage.GetMetaData(DataScopeIdentifier.Administrated).ToList();
                List<IData> publicCompositions = publicPage.GetMetaData(DataScopeIdentifier.Public).ToList();

                List<IPagePlaceholderContent> administrativePlaceholders;
                using (DataScope dataScope = new DataScope(DataScopeIdentifier.Administrated))
                {
                    administrativePlaceholders =
                        (from ph in DataFacade.GetData<IPagePlaceholderContent>()
                         where ph.PageId == administrativePage.Id
                         select ph).ToList();
                }

                List<IPagePlaceholderContent> publicPlaceholders;
                using (DataScope dataScope = new DataScope(DataScopeIdentifier.Public))
                {
                    publicPlaceholders =
                        (from ph in DataFacade.GetData<IPagePlaceholderContent>()
                         where ph.PageId == publicPage.Id
                         select ph).ToList();
                }

                using (ProcessControllerFacade.NoProcessControllers)
                {
                    publicPage.FullCopyChangedTo(administrativePage, propertyNamesToIgnore);
                    DataFacade.Update(administrativePage);

                    foreach (IData publicComposition in publicCompositions)
                    {
                        IData administrativeComposition =
                            (from com in administrativeCompositions
                             where com.DataSourceId.DataId.CompareTo(publicComposition.DataSourceId.DataId, false) 
                             select com).Single();

                        publicComposition.FullCopyChangedTo(administrativeComposition, propertyNamesToIgnore);
                        DataFacade.Update(administrativeComposition);
                    }

                    foreach (IPagePlaceholderContent publicPagePlaceholderContent in publicPlaceholders)
                    {
                        IPagePlaceholderContent administrativePagePlaceholderContent =
                            (from pc in administrativePlaceholders
                             where pc.PlaceHolderId == publicPagePlaceholderContent.PlaceHolderId
                             select pc).Single();

                        publicPagePlaceholderContent.FullCopyChangedTo(administrativePagePlaceholderContent, propertyNamesToIgnore);
                        DataFacade.Update(administrativePagePlaceholderContent);
                    }
                }

                transactionScope.Complete();
            }
        }