Exemplo n.º 1
0
		/// <summary>
		/// Load all records of the same factory and project as the supplied record.
		/// </summary>
		/// <param name="record">A record with factory and project set.</param>
		/// <returns>A list of all mathcing records.</returns>
		public List<RecTransportStack> LoadTransportStack( RecTransportStack record )
		{
			ImpactQuery query = new ImpactQuery()
			{
				Select =
				{
					ImpTransportStack.Factory,
					ImpTransportStack.Project,
					ImpTransportStack.TransportId,
					ImpTransportStack.VehicleId,
					ImpTransportStack.StackId,
					ImpTransportStack.Rack,
					ImpTransportStack.StackX,
					ImpTransportStack.StackY,
					ImpTransportStack.StackZ,
					ImpTransportStack.StackRotation,
					ImpTransportStack.Description,
					ImpTransportStack.StackType,
					ImpTransportStack.StackPosition,
					ImpTransportStack.MaxLength,
					ImpTransportStack.MaxWidth,
					ImpTransportStack.MaxHeight,
					ImpTransportStack.MaxMass,

				},
				From = { ImpTransportStack.As( "T1" ) },
				Where = { ImpTransportStack.Factory.Equal( record.Factory ), 
						  ImpTransportStack.Project.Equal( record.Project ), 
						  ImpTransportStack.TransportId.Equal( record.TransportId ), 
						  ImpTransportStack.VehicleId.Equal( record.VehicleId ) 
						}
			};
			
			if( record.StackId > 0 )
			{
				query.Where.Add( ImpTransportStack.StackId.Equal( record.StackId ) );
			}

			string statement = query.ToString();

			List<RecTransportStack> result;

			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.GetAll( statement, ParseTransportStack );
			}

			return result;
		}
Exemplo n.º 2
0
		/// <summary>
		/// Parses one row in <see cref="System.Data.Common.DbDataReader"/> into
		/// a new instance of <see cref="StruSoft.Impact.V120.Common.Records.RecTransportStack"/>.
		/// </summary>
		/// <param name="dataReader">The data reader.</param>
		/// <returns>A new instance of <see cref="StruSoft.Impact.V120.Common.Records.RecTransportStack"/>.</returns>
		public static RecTransportStack ParseTransportStack( DbDataReader dataReader )
		{
			var record = new RecTransportStack();
			record.Factory = DataConverter.Cast<string>( dataReader[0] );
			record.Project = DataConverter.Cast<string>( dataReader[1] );
			record.TransportId = DataConverter.Cast<int>( dataReader[2] );
			record.VehicleId = DataConverter.Cast<int>( dataReader[3] );
			record.StackId = DataConverter.Cast<int>( dataReader[4] );
			record.Rack = DataConverter.Cast<string>( dataReader[5] );
			record.StackX = DataConverter.Cast<double>( dataReader[6] );
			record.StackY = DataConverter.Cast<double>( dataReader[7] );
			record.StackZ = DataConverter.Cast<double>( dataReader[8] );
			record.StackRotation = DataConverter.Cast<double>( dataReader[9] );
			record.Description = DataConverter.Cast<string>( dataReader[10] );
			record.StackType = DataConverter.Cast<int>( dataReader[11] );
			record.StackPosition = DataConverter.Cast<int>( dataReader[12] );
			record.MaxLength = DataConverter.Cast<double>( dataReader[13] );
			record.MaxWidth = DataConverter.Cast<double>( dataReader[14] );
			record.MaxHeight = DataConverter.Cast<double>( dataReader[15] );
			record.MaxMass = DataConverter.Cast<double>( dataReader[16] );
			return record;
		}
Exemplo n.º 3
0
        /// <summary>
        /// Delete Cascade Stack
        /// </summary>
        /// <param name="transport"></param>
        /// <param name="veh"></param>
        /// <param name="stack"></param>
        /// <returns></returns>
		public int DeleteCascadeStackTransport( RecTransport transport, RecTransportVehicleStd veh, RecTransportStack stack )
		{
            ProjectManager mgr = new ProjectManager();
            RecElementIdStatusStd std = new RecElementIdStatusStd { Factory = transport.Factory, Project = transport.Project };
            List<RecElementIdStatusStd> settings = mgr.LoadStandardSettings( std );

            // Update Status, Note this can be optimized!
            RecTransport recTransportStatus = new RecTransport( transport );
            recTransportStatus.TransportStatus = (int)TransportStatus.NoStatus;
            recTransportStatus.ElementIdStatus = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, recTransportStatus.TransportStatus).StatusId;
            UpdateStatus( transport, recTransportStatus, settings );
            // No reset
			ModelPlanner svc = new ModelPlanner();
			svc.ResetTransport( transport.Factory, transport.Project, 0, transport.TransportId, veh.VehicleId, stack.StackId );

			ProjectManager StackSvc = new ProjectManager();
			return StackSvc.DeleteTransportStack( stack );
		}
Exemplo n.º 4
0
		public int DeleteCascadeVehicleTransport( RecTransport transport, RecTransportVehicleStd veh )
		{
			RecTransportStack rec = new RecTransportStack();
			rec.Factory = transport.Factory;
			rec.Project = transport.Project;
			rec.TransportId = transport.TransportId;
			rec.VehicleId = veh.VehicleId;

			// Delete cascade stacks
			ProjectManager svc = new ProjectManager();
			List<RecTransportStack> stacks = svc.LoadTransportStack( rec );
			foreach( RecTransportStack stack in stacks )
			{
				this.DeleteCascadeStackTransport( transport, veh, stack );
			}

			// Now delete the vehicle
			ProjectManager vehSvc = new ProjectManager();
			List<RecTransportVehicleStd> vehicles = new List<RecTransportVehicleStd>();
			vehicles.Add( veh );
			return vehSvc.RemoveTransportVehicles( transport, vehicles );
		}
Exemplo n.º 5
0
		/// <summary>
		/// Update the specified record in the database.
		/// </summary>
		/// <param name="record">The record to update.</param>
		/// <returns></returns>
		public int UpdateTransportStack( RecTransportStack record )
		{

			var update = new ImpactUpdate( ImpTransportStack.Instance )
			{
				Columns = 
				{
					{ ImpTransportStack.Rack, record.Rack },
					{ ImpTransportStack.StackX, record.StackX },
					{ ImpTransportStack.StackY, record.StackY },
					{ ImpTransportStack.StackZ, record.StackZ },
					{ ImpTransportStack.StackRotation, record.StackRotation },
					{ ImpTransportStack.Description, record.Description },
					{ ImpTransportStack.StackType, record.StackType },
					{ ImpTransportStack.StackPosition, record.StackPosition },
					{ ImpTransportStack.MaxLength, record.MaxLength },
					{ ImpTransportStack.MaxWidth, record.MaxWidth },
					{ ImpTransportStack.MaxHeight, record.MaxHeight },
					{ ImpTransportStack.MaxMass, record.MaxMass },
				},
				Where = 
				{
					{ ImpTransportStack.Factory.Equal( record.Factory ) },
					{ ImpTransportStack.Project.Equal( record.Project ) },
					{ ImpTransportStack.TransportId.Equal( record.TransportId ) },
					{ ImpTransportStack.VehicleId.Equal( record.VehicleId ) },
					{ ImpTransportStack.StackId.Equal( record.StackId ) },
				},
			};

			string statement = update.ToString();

			int result;

			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.ExecuteNonQuery( statement );
			}

			return result;
		}
Exemplo n.º 6
0
		/// <summary>
		/// Delete the specified record from the database.
		/// </summary>
		/// <param name="record">The record to delete from the database.</param>
		/// <returns>The number of affected records.</returns>
		public int DeleteTransportStack( RecTransportStack record )
		{
			var delete = new ImpactDelete( ImpTransportStack.Instance )
			{
				Where = 
				{
					{ ImpTransportStack.Factory.Equal( record.Factory )},
					{ ImpTransportStack.Project.Equal( record.Project )},
					{ ImpTransportStack.TransportId.Equal( record.TransportId )},
					{ ImpTransportStack.VehicleId.Equal( record.VehicleId )},
					{ ImpTransportStack.StackId.Equal( record.StackId )},
				}
			};

			string statement = delete.ToString();

			int result;

			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.ExecuteNonQuery( statement );
			}

			return result;
		}
Exemplo n.º 7
0
		/// <summary>
		/// Insert the specified record into the database.
		/// </summary>
		/// <param name="record">The record to insert into the database.</param>
		/// <returns>The number of affected records.</returns>
		public int InsertTransportStack( RecTransportStack record )
		{
			var insert = new ImpactInsert( ImpTransportStack.Instance )
			{
				Columns = 
				{
					{ ImpTransportStack.Factory, record.Factory },
					{ ImpTransportStack.Project, record.Project },
					{ ImpTransportStack.TransportId, record.TransportId },
					{ ImpTransportStack.VehicleId, record.VehicleId },
					{ ImpTransportStack.StackId, record.StackId },
					{ ImpTransportStack.Rack, record.Rack },
					{ ImpTransportStack.StackX, record.StackX },
					{ ImpTransportStack.StackY, record.StackY },
					{ ImpTransportStack.StackZ, record.StackZ },
					{ ImpTransportStack.StackRotation, record.StackRotation },
					{ ImpTransportStack.Description, record.Description },
					{ ImpTransportStack.StackType, record.StackType },
					{ ImpTransportStack.StackPosition, record.StackPosition },
					{ ImpTransportStack.MaxLength, record.MaxLength },
					{ ImpTransportStack.MaxWidth, record.MaxWidth },
					{ ImpTransportStack.MaxHeight, record.MaxHeight },
					{ ImpTransportStack.MaxMass, record.MaxMass },
				}
			};

			string statement = insert.ToString();

			int result;

			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.ExecuteNonQuery( statement );
			}

			return result;
		}