public void UpdateMap(Entity.Map Map)
        {
            //to update, we need to load MapDictionary first
            DAL.MapDictionaryDA.IMapDictionary baseMapInfoDA     = new DAL.MapDictionaryDA.MapDictionaryDAO();
            List <DAL.MapDictionary>           tmpDictionaryList = baseMapInfoDA.GetMapDictionary();
            Dictionary <string, MapDictionary> dict = new Dictionary <string, MapDictionary>();

            foreach (MapDictionary d in tmpDictionaryList)
            {
                dict.Add(d.MapKey.Trim(), d);
            }
            dict[Entity.Map.KEY_MAP_NAME].MapValue           = Map.MapName;
            dict[Entity.Map.KEY_LAYER_COUNT].MapValue        = Map.LayerCount + "";
            dict[Entity.Map.KEY_RACK_COUNT].MapValue         = Map.RackCount + "";
            dict[Entity.Map.KEY_COLUMN_COUNT].MapValue       = Map.ColumnCount + "";
            dict[Entity.Map.KEY_GAP_ALOMG_RACK].MapValue     = Map.GapAlongRack + "";
            dict[Entity.Map.KEY_GAP_ALONG_COLUMN].MapValue   = Map.GapAlongCloumn + "";
            dict[Entity.Map.KEY_GAP_BETWEEN_LAYERS].MapValue = Map.GapBetweenLayers + "";
            dict[Entity.Map.KEY_PS_MAXSPEED].MapValue        = Map.PSMaxSpeed + "";
            dict[Entity.Map.KEY_PS_ACCELERATION].MapValue    = Map.PSAcceleration + "";
            dict[Entity.Map.KEY_PS_DECELERATION].MapValue    = Map.PSDeceleration + "";
            dict[Entity.Map.KEY_CS_MAXSPEED].MapValue        = Map.CSMaxSpeed + "";
            dict[Entity.Map.KEY_CS_ACCELERATION].MapValue    = Map.CSAcceleration + "";
            dict[Entity.Map.KEY_CS_DECELERATION].MapValue    = Map.CSDeceleration + "";
            dict[Entity.Map.KEY_L_MAXSPEED].MapValue         = Map.LMaxSpeed + "";
            dict[Entity.Map.KEY_L_ACCELERATION].MapValue     = Map.LAcceleration + "";
            dict[Entity.Map.KEY_L_DECELERATION].MapValue     = Map.LDeceleration + "";
            baseMapInfoDA.UpdateMapDictionary(tmpDictionaryList);
        }
 /// <summary>
 /// use this method only when recreate a map or the map id the database is null
 /// </summary>
 /// <param name="MapName"></param>
 /// <param name="layers"></param>
 /// <param name="racks"></param>
 /// <param name="columns"></param>
 /// <returns></returns>
 public Entity.Map CreateNewMap(string MapName, int layers, int racks, int columns)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         Map             = new Entity.Map();
         Map.MapName     = MapName;
         Map.RackCount   = racks;
         Map.LayerCount  = layers;
         Map.ColumnCount = columns;
         //first save map initial messages
         this.MapDictionaryService = new Repository.MapDictionaryService();
         this.MapDictionaryService.InsertMap(Map);
         //Reset Zones' static color
         Zone.ResetRrandomColor();
         //initial all services as the map reference for one
         InitialServices(Map);
         //create general types list
         List <Entity.Types> generalTypes = TypesService.LoadTypes();
         if (generalTypes.Count == 0)//if there has no types in the database, create new and save from code
         {
             generalTypes = GetGeneralTypes();
             this.TypesService.InsertTypes(generalTypes);
         }
         //ALERT!! must be constrainted here as the same name of all the GENERAL_TYPES, or will has logical error
         //ALERT!! you can modify and make contraint from "public class ItemTypesString" in this singleton class
         Entity.Types tt = Map.Types.Single(t => t.Name == ItemTypesString.ITEM_TYPE_DEFAULT_STORAGE);
         this._default_storage = tt;
         //then set mapitems, default type Id is zt's Type Id
         List <Entity.MapItems> additionMapItemList = new List <MapItems>();
         for (int i = 0; i < layers; i++)
         {
             for (int j = 0; j < racks; j++)
             {
                 for (int k = 0; k < columns; k++)
                 {
                     Entity.MapItems tmp     = new Entity.MapItems();
                     DAL.MapItems    DAL_tmp = new DAL.MapItems()
                     {
                         MapItemLayer  = i,
                         MapItemRack   = j,
                         MapItemColumn = k,
                         TypeId        = tt.Id,
                         ZoneId        = 0,
                         CargowayId    = 0,
                         Status        = (int)MapItems.MapItemStatus.STATUS_NOT_STORAGE
                     };
                     tmp.DAL_SetMapItem(DAL_tmp);
                     additionMapItemList.Add(tmp);
                 }
             }
         }
         MapItemsService.InsertMapItems(additionMapItemList);
         scope.Complete();
     }
     return(Map);
 }
        public void DeleteMap(Entity.Map Map)
        {
            //Delete All infos in MapDictionary table
            //because of entity framework's delete needs Id necessarily
            //we must do the query first
            DAL.MapDictionaryDA.IMapDictionary baseMapInfoDA = new DAL.MapDictionaryDA.MapDictionaryDAO();
            List <DAL.MapDictionary>           del           = baseMapInfoDA.GetMapDictionary();

            baseMapInfoDA.DeleteMapDictionary(del);
        }
        private void InitialServices(Entity.Map map)
        {
            this.MapItemsService          = new Repository.MapItemService(map);
            this.GoodsService             = new Repository.GoodsService(map);
            this.ZonesService             = new Repository.ZonesService(map);
            this.TypesService             = new Repository.TypesService(map);
            this.SpecialConnectionService = new Repository.SpecialConnectionService(map);
            this.CargoWaysService         = new Repository.CargoWaysService(map);
            this.CargoWaysLockService     = new Repository.CargoWaysLockService(map);
            this.RailsService             = new Repository.RailsService(map);

            this.MapLogicsService = new MapLogicsService(map);
            //this.MapAlgorithmService = new MapAlgorithmService(map);
        }
        public void InsertMap(Entity.Map Map)
        {
            List <DAL.MapDictionary> insertsDictionary = new List <MapDictionary>();

            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_MAP_NAME, Map.MapName));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_LAYER_COUNT, Map.LayerCount + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_RACK_COUNT, Map.RackCount + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_COLUMN_COUNT, Map.ColumnCount + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_GAP_BETWEEN_LAYERS, Map.GapBetweenLayers + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_GAP_ALONG_COLUMN, Map.GapAlongCloumn + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_GAP_ALOMG_RACK, Map.GapAlongRack + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_PS_MAXSPEED, Map.PSMaxSpeed + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_PS_ACCELERATION, Map.PSAcceleration + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_PS_DECELERATION, Map.PSDeceleration + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_CS_MAXSPEED, Map.CSMaxSpeed + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_CS_ACCELERATION, Map.CSAcceleration + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_CS_DECELERATION, Map.CSDeceleration + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_L_MAXSPEED, Map.LMaxSpeed + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_L_ACCELERATION, Map.LAcceleration + ""));
            insertsDictionary.Add(CreateNewMapDictionary(Entity.Map.KEY_L_DECELERATION, Map.LDeceleration + ""));
            DAL.MapDictionaryDA.IMapDictionary baseMapInfoDA = new DAL.MapDictionaryDA.MapDictionaryDAO();
            baseMapInfoDA.InsertMapDictionary(insertsDictionary);
        }
        public Entity.Map GetMap()
        {
            DAL.MapDictionaryDA.IMapDictionary baseMapInfoDA = new DAL.MapDictionaryDA.MapDictionaryDAO();
            List <DAL.MapDictionary>           dict          = baseMapInfoDA.GetMapDictionary();

            if (dict.Count == 0)
            {
                return(null);
            }
            Entity.Map map = new Entity.Map();
            //load properties
            Dictionary <string, string> tmpDict = new Dictionary <string, string>();

            foreach (DAL.MapDictionary md in dict)
            {
                tmpDict.Add(md.MapKey.Trim(), md.MapValue.Trim());
            }
            map.MapName          = tmpDict[Entity.Map.KEY_MAP_NAME];
            map.LayerCount       = int.Parse(tmpDict[Entity.Map.KEY_LAYER_COUNT]);
            map.RackCount        = int.Parse(tmpDict[Entity.Map.KEY_RACK_COUNT]);
            map.ColumnCount      = int.Parse(tmpDict[Entity.Map.KEY_COLUMN_COUNT]);
            map.GapAlongRack     = double.Parse(tmpDict[Entity.Map.KEY_GAP_ALOMG_RACK]);
            map.GapAlongCloumn   = double.Parse(tmpDict[Entity.Map.KEY_GAP_ALONG_COLUMN]);
            map.GapBetweenLayers = double.Parse(tmpDict[Entity.Map.KEY_GAP_BETWEEN_LAYERS]);
            map.PSMaxSpeed       = double.Parse(tmpDict[Entity.Map.KEY_PS_MAXSPEED]);
            map.PSDeceleration   = double.Parse(tmpDict[Entity.Map.KEY_PS_DECELERATION]);
            map.PSAcceleration   = double.Parse(tmpDict[Entity.Map.KEY_PS_ACCELERATION]);
            map.CSMaxSpeed       = double.Parse(tmpDict[Entity.Map.KEY_CS_MAXSPEED]);
            map.CSDeceleration   = double.Parse(tmpDict[Entity.Map.KEY_CS_DECELERATION]);
            map.CSAcceleration   = double.Parse(tmpDict[Entity.Map.KEY_CS_ACCELERATION]);
            map.LMaxSpeed        = double.Parse(tmpDict[Entity.Map.KEY_L_MAXSPEED]);
            map.LDeceleration    = double.Parse(tmpDict[Entity.Map.KEY_L_DECELERATION]);
            map.LAcceleration    = double.Parse(tmpDict[Entity.Map.KEY_L_ACCELERATION]);

            return(map);
        }
Example #7
0
 public ZonesService(Entity.Map map)
 {
     this._map = map;
     _DAL_Zone = new List <DAL.Zone>();
 }
Example #8
0
 public CargoWaysLockService(Entity.Map map)
 {
     this._map = map;
     this._DAL_CargoWaysLocks = new List <DAL.CargoWaysLock>();
 }
Example #9
0
 public TypesService(Entity.Map map)
 {
     this._map       = map;
     this._DAL_Types = new List <DAL.Types>();
 }
Example #10
0
 public CargoWaysService(Entity.Map map)
 {
     this._map      = map;
     _DAL_CargoWays = new List <DAL.CargoWays>();
 }
Example #11
0
 public RailsService(Models.Entity.Map _map)
 {
     this._map       = _map;
     this._DAL_Rails = new List <DAL.Rails>();
 }
Example #12
0
 public GoodsService(Entity.Map map)
 {
     this._map          = map;
     this._DAL_GoodList = new List <DAL.Goods>();
 }
Example #13
0
 public SpecialConnectionService(Entity.Map map)
 {
     this._map = map;
     this._DAL_SpecialConnections = new List <DAL.SpecialConnection>();
 }
Example #14
0
 public MapItemService(Entity.Map map)
 {
     this._map                    = map;
     this._DAL_MapItemList        = new List <DAL.MapItems>();
     this._DAL_SpecialMapItemList = new List <DAL.MapItems>();
 }