Ejemplo n.º 1
0
        public void RefreshProjectsAndResources()
        {
            OnRefreshing();

            try {
                projects      = new ItemList <Project>();
                projectNames  = new Dictionary <Guid, string>();
                resources     = new ItemList <Resource>();
                resourceNames = new Dictionary <Guid, string>();

                projectAncestors    = new Dictionary <Guid, HashSet <Guid> >();
                projectDescendants  = new Dictionary <Guid, HashSet <Guid> >();
                resourceAncestors   = new Dictionary <Guid, HashSet <Guid> >();
                resourceDescendants = new Dictionary <Guid, HashSet <Guid> >();

                HiveServiceLocator.Instance.CallHiveService(service => {
                    service.GetProjects().ForEach(p => projects.Add(p));
                    service.GetSlaveGroups().ForEach(g => resources.Add(g));
                    service.GetSlaves().ForEach(s => resources.Add(s));
                    projectNames  = service.GetProjectNames();
                    resourceNames = service.GetResourceNames();
                });

                RefreshResourceGenealogy();
                RefreshProjectGenealogy();
                RefreshDisabledParentProjects();
                RefreshDisabledParentResources();
            } catch {
                projects  = null;
                resources = null;
                throw;
            } finally {
                OnRefreshed();
            }
        }
Ejemplo n.º 2
0
    void OnAddItem_AddItem(ItemObject item)
    {
        //BagItemObject _container = Global.Component.GetPlayerBag();
        ContainerPack _containerPack = GetContainerPack();

        if (_containerPack == null)
        {
            //TODO все забито
        }

        IItemList <ItemObject> _innerItems = _containerPack.GetInnerItems();
        IRender    _render    = _containerPack.GetRender();
        GameObject _container = _containerPack.GetContainer();

        if (_innerItems != null)
        {
            //if (_container.IsFuLL() == false)
            //{

            if (IsOpen(_container) == true)
            {
                _innerItems.Add(item);
                _render.Add(item);
            }
            else
            {
                item.inventoryData.SetSlotID(_render.GetFreeSlotID((ItemObject)_innerItems));
                _innerItems.Add(item);
            }
            //}
        }
    }
Ejemplo n.º 3
0
        public void Refresh()
        {
            OnRefreshing();

            try {
                resources = new ItemList <Resource>();
                projects  = new ItemList <Project>();
                projectResourceAssignments = new ItemList <AssignedProjectResource>();
                jobs          = new Dictionary <Guid, HiveItemCollection <RefreshableJob> >();
                tasks         = new Dictionary <Guid, List <LightweightTask> >();
                projectNames  = new Dictionary <Guid, string>();
                resourceNames = new Dictionary <Guid, string>();

                projectAncestors    = new Dictionary <Guid, HashSet <Guid> >();
                projectDescendants  = new Dictionary <Guid, HashSet <Guid> >();
                resourceAncestors   = new Dictionary <Guid, HashSet <Guid> >();
                resourceDescendants = new Dictionary <Guid, HashSet <Guid> >();

                HiveServiceLocator.Instance.CallHiveService(service => {
                    service.GetSlaveGroupsForAdministration().ForEach(g => resources.Add(g));
                    service.GetSlavesForAdministration().ForEach(s => resources.Add(s));
                    service.GetProjectsForAdministration().ForEach(p => projects.Add(p));
                    var projectIds = projects.Select(p => p.Id).ToList();
                    if (projectIds.Any())
                    {
                        service.GetAssignedResourcesForProjectsAdministration(projectIds)
                        .ForEach(a => projectResourceAssignments.Add(a));

                        var unsortedJobs = service.GetJobsByProjectIds(projectIds)
                                           .OrderBy(x => x.DateCreated).ToList();

                        projectNames  = service.GetProjectNames();
                        resourceNames = service.GetResourceNames();
                    }
                });

                UpdateResourceGenealogy();
                UpdateProjectGenealogy();
                RefreshDisabledParentProjects();
                RefreshDisabledParentResources();
            } catch {
                throw;
            } finally {
                OnRefreshed();
            }
        }
Ejemplo n.º 4
0
    public void Refresh() {
      OnRefreshing();

      try {
        resources = new ItemList<Resource>();

        HiveServiceLocator.Instance.CallHiveService(service => {
          service.GetSlaveGroups().ForEach(g => resources.Add(g));
          service.GetSlaves().ForEach(s => resources.Add(s));
        });
      }
      catch {
        throw;
      }
      finally {
        OnRefreshed();
      }
    }
Ejemplo n.º 5
0
        public void Refresh()
        {
            OnRefreshing();

            try {
                resources = new ItemList <Resource>();

                HiveServiceLocator.Instance.CallHiveService(service => {
                    service.GetSlaveGroups().ForEach(g => resources.Add(g));
                    service.GetSlaves().ForEach(s => resources.Add(s));
                });
            }
            catch {
                throw;
            }
            finally {
                OnRefreshed();
            }
        }
Ejemplo n.º 6
0
        private void Dt_TableNewRow(object sender, DataTableNewRowEventArgs e)
        {
            T p = Activator.CreateInstance <T>();

            IItemList list = GetDataList(scen);
            int       id   = list.GetFreeGameObjectID();

            e.Row["id"] = id;
            p.ID        = id;
            list.Add(p);
        }
Ejemplo n.º 7
0
        public virtual bool AddOperator(IOperator op)
        {
            var tOp = op as T;

            if (tOp == null)
            {
                return(false);
            }
            operators.Add(tOp);
            return(true);
        }
Ejemplo n.º 8
0
    public void RefreshCalendar() {
      if (downtimeForResourceId != null && downtimeForResourceId != Guid.Empty) {
        OnRefreshing();

        try {
          downtimes = new ItemList<Downtime>();

          HiveServiceLocator.Instance.CallHiveService(service => {
            service.GetDowntimesForResource(downtimeForResourceId).ForEach(d => downtimes.Add(d));
          });
        }
        catch {
          throw;
        }
        finally {
          OnRefreshed();
        }
      }
    }
Ejemplo n.º 9
0
        public void RefreshCalendar()
        {
            if (downtimeForResourceId != null && downtimeForResourceId != Guid.Empty)
            {
                OnRefreshing();

                try {
                    downtimes = new ItemList <Downtime>();

                    HiveServiceLocator.Instance.CallHiveService(service => {
                        service.GetDowntimesForResource(downtimeForResourceId).ForEach(d => downtimes.Add(d));
                    });
                }
                catch {
                    throw;
                }
                finally {
                    OnRefreshed();
                }
            }
        }
Ejemplo n.º 10
0
        private void dg_ItemsSourceChanged(object sender, EventArgs e)
        {
            if (settingUp)
            {
                return;
            }

            DataGrid  dataGrid = (DataGrid)sender;
            IItemList list     = GetDataList(scen);

            for (int r = 0; r < dataGrid.Items.Count; r++)
            {
                DataRowView item = dataGrid.Items[r] as DataRowView;
                if (item == null)
                {
                    continue;
                }

                int id = (int)item["id"];
                T   p  = (T)list.GetGameObject(id);
                if (p == null)
                {
                    p = Activator.CreateInstance <T>();
                    list.Add(p);
                }
                FieldInfo[]    fields     = getFieldInfos();
                PropertyInfo[] properties = getPropertyInfos();

                foreach (FieldInfo i in fields)
                {
                    string iName = getColumnName(i.Name);

                    if (i.FieldType.IsEnum)
                    {
                        i.SetValue(p, (Int32)Enum.ToObject(i.FieldType, item[iName]));
                    }
                    else if (i.FieldType == typeof(InfluenceKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllInfluenceKinds.GetInfluenceKind((int)item[iName]));
                    }
                    else if (i.FieldType == typeof(ConditionKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllConditionKinds.GetConditionKind((int)item[iName]));
                    }
                    else if (i.FieldType == typeof(TitleKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllTitleKinds.GetTitleKind((int)item[iName]));
                    }
                    else if (i.FieldType == typeof(GameObjects.ArchitectureDetail.EventEffect.EventEffectKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllEventEffectKinds.GetEventEffectKind((int)item[iName]));
                    }
                    else if (i.FieldType == typeof(GameObjects.TroopDetail.EventEffect.EventEffectKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllTroopEventEffectKinds.GetEventEffectKind((int)item[iName]));
                    }
                    else if (i.FieldType == typeof(List <int>))
                    {
                        i.SetValue(p, item[iName].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select((x) => int.Parse(x)).ToList());
                    }
                    else
                    {
                        if (item[iName] != DBNull.Value)
                        {
                            i.SetValue(p, item[iName]);
                        }
                    }
                }
                foreach (PropertyInfo i in properties)
                {
                    string iName = getColumnName(i.Name);

                    if (i.PropertyType.IsEnum)
                    {
                        i.SetValue(p, (Int32)Enum.ToObject(i.PropertyType, item[iName]));
                    }
                    else if (i.PropertyType == typeof(InfluenceKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllInfluenceKinds.GetInfluenceKind((int)item[iName]));
                    }
                    else if (i.PropertyType == typeof(ConditionKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllConditionKinds.GetConditionKind((int)item[iName]));
                    }
                    else if (i.PropertyType == typeof(TitleKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllTitleKinds.GetTitleKind((int)item[iName]));
                    }
                    else if (i.PropertyType == typeof(GameObjects.ArchitectureDetail.EventEffect.EventEffectKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllEventEffectKinds.GetEventEffectKind((int)item[iName]));
                    }
                    else if (i.PropertyType == typeof(GameObjects.TroopDetail.EventEffect.EventEffectKind))
                    {
                        i.SetValue(p, scen.GameCommonData.AllTroopEventEffectKinds.GetEventEffectKind((int)item[iName]));
                    }
                    else if (i.PropertyType == typeof(List <int>))
                    {
                        i.SetValue(p, item[iName].ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select((x) => int.Parse(x)).ToList());
                    }
                    else
                    {
                        if (item[iName] != DBNull.Value)
                        {
                            i.SetValue(p, item[iName]);
                        }
                    }
                }
            }
        }