public PageJavaScriptProjection Create(IPage page)
        {
            IJavaScriptAccessor jsAccessor = null;
            Type pageType;
            if (page is IProxy)
            {
                pageType = page.GetType().BaseType;
            }
            else
            {
                pageType = page.GetType();
            }

            string key = "JAVASCRIPTRENDERER-" + pageType.Name.ToUpperInvariant();

            if (containerProvider.CurrentScope.IsRegisteredWithKey<IJavaScriptAccessor>(key))
            {
                jsAccessor = containerProvider.CurrentScope
                    .ResolveKeyed<IJavaScriptAccessor>(key, new Parameter[]
                                                             {
                                                                 new PositionalParameter(0, page)
                                                             });
            }

            if (jsAccessor == null)
            {
                throw new CmsException(string.Format("No page javascript accessor was found for the page type {0}.", pageType.FullName));
            }

            var jsProjection = new PageJavaScriptProjection(page, jsAccessor);
            return jsProjection;
        }
        /// <summary>
        /// Extends rendering page view model with the blog post data.
        /// </summary>
        /// <param name="viewModel">The rendering page view model.</param>
        /// <param name="page">The page.</param>
        public static void ExtendWithBlogData(this RenderPageViewModel viewModel, IPage page)
        {
            var blogPost = page as BlogPost;
            if (blogPost != null)
            {
                if (viewModel.Bag.BlogPostData == null)
                {
                    viewModel.Bag.BlogPostData = new DynamicDictionary();
                }

                var blogPostProjection = viewModel.Contents.FirstOrDefault(projection => projection.Content.GetType() == typeof(BlogPostContent));
                if (blogPostProjection != null)
                {
                    var content = blogPostProjection.Content as BlogPostContent;
                    if (content != null)
                    {
                        viewModel.Bag.BlogPostData.Status = content.Status;
                        viewModel.Bag.BlogPostData.ActivationDate = content.ActivationDate;
                        viewModel.Bag.BlogPostData.ExpirationDate = content.ExpirationDate;
                    }
                }

                if (blogPost.Author != null)
                {
                    viewModel.Bag.BlogPostData.AuthorId = blogPost.Author.Id;
                    viewModel.Bag.BlogPostData.AuthorName = blogPost.Author.Name;
                }
            }
        }
Exemplo n.º 3
0
        internal PageNode(IPage page, SitemapNavigatorImplementation sitemapNavigator)
        {
            Verify.ArgumentNotNull(page, "page");

            _page = page;
            _sitemapNavigator = sitemapNavigator;
        }
 public NuevoGrupoViewModel(INavigator navigator, IServicioDatos servicioDatos, Session session, IPage page) : base(navigator, servicioDatos, session, page)
 {
     _grupo = new GrupoModel();
     CmdAgregar = new Command(Agregar);
     CmdAgregarImagen = new Command(AgregarImagen);
     MessagingCenter.Send(this, "Hola");
 }
Exemplo n.º 5
0
            public void CreatePageStructure(IPage page, Guid parentPageId)
            {
                if (DataFacade.GetData<IPageStructure>(f => f.Id == page.Id).Any())
                    return;

                PageServices.InsertIntoPositionInternal(page.Id, parentPageId, 0);
            }
Exemplo n.º 6
0
 public MainViewModel(INavigator navigator, IServicioMovil servicio, Session session,IPage page) : base(navigator, servicio, session,page)
 {
     CmdAddContact=new Command(Contactos);
     CmdRecibidos=new Command(Mensajes);
     CmdEnviados=new Command(MensajesEnviados);
     CmdOut=new Command(Logout);
 }
Exemplo n.º 7
0
 private static string GetCacheKey(IPage page)
 {
     var dataSourceId = page.DataSourceId;
     string localizationInfo = dataSourceId.LocaleScope.ToString();
     string dataScope = dataSourceId.DataScopeIdentifier.Name;
     return page.Id + dataScope + localizationInfo;
 }
        public bool TryFindPage(string Url, out IPage page)
        {
            var serializer = new XmlSerializer(typeof(Page));

            page = null;
            //Create WCF Client
            using (var client = new TridionBrokerServiceClient())
            {
                //Create XML Document to hold Xml returned from WCF Client
                var pageContent = new XmlDocument();
                pageContent.LoadXml(client.FindPageByUrl(PublicationId, Url));

                //Load XML into Reader for deserialization
                using (var reader = new XmlNodeReader(pageContent.DocumentElement))
                {
                    try
                    {
                        page = (IPage)serializer.Deserialize(reader);
                        LoadComponentModelsFromComponentFactory(page);
                        return true;
                    }
                    catch (Exception)
                    {
                        //return false;
                        //throw new FieldHasNoValueException();
                    }
                }
            }

            return false;
        }
Exemplo n.º 9
0
 ///   <summary>
 ///   Currently used by the image server
 ///   to get thumbnails that are used in the add page dialog. Since this dialog can show
 ///   an enlarged version of the page, we generate these at a higher resolution than usual.
 ///   Also, to make more realistic views of template pages we insert fake text wherever
 ///   there is an empty edit block.
 ///
 ///   The result is cached for possible future use so the caller should not dispose of it.
 ///   </summary>
 /// <param name="book"></param>
 /// <param name="page"></param>
 ///  <param name="isLandscape"></param>
 ///  <returns></returns>
 public Image GetThumbnailForPage(Book.Book book, IPage page, bool isLandscape)
 {
     var pageDom = book.GetThumbnailXmlDocumentForPage(page);
     var thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
     {
         BackgroundColor = Color.White,// matches the hand-made previews.
         BorderStyle = HtmlThumbNailer.ThumbnailOptions.BorderStyles.None, // allows the HTML to add its preferred border in the larger preview
         CenterImageUsingTransparentPadding = true
     };
     var pageDiv = pageDom.RawDom.SafeSelectNodes("descendant-or-self::div[contains(@class,'bloom-page')]").Cast<XmlElement>().FirstOrDefault();
     // The actual page size is rather arbitrary, but we want the right ratio for A4.
     // Using the actual A4 sizes in mm makes a big enough image to look good in the larger
     // preview box on the right as well as giving exactly the ratio we want.
     // We need to make the image the right shape to avoid some sort of shadow/box effects
     // that I can't otherwise find a way to get rid of.
     if (isLandscape)
     {
         thumbnailOptions.Width = 297;
         thumbnailOptions.Height = 210;
         pageDiv.SetAttribute("class", pageDiv.Attributes["class"].Value.Replace("Portrait", "Landscape"));
     }
     else
     {
         thumbnailOptions.Width = 210;
         thumbnailOptions.Height = 297;
         // On the offchance someone makes a template with by-default-landscape pages...
         pageDiv.SetAttribute("class", pageDiv.Attributes["class"].Value.Replace("Landscape", "Portrait"));
     }
     // In different books (or even the same one) in the same session we may have portrait and landscape
     // versions of the same template page. So we must use different IDs.
     return _thumbnailProvider.GetThumbnail(page.Id + (isLandscape ? "L" : ""), pageDom, thumbnailOptions);
 }
Exemplo n.º 10
0
 public GeneralViewModel(INavigator navigator, 
     IServicioMovil servicio,IPage page)
 {
     _navigator = navigator;
     _servicio = servicio;
     _page = page;
 }
Exemplo n.º 11
0
 public PageCopyAndConnectJob(IPage page, ILinkElement linkElement, PageCopyAndConnectFlags flags)
     : base(page.Project)
 {
     PageToCopy = page;
     ConnectionTarget = linkElement;
     _flags = flags;
 }
Exemplo n.º 12
0
 public GeneralViewModel(INavigator navigator, IServicioDatos servicio, Session session, IPage page)
 {
     _navigator = navigator;
     _servicio = servicio;
     _page = page;
     Session = session;
 }
        public void QueueWrite(IPage pageToWrite, ulong transactionId)
        {
#if DEBUG_PAGESTORE
            Logging.LogDebug("Queue {0}", pageToWrite.Id);
#endif
            _writeTasks.Enqueue(new WriteTask{PageToWrite = pageToWrite, TransactionId = transactionId});
        }
Exemplo n.º 14
0
 public LoginViewModel(INavigator navigator, IServicioMovil servicio, IPage page) :
                       base(navigator, servicio, page)
 {
     Usuario = new UsuarioModel();
     cmdLogin = new Command(RunLogin);
     cmdAlta = new Command(RunAlta);
 }
		public override async Task OnAppearing (IPage CurrentPage)
		{
			await base.OnAppearing (CurrentPage);
			await Task.Delay (2000);
			CurrentPage.HideAll ();
			this.IsFirstLoad = false;
		}
        public MvcHtmlString ComponentPresentations(IPage tridionPage, HtmlHelper htmlHelper, string[] includeComponentTemplate, string includeSchema)
        {
            LoggerService.Information(">>ComponentPresentations", LoggingCategory.Performance);
            StringBuilder sb = new StringBuilder();
            foreach (IComponentPresentation cp in tridionPage.ComponentPresentations)
            {
                if (includeComponentTemplate != null && !MustInclude(cp.ComponentTemplate, includeComponentTemplate))
                    continue;
                if (cp.Component != null && (!string.IsNullOrEmpty(includeSchema)) && !MustInclude(cp.Component.Schema, includeSchema))
                    continue;
                // Quirijn: if a component presentation was created by a non-DD4T template, its output was stored in RenderedContent
                // In that case, we simply write it out
                // Note that this type of component presentations cannot be excluded based on schema, because we do not know the schema
                if (!string.IsNullOrEmpty(cp.RenderedContent))
                    return new MvcHtmlString(cp.RenderedContent);
                LoggerService.Debug("rendering cp {0} - {1}", LoggingCategory.Performance, cp.Component.Id, cp.ComponentTemplate.Id);
               
                cp.Page = tridionPage;
                LoggerService.Debug("about to call RenderComponentPresentation", LoggingCategory.Performance);
                if (ShowAnchors)
                    sb.Append(string.Format("<a id=\"{0}\"></a>", DD4T.Utils.TridionHelper.GetLocalAnchor(cp)));
                sb.Append(RenderComponentPresentation(cp, htmlHelper));
                LoggerService.Debug("finished calling RenderComponentPresentation", LoggingCategory.Performance);

            }
            LoggerService.Information("<<ComponentPresentations", LoggingCategory.Performance);
            return MvcHtmlString.Create(sb.ToString());
        }
		public virtual async Task OnAppearing(IPage CurrentPage)
		{
			if (this.CurrentPage == null || CurrentPage.GetType () != this.CurrentPage.GetType ()) {
				this.SetCurrentPage = CurrentPage;
			}

		}
Exemplo n.º 18
0
 private string FacetKeywords(IPage model)
 {
     Action<KeyValuePair<string, IField>> action = null;
     StringBuilder facetKeywords = new StringBuilder();
     if (model.ComponentPresentations.Count > 0)
     {
         IComponent component = model.ComponentPresentations[0].Component;
         if (component.MetadataFields.ContainsKey("facets"))
         {
             IComponent component2 = component.MetadataFields["facets"].LinkedComponentValues[0];
             if (component2.Fields.Count > 0)
             {
                 facetKeywords.Append(" - ");
             }
             if (action == null)
             {
                 action = delegate (KeyValuePair<string, IField> f) {
                     f.Value.Keywords.ToList<IKeyword>().ForEach(delegate (IKeyword k) {
                         if (!string.IsNullOrEmpty(k.Description))
                         {
                             facetKeywords.AppendFormat("{0}, ", k.Description);
                         }
                     });
                 };
             }
             component2.Fields.ToList<KeyValuePair<string, IField>>().ForEach(action);
         }
     }
     return facetKeywords.ToString();
 }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderPageViewModel" /> class.
        /// </summary>
        /// <param name="page">The page.</param>
        public RenderPageViewModel(IPage page) : this()
        {
            var rootPage = page as Page;

            Id = page.Id;
            IsDeleted = page.IsDeleted;
            Version = page.Version;
            HasSEO = page.HasSEO;
            Title = page.Title;
            MetaTitle = rootPage != null && !string.IsNullOrEmpty(rootPage.MetaTitle) ? rootPage.MetaTitle : Title;
            MetaDescription = rootPage != null ? rootPage.MetaDescription : null;
            MetaKeywords = rootPage != null ? rootPage.MetaKeywords : null;
            PageUrl = page.PageUrl;
            Status = page.Status;
            CreatedOn = page.CreatedOn;
            CreatedByUser = page.CreatedByUser;
            ModifiedOn = page.ModifiedOn;
            ModifiedByUser = page.ModifiedByUser;
            IsMasterPage = page.IsMasterPage;
            ForceAccessProtocol = page.ForceAccessProtocol;

            if (rootPage != null && rootPage.Language != null)
            {
                LanguageCode = rootPage.Language.Code;
            }

            PageData = page;
        }
 /// <summary>
 /// Pages the selected.
 /// </summary>
 /// <param name="page">
 /// The <c>page</c>.
 /// </param>
 private void PageSelected(IPage page)
 {
     if (page != null)
     {
         ShowPage(page);
     }
 }
Exemplo n.º 21
0
 public PagingParams(IPage url)
 {
     PageNumber = url.PageNumber ?? 1;
     PageSize = url.PageSize ?? 50;
     SortColumn = url.SortColumn;
     SortOrder = string.IsNullOrWhiteSpace(url.SortOrder) ? "asc" : url.SortOrder;
 }
 public NuevaTareaViewModel(INavigator navigator, IServicioDatos servicioDatos, Session session, IPage page) : base(navigator, servicioDatos, session, page)
 {
     _tarea = new TareaModel();
     CmdAgregar = new Command(Agregar);
     CmdAgregarUbicacion = new Command(AgregarUbicacion);
     CmdAgregarImagen = new Command(AgregarImagen);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Renders an action projection to given html output.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="securityService"></param>
        /// <param name="html">The html helper.</param>
        /// <returns><c>true</c> on success, otherwise <c>false</c>.</returns>
        public override bool Render(IPage page, ISecurityService securityService, HtmlHelper html)
        {
            if (AccessRole != null && !securityService.IsAuthorized(AccessRole))
            {
                return false;
            }

            using (HtmlControlRenderer control = new HtmlControlRenderer(Tag))
            {
                OnPreRender(control, page, html);

                using (HtmlTextWriter writer = new HtmlTextWriter(html.ViewContext.Writer))
                {
                    control.RenderBeginTag(writer);
                    
                    if (ChildProjections != null)
                    {
                        foreach (var htmlElementProjection in ChildProjections.OrderBy(f => f.Order))
                        {
                            htmlElementProjection.Render(page, securityService, html);
                        }
                    }

                    control.RenderEndTag(writer);
                }
            }

            return true;
        }
Exemplo n.º 24
0
        static void BuildPage(IPage page, XmlNode parent, XmlDocument doc)
        {
            XmlNode pagenode = doc.CreateElement("page");
            parent.AppendChild(pagenode);

            XmlNode titlenode = doc.CreateElement("title");
            titlenode.AppendChild(doc.CreateTextNode(page.Title));
            pagenode.AppendChild(titlenode);

            XmlNode textnode = doc.CreateElement("text");
            textnode.AppendChild(doc.CreateTextNode(page.Text));
            pagenode.AppendChild(textnode);

            XmlNode iconnode = doc.CreateElement("icon");
            iconnode.AppendChild(doc.CreateTextNode(page.Icon));
            pagenode.AppendChild(iconnode);

            XmlNode rendermodenode = doc.CreateElement("rendermode");
            rendermodenode.AppendChild(doc.CreateTextNode(page.RenderMode));
            pagenode.AppendChild(rendermodenode);

            XmlNode itemsnode = doc.CreateElement("items");
            pagenode.AppendChild(itemsnode);

            for (int j = 0; j < page.Items.Count; j++)
                BuildIItem(page, doc, itemsnode, page.Items[j], "item");

            XmlNode actionsnode = doc.CreateElement("actions");
            pagenode.AppendChild(actionsnode);

            for (int j = 0; j < page.Actions.Count; j++)
                BuildIItem(page, doc, actionsnode, page.Actions[j], "action");
        }
Exemplo n.º 25
0
 public void ChangePage(IPage page)
 {
     if (token != null)
         CurrentPage = page;
     else
         CurrentPage = new LoginVM();
 }
Exemplo n.º 26
0
        public ControlConsole(ContentManager Content)
        {
            this.Texture = Content.Load<Texture2D>("Main");
            this.overlay = Content.Load<Texture2D>("SlotBG");
            name = "Mainframe";
            activePage = this;

            temp = new CriticalStat("Temp", 60, -0.001F, new Vector2(178, 246), Content.Load<SpriteFont>("MS Quartz"));
            dist = new CriticalStat("Distance", 1000000, 1, Vector2.Zero, Content.Load<SpriteFont>("MS Quartz"));

            power = new PowerBoard(Content);
            vent = new VentBoard(Content);
                DebugMode.vBoard = vent;
            o2 = new O2Board(Content);
                DebugMode.oBoard = o2;
            man = new Manual(Content);
            term = new Terminal(Content.Load<SpriteFont>("TerminalFont"),
                Content.Load<Texture2D>("CompCons"), Content.Load<Texture2D>("Darkness"), o2, ">>");

            allPages = new Dictionary<Rectangle, IPage>();
            allPages.Add(powerRect, power);
            allPages.Add(ventRect, vent);
            allPages.Add(lmcRect, term);
            allPages.Add(o2Rect, o2);
            allPages.Add(manRect, man);
        }
        public PageStylesheetProjection Create(IPage page, IEnumerable<IOptionValue> options)
        {
            IStylesheetAccessor jsAccessor = null;
            Type pageType;
            if (page is IProxy)
            {
                pageType = page.GetType().BaseType;
            }
            else
            {
                pageType = page.GetType();
            }

            string key = "STYLESHEETRENDERER-" + pageType.Name.ToUpperInvariant();

            if (containerProvider.CurrentScope.IsRegisteredWithKey<IStylesheetAccessor>(key))
            {
                jsAccessor = containerProvider.CurrentScope
                    .ResolveKeyed<IStylesheetAccessor>(key, new Parameter[]
                                                             {
                                                                 new PositionalParameter(0, page),
                                                                 new PositionalParameter(1, options)
                                                             });
            }

            if (jsAccessor == null)
            {
                throw new CmsException(string.Format("No page style sheet accessor was found for the page type {0}.", pageType.FullName));
            }

            var jsProjection = new PageStylesheetProjection(page, jsAccessor);
            return jsProjection;
        }
Exemplo n.º 28
0
 public static string BuildPage(IPage page)
 {
     XmlDocument doc = new XmlDocument();
     XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
     doc.AppendChild(decl);
     BuildPageTo(page, doc, doc);
     return doc.OuterXml;
 }
Exemplo n.º 29
0
        public TabPage(IPage content)
        {
            Init();

            PageContent = content;
            PageContent.Opening();
            PageContent.Opened();
        }
Exemplo n.º 30
0
 public PrincipalViewModel(INavigator navigator, IServicioMovil servicio, IPage page,
                           IComponentContext ctx) : base(navigator, servicio, page)
 {
     Context = ctx;
     CmdContactos = new Command(RunContactos);
     CmdMensajes = new Command(RunMensajes);
     CmdSalir = new Command(RunSalir);
 }
Exemplo n.º 31
0
        private void ValidateExternalSecuritySolutions(IPage <ExternalSecuritySolution> externalSecuritySolutionPage)
        {
            Assert.True(externalSecuritySolutionPage.IsAny());

            externalSecuritySolutionPage.ForEach(ValidateExternalSecuritySolution);
        }
Exemplo n.º 32
0
 protected WebTableBase(IPage parent)
     : base(parent)
 {
 }
Exemplo n.º 33
0
 public ProductAttachmentFacade(IPage page)
 {
     viewPage   = page;
     restClient = new RestClient(ServiceBaseUrl, page);
 }
Exemplo n.º 34
0
 private void TriggerOnPageRebuild(IPage page)
 {
     onListRebuild?.Invoke(page);
 }
        private bool PrepareAddUpdateMetaData(IPage selectedPage, IDictionary <string, IData> dataToAdd, IDictionary <string, IData> dataToUpdate)
        {
            var isValid = ValidateBindings();

            IEnumerable <IPageMetaDataDefinition> pageMetaDataDefinitions = selectedPage.GetAllowedMetaDataDefinitions().Evaluate();

            foreach (var pageMetaDataDefinition in pageMetaDataDefinitions)
            {
                var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(pageMetaDataDefinition.MetaDataTypeId);
                var metaDataType       = TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName);

                var helper = CreateDataTypeDescriptorFormsHelper(pageMetaDataDefinition, dataTypeDescriptor);

                var metaData = selectedPage.GetMetaData(pageMetaDataDefinition.Name, metaDataType);
                if (metaData == null)
                {
                    var newData = DataFacade.BuildNew(metaDataType);

                    PageMetaDataFacade.AssignMetaDataSpecificValues(newData, pageMetaDataDefinition.Name, selectedPage);

                    var localizedData = newData as ILocalizedControlled;
                    if (localizedData != null)
                    {
                        localizedData.SourceCultureName = UserSettings.ActiveLocaleCultureInfo.Name;
                    }

                    if (!BindAndValidate(helper, newData))
                    {
                        isValid = false;
                    }

                    dataToAdd.Add(helper.BindingNamesPrefix, newData);
                }
                else
                {
                    if (!BindAndValidate(helper, metaData))
                    {
                        isValid = false;
                    }

                    dataToUpdate.Add(helper.BindingNamesPrefix, metaData);
                }
            }


            var pageValidationResults = ValidationFacade.Validate(selectedPage);

            if (!pageValidationResults.IsValid)
            {
                isValid = false;
            }


            foreach (var kvp in dataToAdd.Concat(dataToUpdate))
            {
                var validationResults = ValidationFacade.Validate(kvp.Value);

                if (!validationResults.IsValid)
                {
                    isValid = false;

                    foreach (var result in validationResults)
                    {
                        ShowFieldMessage(DataTypeDescriptorFormsHelper.GetBindingName(kvp.Key, result.Key), result.Message);
                    }
                }
            }

            return(isValid);
        }
Exemplo n.º 36
0
        private static void RunApplication(ConfigWrapper config)
        {
            client = CreateMediaServicesClient(config);
            // Set the polling interval for long running operations to 2 seconds.
            // The default value is 30 seconds for the .NET client SDK
            client.LongRunningOperationRetryTimeout = 2;

            List <string> assetNameList = new List <string>();

            Console.WriteLine("Building a list of assets...");

            // Get a list of all of the assets and enumerate through them a page at a time.
            IPage <Asset> assetPage = client.Assets.List(config.ResourceGroup, config.AccountName);
            bool          breakout;

            do
            {
                foreach (Asset asset in assetPage)
                {
                    // Add each asset name to a list
                    assetNameList.Add(asset.Name);
                }
                if (assetPage.NextPageLink != null)
                {
                    assetPage = client.Assets.ListNext(assetPage.NextPageLink);
                    breakout  = false;
                }
                else
                {
                    breakout = true;
                }
            }while (!breakout);

            // We delete in a separate for loop because deleting within the do loop changes the size of the loop itself.
            bool always = false;

            for (int i = 0; i < assetNameList.Count; i++)
            {
                if (!always)
                {
                    Console.WriteLine("Delete the asset '{0}'?  (y)es, (n)o, (a)ll assets, (q)uit", assetNameList[i]);
                    ConsoleKeyInfo response = Console.ReadKey();
                    Console.WriteLine();
                    string responseChar = response.Key.ToString();

                    if (responseChar.Equals("N"))
                    {
                        continue;
                    }
                    if (responseChar.Equals("A"))
                    {
                        always = true;
                    }
                    else if (!(responseChar.Equals("Y")))
                    {
                        break; // At this point anything other than a 'yes' should quit the loop/application.
                    }
                }
                Console.WriteLine("Deleting {0}", assetNameList[i]);
                client.Assets.Delete(config.ResourceGroup, config.AccountName, assetNameList[i]);
            }
        }
        public void TopicCreateGetUpdateDelete()
        {
            using (MockContext context = MockContext.Start(this.GetType()))
            {
                this.InitializeClients(context);

                var location = this.ResourceManagementClient.GetLocationFromProvider();

                var resourceGroup = this.ResourceManagementClient.TryGetResourceGroup(location);
                if (string.IsNullOrWhiteSpace(resourceGroup))
                {
                    resourceGroup = TestUtilities.GenerateName(EventGridManagementHelper.ResourceGroupPrefix);
                    this.ResourceManagementClient.TryRegisterResourceGroup(location, resourceGroup);
                }

                var topicName = TestUtilities.GenerateName(EventGridManagementHelper.TopicPrefix);

                // Temporarily commenting this out as this is not yet enabled for the new API version
                // var operationsResponse = this.EventGridManagementClient.Operations.List();

                var originalTagsDictionary = new Dictionary <string, string>()
                {
                    { "originalTag1", "originalValue1" },
                    { "originalTag2", "originalValue2" }
                };

                Topic topic = new Topic()
                {
                    Location           = location,
                    Tags               = originalTagsDictionary,
                    InputSchema        = InputSchema.CustomEventSchema,
                    InputSchemaMapping = new JsonInputSchemaMapping()
                    {
                        Subject     = new JsonFieldWithDefault("mySubjectField"),
                        Topic       = new JsonField("myTopicField"),
                        DataVersion = new JsonFieldWithDefault(sourceField: null, defaultValue: "2"),
                        EventType   = new JsonFieldWithDefault("MyEventTypeField"),
                        EventTime   = new JsonField("MyEventTimeField"),
                        Id          = new JsonField("MyIDFIELD")
                    }
                };

                var createTopicResponse = this.EventGridManagementClient.Topics.CreateOrUpdateAsync(resourceGroup, topicName, topic).Result;

                Assert.NotNull(createTopicResponse);
                Assert.Equal(createTopicResponse.Name, topicName);

                TestUtilities.Wait(TimeSpan.FromSeconds(5));

                // Get the created topic
                var getTopicResponse = this.EventGridManagementClient.Topics.Get(resourceGroup, topicName);
                if (string.Compare(getTopicResponse.ProvisioningState, "Succeeded", true) != 0)
                {
                    TestUtilities.Wait(TimeSpan.FromSeconds(5));
                }

                getTopicResponse = this.EventGridManagementClient.Topics.Get(resourceGroup, topicName);
                Assert.NotNull(getTopicResponse);
                Assert.Equal("Succeeded", getTopicResponse.ProvisioningState, StringComparer.CurrentCultureIgnoreCase);
                Assert.Equal(location, getTopicResponse.Location, StringComparer.CurrentCultureIgnoreCase);
                Assert.Contains(getTopicResponse.Tags, tag => tag.Key == "originalTag1");

                // Get all topics created within a resourceGroup
                IPage <Topic> topicsInResourceGroupPage = this.EventGridManagementClient.Topics.ListByResourceGroupAsync(resourceGroup).Result;
                var           topicsInResourceGroupList = new List <Topic>();
                if (topicsInResourceGroupPage.Any())
                {
                    topicsInResourceGroupList.AddRange(topicsInResourceGroupPage);
                    var nextLink = topicsInResourceGroupPage.NextPageLink;
                    while (nextLink != null)
                    {
                        topicsInResourceGroupPage = this.EventGridManagementClient.Topics.ListByResourceGroupNextAsync(nextLink).Result;
                        topicsInResourceGroupList.AddRange(topicsInResourceGroupPage);
                        nextLink = topicsInResourceGroupPage.NextPageLink;
                    }
                }

                Assert.NotNull(topicsInResourceGroupList);
                Assert.True(topicsInResourceGroupList.Count() >= 1);
                Assert.Contains(topicsInResourceGroupList, t => t.Name == topicName);
                Assert.True(topicsInResourceGroupList.All(ns => ns.Id.Contains(resourceGroup)));

                IPage <Topic> topicsInResourceGroupPageWithTop = this.EventGridManagementClient.Topics.ListByResourceGroupAsync(resourceGroup, null, 5).Result;
                var           topicsInResourceGroupListWithTop = new List <Topic>();
                if (topicsInResourceGroupPageWithTop.Any())
                {
                    topicsInResourceGroupListWithTop.AddRange(topicsInResourceGroupPageWithTop);
                    var nextLink = topicsInResourceGroupPageWithTop.NextPageLink;
                    while (nextLink != null)
                    {
                        topicsInResourceGroupPageWithTop = this.EventGridManagementClient.Topics.ListByResourceGroupNextAsync(nextLink).Result;
                        topicsInResourceGroupListWithTop.AddRange(topicsInResourceGroupPageWithTop);
                        nextLink = topicsInResourceGroupPageWithTop.NextPageLink;
                    }
                }

                Assert.NotNull(topicsInResourceGroupListWithTop);
                Assert.True(topicsInResourceGroupListWithTop.Count() >= 1);
                Assert.Contains(topicsInResourceGroupListWithTop, t => t.Name == topicName);
                Assert.True(topicsInResourceGroupListWithTop.All(ns => ns.Id.Contains(resourceGroup)));

                // Get all topics created within the subscription irrespective of the resourceGroup
                IPage <Topic> topicsInAzureSubscription     = this.EventGridManagementClient.Topics.ListBySubscriptionAsync(null, 100).Result;
                var           topicsInAzureSubscriptionList = new List <Topic>();
                if (topicsInAzureSubscription.Any())
                {
                    topicsInAzureSubscriptionList.AddRange(topicsInAzureSubscription);
                    var nextLink = topicsInAzureSubscription.NextPageLink;
                    while (nextLink != null)
                    {
                        try
                        {
                            topicsInAzureSubscription = this.EventGridManagementClient.Topics.ListBySubscriptionNextAsync(nextLink).Result;
                            topicsInAzureSubscriptionList.AddRange(topicsInAzureSubscription);
                            nextLink = topicsInAzureSubscription.NextPageLink;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                            break;
                        }
                    }
                }

                Assert.NotNull(topicsInAzureSubscriptionList);
                Assert.True(topicsInAzureSubscriptionList.Count() >= 1);
                Assert.Contains(topicsInAzureSubscriptionList, t => t.Name == topicName);

                var replaceTopicTagsDictionary = new Dictionary <string, string>()
                {
                    { "replacedTag1", "replacedValue1" },
                    { "replacedTag2", "replacedValue2" }
                };

                // Replace the topic
                topic.Tags = replaceTopicTagsDictionary;
                var replaceTopicResponse = this.EventGridManagementClient.Topics.CreateOrUpdateAsync(resourceGroup, topicName, topic).Result;

                Assert.Contains(replaceTopicResponse.Tags, tag => tag.Key == "replacedTag1");
                Assert.DoesNotContain(replaceTopicResponse.Tags, tag => tag.Key == "originalTag1");

                // Update the topic
                var updateTopicTagsDictionary = new Dictionary <string, string>()
                {
                    { "updatedTag1", "updatedValue1" },
                    { "updatedTag2", "updatedValue2" }
                };

                var updateTopicResponse = this.EventGridManagementClient.Topics.UpdateAsync(resourceGroup, topicName, updateTopicTagsDictionary).Result;
                Assert.Contains(updateTopicResponse.Tags, tag => tag.Key == "updatedTag1");
                Assert.DoesNotContain(updateTopicResponse.Tags, tag => tag.Key == "replacedTag1");

                // Delete topic
                this.EventGridManagementClient.Topics.DeleteAsync(resourceGroup, topicName).Wait();
            }
        }
        private List <DeploymentOperation> GetNewOperations(List <DeploymentOperation> old, IPage <DeploymentOperation> current)
        {
            List <DeploymentOperation> newOperations = new List <DeploymentOperation>();

            foreach (DeploymentOperation operation in current)
            {
                DeploymentOperation operationWithSameIdAndProvisioningState = old.Find(o => o.OperationId.Equals(operation.OperationId) && o.Properties.ProvisioningState.Equals(operation.Properties.ProvisioningState));
                if (operationWithSameIdAndProvisioningState == null)
                {
                    newOperations.Add(operation);
                }

                //If nested deployment, get the operations under those deployments as well
                if (operation.Properties.TargetResource != null && operation.Properties.TargetResource.ResourceType.Equals(Constants.MicrosoftResourcesDeploymentType, StringComparison.OrdinalIgnoreCase))
                {
                    HttpStatusCode statusCode;
                    Enum.TryParse <HttpStatusCode>(operation.Properties.StatusCode, out statusCode);
                    if (!statusCode.IsClientFailureRequest())
                    {
                        var resourceGroupName = ResourceIdUtility.GetResourceGroupName(operation.Properties.TargetResource.Id);
                        var deploymentName    = operation.Properties.TargetResource.ResourceName;

                        if (this.CheckDeploymentExistence(resourceGroupName, deploymentName) == true)
                        {
                            List <DeploymentOperation> newNestedOperations = new List <DeploymentOperation>();

                            var result = this.ListDeploymentOperations(resourceGroupName, deploymentName);

                            newNestedOperations = GetNewOperations(operations, result);

                            foreach (DeploymentOperation op in newNestedOperations)
                            {
                                DeploymentOperation nestedOperationWithSameIdAndProvisioningState = newOperations.Find(o => o.OperationId.Equals(op.OperationId) && o.Properties.ProvisioningState.Equals(op.Properties.ProvisioningState));

                                if (nestedOperationWithSameIdAndProvisioningState == null)
                                {
                                    newOperations.Add(op);
                                }
                            }
                        }
                    }
                }
            }

            return(newOperations);
        }
 public override async Task OnAppearing(IPage CurrentPage)
 {
     await base.OnAppearing(CurrentPage);
 }
Exemplo n.º 40
0
 private void ValidateWorkflowList1(IPage <Workflow> result)
 {
     Assert.Single(result);
     this.ValidateWorkflow1(result.First());
     Assert.Equal("http://workflowlist1nextlink", result.NextPageLink);
 }
Exemplo n.º 41
0
        // Make sure proximityPlacementGroup across resource groups are listed successfully and proximityPlacementGroups in a resource groups are listed successfully
        private void VerifyListProximityPlacementGroups()
        {
            string resourceGroup2Name = m_baseResourceGroupName + "_2";
            string baseInputProximityPlacementGroupName = ComputeManagementTestUtilities.GenerateName("testppg");
            string proximityPlacementGroup1Name         = baseInputProximityPlacementGroupName + "_1";
            string proximityPlacementGroup2Name         = baseInputProximityPlacementGroupName + "_2";

            try
            {
                ProximityPlacementGroup inputProximityPlacementGroup1 = new ProximityPlacementGroup
                {
                    Location = m_location,
                    Tags     = new Dictionary <string, string>()
                    {
                        { "RG1", "rg1" },
                        { "testTag", "1" },
                    },
                };
                ProximityPlacementGroup outputProximityPlacementGroup1 = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate(
                    m_resourceGroup1Name,
                    proximityPlacementGroup1Name,
                    inputProximityPlacementGroup1);

                m_ResourcesClient.ResourceGroups.CreateOrUpdate(
                    resourceGroup2Name,
                    new ResourceGroup
                {
                    Location = m_location,
                    Tags     = new Dictionary <string, string>()
                    {
                        { resourceGroup2Name, DateTime.UtcNow.ToString("u") }
                    }
                });

                ProximityPlacementGroup inputProximityPlacementGroup2 = new ProximityPlacementGroup
                {
                    Location = m_location,
                    Tags     = new Dictionary <string, string>()
                    {
                        { "RG2", "rg2" },
                        { "testTag", "2" },
                    },
                };
                ProximityPlacementGroup outputProximityPlacementGroup2 = m_CrpClient.ProximityPlacementGroups.CreateOrUpdate(
                    resourceGroup2Name,
                    proximityPlacementGroup2Name,
                    inputProximityPlacementGroup2);

                //verify proximityPlacementGroup across resource groups are listed successfully
                IPage <ProximityPlacementGroup> response = m_CrpClient.ProximityPlacementGroups.ListBySubscription();
                Assert.True(response.NextPageLink == null, "NextPageLink should be null in response.");

                int validationCount = 0;

                foreach (ProximityPlacementGroup proximityPlacementGroup in response)
                {
                    if (proximityPlacementGroup.Name == proximityPlacementGroup1Name)
                    {
                        //PPG is created using default value, updating the default value in input for validation of expected returned value.
                        inputProximityPlacementGroup1.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard;
                        ValidateResults(outputProximityPlacementGroup1, inputProximityPlacementGroup1, m_resourceGroup1Name, proximityPlacementGroup1Name);
                        validationCount++;
                    }
                    else if (proximityPlacementGroup.Name == proximityPlacementGroup2Name)
                    {
                        //PPG is created using default value, updating the default value in input for validation of expected returned value.
                        inputProximityPlacementGroup2.ProximityPlacementGroupType = ProximityPlacementGroupType.Standard;
                        ValidateResults(outputProximityPlacementGroup2, inputProximityPlacementGroup2, resourceGroup2Name, proximityPlacementGroup2Name);
                        validationCount++;
                    }
                }

                Assert.True(validationCount == 2, "Not all ProximityPlacementGroups are returned in response.");

                //verify proximityPlacementGroups in a resource groups are listed successfully
                response = m_CrpClient.ProximityPlacementGroups.ListByResourceGroup(m_resourceGroup1Name);
                ValidateResults(outputProximityPlacementGroup1, inputProximityPlacementGroup1, m_resourceGroup1Name, proximityPlacementGroup1Name);

                response = m_CrpClient.ProximityPlacementGroups.ListByResourceGroup(resourceGroup2Name);
                ValidateResults(outputProximityPlacementGroup2, inputProximityPlacementGroup2, resourceGroup2Name, proximityPlacementGroup2Name);
            }
            finally
            {
                m_ResourcesClient.ResourceGroups.Delete(resourceGroup2Name);
                // Delete ProximityPlacementGroup
                m_CrpClient.ProximityPlacementGroups.Delete(m_resourceGroup1Name, proximityPlacementGroup1Name);
            }
        }
Exemplo n.º 42
0
 private void TriggerOnPageUpdate(IPage page, IEnumerable <IPackage> addedOrUpdated, IEnumerable <IPackage> removed, bool reorder)
 {
     onListUpdate?.Invoke(page, addedOrUpdated, removed, reorder);
 }
Exemplo n.º 43
0
        protected void Disk_List_Execute(string diskCreateOption, string methodName, int?diskSizeGB = null)
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName, methodName))
            {
                EnsureClientsInitialized(context);

                // Data
                var  rgName1   = TestUtilities.GenerateName(TestPrefix);
                var  rgName2   = TestUtilities.GenerateName(TestPrefix);
                var  diskName1 = TestUtilities.GenerateName(DiskNamePrefix);
                var  diskName2 = TestUtilities.GenerateName(DiskNamePrefix);
                Disk disk1     = GenerateDefaultDisk(diskCreateOption, rgName1, diskSizeGB);
                Disk disk2     = GenerateDefaultDisk(diskCreateOption, rgName2, diskSizeGB);

                try
                {
                    // **********
                    // SETUP
                    // **********
                    // Create resource groups, unless create option is import in which case resource group will be created with vm
                    if (diskCreateOption != DiskCreateOption.Import)
                    {
                        m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName1, new ResourceGroup {
                            Location = DiskRPLocation
                        });
                        m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName2, new ResourceGroup {
                            Location = DiskRPLocation
                        });
                    }

                    // Put 4 disks, 2 in each resource group
                    m_CrpClient.Disks.CreateOrUpdate(rgName1, diskName1, disk1);
                    m_CrpClient.Disks.CreateOrUpdate(rgName1, diskName2, disk2);
                    m_CrpClient.Disks.CreateOrUpdate(rgName2, diskName1, disk1);
                    m_CrpClient.Disks.CreateOrUpdate(rgName2, diskName2, disk2);

                    // **********
                    // TEST
                    // **********
                    // List disks under resource group
                    IPage <Disk> disksOut = m_CrpClient.Disks.ListByResourceGroup(rgName1);
                    Assert.Equal(2, disksOut.Count());
                    Assert.Null(disksOut.NextPageLink);

                    disksOut = m_CrpClient.Disks.ListByResourceGroup(rgName2);
                    Assert.Equal(2, disksOut.Count());
                    Assert.Null(disksOut.NextPageLink);

                    // List disks under subscription
                    disksOut = m_CrpClient.Disks.List();
                    Assert.True(disksOut.Count() >= 4);
                    if (disksOut.NextPageLink != null)
                    {
                        disksOut = m_CrpClient.Disks.ListNext(disksOut.NextPageLink);
                        Assert.True(disksOut.Any());
                    }
                }
                finally
                {
                    // Delete resource group
                    m_ResourcesClient.ResourceGroups.Delete(rgName1);
                    m_ResourcesClient.ResourceGroups.Delete(rgName2);
                }
            }
        }
Exemplo n.º 44
0
 /// <summary>
 /// Initializes an instance of the class <see cref="Navigator"/>.
 /// </summary>
 /// <param name="page">A way to access the current displayed page</param>
 /// <param name="viewFactory">A view factory that creates pages base on a viewModel type</param>
 public Navigator(IPage page, IViewFactory viewFactory)
 {
     _page        = page;
     _viewFactory = viewFactory;
 }
Exemplo n.º 45
0
        private void ValidateAutomationRules(IPage <AutomationRule> AutomationRulepage)
        {
            Assert.True(AutomationRulepage.IsAny());

            AutomationRulepage.ForEach(ValidateAutomationRule);
        }
Exemplo n.º 46
0
        public void GalleryImageVersion_CRUD_Tests()
        {
            string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", galleryHomeLocation);
                EnsureClientsInitialized(context);
                string         rgName    = ComputeManagementTestUtilities.GenerateName(ResourceGroupPrefix);
                VirtualMachine vm        = null;
                string         imageName = ComputeManagementTestUtilities.GenerateName("psTestSourceImage");

                try
                {
                    string sourceImageId = "";
                    vm = CreateCRPImage(rgName, imageName, ref sourceImageId);
                    Assert.False(string.IsNullOrEmpty(sourceImageId));
                    Trace.TraceInformation(string.Format("Created the source image id: {0}", sourceImageId));

                    string  galleryName = ComputeManagementTestUtilities.GenerateName(GalleryNamePrefix);
                    Gallery gallery     = GetTestInputGallery();
                    m_CrpClient.Galleries.CreateOrUpdate(rgName, galleryName, gallery);
                    Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName,
                                                         rgName));
                    string       galleryImageName  = ComputeManagementTestUtilities.GenerateName(GalleryImageNamePrefix);
                    GalleryImage inputGalleryImage = GetTestInputGalleryImage();
                    m_CrpClient.GalleryImages.CreateOrUpdate(rgName, galleryName, galleryImageName, inputGalleryImage);
                    Trace.TraceInformation(string.Format("Created the gallery image: {0} in gallery: {1}", galleryImageName,
                                                         galleryName));

                    string galleryImageVersionName        = "1.0.0";
                    GalleryImageVersion inputImageVersion = GetTestInputGalleryImageVersion(sourceImageId);
                    m_CrpClient.GalleryImageVersions.CreateOrUpdate(rgName, galleryName, galleryImageName,
                                                                    galleryImageVersionName, inputImageVersion);
                    Trace.TraceInformation(string.Format("Created the gallery image version: {0} in gallery image: {1}",
                                                         galleryImageVersionName, galleryImageName));

                    GalleryImageVersion imageVersionFromGet = m_CrpClient.GalleryImageVersions.Get(rgName,
                                                                                                   galleryName, galleryImageName, galleryImageVersionName);
                    Assert.NotNull(imageVersionFromGet);
                    ValidateGalleryImageVersion(inputImageVersion, imageVersionFromGet);
                    imageVersionFromGet = m_CrpClient.GalleryImageVersions.Get(rgName, galleryName, galleryImageName,
                                                                               galleryImageVersionName, ReplicationStatusTypes.ReplicationStatus);
                    Assert.Equal(StorageAccountType.StandardLRS, imageVersionFromGet.PublishingProfile.StorageAccountType);
                    Assert.Equal(StorageAccountType.StandardLRS,
                                 imageVersionFromGet.PublishingProfile.TargetRegions.First().StorageAccountType);
                    Assert.NotNull(imageVersionFromGet.ReplicationStatus);
                    Assert.NotNull(imageVersionFromGet.ReplicationStatus.Summary);

                    inputImageVersion.PublishingProfile.EndOfLifeDate = DateTime.Now.AddDays(100).Date;
                    m_CrpClient.GalleryImageVersions.CreateOrUpdate(rgName, galleryName, galleryImageName,
                                                                    galleryImageVersionName, inputImageVersion);
                    Trace.TraceInformation(string.Format("Updated the gallery image version: {0} in gallery image: {1}",
                                                         galleryImageVersionName, galleryImageName));
                    imageVersionFromGet = m_CrpClient.GalleryImageVersions.Get(rgName, galleryName,
                                                                               galleryImageName, galleryImageVersionName);
                    Assert.NotNull(imageVersionFromGet);
                    ValidateGalleryImageVersion(inputImageVersion, imageVersionFromGet);

                    Trace.TraceInformation("Listing the gallery image versions");
                    IPage <GalleryImageVersion> listGalleryImageVersionsResult = m_CrpClient.GalleryImageVersions.
                                                                                 ListByGalleryImage(rgName, galleryName, galleryImageName);
                    Assert.Single(listGalleryImageVersionsResult);
                    Assert.Null(listGalleryImageVersionsResult.NextPageLink);

                    m_CrpClient.GalleryImageVersions.Delete(rgName, galleryName, galleryImageName, galleryImageVersionName);
                    listGalleryImageVersionsResult = m_CrpClient.GalleryImageVersions.
                                                     ListByGalleryImage(rgName, galleryName, galleryImageName);
                    Assert.Empty(listGalleryImageVersionsResult);
                    Assert.Null(listGalleryImageVersionsResult.NextPageLink);
                    Trace.TraceInformation(string.Format("Deleted the gallery image version: {0} in gallery image: {1}",
                                                         galleryImageVersionName, galleryImageName));

                    ComputeManagementTestUtilities.WaitMinutes(1);
                    m_CrpClient.Images.Delete(rgName, imageName);
                    Trace.TraceInformation("Deleted the CRP image.");
                    m_CrpClient.VirtualMachines.Delete(rgName, vm.Name);
                    Trace.TraceInformation("Deleted the virtual machine.");
                    m_CrpClient.GalleryImages.Delete(rgName, galleryName, galleryImageName);
                    Trace.TraceInformation("Deleted the gallery image.");
                    m_CrpClient.Galleries.Delete(rgName, galleryName);
                    Trace.TraceInformation("Deleted the gallery.");
                }
                finally
                {
                    Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation);
                    if (vm != null)
                    {
                        m_CrpClient.VirtualMachines.Delete(rgName, vm.Name);
                    }
                    m_CrpClient.Images.Delete(rgName, imageName);
                }
            }
        }
Exemplo n.º 47
0
 // ------------------------------------------------------------------
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="page">IPage</param>
 // ------------------------------------------------------------------
 public PageEventArgs(IPage page)
 {
     mPage = page;
 }
Exemplo n.º 48
0
 internal PagePublishJob(IPage page)
 {
     Page             = page;
     LanguageVariants = new List <ILanguageVariant>();
     ProjectVariants  = new List <IProjectVariant>();
 }
Exemplo n.º 49
0
 public CustomerContactFacade(IPage page)
 {
     viewPage   = page;
     restClient = new RestClient(ServiceBaseUrl, page);
 }
 private void pageAddedHandler(IPage i_Page)
 {
     createResultItem(i_Page);
 }
Exemplo n.º 51
0
 public OrderController(IPage <OrderPageViewModel, OrderPageModel> page)
 {
     _page = page;
 }
Exemplo n.º 52
0
 protected WebTableBase(IPage parent, string rootScss)
     : base(parent, rootScss)
 {
 }
Exemplo n.º 53
0
 public static bool IsPageCorrect(IPage page)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 54
0
        protected void Snapshot_List_Execute(string diskCreateOption, string methodName, int?diskSizeGB = null)
        {
            using (MockContext context = MockContext.Start(this.GetType().FullName, methodName))
            {
                EnsureClientsInitialized(context);

                // Data
                var  rgName1       = TestUtilities.GenerateName(TestPrefix);
                var  rgName2       = TestUtilities.GenerateName(TestPrefix);
                var  diskName1     = TestUtilities.GenerateName(DiskNamePrefix);
                var  diskName2     = TestUtilities.GenerateName(DiskNamePrefix);
                var  snapshotName1 = TestUtilities.GenerateName(DiskNamePrefix);
                var  snapshotName2 = TestUtilities.GenerateName(DiskNamePrefix);
                Disk disk1         = GenerateDefaultDisk(diskCreateOption, rgName1, diskSizeGB);
                Disk disk2         = GenerateDefaultDisk(diskCreateOption, rgName2, diskSizeGB);

                try
                {
                    // **********
                    // SETUP
                    // **********
                    // Create resource groups
                    m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName1, new ResourceGroup {
                        Location = DiskRPLocation
                    });
                    m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName2, new ResourceGroup {
                        Location = DiskRPLocation
                    });

                    // Put 4 disks, 2 in each resource group
                    Disk diskOut11 = m_CrpClient.Disks.CreateOrUpdate(rgName1, diskName1, disk1);
                    Disk diskOut12 = m_CrpClient.Disks.CreateOrUpdate(rgName1, diskName2, disk2);
                    Disk diskOut21 = m_CrpClient.Disks.CreateOrUpdate(rgName2, diskName1, disk1);
                    Disk diskOut22 = m_CrpClient.Disks.CreateOrUpdate(rgName2, diskName2, disk2);

                    // Generate 4 snapshots using disks info
                    Snapshot snapshot11 = GenerateDefaultSnapshot(diskOut11.Id);
                    Snapshot snapshot12 = GenerateDefaultSnapshot(diskOut12.Id, SnapshotStorageAccountTypes.StandardZRS);
                    Snapshot snapshot21 = GenerateDefaultSnapshot(diskOut21.Id);
                    Snapshot snapshot22 = GenerateDefaultSnapshot(diskOut22.Id);

                    // Put 4 snapshots, 2 in each resource group
                    m_CrpClient.Snapshots.CreateOrUpdate(rgName1, snapshotName1, snapshot11);
                    m_CrpClient.Snapshots.CreateOrUpdate(rgName1, snapshotName2, snapshot12);
                    m_CrpClient.Snapshots.CreateOrUpdate(rgName2, snapshotName1, snapshot21);
                    m_CrpClient.Snapshots.CreateOrUpdate(rgName2, snapshotName2, snapshot22);

                    // **********
                    // TEST
                    // **********
                    // List snapshots under resource group
                    IPage <Snapshot> snapshotsOut = m_CrpClient.Snapshots.ListByResourceGroup(rgName1);
                    Assert.Equal(2, snapshotsOut.Count());
                    Assert.Null(snapshotsOut.NextPageLink);

                    snapshotsOut = m_CrpClient.Snapshots.ListByResourceGroup(rgName2);
                    Assert.Equal(2, snapshotsOut.Count());
                    Assert.Null(snapshotsOut.NextPageLink);

                    // List snapshots under subscription
                    snapshotsOut = m_CrpClient.Snapshots.List();
                    Assert.True(snapshotsOut.Count() >= 4);
                    if (snapshotsOut.NextPageLink != null)
                    {
                        snapshotsOut = m_CrpClient.Snapshots.ListNext(snapshotsOut.NextPageLink);
                        Assert.True(snapshotsOut.Any());
                    }
                }
                finally
                {
                    // Delete resource group
                    m_ResourcesClient.ResourceGroups.Delete(rgName1);
                    m_ResourcesClient.ResourceGroups.Delete(rgName2);
                }
            }
        }
        /// <summary>
        /// Updates the given metadata item with new Id and setting the metadata definition name and defining item id
        /// </summary>
        /// <param name="metaData"></param>
        /// <param name="metaDataDefinitionName"></param>
        /// <param name="definingPage"></param>
        public static void AssignMetaDataSpecificValues(IData metaData, string metaDataDefinitionName, IPage definingPage)
        {
            Type interfaceType = metaData.DataSourceId.InterfaceType;

            PropertyInfo idPropertyInfo = interfaceType.GetPropertiesRecursively().SingleOrDefault(f => f.Name == nameof(IPageMetaData.Id));

            idPropertyInfo.SetValue(metaData, Guid.NewGuid(), null);

            PropertyInfo namePropertyInfo = GetDefinitionNamePropertyInfo(interfaceType);

            namePropertyInfo.SetValue(metaData, metaDataDefinitionName, null);

            PropertyInfo pageReferencePropertyInfo = GetDefinitionPageReferencePropertyInfo(interfaceType);

            pageReferencePropertyInfo.SetValue(metaData, definingPage.Id, null);

            PropertyInfo pageReferencePropertyVersionInfo = GetDefinitionPageReferencePropertyVersionInfo(interfaceType);

            pageReferencePropertyVersionInfo.SetValue(metaData, definingPage.VersionId, null);
        }
Exemplo n.º 56
0
        private void Taps_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.TabControl.Items.Count == 1)
            {
                return;
            }

            if (!(this.TabControl.SelectedItem is TabItem tp))
            {
                return;
            }

            if (tp.Content != null)
            {
                if (!(tp.Content is IPage page))
                {
                    return;
                }

                if (page.Equals(this._currentPage))
                {
                    return;
                }

                this._currentPage = page;
                page.OnReFocus();

                if (!page.ShowTreeView)
                {
                    if (this.TreeControl.Visibility == Visibility.Visible)
                    {
                        this.TreeControl.Visibility = Visibility.Hidden;
                        this._drag                   = this.TreeColumn.Width.Value;
                        this.TreeColumn.Width        = new GridLength(0);
                        this.VerticalSplitter1.Width = new GridLength(0);
                    }
                }
                else if (this.TreeControl.Visibility == Visibility.Hidden)
                {
                    this.TreeControl.Visibility  = Visibility.Visible;
                    this.TreeColumn.Width        = new GridLength(this._drag);
                    this.VerticalSplitter1.Width = new GridLength(6);
                }

                this.Navigation.Visibility = page.HideNavigation ? Visibility.Hidden : Visibility.Visible;

                this.ConsoleHost.Visibility = page.HideConsole ? Visibility.Hidden : Visibility.Visible;

                this._explorerNavigationBarRow.Height = page.HideExplorerNavigation ? new GridLength(0) : GridLength.Auto;

                switch (page)
                {
                case EmptyPage _:
                    //Console.WriteLine();
                    break;

                case ExplorerView explorer:
                    this._currentExplorerView = explorer;
                    break;

                case SettingsView _:
                    //Console.WriteLine();
                    break;

                case ThemeView _:
                    //Console.WriteLine();
                    break;
                }
            }
            else
            {
                if (this.TabControl.Items.Count > 1)
                {
                    this.TabControl.SelectedIndex = this.TabControl.Items.Count - 2;
                }
            }
        }
 /// <summary>
 /// Removes a metadata definition and possibly deletes all data items that are defined by it
 /// </summary>
 /// <param name="definingPage"></param>
 /// <param name="definitionName"></param>
 /// <param name="deleteExistingMetaData"></param>
 public static void RemoveMetaDataDefinition(this IPage definingPage, string definitionName, bool deleteExistingMetaData = true)
 {
     RemoveDefinition(definingPage.GetPageIdOrNull(), definitionName, deleteExistingMetaData);
 }
 private static Guid GetPageIdOrNull(this IPage page) => page?.Id ?? Guid.Empty;
Exemplo n.º 59
0
 public Navigator(IPageFactory pageFactory, IPage page)
 {
     _pageFactory = pageFactory;
     _page        = page;
 }
 private static bool ExistInOtherScope(IPage page, IEnumerable <IPageMetaDataDefinition> otherPageMetaDataDefinitions)
 {
     return(otherPageMetaDataDefinitions.Any(
                definition => IsDefinitionAllowed(definition, page)));
 }