/// <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<RecProductionCastStrand> LoadProductionCastStrand( RecProductionCastStrand record )
		{
			ImpactQuery query = new ImpactQuery()
			{
				Select =
				{
					ImpProductionCastStrand.Factory,
					ImpProductionCastStrand.Project,
					ImpProductionCastStrand.CastId,
					ImpProductionCastStrand.StrandPos,
					ImpProductionCastStrand.StrandX,
					ImpProductionCastStrand.StrandY,
					ImpProductionCastStrand.StrandQuality,
					ImpProductionCastStrand.StrandDimension,
					ImpProductionCastStrand.StrandPrestressing,

				},
				From  = { ImpProductionCastStrand.As( "T1" ) },
				Where = { ImpProductionCastStrand.Factory.Equal( record.Factory ), 
                          ImpProductionCastStrand.Project.Equal( record.Factory ),// Factory, Factory for productionCast & ProductionCastStrand
                          ImpProductionCastStrand.CastId.Equal( record.CastId )}
			};

			string statement = query.ToString();

			List<RecProductionCastStrand> result;

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

			return result;
		}
		/// <summary>
		/// Load of Transport Vehicle Standard items 
		/// </summary>
		/// <param name="vehicle"></param>
		/// <returns></returns>
		public List<RecTransportVehicleStd> LoadTransportVehicleStd( RecTransportVehicleStd record )
		{
			if( record  == null )
			{
				throw new ArgumentNullException( "TransportVehicleStd" );
			}
			ImpactQuery query = new ImpactQuery()
			{
				Select =
				{
					ImpTransportVehicleStd.Factory,
					ImpTransportVehicleStd.Project, 
					ImpTransportVehicleStd.Name, 

					ImpTransportVehicleStd.Division, 
					ImpTransportVehicleStd.Description, 
					ImpTransportVehicleStd.VehicleType, 
					ImpTransportVehicleStd.TransportType, 

					ImpTransportVehicleStd.Length, 
					ImpTransportVehicleStd.Width, 
					ImpTransportVehicleStd.Height, 
					ImpTransportVehicleStd.Mass,

					ImpTransportVehicleStd.MaxLength, 
					ImpTransportVehicleStd.MaxWidth, 
					ImpTransportVehicleStd.MaxHeight, 
					ImpTransportVehicleStd.MaxMass, 

					ImpTransportVehicleStd.CreatedBy, 
					ImpTransportVehicleStd.CreatedDate, 
					ImpTransportVehicleStd.ChangedBy, 
					ImpTransportVehicleStd.ChangedDate, 
				},
				From = { ImpTransportVehicleStd.As( "T1" ) },
				Where = { ImpTransportVehicleStd.Factory.Equal( record.Factory ), 
						  ImpTransportVehicleStd.Project.Equal( record.Factory ),//for Std use Factory, Factory
						  },
				OrderBy = {ImpTransportVehicleStd.Name}
			};

			string statement = query.ToString();

			List<RecTransportVehicleStd> result;

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

			return result;
		}
Ejemplo n.º 3
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;
		}
        /// <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<RecProductionFormStrandStd> LoadProductionFormStrandStd( RecProductionFormStrandStd record )
		{
			ImpactQuery query = new ImpactQuery()
			{
				Select = 
				{
					ImpProductionFormStrandStd.Factory,
					ImpProductionFormStrandStd.Project,
					ImpProductionFormStrandStd.Name,
					ImpProductionFormStrandStd.StrandPos,
					ImpProductionFormStrandStd.StrandX,
					ImpProductionFormStrandStd.StrandY,
					ImpProductionFormStrandStd.StrandQuality,
					ImpProductionFormStrandStd.StrandDimension,
					ImpProductionFormStrandStd.StrandPrestressing,
                    ImpProductionFormStrand.Form,

				},
				From = { ImpProductionFormStrandStd.As( "T1" ) },
                Join =
				{
					Join.Left( ImpProductionFormStrand.As( "T2" ),	
						ImpProductionFormStrand.Factory.Equal( ImpProductionFormStrandStd.Factory ),
						ImpProductionFormStrand.Project.Equal( ImpProductionFormStrandStd.Project ),//Factory, Factory
						ImpProductionFormStrand.Form.Equal( ImpProductionFormStrandStd.Name ),
                        ImpProductionFormStrand.Strand.Equal( ImpProductionFormStrandStd.StrandPos )),
                },

				Where = { ImpProductionFormStrandStd.Factory.Equal( record.Factory ), 
						  ImpProductionFormStrandStd.Project.Equal( record.Factory ), 
						  ImpProductionFormStrandStd.Name.Equal( record.Name )} //Form name
			};

			string statement = query.ToString();

			List<RecProductionFormStrandStd> result;

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

			return result;
		}
Ejemplo n.º 5
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<RecCalendar> LoadCalendar(RecCalendar record)
        {
            ImpactQuery query = new ImpactQuery()
            {
                Select =
				{
					ImpCalendar.Factory,
					ImpCalendar.Project,
					ImpCalendar.Name,
					ImpCalendar.Description,
					ImpCalendar.CreatedBy,
					ImpCalendar.CreatedDate,
					ImpCalendar.ChangedBy,
					ImpCalendar.ChangedDate,

				},
                From = { ImpCalendar.As("T1") },
                Where = { ImpCalendar.Factory.Equal(record.Factory), ImpCalendar.Project.Equal(record.Factory) }
            };

            string statement = query.ToString();

            List<RecCalendar> result;

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

            if (null != result)
            {
                foreach (RecCalendar recCalendar in result)
                {
                    recCalendar.WorkDays = LoadWorkDays(recCalendar );
                    recCalendar.InvalidDays = LoadInvalidDays(recCalendar);

                }
            }
            return result;
        }
		/// <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<RecTransportVehicleStackStd> LoadTransportVehicleStackStd( RecTransportVehicleStackStd record )
		{
			ImpactQuery query = new ImpactQuery()
			{
				Select =
				{
					ImpTransportVehicleStackStd.Name,
					ImpTransportVehicleStackStd.StackId,
					ImpTransportVehicleStackStd.Rack,
					ImpTransportVehicleStackStd.StackPosition,
					ImpTransportVehicleStackStd.StackX,
					ImpTransportVehicleStackStd.StackY,
					ImpTransportVehicleStackStd.StackZ,
					ImpTransportVehicleStackStd.StackRotation,
					ImpTransportVehicleStackStd.Description,
					ImpTransportVehicleStackStd.StackType,
					ImpTransportVehicleStackStd.MaxLength,
					ImpTransportVehicleStackStd.MaxWidth,
					ImpTransportVehicleStackStd.MaxHeight,
					ImpTransportVehicleStackStd.MaxMass
				},
				From = { ImpTransportVehicleStackStd.As( "T1" ) },
				Where = { ImpTransportVehicleStackStd.Factory.Equal( record.Factory ), 
						  ImpTransportVehicleStackStd.Project.Equal( record.Factory ),//for Std use Factory, Factory
						  ImpTransportVehicleStackStd.Name.Equal( record.Name )}
			};

			string statement = query.ToString();

			List<RecTransportVehicleStackStd> result;

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

			return result;
		}
Ejemplo n.º 7
0
	    /// <summary> 
	    /// Load all records of the same factory and project as the supplied record.
	    /// </summary>
	    /// <param name="factory"> </param>
	    /// <param name="project"> </param>
	    /// <returns>A list of all mathcing records.</returns>
	    public List<RecSectionStyleStd> LoadSectionStyleStd(  string factory, string project  )
		{
			// Add, Factory, Factory and Company, Company
			var company = factory.Substring( 0, 2 ) + "00"; //Is this really OK ??!!

			var orElementType = WhereGroup.Or( ImpSectionStyleStd.ElementType.Equal( "HD/F" ),
										       ImpSectionStyleStd.ElementType.Equal( "D/F" ));

            
            var where1 = WhereGroup.And( ImpSectionStyleStd.Factory.Equal( factory ), ImpSectionStyleStd.Project.Equal( project ) );
            var where2 = WhereGroup.And( ImpSectionStyleStd.Factory.Equal( factory ), ImpSectionStyleStd.Project.Equal( factory ) );
            var where3 = WhereGroup.And( ImpSectionStyleStd.Factory.Equal( company ), ImpSectionStyleStd.Project.Equal( company ) );

            var orProjectFactoryCompany = WhereGroup.Or( where1, where2, where3 );

			var query = new ImpactQuery()
			{
				Select =
				{
					ImpSectionStyleStd.Factory,
					ImpSectionStyleStd.Project,
					ImpSectionStyleStd.ElementType,
					ImpSectionStyleStd.Name,
					ImpSectionStyleStd.SectionType,
					ImpSectionStyleStd.Description,
                    ImpSectionStrandptnStd.Name,
                    Aggregate.Count( ImpSectionStrandptnPosStd.StrandPos ),

                    //ImpSectionStyleStd.Width,
                    //ImpSectionStyleStd.WidthTolerance,
                    //ImpSectionStyleStd.DiffBottomTop,
                    //ImpSectionStyleStd.Height,
                    //ImpSectionStyleStd.Endcap,
                    //ImpSectionStyleStd.Strandptn,
                    //ImpSectionStyleStd.RcTemplate,
                    //ImpSectionStyleStd.Material,
                    //ImpSectionStyleStd.ProductionLine,
                    //ImpSectionStyleStd.CutType,
                    //ImpSectionStyleStd.UseCutZone,
                    //ImpSectionStyleStd.LiftMethod,
                    //ImpSectionStyleStd.LiftRotation1,
                    //ImpSectionStyleStd.LiftRotation2,
                    //ImpSectionStyleStd.LiftPlacingLs,
                    //ImpSectionStyleStd.LiftParameterLs,
                    //ImpSectionStyleStd.LiftPlacingSs,
                    //ImpSectionStyleStd.LiftParameterSs,
                    //ImpSectionStyleStd.LiftCores,
                    //ImpSectionStyleStd.LiftCoreLength,
                    //ImpSectionStyleStd.LiftCoreDisplayMode,
                    //ImpSectionStyleStd.LiftDistanceMax,
                    //ImpSectionStyleStd.LiftDistanceMin,
                    //ImpSectionStyleStd.LiftSpacing,
                    //ImpSectionStyleStd.LiftType,
                    //ImpSectionStyleStd.SectionViewDimStrandGrp,
                    //ImpSectionStyleStd.SectionViewTxtStrandGrp,
                    //ImpSectionStyleStd.SectionViewNbrCores,
                    //ImpSectionStyleStd.SectionViewScale,
                    //ImpSectionStyleStd.UseSectionViewSymbol,
                    //ImpSectionStyleStd.SectionViewFilename,
                    //ImpSectionStyleStd.ChamferDistance,
                    //ImpSectionStyleStd.ChamferText,
                    //ImpSectionStyleStd.ChamferVisibility,
                    //ImpSectionStyleStd.RcCoverCut1,
                    //ImpSectionStyleStd.RcCoverCut2,
                    //ImpSectionStyleStd.ElementGrp,
                    //ImpSectionStyleStd.ProductPrefix,
                    //ImpSectionStyleStd.Product,
                    //ImpSectionStyleStd.ElementMarkPrefix,
                    //ImpSectionStyleStd.DrawingNamePrefix,
                    //ImpSectionStyleStd.DrawingType,
                    //ImpSectionStyleStd.DrawingTemplate,
                    //ImpSectionStyleStd.CreatedBy,
                    //ImpSectionStyleStd.CreatedDate,
                    //ImpSectionStyleStd.ChangedBy,
                    //ImpSectionStyleStd.ChangedDate,
                    //ImpSectionStyleStd.LiftHolePosition,

				},
				From = { ImpSectionStyleStd.As( "T1" ) },
                Join =
				{
					Join.Left( ImpSectionStrandptnStd.As( "T2" ),	
						ImpSectionStrandptnStd.Factory.Equal( ImpSectionStyleStd.Factory ),
						ImpSectionStrandptnStd.Project.Equal( ImpSectionStyleStd.Project ),
						ImpSectionStrandptnStd.ElementType.Equal( ImpSectionStyleStd.ElementType ), 
						ImpSectionStrandptnStd.Section.Equal( ImpSectionStyleStd.Name )),

					Join.Left( ImpSectionStrandptnPosStd.As( "T3" ),	
						ImpSectionStrandptnPosStd.Factory.Equal( ImpSectionStrandptnStd.Factory ),
						ImpSectionStrandptnPosStd.Project.Equal( ImpSectionStrandptnStd.Project ),
						ImpSectionStrandptnPosStd.ElementType.Equal( ImpSectionStrandptnStd.ElementType ), 
						ImpSectionStrandptnPosStd.Section.Equal( ImpSectionStrandptnStd.Section ),
                        ImpSectionStrandptnPosStd.Strandptn.Equal( ImpSectionStrandptnStd.Name )),
				},

				Where = { orElementType, orProjectFactoryCompany },

                GroupBy = 
                {
                    ImpSectionStyleStd.Factory,
                    ImpSectionStyleStd.Project,
                    ImpSectionStyleStd.ElementType,
                    ImpSectionStyleStd.Name,
                    ImpSectionStyleStd.SectionType,
                    ImpSectionStyleStd.Description,
                    ImpSectionStrandptnStd.Name,
                }
			};

			var statement = query.ToString();
           
			List<RecSectionStyleStd> result;

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

			if( result == null || result.Count == 0 )
			{
				return result;
			}

            var companyDic = ( from o in result
				            where ( o.Factory == company && o.Project == company )
				            select new RecSectionStyleStd { Factory = o.Factory, Project = o.Factory, ElementType = o.ElementType, 
                                Name = o.Name, Strandptn = o.Strandptn, NumOfStrands = o.NumOfStrands } ).ToDictionary( x => x.Name + x.Strandptn );

            var factoryDic = ( from o in result
				            where ( o.Factory == factory && o.Project == factory )
				            select new RecSectionStyleStd { Factory = o.Factory, Project = o.Factory, ElementType = o.ElementType, 
                                Name = o.Name, Strandptn = o.Strandptn, NumOfStrands = o.NumOfStrands } ).ToDictionary( x => x.Name + x.Strandptn );

            var projectDic = ( from o in result
				            where ( o.Factory == factory && o.Project == project )
				            select new RecSectionStyleStd { Factory = o.Factory, Project = o.Project, ElementType = o.ElementType, 
                                Name = o.Name, Strandptn = o.Strandptn, NumOfStrands = o.NumOfStrands } ).ToDictionary( x => x.Name + x.Strandptn );

			foreach( var pair in factoryDic )
			{
				if( !projectDic.ContainsKey( pair.Key ) )
				{
					projectDic.Add( pair.Key, pair.Value );
				}
			}
			foreach( var pair in companyDic )
			{
				if( !projectDic.ContainsKey( pair.Key ) )
				{
					projectDic.Add( pair.Key, pair.Value );
				}
			}

			return GetStylesFromDictionary(  projectDic);
		}
Ejemplo n.º 8
0
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="reportFilter"></param>
        /// <returns></returns>
        public DrawingReportData Load( ReportFilter reportFilter )
        {
            var data = new DrawingReportData();

            var query = new ImpactQuery()
            {
                Select =
                    {
                        ImpDrawing.Factory,
                        ImpDrawing.Project,
                        ImpDrawing.DrawingName,
                        ImpDrawing.DrawingType,
                        ImpDrawing.DesignedBy,
                        ImpDrawing.Status,
                        ImpDrawing.ApprovedDate,
                        ImpDrawing.CreatedDate,
                        ImpDrawing.Text6,
                    },
                From = { ImpDrawing.As( "T1" ) },
                Join =
                    {
                        Join.Left(
                            ImpElement.As( "T2" ),
                            ImpDrawing.Factory.Equal( ImpElement.Factory ),
                            ImpDrawing.Project.Equal( ImpElement.Project ),
                            ImpDrawing.DrawingName.Equal( ImpElement.DrawingName ) ),
                    },
                Where =
                    {
                        ImpDrawing.Factory.Equal( reportFilter.Factory ),
                        ImpDrawing.Project.Equal( reportFilter.Project ),
                    },
            };

            if( reportFilter.Ranges.Count > 0 )
            {
                var list = new List<Where>();
                foreach( var range in reportFilter.Ranges )
                {
                    if( !string.IsNullOrEmpty( range.From ) && !string.IsNullOrEmpty( range.To ) )
                    {
                        list.Add( ImpDrawing.DrawingName.Between( range.From, range.To ) );
                    }
                }

                if( list.Count > 0 )
                {
                    query.Where.Add( WhereGroup.Or( list.ToArray() ) );
                }
            }

            var statement = query.ToString();

            using( var database = new ImpactDatabase() )
            {
				data.Rows = database.GetAll( statement, column => new DrawingReportRow()
				                {
				                    Factory = column[0].Cast<string>(),
				                    Project = column[1].Cast<string>(),
				                    DrawingName = column[2].Cast<string>(),
				                    DrawingType = column[3].Cast<string>(),
                                    DesignedBy = column[4].Cast<string>(),
                                    Status = column[5].Cast<string>(),
                                    ApprovedDate = column[6].Cast<DateTime?>(),
                                    CreatedDate = column[7].Cast<DateTime?>(),
                                    DrawingText6 = column[8].Cast<string>(),
				                } );
            }

            return data;

        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
        /// <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;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Load of Transport items
        /// </summary>
        /// <returns></returns>
        public List<RecTMTransport> LoadTransports( PlanningFilter filter, ReportFilter reportFilter )
        {
            if( filter == null )
            {
                throw new ArgumentNullException( "Transport" );
            }

            var where = WhereGroup.And( ImpTransport.Factory.Equal( filter.Factory ) );

            if( !string.IsNullOrWhiteSpace( filter.Project ) )
            {
                where.Add( ImpTransport.Project.Equal( filter.Project ) );
            }

            WhereGroup whereStatus = WhereGroup.Or( new Where[] { } );

            if( filter.NoStatus )
            {
                whereStatus.Add( ImpTransport.TransportStatus.Equal( TransportStatus.NoStatus ) );
            }
            if( filter.Planned )
            {
                whereStatus.Add( ImpTransport.TransportStatus.Equal( TransportStatus.Planned ) );
            }
            if( filter.CallOff )
            {
                whereStatus.Add( ImpTransport.TransportStatus.Equal( TransportStatus.CallOff ) );
            }
            if( filter.Delivered )
            {
                whereStatus.Add( ImpTransport.TransportStatus.Equal( TransportStatus.Delivered ) );
            }

            if( whereStatus.Count > 0 )
            {
                where.Add( whereStatus );
            }

            where.Add( ImpTransport.IsTemplate.Equal( false ) );
            WhereGroup wgDeleted = WhereGroup.Or( ImpModelGeometry.Deleted.NotEqual( 1 ),
                                                  ImpModelGeometry.Deleted.IsNull() );

            where.Add( wgDeleted );

            if( filter.UseLoadDateFrom )
            {
                where.Add( ImpTransport.LoadDate.GreaterThanOrEqual( filter.LoadDateFrom ) );
            }
            if( filter.UseLoadDateTo )
            {
                where.Add( ImpTransport.LoadDate.LessThanOrEqual( filter.LoadDateTo ) );
            }
            if( filter.UseDeliveryDateFrom )
            {
                where.Add( ImpTransport.DeliveryDate.GreaterThanOrEqual( filter.DeliveryDateFrom ) );
            }
            if( filter.UseDeliveryDateTo )
            {
                where.Add( ImpTransport.DeliveryDate.LessThanOrEqual( filter.DeliveryDateTo ) );
            }

            if( reportFilter != null && reportFilter.Ranges.Count > 0 )
            {
                var list = new List<Where>();
                foreach( var range in reportFilter.Ranges )
                {
                    if( !string.IsNullOrEmpty( range.From ) && !string.IsNullOrEmpty( range.To ) )
                    {
                        list.Add( ImpTransport.TransportId.Between( range.From, range.To ) );
                    }
                }

                if( list.Count > 0 )
                {
                    where.Add( WhereGroup.Or( list.ToArray() ) );
                }
            }

            where.Add( ImpTransport.TransportId.GreaterThan( 0 ) );

            ImpactQuery query = new ImpactQuery()
            {
                Select =
				{
					ImpTransport.Project,
					ImpTransport.TransportId,
					ImpTransport.Description,
					ImpTransport.LoadDate,
					ImpTransport.DeliveryDate,
					ImpTransport.TransportStatus,

					ImpTransportVehicle.VehicleId,
					ImpTransportVehicleStd.Name,
					ImpTransportVehicleStd.MaxMass,
					ImpTransportVehicle.TransportType,
					ImpTransportVehicleStd.VehicleType,

					ImpTransportStack.StackId,
					//ImpTransportStack.Rack,
					ImpTransportStack.MaxMass,
					ImpTransportStack.Description,
					ImpTransportStack.StackType,


					ImpModelPlanning.ElementId,
					ImpModelPlanning.ErectionSequenceNo,
					ImpModelPlanning.StackSequenceNo,
					ImpModelPlanning.StackId,
                    ImpModelPlanning.ElementIdStatus,
                    ImpModelPlanning.PlannedDeliveryDate,
                    ImpModelPlanning.DeliveryDate,

                    ImpModelGeometry.ElementMark,
					ImpModelGeometry.Building,
                    ImpModelGeometry.FloorId,
                    ImpModelGeometry.Phase,

					ImpElement.ElementType,
					ImpElement.Product,
                    ImpElement.Style,
					ImpElement.Mass,
					ImpElement.ElementLength,
					ImpElement.ElementWidth,
					ImpElement.ElementHeight,
					ImpElement.GrossArea,
                    ImpElement.NetArea,
				},
                //ELEMENT_TYPE, STYLE  BOUNDING_BOX_AREA 
                From = { ImpTransport.As( "TRA" ) },

                Join =
				{
					Join.Left( ImpTransportVehicle.As( "TRV" ),	
						ImpTransport.Factory.Equal( ImpTransportVehicle.Factory ),
						ImpTransport.Project.Equal( ImpTransportVehicle.Project ),
						ImpTransport.TransportId.Equal( ImpTransportVehicle.TransportId ) ),

					Join.Left( ImpTransportVehicleStd.As( "VST" ),	
						ImpTransport.Factory.Equal( ImpTransportVehicleStd.Factory ),
						ImpTransport.Factory.Equal( ImpTransportVehicleStd.Project ),  // Factory, factory only so far (Needs to be complated with company, company)
						ImpTransportVehicle.Vehicle.Equal( ImpTransportVehicleStd.Name ) ),

					Join.Left( ImpTransportStack.As( "RCK" ),	
						ImpTransport.Factory.Equal( ImpTransportStack.Factory ),
						ImpTransport.Project.Equal( ImpTransportStack.Project ),
						ImpTransport.TransportId.Equal( ImpTransportStack.TransportId ),
						ImpTransportVehicle.VehicleId.Equal( ImpTransportStack.VehicleId )),

					Join.Left( ImpModelPlanning.As( "MPL" ),	
						ImpTransport.Factory.Equal( ImpModelPlanning.Factory ),
						ImpTransport.Project.Equal( ImpModelPlanning.Project ),
						ImpTransport.TransportId.Equal( ImpModelPlanning.TransportId ),
						ImpTransportVehicle.VehicleId.Equal( ImpModelPlanning.VehicleId ) ,
						ImpTransportStack.StackId.Equal( ImpModelPlanning.StackId ) ),

					Join.Left( ImpModelGeometry.As( "MGO" ),	
						ImpModelPlanning.Factory.Equal( ImpModelGeometry.Factory ),
						ImpModelPlanning.Project.Equal( ImpModelGeometry.Project ),
						ImpModelPlanning.ElementId.Equal( ImpModelGeometry.ElementId ) ),

					Join.Left( ImpElement.As( "ELM" ),	
						ImpModelGeometry.Factory.Equal( ImpElement.Factory ),
						ImpModelGeometry.Project.Equal( ImpElement.Project ),
						ImpModelGeometry.ElementMark.Equal( ImpElement.ElementMark ) ),
				},

                Where = { where },

                OrderBy = 
				{ 
					{ ImpTransport.TransportId, OrderBy.Descending },
					{ ImpTransportVehicle.VehicleId }, 
					{ ImpTransportStack.StackId },
					{ ImpModelPlanning.StackSequenceNo, OrderBy.Descending }
				},
            };

            string statement = query.ToString();

            List<RecTMTransport> tmList = new List<RecTMTransport>();
            TranportParser parser = new TranportParser( tmList );

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                var list = database.GetAll( statement, column =>
                    {
                        string project = DataConverter.Cast<string>( column[0] );
                        int transportId = DataConverter.Cast<int>( column[1] );

                        return new
                        {
                            // TODO: THEIB, you must handle null dates in your record class.
                            transport = new RecTransport()
                            {
                                Factory = filter.Factory,
                                Project = project,
                                TransportId = transportId,
                                Description = DataConverter.Cast<string>( column[2] ),
                                LoadDate = DataConverter.Cast<DateTime>( column[3] ),
                                DeliveryDate = DataConverter.Cast<DateTime?>( column[4] ),
                                TransportStatus = DataConverter.Cast<int>( column[5] ),
                            },
                            veh = new RecTransportVehicleStd()
                            {
                                Factory = filter.Factory,
                                Project = project,
                                VehicleId = DataConverter.Cast<int?>( column[6] ) ?? 0,
                                Name = DataConverter.Cast<string>( column[7] ),
                                MaxMass = DataConverter.Cast<double?>( column[8] ) ?? 0d,
                                TransportId = transportId,
                                TransportType = DataConverter.Cast<int?>( column[9] ) ?? 0,
                                VehicleType = DataConverter.Cast<int?>( column[10] ) ?? 0
                            },
                            stack = new RecTransportVehicleStackStd()
                            {
                                StackId = DataConverter.Cast<int?>( column[11] ) ?? 0,
                                MaxMass = DataConverter.Cast<double?>( column[12] ) ?? 0,
                                Description = DataConverter.Cast<string>( column[13] ),
                                StackType = DataConverter.Cast<int?>( column[14] ) ?? 0
                            },
                            elem = new RecTMElement()
                            {
                                Factory = filter.Factory,
                                Project = project,

                                ElementId = DataConverter.Cast<int?>( column[15] ) ?? 0,
                                ErectionSequenceNo = DataConverter.Cast<int?>( column[16] ) ?? 0,
                                StackSequenceNo = DataConverter.Cast<int?>( column[17] ) ?? 0,
                                StackId = DataConverter.Cast<int?>( column[18] ) ?? 0,

                                ElementIdStatus = DataConverter.Cast<int?>( column[19] ) ?? 0,
                                PlannedDeliveryDate = DataConverter.Cast<DateTime?>( column[20] ),
                                DeliveryDate = DataConverter.Cast<DateTime?>( column[21] ),

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

                                ElementType = DataConverter.Cast<string>( column[26] ),
                                Product = DataConverter.Cast<string>( column[27] ),
                                Style = DataConverter.Cast<string>( column[28] ),
                                Mass = DataConverter.Cast<double?>( column[29] ) ?? 0d,
                                ElementLength = DataConverter.Cast<double?>( column[30] ) ?? 0d,
                                ElementWidth = DataConverter.Cast<double?>( column[31] ) ?? 0d,
                                ElementHeight = DataConverter.Cast<double?>( column[32] ) ?? 0d,
                                GrossArea = DataConverter.Cast<double?>( column[33] ) ?? 0d,
                                NetArea = DataConverter.Cast<double?>( column[34] ) ?? 0d,
                            }
                        };
                    } );

                foreach( var item in list )
                {
                    parser.Parse( item.transport, item.veh, item.stack, item.elem );
                }
            }

            return tmList;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Returns a new erections sequence number for the specified project, of the specified factory.
        /// </summary>
        /// <param name="factory">
        /// The factory to which the project belongs.
        /// </param>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <returns>
        /// The next available erection sequence number.
        /// </returns>
        public int GetNewErectionSequenceNumber( string factory, string project )
        {
            project = project.PadLeft( 12 );

            ImpactQuery query = new ImpactQuery
                                {
                Select = {
                            Aggregate.Max( ImpModelPlanning.ErectionSequenceNo ) 
                         }, 
                From = {
                          ImpModelPlanning.As( "T1" ) 
                       }, 
                Where =
                {
                    ImpModelPlanning.Factory.Equal( factory ), 
                    ImpModelPlanning.Project.Equal( project ), 
                }, 
            };

            string statement = query.ToString();

            using( var database = new ImpactDatabase() )
            {
                var erectionSequenceList = database.GetAll( statement, column => column[0].Cast<int>() );

                int maxEs = 0;

                if( erectionSequenceList.Count != 0 )
                {
                    maxEs = erectionSequenceList[0];
                }

                maxEs++;

                return maxEs;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// The get company settings.
        /// </summary>
        /// <param name="company">
        /// The company.
        /// </param>
        /// <param name="database">
        /// The database.
        /// </param>
        /// <returns>
        /// The StruSoft.Impact.V120.ProjectManager.Core.ProjectBrowser.CompanySettings.
        /// </returns>
        private static CompanySettings GetCompanySettings( string company, ImpactDatabase database )
        {
            string companySettingsQuery = GetCompanySettingsQuery( company ).ToString();

            string settingValue = database.GetFirst( companySettingsQuery, column => column[0].Cast<string>() );

            UnitSystemType unitSystem;

            CompanySettings companySettings = new CompanySettings();

            if( !Enum.TryParse( settingValue, true, out unitSystem ) )
            {
                // Default to metric if we failed conversion.
                unitSystem = UnitSystemType.Metric;

                // Since we could not find a unit system in the database for the specified company,
                // we must assume there are no company units either. So we create default company settings.
                companySettings.UnitSystem = unitSystem;

                foreach( var item in CreateDefaultUnitData( unitSystem ) )
                {
                    companySettings[item.Parameter] = item;
                }
            }
            else
            {
                companySettings.UnitSystem = unitSystem;

                // Get the company units from the database.
                string companyUnitsQuery = GetCompanyUnitsQuery( company ).ToString();

                var companyUnitList = database.GetAll( 
                    companyUnitsQuery, 
                    column =>
                        {
                            UnitParameter parameter;

                            if( !Enum.TryParse( column[0].Cast<string>(), true, out parameter ) )
                            {
                                return null;
                            }

                            UnitType unitType = column[1].Cast<UnitType>();

                            return new CompanyUnit( parameter, unitType, column[2].Cast<int>(), column[3].Cast<int>() );
                        });

                // Join the default unit data with the unit data from the database. If any unit is
                // missing from the database, then we'll use the default unit instead.
                var leftJoin = ( from defaultUnit in CreateDefaultUnitData( unitSystem )
                                 join databaseUnit in companyUnitList
                                     on defaultUnit.Parameter equals databaseUnit.Parameter into joinedList
                                 from companyUnit in joinedList.DefaultIfEmpty( defaultUnit )
                                 select companyUnit ).ToList();

                foreach( var item in leftJoin )
                {
                    companySettings[item.Parameter] = item;
                }
            }

            ImpactQuery dateFormatQuery = new ImpactQuery( true )
                {
                    From = {
                               ImpCompany.As( "T1" ) 
                           }, 
                    Select = {
                                 ImpCompany.DateFormat 
                             }, 
                    Where =
                        {
                            ImpCompany.Company.Equal( company ), 
                        }
                };

            var dateFormatList = database.GetAll( dateFormatQuery.ToString(), column => column[0].Cast<CompanyDateFormat>() );

            if( dateFormatList.Count > 0 )
            {
                companySettings.DateFormat = dateFormatList[0];
            }
            else
            {
                companySettings.DateFormat = CompanyDateFormat.Sweden;
            }

            return companySettings;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// The load user data.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <returns>
        /// The StruSoft.Impact.V120.ProjectManager.Core.ProjectBrowserData.UserData.
        /// </returns>
        public UserData LoadUserData( string user )
        {
            user = user.ToLower();

            ImpactQuery query = new ImpactQuery( true )
            {
                From = {
                          ImpUser.As( "U" ) 
                       }, 
                Select = {
                            ImpUserGroup.Company, ImpUserGroupStd.RoleId 
                         }, 
                Join =
                {
                    Join.Inner( ImpUserGroup.As( "UG" ), ImpUser.Userid.Equal( ImpUserGroup.Userid ) ), 
                    Join.Inner( ImpUserGroupStd.As( "UGS" ), ImpUserGroup.UserGroup.Equal( ImpUserGroupStd.Name ) ), 
                }, 
                Where = {
                           ImpUser.Userid.Equal( user ) 
                        }, 
            };

            string statement = query.ToString();

            UserData userData = new UserData
                                {
                UserId = user
            };

            using( var database = new ImpactDatabase() )
            {
                var groupedCompanyRoleList = database.GetAll( 
                    statement, 
                    column => new
                    {
                        Company = column[0].Cast<string>(), 
                        Role = column[1].Cast<UserRole>(), 
                    }

                ).GroupBy( x => x.Company ).ToList();

                foreach( var companyGroup in groupedCompanyRoleList )
                {
                    UserRoleData urd = new UserRoleData( companyGroup.Key, from item in companyGroup select item.Role );

                    userData.UserRoles.Add( urd );
                }
            }

            return userData;
        }
Ejemplo n.º 15
0
		/// <summary>
		/// Load data, returns transport templates only
		/// </summary>
		/// <param name="transport"></param>
		/// <returns></returns>
		public List<RecTransport> LoadTransport( RecTransport record )
		{
			if( record == null )
			{
				throw new ArgumentNullException( "Transport" );
			}
			string project = "";
			if( record.IsTemplate == 1 )
			{
				// Templates are saved on factory level (factory, factory), 2012-04-23
				project = record.Factory;
			}
			else
			{
				project = record.Project;
			}
			ImpactQuery query = new ImpactQuery()
			{
				Select =
				{
					ImpTransport.TransportId,
					ImpTransport.Description,
					ImpTransport.LoadLocation,
					ImpTransport.LoadDate,
					ImpTransport.DeliveryDate,
					ImpTransport.TimeInterval,
					ImpTransport.LoadDivision,
					ImpTransport.DeliveryDivision,
					ImpTransport.IsTemplate,
					ImpTransport.TemplateId,
					ImpTransport.IsVisible,
					ImpTransport.TransportStatus
				},
				From = { ImpTransport.As( "T1" ) },
				Where = { ImpTransport.Factory.Equal( record.Factory ), 
						  ImpTransport.Project.Equal( project ), // Templates are saved on factory level (factory, factory), 2012-04-23
						  ImpTransport.IsTemplate.Equal( record.IsTemplate )},
				//OrderBy = { 
				//            {ImpTransport.TransportId, OrderBy.Descending} // gives Asc !! to be corrected
				//          }
			};

			string statement = query.ToString();
			statement += " ORDER BY T1.TRANSPORT_ID DESC";

			List<RecTransport> result;

			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.GetAll( statement, column =>
				{
					return new RecTransport()
					{
						Factory = record.Factory,
						Project = record.Project,

						TransportId = DataConverter.Cast<int>( column[0] ),
						Description = DataConverter.Cast<string>( column[1] ),
						LoadLocation = DataConverter.Cast<string>( column[2] ),
						LoadDate = DataConverter.Cast<DateTime>( column[3] ),
						DeliveryDate = DataConverter.Cast<DateTime>( column[4] ),
						TimeInterval = DataConverter.Cast<int>( column[5] ),
						LoadDivision = DataConverter.Cast<string>( column[6] ),
						DeliveryDivision = DataConverter.Cast<string>( column[7] ),
						IsTemplate = DataConverter.Cast<int>( column[8] ),
						TemplateId = DataConverter.Cast<int>( column[9] ),
						IsVisible = DataConverter.Cast<int>( column[10] ),
						TransportStatus = DataConverter.Cast<int>( column[11] ),
					};
				} );
			}

			return result;
		}
Ejemplo n.º 16
0
        /// <summary>
        /// Returns a set of casts with element information 
        /// </summary>
        /// <param name="filter">curFilter</param>
        /// <param name="reportFilter"> </param>
        /// <returns></returns>
        public CastScheduleData LoadCastSchedule( BedFilter filter, ReportFilter reportFilter )
        {
            if( filter == null || string.IsNullOrEmpty( filter.Factory ) || string.IsNullOrEmpty( filter.Project ) )
            {
                return null;
            }

            var query = new ImpactQuery()
            {
                Select =
				{
					ImpProductionCast.CastId,
					ImpProductionCast.Description,
					ImpProductionCast.StartDate,
					ImpProductionCast.EndDate,
					ImpProductionCast.Tolerance,
					ImpProductionCast.ElementType,
					ImpProductionCast.Style,
					ImpProductionCast.Strandptn,
					ImpProductionCast.CastStatus,
                    ImpProductionCast.CastType,
					ImpProductionCast.Form,
					ImpProductionCast.Shift,

                    Aggregate.Count( ImpProductionCastStrand.StrandPos ),

					ImpProductionFormStd.Location,
                    ImpProductionFormStd.FormType,
					ImpProductionFormStd.MaxLength,
					ImpProductionFormStd.MaxWidth,
					ImpProductionFormStd.MaxHeight,
                    ImpProductionFormStd.ElementType,

					ImpModelPlanning.ElementId,
					ImpModelGeometry.ElementMark,

                    ImpModelGeometry.Building,
                    ImpModelGeometry.FloorId,
                    ImpModelGeometry.Phase,

					ImpModelPlanning.ErectionSequenceNo,
					ImpModelPlanning.TransportId,

					ImpModelPlanning.BedSequenceNo,
					ImpModelPlanning.BedX,
					ImpModelPlanning.BedY,
					ImpModelPlanning.BedZ,
					ImpModelPlanning.BedRotation,
                    ImpModelPlanning.ElementIdStatus,

                    ImpModelPlanning.ProductionDate,
                    ImpModelPlanning.PlannedProductionDate,

                    ImpElement.ElementLength,
					ImpElement.ElementWidth,
					ImpElement.ElementHeight,
					ImpElement.ElementType,
					ImpElement.GrossArea,
					ImpElement.NetArea,
					ImpElement.Volume,
					ImpElement.Product,
					ImpElement.Project,
					ImpElement.AngleLeftSide,
					ImpElement.AngleRightSide,
                    ImpElement.Mass,

					ImpElement.Style,
					ImpElement.Strandptn,
					ImpElement.NbrOfStrands,
				},

                From = { ImpProductionCast.As( "CST" ) },

                Join =
				{
					Join.Left( ImpProductionCastStrand.As( "STA" ),	
						ImpProductionCast.Factory.Equal( ImpProductionCastStrand.Factory ),
						ImpProductionCast.Project.Equal( ImpProductionCastStrand.Project ),//Factory, Factory
						ImpProductionCast.CastId.Equal( ImpProductionCastStrand.CastId ) ),

					Join.Left( ImpProductionFormStd.As( "FRM" ),	
						ImpProductionCast.Factory.Equal( ImpProductionFormStd.Factory ),
						ImpProductionCast.Project.Equal( ImpProductionFormStd.Project ),// Factory, Factory for productionCast & ProductionCastStrand
						ImpProductionCast.Form.Equal( ImpProductionFormStd.Name ) ),

					Join.Left( ImpModelPlanning.As( "MPL" ),	
						ImpProductionCast.Factory.Equal( ImpModelPlanning.Factory ),
						ImpProductionCast.Project.Equal( ImpModelPlanning.Factory ),// Factory, Factory for productionCast & ProductionCastStrand
						ImpProductionCast.CastId.Equal( ImpModelPlanning.CastId ) ),


					Join.Left( ImpModelGeometry.As( "MGO" ),	
						ImpModelPlanning.Factory.Equal( ImpModelGeometry.Factory ),
						ImpModelPlanning.Project.Equal( ImpModelGeometry.Project ),
						ImpModelPlanning.ElementId.Equal( ImpModelGeometry.ElementId ) ),

					Join.Left( ImpElement.As( "ELM" ),	
						ImpModelGeometry.Factory.Equal( ImpElement.Factory ),
						ImpModelGeometry.Project.Equal( ImpElement.Project ),
						ImpModelGeometry.ElementMark.Equal( ImpElement.ElementMark ) ),
				},

                Where = {
							ImpProductionCast.Factory.Equal( filter.Factory ), 
							ImpProductionCast.Project.Equal( filter.Factory ), // Factory, Factory for productionCast & ProductionCastStrand
                            //ImpModelPlanning.CastId.GreaterThan( 0 ), 
						},
                GroupBy = 
                {
					ImpProductionCast.CastId,
					ImpProductionCast.Description,
					ImpProductionCast.StartDate,
					ImpProductionCast.EndDate,
					ImpProductionCast.Tolerance,
					ImpProductionCast.ElementType,
					ImpProductionCast.Style,
					ImpProductionCast.Strandptn,
					ImpProductionCast.CastStatus,
                    ImpProductionCast.CastType,
					ImpProductionCast.Form,
					ImpProductionCast.Shift,

					ImpProductionFormStd.Location,
                    ImpProductionFormStd.FormType,
					ImpProductionFormStd.MaxLength,
					ImpProductionFormStd.MaxWidth,
					ImpProductionFormStd.MaxHeight,
                    ImpProductionFormStd.ElementType,

					ImpModelPlanning.ElementId,
					ImpModelGeometry.ElementMark,

                    ImpModelGeometry.Building,
                    ImpModelGeometry.FloorId,
                    ImpModelGeometry.Phase,

					ImpModelPlanning.ErectionSequenceNo,
					ImpModelPlanning.TransportId,

					ImpModelPlanning.BedSequenceNo,
					ImpModelPlanning.BedX,
					ImpModelPlanning.BedY,
					ImpModelPlanning.BedZ,
					ImpModelPlanning.BedRotation,
                    ImpModelPlanning.ElementIdStatus,

                    ImpModelPlanning.ProductionDate,
                    ImpModelPlanning.PlannedProductionDate,

					ImpElement.ElementLength,
					ImpElement.ElementWidth,
					ImpElement.ElementHeight,
					ImpElement.ElementType,
					ImpElement.GrossArea,
					ImpElement.NetArea,
					ImpElement.Volume,
					ImpElement.Product,
					ImpElement.Project,
					ImpElement.AngleLeftSide,
					ImpElement.AngleRightSide,
                    ImpElement.Mass,

					ImpElement.Style,
					ImpElement.Strandptn,
					ImpElement.NbrOfStrands,
                },

                OrderBy = 
				{ 
					{ ImpElement.Project },
					{ ImpProductionCast.StartDate, OrderBy.Descending },
					{ ImpProductionCast.CastId },
				},
            };

            var whereStatus = WhereGroup.Or( new Where[] { } );

            if( filter.NoStatus )
            {
                whereStatus.Add( ImpProductionCast.CastStatus.Equal( CastStatus.NoStatus ) );
            }
            if( filter.Planned )
            {
                whereStatus.Add( ImpProductionCast.CastStatus.Equal( CastStatus.Planned ) );
            }
            if( filter.Produced )
            {
                whereStatus.Add( ImpProductionCast.CastStatus.Equal( CastStatus.Produced ) );
            }

            if( whereStatus.Count > 0 )
            {
               query.Where.Add( whereStatus );
            }

            if( filter.UseStartDateFrom )
            {
                query.Where.Add( ImpProductionCast.StartDate.GreaterThanOrEqual( filter.StartDateFrom ) );
            }
            if( filter.UseStartDateTo )
            {
                query.Where.Add( ImpProductionCast.StartDate.LessThanOrEqual( filter.StartDateTo ) );
            }
            if( filter.UseEndDateFrom )
            {
                query.Where.Add( ImpProductionCast.EndDate.GreaterThanOrEqual( filter.EndDateFrom ) );
            }
            if( filter.UseEndDateTo )
            {
                query.Where.Add( ImpProductionCast.EndDate.LessThanOrEqual( filter.EndDateTo ) );
            }

            if( filter.Shift != 0 )
            {
                query.Where.Add( ImpProductionCast.Shift.Equal( filter.Shift ) );
            }
            if( !string.IsNullOrEmpty(filter.Location) && !filter.Location.Equals( Filter.All ) )
            {
                query.Where.Add( ImpProductionFormStd.Location.Equal( filter.Location ) );
            }
            if( !filter.Bed.Equals( Filter.All ) )
            {
                query.Where.Add( ImpProductionCast.Form.Equal( filter.Bed ) );
            }
            if( !string.IsNullOrEmpty( filter.CastId ) )
            {
                query.Where.Add( ImpProductionCast.CastId.Like( filter.CastId ) );
            }

            if( reportFilter != null && reportFilter.Ranges.Count > 0 )
            {
                var list = new List<Where>();
                foreach( var range in reportFilter.Ranges )
                {
                    if( !string.IsNullOrEmpty( range.From ) && !string.IsNullOrEmpty( range.To ) )
                    {
                        list.Add( ImpProductionCast.CastId.Between( range.From, range.To ) );
                    }
                }

                if( list.Count > 0 )
                {
                    query.Where.Add( WhereGroup.Or( list.ToArray() ) );
                }
            }

            var statement = query.ToString();

            var tmList = new List<RecProductionCast>();
            var parser = new CastParser( tmList );

            using( var database = new ImpactDatabase() )
            {
                var list = database.GetAll( statement, ParseSchedule );

                foreach( var item in list )
                {
                    item.Form.Factory = filter.Factory;
                    item.Cast.Factory = filter.Factory;

                    item.Form.Project = filter.Project;
                    item.Cast.Project = filter.Project;

                    if( null != item.Element )
                    {
                        item.Element.Factory = filter.Factory;
                        // Never set element.project to curFilter.project
                        // since we retrieve elmenets from different projects!                    
                    }

                    parser.Parse( item.Form, item.Cast, item.Element );
                }
            }

            // Now load all the existing forms
            var formSvc = new ProjectManager();
            var productionFormStdData = formSvc.LoadProductionFormStd( new BedFilter( filter ) { Location = Filter.All } );
            return new CastScheduleData( tmList, productionFormStdData );
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Returns CastData which contains the following info
        /// (1) List<RecProductionFormStd>: a set of beds, each with one production cast ONLY.
        /// The production cast object can contain elements.
        /// (2) ProductionFormStdData: Production Forms Standard Data
        /// </summary>
        /// <param name="filter">BedFilter</param>
        /// <param name="form">RecProductionFormStd</param>
        /// <returns></returns>
        public CastData LoadBedPlanning( BedFilter filter, RecProductionFormStd form )
        {
            if( null == filter || 
                string.IsNullOrEmpty( filter.Factory ) || 
                string.IsNullOrEmpty( filter.Project ) )
            {
                return null;
            }

            ImpactQuery query = new ImpactQuery()
            {
                Select =
				{
					ImpProductionCast.CastId,
					ImpProductionCast.Description,
					ImpProductionCast.StartDate,
					ImpProductionCast.EndDate,
					ImpProductionCast.Tolerance,
					ImpProductionCast.ElementType,
                    ImpProductionCast.Style,
					ImpProductionCast.Strandptn,
                    ImpProductionCast.CastType,
					ImpProductionCast.CastStatus,
                    ImpProductionCast.Form,
					ImpProductionCast.Shift,
					Aggregate.Count( ImpProductionCastStrand.StrandPos ),

					ImpProductionFormStd.Name,
					ImpProductionFormStd.MaxLength,
					ImpProductionFormStd.MaxWidth,
					ImpProductionFormStd.MaxHeight,
                    ImpProductionFormStd.ElementType,
                    ImpProductionFormStd.Style,
					ImpProductionFormStd.Strandptn,
                    ImpProductionFormStd.StrandType,
                    ImpProductionFormStd.FormType,

					ImpModelPlanning.ElementId,
					ImpModelGeometry.ElementMark,
					ImpModelPlanning.ErectionSequenceNo,
					ImpModelPlanning.TransportId,

					ImpModelPlanning.BedSequenceNo,
					ImpModelPlanning.BedX,
					ImpModelPlanning.BedY,
					ImpModelPlanning.BedZ,
					ImpModelPlanning.BedRotation,
                    ImpModelPlanning.ElementIdStatus,
                    ImpModelPlanning.ProductionDate,
                    ImpModelPlanning.PlannedProductionDate,

					ImpElement.ElementLength,
					ImpElement.ElementWidth,
					ImpElement.ElementHeight,
					ImpElement.ElementType,
					ImpElement.GrossArea,
					ImpElement.Product,
					ImpElement.Project,
					ImpElement.AngleLeftSide,
					ImpElement.AngleRightSide,

					ImpElement.Style,
					ImpElement.Strandptn,
					ImpElement.NbrOfStrands,
                    ImpElement.Volume,
                },

                From = { ImpProductionFormStd.As( "FRM" ) },

                Join =
				{
					Join.Left( ImpProductionCast.As( "CST" ),	
						ImpProductionCast.Factory.Equal( ImpProductionFormStd.Factory ),
						ImpProductionCast.Project.Equal( ImpProductionFormStd.Project ),//Factory, Factory
						ImpProductionCast.Form.Equal( ImpProductionFormStd.Name ) ),

					Join.Left( ImpProductionCastStrand.As( "STA" ),	
						ImpProductionCast.Factory.Equal( ImpProductionCastStrand.Factory ),
						ImpProductionCast.Project.Equal( ImpProductionCastStrand.Project ),// Factory, Factory for productionCast & ProductionCastStrand
						ImpProductionCast.CastId.Equal( ImpProductionCastStrand.CastId ) ),


					Join.Left( ImpModelPlanning.As( "MPL" ),	
						ImpProductionCast.Factory.Equal( ImpModelPlanning.Factory ),
						ImpProductionCast.Project.Equal( ImpModelPlanning.Factory ),// Factory, Factory for productionCast & ProductionCastStrand
						ImpProductionCast.CastId.Equal( ImpModelPlanning.CastId ) ),


					Join.Left( ImpModelGeometry.As( "MGO" ),	
						ImpModelPlanning.Factory.Equal( ImpModelGeometry.Factory ),
						ImpModelPlanning.Project.Equal( ImpModelGeometry.Project ),
						ImpModelPlanning.ElementId.Equal( ImpModelGeometry.ElementId ) ),

					Join.Left( ImpElement.As( "ELM" ),	
						ImpModelGeometry.Factory.Equal( ImpElement.Factory ),
						ImpModelGeometry.Project.Equal( ImpElement.Project ),
						ImpModelGeometry.ElementMark.Equal( ImpElement.ElementMark ) ),
				},

                Where = {
							ImpProductionCast.Factory.Equal( filter.Factory ), 
							ImpProductionCast.Project.Equal( filter.Factory ), // Factory, Factory for productionCast & ProductionCastStrand
							ImpProductionCast.StartDate.Equal( filter.StartDateFrom ), 
                            ImpProductionCast.Shift.Equal( filter.Shift ), 
						   // ImpModelPlanning.CastId.GreaterThan( 0 ),      // Get even the casts without elements!
						},

                GroupBy = 
                {
					ImpProductionCast.CastId,
					ImpProductionCast.Description,
					ImpProductionCast.StartDate,
					ImpProductionCast.EndDate,
					ImpProductionCast.Tolerance,
					ImpProductionCast.ElementType,
                    ImpProductionCast.Style,
					ImpProductionCast.Strandptn,
                    ImpProductionCast.CastType,
					ImpProductionCast.CastStatus,
					ImpProductionCast.Form,
					ImpProductionCast.Shift,

					ImpProductionFormStd.Name,
					ImpProductionFormStd.MaxLength,
					ImpProductionFormStd.MaxWidth,
					ImpProductionFormStd.MaxHeight,
                    ImpProductionFormStd.ElementType,
                    ImpProductionFormStd.Style,
					ImpProductionFormStd.Strandptn,
                    ImpProductionFormStd.StrandType,
                    ImpProductionFormStd.FormType,

					ImpModelPlanning.ElementId,
					ImpModelGeometry.ElementMark,
					ImpModelPlanning.ErectionSequenceNo,
					ImpModelPlanning.TransportId,

					ImpModelPlanning.BedSequenceNo,
					ImpModelPlanning.BedX,
					ImpModelPlanning.BedY,
					ImpModelPlanning.BedZ,
					ImpModelPlanning.BedRotation,
                    ImpModelPlanning.ElementIdStatus,
                    ImpModelPlanning.ProductionDate,
                    ImpModelPlanning.PlannedProductionDate,

					ImpElement.ElementLength,
					ImpElement.ElementWidth,
					ImpElement.ElementHeight,
					ImpElement.ElementType,
					ImpElement.GrossArea,
					ImpElement.Product,
					ImpElement.Project,
					ImpElement.AngleLeftSide,
					ImpElement.AngleRightSide,

					ImpElement.Style,
					ImpElement.Strandptn,
					ImpElement.NbrOfStrands,
                    ImpElement.Volume,
                },

                OrderBy = 
				{ 
					{ ImpElement.Project },
					{ ImpProductionFormStd.Name },
					{ ImpProductionCast.CastId },
					{ ImpModelPlanning.BedSequenceNo, OrderBy.Ascending }
				},
            };

            if( filter.FormType != FormType.All )
            {
                query.Where.Add( ImpProductionCast.CastType.Equal( filter.FormType ) );
            }

            if( !string.IsNullOrWhiteSpace( filter.Location ) && !filter.Location.Equals( Filter.All ) )
            {
                query.Where.Add( ImpProductionFormStd.Location.Equal( filter.Location ) );
            }
            if( !filter.Bed.Equals( Filter.All ) )
            {
                query.Where.Add( ImpProductionCast.Form.Equal( filter.Bed ) );
            }

            // used when sorting elements on bed
            if( form != null && !string.IsNullOrWhiteSpace( form.Name ) )
            {
                query.Where.Add( ImpProductionFormStd.Name.Equal( form.Name ) );
            }

            var statement = query.ToString();

            var tmList = new List<RecProductionFormStd>();
            var parser = new FormParser( tmList );

            using( var database = new ImpactDatabase() )
            {
                var list = database.GetAll( statement, ParseCast );

                foreach( var item in list )
                {
                    item.Form.Factory = filter.Factory;
                    item.Cast.Factory = filter.Factory;

                    item.Form.Project = filter.Project; // What does that really mean!
                    item.Cast.Project = filter.Project; // What does that really mean!

                    if( null != item.Element )
                    {
                        item.Element.Factory = filter.Factory;
                        // Never set element.project to curFilter.project
                        // since we retrieve elmenets from different projects!
                    }

                    parser.Parse( item.Form, item.Cast, item.Element );
                }
            }

            var formSvc = new ProjectManager();
            var filter2 = new BedFilter( filter ) { Location = "" };
            var productionFormStdData = formSvc.LoadProductionFormStd( filter2 );

            // Load strands
            LoadCastStrands( tmList, filter );
            LoadFormStrands( productionFormStdData.Forms, filter );

            return new CastData( tmList, productionFormStdData );
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Returns a list of projects that are involved in a certain cast
        /// </summary>
        /// <param name="filter">curFilter</param>
        /// <param name="castId">castId</param>
        /// <returns></returns>
        public List<string> LoadCastProjects( BedFilter filter, int castId )
        {
            if( null == filter || string.IsNullOrWhiteSpace( filter.Factory ) )
            {
                return null;
            }

            var query = new ImpactQuery( true )
            {
                Select =
				{
					ImpModelPlanning.Project,
				},

                From = { ImpProductionCast.As( "CST" ) },

                Join =
				{
					Join.Left( ImpModelPlanning.As( "PLN" ),	
						ImpModelPlanning.Factory.Equal( ImpProductionCast.Factory ),
						ImpModelPlanning.CastId.Equal( ImpProductionCast.CastId ) ),
				},

                Where = {
							ImpModelPlanning.CastId.GreaterThan( 0 ), 
							ImpProductionCast.Factory.Equal( filter.Factory ), 
						},
            };

            if( castId > 0 )
            {
                query.Where.Add( ImpProductionCast.CastId.Equal( castId ) );
            }
            else
            {
                query.Where.Add( ImpProductionCast.StartDate.Equal( filter.StartDateFrom ) );
                query.Where.Add( ImpProductionCast.Shift.Equal( filter.Shift ) );
            }

            string statement = query.ToString();

            List<string> result;
            using( ImpactDatabase database = new ImpactDatabase() )
            {
                result = database.GetAll( statement, Parse );
            }

            return result;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Returns a list of elements that are allowed to bed positioned of the given castunit(bed)
        /// </summary>
        /// <param name="filter">curFilter</param>
        /// <param name="form">castunit</param>
        /// <param name="recProductionCast"> </param>
        /// <param name="elements">A list of elements to be positioned</param>
        /// <param name="strict">Strict flag</param>
        /// <returns></returns>
        private List<RecTMElement> LoadAllowedElements( BedFilter filter, RecProductionFormStd form, RecProductionCast recProductionCast, List<RecTMElement> elements, bool strict )
        {
            if( elements == null || elements.Count == 0 || form == null &&
                filter == null || string.IsNullOrEmpty( filter.Factory ) || string.IsNullOrEmpty( filter.Project ) )
            {
                return null;
            }

            var inVect = ( from o in elements select o.ElementId ).ToArray();

            List<RecTMElement> result;
            var query = new ImpactQuery()
            {
                Select =
				{
                    ImpElement.ElementMark,

                    ImpElement.ElementLength,
					ImpElement.ElementWidth,
					ImpElement.ElementHeight,

                    ImpElement.ElementType,
                    ImpElement.AngleLeftSide,
					ImpElement.AngleRightSide,

					ImpElement.Style,
					ImpElement.Strandptn,
					ImpElement.NbrOfStrands,

                    ImpModelGeometry.Factory,
                    ImpModelGeometry.Project,
                    ImpModelGeometry.ElementId,
				},

                From = { ImpElement.As( "ELM" ) },

                Join =
				{
					Join.Left( ImpModelGeometry.As( "GEO" ),	
						ImpModelGeometry.Factory.Equal( ImpElement.Factory ),
						ImpModelGeometry.Project.Equal( ImpElement.Project ),
						ImpModelGeometry.ElementMark.Equal( ImpElement.ElementMark ) ),
				},

                Where = {
							ImpElement.Factory.Equal( filter.Factory ), 
							ImpElement.Project.Equal( filter.Project ), 
							ImpModelGeometry.ElementId.In( inVect ), 
						},
            };

            if( form != null && ( strict && form.FormType == FormType.Bed ) )
            {
                query.Where.Add( ImpElement.ElementType.Equal( form.ElementType ) );

                var hasStrands = form.ElementType.Equals( ImpactElementType.HollowCore ) ||
                                  form.ElementType.Equals( ImpactElementType.PrestressedSlab ) ||
                                  form.ElementType.Equals( ImpactElementType.PrestressedFormSlab );

                if( hasStrands )
                {
                    if( filter.ForceStyleControl )
                    {
                        var style = (null != recProductionCast)? recProductionCast.Style : form.Style;
                        var strandptn = (null != recProductionCast)? recProductionCast.Strandptn : form.Strandptn;
                        var nbrOfStrands = (null != recProductionCast)? GetNumberOfStrands( recProductionCast ) : GetNumberOfStrands( form );

                        query.Where.Add( ImpElement.Style.Equal( style ) );
                        query.Where.Add( ImpElement.Strandptn.Equal( strandptn ) );
                        query.Where.Add( ImpElement.NbrOfStrands.LessThanOrEqual( nbrOfStrands ) );
                    }
                }
            }

            var statement = query.ToString();
            using( var database = new ImpactDatabase() )  
            {
                result = database.GetAll( statement, ElementParse );
            }

            return result;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Loads all companies, factories and projects available to the specified user.
        /// </summary>
        /// <param name="user">
        /// </param>
        /// <returns>
        /// The StruSoft.Impact.Data.CompanyDataCollection.
        /// </returns>
        public static CompanyDataCollection Load( string user )
        {
            // Make sure the user name is in lower case. ( Doesn't matter for SQL Server, but might be needed for Ingres )
            user = user.ToLower();

            List<Company> result = new List<Company>();

            string statement = GetCompanyFactoryProjectQuery( user );

            ImpactQuery query = new ImpactQuery
                                {
                                    Select =
				{
					ImpUser.CurrentFactory, 
					ImpUser.CurrentProject
				},
                                    From = {
              ImpUser.As( "T1" ) 
           },
                                    Where = {
               ImpUser.Userid.Equal( user ) 
            },
                                };

            string userFactoryProject = query.ToString();

            CompanyDataCollection data = null;

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                var tempDataList = database.GetAll( statement, column => new
                {
                    Company = column[0].Cast<string>(),
                    CompanyName = column[1].Cast<string>(),
                    Factory = column[2].Cast<string>(),
                    FactoryName = column[3].Cast<string>(),
                    Project = column[4].Cast<string>().Trim(),
                    ProjectName = column[5].Cast<string>(),
                    Description = column[6].Cast<string>(),
                    Date = column[7].Cast<DateTime?>(),
                    ProjectType = column[8].Cast<ProjectType>(),
                    Status = column[9].Cast<ProjectStatus>(),
                } );

                var phaseList = database.GetAll( GetAllProjectPhaseQuery( user ), column => new
                {
                    Factory = column[0].Cast<string>(),
                    Project = column[1].Cast<string>().Trim(),
                    Phase = column[2].Cast<string>().Trim(),
                } );

                result = ( from row in tempDataList
                           orderby row.Company.GetAlphaNumericOrderToken()
                           group row by new { row.Company, row.CompanyName } into companyGroup
                           select new Company( companyGroup.Key.Company, companyGroup.Key.CompanyName )
                           {
                               Factories =
                                 ( from row in companyGroup
                                   orderby row.Factory.GetAlphaNumericOrderToken()
                                   group row by new { row.Factory, row.FactoryName } into factoryGroup
                                   select new Factory( factoryGroup.Key.Factory, factoryGroup.Key.FactoryName )
                                   {
                                       Projects =
                                       ( from row in factoryGroup
                                         orderby row.Date descending
                                         // Find all phases mathching this project and the project's factory, select the phase and order by ascending.
                                         let phases =
                                             phaseList.FindAll( phase => phase.Factory == row.Factory && phase.Project == row.Project ).Select(
                                                 phase => phase.Phase ).OrderBy( phase => phase.GetAlphaNumericOrderToken() )
                                         select
                                             new Project( row.Project, row.ProjectName, row.Description, row.Date, row.ProjectType, row.Status,
                                                          phases.ToList() ) ).ToList()

                                   } ).ToList(),

                           } ).ToList();

                CurrentProject currentProject = database.GetFirst( userFactoryProject, column => new CurrentProject
                                                                                                 {
                                                                                                     User = user,
                                                                                                     Factory = column[0].Cast<string>(),
                                                                                                     Project = ( column[1].Cast<string>() ?? string.Empty ).Trim(),
                                                                                                 } );

                if( null == currentProject )
                {
                    data = new CompanyDataCollection( user, result );
                }
                else
                {
                    data = new CompanyDataCollection( currentProject, result );
                }
            }

            return data;
        }
Ejemplo n.º 21
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<RecSectionStyleStd> LoadSqlServer( RecSectionStyleStd record )
		{
			if( record == null || record.Factory == null )
			{
				return null;
			}
			string company = record.Factory.Substring( 0, 2 ) + "00"; //Is this really OK ??!!

			WhereGroup wgElementType = WhereGroup.Or( ImpSectionStyleStd.ElementType.Equal( "HD/F" ),
													  ImpSectionStyleStd.ElementType.Equal( "D/F" ));

			// Prepare Factory, Project statement
			ImpactQuery projectQuery = new ImpactQuery()
			{
				Select = {
					        ImpSectionStyleStd.Factory,
					        ImpSectionStyleStd.Project,
					        ImpSectionStyleStd.ElementType,
					        ImpSectionStyleStd.Name,
					        ImpSectionStyleStd.SectionType,
					        ImpSectionStyleStd.Description,
				        },
				From = { ImpSectionStyleStd.As( "T1" ) },
				Where = {
                            ImpSectionStyleStd.Factory.Equal( record.Factory ),
					        ImpSectionStyleStd.Project.Equal( record.Project ),
							wgElementType },
			};
			string projectStatement = projectQuery.ToString();

			// Prepare Factory, Factory statement
			ImpactQuery factoryQuery = new ImpactQuery()
			{
				Select = {
					        ImpSectionStyleStd.Factory,
					        ImpSectionStyleStd.Project,
					        ImpSectionStyleStd.ElementType,
					        ImpSectionStyleStd.Name,
					        ImpSectionStyleStd.SectionType,
					        ImpSectionStyleStd.Description,
				        },
				From = { ImpSectionStyleStd.As( "T1" ) },
				Where = {
                            ImpSectionStyleStd.Factory.Equal( record.Factory ),
					        ImpSectionStyleStd.Project.Equal( record.Factory ),
							wgElementType 
                        },
			};
			string factoryStatement = factoryQuery.ToString();
			ImpactQuery projectSubquery = new ImpactQuery {
				Select = { ImpSectionStyleStd.Name },
				From = { ImpSectionStyleStd.As( "T1" ) },
				Where = {
                            ImpSectionStyleStd.Factory.Equal( record.Factory ),
					        ImpSectionStyleStd.Project.Equal( record.Project ),
							wgElementType 
                        },
			};
			factoryStatement += " AND T1.Name Not In (" + projectSubquery.ToString() + ")";

			// Prepare Company, Company statement
			ImpactQuery companyQuery = new ImpactQuery()
			{
				Select = {
					        ImpSectionStyleStd.Factory,
					        ImpSectionStyleStd.Project,
					        ImpSectionStyleStd.ElementType,
					        ImpSectionStyleStd.Name,
					        ImpSectionStyleStd.SectionType,
					        ImpSectionStyleStd.Description,
				        },
				From = { ImpSectionStyleStd.As( "T1" ) },
				Where = {
                            ImpSectionStyleStd.Factory.Equal( company ),
					        ImpSectionStyleStd.Project.Equal( company ),
							wgElementType },
			};
			string companyStatement = companyQuery.ToString();
			ImpactQuery factorySubquery = new ImpactQuery()
			{
				Select = { ImpSectionStyleStd.Name },
				From = { ImpSectionStyleStd.As( "T1" ) },
				Where = {
                            ImpSectionStyleStd.Factory.Equal( record.Factory ),
					        ImpSectionStyleStd.Project.Equal( record.Factory ),
							wgElementType },
			};
			companyStatement += " AND T1.Name Not In (" + projectSubquery.ToString() + ")"
							 + " AND T1.Name Not In (" + factorySubquery.ToString() + ")";
			string statement = projectStatement + " Union " + factoryStatement + " Union " + companyStatement + " Order By T1.ELEMENT_TYPE, T1.Name";

			List<RecSectionStyleStd> result;
			using( ImpactDatabase database = new ImpactDatabase() )
			{
				result = database.GetAll( statement, ParseSectionStyleStd );
			}
			return result;
		}
Ejemplo n.º 22
0
        /// <summary>
        /// The load planning table data.
        /// </summary>
        /// <param name="factory">
        /// The factory.
        /// </param>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <param name="user">
        /// The user.
        /// </param>
        /// <param name="idList">
        /// The id list.
        /// </param>
        /// <returns>
        /// The StruSoft.Impact.V120.ProjectManager.Core.TableGrid.PlanningData.
        /// </returns>
        public static PlanningData LoadPlanningTableData( string factory, string project, string user, int[] idList )
        {
            string company = Util.FactoryToCompany( factory );
            project = Util.CorrectProjectName( project );

            List<PlanningElementData> planningElementDataList;

            using( ImpactDatabase service = new ImpactDatabase() )
            {
                string query = GetPlanningElementDataQuery( factory, project, idList ).ToString();
                string factoryQuery = GetFactoryQuery( factory, project, user ).ToString();
                string divisionQuery = GetPlanningDivisionQuery( company ).ToString();

                // Get all the specified elements.
                planningElementDataList = service.GetAll( query, ReadPlanningElementData );

                var elementStatusStandard = service.GetAll( 
                    GetElementStatusStandardQuery( company ), 
                    column => new ElementStatusStandard
                        {
                            StatusId    = column[0].Cast<int>(), 
                            Description = column[1].Cast<string>(), 
                            ColorIndex  = column[2].Cast<int>(), 
                        }).ToDictionary( item => item.StatusId );

                var factoryDataList = service.GetAll( factoryQuery, column => new Factory( column[0].Cast<string>(), column[1].Cast<string>() ) );
                factoryDataList.Add( Factory.External );

                var divisionDataList = service.GetAll( divisionQuery, column => column[0].Cast<string>() );

                foreach( var planningElement in planningElementDataList )
                {
                    ElementStatusStandard standard;

                    if( elementStatusStandard.TryGetValue( planningElement.Status, out standard ) )
                    {
                        planningElement.StatusDescription = standard.Description;
                    }

                    if( 0 == string.Compare( planningElement.ProducingFactory, ProjectBrowserLoader.ProducingFactoryExternalValue, true ) )
                    {
                        planningElement.ProducingFactory = Factory.External.Number;
                    }
                }

                PlanningData planningData = new PlanningData( planningElementDataList, divisionDataList, factoryDataList );

                return planningData;
            }
        }
Ejemplo n.º 23
0
	    /// <summary> 
	    /// Load the strands of the given pattern.
	    /// </summary>
	    /// <param name="factory"> </param>
	    /// <param name="project"> </param>
	    /// <param name="elementType"> </param>
	    /// <param name="style"> </param>
	    /// <param name="strandpattern"> </param>
	    /// <returns>A list of all mathcing records.</returns>
	    public List<RecProductionCastStrand> LoadStrands(  string factory, string project, string elementType, string style, string strandpattern )
		{
			// Add, Factory, Factory and Company, Company
			var company = factory.Substring( 0, 2 ) + "00"; //Is this really OK ??!!
            
            var where1 = WhereGroup.And( ImpSectionStyleStd.Factory.Equal( factory ), ImpSectionStyleStd.Project.Equal( project ) );
            var where2 = WhereGroup.And( ImpSectionStyleStd.Factory.Equal( factory ), ImpSectionStyleStd.Project.Equal( factory ) );
            var where3 = WhereGroup.And( ImpSectionStyleStd.Factory.Equal( company ), ImpSectionStyleStd.Project.Equal( company ) );

            var orProjectFactoryCompany = WhereGroup.Or( where1, where2, where3 );

			var query = new ImpactQuery()
			{
				Select =
				{
					ImpSectionStyleStd.Factory,
					ImpSectionStyleStd.Project,
                    ImpSectionStyleStd.Name,
                    ImpSectionStrandptnStd.Name,
					ImpSectionStrandPosStd.StrandPos,
					ImpSectionStrandPosStd.StrandX,
					ImpSectionStrandPosStd.StrandY,
					ImpSectionStrandptnGrpStd.StrandDimension,
                    ImpSectionStrandptnGrpStd.StrandPrestressing,
                    ImpSectionStrandptnGrpStd.StrandQuality,
				},
				From = { ImpSectionStyleStd.As( "T1" ) },
                Join =
				{
					Join.Left( ImpSectionStrandptnStd.As( "T2" ),	
						ImpSectionStrandptnStd.Factory.Equal( ImpSectionStyleStd.Factory ),
						ImpSectionStrandptnStd.Project.Equal( ImpSectionStyleStd.Project ),
						ImpSectionStrandptnStd.ElementType.Equal( ImpSectionStyleStd.ElementType ), 
						ImpSectionStrandptnStd.Section.Equal( ImpSectionStyleStd.Name )),

					Join.Left( ImpSectionStrandptnPosStd.As( "T3" ),	
						ImpSectionStrandptnPosStd.Factory.Equal( ImpSectionStrandptnStd.Factory ),
						ImpSectionStrandptnPosStd.Project.Equal( ImpSectionStrandptnStd.Project ),
						ImpSectionStrandptnPosStd.ElementType.Equal( ImpSectionStrandptnStd.ElementType ), 
						ImpSectionStrandptnPosStd.Section.Equal( ImpSectionStrandptnStd.Section ),
                        ImpSectionStrandptnPosStd.Strandptn.Equal( ImpSectionStrandptnStd.Name )),

					Join.Left( ImpSectionStrandPosStd.As( "T4" ),	
						ImpSectionStrandPosStd.Factory.Equal( ImpSectionStrandptnPosStd.Factory ),
						ImpSectionStrandPosStd.Project.Equal( ImpSectionStrandptnPosStd.Project ),
						ImpSectionStrandPosStd.ElementType.Equal( ImpSectionStrandptnPosStd.ElementType ), 
						ImpSectionStrandPosStd.Section.Equal( ImpSectionStrandptnPosStd.Section ),
                        ImpSectionStrandPosStd.StrandPos.Equal( ImpSectionStrandptnPosStd.StrandPos )),

					Join.Left( ImpSectionStrandptnGrpStd.As( "T5" ),	
						ImpSectionStrandptnGrpStd.Factory.Equal( ImpSectionStrandPosStd.Factory ),
						ImpSectionStrandptnGrpStd.Project.Equal( ImpSectionStrandPosStd.Project ),
						ImpSectionStrandptnGrpStd.ElementType.Equal( ImpSectionStrandPosStd.ElementType ), 
                        ImpSectionStrandptnGrpStd.Section.Equal( ImpSectionStrandPosStd.Section ),
						ImpSectionStrandptnGrpStd.Strandptn.Equal( ImpSectionStrandptnPosStd.Strandptn ),
                        ImpSectionStrandptnGrpStd.StrandGrp.Equal( ImpSectionStrandPosStd.StrandGrp )),
				},

				Where =
				    {
				        ImpSectionStyleStd.ElementType.Equal( elementType ), 
                        ImpSectionStyleStd.Name.Equal( style ), 
                        ImpSectionStrandptnPosStd.Strandptn.Equal( strandpattern ),
                        orProjectFactoryCompany
				    },
			};

			var statement = query.ToString();
           
			List<RecProductionCastStrand> result;

			using( var database = new ImpactDatabase() )
			{
				result = database.GetAll( statement, column => new RecProductionCastStrand()
				                {
				                    Factory = column[0].Cast<string>(),
				                    Project = column[1].Cast<string>(),
				                    Style = column[2].Cast<string>(),
				                    Strandpattern = column[3].Cast<string>(),
                                    StrandPos = column[4].Cast<int>(),
                                    StrandX = column[5].Cast<double>(),
                                    StrandY = column[6].Cast<double>(),
                                    StrandDimension = column[7].Cast<double>(),
                                    StrandPrestressing = column[8].Cast<double>(),
                                    StrandQuality = column[9].Cast<string>(),

				                } );
			}

			if( result == null || result.Count == 0 )
			{
				return result;
			}

	        var strands = ( from o in result where ( o.Factory == factory && o.Project == project ) select o ).ToList();
            if( strands.Count > 0 )
            {
                return strands;
            }

            strands = ( from o in result where ( o.Factory == factory && o.Project == factory ) select o ).ToList();
            if( strands.Count > 0 )
            {
                return strands;
            }

            return ( from o in result where ( o.Factory == company && o.Project == company ) select o ).ToList();
		}
Ejemplo n.º 24
0
        /// <summary>
        /// Load Element status Settings
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public List<RecElementIdStatusStd> LoadStandardSettings( RecElementIdStatusStd record )
        {
            if( record == null || record.Factory == null )
            {
                return null;
            }
            string company = record.Factory.Substring( 0, 2 ) + "00"; //Is this really OK ??!!


            // Prepare Factory, Project statement
            ImpactQuery projectQuery = new ImpactQuery()
            {
                Select = {
					        ImpElementIdStatusStd.Factory,
					        ImpElementIdStatusStd.Project,
					        ImpElementIdStatusStd.StatusId,
					        ImpElementIdStatusStd.Description,
					        ImpElementIdStatusStd.StatusType,
					        ImpElementIdStatusStd.ColorIndex,
				        },
                From = { ImpElementIdStatusStd.As( "T2" ) },
                Where = {
                            { ImpElementIdStatusStd.Factory.Equal( record.Factory )},
					        { ImpElementIdStatusStd.Project.Equal( record.Project )},
                        },
            };
            string projectStatement = projectQuery.ToString();

            // Prepare Factory, Factory statement
            ImpactQuery factoryQuery = new ImpactQuery()
            {
                Select = {
					        ImpElementIdStatusStd.Factory,
					        ImpElementIdStatusStd.Project,
					        ImpElementIdStatusStd.StatusId,
					        ImpElementIdStatusStd.Description,
					        ImpElementIdStatusStd.StatusType,
					        ImpElementIdStatusStd.ColorIndex,
				        },
                From = { ImpElementIdStatusStd.As( "T1" ) },
                Where = {
                            { ImpElementIdStatusStd.Factory.Equal( record.Factory )},
					        { ImpElementIdStatusStd.Project.Equal( record.Factory )},
                        },
            };
            string factoryStatement = factoryQuery.ToString();
            ImpactQuery projectSubquery = new ImpactQuery()
            {
                Select = { ImpElementIdStatusStd.StatusId },
                From = { ImpElementIdStatusStd.As( "T1" ) },
                Where = {
                            { ImpElementIdStatusStd.Factory.Equal( record.Factory )},
					        { ImpElementIdStatusStd.Project.Equal( record.Project )},
                        },
            };
            factoryStatement += " AND T1.Status_Id Not In (" + projectSubquery.ToString() + ")";

            // Prepare Company, Company statement
            ImpactQuery companyQuery = new ImpactQuery()
            {
                Select = {
					        ImpElementIdStatusStd.Factory,
					        ImpElementIdStatusStd.Project,
					        ImpElementIdStatusStd.StatusId,
					        ImpElementIdStatusStd.Description,
					        ImpElementIdStatusStd.StatusType,
					        ImpElementIdStatusStd.ColorIndex,
				        },
                From = { ImpElementIdStatusStd.As( "T1" ) },
                Where = {
                            { ImpElementIdStatusStd.Factory.Equal( company )},
					        { ImpElementIdStatusStd.Project.Equal( company )},
                        },
            };
            string companyStatement = companyQuery.ToString();
            ImpactQuery factorySubquery = new ImpactQuery()
            {
                Select = { ImpElementIdStatusStd.StatusId },
                From = { ImpElementIdStatusStd.As( "T1" ) },
                Where = {
                            { ImpElementIdStatusStd.Factory.Equal( record.Factory )},
					        { ImpElementIdStatusStd.Project.Equal( record.Factory )},
                        },
            };
            companyStatement += " AND T1.Status_Id Not In (" + projectSubquery.ToString() + ")"
                             + " AND T1.Status_Id Not In (" + factorySubquery.ToString() + ")";
            string statement = projectStatement + " Union " + factoryStatement + " Union " + companyStatement + " Order By T2.Status_Id";

            List<RecElementIdStatusStd> result;
            using( ImpactDatabase database = new ImpactDatabase() )
            {
                result = database.GetAll( statement, SettingParse );
            }
            return result;
        }
Ejemplo n.º 25
0
        /// <summary>
        /// The update erection sequence.
        /// </summary>
        /// <param name="factory">
        /// The factory.
        /// </param>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <param name="erectionSequenceList">
        /// The erection sequence list.
        /// </param>
        /// <returns>
        /// The System.Boolean.
        /// </returns>
        public bool UpdateErectionSequence( string factory, string project, List<KeyValuePair<int, int>> erectionSequenceList )
        {
            project = project.PadLeft( 12 );

            List<string> statementList = new List<string>( erectionSequenceList.Count );

            using( var database = new ImpactDatabase() )
            {
                var allIdArray = erectionSequenceList.Select( x => (object)x.Key ).ToArray();
                ImpactQuery query = new ImpactQuery
                                    {
                    Select = {
                                ImpModelPlanning.ElementId 
                             }, 
                    From = {
                              ImpModelPlanning.As( "T1" ) 
                           }, 
                    Where =
                    {
                        ImpModelPlanning.Factory.Equal( factory ), 
                        ImpModelPlanning.Project.Equal( project ), 
                        ImpModelPlanning.ElementId.In( allIdArray ), 
                    }, 
                };

                string statement = query.ToString();
                var existingPlanningList = database.GetAll( statement, column => column[0].Cast<int>() );
                var groupedByInsertUpdate = erectionSequenceList.GroupBy( x => existingPlanningList.Remove( x.Key ) ).ToList();

                var updateList = groupedByInsertUpdate.Find( x => x.Key );

                var insertList = groupedByInsertUpdate.Find( x => !x.Key );

                if( null != updateList )
                {
                    foreach( var item in updateList )
                    {
                        var update = new ImpactUpdate( ImpModelPlanning.Instance )
                        {
                            Columns = {
                                         { ImpModelPlanning.ErectionSequenceNo, item.Value } 
                                      }, 
                            Where =
                            {
                                ImpModelPlanning.Factory.Equal( factory ), 
                                ImpModelPlanning.Project.Equal( project ), 
                                ImpModelPlanning.ElementId.Equal( item.Key ), 
                            }
                        };
                        statementList.Add( update.ToString() );
                    }
                }

                if( null != insertList )
                {
                    foreach( var item in insertList )
                    {
                        var insert = new ImpactInsert( ImpModelPlanning.Instance )
                        {
                            Columns =
                            {
                            { ImpModelPlanning.Factory, factory }, 
                            { ImpModelPlanning.Project, project }, 
                            { ImpModelPlanning.ElementId, item.Key }, 
                            { ImpModelPlanning.ErectionSequenceNo, item.Value }, 
                            }, 
                        };

                        statementList.Add( insert.ToString() );
                    }
                }

                int result = database.ExecuteNonQuery( statementList.ToArray() );

                return result > 0;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Loads all the data necessesary for creating the "Project Browser" tree.
        /// </summary>
        /// <param name="factory">
        /// Which factory the project belongs to.
        /// </param>
        /// <param name="project">
        /// Which project to load.
        /// </param>
        /// <returns>
        /// The <see cref="ProjectRootData"/>.
        /// </returns>
        public static ProjectRootData Load( string factory, string project )
        {
            ProjectRootData projectRoot = new ProjectRootData( factory, project.Trim() );

            project = Util.CorrectProjectName( project );
            string company = Util.FactoryToCompany( factory );

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                var titleAndDescription = database.GetFirst( 
                    GetProjectInfoQuery( factory, project ).ToString(), 
                    column => new
                        {
                            Title = column[0].Cast<string>(),
                            Description = column[1].Cast<string>(),
                            FactoryName = column[2].Cast<string>()
                        } );

                projectRoot.Title = titleAndDescription.Title;
                projectRoot.Description = titleAndDescription.Description;
                projectRoot.FactoryName = titleAndDescription.FactoryName;

                // Get and set the element status standard.
                projectRoot.ElementStatusStandard = database.GetAll( 
                    GetElementStatusStandardQuery( company ), 
                    column => new ElementStatusStandard
                              {
                                  StatusId    = column[0].Cast<int>(),
                                  Description = column[1].Cast<string>(),
                                  ColorIndex  = column[2].Cast<int>(),
                              }

                    ).ToDictionary( item => item.StatusId );

                // Get all elements.
                var elementDataList = database.GetAll( GetProjectElementDataQuery( factory, project ), ReadElementData );

                foreach (var elementGroup in elementDataList.GroupBy(data => data.ElementMark) )
                {
                    var count = elementGroup.Count();
                    foreach (var elementData in elementGroup)
                    {
                        elementData.Quantity = count;
                    }
                }
                
                // Get all levels and buildings.
                var tempBuildingFloorList = database.GetAll( 
                    GetBuildingLevelDataQuery( factory, project ), 
                    column => new
                    {
                        Building             = column[0].Cast<string>().Trim(), 
                        FloorId              = column[1].Cast<int>(), 
                        FloorName            = column[2].Cast<string>(), 
                        ElevationFloor       = column[3].Cast<double>(), 
                        Topping              = column[4].Cast<double>(), 
                        FloorHeight          = column[5].Cast<double>(), 
                        FloorToHeadOfOpening = column[6].Cast<double>(), 
                        FloorToCeiling       = column[7].Cast<double>(), 
                        WallBlockUp          = column[8].Cast<double>(), 
                    });

                // Phases.
                projectRoot.Phases = database.GetAll( GetPhaseQuery( factory, project ), column => column[0].Cast<string>().Trim() ).OrderBy( x => x.GetAlphaNumericOrderToken() ).ToList();

                // Elevations.
                var elevationList = database.GetAll( GetElevationQuery( factory, project ).ToString(), column => column[0].Cast<string>().Trim() ).OrderBy( x => x.GetAlphaNumericOrderToken() ).ToList();

                var elementsGrouping = ( from row in elementDataList
                                         orderby row.ElementMark.GetAlphaNumericOrderToken() ascending
                                         group row by new { row.Building, row.FloorId, row.ElementType } into g
                                         select g ).ToList();

                var buildingDataList = ( from row in tempBuildingFloorList
                                         group row by new { row.Building } into buildingGroup
                                         orderby buildingGroup.Key.Building.GetAlphaNumericOrderToken()
                                         select new BuildingData( buildingGroup.Key.Building )
                                         {
                                             Levels =
                                               ( from level in buildingGroup
                                                 orderby level.ElevationFloor
                                                 select new LevelData
                                                        {
                                                     Building              = level.Building, 
                                                     Id                    = level.FloorId, 
                                                     Name                  = level.FloorName, 
                                                     Elevation             = level.ElevationFloor, 
                                                     Height                = level.FloorHeight, 
                                                     HeightToHeadOfOpening = level.FloorToHeadOfOpening, 
                                                     HeightToCeiling       = level.FloorToCeiling, 
                                                     WallBlockUp           = level.WallBlockUp, 

                                                     ElementCategories =
                                                         ( from elementGroup in elementsGrouping
                                                           where
                                                           elementGroup.Key.Building == level.Building &&
                                                           elementGroup.Key.FloorId == level.FloorId
                                                           select new ElementCategoryData( elementGroup.Key.ElementType, elementGroup.ToList() ) ).ToList()
                                                 }

                                                 ).ToList()
                                         }).ToList();

                // Set the building data list.
                projectRoot.Model = new ModelData( buildingDataList, elevationList );

                // Get Company Settings.
                CompanySettings companySettings = GetCompanySettings( company, database );

                projectRoot.CompanySettings = companySettings;
            }

            return projectRoot;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// The update planning element data.
        /// </summary>
        /// <param name="factory">
        /// The factory.
        /// </param>
        /// <param name="project">
        /// The project.
        /// </param>
        /// <param name="planningElementList">
        /// The planning element list.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// Thrown when the database source is unknown.
        /// </exception>
        public void UpdatePlanningElementData( string factory, string project, List<PlanningElementDataUpdate> planningElementList )
        {
            project = Util.CorrectProjectName( project );
                      
            switch( ImpactDatabase.DataSource )
            {
                case DataSource.Ingres92:
                case DataSource.Ingres100:
                {
                    // Create a query that return all the id's of those elements that aldready has planning data.
                    ImpactQuery query = new ImpactQuery()
                        {
                            From = { ImpModelPlanning.As( "T1" ) },
                            Select = { ImpModelPlanning.ElementId },
                            Where =
                                    {
                                        ImpModelPlanning.Factory.Equal(factory),
                                        ImpModelPlanning.Project.Equal(project),
                                        ImpModelPlanning.ElementId.In<int>( planningElementList.Select( element => element.ElementId ) )
                                    }
                        };

                    using( var database = new ImpactDatabase() )
                    {
                        var existingIds = database.GetAll( query.ToString(), reader => reader[0].Cast<int>() );

                        var statementList = new List<string>( planningElementList.Count );

                        foreach( var element in planningElementList )
                        {
                            string producingFactory;

                            if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) )
                            {
                                producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue;
                            }
                            else
                            {
                                producingFactory = element.ProducingFactory;
                            }

                            if( existingIds.Contains( element.ElementId ) )
                            {
                                // We have an update.
                                var update = new ImpactUpdate( ImpModelPlanning.Instance )
                                {
                                    Where = 
                                        {
                                            ImpModelPlanning.Factory.Equal( factory ), 
                                            ImpModelPlanning.Project.Equal( project ), 
                                            ImpModelPlanning.ElementId.Equal( element.ElementId ), 
                                        },
                                    Columns =
                                        {
                                            { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, 
                                            { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, 
                                            { ImpModelPlanning.ProductionDate, element.ProductionDate }, 
                                            { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, 
                                            { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, 
                                            { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, 
                                            { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, 
                                            { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, 
                                            { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, 
                                            { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, 
                                            { ImpModelPlanning.ElementIdStatus, element.Status }, 
                                        }
                                };

                                statementList.Add( update.ToString() );
                            }
                            else
                            {
                                // We must insert a new row.
                                var insert = new ImpactInsert( ImpModelPlanning.Instance )
                                {
                                    Columns =
                                        {
                                            { ImpModelPlanning.Factory, factory }, 
                                            { ImpModelPlanning.Project, project }, 
                                            { ImpModelPlanning.ElementId, element.ElementId }, 
                                            { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, 
                                            { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, 
                                            { ImpModelPlanning.ProductionDate, element.ProductionDate }, 
                                            { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, 
                                            { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, 
                                            { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, 
                                            { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, 
                                            { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, 
                                            { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, 
                                            { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, 
                                            { ImpModelPlanning.ElementIdStatus, element.Status }, 
                                        }
                                };

                                statementList.Add( insert.ToString() );
                            }
                        }

                        database.ExecuteNonQuery( statementList.ToArray() );
                    }
                    break;
                }
                case DataSource.SqlServer:
                case DataSource.SqlServerExpress:
                {
                    List<string> statementList = new List<string>( planningElementList.Count );

                    foreach( var element in planningElementList )
                    {
                        string producingFactory;

                        if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) )
                        {
                            producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue;
                        }
                        else
                        {
                            producingFactory = element.ProducingFactory;
                        }

                        ImpactInsertOrUpdate insertOrUpdate = new ImpactInsertOrUpdate( ImpModelPlanning.Instance )
                        {
                            Keys =
                            {
                                { ImpModelPlanning.Factory, factory }, 
                                { ImpModelPlanning.Project, project }, 
                                { ImpModelPlanning.ElementId, element.ElementId }, 
                            }, 
                            Columns =
                            {
                                { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, 
                                { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, 
                                { ImpModelPlanning.ProductionDate, element.ProductionDate }, 
                                { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, 
                                { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, 
                                { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, 
                                { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, 
                                { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, 
                                { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, 
                                { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, 
                                { ImpModelPlanning.ElementIdStatus, element.Status }, 
                            }
                        };

                        statementList.Add( insertOrUpdate.ToString() );
                    }

                    using( var database = new ImpactDatabase() )
                    {
                        database.ExecuteNonQuery( statementList.ToArray() );
                    }

                    break;
                }

                default:
                {
                    throw new InvalidOperationException( "Unknown database source." );
                }
            }
        }
		/// <summary>
		/// Loading Transport Vehicle Standard items
		/// </summary>
		/// <param name="rec"></param>
		/// <returns></returns>
		public List<RecTransportVehicleStd> LoadTransportVehiclesEx( RecTransport rec, int vehicleId )
		{
			if( rec == null || rec.Factory == null || rec.Project == null )
			{
				return null;
			}
			string project = "";
			if( rec.IsTemplate == 1 )
			{
				// Templates are saved on factory level (factory, factory), 2012-04-23
				project = rec.Factory;
			}
			else
			{
				project = rec.Project;
			}
			List<RecTransportVehicleStd> lst = new List<RecTransportVehicleStd>();
			using( ImpactDatabase database = new ImpactDatabase() )
			{
				// 1. Instantiate a new command with a query and connection
				string wcVehicle = "";
				if( vehicleId > 0 )
				{
					wcVehicle = " AND TSP.VEHICLE_ID=" + Conv.Sql( vehicleId );
				}
				string sql = "SELECT TSP.TRANSPORT_TYPE AS TSP_TRANSPORT_TYPE, TSP.VEHICLE_ID AS TSP_VEHICLE_ID, "
							+ "VEH.VEHICLE_TYPE, VEH.NAME, VEH.Description, VEH.Max_Length, VEH.Max_Width, VEH.Max_Height, VEH.Max_Mass"
							+ " FROM "
							+ "IMP_TRANSPORT_VEHICLE_STD VEH "
							+ "join IMP_TRANSPORT_VEHICLE TSP ON "
							+ "VEH.FACTORY = TSP.FACTORY "
							+ "AND VEH.PROJECT = TSP.FACTORY "// Factory, Factory only so far!!!
							+ "AND VEH.NAME = TSP.VEHICLE "
							+ "Where "
							+ "TSP.FACTORY=" + Conv.Sql( rec.Factory ) + " AND "
							+ "TSP.PROJECT=" + Conv.Sql( project ) + " AND " // Templates are saved on factory level (factory, factory), 2012-04-23
							+ "TSP.TRANSPORT_ID=" + Conv.Sql( rec.TransportId )
							+ wcVehicle
							+ " Order By TSP.VEHICLE_SEQUENCE_NO";

				lst = database.GetAll( sql, column => new RecTransportVehicleStd()
				{
					TransportType = DataConverter.Cast<int>( column[0] ),
					VehicleId = DataConverter.Cast<int>( column[1] ),
					VehicleType = DataConverter.Cast<int>( column[2] ),


					Name = DataConverter.Cast<string>( column[3] ),
					Description = DataConverter.Cast<string>( column[4] ),
					MaxLength = DataConverter.Cast<double>( column[5] ),
					MaxWidth = DataConverter.Cast<double>( column[6] ),
					MaxHeight = DataConverter.Cast<double>( column[7] ),
					MaxMass = DataConverter.Cast<double>( column[8] ),

					// Make life easier for the client
					TransportId = rec.TransportId,
					Factory = rec.Factory,
					Project = rec.Project,
				} );
			}
			return lst;
		}
Ejemplo n.º 29
0
		/// <summary>
		/// Returns max value of transport_id
		/// </summary>
		/// <param name="transport"></param>
		/// <returns></returns>
		public int GetMaxTransportId( RecTransport record )
		{
			if( record == null )
			{
				throw new ArgumentNullException( "Transport" );
			}
			int ret = 0;
			using( ImpactDatabase database = new ImpactDatabase() )
			{
				ImpactQuery query = new ImpactQuery()
				{
					Select =
					{
						 Aggregate.Max(ImpTransport.TransportId)
					},
					From = { ImpTransport.As( "T1" ) },
					Where = { ImpTransport.Factory.Equal( record.Factory ), 
							  ImpTransport.Project.Equal( record.Project ),
							  ImpTransport.TransportId.GreaterThan( 0 )},
				};
				string statement = query.ToString();
				List<int> result = null;
				try
				{
					result = database.GetAll( statement, column =>
					{
						return DataConverter.Cast<int?>( column[0] ) ?? 0;
					} );
					ret = result[0];
				}
				catch( Exception ) { }//Just eat it please!
			}
			return ret;
		}
Ejemplo n.º 30
0
        /// <summary>
        /// GetUntransportedElement
        /// </summary>
        /// <param name="factory"></param>
        /// <param name="project"></param>
        /// <param name="elements"></param>
        /// <returns></returns>
        private List<RecTMElement> GetUntransportedElement( string factory, string project, List<RecTMElement> elements )
        {
            if( elements == null || elements.Count == 0 )
            {
                return null;
            }
            int[] InVect = new int[elements.Count];
            // Linq is to be used
            //InVect = (int[])(from row in elements select row.ElementId);
            //int i = 0;
            //foreach (RecTMElement rec in elements)
            //{
            //  InVect[i] = rec.ElementId;
            //  i++;
            //}
            string whereIn = "";
            foreach( RecTMElement rec in elements )
            {
                whereIn += rec.ElementId.ToString() + ",";
            }
            if( whereIn.Length > 0 )
            {
                whereIn = whereIn.Substring( 0, whereIn.Length - 1 );
            }

            List<RecTMElement> transported = null;

            using( ImpactDatabase database = new ImpactDatabase() )
            {
                ImpactQuery query = new ImpactQuery()
                {
                    From = { ImpModelPlanning.As( "T1" ) },
                    Select = { ImpModelPlanning.ElementId },
                    Where = { ImpModelPlanning.Factory.Equal(factory), 
								ImpModelPlanning.Project.Equal(project), 
								ImpModelPlanning.TransportId.GreaterThan(0) 
							} //ImpModelPlanning.ElementId.In(InVect) //To be used in stead of the code below!
                };

                string statement = query.ToString();
                if( whereIn.Length > 0 )
                {
                    statement += " AND T1.ELEMENT_ID " + "IN(" + whereIn + ")";
                }

                transported = database.GetAll( statement, column => new RecTMElement()
                {
                    ElementId = DataConverter.Cast<int>( column[0] )
                } );
            }
            List<RecTMElement> result = elements;
            if( transported != null && transported.Count > 0 )
            {
                //Some of our elements in the list are already transported
                //so remove them from the incoming list
                result = new List<RecTMElement>();
                foreach( RecTMElement rec in elements )
                {
                    if( !IsTransported( rec, transported ) )
                    {
                        result.Add( rec );
                    }
                }
            }
            return result;
        }