Beispiel #1
0
 private void PropertiesGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.Column.Header.ToString() == nameof(ControlProperty.Value))
     {
         ControlProperty ctrlProp = e.EditingElement.DataContext as ControlProperty;
         mSelectedElement.Path = ctrlProp != null ? ctrlProp.Value : "";
     }
 }
 private static void ApplyValuePropertyCallback(HtmlObject target, ControlProperty property, Object value, ControlPropertyApplyResult result)
 {
     var applierTarget = target as IValuePropertyApplier;
     if (applierTarget != null)
         applierTarget.ApplyValueProperty(target, property, value, result);
     else
         throw new Exception("The target control must implement IValuePropertyApplier in order to accepted ValueProperty value apply.");
 }
        /// <summary>
        /// Performs the logic to mark a label as 'standard value' if the value matches the parent's value
        /// </summary>
        /// <param name="parentPage">The parent page</param>
        /// <param name="currentPagePreview">The current page preview</param>
        /// <param name="controls">The controls of the designer page</param>
        public void AddStandardValue(IEnumerable <Control> controls)
        {
            try
            {
                var pageManager = PageManager.GetManager();

                var parentSite = GetParentSite(pageManager, new Guid(System.Web.SiteMap.RootNode.Key));

                if (parentSite == null)
                {
                    return;
                }

                var pageName = GetPageName();

                if (pageName == "")
                {
                    return;
                }

                var currentPagePreview = GetCurrentPagePreview(pageManager, pageName);

                if (currentPagePreview == null)
                {
                    return;
                }

                var parentPage = GetParentPage(pageManager, parentSite, pageName);

                if (parentPage == null)
                {
                    return;
                }

                parentPage.Controls[0].Properties.First(r => r.Name.ToLower() == "settings").ChildProperties.ToList().ForEach(p =>
                {
                    ControlProperty currentProperty = null;
                    var settings = currentPagePreview.Controls[0].Properties.FirstOrDefault(r => r.Name.ToLower() == "settings");
                    if ((currentProperty = settings.ChildProperties.FirstOrDefault(n => n.Name.ToLower() == p.Name.ToLower())) != null)
                    {
                        if (p.Value == currentProperty.Value)
                        {
                            controls.ToList().ForEach(c =>
                            {
                                if (c is Label && ((Label)c).AssociatedControlID.ToLower() == currentProperty.Name.ToLower())
                                {
                                    ((Label)c).Text += "<span style='color:grey;font-style:italic;font-size:80%'>&nbsp;(Standard Value)</span>";
                                }
                            });
                        }
                    }
                });
            }
            catch (Exception)
            {
                //add logging here
            }
        }
Beispiel #4
0
 public void UpdateControl()
 {
     if (!_controlUpdatedFromEvent)
     {
         _viewModelUpdatedFromEvent = true;
         ControlProperty.Setter(ViewModelToControlConverter(ViewModelProperty.Getter()));
         _viewModelUpdatedFromEvent = false;
     }
 }
Beispiel #5
0
 public void UpdateViewModel()
 {
     if (!_viewModelUpdatedFromEvent)
     {
         _controlUpdatedFromEvent = true;
         ViewModelProperty.Setter(ControlToViewModelConverter(ControlProperty.Getter()));
         _controlUpdatedFromEvent = false;
     }
 }
Beispiel #6
0
        private void SetValueButton_Click(object sender, RoutedEventArgs e)
        {
            // TODO: create an action to get the focusable control from the driver on the device
            List<ElementInfo> list = ((IWindowExplorer)mAndroidADBDriver).GetVisibleControls(null);
            // get from the list only text Edit
            foreach (ElementInfo EI in list)
            {
                if (EI.ElementType == "android.widget.EditText")  // check if it will work on all apps, might need to rethink 
                {
                    ObservableList<ControlProperty> props = EI.GetElementProperties();
                    ControlProperty cp = (from x in props where x.Name == "focused" select x).FirstOrDefault();

                    //FIXME: temp just to try, need to get the best locator for element.
                    ControlProperty cpresourceid = (from x in props where x.Name == "resource-id" select x).FirstOrDefault();

                    if (cp.Value == "true")
                    {
                        // mDeviceViewPage.AddTextBox()
                        ActUIElement a = new ActUIElement();
                        a.ElementLocateBy = eLocateBy.ByResourceID;
                        a.ElementType = eElementType.TextBox;
                        a.ElementAction = ActUIElement.eElementAction.SetText;

                        // Need to set value in both since sending direct to driver
                        // a.ElementLocateValue = cpresourceid.Value;
                        a.GetOrCreateInputParam(ActUIElement.Fields.ElementLocateValue).ValueForDriver = cpresourceid.Value;
                        

                        a.GetOrCreateInputParam(ActUIElement.Fields.Value).ValueForDriver = SetValueTextBox.Text;
                        

                        // a.Value = SendKeysTextBox.Text;
                        mAndroidADBDriver.RunAction(a);


                        if (IsRecording)
                        {
                            ControlProperty desc = (from x in props where x.Name == "content-desc" select x).FirstOrDefault();
                            if (string.IsNullOrEmpty(desc.Value))
                            {
                                desc = cpresourceid;
                            }
                            a.Description = "Set '" + desc.Value + "' value to '" + SetValueTextBox.Text +  "'";
                            a.GetOrCreateInputParam(ActUIElement.Fields.Value).Value = SetValueTextBox.Text;
                            a.GetOrCreateInputParam(ActUIElement.Fields.ElementLocateValue).Value = cpresourceid.Value;
                            
                            mBusinessFlow.AddAct(a);
                        }

                        return;
                    }
                }
            }
            
            

        }
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value.AsString().HasValue())
     {
         if (Raw)
             result.RawInnerText.Append(value.AsString());
         else
             result.InnerText.Append(value.AsString());
     }
 }
        public virtual void FillSource(TSource model)
        {
            if (model == null)
            {
                return;
            }

            var value = ControlProperty.GetPropertyInfo().GetValue(Control);

            Property.GetPropertyInfo().SetValue(model, value);
        }
Beispiel #9
0
        private static void ApplyValuePropertyCallback(HtmlObject target, ControlProperty property, Object value, ControlPropertyApplyResult result)
        {
            var applierTarget = target as IValuePropertyApplier;

            if (applierTarget != null)
            {
                applierTarget.ApplyValueProperty(target, property, value, result);
            }
            else
            {
                throw new Exception("The target control must implement IValuePropertyApplier in order to accepted ValueProperty value apply.");
            }
        }
Beispiel #10
0
        private bool IsPropertyExist(ObservableList <ControlProperty> Properties, string PropName, string PropValue)
        {
            ControlProperty property = Properties.Where(x => x.Name == PropName && x.Value == PropValue).FirstOrDefault();

            if (property != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     if (value.AsString().HasValue())
     {
         if (Raw)
         {
             result.RawInnerText.Append(value.AsString());
         }
         else
         {
             result.InnerText.Append(value.AsString());
         }
     }
 }
Beispiel #12
0
        private void AddPropertyHandler(object sender, RoutedEventArgs e)
        {
            xPropertiesGrid.Grid.CommitEdit();

            ControlProperty elemProp = new ControlProperty()
            {
                Name = parentFramePropertyName
            };

            mSelectedElement.Properties.Add(elemProp);
            xPropertiesGrid.Grid.SelectedItem = elemProp;
            xPropertiesGrid.ScrollToViewCurrentItem();

            xPropertiesGrid.ShowAdd = Visibility.Collapsed;
        }
Beispiel #13
0
        private void xPropertyValueVEButton_Click(object sender, RoutedEventArgs e)
        {
            ControlProperty selectedVerb = (ControlProperty)xPropertiesGrid.CurrentItem;
            ElementInfo     elementInfo  = (ElementInfo)xMainElementsGrid.CurrentItem;

            if (elementInfo.IsAutoLearned)
            {
                Reporter.ToUser(eUserMsgKey.StaticWarnMessage, "You can not edit Property which was auto learned.");
                disabeledLocatorsMsgShown = true;
            }
            else
            {
                ValueExpressionEditorPage VEEW = new ValueExpressionEditorPage(selectedVerb, nameof(ControlProperty.Value), null);
                VEEW.ShowAsWindow();
            }
        }
 /// <summary>
 /// Aplica o atributo de visibilidade a um controle.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 /// <param name="result"></param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     var state = (Visibility)value;
     switch (state)
     {
         case Visibility.Visible:
             result.Styles.Remove(CssProperty.Visibility);
             break;
         case Visibility.Hidden:
             result.Styles[CssProperty.Visibility] = state.ToString().ToLower();
             break;
         case Visibility.None:
             result.Styles.Remove(CssProperty.Visibility);
             result.Styles[CssProperty.Display] = "none";
             break;
     }
 }
        //Add Data From Linked Tables for Display
        public void EditForDisplay(ControlValue controlValue)
        {
            ControlPropertyRepository controlPropertyRepository = new ControlPropertyRepository();
            ControlProperty           controlProperty           = new ControlProperty();

            controlProperty = controlPropertyRepository.GetControlProperty(controlValue.ControlPropertyId);
            if (controlProperty != null)
            {
                controlValue.ControlPropertyDescription = controlProperty.ControlPropertyDescription;
            }
            //ControlNameRepository controlNameRepository = new ControlNameRepository();
            //ControlName controlName = new ControlName();
            //controlName = controlNameRepository.GetControlName(controlValue.ControlNameId);
            //if (controlName != null)
            //{
            //    controlValue.ControlName = controlName.ControlName1;
            // }
        }
        private static ControlProperty GetControlPropertyModel(FormControl formControl)
        {
            ControlProperty property = null;

            if (formControl.Properties != null)
            {
                var settings = formControl.Properties.FirstOrDefault(p => p.Name == SettingsPropertyName);
                if (settings != null && settings.ChildProperties != null)
                {
                    var model = settings.ChildProperties.FirstOrDefault(p => p.Name == ModelPropertyName);
                    if (model != null)
                    {
                        property = model;
                    }
                }
            }

            return(property);
        }
        /// <summary>
        /// Aplica o atributo de visibilidade a um controle.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="property"></param>
        /// <param name="value"></param>
        /// <param name="result"></param>
        public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
        {
            var state = (Visibility)value;

            switch (state)
            {
            case Visibility.Visible:
                result.Styles.Remove(CssProperty.Visibility);
                break;

            case Visibility.Hidden:
                result.Styles[CssProperty.Visibility] = state.ToString().ToLower();
                break;

            case Visibility.None:
                result.Styles.Remove(CssProperty.Visibility);
                result.Styles[CssProperty.Display] = "none";
                break;
            }
        }
Beispiel #18
0
        private void AddPropertyHandler(object sender, RoutedEventArgs e)
        {
            xPropertiesGrid.Grid.CommitEdit();

            //for java Swing ParentIframe is not required
            if (WorkSpace.Instance.Solution.GetTargetApplicationPlatform(mPOM.TargetApplicationKey).Equals(ePlatformType.Java) && !mSelectedElement.GetType().Equals(typeof(HTMLElementInfo)))
            {
                return;
            }

            ControlProperty elemProp = new ControlProperty()
            {
                Name = ElementProperty.ParentIFrame
            };

            mSelectedElement.Properties.Add(elemProp);
            xPropertiesGrid.Grid.SelectedItem = elemProp;
            xPropertiesGrid.ScrollToViewCurrentItem();

            xPropertiesGrid.ShowAdd = Visibility.Collapsed;
        }
 /// <summary>
 /// Aplica a propriedade à saída de um controle.
 /// </summary>
 /// <param name="target">Controle alvo</param>
 /// <param name="property">Propriedade sendo aplicada</param>
 /// <param name="value">Valor da propriedade sendo aplicada</param>
 /// <param name="result">Resultado da saida da renderização atual.</param>
 public void ApplyProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     var thickness = value as Thickness;
     if (value != null && thickness.IsSetted())
     {
         if (thickness.AllValuesIsSetted())
             result.Styles[CssAttribute] = thickness.GetAllValuesString();
         else
         {
             var str = CssAttribute.ToString().ToLower();
             if (thickness.Top.HasValue)
                 result.Styles[CssConfig.GetEnumItemFromCssName<CssProperty>(str + "-top")] = thickness.GetTopStringValue();
             if (thickness.Bottom.HasValue)
                 result.Styles[CssConfig.GetEnumItemFromCssName<CssProperty>(str + "-bottom")] = thickness.GetBottomStringValue();
             if (thickness.Left.HasValue)
                 result.Styles[CssConfig.GetEnumItemFromCssName<CssProperty>(str + "-left")] = thickness.GetLeftStringValue();
             if (thickness.Right.HasValue)
                 result.Styles[CssConfig.GetEnumItemFromCssName<CssProperty>(str + "-right")] = thickness.GetRightStringValue();
         }
     }
 }
        public virtual void FillTarget(TSource model)
        {
            object value;

            if (model == null)
            {
                var prop = Property.GetPropertyInfo().PropertyType;
                value = GetDefault(prop);
                if (value == null && prop == typeof(string))
                {
                    value = string.Empty;
                }
            }
            else
            {
                value = Property.GetPropertyInfo().GetValue(model);
            }
            ControlProperty.GetPropertyInfo().SetValue(Control, value);

            Callback?.Invoke();
        }
        public ControlManifestDetails FetchProperties(ControlManifestDetails controlDetails)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNodeList propertyNodes = manifestFile.SelectNodes("/manifest/control/property");

            foreach (XmlNode node in propertyNodes)
            {
                ControlProperty property = new ControlProperty();

                try
                {
                    property.Name               = (node.Attributes["name"]?.Value) ?? string.Empty;
                    property.DisplayNameKey     = (node.Attributes["display-name-key"]?.Value) ?? string.Empty;
                    property.DescriptionNameKey = (node.Attributes["description-key"]?.Value) ?? string.Empty;
                    property.TypeOrTypeGroup    = (node.Attributes["of-type"]?.Value) ?? string.Empty;
                    property.IsRequired         = bool.Parse(node.Attributes["required"]?.Value ?? "false");
                    property.Usage              = (node.Attributes["usage"]?.Value ?? "bound") == "bound" ? Enum.UsageType.bound : Enum.UsageType.input;

                    // Check of of-type-group
                    if (string.IsNullOrEmpty(property.TypeOrTypeGroup))
                    {
                        property.TypeOrTypeGroup  = (node.Attributes["of-type-group"]?.Value) ?? string.Empty;
                        property.IsUsingTypeGroup = true;
                    }

                    property.IsValid = true;
                }
                catch (Exception ex)
                {
                    property.IsValid = false;
                }

                controlDetails.Properties.Add(property);
            }

            return(controlDetails);
        }
Beispiel #22
0
        public override ObservableList <ControlProperty> GetElementProperties(object obj)
        {
            ObservableList <ControlProperty> list = new ObservableList <ControlProperty>();
            AutomationElement AE = (AutomationElement)obj;

            foreach (PropertyId AP in AE.BasicAutomationElement.GetSupportedProperties())
            {
                ControlProperty CP = new ControlProperty();
                CP.Name = AP.Name;
                CP.Name = CP.Name.Replace("AutomationElementIdentifiers.", "");
                CP.Name = CP.Name.Replace("Property", "");
                object propValue = null;
                AE.BasicAutomationElement.TryGetPropertyValue(AP, out propValue);
                // If Property Value is not null then only add it to the list.
                if (propValue != null)
                {
                    CP.Value = propValue.ToString();
                    list.Add(CP);
                }
            }
            return(list);
        }
        ObservableList <ControlProperty> IWindowExplorerTreeItem.GetElementProperties()
        {
            ObservableList <ControlProperty> CPL = new ObservableList <ControlProperty> ();

            ControlProperty CP1 = new ControlProperty();

            CP1.Name  = "Caret Position";
            CP1.Value = XSF.Location.position.ToString();
            CPL.Add(CP1);

            ControlProperty CP2 = new ControlProperty();

            CP2.Name  = "X/Y";
            CP2.Value = XSF.Location.left.ToString() + "/" + XSF.Location.top.ToString();
            CPL.Add(CP2);


            ControlProperty CP3 = new ControlProperty();

            CP3.Name  = "Read Only";
            CP3.Value = XSF.Attributes.Protected.ToString();
            CPL.Add(CP3);
            return(CPL);
        }
        public void CreateNewProperty(ControlManifestDetails controlDetails, ControlProperty property)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode controlNode = manifestFile.SelectSingleNode($"/manifest/control");

            XmlElement propertyNode = manifestFile.CreateElement("property");

            if (!string.IsNullOrEmpty(property.Name))
            {
                propertyNode.SetAttribute("name", property.Name);
            }
            if (!string.IsNullOrEmpty(property.DisplayNameKey))
            {
                propertyNode.SetAttribute("display-name-key", property.DisplayNameKey);
            }
            if (!string.IsNullOrEmpty(property.DescriptionNameKey))
            {
                propertyNode.SetAttribute("description-key", property.DescriptionNameKey);
            }
            propertyNode.SetAttribute("usage", property.Usage.ToString());
            propertyNode.SetAttribute("required", property.IsRequired ? "true" : "false");
            if (property.IsUsingTypeGroup)
            {
                propertyNode.SetAttribute("of-type-group", property.TypeOrTypeGroup);
            }
            else
            {
                propertyNode.SetAttribute("of-type", property.TypeOrTypeGroup);
            }
            controlNode.AppendChild(propertyNode);

            manifestFile.Save(controlDetails.ManifestFilePath);
        }
 void IValuePropertyApplier.ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     this.ApplyValueProperty(target, property, value, result);
 }
 protected abstract void ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result);
        /// <summary>
        /// Installs this module in Sitefinity system for the first time.
        /// </summary>
        /// <param name="initializer">The Site Initializer. A helper class for installing Sitefinity modules.</param>
        public override void Install(SiteInitializer initializer)
        {
            // get page manager
            var pageManager = initializer.PageManager;

            // create Module Landing Page if doesn't exist
            var landingPage = pageManager.GetPageNodes().SingleOrDefault(p => p.Id == this.LandingPageId);

            if (landingPage == null)
            {
                // create admin list view control and add to new landing page
                var ctrl = pageManager.CreateControl <PageControl>("~/Modules/Testimonials/Admin/TestimonialsAdminView.ascx", "Content");
                this.CreatePage(pageManager, this.LandingPageId, SiteInitializer.ModulesNodeId, TestimonialsModule.ModuleName, true, TestimonialsModule.ModuleName, ctrl);
            }

            // create testimonials "Create" Page if doesn't exist
            var createPage = pageManager.GetPageNodes().SingleOrDefault(p => p.Id == this.CreatePageId);

            if (createPage == null)
            {
                // create admin control, set properties
                var ctrl = pageManager.CreateControl <PageControl>("~/Modules/Testimonials/Admin/TestimonialsAddEditView.ascx", "Content");
                var prop = ctrl.Properties.FirstOrDefault(p => p.Name == "Mode");
                if (prop == null)
                {
                    prop      = new ControlProperty();
                    prop.Id   = Guid.NewGuid();
                    prop.Name = "Mode";
                    ctrl.Properties.Add(prop);
                }

                // set control to "Create" mode
                prop.Value = SitefinityWebApp.Modules.Testimonials.Admin.TestimonialsAddEditView.AdminControlMode.Create.ToString();

                // create backend page and add control
                this.CreatePage(pageManager, this.CreatePageId, this.LandingPageId, "Create", false, "Create Testimonial", ctrl);
            }

            // create testimonials "Edit" Page if doesn't exist
            var editPage = pageManager.GetPageNodes().SingleOrDefault(p => p.Id == this.EditPageId);

            if (editPage == null)
            {
                // create admin control, set properties
                var ctrl = pageManager.CreateControl <PageControl>("~/Modules/Testimonials/Admin/TestimonialsAddEditView.ascx", "Content");
                var prop = ctrl.Properties.FirstOrDefault(p => p.Name == "Mode");
                if (prop == null)
                {
                    prop      = new ControlProperty();
                    prop.Id   = Guid.NewGuid();
                    prop.Name = "Mode";
                    ctrl.Properties.Add(prop);
                }

                // set control to "Create" mode
                prop.Value = SitefinityWebApp.Modules.Testimonials.Admin.TestimonialsAddEditView.AdminControlMode.Edit.ToString();

                // create backend page and add control
                this.CreatePage(pageManager, this.EditPageId, this.LandingPageId, "Edit", false, "Edit Testimonial", ctrl);
            }

            string toolboxName = "PageControls";
            string sectionName = "Samples";
            var    config      = initializer.Context.GetConfig <ToolboxesConfig>();

            var controls = config.Toolboxes[toolboxName];
            var section  = controls.Sections.Where <ToolboxSection>(e => e.Name == sectionName).FirstOrDefault();

            if (section == null)
            {
                section = new ToolboxSection(controls.Sections)
                {
                    Name            = sectionName,
                    Title           = sectionName,
                    Description     = sectionName,
                    ResourceClassId = typeof(PageResources).Name
                };
                controls.Sections.Add(section);
            }

            // Add TestimonialsView Widget if doesn't exist
            if (!section.Tools.Any <ToolboxItem>(e => e.Name == TestimonialsView.ViewName))
            {
                var tool = new ToolboxItem(section.Tools)
                {
                    Name        = TestimonialsView.ViewName,
                    Title       = "TestimonialsView",
                    Description = "Public control for the Testimonials module",
                    ControlType = "~/Modules/Testimonials/TestimonialsView.ascx",
                    CssClass    = "sfTestimonialsWidget"
                };
                section.Tools.Add(tool);
            }

            // Add SubmitTestimonial Widget if doesn't exist
            if (!section.Tools.Any <ToolboxItem>(e => e.Name == SubmitTestimonial.ViewName))
            {
                var tool = new ToolboxItem(section.Tools)
                {
                    Name        = SubmitTestimonial.ViewName,
                    Title       = "SubmitTestimonial",
                    Description = "Public control for submitting Testimonial",
                    ControlType = "~/Modules/Testimonials/SubmitTestimonial.ascx",
                    CssClass    = "sfTestimonialsWidget"
                };
                section.Tools.Add(tool);
            }
        }
Beispiel #28
0
        private void SetMatchingElementDeltaDetails(ElementInfo existingElement, ElementInfo latestElement)
        {
            DeltaElementInfo matchedDeltaElement = new DeltaElementInfo();

            //copy possible customized fields from original
            latestElement.Guid         = existingElement.Guid;
            latestElement.ElementName  = existingElement.ElementName;
            latestElement.Description  = existingElement.Description;
            latestElement.ElementGroup = existingElement.ElementGroup;
            if (existingElement.OptionalValuesObjectsList.Count > 0 && latestElement.OptionalValuesObjectsList.Count == 0)
            {
                latestElement.OptionalValuesObjectsList = existingElement.OptionalValuesObjectsList;
            }
            matchedDeltaElement.ElementInfo = latestElement;
            ////////------------------ Delta Locators
            foreach (ElementLocator latestLocator in latestElement.Locators)
            {
                latestLocator.LocateStatus = ElementLocator.eLocateStatus.Unknown;
                DeltaElementLocator deltaLocator = new DeltaElementLocator();
                latestLocator.LocateStatus  = ElementLocator.eLocateStatus.Unknown;
                deltaLocator.ElementLocator = latestLocator;
                ElementLocator matchingExistingLocator = existingElement.Locators.Where(x => x.LocateBy == latestLocator.LocateBy).FirstOrDefault();
                if (matchingExistingLocator != null)
                {
                    latestLocator.Guid = matchingExistingLocator.Guid;
                    if (matchingExistingLocator.LocateBy == eLocateBy.ByXPath)
                    {
                        //fiting previous learned Xpath to latest structure to avoid false change indication
                        if (matchingExistingLocator.LocateValue.StartsWith("/") == false)
                        {
                            string   updatedXpath = string.Empty;
                            string[] xpathVals    = matchingExistingLocator.LocateValue.Split(new char[] { '/' });
                            for (int indx = 0; indx < xpathVals.Count(); indx++)
                            {
                                if (indx == 0)
                                {
                                    xpathVals[0] = xpathVals[0] + "[1]";
                                }
                                updatedXpath += "/" + xpathVals[indx];
                            }

                            matchingExistingLocator.LocateValue = updatedXpath;
                        }
                    }
                    //compare value
                    if ((string.IsNullOrWhiteSpace(matchingExistingLocator.LocateValue) == true && string.IsNullOrWhiteSpace(latestLocator.LocateValue) == true) ||
                        matchingExistingLocator.LocateValue.Equals(latestLocator.LocateValue, StringComparison.OrdinalIgnoreCase))   //Unchanged
                    {
                        deltaLocator.DeltaStatus = eDeltaStatus.Unchanged;
                    }
                    else//Changed
                    {
                        deltaLocator.DeltaStatus       = eDeltaStatus.Changed;
                        deltaLocator.DeltaExtraDetails = string.Format("Previous value was: '{0}'", matchingExistingLocator.LocateValue);
                    }
                }
                else//new locator
                {
                    deltaLocator.DeltaStatus = eDeltaStatus.Added;
                }
                matchedDeltaElement.Locators.Add(deltaLocator);
            }
            //not Learned Locators
            List <ElementLocator> notLearnedLocators = existingElement.Locators.Where(x => latestElement.Locators.Where(y => y.Guid == x.Guid).FirstOrDefault() == null).ToList();

            foreach (ElementLocator notLearedLocator in notLearnedLocators)
            {
                DeltaElementLocator deltaLocator = new DeltaElementLocator();
                notLearedLocator.LocateStatus = ElementLocator.eLocateStatus.Unknown;
                deltaLocator.ElementLocator   = notLearedLocator;
                if (notLearedLocator.IsAutoLearned == true)//deleted
                {
                    deltaLocator.DeltaStatus       = eDeltaStatus.Deleted;
                    deltaLocator.DeltaExtraDetails = "Locator not exist on latest";
                }
                else//customized locator so avoid it
                {
                    deltaLocator.DeltaStatus       = eDeltaStatus.Avoided;
                    deltaLocator.DeltaExtraDetails = "Customized locator not exist on latest";
                    if (KeepOriginalLocatorsOrderAndActivation == true)
                    {
                        latestElement.Locators.Add(notLearedLocator);
                    }
                }
                matchedDeltaElement.Locators.Add(deltaLocator);
            }
            if (KeepOriginalLocatorsOrderAndActivation == true)
            {
                foreach (ElementLocator originalLocator in existingElement.Locators)
                {
                    ElementLocator latestLocator = latestElement.Locators.Where(x => x.Guid == originalLocator.Guid).FirstOrDefault();

                    if (latestLocator != null)
                    {
                        latestLocator.Active = originalLocator.Active;
                        int originalIndex = existingElement.Locators.IndexOf(originalLocator);
                        if (originalIndex <= latestElement.Locators.Count)
                        {
                            latestElement.Locators.Move(latestElement.Locators.IndexOf(latestLocator), originalIndex);
                            matchedDeltaElement.Locators.Move(matchedDeltaElement.Locators.IndexOf(matchedDeltaElement.Locators.Where(x => x.ElementLocator == latestLocator).First()), originalIndex);
                        }
                    }
                }
            }

            ////////--------------- Properties
            foreach (ControlProperty latestProperty in latestElement.Properties)
            {
                DeltaControlProperty deltaProperty            = new DeltaControlProperty();
                ControlProperty      matchingExistingProperty = existingElement.Properties.Where(x => x.Name == latestProperty.Name).FirstOrDefault();
                if (matchingExistingProperty != null)
                {
                    latestProperty.Guid           = matchingExistingProperty.Guid;
                    deltaProperty.ElementProperty = latestProperty;
                    if ((string.IsNullOrWhiteSpace(matchingExistingProperty.Value) == true && string.IsNullOrWhiteSpace(latestProperty.Value) == true) ||
                        (matchingExistingProperty.Value != null && matchingExistingProperty.Value.Equals(latestProperty.Value, StringComparison.OrdinalIgnoreCase)))    //Unchanged
                    {
                        deltaProperty.DeltaStatus = eDeltaStatus.Unchanged;
                    }
                    else//Changed
                    {
                        if (PropertiesChangesToAvoid == DeltaControlProperty.ePropertiesChangesToAvoid.None ||
                            (PropertiesChangesToAvoid == DeltaControlProperty.ePropertiesChangesToAvoid.OnlySizeAndLocationProperties && mVisualPropertiesList.Contains(deltaProperty.Name) == false))
                        {
                            deltaProperty.DeltaStatus       = eDeltaStatus.Changed;
                            deltaProperty.DeltaExtraDetails = string.Format("Previous value was: '{0}'", matchingExistingProperty.Value);
                        }
                        else
                        {
                            deltaProperty.DeltaStatus       = eDeltaStatus.Avoided;
                            deltaProperty.DeltaExtraDetails = string.Format("Previous value was: '{0}' but change was avoided", matchingExistingProperty.Value);
                        }
                    }
                }
                else//new Property
                {
                    deltaProperty.ElementProperty = latestProperty;
                    if (string.IsNullOrWhiteSpace(latestProperty.Value) == false)
                    {
                        deltaProperty.DeltaStatus = eDeltaStatus.Added;
                    }
                    else
                    {
                        deltaProperty.DeltaStatus       = eDeltaStatus.Avoided;
                        deltaProperty.DeltaExtraDetails = "New property but value is empty so it was avoided";
                    }
                }
                matchedDeltaElement.Properties.Add(deltaProperty);
            }
            //deleted Properties
            List <ControlProperty> deletedProperties = existingElement.Properties.Where(x => latestElement.Properties.Where(y => y.Name == x.Name).FirstOrDefault() == null).ToList();

            foreach (ControlProperty deletedProperty in deletedProperties)
            {
                DeltaControlProperty deltaProp = new DeltaControlProperty();
                deltaProp.ElementProperty = deletedProperty;
                if (PropertiesChangesToAvoid == DeltaControlProperty.ePropertiesChangesToAvoid.None ||
                    (PropertiesChangesToAvoid == DeltaControlProperty.ePropertiesChangesToAvoid.OnlySizeAndLocationProperties && mVisualPropertiesList.Contains(deletedProperty.Name) == false))
                {
                    deltaProp.DeltaStatus       = eDeltaStatus.Deleted;
                    deltaProp.DeltaExtraDetails = "Property not exist on latest";
                }
                else
                {
                    deltaProp.DeltaStatus       = eDeltaStatus.Avoided;
                    deltaProp.DeltaExtraDetails = "Property not exist on latest but avoided";
                }
                matchedDeltaElement.Properties.Add(deltaProp);
            }

            //------------ General Status set
            List <DeltaElementLocator>  modifiedLocatorsList   = matchedDeltaElement.Locators.Where(x => x.DeltaStatus == eDeltaStatus.Changed || x.DeltaStatus == eDeltaStatus.Deleted).ToList();
            List <DeltaControlProperty> modifiedPropertiesList = matchedDeltaElement.Properties.Where(x => x.DeltaStatus == eDeltaStatus.Changed || x.DeltaStatus == eDeltaStatus.Deleted).ToList();

            if (modifiedLocatorsList.Count > 0 || modifiedPropertiesList.Count > 0)
            {
                matchedDeltaElement.DeltaStatus = eDeltaStatus.Changed;
                matchedDeltaElement.IsSelected  = true;
                if (modifiedLocatorsList.Count > 0 && modifiedPropertiesList.Count > 0)
                {
                    matchedDeltaElement.DeltaExtraDetails = "Locators & Properties changed";
                }
                else if (modifiedLocatorsList.Count > 0)
                {
                    matchedDeltaElement.DeltaExtraDetails = "Locators changed";
                }
                else if (modifiedPropertiesList.Count > 0)
                {
                    matchedDeltaElement.DeltaExtraDetails = "Properties changed";
                }
            }
            else
            {
                matchedDeltaElement.DeltaStatus = eDeltaStatus.Unchanged;
                matchedDeltaElement.IsSelected  = false;
                List <DeltaElementLocator>  minorLocatorsChangesList   = matchedDeltaElement.Locators.Where(x => x.DeltaStatus == eDeltaStatus.Avoided || x.DeltaStatus == eDeltaStatus.Added || x.DeltaStatus == eDeltaStatus.Unknown).ToList();
                List <DeltaControlProperty> minorPropertiesChangesList = matchedDeltaElement.Properties.Where(x => x.DeltaStatus == eDeltaStatus.Avoided || x.DeltaStatus == eDeltaStatus.Added || x.DeltaStatus == eDeltaStatus.Unknown).ToList();
                if (minorLocatorsChangesList.Count > 0 || minorPropertiesChangesList.Count > 0)
                {
                    matchedDeltaElement.DeltaExtraDetails = "Unimportant differences exists";
                }
            }

            DeltaViewElements.Add(matchedDeltaElement);
        }
        protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
        {
            var    url      = System.Web.HttpContext.Current.Session["PageUrl"].ToString();
            var    regEx    = new System.Text.RegularExpressions.Regex(@"^/([a-zA-Z]+)/[a-zA-Z/]*$");
            var    match    = regEx.Match(url);
            string pageName = "";

            if (!match.Success)
            {
                throw new NullReferenceException("The url did not contain the current page name");
            }

            pageName = match.Groups[1].ToString().ToLower();

            var pManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();

            var sites = new Telerik.Sitefinity.Multisite.MultisiteManager();

            var homePage = pManager.GetPageDataList().Where(p => p.NavigationNode.Title.ToString().ToLower() == pageName && p.NavigationNode.ParentId == new Guid(System.Web.SiteMap.RootNode.Key)).FirstOrDefault();

            if (homePage == null)
            {
                throw new NullReferenceException("The current published page could not be found");
            }

            var homePagePreview = pManager.GetPreview(homePage.NavigationNode.PageId);

            if (homePagePreview == null)
            {
                throw new NullReferenceException("The current preview page could not be found");
            }

            var configPage = pManager.GetPageDataList().Where(p => p.NavigationNode.Title.ToString().ToLower() == "config" && p.NavigationNode.ParentId == new Guid(System.Web.SiteMap.RootNode.Key)).FirstOrDefault();

            if (configPage == null)
            {
                throw new NullReferenceException("The config page could not be found");
            }

            var parentName = configPage.Controls[0].Properties.FirstOrDefault(p => p.Name == "ParentName");

            if (parentName == null)//no parent, most likely is parent site
            {
                return;
            }

            var parentSiteName = parentName.Value;

            if (parentSiteName == "")
            {
                throw new NullReferenceException("The ParentName property is empty");
            }

            var parentSite = sites.GetSites().Where(p => p.Name == parentSiteName).FirstOrDefault();

            if (parentSite == null)
            {
                throw new NullReferenceException("The parent site name: " + parentSiteName + " could not be found");
            }

            var thisPage = pManager.GetPageDataList().Where(p => p.NavigationNode.Title.ToString().ToLower() == pageName && p.NavigationNode.ParentId == parentSite.SiteMapRootNodeId).FirstOrDefault();

            if (thisPage == null)
            {
                throw new NullReferenceException("The current page of the parent site could not be found");
            }

            thisPage.Controls[0].Properties.ToList().ForEach(p =>
            {
                ControlProperty homeProperty = null;
                if ((homeProperty = homePagePreview.Controls[0].Properties.FirstOrDefault(n => n.Name == p.Name)) != null)
                {
                    if (p.Value != homeProperty.Value)
                    {
                        StandardValue.Visible = false;
                    }
                }
            });
        }
Beispiel #30
0
 protected abstract void ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result);
 public ControlPropertyTemplateBinding(ControlProperty targetProperty, ControlProperty sourceProperty)
 {
     this.SourceProperty = sourceProperty;
     this.TargetProperty = targetProperty;
 }
Beispiel #32
0
 public string this[ControlProperty index]
 {
     get
     {
         return AdditionalProperties[index];
     }
     set
     {
         AdditionalProperties[index] = value;
     }
 }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            this.dgMessages.Rows.Clear();

            List <ControlProperty> contextProps = new List <ControlProperty>();
            List <string>          serviceNames = new List <string>();

            foreach (DataGridViewRow dr in this.dgProps.Rows)
            {
                if (dr.Cells[0].Value != null)
                {
                    //ControlProperty cp = new ControlProperty();
                    //cp.Namespace = (string)dr.Cells[1].Value;
                    //cp.Property = (string)dr.Cells[0].Value;
                    //cp.Value = (string)dr.Cells[2].Value;

                    //contextProps.Add(cp);
                    serviceNames.Add((string)dr.Cells[0].Value);
                }
            }

            string entityConnectionStr = String.Empty;

            this.testConnection(out entityConnectionStr, false);

            using (BizTalkDTADbEntities btsDTA = new BizTalkDTADbEntities(entityConnectionStr))
            {
                TrackingDatabase dta = new TrackingDatabase(this.txtDTAServerName.Text,
                                                            this.txtDTADBName.Text);
                BizTalkOperations operations = new BizTalkOperations(this.txtDTAServerName.Text, this.txtMgmtDBName.Text);

                var msgIds = from mioe in btsDTA.dta_MessageInOutEvents
                             join si in btsDTA.dta_ServiceInstances on mioe.uidServiceInstanceId equals si.uidServiceInstanceId
                             join s in btsDTA.dta_Services on si.uidServiceId equals s.uidServiceId
                             join pn in btsDTA.dta_PortName on mioe.nPortId equals pn.nPortId
                             join sn in btsDTA.dta_SchemaName on mioe.nSchemaId equals sn.nSchemaId
                             where mioe.dtTimestamp > this.dtFrom.Value &&
                             mioe.dtTimestamp < this.dtTo.Value &&
                             serviceNames.Contains(s.strServiceName)
                             orderby mioe.dtInsertionTimeStamp descending
                             select new tempMsgInfo
                {
                    strServiceName         = s.strServiceName
                    , uidMessageInstanceId = mioe.uidMessageInstanceId
                    , strPortName          = pn.strPortName
                    , dtTimestamp          = mioe.dtTimestamp
                    , nStatus       = mioe.nStatus
                    , strSchemaName = sn.strSchemaName
                };

                ControlProperty tempCP = contextProps.Find(cp =>
                                                           cp.Namespace == BizWTF.Core.Entities.BTSProperties.messageType.Name.Namespace
                                                           &&
                                                           cp.Property == BizWTF.Core.Entities.BTSProperties.messageType.Name.Name);
                if (tempCP != null)
                {
                    msgIds = msgIds.Where(rec => rec.strSchemaName == tempCP.Value);
                }

                /// Looping through all the messages in order to identify the one we are looking for
                foreach (var msg in msgIds.Take(Int32.Parse(this.txtMaxRecord.Text)))
                {
                    bool match = MatchingPartInfo.PerformMessageLookup(msg.uidMessageInstanceId, contextProps, new List <ControlField>(), dta, operations);

                    if (match)
                    {
                        string status = String.Empty;
                        switch (msg.nStatus)
                        {
                        case 0:
                            status = "Receive";
                            break;

                        case 1:
                            status = "Send";
                            break;

                        case 5:
                            status = "Transmission Failure";
                            break;

                        default:
                            status = "?";
                            break;
                        }
                        this.dgMessages.Rows.Add(status, msg.strServiceName, msg.strPortName, msg.strSchemaName, msg.dtTimestamp, msg.uidMessageInstanceId);
                    }
                }
            }
        }
 public ControlPropertyTemplateBinding(ControlProperty targetProperty, ControlProperty sourceProperty)
 {
     this.SourceProperty = sourceProperty;
     this.TargetProperty = targetProperty;
 }
Beispiel #35
0
 set => SetValue(ControlProperty, value);
        public ControlManifestDetails UpdatePropertyDetails(string propertyName, ControlManifestDetails controlDetails, ControlProperty property)
        {
            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(controlDetails.ManifestFilePath);

            XmlNode      propertyNode       = manifestFile.SelectSingleNode($"/manifest/control/property[@name='{propertyName}']");
            XmlAttribute attrName           = propertyNode.Attributes["name"];
            XmlAttribute attrDisplayNameKey = propertyNode.Attributes["display-name-key"];
            XmlAttribute attrDescriptionKey = propertyNode.Attributes["description-key"];
            XmlAttribute attrUsage          = propertyNode.Attributes["usage"];
            XmlAttribute attrRequired       = propertyNode.Attributes["required"];
            XmlAttribute attrOfType         = propertyNode.Attributes["of-type"];
            XmlAttribute attrOfTypeGroup    = propertyNode.Attributes["of-type-group"];

            // Update
            if (!string.IsNullOrEmpty(property.Name) && attrName != null)
            {
                attrName.Value = property.Name;
            }
            if (!string.IsNullOrEmpty(property.DisplayNameKey) && attrDisplayNameKey != null)
            {
                attrDisplayNameKey.Value = property.DisplayNameKey;
            }
            if (!string.IsNullOrEmpty(property.DescriptionNameKey) && attrDescriptionKey != null)
            {
                attrDescriptionKey.Value = property.DescriptionNameKey;
            }
            if (attrUsage != null)
            {
                attrUsage.Value = property.Usage.ToString();
            }
            if (attrRequired != null)
            {
                attrRequired.Value = property.IsRequired ? "true" : "false";
            }
            if (attrOfType != null)
            {
                if (property.IsUsingTypeGroup)
                {
                    // Change of-type ot of-type-group
                    XmlAttribute newattr = manifestFile.CreateNewAttribute("of-type-group", property.TypeOrTypeGroup);
                    propertyNode.Attributes.Append(newattr);
                    propertyNode.Attributes.Remove(attrOfType);
                }
                else
                {
                    attrOfType.Value = property.TypeOrTypeGroup;
                }
            }
            if (attrOfTypeGroup != null)
            {
                if (property.IsUsingTypeGroup)
                {
                    attrOfTypeGroup.Value = property.TypeOrTypeGroup;
                }
                else
                {
                    // Change of-type ot of-type-group
                    XmlAttribute newattr = manifestFile.CreateNewAttribute("of-type", property.TypeOrTypeGroup);
                    propertyNode.Attributes.Append(newattr);
                    propertyNode.Attributes.Remove(attrOfTypeGroup);
                }
            }

            // Update Control Manifest Details
            var updateProp = controlDetails.Properties.FirstOrDefault(p => p.Name == propertyName);

            updateProp = property;

            manifestFile.Save(controlDetails.ManifestFilePath);

            return(controlDetails);
        }
Beispiel #37
0
        public override void Save(ref ControlProperty prop)
        {
            base.Save(ref prop);

            prop.m_szTexture = Image;
        }
Beispiel #38
0
        public void Save()
        {
            if (!ResManager.Instance.Data.Apps.Keys.Contains(m_szID))
                ResManager.Instance.Data.Apps.Add(m_szID, ResManager.Instance.Data.Apps.Values.LastOrDefault()+1);
            if (!ResManager.Instance.Data.Properties.Keys.Contains(m_szID))
                ResManager.Instance.Data.Properties.Add(m_szID, new WindowProperty());
            WindowProperty prop = ResManager.Instance.Data.Properties[m_szID];
            prop.m_szID = m_szID;
            if (m_bBackgroundImage)
                prop.m_szTexture = BackgroundImage;
            else
                prop.m_szTexture = "";
            prop.m_size = m_rectBounds.Size;
            prop.m_szTitle = m_szCaption;
            prop.m_szHelp = m_szHelp;
            prop.m_style = (WindowStyle)0;
            if (m_bSizable)
                prop.m_style |= WindowStyle.WBS_THICKFRAME;
            if (m_bNoDrawFrame)
                prop.m_style |= WindowStyle.WBS_NODRAWFRAME;
            if (m_bNoFrame)
                prop.m_style |= WindowStyle.WBS_NOFRAME;
            if (m_bShowCaption)
                prop.m_style |= WindowStyle.WBS_CAPTION;
            if (m_bTopMost)
                prop.m_style |= WindowStyle.WBS_TOPMOST;
            if (m_bMovable)
                prop.m_style |= WindowStyle.WBS_MOVE;
            if (m_bPopup)
                prop.m_style |= WindowStyle.WBS_POPUP;
            if (m_bVertScrollBar)
                prop.m_style |= WindowStyle.WBS_VSCROLL;
            if (m_bHoriScrollBar)
                prop.m_style |= WindowStyle.WBS_HSCROLL;
            if (m_bgLayoutType == BGLAYOUT_TYPE.Tile)
                prop.m_bTile = 1;
            else
                prop.m_bTile = 0;
            //if (m_bNoFocus)
                //prop.style |= WindowStyle.WBS_NOFOCUS;

            prop.m_aControls.Clear();
            foreach (Control ctrl in m_children)
            {
                ControlProperty ctrlprop = new ControlProperty();
                ctrl.Save(ref ctrlprop);
                prop.m_aControls.Add(ctrl.Id, ctrlprop);
            }

            ResManager.Instance.Data.Properties[m_szID] = prop;
        }
Beispiel #39
0
 void IValuePropertyApplier.ApplyValueProperty(HtmlObject target, ControlProperty property, object value, ControlPropertyApplyResult result)
 {
     this.ApplyValueProperty(target, property, value, result);
 }
Beispiel #40
0
 public Button(ControlProperty resource)
     : base(resource)
 {
     m_szDefaultID = DefaultStrings.ButtonControl;
     if (resource.m_szTexture.Length > 3)
         Image = resource.m_szTexture;
     m_bResizable = false;
 }
Beispiel #41
0
        private void CreateSampleWorker(object[] args)
        {
            SampleUtilities.CreateUsersAndRoles();
            SampleUtilities.RegisterTheme(SamplesThemeName, SamplesThemePath);
            SampleUtilities.RegisterTemplate(new Guid(SamplesTemplateId), SamplesTemplateName, SamplesTemplateName, SamplesTemplatePath, SamplesThemeName);

            // Create Testimonials home page
            var result = SampleUtilities.CreatePage(new Guid(HomePageID), "Home", true);

            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(HomePageID), new Guid(SamplesTemplateId));

                // add welcome and instructions to page
                var generalInformationBlock = new ContentBlock();
                generalInformationBlock.Html = @"<h1>Testimonials Intra-Site Module Example</h1><p>This is the home page for the Testimonials Intra-Site module. Below is the Testimonials View Widget. It has a property to set a <a href=""testimonials"">separate page</a> for the details view.</p><p>On <a href=""testimonials"">the testimonials page</a> is a separate Testimonials View Widget that uses its own page as the details page.</p><p>This allows you to have multiple instances of the same content lists, all pointing to the same details page.</p>";

                SampleUtilities.AddControlToPage(new Guid(HomePageID), generalInformationBlock, "Content", "Content block");

                // create Testimonials View
                var mgr  = PageManager.GetManager();
                var ctrl = mgr.CreateControl <PageControl>("~/Modules/Testimonials/TestimonialsView.ascx", "Content");
                ctrl.Caption = "TestimonialsView";

                // set details page to Testimonials Page
                var prop = ctrl.Properties.FirstOrDefault(p => p.Name == "DetailsPageID");
                if (prop == null)
                {
                    prop      = new ControlProperty();
                    prop.Id   = Guid.NewGuid();
                    prop.Name = "DetailsPageID";
                    ctrl.Properties.Add(prop);
                }

                // the ID is needed for the control to be duplicated
                var idProp = ctrl.Properties.FirstOrDefault(p => p.Name == "ID");
                if (idProp == null)
                {
                    idProp      = new ControlProperty();
                    idProp.Id   = Guid.NewGuid();
                    idProp.Name = "ID";
                    ctrl.Properties.Add(idProp);
                }

                prop.Value   = TestimonialsPageID;
                idProp.Value = "TestimonialsView";

                SampleUtilities.AddControlToPage(new Guid(HomePageID), ctrl, "Content");
            }

            // Create Testimonials list/details page
            result = SampleUtilities.CreatePage(new Guid(TestimonialsPageID), "Testimonials", false);
            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(TestimonialsPageID), new Guid(SamplesTemplateId));
                SampleUtilities.AddControlToPage(new Guid(TestimonialsPageID), "~/Modules/Testimonials/TestimonialsView.ascx", "Content", "TestimonialsView");
            }

            // "Submit Testimonial" page
            result = SampleUtilities.CreatePage(new Guid(SubmitTestimonialPageID), "Submit", false);
            if (result)
            {
                SampleUtilities.SetTemplateToPage(new Guid(SubmitTestimonialPageID), new Guid(SamplesTemplateId));
                SampleUtilities.AddControlToPage(new Guid(SubmitTestimonialPageID), "~/Modules/Testimonials/SubmitTestimonial.ascx", "Content", "SubmitTestimonial");
            }

            // create sample testimonials
            var context = TestimonialsContext.Get();

            if (context.Testimonials.Count() > 0)
            {
                return;
            }

            context.Add(new Testimonial()
            {
                Name       = "John Doe",
                Rating     = 5,
                Summary    = "What a great product!",
                Text       = TESIMONIAL_TEXT,
                DatePosted = DateTime.Now,
                Published  = true,
                UrlName    = "john-doe"
            });
            context.Add(new Testimonial()
            {
                Name       = "Jane Doe",
                Rating     = 4,
                Summary    = "A solid product, almost perfect!",
                Text       = TESIMONIAL_TEXT,
                DatePosted = DateTime.Now,
                Published  = true,
                UrlName    = "jane-doe"
            });
            context.Add(new Testimonial()
            {
                Name       = "Jim Doe",
                Rating     = 3,
                Summary    = "Not bad; worth my time but could use a few more features.",
                Text       = TESIMONIAL_TEXT,
                DatePosted = DateTime.Now,
                Published  = true,
                UrlName    = "jim-doe"
            });
            context.SaveChanges();
        }