Пример #1
0
 void spawnDrop(Monster monster, Vector3 position)
 {
     for (int i = 0; i < monster.dropIds.Length; i++)
     {
         if (!isUnder(monster.dropChance[i]))
         {
             continue;
         }
         int itemID = monster.dropIds[i];
         Debug.Log("item ID here!: " + itemID + " : " + i);
         GameObject prefab;
         prefab = (GameObject)Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToDropModel")));
         //Drop drop = prefab.AddComponent<Drop>();
         NetworkIdentity identity     = prefab.GetComponent <NetworkIdentity>();
         int             itemQuantity = monster.dropQuantity[i];
         Item            item         = new Item(itemID);
         item.setQuantity(itemQuantity);
         Drop drop = prefab.GetComponent <Drop>();
         drop.initilize(item);
         //drop.initilize(item, this.targetNetwork);
         prefab.transform.position = position;
         NetworkServer.Spawn(prefab);
         ItemInfo packet = new ItemInfo();
         packet.item  = Tools.objectToByteArray(item);
         packet.netId = identity.netId;
         NetworkServer.SendToAll(PacketTypes.DROP_INIT, packet);
     }
 }
Пример #2
0
    public void equipItem(int itemID, string type)
    {
        if (type == "Weapon")
        {
            equipWeapon(itemID);
            return;
        }
        if (type == "Shoe")
        {
            for (int i = 0; i < shoes.Length; i++)
            {
                Destroy(equips[i]);
                equips[i] = Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToModel")));
                equips[i].transform.SetParent(this.character.transform.GetChild(1));
                equips[i].GetComponent <SkinnedMeshRenderer>().rootBone = headTransform.transform;
            }
            return;
        }
        Debug.Log("EQUIPS LENGTH: " + type);
        int        index    = getIndex(type);
        Transform  trans    = equips[index].GetComponent <Transform>();
        GameObject tempItem = Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToModel")));

        equips[index].GetComponent <SkinnedMeshRenderer>().sharedMesh     = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMesh;
        equips[index].GetComponent <SkinnedMeshRenderer>().sharedMaterial = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMaterial;
        Destroy(tempItem);
    }
Пример #3
0
    public static void spawnMonster(int id)
    {
        Monster monsterToFind = getMonsterFromJson(id);

        if (monsterToFind != null)
        {
            GameObject enemy = Instantiate(ResourceStructure.getGameObjectFromPath(monsterToFind.pathToModel));
            NetworkServer.Spawn(enemy);
        }
    }
        public ActionResult RemoveParent(long id)
        {
            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            {
                ResourceStructure resourceStructure = rsManager.GetResourceStructureById(id);
                resourceStructure.Parent = null;
                rsManager.Update(resourceStructure);

                return(RedirectToAction("Edit", new { id = resourceStructure.Id }));
            }
        }
 private bool IsAttributeInStructure(ResourceStructure rs, ResourceStructureAttribute rsa)
 {
     if (rs.ResourceAttributeUsages.Select(a => a.ResourceStructureAttribute.Id).ToList().Contains(rsa.Id))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public ActionResult Edit(long id)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Edit Resource Structures", this.Session.GetTenant());

            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            {
                ResourceStructure resourceStructure = rsManager.GetResourceStructureById(id);
                ViewData["RSID"] = id;
                //ResourceStructureModel tem = new ResourceStructureModel();
                return(View("_editResourceStructure", new ResourceStructureModel(resourceStructure)));
            }
        }
Пример #7
0
    public void spawnActionText(Vector3 startPosition, string text, Color color, int speed)
    {
        GameObject o = Instantiate(ResourceStructure.getGameObjectFromObject(e_Objects.SYSTEM_ACTION_TEXT));

        o.transform.position = startPosition;
        o.transform.SetParent(GameObject.Find("WorldSpaceCanvas").transform);
        Text t = o.GetComponent <Text>();

        t.text  = text;
        t.color = color;
        o.GetComponent <TextFade>().speed = speed;
    }
        public ActionResult AddParent(long id, long parentId)
        {
            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            {
                ResourceStructure parentResourceStructure = rsManager.GetResourceStructureById(parentId);
                ResourceStructure resourceStructure       = rsManager.GetResourceStructureById(id);

                resourceStructure.Parent = parentResourceStructure;
                rsManager.Update(resourceStructure);

                return(RedirectToAction("Edit", new { id = resourceStructure.Id }));
                // return View("_editResourceStructure", new ResourceStructureModel(resourceStructure));
            }
        }
        public ActionResult EditIsFileUsage(long usageId, string isFile)
        {
            using (ResourceStructureAttributeManager rsaManger = new ResourceStructureAttributeManager())
                using (ResourceStructureManager rsManager = new ResourceStructureManager())
                {
                    ResourceAttributeUsage usage = rsaManger.GetResourceAttributeUsageById(usageId);
                    usage.IsFileDataType = Convert.ToBoolean(isFile);
                    rsaManger.UpdateResourceAttributeUsage(usage);

                    ResourceStructure resourceStructure = rsManager.GetResourceStructureById(usage.ResourceStructure.Id);

                    return(View("_editResourceStructure", new ResourceStructureModel(resourceStructure)));
                }
        }
Пример #10
0
    public void equipWeapon(int itemID)
    {
        int index = getIndex("Weapon");

        if (equips[index].transform.childCount == 1)
        {
            Destroy(equips[index].transform.GetChild(0).gameObject);
        }
        GameObject weapon = (GameObject)Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(itemID).getString("pathToModel")));

        weapon.transform.SetParent(equips[index].transform);
        weapon.transform.localPosition = Vector3.zero;
        weapon.transform.localScale    = Vector3.one;
        weapon.transform.localRotation = Quaternion.identity;
    }
        public ActionResult EditResourceStructure(ResourceStructureModel model)
        {
            using (ResourceStructureManager rsManager = new ResourceStructureManager())
            {
                //check name
                ResourceStructure temp = rsManager.GetResourceStructureByName(StringHelper.CutSpaces(model.Name));
                if (temp != null && temp.Id != model.Id)
                {
                    ModelState.AddModelError("NameExist", "Name already exist");
                }


                ResourceStructure rs = rsManager.GetResourceStructureById(model.Id);
                if (rs == null)
                {
                    ModelState.AddModelError("Errors", "ResourceStructure does not exist.");
                }

                if (rs.ResourceAttributeUsages.Select(a => a.ResourceStructureAttribute).ToList().Count() < 1)
                {
                    ModelState.AddModelError("Errors", "Resource Structure has no attributes.");
                }

                if (rs.Parent != null)
                {
                    if (rs.Parent.Id == rs.Id)
                    {
                        ModelState.AddModelError("Errors", "Parent resource structure can not be themselves.");
                    }
                }



                if (ModelState.IsValid)
                {
                    rs.Name        = model.Name;
                    rs.Description = model.Description;

                    rsManager.Update(rs);

                    return(RedirectToAction("ResourceStructure"));
                }
                else
                {
                    return(View("_editResourceStructure", model));
                }
            }
        }
        public ActionResult ResourceStructureUsages_Select(long id)
        {
            using (ResourceStructureManager rsm = new ResourceStructureManager())
            {
                ResourceStructure resourceStructure = rsm.GetResourceStructureById(id);

                List <ResourceStructureAttributeUsageModel> list = new List <ResourceStructureAttributeUsageModel>();
                foreach (ResourceAttributeUsage usage in resourceStructure.ResourceAttributeUsages)
                {
                    list.Add(new ResourceStructureAttributeUsageModel(usage.Id));
                }
                return(View("_showResourceStructureAttributes", new GridModel <ResourceStructureAttributeUsageModel> {
                    Data = list
                }));
            }
        }
Пример #13
0
    public static void setClothes(Item item, GameObject[] origins)
    {
        int index = 1;

        Debug.Log(item.getID());
        if (item.getID().isItemType(e_itemTypes.BODY))
        {
            index = 0;
        }
        Transform  trans    = origins[index].GetComponent <Transform>();
        GameObject tempItem = Instantiate(ResourceStructure.getGameObjectFromPath(ItemDataProvider.getInstance().getStats(item.getID()).getString("pathToModel")));

        origins[index].GetComponent <SkinnedMeshRenderer>().sharedMesh     = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMesh;
        origins[index].GetComponent <SkinnedMeshRenderer>().sharedMaterial = tempItem.GetComponent <SkinnedMeshRenderer>().sharedMaterial;
        Destroy(tempItem);
    }
Пример #14
0
    public static void spawnMonster(int id, Vector3 pos)
    {
        Monster monsterToFind = getMonsterFromJson(id);

        if (monsterToFind != null)
        {
            GameObject   enemy = Instantiate(ResourceStructure.getGameObjectFromPath(monsterToFind.pathToModel));
            NavMeshAgent agent = enemy.GetComponent <NavMeshAgent>();

            if (agent)
            {
                agent.Warp(pos);
            }

            NetworkServer.Spawn(enemy);
        }
    }
        public ActionResult Create(CreateResourceStructureModel model)
        {
            using (ResourceStructureManager rsManager = new ResourceStructureManager())
                using (var pManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                        using (UserManager userManager = new UserManager())
                        {
                            //check name
                            ResourceStructure temp = rsManager.GetResourceStructureByName(StringHelper.CutSpaces(model.Name));
                            if (temp != null)
                            {
                                ModelState.AddModelError("NameExist", "Name already exist");
                            }

                            if (ModelState.IsValid)
                            {
                                ResourceStructure rS = rsManager.Create(model.Name, model.Description, null, null);

                                //Start -> add security ----------------------------------------
                                var userTask = userManager.FindByNameAsync(HttpContext.User.Identity.Name);
                                userTask.Wait();
                                var user = userTask.Result;

                                Entity entityType = entityTypeManager.FindByName("ResourceStructure");

                                //31 is the sum from all rights:  Read = 1, Write = 4, Delete = 8, Grant = 16
                                int rights = (int)RightType.Read + (int)RightType.Write + (int)RightType.Delete + (int)RightType.Grant;
                                pManager.Create(user, entityType, rS.Id, rights);


                                //End -> add security ------------------------------------------


                                ResourceStructureModel rSmodel = new ResourceStructureModel(rS);
                                rSmodel.FirstCreated = true;
                                return(View("_editResourceStructure", rSmodel));
                            }

                            else
                            {
                                return(View("_createResourceStructure", model));
                            }
                        }
        }
 //prevents circulation in parents
 private bool CheckParentPossibility(long rsId, long parentId)
 {
     using (ResourceStructureManager rsManager = new ResourceStructureManager())
     {
         ResourceStructure rsParent = rsManager.GetResourceStructureById(parentId);
         if (rsParent.Parent != null)
         {
             if (rsParent.Parent.Id != rsId)
             {
                 CheckParentPossibility(rsId, rsParent.Parent.Id);
             }
             else
             {
                 return(true);
             }
         }
         return(false);
     }
 }
        public ActionResult Delete(long id)
        {
            using (var rsManager = new ResourceStructureManager())
                using (var permissionManager = new EntityPermissionManager())
                    using (var entityTypeManager = new EntityManager())
                    {
                        ResourceStructure resourceStructure = rsManager.GetResourceStructureById(id);
                        bool deleted = rsManager.Delete(resourceStructure);

                        if (deleted)
                        {
                            Type entityType = entityTypeManager.FindByName("ResourceStructure").EntityType;
                            //delete security
                            permissionManager.Delete(entityType, id);
                        }
                    }

            return(RedirectToAction("ResourceStructure", "ResourceStructure"));
        }
Пример #18
0
    public void damageEnemy(GameObject enemy, e_Objects impactEffect, e_DamageType type, float damageMultiplier)
    {
        DamageInfo damageInfo = new DamageInfo();

        damageInfo.clientNetworkInstanceId = this.GetComponent <NetworkIdentity>().netId;
        damageInfo.enemyNetworkInstanceId  = enemy.GetComponent <NetworkIdentity>().netId;
        damageInfo.damageType       = type;
        damageInfo.damageTarget     = e_DamageTarget.MOB;
        damageInfo.damageMultiplier = damageMultiplier;

        Vector3    pos = new Vector3(enemy.transform.position.x, enemy.transform.position.y + 0.5f, enemy.transform.position.z);
        GameObject o   = Instantiate(ResourceStructure.getGameObjectFromObject(impactEffect));

        o.transform.position   = pos;
        o.transform.localScale = new Vector3(enemy.transform.lossyScale.x * 2, enemy.transform.lossyScale.y * 2, enemy.transform.lossyScale.z * 2);

        player.CmdSpawnGameObjectLocally(ResourceStructure.getPathForObject(impactEffect), pos);

        con.Send(PacketTypes.DEAL_DAMAGE, damageInfo);
    }
Пример #19
0
    //#SETUP
    public override void OnStartServer()
    {
        connectionString = "Server=" + host + ";Database=" + database + ";Uid=" + username + ";Pwd=" + password + ";";
        base.OnStartServer();
        NetworkServer.RegisterHandler(PacketTypes.LOAD_PLAYER, onLoadCharacter);
        NetworkServer.RegisterHandler(PacketTypes.LOGIN, onLogin);
        NetworkServer.RegisterHandler(PacketTypes.DISCONNECT, onDisconnect);
        NetworkServer.RegisterHandler(PacketTypes.SAVE_INVENTORY, onSaveInventory);
        NetworkServer.RegisterHandler(PacketTypes.INVENTORY_MOVE_ITEM, onChangeItem);
        NetworkServer.RegisterHandler(PacketTypes.INVENTORY_DROP_ITEM, onDropItem);
        NetworkServer.RegisterHandler(PacketTypes.LOAD_INVENTORY, onLoadInventory);
        NetworkServer.RegisterHandler(PacketTypes.INVENTORY_PICKUP_ITEM, onPickupItem);
        NetworkServer.RegisterHandler(PacketTypes.SEND_MESSAGE, onReciveMessage);
        NetworkServer.RegisterHandler(PacketTypes.NPC_INTERACT, onNPCInteract);
        NetworkServer.RegisterHandler(PacketTypes.PICK_CHAR, onCharPicked);
        NetworkServer.RegisterHandler(PacketTypes.VERIFY_SKILL, onVerifySkills);
        resourceStructure = new ResourceStructure();

        //Create system objects
        Instantiate(ResourceStructure.getGameObjectFromObject(e_Objects.SYSTEM_RESPAWNER));
    }
        public ActionResult AddResourceAttributeUsages(string rsId, string rsaIds)
        {
            using (ResourceStructureManager rsManger = new ResourceStructureManager())
                using (ResourceStructureAttributeManager rsaManager = new ResourceStructureAttributeManager())
                {
                    ResourceStructure rs = rsManger.GetResourceStructureById(Convert.ToInt64(rsId));

                    string message = "";
                    if (rs != null)
                    {
                        if (!string.IsNullOrEmpty(rsaIds))
                        {
                            var selectedRsa = rsaIds.Split(',').Select(n => int.Parse(n)).ToList();
                            foreach (int i in selectedRsa)
                            {
                                ResourceStructureAttribute rsa = rsaManager.GetResourceStructureAttributesById(i);
                                if (!IsAttributeInStructure(rs, rsa))
                                {
                                    rsaManager.CreateResourceAttributeUsage(rsa, rs, false, false);
                                }
                                else
                                {
                                    message += "Resource Structure Attribute " + rsa.Name + "is allready in the structure.";
                                }
                            }
                        }

                        ResourceStructureModel model = new ResourceStructureModel(rs);
                        model.Message = message;
                        return(View("_editResourceStructure", model));
                    }
                    else
                    {
                        //rs don't exsits ??
                        return(View("_editResourceStructure"));
                    }
                }
        }
        public ActionResult AddResourceAttributeUsage(long rsId, long rsaId)
        {
            using (ResourceStructureManager rsManger = new ResourceStructureManager())
                using (ResourceStructureAttributeManager rsaManager = new ResourceStructureAttributeManager())
                {
                    ResourceStructure          rs  = rsManger.GetResourceStructureById(rsId);
                    ResourceStructureAttribute rsa = rsaManager.GetResourceStructureAttributesById(rsaId);
                    string message = "";

                    if (!IsAttributeInStructure(rs, rsa))
                    {
                        rsaManager.CreateResourceAttributeUsage(rsa, rs, false, false);
                    }
                    else
                    {
                        message += "Resource Structure Attribute " + rsa.Name + "is allready in the structure.";
                    }

                    ResourceStructureModel model = new ResourceStructureModel(rs);
                    model.Message = message;
                    return(View("_editResourceStructure", model));
                }
        }
Пример #22
0
    public override void OnStartLocalPlayer()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        commandManager = new CommandManager(this);
        for (int i = 0; i < prefabsToRegister.Length; i++)
        {
            ClientScene.RegisterPrefab(prefabsToRegister [i]);
        }
        ResourceStructure.initilize();

        /*
         * ClientScene.RegisterPrefab((GameObject)Resources.Load("Prefabs/Enemy"));
         * ClientScene.RegisterPrefab((GameObject)Resources.Load("Particles/Hit"));
         * ClientScene.RegisterPrefab((GameObject)Resources.Load("Particles/ImpactOnGround"));
         * ClientScene.RegisterPrefab(skillPrefab);
         * ClientScene.RegisterPrefab(skillEffectPrefab);*/
        //UI
        UICanvas      = GameObject.Find("UI");
        login         = Tools.findInactiveChild(UICanvas, "Login_UI").GetComponent <Login>();
        this.movement = GetComponent <PlayerMovement>();
        //skills
        this.skillUi = Tools.findInactiveChild(UICanvas, "Actionbar_UI").GetComponent <SkillUIManager>();
        this.skillUi.init(this);
        this.skillManager = GetComponent <SkillManager>();
        this.skillManager.init(this, getSkillUiManager());

        //this.skillTreeUi = GameObject.Find(this.skillTreeUi.name)

        //network
        network = GetComponent <playerNetwork>();
        network.initialize(this);

        this.skillTreeUi = Tools.getChild(UICanvas, this.skillTreeUi.name);

        //chat
        chat = Tools.getChild(UICanvas, "Chat_UI").GetComponent <Chat>();
        chat.setPlayer(this);

        //inventory
        this.inventory = this.GetComponent <Inventory> ();
        this.inventory.init(this);

        //equip
        equip = Tools.getChild(UICanvas, "Equipment_UI").GetComponent <EquipmentHandler>();
        equip.setEquipmentUI(Tools.getChild(UICanvas, "Equipment_UI"));
        equip.setPlayer(this);

        //camera
        camera = Camera.main;
        camera.GetComponent <MainCamera> ().player = this.gameObject;
        camera.GetComponent <MainCamera> ().setState((int)e_cameraStates.DEFAULT);

        //worlds
        worlds[0] = GameObject.Find("login_World");
        worlds[1] = GameObject.Find("World");


        //TempQuestUI
        GameObject tempQuestUI = Instantiate(this.quest_UI);

        this.questInformationData = tempQuestUI.GetComponentInChildren <QuestInformationData>();
        tempQuestUI.transform.SetParent(this.getUI().transform);
        tempQuestUI.transform.SetAsLastSibling();
        tempQuestUI.SetActive(false);
        questInformationObject = tempQuestUI;

        //QuestWrapper
        questWrapper = getUI().transform.GetChild(getUI().transform.childCount - 1).GetChild(1).GetChild(0).GetComponent <QuestWrapper>();

        //UIPlayer
        this.UIPlayer = Tools.findInactiveChild(UICanvas, "Footer_UI").GetComponent <UIPlayerHandler>();
        this.UIPlayer.setPlayer(this);
        this.UIPlayer.gameObject.SetActive(true);
        this.UIPlayer.updateInfo();

        this.UIActionBar = Tools.findInactiveChild(UICanvas, "Actionbar_UI");
        UIActionBar.SetActive(true);
        this.uiStats = Tools.findInactiveChild(UICanvas, "Stat_UI").GetComponent <UIStats>();
        uiStats.gameObject.SetActive(false);
        Debug.Log("STATS: " + this.stats.s_str);

        this.UIDeath = Tools.findInactiveChild(this.getUI(), "Death_UI");
        this.UIDeath.SetActive(true);
        this.UIDeath.GetComponent <GraveStone>().player = this;
        this.UIDeath.SetActive(false);

        //QuestManager
        this.npcController = GameObject.FindWithTag("NPCManager").GetComponent <NPCController>();
        npcController.initilize(this);

        identity = this.GetComponent <NetworkIdentity>();
        Debug.Log("INFO1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    }
Пример #23
0
        public void GenerateSeedData()
        {
            #region ENTITIES

            List <EntityStruct> entities = new List <EntityStruct>();
            entities.Add(new EntityStruct("SingleResource", typeof(SingleResource), typeof(BExIS.Rbm.Services.Resource.SingleResourceStore)));
            entities.Add(new EntityStruct("ResourceStructure", typeof(ResourceStructure), typeof(BExIS.Rbm.Services.ResourceStructure.ResourceStructureStore)));
            entities.Add(new EntityStruct("ResourceStructureAttribute", typeof(ResourceStructureAttribute), typeof(BExIS.Rbm.Services.ResourceStructure.ResourceStructureAttributeStore)));
            entities.Add(new EntityStruct("Activity", typeof(Activity), typeof(BExIS.Rbm.Services.Booking.ActivityStore)));
            entities.Add(new EntityStruct("BookingEvent", typeof(BookingEvent), typeof(BExIS.Rbm.Services.Booking.BookingEventStore)));
            entities.Add(new EntityStruct("Notification", typeof(Notification), typeof(BExIS.Rbm.Services.Booking.NotificationStore)));
            entities.Add(new EntityStruct("Schedule", typeof(Schedule), typeof(BExIS.Rbm.Services.Booking.ScheduleStore)));



            Dictionary <string, Type> rbmEntities = new Dictionary <string, Type>();
            rbmEntities.Add("SingleResource", typeof(SingleResource));
            rbmEntities.Add("ResourceStructure", typeof(ResourceStructure));
            rbmEntities.Add("ResourceStructureAttribute", typeof(ResourceStructureAttribute));
            rbmEntities.Add("Activity", typeof(Activity));
            rbmEntities.Add("BookingEvent", typeof(BookingEvent));
            rbmEntities.Add("Notification", typeof(Notification));
            rbmEntities.Add("Schedule", typeof(Schedule));

            using (var entityManager = new EntityManager())
            {
                foreach (var et in entities)
                {
                    Entity entity = entityManager.Entities.Where(e => e.Name.ToUpperInvariant() == et.Name.ToUpperInvariant()).FirstOrDefault();

                    if (entity == null)
                    {
                        entity                 = new Entity();
                        entity.Name            = et.Name;
                        entity.EntityType      = et.Type;
                        entity.EntityStoreType = et.StoreType;
                        //entity.UseMetadata = true;
                        entity.Securable = true;
                        entityManager.Create(entity);
                    }
                }
            }

            try
            {
                ResourceStructureAttribute rsa = new ResourceStructureAttribute();
                using (var rsaManager = new ResourceStructureAttributeManager())
                    rsa = rsaManager.CreateResourceStructureAttribute("Exploratory", "Biodiversity Exploratories funded by DFG Priority Programme 1374. They serve as open research platform for all biodiversity and ecosystem research groups of Germany.");

                var dcManager = new DataContainerManager();

                string[]          keys        = { "Hainich-Dün", "Schorfheide-Chorin", "Schwäbische Alb" };
                List <DomainItem> domainItems = CreateDomainItems(keys);
                DomainConstraint  dc          = new DomainConstraint(ConstraintProviderSource.Internal, "", "en-US", "a simple domain validation constraint", false, null, null, null, domainItems);
                dcManager.AddConstraint(dc, rsa);


                ResourceStructureAttribute rsa2 = new ResourceStructureAttribute();
                using (var rsaManager2 = new ResourceStructureAttributeManager())
                    rsa2 = rsaManager2.CreateResourceStructureAttribute("Type", "Type of resource.");

                var dcManager2 = new DataContainerManager();

                string[]          keys2        = { "Area", "Equipment", "Sleeping place" };
                List <DomainItem> domainItems2 = CreateDomainItems(keys2);
                DomainConstraint  dc2          = new DomainConstraint(ConstraintProviderSource.Internal, "", "en-US", "a simple domain validation constraint", false, null, null, null, domainItems2);
                dcManager2.AddConstraint(dc2, rsa2);

                ResourceStructureAttribute rsa3 = new ResourceStructureAttribute();
                using (var rsaManager3 = new ResourceStructureAttributeManager())
                    rsa3 = rsaManager3.CreateResourceStructureAttribute("Information File", "Important information as file");

                ResourceStructureManager rsManager = new ResourceStructureManager();;
                ResourceStructure        rs        = rsManager.Create("Explo resources", "Resources related to exploratories.", null, null);

                using (var rsaManager = new ResourceStructureAttributeManager())
                    rsaManager.CreateResourceAttributeUsage(rsa, rs, true, false);
                using (var rsaManager = new ResourceStructureAttributeManager())
                    rsaManager.CreateResourceAttributeUsage(rsa2, rs, true, false);

                using (var rsaManager = new ResourceStructureAttributeManager())
                    rsaManager.CreateResourceAttributeUsage(rsa3, rs, true, true);

                ActivityManager aManager = new ActivityManager();
                aManager.CreateActivity("Adding of material (litter, dead wood, chemicals ....)", "", false);
                aManager.CreateActivity("Adding of organisms (seeds and others)", "", false);
                aManager.CreateActivity("Conference", "", false);
                aManager.CreateActivity("Contact stakeholder", "", false);
                aManager.CreateActivity("Dismantling of experiments", "", false);
                aManager.CreateActivity("Installation of equipment remaining for some time", "", false);
                aManager.CreateActivity("Measuring and marking of subplots/experiments/study organisms", "", false);
                aManager.CreateActivity("Observation/capture of organisms without removal", "", false);
                aManager.CreateActivity("Plot maintenance", "", false);
                aManager.CreateActivity("Removal of org. material without killing", "", false);
                aManager.CreateActivity("Removal of organisms", "", false);
                aManager.CreateActivity("Removal of soil samples", "", false);
                aManager.CreateActivity("Visit without activity", "", false);

                ResourceManager             rManager = new ResourceManager();;
                List <newResourceStructure> rs_new   = new List <newResourceStructure>();

                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all EPs (SCH)", color = "#ec5959", description = "Visit of all forest EPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all MIPs (SCH)", color = "#ec5959", description = "Visit of all forest MIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all VIPs (SCH)", color = "#ec5959", description = "Visit of all forest VIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Altenhof", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Arnimswalde", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Chorin", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Eichheide", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Glambeck", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Liepe", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Maienpfuhl", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Melzow", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Poratz", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Ringenwalde", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Senftenthal", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Theerofen", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Voigtswiese", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - Forstgut Altkuenkendorf", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - Fuerstliche Forstverwaltung Oettingen-Spielberg", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - Stiftung Schorfheide-Chorin", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - FOX (SCH)", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - RP/UP (SCH)", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - ABP Landwirtschaft Neugrimnitz GmbH", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AEVG Stegelitz-Flieth", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Agrargemeinschaft Greiffenberg GmbH", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all EPs (SCH)", color = "#ff0000", description = "Visit of all grassland EPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all MIPs (SCH)", color = "#ff0000", description = "Visit of all grassland MIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all VIPs (SCH)", color = "#ff0000", description = "Visit of all grassland VIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Gut Biesenbrow", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Ingolf Limber", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Lehrschaeferei Friedrichsfelde", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - LW-Betrieb Haferkamp", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Naturrind GmbH Boeckenberg", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Reiner Wegner", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Weidewirtschaft Liepe", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "no plot visit (SCH)", color = "#e28f8f", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin"
                });


                rs_new.Add(new newResourceStructure()
                {
                    name = "Sleeping place (SCH)", color = "#9c3939", description = "Sleeping places in Schorfheide-Chorin", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Sleeping place", explo = "Schorfheide-Chorin"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Drying cabinet (SCH)", color = "#940b0b", description = "Drying cabinet in Schorfheide-Chorin", duration = 1, quantity = 5, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Fridge (SCH)", color = "#940b0b", description = "Fridge in Schorfheide-Chorin", duration = 1, quantity = 2, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Freezer (SCH)", color = "#940b0b", description = "Freezer in Schorfheide-Chorin", duration = 1, quantity = 2, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Metal detector (Magna Trak 100) (SCH)", color = "#940b0b", description = "Metal detector (Magna Trak 100) in Schorfheide-Chorin", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Binocular (SCH)", color = "#940b0b", description = "", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Chest freezer (SCH)", color = "#940b0b", description = "", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Helmet (SCH)", color = "#940b0b", description = "", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all EPs (HAI)", color = "#8cca0d", description = "Visit of all forest EPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all GPs (HAI)", color = "#8cca0d", description = "Visit of all forestGPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all MIPs (HAI)", color = "#8cca0d", description = "Visit of all forest MIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all VIPs (HAI)", color = "#8cca0d", description = "Visit of all forest VIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - FOX (HAI)", color = "8cca0d", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Anrode", color = "#8cca0d", description = "Forest - district Anrode", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - city of Mühlhausen", color = "#8cca0d", description = "Forest - city of Mühlhausen", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Behringen", color = "#8cca0d", description = "Forest - district Behringen", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Geney", color = "#8cca0d", description = "Forest - district Geney", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Keula", color = "#8cca0d", description = "Forest - district Keula", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Langula", color = "#8cca0d", description = "Forest - district Langula", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Sollstedt", color = "#8cca0d", description = "Forest - district Sollstedt", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Zehnsberg", color = "#8cca0d", description = "Forest - district Zehnsberg", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - national park", color = "#8cca0d", description = "Forest - national park", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - national park Weberstedterholz (core zone)", color = "#8cca0d", description = "Forest - national park Weberstedterholz (core zone)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - district Westerwald", color = "#8cca0d", description = "Forest - district Westerwald", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all GPs (HAI)", color = "#9acd32", description = "Visit of all grassland GPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all EPs (HAI)", color = "#9acd32", description = "Visit of all grassland EPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all MIPs (HAI)", color = "#9acd32", description = "Visit of all grassland MIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all VIPs (HAI)", color = "#9acd32", description = "Visit of all grassland VIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - RP/UP (HAI)", color = "9acd32", description = "Visit of all new landuse experiment plots in HAI (HEG1,2,3,6,14,15)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });


                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Diedorf", color = "#9acd32", description = "Grassland - AG Diedorf", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Großenlupnitz", color = "#9acd32", description = "Grassland - AG Großenlupnitz", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Kirchheiligen", color = "#9acd32", description = "Grassland - AG Kirchheiligen", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Bollstedt", color = "#9acd32", description = "Grassland - AG Bollstedt", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Lengefeld", color = "#9acd32", description = "Grassland - AG Lengefeld", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Mülverstedt", color = "#9acd32", description = "Grassland - AG Mülverstedt", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Wartburgblick", color = "#9acd32", description = "Grassland - AG Wartburgblick", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG Wenigenlupnitz", color = "#9acd32", description = "Grassland - AG Wenigenlupnitz", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - AG-Struth-Eigenrieden", color = "#9acd32", description = "Grassland - AG-Struth-Eigenrieden", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - BEAG/TOA", color = "#9acd32", description = "Grassland - BEAG/TOA", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Bundesforst Dörnaerplatz", color = "#9acd32", description = "Grassland - Bundesforst Dörnaerplatz", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Gut Sambach", color = "#9acd32", description = "Grassland - Gut Sambach", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Thüringen Wagyu Becker&Becker", color = "#9acd32", description = "Grassland - Thüringen Wagyu Becker&Becker", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Heller", color = "#9acd32", description = "Grassland - Heller", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Schaeferei Effenberger", color = "#9acd32", description = "Grassland - Schaeferei Effenberger", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Nationalpark", color = "#9acd32", description = "Grassland - Nationalpark", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Nordagrar (Naturrind Unstruttal)", color = "#9acd32", description = "Grassland - Nordagrar (Naturrind Unstruttal)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Schaeferei Goepfert", color = "#9acd32", description = "Grassland - Schaeferei Goepfert", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Börner", color = "#9acd32", description = "Grassland - Börner", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - Strewe-Winterberg", color = "#9acd32", description = "Grassland - Strewe-Winterberg", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - TUPAG (Hainich Weiderind)", color = "#9acd32", description = "Grassland - TUPAG (Hainich Weiderind)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "no plot visit", color = "#a9fb00", description = "No plot visit in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün"
                });


                rs_new.Add(new newResourceStructure()
                {
                    name = "Sleeping place (HAI)", color = "#78ab0f", description = "Sleeping place in Hainich-Dün", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Sleeping place", explo = "Hainich-Dün"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Drying cabinet (HAI)", color = "#6a8a27", description = "Drying cabinete in Hainich-Dün", duration = 1, quantity = 4, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Fridge (HAI)", color = "#6a8a27", description = "Fridge in Hainich-Dün", duration = 1, quantity = 2, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Freezer (HAI)", color = "#6a8a27", description = "Freezer in Hainich-Dün", duration = 1, quantity = 3, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Metal detector (Magna Trak 100) (HAI)", color = "#6a8a27", description = "Metal detector (Magna Trak 100) in Hainich-Dün", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Metal detector (Garrett ACE  150) (HAI)", color = "#6a8a27", description = "Metal detector (Garrett ACE  150) in Hainich-Dün", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün"
                });


                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - all EPs (ALB)", color = "#3a75e0", description = "Visit of all forest EPs in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - VIP AEW1-8 (ALB)", color = "#3a75e0", description = "Visit of all VIP AEW1-8 in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - VIP AEW9 (Alb)", color = "#3a75e0", description = "Visit of all VIP AEW9 in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Forest - FOX (ALB)", color = "#3a75e0", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });


                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all EPs excluding former military training area", color = "#6495ed", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all EPs including former military training area", color = "#6495ed", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - all VIPs (ALB)", color = "#6495ed", description = "Visit of all grassland VIPs in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Grassland - RP/UP (ALB)", color = "#6495ed", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });


                rs_new.Add(new newResourceStructure()
                {
                    name = "no plot visit (ALB)", color = "#0057f5", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "total Exploratory outside EP", color = "#0057f6", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Sleeping place (ALB)", color = "#27509a", description = "Sleeping places in Schwäbische Alb", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Sleeping place", explo = "Schwäbische Alb"
                });

                rs_new.Add(new newResourceStructure()
                {
                    name = "Drying cabinet (ALB)", color = "#7e95bf", description = "Drying cabinet in Schwäbische Alb", duration = 1, quantity = 5, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Binocular (ALB)", color = "#7e95bf", description = "", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schwäbische Alb"
                });
                rs_new.Add(new newResourceStructure()
                {
                    name = "Metal detector (Magna Trak 100) (ALB)", color = "#7e95bf", description = "Metal detector (Magna Trak 100) in Schwäbische Alb", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schwäbische Alb"
                });

                //get/create admin group for entity rights
                using (var groupManager = new GroupManager())
                    using (var permissionManager = new EntityPermissionManager())
                        using (var entityManager = new EntityManager())
                            using (var valueManager = new ResourceStructureAttributeManager())
                            {
                                var adminGroup = groupManager.Groups.Where(r => r.Name == "administrator").FirstOrDefault();
                                if (adminGroup == null)
                                {
                                    // create new group
                                    adminGroup = new Group
                                    {
                                        Name          = "administrator",
                                        Description   = "administrator",
                                        DisplayName   = "administrator",
                                        IsSystemGroup = false,
                                        IsValid       = true
                                    };

                                    groupManager.CreateAsync(adminGroup).Wait();
                                }

                                //create right type
                                int rights = (int)RightType.Read + (int)RightType.Write + (int)RightType.Delete + (int)RightType.Grant;

                                foreach (newResourceStructure rs_item in rs_new)
                                {
                                    var duration = new TimeDuration();
                                    duration.Value = rs_item.duration;
                                    var resource = rManager.CreateResource(rs_item.name, rs_item.description, rs_item.quantity, rs_item.color, rs_item.withActivity, rs_item.resourceStructure, duration);

                                    //add entity rights
                                    permissionManager.Create(adminGroup,
                                                             entityManager.FindByName("SingleResource"),
                                                             resource.Id,
                                                             rights
                                                             );

                                    ResourceAttributeUsage usage = valueManager.GetResourceAttributeUsageById(1);
                                    valueManager.CreateResourceAttributeValue(rs_item.explo, rManager.GetResourceById(resource.Id), usage);
                                    ResourceAttributeUsage usage2 = valueManager.GetResourceAttributeUsageById(2);
                                    valueManager.CreateResourceAttributeValue(rs_item.type, rManager.GetResourceById(resource.Id), usage2);
                                }
                            }
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }
            #endregion

            #region SECURITY

            OperationManager operationManager = new OperationManager();
            FeatureManager   featureManager   = new FeatureManager();

            try
            {
                List <Feature> features = featureManager.FeatureRepository.Get().ToList();

                Feature ResourceBooking = features.FirstOrDefault(f => f.Name.Equals("Resource Booking"));
                if (ResourceBooking == null)
                {
                    ResourceBooking = featureManager.Create("Resource Booking", "Resource Booking");
                }

                Feature NotificationBlackboard = features.FirstOrDefault(f => f.Name.Equals("Notification Blackboard"));
                if (NotificationBlackboard == null)
                {
                    NotificationBlackboard = featureManager.Create("Notification Blackboard", "Notification Blackboard", ResourceBooking);
                }


                Feature ResourceAdmin = features.FirstOrDefault(f => f.Name.Equals("Resource Administration"));
                if (ResourceAdmin == null)
                {
                    ResourceAdmin = featureManager.Create("Resource Administration", "Resource Administration");
                }

                Feature ResourceManagement = features.FirstOrDefault(f => f.Name.Equals("Resource Management"));
                if (ResourceManagement == null)
                {
                    ResourceManagement = featureManager.Create("Resource Management", "Resource Management", ResourceAdmin);
                }

                Feature ResourceStructureManagement = features.FirstOrDefault(f => f.Name.Equals("Resource Structure Management"));
                if (ResourceStructureManagement == null)
                {
                    ResourceStructureManagement = featureManager.Create("Resource Structure Management", "Resource Structure Management", ResourceAdmin);
                }

                Feature ResourceStructureAttributeManagement = features.FirstOrDefault(f => f.Name.Equals("Resource Structure Attribute Management"));
                if (ResourceStructureAttributeManagement == null)
                {
                    ResourceStructureAttributeManagement = featureManager.Create("Resource Structure Attribute Management", "Resource Structure Attribute Management", ResourceAdmin);
                }

                Feature NotificationManagement = features.FirstOrDefault(f => f.Name.Equals("Notification Management"));
                if (NotificationManagement == null)
                {
                    NotificationManagement = featureManager.Create("Notification Management", "Notification Management", ResourceAdmin);
                }

                Feature ActivityManagement = features.FirstOrDefault(f => f.Name.Equals("Activity Management"));
                if (ActivityManagement == null)
                {
                    ActivityManagement = featureManager.Create("Activity Management", "Activity Management", ResourceAdmin);
                }


                operationManager.Create("RBM", "Schedule", "*", ResourceBooking);
                operationManager.Create("RBM", "Calendar", "*", ResourceBooking);
                operationManager.Create("RBM", " NotificationBlackboard", "*", NotificationBlackboard);



                operationManager.Create("RBM", "Resource", "*", ResourceManagement);
                operationManager.Create("RBM", "ResourceStructure", "*", ResourceStructureManagement);
                operationManager.Create("RBM", "ResourceStructure", "*", ResourceStructureAttributeManagement);
                operationManager.Create("RBM", "Notification", "*", NotificationManagement);
                operationManager.Create("RBM", "Activity", "*", ActivityManagement);

                #region Help Workflow

                if (!operationManager.Exists("RBM", "help", "*"))
                {
                    operationManager.Create("RBM", "Help", "*");
                }

                #endregion Help Workflow
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                operationManager.Dispose();
                featureManager.Dispose();
            }

            #endregion
        }
Пример #24
0
 public static GameObject loadObjectFromResources(e_Objects obj)
 {
     return((GameObject)Resources.Load(ResourceStructure.getPathForObject(obj)));
 }
Пример #25
0
 void Start()
 {
     wood = new ResourceStructure("wood", 0, 25);
 }
        public ActionResult SaveResourceStructureAttribute(EditResourceStructureAttributeModel model, string[] keys)
        {
            using (var rsaManager = new ResourceStructureAttributeManager())
            {
                //check name
                if (model.AttributeName != null)
                {
                    ResourceStructureAttribute tempRS = rsaManager.GetResourceStructureAttributesByName(StringHelper.CutSpaces(model.AttributeName));
                    if (tempRS != null && tempRS.Id != model.Id)
                    {
                        ModelState.AddModelError("NameExist", "Name already exist.");
                    }
                }

                //check domain items
                if (keys != null)
                {
                    List <DomainItemModel> tempList = new List <DomainItemModel>();
                    foreach (string k in keys)
                    {
                        DomainItemModel d = new DomainItemModel();
                        d.Key   = k;
                        d.Value = k;
                        tempList.Add(d);
                        if (string.IsNullOrEmpty(k))
                        {
                            ModelState.AddModelError("DomainItem", "One domain item has no value.");
                        }
                    }
                    model.DomainItems = tempList;
                }

                if (ModelState.IsValid)
                {
                    ResourceStructureAttribute rsa = new ResourceStructureAttribute();
                    using (var rsManager = new ResourceStructureManager())
                    {
                        if (model.Id == 0)
                        {
                            rsa = rsaManager.CreateResourceStructureAttribute(model.AttributeName, model.AttributeDescription);
                        }
                        else
                        {
                            rsa             = rsaManager.GetResourceStructureAttributesById(model.Id);
                            rsa.Name        = model.AttributeName;
                            rsa.Description = model.AttributeDescription;
                            rsaManager.UpdateResourceStructureAttribute(rsa);
                        }

                        if (rsa != null && model.Id == 0)
                        {
                            //Start -> add security ----------------------------------------

                            using (EntityPermissionManager pManager = new EntityPermissionManager())
                                using (var entityTypeManager = new EntityManager())
                                    using (UserManager userManager = new UserManager())
                                    {
                                        var userTask = userManager.FindByNameAsync(HttpContext.User.Identity.Name);
                                        userTask.Wait();
                                        var user = userTask.Result;

                                        Entity entityType = entityTypeManager.FindByName("ResourceStructureAttribute");

                                        pManager.Create(user, entityType, rsa.Id, 31);
                                    }

                            //End -> add security ------------------------------------------
                        }


                        if (keys != null)
                        {
                            List <DomainItem> domainItems = CreateDomainItems(keys);
                            using (var dcManager = new DataContainerManager())
                            {
                                if (model.Id == 0 || rsa.Constraints.Count() == 0)
                                {
                                    DomainConstraint dc = new DomainConstraint(ConstraintProviderSource.Internal, "", "en-US", "a simple domain validation constraint", false, null, null, null, domainItems);
                                    dcManager.AddConstraint(dc, rsa);
                                }
                                else
                                {
                                    DomainConstraint temp = (DomainConstraint)rsa.Constraints.ElementAt(0);
                                    temp.Materialize();
                                    temp.Items = domainItems;
                                    dcManager.AddConstraint(temp, rsa);
                                }
                            }
                        }

                        //Creation with usage
                        if (model.rsID != 0)
                        {
                            ResourceStructure resourceStructure = rsManager.GetResourceStructureById(model.rsID);
                            rsaManager.CreateResourceAttributeUsage(rsa, resourceStructure, true, false);
                            //resourceStructure.ResourceStructureAttributes.Add(rsa);
                            //rsManager.Update(resourceStructure);
                            //return View("_editResourceStructure", new ResourceStructureModel(resourceStructure));
                            return(Json(new { success = true }));
                        }
                        else
                        {
                            return(Json(new { success = true }));
                        }
                    }
                }
                else
                {
                    return(PartialView("_createResourceStructureAttribute", model));
                }
            }
        }