Beispiel #1
0
		public bool Load( RecTMElement elem, RecTransport recTransport, RecTransportVehicleStd recVeh )
		{
			// *** Force erection sequence since it is paramount ***
			// Once a vehicle is set till full, never try to put other lighter elements even though
			// the total weight still allowed
			if( IsFull )
			{
				return false;
			}
			// It is not allowed to use a vehicle not capable to carry a single element!
			if( elem.Mass > TransportVehicleStackStdObject.MaxMass )
			{
				string elemMass = elem.Mass.ToString( "#0.000" );
				string stackMaxMass = TransportVehicleStackStdObject.MaxMass.ToString( "#0.000" );
				string msg = string.Format( "The stack \"{0}\" max load capacity {1} < element mass {2} for element \"{3}\", Standard vehicle \"{4}\" !",
					TransportVehicleStackStdObject.Description,
					stackMaxMass,
					elemMass,
					elem.ElementId,
					TransportVehicleStackStdObject.Name );
				throw new FaultException<BusinessFaultContract>( new BusinessFaultContract() { Argument = msg }, "Stack load capacity < Element mass!" );
			}
			double tot = GetTotElementMass() + elem.Mass;
			if( tot > TransportVehicleStackStdObject.MaxMass )
			{
				IsFull = true;
				return false;
			}
			else
			{
				TMElements.Add( new TMElement( elem ) );
			}
			return true;
		}
        /// <summary> 
        /// Creates a new record if the desired record is not yet created 
        /// and updates the desired record.
        /// </summary>
        /// <param name="rec">RecTransportPlanner</param>
        private void SaveElementTransport( RecTMElement rec )
        {
            if( rec == null || rec.Factory == null || rec.Project == null )
            {
                return;
            }
            // Now update the element with transport information
            ImpactUpdate update = new ImpactUpdate( ImpModelPlanning.Instance )
            {
                Columns =
                {
                    //{ ImpTransport.TransportStatus, record.TransportStatus },
                },
                Where =
				{
					ImpModelPlanning.Factory.Equal( rec.Factory ),
					ImpModelPlanning.Project.Equal( rec.Project ),
				}
            };
            // Extra Where Clause
            if( rec.ElementId > 0 )
            {
                update.Where.Add( ImpModelPlanning.ElementId.Equal( rec.ElementId ) );
            }
            else
            {
                update.Where.Add( ImpModelPlanning.TransportId.Equal( rec.TransportId ) );
            }

            // Extra Update fields
            if( rec.TransportId > 0 )
            {
                update.Columns.Add( ImpModelPlanning.TransportId, rec.TransportId );
            }

            if( rec.VehicleId > 0 )
            {
                update.Columns.Add( ImpModelPlanning.VehicleId, rec.VehicleId );
            }

            if( rec.StackId > 0 )
            {
                update.Columns.Add( ImpModelPlanning.StackId, rec.StackId );
            }
            if( rec.StackSequenceNo > 0 )
            {
                update.Columns.Add( ImpModelPlanning.StackSequenceNo, rec.StackSequenceNo );
            }

            string sql = update.ToString();

            int result;

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                result = database.ExecuteNonQuery( sql );
            }
        }
Beispiel #3
0
		public bool CanAdd( ExBed bed, RecTMElement element)
		{
			double maxWidth = bed.MaxWidth;
			double currWidth = GetWidth() + TolenranceY + element.ElementWidthOnBed;
			if( maxWidth >= currWidth )
			{
				return true;
			}

			return false;
		}
        /// <summary> 
        /// Creates a new record if the desired record is not yet created 
        /// and updates the desired record.
        /// </summary>
        /// <param name="rec">RecTransportPlanner</param>
        public void SaveElementTransport( RecTMElement rec, bool verifyExist )
        {
            if( rec == null || rec.Factory == null || rec.Project == null || rec.ElementId == 0 )
            {
                return;
            }

            // Create a new record if it doesnt exist
            if( verifyExist )
            {
                Verify( rec.Factory, rec.Project, rec.ElementId );
            }

            SaveElementTransport( rec );
        }
Beispiel #5
0
		public bool Load( RecTMElement elem, RecTransport recTransport )
		{
			foreach( TMStack tmStack in Stacks )
			{
				// Try to load this element on the current vehicle
				if( tmStack.Load( elem, recTransport, TransportVehicleStdObject ) )
				{
					return true;
				}
			}
			// OK, All the vehicles are already fully loaded
			IsFull = true;
			// return false, to indicate that.
			return false;
		}
Beispiel #6
0
		//private bool SimpleLoad(RecTMElement elem)
		//{
		//  if (Vehicles.Count == 0 && elem.Mass > TransportObject.MaxMass)
		//  {
		//    string msg = string.Format("Transport {0} max load capacity {1} < element mass {2} for element{3}!", TransportObject.Name, TransportObject.MaxMass, elem.Mass, elem.Element_id);
		//    throw new FaultException<BusinessFaultContract>(new BusinessFaultContract() { Argument = msg }, "Transport load capacity < Element mass!");
		//  }
		//  double tot = GetTotElementMass() + elem.Mass;
		//  if (tot > TransportObject.MaxMass)
		//  {
		//    IsFull = true;
		//    return false;
		//  }
		//  else
		//  {
		//    TMElements.Add(new TMElement(elem));
		//  }
		//  return true;
		//}
		public bool Load( RecTMElement elem )
		{
			// Vehicle transport Mode
			foreach( TMVehicle tmVehicle in Vehicles )
			{
				// Try to load this element on the current vehicle
				if( tmVehicle.Load( elem, TransportObject ) )
				{
					return true;
				}
			}
			// OK, All the vehicles are already fully loaded
			IsFull = true;
			// return false, to indicate that.
			return false;
		}
Beispiel #7
0
		private bool ProcessLoad( RecTMElement elem, List<RecTransport> templates )
		{
			TMTransport tmTransport = GetTMTransport( templates );
			if( tmTransport == null )
			{
				return false;
			}
			if( !tmTransport.Load( elem ) )
			{
				// OK that transport device was full, let's try the next transport
				// Recursive call!
				if( !ProcessLoad( elem, templates ) )
				{
					return false;
				}
			}
			return true;
		}
        /// <summary>
        /// Parsing helper
        /// </summary>
        /// <param name="column">column</param>
        /// <returns></returns>
        private static DataHolder ParseSchedule( DbDataReader column )
        {
            RecProductionCast cast = new RecProductionCast()
            {
                CastId = DataConverter.Cast<int>( column[0] ),

                Description = DataConverter.Cast<string>( column[1] ),
                StartDate = DataConverter.Cast<DateTime>( column[2] ),
                EndDate = DataConverter.Cast<DateTime?>( column[3] ),
                Tolerance = DataConverter.Cast<double>( column[4] ),
                ElementType = DataConverter.Cast<string>( column[5] ),
                Style = DataConverter.Cast<string>( column[6] ),
                Strandptn = DataConverter.Cast<string>( column[7] ),
                CastStatus = DataConverter.Cast<int>( column[8] ),
                CastType = DataConverter.Cast<int>( column[9] ),

                Form = DataConverter.Cast<string>( column[10] ),
                Shift = DataConverter.Cast<int>( column[11] ),
                NumOfStrands = DataConverter.Cast<int>( column[12] ),
                Location = DataConverter.Cast<string>( column[13] ),
            };
            RecProductionFormStd form = new RecProductionFormStd()
            {
                Location = DataConverter.Cast<string>( column[13] ), // Location repeated here!!!
                FormType = DataConverter.Cast<int>( column[14] ),
                MaxLength = DataConverter.Cast<double?>( column[15] ) ?? 0d,
                MaxWidth = DataConverter.Cast<double?>( column[16] ) ?? 0d,
                MaxHeight = DataConverter.Cast<double?>( column[17] ) ?? 0d,
                ElementType = DataConverter.Cast<string>( column[18] ),
            };

            RecTMElement elem = null;
            int elementId = DataConverter.Cast<int?>( column[19] ) ?? 0;
            if( 0 != elementId )
            {
                elem = new RecTMElement()
                {
                    ElementId = elementId,
                    ElementMark = DataConverter.Cast<string>( column[20] ),

                    Building = DataConverter.Cast<string>( column[21] ),
                    FloorId = DataConverter.Cast<int?>( column[22] ) ?? 0,
                    Phase = DataConverter.Cast<string>( column[23] ),

                    ErectionSequenceNo = DataConverter.Cast<int?>( column[24] ) ?? 0,
                    TransportId = DataConverter.Cast<int?>( column[25] ) ?? 0,

                    BedSequenceNo = DataConverter.Cast<int>( column[26] ),
                    BedX = DataConverter.Cast<double>( column[27] ),
                    BedY = DataConverter.Cast<double>( column[28] ),
                    BedZ = DataConverter.Cast<double>( column[29] ),
                    BedRotation = DataConverter.Cast<double>( column[30] ),
                    ElementIdStatus = DataConverter.Cast<int>( column[31] ),

                    ProductionDate = column[32].Cast<DateTime?>(),
                    PlannedProductionDate = column[33].Cast<DateTime?>(),

                    ElementLength = DataConverter.Cast<double?>( column[34] ) ?? 0d,
                    ElementWidth = DataConverter.Cast<double?>( column[35] ) ?? 0d,
                    ElementHeight = DataConverter.Cast<double?>( column[36] ) ?? 0d,
                    ElementType = DataConverter.Cast<string>( column[37] ),
                    GrossArea = DataConverter.Cast<double?>( column[38] ) ?? 0d,
                    NetArea = DataConverter.Cast<double?>( column[39] ) ?? 0d,
                    Volume = DataConverter.Cast<double?>( column[40] ) ?? 0d,
                    Product = DataConverter.Cast<string>( column[41] ),
                    Project = DataConverter.Cast<string>( column[42] ),
                    AngleLeft = DataConverter.Cast<double?>( column[43] ) ?? 0d,
                    AngleRight = DataConverter.Cast<double?>( column[44] ) ?? 0d,
                    Mass = DataConverter.Cast<double?>( column[45] ) ?? 0d,

                    Style = DataConverter.Cast<string>( column[46] ),
                    Strandptn = DataConverter.Cast<string>( column[47] ),
                    NbrOfStrands = DataConverter.Cast<int>( column[48] ),
                };
            }

            return new DataHolder( cast, form, elem );
        }
        /// <summary>
        /// Parsing helper
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        private static RecTMElement ElementParse( DbDataReader column )
        {
            var record = new RecTMElement
                             {
                                 ElementMark = column[0].Cast<string>(),
                                 ElementLength = column[1].Cast<double?>() ?? 0d,
                                 ElementWidth = column[2].Cast<double?>() ?? 0d,
                                 ElementHeight = column[3].Cast<double?>() ?? 0d,
                                 ElementType = column[4].Cast<string>(),
                                 AngleLeft = column[5].Cast<double?>() ?? 0d,
                                 AngleRight = column[6].Cast<double?>() ?? 0d,
                                 Style = column[7].Cast<string>(),
                                 Strandptn = column[8].Cast<string>(),
                                 NbrOfStrands = column[9].Cast<int>(),
                                 Factory = column[10].Cast<string>(),
                                 Project = column[11].Cast<string>(),
                                 ElementId = column[12].Cast<int?>() ?? 0
                             };

            return record;
        }
Beispiel #10
0
 /// <summary>
 /// Looks for an element
 /// </summary>
 /// <param name="totPositioned"></param>
 /// <param name="elem"></param>
 /// <returns></returns>
 public bool Find( List<RecTMElement> totPositioned, RecTMElement elem )
 {
     return totPositioned.Any( positioned => positioned.GetKey().Equals( elem.GetKey() ) );
 }
Beispiel #11
0
 public DataHolder( RecProductionCast cast, RecProductionFormStd form, RecTMElement element )
 {
     this.Cast = cast;
     this.Form = form;
     this.Element = element;
 }
        /// <summary>
        /// Load data
        /// </summary>
        /// <param name="rec"> </param>
        /// <returns></returns>
        public List<RecTransport> LoadTemplates( RecTMElement rec )
        {
            if( rec == null )
            {
                throw new ArgumentNullException( "RecTransportManager" );
            }
            List<RecTransport> result = new List<RecTransport>();

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                ImpactQuery query = new ImpactQuery()
                {
                    From = { ImpTransport.As( "T1" ) },
                    Where =
					{
						ImpTransport.Factory.Equal( rec.Factory ),
						ImpTransport.Project.Equal( rec.Project ),
						ImpTransport.IsTemplate.Equal( true ),
						ImpTransport.IsVisible.Equal( true ),
					},
                    OrderBy = { ImpTransport.TransportId },
                };

                string statement = query.ToString();

                result = database.GetAll( statement, rdr => new RecTransport()
                {
                    Factory = DataConverter.Cast<string>( rdr["FACTORY"] ),
                    Project = DataConverter.Cast<string>( rdr["PROJECT"] ),
                    TransportStatus = DataConverter.Cast<int>( rdr["Transport_status"] ),
                    Description = DataConverter.Cast<string>( rdr["Description"] ),
                    TransportId = DataConverter.Cast<int>( rdr["Transport_Id"] ),
                    LoadDate = DataConverter.Cast<DateTime>( rdr["Load_Date"] ),
                    DeliveryDate = DataConverter.Cast<DateTime>( rdr["Delivery_Date"] ),
                    TimeInterval = DataConverter.Cast<int>( rdr["Time_Interval"] ),
                    IsTemplate = DataConverter.Cast<int>( rdr["Is_Template"] ),
                    TemplateId = DataConverter.Cast<int>( rdr["Template_Id"] ),
                    IsVisible = DataConverter.Cast<int>( rdr["Is_Visible"] ),
                } );
            }

            return result;
        }
 bool Find( RecTMElement newElem, List<RecTMElement> elements )
 {
     foreach( RecTMElement elem in elements )
     {
         if( newElem.ElementId == elem.ElementId )
         {
             return true;
         }
     }
     return false;
 }
Beispiel #14
0
        /// <summary>
        /// Parsing helper
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        private static RecTMElement ElementParse( DbDataReader column )
        {
            var record = new RecTMElement
                             {
                                 Style = column[0].Cast<string>(),
                                 Strandptn = column[1].Cast<string>(),
                                 NbrOfStrands = column[2].Cast<int>(),
                             };

            return record;
        }
Beispiel #15
0
        /// <summary>
        /// Create Production Cast
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public RecProductionCast AdjustProductionCastToElement( RecTMElement element )
        {
            var result = LoadElement( element );
            this.ProductionCast.Style = result.Style;
            this.ProductionCast.Strandptn = result.Strandptn;
            this.ProductionCast.NumOfStrands = result.NbrOfStrands;

            return this.ProductionCast;
        }
        private bool SwapElements( RecTMElement element1, RecTMElement element2 )
        {
            if( element1 == null || element2 == null )
            {
                return false;
            }
            Boolean rotated = false;
            RecTMElement temp = new RecTMElement( element1 );
            if( element1.BedRotation != element2.BedRotation )
            {
                // Rotate the first
                RecTMElement recRotated = RecTMElement.RotateElement( element1 );
                element1.BedX = recRotated.BedX;
                element1.BedY = recRotated.BedY;
                element1.BedRotation = recRotated.BedRotation;
                rotated = true;
            }
            // Gap Between Elements
            double gap = GetGap( element1, element2 );

            element1.BedSequenceNo = element2.BedSequenceNo;
            element1.BedX += element2.ElementLengthOnBed + gap;

            // Correct the rotation before saving
            if( rotated )
            {
                RecTMElement recRotated = RecTMElement.RotateElement( element1 );
                element1.BedX = recRotated.BedX;
                element1.BedY = recRotated.BedY;
                element1.BedRotation = recRotated.BedRotation;
            }
            SaveElementProduction( element1, false );

            element2.BedSequenceNo = temp.BedSequenceNo;
            element2.BedX -= ( temp.ElementLengthOnBed + gap );

            SaveElementProduction( element2, false );

            return true;
        }
Beispiel #17
0
        /// <summary>
        /// Loads element details
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        private static RecTMElement LoadElement( RecTMElement element )
        {
            if( element == null || string.IsNullOrEmpty( element.Factory ) || string.IsNullOrEmpty( element.Project ) )
            {
                return null;
            }

            List<RecTMElement> result;
            var query = new ImpactQuery()
            {
                Select =
				{
					ImpElement.Style,
					ImpElement.Strandptn,
					ImpElement.NbrOfStrands,
				},

                From = { ImpElement.As( "ELM" ) },
                Where = {
							ImpElement.Factory.Equal( element.Factory ), 
							ImpElement.Project.Equal( element.Project ), 
							ImpElement.ElementMark.Equal( element.ElementMark ), 
						},
            };
            var statement = query.ToString();
            using( var database = new ImpactDatabase() )
            {
                result = database.GetAll( statement, ElementParse );
            }

            return (result != null && result.Count > 0)? result[0] : null;
        }
        private double GetGap( RecTMElement element1, RecTMElement element2 )
        {
            // Gap Between Elements
            double gap = 0;
            if( element1.BedRotation > 0 )
            {
                gap = element2.BedX - element1.BedX - element2.ElementLengthOnBed;
            }
            else
            {
                gap = element2.BedX - element1.BedX - element1.ElementLengthOnBed;
            }

            return gap;
        }
        /// <summary>
        /// Shrinks stack order no for elements in a given stack
        /// with higher stack order if there are no elements on the same level
        /// </summary>
        /// <param name="rec"></param>
        /// <returns></returns>
        private int ShrinkStackOrder( RecTMElement rec )
        {
            if( rec.Factory == null || rec.Project == null )
            {
                return -1;
            }
            if( rec.ElementId <= 0 || rec.TransportId <= 0 || rec.VehicleId <= 0 || rec.StackId <= 0 )
            {
                return -1;
            }
            // Find elements on the same level
            ImpactQuery selectQuery = new ImpactQuery()
            {
                From = { ImpModelPlanning.As( "T1" ) },
                Where =
				{
					ImpModelPlanning.Factory.Equal( rec.Factory ),
					ImpModelPlanning.Project.Equal( rec.Project ),
					ImpModelPlanning.TransportId.Equal( rec.TransportId ),
					ImpModelPlanning.VehicleId.Equal( rec.VehicleId ),
					ImpModelPlanning.StackId.Equal( rec.StackId ),
					ImpModelPlanning.StackSequenceNo.Equal( rec.StackSequenceNo ),
				}
            };

            // Conditional update
            int result = 0;
            using( ImpactDatabase database = new ImpactDatabase() )
            {

                string wc = "";
                wc = ConcatWC( wc, "TRANSPORT_ID", rec.TransportId );
                wc = ConcatWC( wc, "VEHICLE_ID", rec.VehicleId );
                wc = ConcatWC( wc, "STACK_ID", rec.StackId );
                string sql = "Update IMP_MODEL_PLANNING set "
                                        + "Stack_sequence_no=Stack_sequence_no - " + Conv.Sql( 1 )
                                        + " Where "
                                        + "Factory =" + Conv.Sql( rec.Factory ) + " AND "
                                        + "Project=" + Conv.Sql( rec.Project ) + " AND "
                                        + "Stack_sequence_no > " + Conv.Sql( rec.StackSequenceNo ) + " AND "
                                        + wc;

                string statement = string.Format( "IF NOT EXISTS ( {0} ) {1}", selectQuery.ToString(), sql );

                result = database.ExecuteNonQuery( statement );
            }
            return result;
        }
 /// <summary>
 /// Reset element transport data and corrects the stack order number on the stack
 /// </summary>
 /// <param name="rec">RecTransportPlanner</param>
 public void RemoveElement( RecTMElement rec )
 {
     if( rec.Factory == null || rec.Project == null )
     {
         return;
     }
     if( rec.ElementId <= 0 || rec.TransportId <= 0 || rec.VehicleId <= 0 || rec.StackId <= 0 )
     {
         return;
     }
     ResetTransport( rec.Factory, rec.Project, rec.ElementId, rec.TransportId, rec.VehicleId, rec.StackId );
     ShrinkStackOrder( rec );
 }
Beispiel #21
0
		public TMElement( RecTMElement element )
			: base( element )
		{
		}
        /// <summary>
        /// Parsing method
        /// </summary>
        /// <param name="transport"></param>
        /// <param name="vehicle"></param>
        /// <param name="rack"></param>
        /// <param name="elem"></param>
        public void Parse( RecTransport transport, RecTransportVehicleStd vehicle, RecTransportVehicleStackStd stack, RecTMElement elem )
        {
            string transpKey = transport.Factory + transport.Project + transport.TransportId;
            RecTMVehicle vehObj = null;
            RecTMStack stackObj = null;
            RecTMTransport transpObj = null;
            if( dic.ContainsKey( transpKey ) )
            {
                transpObj = dic[transpKey];
            }
            else
            {
                transpObj = new RecTMTransport();
                dic.Add( transpKey, transpObj );
                tmList.Add( transpObj );
            }
            transpObj.TransportObject = transport;

            bool isVehicleMode = vehicle.VehicleId != 0;
            if( isVehicleMode || transpObj.Vehicles.Count > 0 )
            {
                vehObj = transpObj.FindVehicle( vehicle );
                if( vehObj == null )
                {
                    vehObj = new RecTMVehicle();
                    transpObj.AddVehicle( vehObj );
                }
                vehObj.TransportVehicleStdObject = vehicle;
                if( stack.StackId != 0 )
                {
                    stackObj = vehObj.FindStack( stack );
                    if( stackObj == null )
                    {
                        stackObj = new RecTMStack();
                        vehObj.AddStack( stackObj );
                    }
                    stackObj.TransportVehicleStackStdObject = stack;
                    // To be revised!!!!!!!!!!! rackObj.TransportVehicleStackStdObject = stack;
                }
            }
            // Save the element if we do have an element
            if( elem.ElementId > 0 )
            {
                if( stackObj != null )
                {
                    stackObj.TMElements.Add( elem );
                }
                else if( vehObj != null )
                {
                    vehObj.TMElements.Add( elem );
                }
                else
                {
                    transpObj.TMElements.Add( elem );
                }
            }
        }
 /// <summary>
 /// IsTransported
 /// </summary>
 /// <param name="rec"></param>
 /// <param name="transported"></param>
 /// <returns></returns>
 private bool IsTransported( RecTMElement rec, List<RecTMElement> transported )
 {
     foreach( RecTMElement cur in transported )
     {
         if( cur.ElementId == rec.ElementId )
         {
             return true;
         }
     }
     return false;
 }
        /// <summary>
        /// Rotate
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        private bool Rotate( RecTMElement element )
        {
            if( element == null )
            {
                return false;
            }

            RecTMElement temp = RecTMElement.RotateElement( element );

            SaveElementProduction( temp, false );
            return true;
        }
        /// <summary>
        /// Swaps elements erection and load sequence
        /// </summary>
        /// <param name="rec1"></param>
        /// <param name="rec2"></param>
        /// <returns></returns>
        public bool SwapElementSequence( RecTMElement rec1, RecTMElement rec2 )
        {
            if( rec1 == null || rec2 == null )
            {
                return false;
            }
            // Create a temp copy
            RecTMElement recTemp = new RecTMElement( rec1 );

            ModelPlanner svc = new ModelPlanner();
            // Update the rec1
            rec1.StackSequenceNo = rec2.StackSequenceNo;
            svc.SaveElementTransport( rec1, false );
            // Update the rec2
            rec2.StackSequenceNo = recTemp.StackSequenceNo;
            svc.SaveElementTransport( rec2, false );

            return true;
        }
Beispiel #26
0
            public void Parse( RecProductionFormStd form, RecProductionCast cast, RecTMElement elem )
            {
                string castKey = cast.Factory + cast.Project + cast.CastId;
                RecProductionCast castObj = null;
                if( dic.ContainsKey( castKey ) )
                {
                    castObj = dic[castKey];
                }
                else
                {
                    castObj = new RecProductionCast( cast );
                    dic.Add( castKey, castObj );
                    tmList.Add( castObj );
                }

                // Save the element if we do have an element
                if( elem != null && elem.ElementId > 0 )
                {
                    if( castObj != null && castObj.CastId > 0 )
                    {
                        elem.CastId = castObj.CastId;
                        castObj.Project = elem.Project;
                        castObj.AddElement( elem );
                    }
                }
            }
 RecTransportVehicleStd GetStandardVehicle( RecTMElement rec )
 {
     ProjectManager svc = new ProjectManager();
     RecTransport recTrans = new RecTransport();
     recTrans.Factory = rec.Factory;
     recTrans.Project = rec.Project;
     recTrans.TransportId = rec.TransportId;
     List<RecTransportVehicleStd> vehList = svc.LoadTransportVehiclesEx( recTrans, rec.VehicleId );
     if( vehList != null && vehList.Count > 0 )
     {
         return vehList[0];
     }
     return null;
 }
        /// <summary>
        /// Saves element production data
        /// </summary>
        /// <param name="rec"></param>
        /// <param name="verifyExist"></param>
        /// <returns></returns>
        public int SaveElementProduction( RecTMElement rec, bool verifyExist )
        {
            if( rec == null || string.IsNullOrWhiteSpace( rec.Factory ) || string.IsNullOrWhiteSpace( rec.Project ) || rec.ElementId == 0 )
            {
                return -1;
            }
            // Create a new record if it doesnt exist
            if( verifyExist )
            {
                Verify( rec.Factory, rec.Project, rec.ElementId );
            }

            var update = new ImpactUpdate( ImpModelPlanning.Instance )
            {
                Columns = 
				{
					{ ImpModelPlanning.CastId, rec.CastId },
					{ ImpModelPlanning.BedSequenceNo, rec.BedSequenceNo },
					{ ImpModelPlanning.BedX, rec.BedX },
					{ ImpModelPlanning.BedY, rec.BedY },
					{ ImpModelPlanning.BedZ, rec.BedZ },
					{ ImpModelPlanning.BedRotation, rec.BedRotation },
				},
                Where = 
				{
					{ ImpModelPlanning.Factory.Equal( rec.Factory ) },
					{ ImpModelPlanning.Project.Equal( rec.Project ) },
					{ ImpModelPlanning.ElementId.Equal( rec.ElementId ) },
				},
            };

            string statement = update.ToString();

            int result;

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                result = database.ExecuteNonQuery( statement );
            }
            return result;
        }
Beispiel #29
0
            public void Parse( RecProductionFormStd form, RecProductionCast cast, RecTMElement elem )
            {
                string formKey = form.Factory + form.Project + form.Name;
                RecProductionFormStd formObj = null;
                if( dic.ContainsKey( formKey ) )
                {
                    formObj = dic[formKey];
                }
                else
                {
                    formObj = new RecProductionFormStd( form );
                    dic.Add( formKey, formObj );
                    tmList.Add( formObj );
                }

                RecProductionCast castObj = null;
                if( cast != null )
                {
                    castObj = formObj.FindCast( cast );
                    if( castObj == null )
                    {
                        castObj = new RecProductionCast( cast ) { Form = form.Name };
                        formObj.ProductionCast = castObj;
                    }
                }
                // Save the element if we do have an element
                if( null == elem || elem.ElementId <= 0 )
                {
                    return;
                }
                if( castObj == null || castObj.CastId <= 0 )
                {
                    return;
                }
                elem.CastId = castObj.CastId;
                castObj.Project = elem.Project;
                castObj.AddElement( elem );
            }
        /// <summary>
        /// Move element
        /// </summary>
        /// <param name="element"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <param name="rotation"></param>
        /// <returns></returns>
        private bool Move( RecTMElement element, double x, double y, double z, double rotation )
        {
            if( element == null )
            {
                return false;
            }

            RecTMElement temp = new RecTMElement( element );

            temp.BedX += x;
            temp.BedY += y;
            temp.BedZ += z;
            temp.BedRotation += rotation;

            SaveElementProduction( temp, false );

            return true;
        }