Пример #1
0
        /// <summary>
        /// Update the transport and elements with new status
        /// </summary>
        /// <param name="transports"></param>
        /// <param name="recTransportStatus"></param>
        /// <returns></returns>
        public int UpdateStatusTransport( List<RecTransport> transports, RecTransport recTransportStatus )
        {
            if( null == transports || transports.Count == 0 )
            {
                return 0;
            }

            ProjectManager mgr = new ProjectManager();
            RecElementIdStatusStd std = new RecElementIdStatusStd { Factory = recTransportStatus.Factory, Project = recTransportStatus.Project };
            List<RecElementIdStatusStd> settings = mgr.LoadStandardSettings( std );

            foreach( RecTransport recTransport in transports )
            {
                UpdateStatus( recTransport, recTransportStatus, settings );
            }

            return 0;
        }
Пример #2
0
        /// <summary>
        /// Update the transport and elements with new status
        /// </summary>
        /// <param name="transports"></param>
        /// <param name="recTransportStatus"></param>
        /// <returns></returns>
        public int UpdateStatusProductionCast( List<RecProductionCast> casts, RecProductionCast recProductionCastStatus )
        {
            if( null == casts || casts.Count == 0 )
            {
                return 0;
            }

            ProjectManager mgr = new ProjectManager();
            RecElementIdStatusStd std = new RecElementIdStatusStd { Factory = recProductionCastStatus.Factory, Project = recProductionCastStatus.Project };
            List<RecElementIdStatusStd> settings = mgr.LoadStandardSettings( std );

            int ret = 0;
            foreach( RecProductionCast rec in casts )
            {
                ret += UpdateStatus( rec, recProductionCastStatus, settings );
            }

            return ret;
        }
Пример #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 );
		}
Пример #4
0
		/// <summary>
		/// Returns a list of the reset element ids.
		/// </summary>
		/// <param name="record">The record to delete from the database.</param>
		/// <returns>The number of affected records.</returns>
		public CastScheduleResult DeleteProductionCast( RecProductionCast record )
		{
            ProjectManager projectManagerService = new ProjectManager();   
            BedFilter filter = new BedFilter();
            filter.Factory = record.Factory;
            List<string> projectsInvolved = projectManagerService.LoadCastProjects( filter, record.CastId );
            if( null == projectsInvolved )
            {
                return null;
            }

            ProjectManager mgr = new ProjectManager();
            RecElementIdStatusStd std = new RecElementIdStatusStd { Factory = record.Factory, Project = record.Project };
            List<RecElementIdStatusStd> settings = mgr.LoadStandardSettings( std );

			ModelPlanner svc = new ModelPlanner( );
            List<int> deletedIds = svc.LoadElementIds( record.Factory, record.Project, record.CastId );

            // (1) Reset elements
            // Update Status, Note this can be optimized!
            RecProductionCast recProductionCastStatus = new RecProductionCast( record );
            recProductionCastStatus.CastStatus = (int)CastStatus.NoStatus;
            recProductionCastStatus.ElementIdStatus = RecElementIdStatusStd.GetLocalSettingFromGlobalId( settings, recProductionCastStatus.CastStatus).StatusId;
            UpdateStatus( record, recProductionCastStatus, settings );
            // Now reset
			svc.ResetElementProduction( record.Factory, record.Project, record.CastId, 0, false );

            // (2) Delete strands
            RecProductionCastStrand recStrand = new RecProductionCastStrand();
            recStrand.Factory = record.Factory;
            recStrand.Project = record.Factory; // Factory, Factory for productionCast & ProductionCastStrand
            recStrand.CastId = record.CastId;
            recStrand.StrandPos = 0;
            ProjectManager strand = new ProjectManager();
            strand.DeleteProductionCastStrand(recStrand);
            // (3) Now delete the cast Object
            int result = 0;
            // The cast object can be deleted if no elements belong to other projects other that the current one
            if( projectsInvolved.Count == 0 || (projectsInvolved.Count == 1 && projectsInvolved[0].Equals( record.Project ) )  )
            {
                var delete = new ImpactDelete( ImpProductionCast.Instance )
                {
                    Where = 
				{
					{ ImpProductionCast.Factory.Equal( record.Factory )},
					{ ImpProductionCast.Project.Equal( record.Factory )},// Factory, Factory for productionCast & ProductionCastStrand
					{ ImpProductionCast.CastId.Equal( record.CastId )},
				}
                };

                string statement = delete.ToString();

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

			return new CastScheduleResult(deletedIds, projectsInvolved);
		}