Ejemplo n.º 1
0
        /// <summary>
        /// This method is used to get data and insert data in database for vehicle
        /// </summary>
        /// <param name="BatchId"></param>
        /// <param name="User"></param>
        /// <returns></returns>
        public bool VehicleImportTransactionProcess(int batchId, string user)
        {
            bool isSucceeded = false;

            var query = string.Empty;

            try
            {
                List <VehicleLocationImportTransactionProp> vehicleLocationImportTransactionProp = new List <VehicleLocationImportTransactionProp>();

                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    VINDecodeList lstVINDecodeList = new VINDecodeList();

                    //If jst(lSessionHost,'U')='DAIDB'
                    // Sta: exec DataHub.dbo.DAIYMSP_GetStorageReceiptData
                    // Else If jst(lSessionHost,'U')='DAIDBVPC'
                    // Sta: exec DataHUBVPC.dbo.DAIYMSP_GetStorageReceiptData
                    // Else
                    // Sta: exec DataHubDev.dbo.DAIYMSP_GetStorageReceiptData
                    // End If

                    // Get current database name
                    string currentDatabaseName = objAppWorksEntities.Database.Connection.Database;

                    //if (currentDatabaseName.Equals("psdb", StringComparison.OrdinalIgnoreCase))
                    //{
                    query = SqlConstants.VEHICLE_LOCATION_IMPORT_TRANSACTION;
                    //}

                    var result = objAppWorksEntities.Database.SqlQuery <VehicleLocationImportTransactionProp>(query).ToList();



                    if (result != null && result.Count > 0)
                    {
                        PortStorageVehiclesImport portStorageVehiclesImport = new PortStorageVehiclesImport();

                        foreach (var item in result)
                        {
                            VehicleLocationImportTransactionProp obj = new VehicleLocationImportTransactionProp();
                            obj.VinNumberAndVinKey = item.VinNumberAndVinKey;
                            obj.Row                = item.Row;
                            obj.Bay                = item.Bay;
                            obj.DealerCode         = item.DealerCode;
                            obj.ColorCode          = item.ColorCode;
                            obj.DamageCode         = item.DamageCode;
                            obj.HandheldActionDate = item.HandheldActionDate;
                            obj.UserCode           = item.UserCode;
                            vehicleLocationImportTransactionProp.Add(obj);
                            obj = null;
                        }

                        if (vehicleLocationImportTransactionProp.Count > 0)
                        {
                            foreach (var val in vehicleLocationImportTransactionProp)
                            {
                                if (val.VinNumberAndVinKey.Length > 17)// check validation
                                {
                                    if ((val.VinNumberAndVinKey.Length == 18) && (val.VinNumberAndVinKey.Substring(0, 1).Equals("I")))
                                    {
                                        val.VinNumberAndVinKey = val.VinNumberAndVinKey.Remove(0, 1);
                                    }
                                    else
                                    {
                                        val.VinNumberAndVinKey = val.VinNumberAndVinKey.Substring(0, 17);
                                    }
                                }

                                lstVINDecodeList = GetDataByDecodeVIN(val.VinNumberAndVinKey);

                                if (lstVINDecodeList != null)
                                {
                                    portStorageVehiclesImport.VehicleYear   = lstVINDecodeList.VehicleYear;
                                    portStorageVehiclesImport.Make          = lstVINDecodeList.Make;
                                    portStorageVehiclesImport.Model         = lstVINDecodeList.Model;
                                    portStorageVehiclesImport.Bodystyle     = lstVINDecodeList.Bodystyle;
                                    portStorageVehiclesImport.VehicleLength = lstVINDecodeList.VehicleLength;
                                    portStorageVehiclesImport.VehicleWidth  = lstVINDecodeList.VehicleWidth;
                                    portStorageVehiclesImport.VehicleHeight = lstVINDecodeList.VehicleHeight;
                                }
                                else
                                {
                                    portStorageVehiclesImport.VehicleYear   = string.Empty;
                                    portStorageVehiclesImport.Make          = string.Empty;
                                    portStorageVehiclesImport.Model         = string.Empty;
                                    portStorageVehiclesImport.Bodystyle     = string.Empty;
                                    portStorageVehiclesImport.VehicleLength = string.Empty;
                                    portStorageVehiclesImport.VehicleWidth  = string.Empty;
                                    portStorageVehiclesImport.VehicleHeight = string.Empty;
                                }

                                portStorageVehiclesImport.VINDecodedInd = 0;
                                portStorageVehiclesImport.BatchID       = batchId;
                                portStorageVehiclesImport.DateIn        = val.HandheldActionDate.Value.ToString("MM/dd/yyyy");

                                portStorageVehiclesImport.DealerCode = val.DealerCode;
                                portStorageVehiclesImport.VIN        = val.VinNumberAndVinKey;

                                portStorageVehiclesImport.Color = val.ColorCode;
                                //portStorageVehiclesImport.DamageCodeList = val.DealerCode;
                                portStorageVehiclesImport.DamageCodeList = val.DamageCode;
                                portStorageVehiclesImport.Location       = (val.Row + " " + val.Bay).Trim();
                                portStorageVehiclesImport.ImportedInd    = 0;
                                portStorageVehiclesImport.CreationDate   = DateTime.Now;
                                portStorageVehiclesImport.CreatedBy      = user;

                                portStorageVehiclesImport.RecordStatus = "Import Pending";
                                objAppWorksEntities.PortStorageVehiclesImports.Add(portStorageVehiclesImport);  /// Insert the Record in Respected Table.
                                objAppWorksEntities.SaveChanges();
                                isSucceeded = true;
                            }
                        }
                    }
                    else
                    {
                        isSucceeded = true;
                    }
                }
            }
            catch (Exception ex)
            {
                var message = ex.Message;

                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }

            return(isSucceeded);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method is used to get data and insert data in database
        /// </summary>
        /// <param name="BatchId"></param>
        /// <param name="User"></param>
        /// <returns></returns>
        public bool LocationImportTransactionProcess(int BatchId, string User)
        {
            bool Result = true;

            try
            {
                List <VehicleLocationImportTransactionProp> vehicleLocationImportTransactionProp = new List <VehicleLocationImportTransactionProp>();
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    string CurruntDatabaseName = objAppWorksEntities.Database.Connection.Database; // Get currunt database name

                    var result = objAppWorksEntities.spGetDataStoragePhyDataImportLocation(CurruntDatabaseName).ToList();
                    if (result != null && result.Count > 0)
                    {
                        PortStorageVehicleLocationImport portStorageVehicleLocationImport = new PortStorageVehicleLocationImport();
                        foreach (var item in result)
                        {
                            VehicleLocationImportTransactionProp obj = new VehicleLocationImportTransactionProp();
                            obj.VinNumberAndVinKey = item.VINNumberAndVINKey;
                            obj.Row                = item.Row;
                            obj.Bay                = item.Bay;
                            obj.ByRowFlag          = item.ByRowFlg;
                            obj.HandheldActionDate = item.HandheldActionDate;
                            obj.UserCode           = item.UserCode;
                            vehicleLocationImportTransactionProp.Add(obj);
                            obj = null;
                        }
                        if (vehicleLocationImportTransactionProp.Count > 0)
                        {
                            foreach (var val in vehicleLocationImportTransactionProp)
                            {
                                //                            If len(iSqlRow.VIN)>17
                                //If (len(iSqlRow.VIN)=18)&(left(iSqlRow.VIN,1)='I')
                                //Calculate iSqlRow.VIN as right(iSqlRow.VIN,17)
                                //Else
                                //Calculate iSqlRow.VIN as left(iSqlRow.VIN,17)
                                if (val.VinNumberAndVinKey.Length > 17)
                                {
                                    if ((val.VinNumberAndVinKey.Length == 18) && (val.VinNumberAndVinKey.Substring(0, 1).Equals("I")))
                                    {
                                        val.VinNumberAndVinKey = val.VinNumberAndVinKey.Remove(0, 1);
                                    }
                                    else
                                    {
                                        val.VinNumberAndVinKey = val.VinNumberAndVinKey.Substring(0, 17);
                                    }
                                }

                                portStorageVehicleLocationImport.BatchID      = BatchId;
                                portStorageVehicleLocationImport.VIN          = val.VinNumberAndVinKey;
                                portStorageVehicleLocationImport.Location     = (val.Row + " " + val.Bay).Trim();
                                portStorageVehicleLocationImport.ImportedInd  = 0;
                                portStorageVehicleLocationImport.CreationDate = DateTime.Now;
                                portStorageVehicleLocationImport.CreatedBy    = User;
                                portStorageVehicleLocationImport.RecordStatus = "Import Pending";
                                objAppWorksEntities.PortStorageVehicleLocationImports.Add(portStorageVehicleLocationImport); /// Insert the Record in Respected Table.
                                objAppWorksEntities.SaveChanges();                                                           /// Check the Chenges in Table After Record Insertion.
                                Result = false;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
            return(Result);
        }