Пример #1
0
        public void Can_get_base_class_name(OwnershipTypes ownership, string expected)
        {
            var entityMetadata = new EntityMetadata
            {
                LogicalName   = "entity",
                OwnershipType = ownership
            };

            var generator = new EntityClassGenerator(entityMetadata);

            Assert.Equal("Entity", generator.GenerateBaseClassName());

            typeof(EntityMetadata).GetProperty("IsCustomEntity").SetValue(entityMetadata, true);
            Assert.Equal(expected, generator.GenerateBaseClassName());
        }
        private EntityMetadata BuildEntity()
        {
            OwnershipTypes ownerType = OwnershipTypes.UserOwned;

            if (Owner == CrmEntityOwner.Organization)
            {
                ownerType = OwnershipTypes.OrganizationOwned;
            }
            if (Owner == CrmEntityOwner.User)
            {
                ownerType = OwnershipTypes.UserOwned;
            }

            EntityMetadata entity = new EntityMetadata()
            {
                SchemaName            = Name,
                DisplayName           = new Label(DisplayName, CrmContext.Language),
                DisplayCollectionName = new Label(DisplayCollectionName, CrmContext.Language),
                Description           = new Label(Description ?? string.Empty, CrmContext.Language),
                OwnershipType         = ownerType,
                IsActivity            = IsActivity.ToBool()
            };

            if (Customizable.HasValue)
            {
                entity.IsCustomizable = new BooleanManagedProperty(Customizable.Value);
            }

            if (IsActivity)
            {
                if (ExcludeFromMenu)
                {
                    entity.ActivityTypeMask = 0;
                }
                entity.IsConnectionsEnabled = new BooleanManagedProperty(true);
                entity.IsValidForQueue      = new BooleanManagedProperty(true);
                entity.IsAvailableOffline   = true;
                entity.OwnershipType        = OwnershipTypes.UserOwned;
            }
            else
            {
                if (_context != null)
                {
                    _context.SetParametersOnEntity(entity);
                }
            }
            return(entity);
        }
Пример #3
0
 public EntityMetadataBuilder OwnershipType(OwnershipTypes ownershipType)
 {
     this.Entity.OwnershipType = ownershipType;
     return(this);
 }
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entityName">The name of the entity</param>
        /// <param name="ownership">The ownership type of the entity</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, OwnershipTypes ownership)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entityName;
            rect.Text = entityName + " ";

            // Determine the shape fill color based on entity ownership.
            string fillColor;

            // Update the style of the entity name
            VisioApi.Characters characters = rect.Characters;
            characters.Begin = 0;
            characters.End   = entityName.Length;
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE);
            //set the font family of the text to segoe for the visio 2013.
            if (VersionName == "15.0")
            {
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE);
            }

            switch (ownership)
            {
            case OwnershipTypes.BusinessOwned:
                fillColor = "RGB(255,140,0)";                                                                                          // orange
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); // set the font color of the text
                break;

            case OwnershipTypes.OrganizationOwned:
                fillColor = "RGB(127, 186, 0)";                                                                                        // green
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack); // set the font color of the text
                break;

            case OwnershipTypes.UserOwned:
                fillColor = "RGB(0,24,143)";                                                                                           // blue
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visWhite); // set the font color of the text
                break;

            default:
                fillColor = "RGB(255,255,255)";                                                                                           // White
                characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue); // set the font color of the text
                break;
            }

            // Set the fill color, placement properties, and line weight of the shape.
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).FormulaU     = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor;
            return(rect);
        }
Пример #5
0
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entityName">The name of the entity</param>
        /// <param name="ownership">The ownership type of the entity</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, OwnershipTypes ownership)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entityName;
            rect.Text = entityName + " ";

            // Determine the shape fill color based on entity ownership.
            string fillColor;

            // Update the style of the entity name
            VisioApi.Characters characters = rect.Characters;
            characters.Begin = 0;
            characters.End = entityName.Length;
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE);
            //set the font family of the text to segoe for the visio 2013.
            if (VersionName == "15.0")
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterFont, (short)FONT_STYLE); 
          
            switch (ownership)
            {
                case OwnershipTypes.BusinessOwned:                   
                    fillColor = "RGB(255,140,0)"; // orange
                    characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack);// set the font color of the text
                    break;
                case OwnershipTypes.OrganizationOwned:                    
                    fillColor = "RGB(127, 186, 0)"; // green
                    characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visBlack);// set the font color of the text
                    break;
                case OwnershipTypes.UserOwned:                    
                    fillColor = "RGB(0,24,143)"; // blue 
                    characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visWhite);// set the font color of the text
                    break;
                default:
                    fillColor = "RGB(255,255,255)"; // White
                    characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue);// set the font color of the text
                    break;
            }

            // Set the fill color, placement properties, and line weight of the shape.
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).FormulaU = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).FormulaU = fillColor;            
            return rect;
        }
Пример #6
0
 public Ownership(string userName, string fullName, OwnershipTypes ownerType)
 {
     UserName  = userName;
     FullName  = fullName;
     OwnerType = ownerType;
 }
Пример #7
0
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entityName">The name of the entity</param>
        /// <param name="ownership">The ownership type of the entity</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, OwnershipTypes ownership)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entityName;
            rect.Text = entityName + " ";

            //// Determine the shape fill color based on entity ownership.
            //string fillColor;

            //switch (ownership)
            //{
            //    case OwnershipTypes.BusinessOwned:
            //        fillColor = "RGB(255,202,176)"; // Light orange
            //        break;
            //    case OwnershipTypes.OrganizationOwned:
            //        fillColor = "RGB(255,255,176)"; // Light yellow
            //        break;
            //    case OwnershipTypes.UserOwned:
            //        fillColor = "RGB(204,255,204)"; // Light green
            //        break;
            //    default:
            //        fillColor = "RGB(255,255,255)"; // White
            //        break;
            //}

            // Set the fill color, placement properties, and line weight of the shape.
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).Formula = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            //rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).Formula = fillColor;
            // Update the style of the entity name
            VisioApi.Characters characters = rect.Characters;
            characters.Begin = 0;
            characters.End = entityName.Length;
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE);

            return rect;
        }
Пример #8
0
        /// <summary>
        /// Draw an "Entity" Rectangle
        /// </summary>
        /// <param name="page">The Page on which to draw</param>
        /// <param name="entityName">The name of the entity</param>
        /// <param name="ownership">The ownership type of the entity</param>
        /// <returns>The newly drawn rectangle</returns>
        private VisioApi.Shape DrawEntityRectangle(VisioApi.Page page, string entityName, OwnershipTypes ownership)
        {
            VisioApi.Shape rect = page.DrawRectangle(X_POS1, Y_POS1, X_POS2, Y_POS2);
            rect.Name = entityName;
            rect.Text = entityName + " ";

            //// Determine the shape fill color based on entity ownership.
            //string fillColor;

            //switch (ownership)
            //{
            //    case OwnershipTypes.BusinessOwned:
            //        fillColor = "RGB(255,202,176)"; // Light orange
            //        break;
            //    case OwnershipTypes.OrganizationOwned:
            //        fillColor = "RGB(255,255,176)"; // Light yellow
            //        break;
            //    case OwnershipTypes.UserOwned:
            //        fillColor = "RGB(204,255,204)"; // Light green
            //        break;
            //    default:
            //        fillColor = "RGB(255,255,255)"; // White
            //        break;
            //}

            // Set the fill color, placement properties, and line weight of the shape.
            rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowMisc, (short)VisioApi.VisCellIndices.visLOFlags).Formula = ((int)VisioApi.VisCellVals.visLOFlagsPlacable).ToString();
            //rect.get_CellsSRC(VISIO_SECTION_OJBECT_INDEX, (short)VisioApi.VisRowIndices.visRowFill, (short)VisioApi.VisCellIndices.visFillForegnd).Formula = fillColor;
            // Update the style of the entity name
            VisioApi.Characters characters = rect.Characters;
            characters.Begin = 0;
            characters.End   = entityName.Length;
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterStyle, (short)VisioApi.VisCellVals.visBold);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterColor, (short)VisioApi.VisDefaultColors.visDarkBlue);
            characters.set_CharProps((short)VisioApi.VisCellIndices.visCharacterSize, NAME_CHARACTER_SIZE);

            return(rect);
        }
Пример #9
0
 public EntityMetadataBuilder OwnershipType(OwnershipTypes ownershipType)
 {
     this.Entity.OwnershipType = ownershipType;
     return this;
 }