public static void InvokeTemplateDeleted(TemplateProfile profile, Template template)
		{
			if (profile != null && !profile.Deleted && template != null && OnTemplateDeleted != null)
			{
				OnTemplateDeleted(profile, template);
			}
		}
		public static void InvokeTemplateSelected(TemplateProfile profile, Template oldTemplate)
		{
			if (profile != null && !profile.Deleted && OnTemplateSelected != null)
			{
				OnTemplateSelected(profile, oldTemplate);
			}
		}
		public static void InvokeProfileDeleted(TemplateProfile profile)
		{
			if (profile != null && profile.Deleted && OnProfileDeleted != null)
			{
				OnProfileDeleted(profile);
			}
		}
		public static TemplateProfile FetchProfile(PlayerMobile pm, bool replace = false)
		{
			if(pm == null)
			{
				return null;
			}

			if(!Templates.ContainsKey(pm))
			{
				Templates.Add(pm, new TemplateProfile(pm));
			}
			else if(replace || Templates[pm] == null)
			{
				Templates[pm] = new TemplateProfile(pm);
			}

			return Templates[pm];
		}
        public ManageTemplateGump(PlayerMobile user, Gump parent = null, TemplateProfile profile = null,
            Template edit = null)
            : base(user, parent, null, null, null, null, 7020)
        {
            Profile = profile ?? PvPTemplates.FetchProfile(user);

            Modal = true;
            ForceRecompile = true;

            if(LockMode)
            {
                return;
            }

            if(edit == null || !Profile.Contains(edit))
            {
                Title = "Create Template";

                TemplateName = "New Template";
                TemplateNotes = "Description/Notes";

                TemplateSkills = new SkillName[0];

                TemplateStr = TemplateDex = TemplateInt = 0;
            }
            else
            {
                Title = "Edit Template";

                Template = edit;

                TemplateName = Template.Name;
                TemplateNotes = Template.Notes;

                TemplateSkills = Template.GetActiveSkills().ToArray();

                TemplateStr = Template.Stats[StatType.Str];
                TemplateDex = Template.Stats[StatType.Dex];
                TemplateInt = Template.Stats[StatType.Int];
            }
        }
Exemple #6
0
        // Configure Mapper
        protected override void Configure()
        {
            #region CodeSet
            CreateMap <CodeSet, Contracts.Administration.DTO.CodeSetAdmin.CodeSet>();
            #endregion

            #region Code
            CreateMap <CodeDetails, Code>()
            .AfterMap((dto, code) => code.SetLifetime(dto.ActiveOn, dto.InactiveAfter));
            CreateMap <Code, Contracts.Administration.DTO.CodeSetAdmin.Code>();
            #endregion

            #region Ucr and Violation Code

            CreateMap <UcrCode, UcrCodeDetails>();
            CreateMap <UcrCodeDetails, UcrCode>();
            CreateMap <UcrCodeDetails, UCRCodeReference>();

            CreateMap <ViolationCode, ViolationCodeDetails>();
            CreateMap <ViolationCodeDetails, ViolationCode>();

            #endregion

            #region NCICCode

            CreateMap <NCICCode, NCICCodeDetails>();
            CreateMap <NCICCodeDetails, NCICCode>();

            #endregion

            #region ImageInfo

            CreateMap <ImageInfo, ImageInfoDetails>();
            CreateMap <ImageInfoDetails, ImageInfo>();

            #endregion

            #region ContactInfo

            CreateMap <ContactInfo, Domain.Administration.ValueObjects.ContactInfo>();
            CreateMap <Domain.Administration.ValueObjects.ContactInfo, ContactInfo>();
            #endregion

            #region Role
            CreateMap <RoleDetails, Role>().IgnorePrivateAndProtectedSetters();
            CreateMap <Role, Contracts.Administration.DTO.RoleAdmin.Role>()
            .IgnorePrivateAndProtectedSetters()
            .ForMember(d => d.ModulePermissions, o => o
                       .MapFrom(s => s.ModulePermissions.ToDictionary(permission => permission.ModuleType, permission => permission.Permissions)));
            #endregion

            #region Permissions
            CreateMap <ModulePermissions, Domain.Administration.Aggregates.Agency.ValueObjects.ModulePermissions>().ReverseMap();
            CreateMap <AgencyPermissions, Domain.Administration.Aggregates.Agency.ValueObjects.AgencyPermissions>().ReverseMap();
            #endregion

            #region User

            // Map User Details into a User Entity. Also map User details into the Officer Entity
            CreateMap <UserDetails, User>()
            .IgnorePrivateAndProtectedSetters()
            .AfterMap((details, user) => { if (user.AgencyOfficer != null)
                                           {
                                               details.MapInto(user.AgencyOfficer);
                                           }
                      });

            // Map User Details into an Officer Entity.
            CreateMap <UserDetails, Officer>()
            .ForMember(d => d.Name, o => o.MapFrom(s => CommonFormats.FullName(s.LastName, s.FirstName, s.MiddleName, null)))
            .IgnorePrivateAndProtectedSetters();

            // Map User Information into a User DTO.
            // Also Map Officer information into the User DTO.
            CreateMap <User, Contracts.Administration.DTO.UserAdmin.User>()
            .BeforeMap((user, dto) => user.AgencyOfficer.MapInto(dto))     // Map Officer Information
            .ForMember(d => d.Roles,
                       o => o.MapFrom(s => s.AssignedRoles
                                      .Select(x => x.Role)
                                      .Select(Projections.Role.Reference)
                                      .ToList()));

            // Map Officer Information into a User DTO.
            CreateMap <Officer, Contracts.Administration.DTO.UserAdmin.User>();


            // Map Classic User Details into a User Entity. Also map User details into the Officer Entity
            CreateMap <ClassicUser, User>()
            .IgnorePrivateAndProtectedSetters()
            .AfterMap((details, user) => { if (user.AgencyOfficer != null)
                                           {
                                               details.MapInto(user.AgencyOfficer);
                                           }
                      });

            // Map Classic User Details into an Officer Entity.
            CreateMap <ClassicUser, Officer>()
            .ForMember(d => d.Name, o => o.MapFrom(s => CommonFormats.FullName(s.LastName, s.FirstName, s.MiddleName, null)))
            .IgnorePrivateAndProtectedSetters();
            #endregion

            #region Officer

            CreateMap <Officer, Contracts.Administration.DTO.CodeSetAdmin.Code>()
            .ForMember(x => x.Value, o => o.MapFrom(s => s.OfficerId))
            .ForMember(x => x.Description, o => o.MapFrom(s => string.IsNullOrWhiteSpace(s.OfficerId) ? s.Name : string.Concat(s.Name, " ", s.OfficerId)));


            #endregion

            #region Queue

            // Queue is the Entity
            CreateMap <Queue, Contracts.Administration.DTO.UserAdmin.Queue>();
            CreateMap <QueueDetails, Queue>();

            // TODO: Style should be a value object.
            CreateMap <QueueStyle, Contracts.Administration.DTO.UserAdmin.QueueStyle>().ReverseMap();

            // Queue Configuration is a Value Object of the Queue Entity
            CreateMap <QueueConfiguration, Contracts.Administration.DTO.UserAdmin.QueueConfiguration>()
            .ForMember(d => d.Columns, o => o.MapFrom(s => s.ToList()));
            // Construct a New Value
            CreateMap <Contracts.Administration.DTO.UserAdmin.QueueConfiguration, QueueConfiguration>()
            .AfterMap((configuration, queueConfiguration) =>
            {
                queueConfiguration.Clear();
                configuration.Columns.AsListOf <QueueColumn>().ForEach(queueConfiguration.Add);
            });

            // QueueColumn is a Value Object
            CreateMap <QueueColumn, Contracts.Administration.DTO.UserAdmin.QueueColumn>();

            // Construct a New Value
            CreateMap <Contracts.Administration.DTO.UserAdmin.QueueColumn, QueueColumn>()
            .ConstructUsing(col => new QueueColumn(col.Field, col.Title, col.Hidden, col.Width));

            #endregion

            #region Templates
            TemplateProfile.Load(this);
            #endregion

            #region Workflow
            CreateMap <WorkflowDetails, Workflow>();
            CreateMap <Workflow, Contracts.Administration.DTO.WorkflowAdmin.Workflow>();

            CreateMap <Workflow, WorkflowReference>();

            #region Activity to DTO

            CreateMap <Workflow, Contracts.Administration.DTO.WorkflowAdmin.Workflow>()
            .ForMember(dto => dto.Activities, exp => exp.MapFrom(act => Deserialize(act.Xaml)));

            CreateMap <Activity, IActivity>()
            .Include <Submit, Contracts.Administration.DTO.WorkflowAdmin.Submit>()
            .Include <Review, Contracts.Administration.DTO.WorkflowAdmin.Review>()
            .Include <Notify, Contracts.Administration.DTO.WorkflowAdmin.Notify>()
            .ForMember(dto => dto.Text, exp => exp.MapFrom(a => a.DisplayName));

            CreateMap <Submit, Contracts.Administration.DTO.WorkflowAdmin.Submit>();
            CreateMap <Review, Contracts.Administration.DTO.WorkflowAdmin.Review>();
            CreateMap <Notify, Contracts.Administration.DTO.WorkflowAdmin.Notify>();

            #endregion

            #region DTO to Activity

            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Workflow, Workflow>()
            .ForMember(workflow => workflow.Xaml, o => o.MapFrom(dto => ConstructActivitySequenceXaml(dto.Activities)));

            Mapper.CreateMap <IActivity, Activity>()
            .Include <Contracts.Administration.DTO.WorkflowAdmin.Submit, Submit>()
            .Include <Contracts.Administration.DTO.WorkflowAdmin.Review, Review>()
            .Include <Contracts.Administration.DTO.WorkflowAdmin.Notify, Notify>()
            .ForMember(act => act.DisplayName, exp => exp.MapFrom(dto => dto.Text));

            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Submit, Submit>();
            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Review, Review>();
            Mapper.CreateMap <Contracts.Administration.DTO.WorkflowAdmin.Notify, Notify>();

            #endregion

            #endregion

            #region Agency

            CreateMap <Agency, AgencyReference>()
            .ConvertUsing(Projections.Agency.ToReference);

            CreateMap <AgencyReference, Contracts.Administration.DTO.CodeSetAdmin.Code>()
            .ForMember(x => x.Value, o => o.MapFrom(s => s.Ori))
            .ForMember(x => x.Description, o => o.MapFrom(s => s.Name));

            #endregion

            #region AgencySettings

            CreateMap <SettingValue, AgencySetting>();

            #endregion

            #region AgencyConfiguration

            #region Smtp
            CreateMap <SmtpConfiguration, Domain.Administration.Aggregates.Agency.ValueObjects.SmtpConfiguration>();
            CreateMap <Domain.Administration.Aggregates.Agency.ValueObjects.SmtpConfiguration, SmtpConfiguration>();
            #endregion

            #region Geo
            CreateMap <GeoConfiguration, Domain.Administration.Aggregates.Agency.ValueObjects.GeoConfiguration>();
            CreateMap <Domain.Administration.Aggregates.Agency.ValueObjects.GeoConfiguration, GeoConfiguration>();
            #endregion

            #region AgencyConfig

            CreateMap <Domain.Administration.Aggregates.Agency.AgencyConfiguration, Contracts.Administration.DTO.AgencyAdmin.AgencyConfiguration>();
            CreateMap <Contracts.Administration.DTO.AgencyAdmin.AgencyConfiguration, Domain.Administration.Aggregates.Agency.AgencyConfiguration>();
            #endregion


            #region Password

            CreateMap <PasswordConfiguration, Domain.Administration.Aggregates.Agency.ValueObjects.PasswordConfiguration>();
            CreateMap <Domain.Administration.Aggregates.Agency.ValueObjects.PasswordConfiguration, PasswordConfiguration>();
            #endregion

            CreateMap <TemplateReference, Template>();
            CreateMap <Template, TemplateReference>();
            #endregion

            #region QueryConfiguration

            CreateMap <Contracts.Administration.DTO.QueryAdmin.QueryConfiguration, Domain.Administration.Aggregates.Agency.QueryConfiguration>();
            CreateMap <Contracts.Query.DTO.QueryCategory, Domain.Administration.Aggregates.Agency.QueryCategory>();

            #endregion

            this.ConfigureFromAssembly();
        }
		private static bool DeserializeTemplates(GenericReader reader)
		{
			int version = reader.GetVersion();

			switch (version)
			{
				case 0:
					{
						reader.ReadBlockDictionary(
							() =>
							{
								var key = reader.ReadMobile<PlayerMobile>();
								var val = new TemplateProfile(reader);
								return new KeyValuePair<PlayerMobile, TemplateProfile>(key, val);
							},
							Templates);
					}
					break;
			}

			return true;
		}