Beispiel #1
0
 /// <summary>
 /// Constructor of the Party class.
 /// </summary>
 /// <param name="grid">Reference to the HexGrid class.</param>
 public Party (HexGrid grid, PartyManager manager)
 {
   PartyId = parties++;
   _grid = grid;
   _partyManager = manager;
   _hexes = new List<AxialCoordinate>(); 
   _partyColor = new Color(Random.Range(0.1f, 0.6f), Random.Range(0.1f, 0.6f), Random.Range(0.1f, 0.6f));
 }
 void Start() 
 {
   _path = new HexPathFinding(grid);
   _partyManager = new PartyManager(grid, _path, ui, AmountOfParties);
   
   grid.CreateGrid();
   // _partyManager.SpawnParties();
 }
        public void onEntityDeathMonitor(EventEntityDeath evt)
        {
            if (!evt.getUnit().GetType().Equals(typeof(HumanEntity)))
            {
                if (BattleManager.EnemyCount <= 0 && BattleManager.isFighting)
                {
                    BattleManager.Reward();
                    BattleManager.isBattleOver = true;
                }
                if (BattleManager.EnemyCount > 0)
                {
                    BattleManager.EnemyCount--;
                }
            }
            else
            {
                HumanEntity bandit = (HumanEntity)evt.getUnit();

                if (PartyManager.draftees.Exists(x => x.uName == evt.getUnit().unitName))
                {

                    if (bandit.getProfession().getProfessionName() != "Bandit")
                    {
                        if (PartyManager.draftees.Find(x => x.uName == evt.getUnit().unitName).isEnlisted)
                        {
                            if (PartyManager.PartySize > 0)
                            {
                                PartyManager.PartySize--;
                            }
                        }
                        PartyManager.draftees.Remove(PartyManager.draftees.Find(x => x.uName == evt.getUnit().unitName));
                        if (BattleManager.isInTown)
                        {
                            PartyManager partyManager = new PartyManager();
                            partyManager.ManageParty(2);
                        }
                    }
                    else
                    {
                        evt.getUnit().Destroy();
                    }
                }
                else
                {
                    evt.getUnit().Destroy();
                }
            }

            if (MessengerManager.messengerEntity != null)
            {
                if (evt.getUnit().unitName == MessengerManager.messengerEntity.unitName)
                {
                    evt.getUnit().Destroy();
                }
            }
        }
Beispiel #4
0
        public ActionResult View(int id)
        {
            PartyManager     partyManager     = null;
            PartyTypeManager partyTypeManager = null;

            try
            {
                partyManager     = new PartyManager();
                partyTypeManager = new PartyTypeManager();
                ViewBag.Title    = PresentationModel.GetGenericViewTitle("View Party");
                var model = new PartyModel();
                model.PartyTypeList      = partyTypeManager.PartyTypeRepository.Get().ToList();
                model.PartyRelationships = getPartyRelationships(id);
                Party party = partyManager.PartyRepository.Get(id);
                model.Description = party.Description;
                model.PartyType   = party.PartyType;
                model.Id          = party.Id;
                model.Name        = party.Name;
                if (party.StartDate == DateTime.MinValue)
                {
                    model.StartDate = null;
                }
                else
                {
                    model.StartDate = party.StartDate;
                }
                if (party.EndDate.Date == DateTime.MaxValue.Date)
                {
                    model.EndDate = null;
                }
                else
                {
                    model.EndDate = party.EndDate;
                }
                ViewBag.Title = "View party";
                return(View(model));
            }
            finally
            {
                partyManager?.Dispose();
                partyTypeManager?.Dispose();
            }
        }
Beispiel #5
0
        public string DeletePartyRelationship(int id)
        {
            PartyManager partyManager = null;

            try
            {
                partyManager = new PartyManager();
                partyManager.RemovePartyRelationship(partyManager.PartyRelationshipRepository.Get(id));
                return("successfull");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            finally
            {
                partyManager?.Dispose();
            }
        }
Beispiel #6
0
    private void Awake()
    {
        #region DontDestroyOnLoad
        //Prexisting GameManager check
        //if (GameObject.FindGameObjectWithTag("GameManager") != null)
        //{
        //    Destroy(this);
        //}
        //else
        //{
        //    DontDestroyOnLoad(this);
        //}
        #endregion

        partyManager = FindOrCreateObjectWithTagAndType("PartyManager", typeof(PartyManager))
                       .GetComponent <PartyManager>();
        dungeonManager = FindOrCreateObjectWithTagAndType("DungeonManager", typeof(DungeonManager))
                         .GetComponent <DungeonManager>();
    }
Beispiel #7
0
        public ActionResult customizeGridColumns(IEnumerable <PartyCustomGridColumns> partyCustomGridColumns)
        {
            PartyManager partyManager   = null;
            String       partytypeTitle = "";

            try
            {
                partyManager = new PartyManager();
                partyManager.UpdatePartyGridCustomColumns(partyCustomGridColumns);

                partytypeTitle = partyManager.PartyCustomGridColumnsRepository.Get(partyCustomGridColumns.First().Id).CustomAttribute.PartyType.Title;
            }
            finally
            {
                partyManager?.Dispose();
            }

            return(RedirectToAction("Index", new { partyTypeTitle = partytypeTitle }));
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">party id</param>
        /// <returns></returns>
        public ActionResult LoadPartyRelationships(int id)
        {
            PartyManager partyManager = null;

            try
            {
                partyManager = new PartyManager();
                var   model = new PartyModel();
                Party party = partyManager.PartyRepository.Get(id);
                model.Description = party.Description;
                model.EndDate     = party.EndDate;
                model.Id          = party.Id;
                model.PartyType   = party.PartyType;
                model.StartDate   = party.StartDate;
                model.Name        = party.Name;
                return(PartialView("~/Areas/BAM/Views/PartyService/_partyRelationshipsPartial.cshtml", model));
            }
            finally { partyManager?.Dispose(); }
        }
Beispiel #9
0
    // Start is called before the first frame update
    void Start()
    {
        // Instantiate all essential objects
        if (PlayerControl.selfReference == null)
        {
            PlayerControl clone = Instantiate(player).GetComponent <PlayerControl>();
            PlayerControl.selfReference = clone;
        }

        if (FadeTransition.selfReference == null)
        {
            FadeTransition clone = Instantiate(canvas).GetComponent <FadeTransition>();
            FadeTransition.selfReference = clone;
        }

        if (PartyManager.selfReference == null)
        {
            PartyManager clone = Instantiate(partyManager).GetComponent <PartyManager>();
            PartyManager.selfReference = clone;
        }

        if (GameManager.selfReference == null)
        {
            GameManager clone = Instantiate(gameManager).GetComponent <GameManager>();
            GameManager.selfReference = clone;
        }

        if (AudioManager.selfReference == null)
        {
            AudioManager clone = Instantiate(audioManager).GetComponent <AudioManager>();
            AudioManager.selfReference = clone;
        }

        if (BattleManager.selfReference == null)
        {
            BattleManager clone = Instantiate(battleManager).GetComponent <BattleManager>();
            BattleManager.selfReference = clone;
        }

        // For testing
        PlayerControl.selfReference.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, PlayerControl.selfReference.transform.position.z);
    }
Beispiel #10
0
        public void AddPartyRelationshipTest()
        {
            PartyManager     partyManager     = new PartyManager();
            PartyTypeManager partyTypeManager = new PartyTypeManager();
            var partyStatusTypes = new List <PartyStatusType>();

            partyStatusTypes.Add(new PartyStatusType()
            {
                Name = "Created", Description = ""
            });
            var partyTypeTest   = partyTypeManager.Create("partyTypeTitle", "", "", partyStatusTypes);
            var partyTypeTest2  = partyTypeManager.Create("partyTypeTitle2", "", "", partyStatusTypes);
            var partyStatusType = partyTypeManager.GetStatusType(partyTypeTest, "Created");
            //create cstom attributes
            var partyCustomAttribute1 = partyTypeManager.CreatePartyCustomAttribute(partyTypeTest, "String", "FirstName", "", "", "", isMain: true);
            var partyCustomAttribute2 = partyTypeManager.CreatePartyCustomAttribute(partyTypeTest, "String", "LastName", "", "", "", isMain: true);
            var partyCustomAttribute3 = partyTypeManager.CreatePartyCustomAttribute(partyTypeTest, "Int", "Age", "", "", "");
            //create with CustomAttributeValues<Id,value>
            Dictionary <long, String> customAttributeValues = new Dictionary <long, string>();

            customAttributeValues.Add(partyCustomAttribute1.Id, "Masoud");
            customAttributeValues.Add(partyCustomAttribute2.Id, "Allahyari");
            customAttributeValues.Add(partyCustomAttribute3.Id, "31");
            var party = partyManager.Create(partyTypeTest2, "description test", DateTime.Now.AddDays(-10), DateTime.Now.AddDays(10), customAttributeValues);

            //create with CustomAttributeValues<Id,value>
            customAttributeValues = new Dictionary <long, string>();
            customAttributeValues.Add(partyCustomAttribute1.Id, "Ali");
            customAttributeValues.Add(partyCustomAttribute2.Id, "Wandern");
            customAttributeValues.Add(partyCustomAttribute3.Id, "37");
            var party2 = partyManager.Create(partyTypeTest, "description test", DateTime.Now.AddDays(-10), DateTime.Now.AddDays(10), customAttributeValues);

            //party type pair
            var prtManager = new PartyRelationshipTypeManager();

            prtManager.Create("relationship test", "", "", true, 10, 0, true, partyTypeTest, partyTypeTest2, "type pair test", "", "", "", 0);

            // partyManager.AddPartyRelationship(party,party2,"relation test","",)
            //add relationship

            //test maximun and minimum cardinality
        }
Beispiel #11
0
        public static void StartDungeon(Client client, string param1, string param2, string param3)
        {
            if (client.Player.PartyID == null)
            {
                StartDungeonSolo(client, param1, param2, param3);
            }
            else
            {
                //StartDungeonSolo(client, param1, param2, param3);

                bool  ready = true;
                Party party = PartyManager.FindPlayerParty(client);
                foreach (string charID in party.GetMemberCharacters())
                {
                    Client member = ClientManager.FindClientFromCharID(charID);
                    if (member != client && (member == null || member.Player.QuestionID != ("PartyDungeon|" + param1 + "|" + param2 + "|" + param3)))
                    {
                        ready = false;
                    }
                }

                if (ready)
                {
                    List <Client> members = new List <Client>();
                    foreach (Client member in party.GetOnlineMemberClients())
                    {
                        members.Add(member);
                    }

                    foreach (Client member in members)
                    {
                        StartDungeonSolo(member, param1, param2, param3);
                        Messenger.ForceEndStoryTo(member);
                    }
                }
                else
                {
                    AskDungeonCancelQuestion(client, param1, param2, param3);
                }
            }
        }
Beispiel #12
0
        public override void OnStart()
        {
            TimeManager.ResumeTime();

            ResetFields();

            inventoryInputManager = FindObjectOfType <InventoryInputManager>();
            generator             = FindObjectOfType <BattleGenerator>();
            _sortingCalculator    = FindObjectOfType <SortingCalculator>();

            BattleEvents.NormalEvent.AddListener(this);
            BattleEvents.EndOfTurnEvent.AddListener(this);
            BattleEvents.SkipTurnEvent.AddListener(this);

            canGiveCommand = true;
            roundCount     = 0;

            AudioController.PlayAudio(CommonAudioTypes.MainBattleTheme, true, 2);
            PartyManager.Order();
            Timing.RunCoroutine(SetupBattle());
        }
Beispiel #13
0
        public ActionResult ViewPartyDetail(int id)
        {
            using (PartyManager partyManager = new PartyManager())
                using (PartyTypeManager partyTypeManager = new PartyTypeManager())
                {
                    ViewBag.Title = PresentationModel.GetGenericViewTitle("View Party");
                    var model = new PartyModel();
                    model.PartyTypeList      = partyTypeManager.PartyTypeRepository.Get().ToList();
                    model.PartyRelationships = getPartyRelationships(id);

                    Party party = partyManager.PartyRepository.Get(id);
                    model.Description = party.Description;
                    model.EndDate     = party.EndDate;
                    model.Id          = party.Id;
                    model.PartyType   = party.PartyType;
                    model.StartDate   = party.StartDate;
                    model.ViewMode    = true;
                    model.Name        = party.Name;
                    return(PartialView("View", model));
                }
        }
    public void Start()
    {
        _items        = GetComponentInChildren <InventoryPresenter>();
        _interface    = GetComponentInChildren <PauseInterface>();
        _presenter    = GetComponentInChildren <PausePresenter>();
        _settings     = GetComponentInChildren <SettingsPresenter>();
        _member       = GetComponentInChildren <MemberStatPresenter>();
        _equipment    = GetComponentInChildren <EquipmentPresenter>();
        _magic        = GetComponentInChildren <MagicPresenter>();
        _memberSelect = GetComponentInChildren <MemberSelectPresenter>();

        _party     = PartyManager.Instance;
        _controls  = ControlManager.Instance;
        _inventory = InventoryManager.Instance;

        if (_interface == null)
        {
            DebugMessage("Could not find a Pause Interface in the children of " + gameObject.name + "!", LogLevel.Warning);
        }

        if (_presenter == null)
        {
            DebugMessage("Could not find a Pause Presenter in the children of " + gameObject.name + "!", LogLevel.Warning);
        }

        if (_settings == null)
        {
            DebugMessage("Could not find a Settings Presenter in the children of " + gameObject.name + "!", LogLevel.Warning);
        }

        if (_equipment == null)
        {
            DebugMessage("Could not find an Equipment Presenter in the children of " + gameObject.name + "!", LogLevel.Warning);
        }

        if (_magic == null)
        {
            DebugMessage("Could not find an Magic Presenter in the children of " + gameObject.name + "!", LogLevel.Warning);
        }
    }
Beispiel #15
0
        public ActionResult Edit(PartyModel partyModel, Dictionary <string, string> partyCustomAttributeValues)
        {
            var          party        = new Party();
            PartyManager partyManager = null;
            UserManager  userManager  = null;

            try
            {
                partyManager = new PartyManager();
                userManager  = new UserManager();
                if (!HttpContext.User.Identity.IsAuthenticated)
                {
                    return(RedirectToAction("Index", "Home"));
                }


                var userTask = userManager.FindByNameAsync(HttpContext.User.Identity.Name);
                userTask.Wait();
                var user      = userTask.Result;
                var userParty = partyManager.GetPartyByUser(user.Id);
                if (userParty.Id != partyModel.Id)
                {
                    throw new Exception("Permission denide.");
                }
                if (partyModel.Id == 0)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    party = Helpers.Helper.EditParty(partyModel, partyCustomAttributeValues);
                }
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
            finally
            {
                partyManager?.Dispose();
                userManager?.Dispose();
            }
        }
 private void OnQuery_JOIN()
 {
     GameSection.StayEvent();
     MonoBehaviourSingleton <GuildManager> .I.SendRequestJoin(_clanId, -1, delegate(bool isSuccess, Error error)
     {
         GuildInvitedJoinDialog guildInvitedJoinDialog = this;
         DoWaitProtocolBusyFinish(delegate
         {
             if (!GuildManager.IsValidInGuild())
             {
                 GameSection.ChangeStayEvent("REQUEST", null);
             }
             GameSection.ResumeEvent(isSuccess, null);
             MonoBehaviourSingleton <GuildManager> .I.guildInviteList.Clear();
             if (!PartyManager.IsValidNotEmptyList())
             {
                 MonoBehaviourSingleton <UserInfoManager> .I.ClearPartyInvite();
                 MonoBehaviourSingleton <UIManager> .I.invitationButton.Close(UITransition.TYPE.CLOSE);
             }
         });
     });
 }
Beispiel #17
0
        public ActionResult LoadParties(string party_types = "")
        {
            PartyManager partyManager = null;

            try
            {
                var partyTypes = party_types.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                partyManager = new PartyManager();
                //When telerik grid is client based, it's not able to load lazy list and circular dependencies errors
                var partiesForGrid = new List <partyGridModel>();
                if (partyTypes.Any())
                {
                    // var childPartyTypes = new PartyRelationshipTypeManager().GetChildPartyTypes(id);
                    foreach (Party party in partyManager.PartyRepository.Get(cc => partyTypes.Contains(cc.PartyType.Title)))//childPartyTypes.Contains(c.PartyType)))
                    {
                        partiesForGrid.Add(new partyGridModel()
                        {
                            Id = party.Id, Name = party.Name, PartyTypeTitle = party.PartyType.DisplayName, StartDate = (party.StartDate != null && party.StartDate < new DateTime(1000, 1, 1) ? "" : party.StartDate.ToShortDateString()), EndDate = (party.EndDate != null && party.EndDate > new DateTime(3000, 1, 1) ? "" : party.EndDate.ToShortDateString()), IsTemp = party.IsTemp
                        });
                    }
                }
                else
                {
                    foreach (Party party in partyManager.PartyRepository.Get())
                    {
                        partiesForGrid.Add(new partyGridModel()
                        {
                            Id = party.Id, Name = party.Name, PartyTypeTitle = party.PartyType.DisplayName, StartDate = (party.StartDate != null && party.StartDate < new DateTime(1000, 1, 1) ? "" : party.StartDate.ToShortDateString()), EndDate = (party.EndDate != null && party.EndDate > new DateTime(3000, 1, 1) ? "" : party.EndDate.ToShortDateString()), IsTemp = party.IsTemp
                        });
                    }
                }
                return(PartialView("_partiesPartial", partiesForGrid.OrderByDescending(cc => cc.IsTemp).ThenByDescending(cc => cc.StartDate).ThenBy(cc => cc.Name).ToList()));
            }
            finally
            {
                partyManager?.Dispose();
            }
        }
Beispiel #18
0
 public ActionResult LoadCustomGridColumns(string partyTypeTitle)
 {
     using (PartyManager partyManager = new PartyManager())
         using (PartyTypeManager partyTypeManager = new PartyTypeManager())
         {
             var partyType = partyTypeManager.PartyTypeRepository.Get(cc => cc.Title.Equals(partyTypeTitle)).FirstOrDefault();
             var partyCustomGridColumns = partyManager.GetPartyCustomGridColumns(partyType.Id, all: true);
             //To avoid NHibernate.LazyInitializationException in view
             //Todo: Finding a good soloution
             foreach (var partyCustomGridColumn in partyCustomGridColumns)
             {
                 if (partyCustomGridColumn.CustomAttribute != null)
                 {
                     partyCustomGridColumn.CustomAttribute.DisplayName = partyCustomGridColumn.CustomAttribute.DisplayName;
                 }
                 else
                 {
                     partyCustomGridColumn.TypePair.Title = partyCustomGridColumn.TypePair.Title;
                 }
             }
             return(PartialView("_partyGridFields", partyCustomGridColumns.ToList()));
         }
 }
Beispiel #19
0
        public async Task CPartyDelUser(GSSession session, CPartyDelUser message)
        {
            var party = session.Player.Character.Party;

            if (party == null)
            {
                return;
            }

            var memb = party.Members.ElementAtOrDefault(message.Index);

            if (memb == null)
            {
                return;
            }

            if (memb != party.Master && memb != session.Player)
            {
                return;
            }

            PartyManager.Remove(memb);
        }
Beispiel #20
0
        internal static Party CreateParty(PartyModel partyModel, Dictionary <string, string> partyCustomAttributeValues)
        {
            PartyTypeManager partyTypeManager = new PartyTypeManager();
            PartyManager     partyManager     = new PartyManager();
            var party = new Party();

            try
            {
                PartyType partyType       = partyTypeManager.PartyTypeRepository.Get(partyModel.PartyType.Id);
                var       partyStatusType = partyTypeManager.GetStatusType(partyType, "Created");
                // save party as temp if the reationships are required
                var requiredPartyRelationTypes = new PartyRelationshipTypeManager().GetAllPartyRelationshipTypes(partyType.Id).Where(cc => cc.MinCardinality > 0);
                //Create party
                party = partyManager.Create(partyType, "", partyModel.Description, partyModel.StartDate, partyModel.EndDate, partyStatusType, requiredPartyRelationTypes.Any());
                partyManager.AddPartyCustomAttributeValues(party, partyCustomAttributeValues.ToDictionary(cc => long.Parse(cc.Key), cc => cc.Value));
            }
            finally
            {
                partyTypeManager?.Dispose();
                partyManager?.Dispose();
            }
            return(party);
        }
Beispiel #21
0
        public async Task PartyManager_CreateNewPartyWithName(string name)
        {
            // Arrange
            var repo = new Mock <IPartyRepository>();

            repo.Setup(r => r.InsertAsync(It.IsAny <Party>())).Returns(Task.CompletedTask);
            var manager  = new PartyManager(repo.Object);
            var expected = new Party
            {
                Info = new PartyInfo
                {
                    Name = name
                }
            };

            // Act
            var result = await manager.CreateNewPartyAsync(name);

            // Assert
            Assert.NotNull(result);
            Assert.NotNull(result.Id);
            Assert.AreEqual(expected.Info.Name, result.Info.Name);
        }
Beispiel #22
0
        public ActionResult CreatePartyRelationships(int partyId, Dictionary <string, string> partyRelationshipsDic)
        {
            PartyManager partyManager = null;

            try
            {
                partyManager = new PartyManager();
                Party party = partyManager.PartyRepository.Get(partyId);
                List <PartyRelationship> partyRelationships = ConvertDictionaryToPartyRelationships(partyRelationshipsDic);
                var partyRelationshipManager = new PartyRelationshipTypeManager();
                foreach (var partyRelationship in partyRelationships)
                {
                    Party secondParty = partyManager.PartyRepository.Get(partyRelationship.SecondParty.Id);
                    PartyRelationshipType partyRelationshipType = partyRelationshipManager.PartyRelationshipTypeRepository.Get(partyRelationship.PartyRelationshipType.Id);
                    PartyTypePair         partyTypePair         = partyRelationshipManager.PartyTypePairRepository.Get(partyRelationship.PartyTypePair.Id);
                    //Min date value is sent from telerik date time element, if it was empty
                    if (partyRelationship.EndDate == DateTime.MinValue)
                    {
                        partyRelationship.EndDate = DateTime.MaxValue;
                    }
                    partyManager.AddPartyRelationship(party, secondParty, partyRelationshipType, partyRelationship.Title, partyRelationship.Description, partyTypePair, partyRelationship.StartDate, partyRelationship.EndDate, partyRelationship.Scope);
                }
                partyManager?.Dispose();
                //partyManager = new PartyManager();
                ////if relationship rules are satisfied, it is not temp
                //  if (string.IsNullOrWhiteSpace(Helpers.Helper.ValidateRelationships(party.Id)))
                //    party.IsTemp = false;
                //else
                //    party.IsTemp = true;
                //partyManager.Update(party);
                return(RedirectToAction("CreateEdit", "party", new { id = partyId, relationTabAsDefault = true }));
            }
            finally
            {
                partyManager?.Dispose();
            }
        }
Beispiel #23
0
        public string DeletePartyRelationship(int id, long selectedParty)
        {
            PartyManager partyManager = null;

            try
            {
                partyManager = new PartyManager();
                var prs = partyManager.PartyRelationshipRepository.Get(id);

                //remove a releationship must defines with a direction, because the cardinality of the releationshiptype
                int direction = prs.SourceParty.Id.Equals(selectedParty) ? 0 : 1;

                partyManager.RemovePartyRelationship(partyManager.PartyRelationshipRepository.Get(id), direction);
                return("successfull");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            finally
            {
                partyManager?.Dispose();
            }
        }
Beispiel #24
0
        private void SetupMemberPanels()
        {
            PartyManager.Order();
            memberPanels.ForEach(p => p.gameObject.SetActive(false));

            for (var i = 0; i < PartyManager.Members.Count; i++)
            {
                var image     = memberPanels[i].transform.Find("Character Image").GetComponent <Image>();
                var nameText  = memberPanels[i].transform.Find("Name Text").GetComponent <TextMeshProUGUI>();
                var levelText = memberPanels[i].transform.Find("Level Text").GetComponent <TextMeshProUGUI>();

                image.sprite   = PartyManager.Members[i].fullBodyArt;
                nameText.text  = PartyManager.Members[i].characterName;
                levelText.text = $"LVL {PartyManager.Members[i].level.ToString()}";

                if (PartyManager.Members[i] == lilith)
                {
                    image.rectTransform.localPosition = new Vector3(-18, -94, 0);
                    image.rectTransform.localScale    = new Vector3(1.1f, 1.1f, 1);
                }

                memberPanels[i].gameObject.SetActive(true);
            }
        }
Beispiel #25
0
        public ActionResult UserRegistration()
        {
            PartyManager                 partyManager                 = null;
            PartyTypeManager             partyTypeManager             = null;
            PartyRelationshipTypeManager partyRelationshipTypeManager = null;
            UserManager userManager = null;

            try
            {
                if (!HttpContext.User.Identity.IsAuthenticated)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                //Defined AccountPartyTypes vallue in web config format is like PartyType1:PartyTypePairTitle1-PartyTypePairTitle2,PartyType2
                var accountPartyTypes     = new List <string>();
                var partyTypeAccountModel = new PartyTypeAccountModel();
                partyManager                 = new PartyManager();
                partyTypeManager             = new PartyTypeManager();
                partyRelationshipTypeManager = new PartyRelationshipTypeManager();
                userManager = new UserManager();
                var allowedAccountPartyTypes = GetPartyTypesForAccount();
                if (allowedAccountPartyTypes == null)
                {
                    throw new Exception("Allowed party types for registration in setting.xml are not exist!");
                }
                //Split them by "," and split each one by ":"
                foreach (var allowedAccountPartyType in allowedAccountPartyTypes)
                {
                    var partyType = partyTypeManager.PartyTypeRepository.Get(item => item.Title == allowedAccountPartyType.Key).FirstOrDefault();
                    if (partyType == null)
                    {
                        throw new Exception("AccountPartyType format in app setting is not correct or this 'partyType' doesn't exist.");
                    }
                    var allowedPartyTypePairs = new Dictionary <string, PartyTypePair>();
                    if (allowedAccountPartyType.Value != null)
                    {
                        var partyRelationshipsType = partyRelationshipTypeManager.PartyRelationshipTypeRepository.Get(item => allowedAccountPartyType.Value.Contains(item.Title));
                        foreach (var partyRelationshipType in partyRelationshipsType)
                        {
                            //filter AssociatedPairs to allowed pairs
                            partyRelationshipType.AssociatedPairs = partyRelationshipType.AssociatedPairs.Where(item => partyType.Id == item.SourcePartyType.Id && item.TargetPartyType.Parties.Any()).ToList();
                            //try to find first type pair which has PartyRelationShipTypeDefault otherwise the first one
                            var defaultPartyTypePair = partyRelationshipType.AssociatedPairs.FirstOrDefault(item => item.PartyRelationShipTypeDefault);

                            if (defaultPartyTypePair == null)
                            {
                                defaultPartyTypePair = partyRelationshipType.AssociatedPairs.FirstOrDefault();
                            }
                            if (defaultPartyTypePair != null)
                            {
                                if (defaultPartyTypePair.TargetPartyType.Parties != null)
                                {
                                    defaultPartyTypePair.TargetPartyType.Parties = defaultPartyTypePair.TargetPartyType.Parties.OrderBy(item => item.Name).ToList(); // order parties by name
                                }
                                allowedPartyTypePairs.Add(partyRelationshipType.DisplayName, defaultPartyTypePair);
                            }
                        }
                    }
                    partyTypeAccountModel.PartyRelationshipsTypes.Add(partyType, allowedPartyTypePairs);
                }
                //Bind party if there is already a user associated to this party
                var userTask = userManager.FindByNameAsync(HttpContext.User.Identity.Name);
                userTask.Wait();
                var user = userTask.Result;
                partyTypeAccountModel.Party = partyManager.GetPartyByUser(user.Id);
                //TODO: Discuss . Current soloution is to navigate the user to edit party
                if (partyTypeAccountModel.Party != null)
                {
                    return(RedirectToAction("Edit"));
                }
                return(View("_userRegisterationPartial", partyTypeAccountModel));
            }
            finally
            {
                partyManager?.Dispose();
                partyTypeManager?.Dispose();
                partyRelationshipTypeManager?.Dispose();
                userManager?.Dispose();
            }
        }
        /// <summary>
        /// Remove a party member.  If the party member was the last in the
        /// party, then the party is dissolved.
        /// </summary>
        /// <param name="Creature">Supplies the creature to remove.</param>
        public void RemovePartyMember(CreatureObject Creature)
        {
            if (Creature.Party != this)
            {
                throw new ApplicationException(String.Format(
                                                   "Removing creature {0} from party, but it is not in this party."));
            }

            PartyMembers.Remove(Creature);
            Creature.Party = null;

            if (PartyLeader == Creature)
            {
                PartyLeader = null;
            }

            if (PartyMembers.Count == 0)
            {
                PartyManager.RemoveParty(this);
            }

            switch ((AIType)Creature.TacticsType)
            {
            case AIType.BEHAVIOR_TYPE_ANIMAL:
                PartyAnimals.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_ARCHER:
                PartyArchers.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_BUFFS:
                PartyBuffs.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_CONTROL:
                PartyControls.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_COWARD:
                PartyCowards.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_FLANK:
                PartyFlanks.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_MEDIC:
                PartyMedics.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_MINDLESS:
                PartyMindless.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_NUKE:
                PartyNukes.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_SHOCK:
                PartyShocks.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_SKIRMISH:
                PartySkrimishers.Remove(Creature);
                break;

            case AIType.BEHAVIOR_TYPE_TANK:
                PartyTanks.Remove(Creature);
                break;

            default:
                break;
            }

            if (PartyMembers.Count > 0 && PartyLeader == null)
            {
                int nCha = 0;
                foreach (CreatureObject Member in PartyMembers)
                {
                    if (Member.Script.GetAbilityModifier(CLRScriptBase.ABILITY_CHARISMA, Member.ObjectId) > nCha)
                    {
                        nCha        = Member.Script.GetAbilityModifier(CLRScriptBase.ABILITY_CHARISMA, Member.ObjectId);
                        PartyLeader = Member;
                    }
                }
            }
        }
Beispiel #27
0
 private void Awake()
 {
     partyInstance = this;
 }
Beispiel #28
0
        /// <summary>
        /// Send a booking notification (create, edit or delete event) as email to in config file defined receivers
        /// </summary>
        /// <param name="bookingAction">For which action the notification will be send. (create, edit or delete event)</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static void SendBookingNotification(BookingAction bookingAction, BookingEventModel model)
        {
            //get receiver and sender from the settings file
            var receiver    = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiver").ToString().Split(',').ToList();
            var receiverCC  = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiverCC").ToString().Split(',').ToList();
            var receiverBCC = Modules.RBM.UI.Helper.Settings.get("BookingMailReceiverBCC").ToString().Split(',').ToList();

            var sender = Modules.RBM.UI.Helper.Settings.get("BookingMailSender").ToString();

            var subject = Modules.RBM.UI.Helper.Settings.get("BookingMailSubject").ToString() + ": " + bookingAction;

            string message = "";

            message += "<p>The following booking has been " + bookingAction + "</p>";
            message += "<b>Booking name: </b>" + model.Name + "</br>";
            if (!String.IsNullOrEmpty(model.Description))
            {
                message += "<b>Booking description: </b> " + model.Description + "</br>";
            }
            message += "<p><b>Booked Resources:</b></p>";
            using (var userManager = new UserManager())
                using (var partyManager = new PartyManager())
                {
                    foreach (ScheduleEventModel schedule in model.Schedules)
                    {
                        message += "<b>Resource: </b>" + schedule.ResourceName + "</br>";
                        message += "<b>Start date: </b>" + schedule.ScheduleDurationModel.StartDate.ToString("dd.MM.yyyy") + "</br>";
                        message += "<b>End date: </b>" + schedule.ScheduleDurationModel.EndDate.ToString("dd.MM.yyyy") + "</br>";
                        message += "<b>Reserved by: </b>" + schedule.ByPerson + "</br>";
                        message += "<b>Contact person: </b>" + schedule.ContactName + " ( #" + schedule.Contact.MobileNumber + ")</br>";
                        message += "<b>Reserved for: </b>";


                        foreach (PersonInSchedule person in schedule.ForPersons)
                        {
                            if (schedule.ForPersons.IndexOf(person) == schedule.ForPersons.Count - 1)
                            {
                                message += person.UserFullName;
                            }
                            else
                            {
                                message += person.UserFullName + ", ";
                            }

                            var user = userManager.FindByIdAsync(person.UserId).Result;

                            if (user != null)
                            {
                                receiver.Add(user.Email);
                            }
                        }

                        message += "</br></br>";
                    }
                }

            receiverBCC.Add(ConfigurationManager.AppSettings["SystemEmail"].ToString()); // Allways send BCC to SystemEmail

            var emailService = new EmailService();

            emailService.Send(
                subject,
                message,
                receiver.Distinct().ToList(),
                receiverCC,
                receiverBCC
                );
        }
Beispiel #29
0
        // GET: DQ
        public ActionResult ShowDQ(long datasetId, long versionId)
        {
            DQModels dqModel = new DQModels();
            Dictionary <string, string> datasetInfo  = new Dictionary <string, string>();
            List <performer>            performers   = new List <performer>();
            List <varVariable>          varVariables = new List <varVariable>();
            Dictionary <string, double> datasetSize  = new Dictionary <string, double>();
            DatasetManager          dm  = new DatasetManager();
            DataStructureManager    dsm = new DataStructureManager();
            EntityPermissionManager entityPermissionManager = new EntityPermissionManager();
            PartyManager            pm          = new PartyManager();
            UserManager             um          = new UserManager();
            DatasetVersion          dsv         = new DatasetVersion();
            UserManager             userManager = new UserManager();

            // data quality files
            try
            {
                string       pathPerformerDataset   = @"C:\Data\DatasetQualities\PerformerDataset.csv";
                StreamReader readerPerformerDataset = new StreamReader(pathPerformerDataset);
            }
            catch (Exception ex)
            { }

            //////////////////////////////////////////////////////////////////////////
            DatasetVersion currentDatasetVersion = dm.GetDatasetVersion(versionId);                                                   //Current dataset version
            DataStructure  currentDataStr        = dsm.AllTypesDataStructureRepo.Get(currentDatasetVersion.Dataset.DataStructure.Id); //current data structure
            var            currentUser           = userManager.FindByNameAsync(GetUsernameOrDefault()).Result;                        //Find current user

            //Find the dataset Type
            string currentDatasetType = "file";

            if (currentDataStr.Self.GetType() == typeof(StructuredDataStructure))
            {
                currentDatasetType = "tabular";
            }
            dqModel.type = currentDatasetType;

            #region performers

            #region dataset's performers
            try
            {
                string           pathPerformerDataset   = @"C:\Data\DatasetQualities\PerformerDataset.csv";
                StreamReader     readerPerformerDataset = new StreamReader(pathPerformerDataset);
                string           pathPerformers         = @"C:\Data\DatasetQualities\Performers.csv";
                StreamReader     readerPerformers       = new StreamReader(pathPerformers);
                string           performerLine;
                List <string>    pfs = new List <string>();
                List <performer> ps  = new List <performer>();

                while ((performerLine = readerPerformerDataset.ReadLine()) != null)
                {
                    string[] s = performerLine.Split(',');
                    if (long.Parse(s[1]) == datasetId)
                    {
                        pfs.Add(s[0]);
                    }
                }
                while ((performerLine = readerPerformers.ReadLine()) != null)
                {
                    string[] s = performerLine.Split(',');
                    if (pfs.Contains(s[0]))
                    {
                        performer p = new performer();
                        p.performerName = FindPerformerNameFromUsername(um, s[0]);           //find performer name
                        p.performerRate = int.Parse(s[1]);
                        List <long> pfIds = FindDatasetsFromPerformerUsername(dm, um, s[0]); //Find all datasets in wich the username is involved.
                        p.DatasetIds = pfIds;
                        ps.Add(p);
                    }
                }
                dqModel.performers = ps;
                readerPerformerDataset.Close();
                readerPerformers.Close();
            }
            catch (Exception ex)
            {
            }
            #endregion

            #endregion //performers

            //dqModel.isPublic = entityPermissionManager.GetRights(null, 1, datasetId); //check if dataset is public
            //check the read permission for current dataset
            bool rPermission = entityPermissionManager.HasEffectiveRight(currentUser.UserName, typeof(Dataset), datasetId, Security.Entities.Authorization.RightType.Read); //find if user has read permission
            if (rPermission == true)                                                                                                                                        //has read permission or public = readable
            {
                dqModel.readable = 1;
            }
            else
            {
                dqModel.readable = 0;
            }                              //cannot read

            //Check if the current metadata is valid
            if (currentDatasetVersion.StateInfo != null)
            {
                dqModel.isValid = DatasetStateInfo.Valid.ToString().Equals(currentDatasetVersion.StateInfo.State) ? 1 : 0; //1:valid; 0:invalid.
            }
            else
            {
                dqModel.isValid = 0;
            }


            List <long> datasetIds = dm.GetDatasetLatestIds();
            dqModel.allDatasets = datasetIds.Count;
            List <int>    metadataRates      = new List <int>();
            List <int>    dsDescLength       = new List <int>();
            List <int>    dstrDescLength     = new List <int>();
            List <int>    dstrUsage          = new List <int>();
            List <int>    datasetSizeTabular = new List <int>();
            List <int>    datasetRows        = new List <int>();
            List <int>    datasetCols        = new List <int>();
            List <double> datasetSizeFiles   = new List <double>();
            double        datasetSizeFile    = new double();
            List <int>    datasetFileNumber  = new List <int>();
            List <int>    restrictions       = new List <int>();
            int           fileNumber         = 0;
            List <int>    sizeTabular        = new List <int>(); //collect size, column number, and row number for one dataset
            int           publicDatasets     = 0;
            int           restrictedDatasets = 0;
            int           fileDatasets       = 0;
            int           tabularDatasets    = 0;
            int           rpTrue             = 0;
            int           rp;
            int           validMetadata   = 0;
            int           allValidMetadas = 0;


            foreach (long Id in datasetIds) //for each dataset
            {
                if (dm.IsDatasetCheckedIn(Id))
                {
                    DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(Id);          //get last dataset versions

                    //If user has read permission
                    rPermission = entityPermissionManager.HasEffectiveRight(currentUser.UserName, typeof(Dataset), Id, Security.Entities.Authorization.RightType.Read);
                    if (rPermission == true) //has read permission or public = readable
                    {
                        rp      = 1;
                        rpTrue += 1;
                    }
                    else
                    {
                        rp = 0;
                    }                //cannot read
                }
            }
            dqModel.allReadables = rpTrue;

            string       pathDatasetInfo   = @"C:\Data\DatasetQualities\datasetInfo.csv";
            StreamReader readerDatasetInfo = new StreamReader(pathDatasetInfo);
            List <datasetInformation> datasetsInformation = new List <datasetInformation>();
            try
            {
                string lineDatasetInfo;
                while ((lineDatasetInfo = readerDatasetInfo.ReadLine()) != null)
                {
                    string[]           dsInf = lineDatasetInfo.Split(';');
                    datasetInformation datasetInformation = new datasetInformation();

                    long id = long.Parse(dsInf[0]);
                    datasetInformation.datasetId = id;
                    datasetInformation.title     = dm.GetDatasetLatestVersion(id).Title;

                    rPermission = entityPermissionManager.HasEffectiveRight(currentUser.UserName, typeof(Dataset), id, Security.Entities.Authorization.RightType.Read);
                    if (rPermission == true)
                    {
                        datasetInformation.readable = 1;
                    }
                    if (rPermission == false)
                    {
                        datasetInformation.readable = 0;
                    }
                    datasetInformation.type = dsInf[1];
                    datasetInformation.metadataValidation         = int.Parse(dsInf[2]);
                    datasetInformation.metadataComplition         = int.Parse(dsInf[3]);
                    datasetInformation.descriptionLength          = int.Parse(dsInf[4]);
                    datasetInformation.structureDescriptionLength = int.Parse(dsInf[5]);
                    datasetInformation.structureUsage             = int.Parse(dsInf[6]);
                    datasetInformation.columnNumber    = int.Parse(dsInf[7]);
                    datasetInformation.rowNumber       = int.Parse(dsInf[8]);
                    datasetInformation.fileNumber      = int.Parse(dsInf[9]);
                    datasetInformation.datasetSizeFile = double.Parse(dsInf[10]);
                    string[]      pfrms          = dsInf[11].Split(',');
                    List <string> performerNames = new List <string>();
                    foreach (string p in pfrms)
                    {
                        performerNames.Add(p);
                    }
                    datasetInformation.performerNames = performerNames;

                    datasetsInformation.Add(datasetInformation);

                    if (datasetId == id)
                    {
                        dqModel.metadataComplition.requiredFields = int.Parse(dsInf[2]);
                        dqModel.metadataComplition.totalFields    = int.Parse(dsInf[3]);
                        dqModel.datasetDescriptionLength.currentDescriptionLength = int.Parse(dsInf[4]);
                        dqModel.dataStrDescriptionLength.currentDescriptionLength = int.Parse(dsInf[5]);
                        dqModel.dataStrUsage.currentDataStrUsage = int.Parse(dsInf[6]);

                        dqModel.columnNumber = datasetInformation.columnNumber;
                        dqModel.rowNumber    = datasetInformation.rowNumber;
                        dqModel.fileNumber   = datasetInformation.fileNumber;
                        dqModel.datasetTotalSize.currentTotalSize = datasetInformation.datasetSizeFile;
                    }
                }
            }
            catch
            {
            }

            dqModel.datasetsInformation = datasetsInformation;
            readerDatasetInfo.Close();

            //CURRENT DATASET VERSION
            //dqModel.metadataComplition.totalFields = GetMetadataRate(currentDatasetVersion); //current dataset version: metadata rate
            //dqModel.metadataComplition.requiredFields = 100; //Need to calculate: metadataStructureId = dsv.Dataset.MetadataStructure.Id;
            //dqModel.datasetDescriptionLength.currentDescriptionLength = currentDatasetVersion.Description.Length; // Current dataset vesion: dataset description length
            //dqModel.dataStrDescriptionLength.currentDescriptionLength = currentDatasetVersion.Dataset.DataStructure.Description.Length; // Current dataset version: data structure description length
            //dqModel.dataStrUsage.currentDataStrUsage = currentDataStr.Datasets.Count() - 1; // Current dataset version: how many times the data structure is used in other datasets

            #region comparision
            try
            {
                string       pathComparison   = @"C:\Data\DatasetQualities\Comparison.csv";
                StreamReader readerComparison = new StreamReader(pathComparison);
                string       infoline;
                List <int>   infos = new List <int>();
                while ((infoline = readerComparison.ReadLine()) != null)
                {
                    string[] s = infoline.Split(',');
                    if (s[0] == "performersActivity")
                    {
                        dqModel.performersActivity.minActivity    = int.Parse(s[1]);
                        dqModel.performersActivity.medianActivity = int.Parse(s[2]);
                        dqModel.performersActivity.maxActivity    = int.Parse(s[3]);
                    }
                    else if (s[0] == "type")
                    {
                        dqModel.allDatasets     = int.Parse(s[1]);
                        dqModel.tabularDatasets = int.Parse(s[2]);
                        dqModel.fileDatasets    = int.Parse(s[3]);
                    }
                    else if (s[0] == "metadataRates")
                    {
                        dqModel.metadataComplition.minRate    = int.Parse(s[1]);
                        dqModel.metadataComplition.medianRate = int.Parse(s[2]);
                        dqModel.metadataComplition.maxRate    = int.Parse(s[3]);
                    }
                    else if (s[0] == "allValidMetadas")
                    {
                        dqModel.allValids = int.Parse(s[1]);
                    }
                    else if (s[0] == "datasetDescriptionLength")
                    {
                        dqModel.datasetDescriptionLength.minDescriptionLength    = int.Parse(s[1]);
                        dqModel.datasetDescriptionLength.medianDescriptionLength = int.Parse(s[2]);
                        dqModel.datasetDescriptionLength.maxDescriptionLength    = int.Parse(s[3]);
                    }
                    else if (s[0] == "dataStrDescriptionLength")
                    {
                        dqModel.dataStrDescriptionLength.minDescriptionLength    = int.Parse(s[1]);
                        dqModel.dataStrDescriptionLength.medianDescriptionLength = int.Parse(s[2]);
                        dqModel.dataStrDescriptionLength.maxDescriptionLength    = int.Parse(s[3]);
                    }
                    else if (s[0] == "dataStrUsage")
                    {
                        dqModel.dataStrUsage.minDataStrUsage    = int.Parse(s[1]);
                        dqModel.dataStrUsage.medianDataStrUsage = int.Parse(s[2]);
                        dqModel.dataStrUsage.maxDataStrUsage    = int.Parse(s[3]);
                    }
                    else if (s[0] == "datasetColNumber")
                    {
                        dqModel.datasetColNumber.minColNumber    = int.Parse(s[1]);
                        dqModel.datasetColNumber.medianColNumber = int.Parse(s[2]);
                        dqModel.datasetColNumber.maxColNumber    = int.Parse(s[3]);
                    }
                    else if (s[0] == "datasetRowNumber")
                    {
                        dqModel.datasetRowNumber.minRowNumber    = int.Parse(s[1]);
                        dqModel.datasetRowNumber.medianRowNumber = int.Parse(s[2]);
                        dqModel.datasetRowNumber.maxRowNumber    = int.Parse(s[3]);
                    }
                    else if (s[0] == "datasetFileNumber")
                    {
                        dqModel.datasetFileNumber.minFileNumber    = int.Parse(s[1]);
                        dqModel.datasetFileNumber.medianFileNumber = int.Parse(s[2]);
                        dqModel.datasetFileNumber.maxFileNumber    = int.Parse(s[3]);
                    }
                    else if (s[0] == "datasetTotalSizeFiles")
                    {
                        dqModel.datasetTotalSize.minSizeFile    = double.Parse(s[1]);
                        dqModel.datasetTotalSize.medianSizeFile = double.Parse(s[2]);
                        dqModel.datasetTotalSize.maxSizeFile    = double.Parse(s[3]);
                    }
                }
                readerComparison.Close();
            }
            catch (Exception ex)
            {
            }

            #endregion

            ///////////////////////////////////////////////////////////////////////

            #region TABULAR FORMAT DATASET
            //If it is a tabular format dataset
            if (currentDatasetType == "tabular")
            {
                string       pathVariables   = @"C:\Data\DatasetQualities\Variables.csv";
                StreamReader readerVariables = new StreamReader(pathVariables);

                string varLine;
                while ((varLine = readerVariables.ReadLine()) != null)
                {
                    string[] varDetail = varLine.Split(',');
                    if (varDetail[0] == datasetId.ToString())
                    {
                        varVariable v = new varVariable();
                        v.varLabel       = varDetail[1];
                        v.varType        = varDetail[2];
                        v.varDescription = varDetail[3];
                        v.varUsage       = int.Parse(varDetail[4]);
                        v.missing        = int.Parse(varDetail[5]);

                        varVariables.Add(v);
                    }
                }
                dqModel.varVariables = varVariables;
                readerVariables.Close();
            }

            //    string serverName = "http://*****:*****@"C:\Data\DatasetQualities\Files.csv";
                try
                {
                    StreamReader readerFiles = new StreamReader(pathFiles);
                    while ((fileLine = readerFiles.ReadLine()) != null)
                    {
                        string[] fileDetail = fileLine.Split(',');
                        if (fileDetail[0] == datasetId.ToString())
                        {
                            fileInformation f = new fileInformation();
                            f.fileName   = fileDetail[1];
                            f.fileFormat = fileDetail[2];
                            double d = Convert.ToDouble(fileDetail[3]);
                            f.fileSize = d;
                            filesInformations.Add(f);
                        }
                    }
                    readerFiles.Close();
                }
                catch
                {
                }
                dqModel.filesInformation = filesInformations;
            }

            //if (currentDatasetVersion != null)
            //{
            //    List<ContentDescriptor> contentDescriptors = currentDatasetVersion.ContentDescriptors.ToList();
            //    double totalSize = 0;
            //    if (contentDescriptors.Count > 0)
            //    {
            //        foreach (ContentDescriptor cd in contentDescriptors)
            //        {
            //            if (cd.Name.ToLower().Equals("unstructureddata"))
            //            {
            //                fileInformation fileInformation = new fileInformation();
            //                string uri = cd.URI;

            //                //get the file path
            //                try
            //                {
            //                    String path = Server.UrlDecode(uri);
            //                    path = Path.Combine(AppConfiguration.DataPath, path);
            //                    Stream fileStream = System.IO.File.OpenRead(path);

            //                    if (fileStream != null)
            //                    {
            //                        FileStream fs = fileStream as FileStream;
            //                        if (fs != null)
            //                        {
            //                            //get file information
            //                            FileInformation fileInfo = new FileInformation(fs.Name.Split('\\').LastOrDefault(), MimeMapping.GetMimeMapping(fs.Name), (uint)fs.Length, uri);
            //                            fileInformation.fileName = fileInfo.Name.Split('.')[0]; //file name
            //                            fileInformation.fileFormat = fileInfo.Name.Split('.')[1].ToLower(); //file extension
            //                            fileInformation.fileSize = fileInfo.Size; //file size
            //                            totalSize += fileInfo.Size;
            //                        }
            //                    }
            //                }
            //                catch
            //                {

            //                }
            //        filesInformation.Add(fileInformation);
            //    }

            //}
            //}
            //dqModel.fileNumber = contentDescriptors.Count;
            //dqModel.datasetTotalSize.currentTotalSize = totalSize;
            //}
            //dqModel.filesInformation = filesInformation;
            //}
            #endregion


            return(PartialView(dqModel));
        }
Beispiel #30
0
        public void CreatePartyTest()
        {
            //Scenario: create, create with CustomAttributeValues<Id,value>, create with CustomAttributeValues<Name,value>,
            PartyManager     partyManager     = new PartyManager();
            PartyTypeManager partyTypeManager = new PartyTypeManager();
            var partyStatusTypes = new List <PartyStatusType>();

            partyStatusTypes.Add(new PartyStatusType()
            {
                Name = "Created", Description = ""
            });

            var partyTypeTest   = partyTypeManager.Create("partyTypeTitle", "", "", partyStatusTypes);
            var partyStatusType = partyTypeManager.GetStatusType(partyTypeTest, "Created");
            var party1          = partyManager.Create(partyTypeTest, "alias", "description test", DateTime.Now.AddMonths(-1), DateTime.Now.AddMonths(1), partyStatusType);

            party1.Should().NotBeNull();
            party1.Id.Should().BeGreaterThan(0);
            var party1Id     = party1.Id;
            var fetchedParty = partyManager.PartyRepository.Get(party1Id);

            party1.Name.Should().BeEquivalentTo(fetchedParty.Name);
            party1.Alias.Should().BeEquivalentTo(fetchedParty.Alias);
            party1.Description.Should().BeEquivalentTo(fetchedParty.Description);
            party1.EndDate.ToShortDateString().Should().BeEquivalentTo(fetchedParty.EndDate.ToShortDateString());
            party1.PartyType.Id.Should().Be(fetchedParty.PartyType.Id);
            party1.StartDate.ToShortDateString().Should().BeEquivalentTo(fetchedParty.StartDate.ToShortDateString());
            party1.Id.Should().Be(fetchedParty.Id);
            //cleanup
            partyManager.Delete(party1);
            var partyAfterDelete = partyManager.PartyRepository.Get(cc => cc.Id == party1Id).FirstOrDefault();

            partyAfterDelete.Should().BeNull();
            //create cstom attributes
            var partyCustomAttribute1 = partyTypeManager.CreatePartyCustomAttribute(partyTypeTest, "String", "FirstName", "", "", "", isMain: true);
            var partyCustomAttribute2 = partyTypeManager.CreatePartyCustomAttribute(partyTypeTest, "String", "LastName", "", "", "", isMain: true);
            var partyCustomAttribute3 = partyTypeManager.CreatePartyCustomAttribute(partyTypeTest, "Int", "Age", "", "", "");
            //create with CustomAttributeValues<Id,value>
            Dictionary <long, String> customAttributeValues = new Dictionary <long, string>();

            customAttributeValues.Add(partyCustomAttribute1.Id, "Masoud");
            customAttributeValues.Add(partyCustomAttribute2.Id, "Allahyari");
            customAttributeValues.Add(partyCustomAttribute3.Id, "31");
            var party2        = partyManager.Create(partyTypeTest, "", null, null, customAttributeValues);
            var party2Id      = party2.Id;
            var fetchedParty2 = partyManager.PartyRepository.Get(party2Id);

            //First name and lastname in custom attributes were defined as main;therefore, party name should be "name lastname"
            party2.Name.Should().BeEquivalentTo("Masoud Allahyari");
            party2.Alias.Should().BeEquivalentTo(fetchedParty2.Alias);
            party2.Description.Should().BeEquivalentTo(fetchedParty2.Description);
            party2.EndDate.ToShortDateString().Should().Be(fetchedParty2.EndDate.ToShortDateString());
            party2.PartyType.Id.Should().Be(fetchedParty2.PartyType.Id);
            party2.StartDate.ToShortDateString().Should().Be(fetchedParty2.StartDate.ToShortDateString());
            party2.Id.Should().Be(fetchedParty2.Id);
            var fethedCustomAttributeValues = fetchedParty2.CustomAttributeValues;

            fethedCustomAttributeValues.Count().Should().Be(customAttributeValues.Count());

            fethedCustomAttributeValues.Any(cc => cc.Value == "Masoud" && cc.CustomAttribute.Id == partyCustomAttribute1.Id).Should().Be(true);
            fethedCustomAttributeValues.Any(cc => cc.Value == "Allahyari" && cc.CustomAttribute.Id == partyCustomAttribute2.Id).Should().Be(true);
            fethedCustomAttributeValues.Any(cc => cc.Value == "31" && cc.CustomAttribute.Id == partyCustomAttribute3.Id).Should().Be(true);
            fethedCustomAttributeValues.Any(cc => cc.Value == "30" && cc.CustomAttribute.Id == partyCustomAttribute3.Id).Should().Be(false);
            //Cleanup DB
            partyManager.Delete(party2);
            //custom Attribute values should have benn deleted
            var customAttrValues = partyManager.PartyCustomAttributeValueRepository.Get(cc => cc.Party.Id == party2Id);

            customAttrValues.Count().Should().Be(0);
            //create with CustomAttributeValues<Name,value>
            Dictionary <String, String> customAttributeValues2 = new Dictionary <String, string>();

            customAttributeValues2.Add(partyCustomAttribute1.Name, "Alex");
            customAttributeValues2.Add(partyCustomAttribute2.Name, "Abedini");
            customAttributeValues2.Add(partyCustomAttribute3.Name, "31");
            var party3        = partyManager.Create(partyTypeTest, "", null, null, customAttributeValues2);
            var party3Id      = party3.Id;
            var fetchedParty3 = partyManager.PartyRepository.Get(party3Id);

            party3.Name.Should().BeEquivalentTo("Alex Abedini");
            party3.Alias.Should().BeEquivalentTo(fetchedParty3.Alias);
            party3.Description.Should().BeEquivalentTo(fetchedParty3.Description);
            party3.EndDate.ToShortDateString().Should().BeEquivalentTo(fetchedParty3.EndDate.ToShortDateString());
            party3.PartyType.Id.Should().Be(fetchedParty3.PartyType.Id);
            party3.StartDate.ToShortDateString().Should().BeEquivalentTo(fetchedParty3.StartDate.ToShortDateString());
            party3.Id.Should().Be(fetchedParty3.Id);
            fethedCustomAttributeValues = fetchedParty3.CustomAttributeValues;
            fethedCustomAttributeValues.Count().Should().Be(customAttributeValues2.Count());
            fethedCustomAttributeValues.Any(cc => cc.Value == "Alex" && cc.CustomAttribute.Id == partyCustomAttribute1.Id).Should().Be(true);
            fethedCustomAttributeValues.Any(cc => cc.Value == "Abedini" && cc.CustomAttribute.Id == partyCustomAttribute2.Id).Should().Be(true);
            fethedCustomAttributeValues.Any(cc => cc.Value == "31" && cc.CustomAttribute.Id == partyCustomAttribute3.Id).Should().Be(true);
            fethedCustomAttributeValues.Any(cc => cc.Value == "30" && cc.CustomAttribute.Id == partyCustomAttribute3.Id).Should().Be(false);
            //Cleanup DB
            partyManager.Delete(party3);
            partyTypeManager.Delete(partyTypeTest);
        }
Beispiel #31
0
        public void onGameLoad(EventGameLoad evt)
        {
            if (File == "")
            {
                File = worldManager.settlementName.ToString();
            }

            if (!AdventureMap.isMapCreated)
            {
                AManager<MapManager>.getInstance().CreateWorldMap();
                AdventureMap.isMapCreated = true;
            }

            if (BattleManager.isStartingFight)
            {
                TransitionScreen.CloseWindow();
                AManager<TimeManager>.getInstance().pause();
                Screen.lockCursor = false;
                Screen.showCursor = true;
                GUIManager.getInstance().startMenu = "";
                GUIManager.getInstance().inStartMenu = true;
                GUIManager.getInstance().inGame = false;
                BattleManager.isStartingFight = false;
            }

            if (PartyManager.draftees.Count <= 0)
            {
                PartyManager partyManager = new PartyManager();
                partyManager.ManageParty(0);
            }
        }
Beispiel #32
0
        /// <summary>
        /// Update rules:
        /// Comparison for update is by the title of elements: title of elements are not editable
        /// if title of an element is changed because remove is forbiden here ,  it adds it as a new element and the old one will remain there
        ///
        /// </summary>
        private void ImportPartyTypes()
        {
            PartyTypeManager             partyTypeManager             = null;
            PartyManager                 partyManager                 = null;
            PartyRelationshipTypeManager partyRelationshipTypeManager = null;

            try
            {
                partyTypeManager             = new PartyTypeManager();
                partyManager                 = new PartyManager();
                partyRelationshipTypeManager = new PartyRelationshipTypeManager();
                var         filePath = Path.Combine(AppConfiguration.GetModuleWorkspacePath("BAM"), "partyTypes.xml");
                XDocument   xDoc     = XDocument.Load(filePath);
                XmlDocument xmlDoc   = new XmlDocument();
                xmlDoc.Load(xDoc.CreateReader());
                var partyTypesNodeList = xmlDoc.SelectNodes("//PartyTypes");

                var deleteAbleAttr       = new List <PartyCustomAttribute>();
                var deleteAbleAttrValues = new List <PartyCustomAttributeValue>();

                if (partyTypesNodeList.Count > 0)
                {
                    foreach (XmlNode partyTypeNode in partyTypesNodeList[0].ChildNodes)
                    {
                        if (!(partyTypeNode is XmlElement))
                        {
                            continue;
                        }

                        //Convert xmAttributeCollection to list to skipt the case sensitive and null problems
                        var attributes = new List <XmlAttribute>();
                        foreach (XmlAttribute att in partyTypeNode.Attributes)
                        {
                            attributes.Add(att);
                        }
                        var title       = GetAttributeValue(attributes, "Name", true);
                        var displayName = GetAttributeValue(attributes, "DisplayName", false);
                        var systemType  = GetAttributeValue(attributes, "SystemType", true);
                        var partyType   = partyTypeManager.PartyTypeRepository.Get(item => item.Title == title).FirstOrDefault();
                        //If there is not such a party type
                        if (partyType == null)
                        {
                            var partyStatusTypes = new List <PartyStatusType>();
                            partyStatusTypes.Add(new PartyStatusType()
                            {
                                Name = "Created", Description = ""
                            });
                            partyType = partyTypeManager.Create(title, "Imported from partyTypes.xml", displayName, partyStatusTypes, (systemType == null ? false : Convert.ToBoolean(systemType)));
                            var customAttrs = new List <PartyCustomAttribute>();
                            foreach (XmlNode customAttrNode in partyTypeNode.ChildNodes)
                            {
                                if (!(customAttrNode is XmlElement))
                                {
                                    continue;
                                }

                                var customAttrNodeAttributes = new List <XmlAttribute>();
                                foreach (XmlAttribute att in customAttrNode.Attributes)
                                {
                                    customAttrNodeAttributes.Add(att);
                                }
                                PartyCustomAttribute partyCustomAttr = ParsePartyCustomAttribute(customAttrNodeAttributes);

                                customAttrs.Add(new PartyCustomAttribute()
                                {
                                    DataType        = partyCustomAttr.DataType,
                                    Description     = partyCustomAttr.Description,
                                    IsMain          = partyCustomAttr.IsMain,
                                    IsUnique        = partyCustomAttr.IsUnique,
                                    IsValueOptional = partyCustomAttr.IsValueOptional,
                                    Name            = partyCustomAttr.Name,
                                    PartyType       = partyType,
                                    ValidValues     = partyCustomAttr.ValidValues,
                                    DisplayName     = partyCustomAttr.DisplayName,
                                    Condition       = partyCustomAttr.Condition
                                });
                            }

                            if (!customAttrs.Any(c => c.IsMain))
                            {
                                customAttrs[0].IsMain = true;
                            }

                            foreach (var customAttr in customAttrs)
                            {
                                partyTypeManager.CreatePartyCustomAttribute(customAttr);
                            }
                        }
                        else //partytype exist
                        {
                            var newCustomAttrs      = new List <PartyCustomAttribute>();
                            var existingCustomAttrs = new List <PartyCustomAttribute>();

                            foreach (XmlNode customAttrNode in partyTypeNode.ChildNodes)
                            {
                                if (!(customAttrNode is XmlElement))
                                {
                                    continue;
                                }

                                var attributesList = new List <XmlAttribute>();
                                foreach (XmlAttribute att in customAttrNode.Attributes)
                                {
                                    attributesList.Add(att);
                                }

                                var customAttrName = GetAttributeValue(attributesList, "Name", true);
                                //create new custom attribute if there is not such a name
                                if (!partyType.CustomAttributes.Any(item => item.Name == customAttrName))
                                {
                                    var customAttrNodeAttributes = new List <XmlAttribute>();
                                    foreach (XmlAttribute att in customAttrNode.Attributes)
                                    {
                                        customAttrNodeAttributes.Add(att);
                                    }

                                    PartyCustomAttribute partyCustomAttr = ParsePartyCustomAttribute(customAttrNodeAttributes);
                                    newCustomAttrs.Add(new PartyCustomAttribute()
                                    {
                                        DataType        = partyCustomAttr.DataType,
                                        Description     = partyCustomAttr.Description,
                                        IsMain          = partyCustomAttr.IsMain,
                                        IsUnique        = partyCustomAttr.IsUnique,
                                        IsValueOptional = partyCustomAttr.IsValueOptional,
                                        Name            = customAttrName,
                                        PartyType       = partyType,
                                        ValidValues     = partyCustomAttr.ValidValues,
                                        DisplayName     = partyCustomAttr.DisplayName,
                                        Condition       = partyCustomAttr.Condition
                                    });
                                }
                                else //update if exist
                                {
                                    //add to existingCustomAttr list
                                    var existingAttr = partyType.CustomAttributes.Where(item => item.Name == customAttrName).FirstOrDefault();
                                    if (existingAttr != null)
                                    {
                                        existingCustomAttrs.Add(existingAttr);
                                    }
                                }
                            }// end foreach customAttrNode

                            if (!newCustomAttrs.Any(c => c.IsMain) && !partyType.CustomAttributes.Any(c => c.IsMain))
                            {
                                throw new Exception("There is no main field. Each party type needs at least one main field.");
                            }

                            // create all custom Attr´s
                            foreach (var customAttr in newCustomAttrs)
                            {
                                partyTypeManager.CreatePartyCustomAttribute(customAttr);
                            }

                            // Delete all attrs that are no longer in the partytype.xml
                            newCustomAttrs.AddRange(existingCustomAttrs);
                            var currentListOfAttr = partyType.CustomAttributes;

                            foreach (var attr in currentListOfAttr)
                            {
                                if (!newCustomAttrs.Any(a => a.Id.Equals(attr.Id)))
                                {
                                    deleteAbleAttr.Add(attr);
                                    //select all value that are created based on the attr
                                    // the values need to delete befor the attr itself
                                    deleteAbleAttrValues.AddRange(
                                        partyManager.PartyCustomAttributeValueRepository.Query()
                                        .Where(v => v.CustomAttribute.Id.Equals(attr.Id)));
                                }
                            }
                        }
                    }
                }
                var partyRelationshipTypesNodeList = xmlDoc.SelectNodes("//PartyRelationshipTypes");
                if (partyRelationshipTypesNodeList.Count > 0)
                {
                    foreach (XmlNode partyRelationshipTypesNode in partyRelationshipTypesNodeList[0].ChildNodes)
                    {
                        if (!(partyRelationshipTypesNode is XmlElement))
                        {
                            continue;
                        }

                        var customAttrNodeAttributes = new List <XmlAttribute>();
                        foreach (XmlAttribute att in partyRelationshipTypesNode.Attributes)
                        {
                            customAttrNodeAttributes.Add(att);
                        }

                        var title              = GetAttributeValue(customAttrNodeAttributes, "Name", true);
                        var displayName        = GetAttributeValue(customAttrNodeAttributes, "DisplayName", false);
                        var description        = GetAttributeValue(customAttrNodeAttributes, "Description", false);
                        var indicatesHierarchy = GetAttributeValue(customAttrNodeAttributes, "IndicatesHierarchy", true); // false;
                        var maxCardinality     = GetAttributeValue(customAttrNodeAttributes, "MaxCardinality", true);     // -1
                        var minCardinality     = GetAttributeValue(customAttrNodeAttributes, "MinCardinality", true);     // 0

                        //Import party type pairs
                        var partyTypePairs = new List <PartyTypePair>();
                        foreach (XmlNode partyTypesPairNode in partyRelationshipTypesNode.ChildNodes[0].ChildNodes)
                        {
                            var partyTypesPairNodeAttributes = new List <XmlAttribute>();
                            foreach (XmlAttribute att in partyTypesPairNode.Attributes)
                            {
                                partyTypesPairNodeAttributes.Add(att);
                            }
                            var allowedSourceTitle = GetAttributeValue(partyTypesPairNodeAttributes, "SourceType", true);
                            var allowedTargetTitle = GetAttributeValue(partyTypesPairNodeAttributes, "TargetType", true);
                            var allowedSource      = partyTypeManager.PartyTypeRepository.Get(item => item.Title.ToLower() == allowedSourceTitle.ToLower()).FirstOrDefault();
                            if (allowedSource == null)
                            {
                                throw new Exception("Error in importing party relationship types ! \r\n " + allowedSourceTitle + " is not a party type!!");
                            }
                            var allowedTarget = partyTypeManager.PartyTypeRepository.Get(item => item.Title.ToLower() == allowedTargetTitle.ToLower()).FirstOrDefault();
                            if (allowedTarget == null)
                            {
                                throw new Exception("Error in importing party relationship types ! \r\n " + allowedTargetTitle + " is not a party type!!");
                            }

                            var typePairTitle       = GetAttributeValue(partyTypesPairNodeAttributes, "Title", true);
                            var typePairDescription = GetAttributeValue(partyTypesPairNodeAttributes, "Description", false);
                            var typePairDefault     = GetAttributeValue(partyTypesPairNodeAttributes, "Default", true);
                            var conditionSource     = GetAttributeValue(partyTypesPairNodeAttributes, "conditionSource", false);
                            var conditionTarget     = GetAttributeValue(partyTypesPairNodeAttributes, "conditionTarget", false);
                            var permissionsTemplate = GetAttributeValue(partyTypesPairNodeAttributes, "permissionsTemplate", false);
                            partyTypePairs.Add(new PartyTypePair()
                            {
                                SourcePartyType = allowedSource,
                                TargetPartyType = allowedTarget,
                                Description     = typePairDescription,
                                Title           = typePairTitle,
                                PartyRelationShipTypeDefault = typePairDefault == null ? true : Convert.ToBoolean(typePairDefault),
                                ConditionSource    = conditionSource,
                                ConditionTarget    = conditionTarget,
                                PermissionTemplate = Helper.GetPermissionValue(permissionsTemplate)
                            });
                        }

                        var partyRelationshipType = partyRelationshipTypeManager.PartyRelationshipTypeRepository.Get(item => item.Title == title).FirstOrDefault();
                        //If there is not such a party relationship type
                        //It is mandatory to create at least one party type pair when we are creating a party type relation
                        //
                        if (partyRelationshipType == null)
                        {
                            partyRelationshipType = partyRelationshipTypeManager.Create(title, displayName, description, (indicatesHierarchy == null ? false : Convert.ToBoolean(indicatesHierarchy)), maxCardinality == null ? -1 : int.Parse(maxCardinality), minCardinality == null ? 0 : int.Parse(minCardinality), partyTypePairs.First().PartyRelationShipTypeDefault, partyTypePairs.First().SourcePartyType, partyTypePairs.First().TargetPartyType,
                                                                                        partyTypePairs.First().Title, partyTypePairs.First().Description, partyTypePairs.First().ConditionSource, partyTypePairs.First().ConditionTarget, partyTypePairs.First().PermissionTemplate);
                        }
                        else
                        {
                            partyRelationshipType = partyRelationshipTypeManager.Update(partyRelationshipType.Id, title, "", description, (indicatesHierarchy == null ? false : Convert.ToBoolean(indicatesHierarchy)), maxCardinality == null ? -1 : int.Parse(maxCardinality), minCardinality == null ? 0 : int.Parse(minCardinality));
                            UpdateOrCreatePartyTypePair(partyTypePairs.First(), partyRelationshipType, partyRelationshipTypeManager);
                        }
                        //If there are more than one partyTypepair exist
                        //if (partyTypePairs.Count() > 1)
                        foreach (var partyTypePair in partyTypePairs.Where(item => item != partyTypePairs.First()))
                        {
                            UpdateOrCreatePartyTypePair(partyTypePair, partyRelationshipType, partyRelationshipTypeManager);//
                        }
                    }
                }
                //Add all the custom Attribute names ao custom grid column of default user
                foreach (var partyType in partyTypeManager.PartyTypeRepository.Get(cc => !cc.SystemType))
                {
                    foreach (var partyCustomAttr in partyType.CustomAttributes)
                    {
                        partyManager.UpdateOrAddPartyGridCustomColumn(partyType, partyCustomAttr, null);
                    }
                    var partyRelationshipTypePairs = partyRelationshipTypeManager.PartyTypePairRepository.Get(cc => cc.SourcePartyType.Id == partyType.Id && !cc.TargetPartyType.SystemType);
                    foreach (var partyTypePair in partyRelationshipTypePairs)
                    {
                        partyManager.UpdateOrAddPartyGridCustomColumn(partyType, null, partyTypePair);
                    }
                }

                if (deleteAbleAttr.Any())
                {
                    //delete all existing PartyCustomAttrValues
                    deleteAbleAttrValues.ForEach(a => partyManager.RemovePartyCustomAttributeValue(a));

                    // Delete all GridColumns of the CustomAttribute
                    var listOfIds         = deleteAbleAttr.Select(d => d.Id);
                    var gridColumns       = partyManager.PartyCustomGridColumnsRepository.Get();
                    var listOfGridColumns = gridColumns.Where(c => c.CustomAttribute != null && listOfIds.Contains(c.CustomAttribute.Id)).ToList();

                    listOfGridColumns.ForEach(c => partyManager.RemovePartyGridCustomColumn(c.Id));

                    // add CustomAttribute Grid Columns
                    deleteAbleAttr.ForEach(a => partyTypeManager.DeletePartyCustomAttribute(a));
                }
            }
            catch (Exception ex)
            {
                LoggerFactory.LogCustom("SeedData Failed: " + ex.Message);
                throw;
            }
            finally
            {
                partyManager?.Dispose();
                partyTypeManager?.Dispose();
                partyRelationshipTypeManager?.Dispose();
            }
        }
Beispiel #33
0
        public ActionResult Edit(PartyModel partyModel, Dictionary <string, string> partyCustomAttributeValues)
        {
            var party = new Party();

            using (PartyManager partyManager = new PartyManager())
                using (PartyTypeManager partyTypeManager = new PartyTypeManager())
                    using (UserManager userManager = new UserManager())
                    {
                        if (!HttpContext.User.Identity.IsAuthenticated)
                        {
                            return(RedirectToAction("Index", "Home"));
                        }

                        var userTask = userManager.FindByNameAsync(HttpContext.User.Identity.Name);
                        userTask.Wait();
                        var user      = userTask.Result;
                        var userParty = partyManager.GetPartyByUser(user.Id);
                        if (userParty.Id != partyModel.Id)
                        {
                            throw new Exception("Permission denied.");
                        }
                        if (partyModel.Id == 0)
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                        else
                        {
                            party = Helpers.Helper.EditParty(partyModel, partyCustomAttributeValues, null);

                            var    p           = partyManager.GetParty(party.Id);
                            string displayName = String.Join(" ",
                                                             p.CustomAttributeValues.
                                                             Where(ca => ca.CustomAttribute.IsMain.Equals(true)).
                                                             OrderBy(ca => ca.CustomAttribute.Id).
                                                             Select(ca => ca.Value).ToArray());

                            user.DisplayName = displayName;

                            if (ConfigurationManager.AppSettings["usePersonEmailAttributeName"] == "true")
                            {
                                var nameProp = partyTypeManager.PartyCustomAttributeRepository.Get(attr => (attr.PartyType == party.PartyType) && (attr.Name == ConfigurationManager.AppSettings["PersonEmailAttributeName"])).FirstOrDefault();
                                if (nameProp != null)
                                {
                                    var entity = party.CustomAttributeValues.FirstOrDefault(item => item.CustomAttribute.Id == nameProp.Id);
                                    if (user.Email != entity.Value)
                                    {
                                        var es = new EmailService();
                                        es.Send(MessageHelper.GetUpdateEmailHeader(),
                                                MessageHelper.GetUpdaterEmailMessage(user.DisplayName, user.Email, entity.Value),
                                                ConfigurationManager.AppSettings["SystemEmail"]
                                                );
                                    }
                                    user.Email = entity.Value;
                                }
                            }


                            userManager.UpdateAsync(user);
                        }
                        return(RedirectToAction("Index", "Home", new { area = "" }));
                    }
        }
Beispiel #34
0
        internal static DataTable getPartyDataTable(PartyType partyType, List <Party> parties)
        {
            using (PartyRelationshipTypeManager partyRelationshipTypeManager = new PartyRelationshipTypeManager())
                using (PartyManager partyManager = new PartyManager())
                {
                    DataTable table = new DataTable();
                    table.Columns.Add("PartyId");
                    table.Columns.Add("PartyName");
                    table.Columns.Add("PartyTypeTitle");
                    table.Columns.Add("StartDate");
                    table.Columns.Add("EndDate");
                    table.Columns.Add("IsTemp");
                    var partyCustomGridColumnsRepository = partyManager.GetPartyCustomGridColumns(partyType.Id);
                    foreach (var partyCustomGridColumn in partyCustomGridColumnsRepository)
                    {
                        if (partyCustomGridColumn.CustomAttribute != null)
                        {
                            table.Columns.Add(partyCustomGridColumn.CustomAttribute.DisplayName.Replace(" ", "_"));
                        }
                        else
                        {
                            table.Columns.Add(partyCustomGridColumn.TypePair.Title.Replace(" ", "_"));
                        }
                    }

                    for (int i = 0; i < parties.Count(); i++)
                    {
                        DataRow row   = table.NewRow();
                        var     party = parties[i];
                        //var pivotTable = forDataPivot.ToPivotTable(party.CustomAttributeValues,
                        //       item => item.CustomAttribute.Name,
                        //       item => item.Party.Id,
                        //       items => items.Any() ? items.Sum(x => x.VersionNo) : 0);

                        row["PartyId"]        = party.Id;
                        row["PartyName"]      = party.Name;
                        row["PartyTypeTitle"] = party.PartyType.DisplayName;
                        row["StartDate"]      = (party.StartDate != null && party.StartDate < new DateTime(1000, 1, 1) ? "" : party.StartDate.ToShortDateString());
                        row["EndDate"]        = (party.EndDate != null && party.EndDate > new DateTime(3000, 1, 1) ? "" : party.EndDate.ToShortDateString());
                        row["IsTemp"]         = party.IsTemp;
                        foreach (var customAttributeValue in party.CustomAttributeValues)
                        {
                            if (partyCustomGridColumnsRepository.Any(cc => cc.CustomAttribute != null && (cc.CustomAttribute.Id == (customAttributeValue.CustomAttribute.Id))))
                            {
                                row[customAttributeValue.CustomAttribute.DisplayName.Replace(" ", "_")] = customAttributeValue.Value;
                            }
                        }
                        var partyRelationships = partyManager.PartyRelationshipRepository.Get(cc => (cc.SourceParty.Id == party.Id && !cc.PartyTypePair.TargetPartyType.SystemType));
                        foreach (var partyRelationship in partyRelationships)
                        {
                            if (partyCustomGridColumnsRepository.Any(cc => cc.TypePair != null && cc.TypePair.Id == (partyRelationship.PartyTypePair.Id)))
                            {
                                row[partyRelationship.PartyTypePair.Title.Replace(" ", "_")] += "[" + partyRelationship.TargetParty.Name + "] ";
                            }
                        }

                        table.Rows.Add(row);
                    }
                    return(table);
                }
        }
 void Start()
 {
     mainPartyManager=this;//mainPlayerState=this;
     //GameManager.main.PartyManagerStartDelegate+=SetDefaultState;
     //GameManager.GameStart+=SetDefaultState;
     GameManager.GameOver+=GameOverCleanup;
 }