Esempio n. 1
0
        /// <summary>
        /// To Remove the Record of existing User
        /// </summary>
        /// <param name="AdminUserProp"></param>
        /// <returns>int</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-29,2016</createdOn>
        public int RemoveUserDetails(FindUserProp objFindUserProp)
        {
            int value = 0;

            try
            {
                int userID = Convert.ToInt32(objFindUserProp.UserID);
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    string userName = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID select tblUser.UserCode).FirstOrDefault();
                    string password = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID select tblUser.Password).FirstOrDefault();

                    if (userID != 0)
                    {
                        var  userRecord = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userID && tblUser.Password == password && tblUser.UserCode == userName select tblUser).FirstOrDefault();
                        User user       = objAppWorksEntities.Users.Where(U => U.UserID == userID).FirstOrDefault();
                        user.RecordStatus = objFindUserProp.RecordStatus;
                        objAppWorksEntities.Users.Remove(userRecord);
                        objAppWorksEntities.SaveChanges();
                        value = objAppWorksEntities.SaveChanges();
                    }
                }
            }
            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(value);
        }
Esempio n. 2
0
        /// <summary>
        /// For updating batch id of print request vehical list
        /// </summary>
        /// <param name="vehicleIds"></param>
        /// <returns></returns>
        public bool UpdateRequestPrintIndexForVehicles(List <string> vehicleIds)
        {
            bool isRequsetCompleted = false;

            CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                var previousPrintBatchSettings = psEntities.SettingTables.Where(x => x.ValueKey == "NextPSRequestPrintingBatchID").FirstOrDefault();
                int previousBatchId            = int.Parse(previousPrintBatchSettings.ValueDescription);
                previousPrintBatchSettings.ValueDescription = (previousBatchId + 1).ToString();
                psEntities.SaveChanges();

                foreach (var vehicleId in vehicleIds)
                {
                    int vehicleID = int.Parse(vehicleId);
                    var vehicle   = psEntities.PortStorageVehicles.Where(x => x.PortStorageVehiclesID == vehicleID).FirstOrDefault();
                    vehicle.RequestPrintedInd     = 1;
                    vehicle.RequestPrintedBatchID = (previousBatchId);
                    vehicle.DateRequestPrinted    = DateTime.Now;
                }
                psEntities.SaveChanges();
                isRequsetCompleted = true;
            }
            catch (Exception ex)
            {
                isRequsetCompleted = false;
                //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(isRequsetCompleted);
        }
Esempio n. 3
0
        /// <summary>
        /// function to get edit the Damage Code
        /// </summary>
        /// <param name="portStorageVehiclesId"></param>
        /// <returns>Int<returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-6,2016</createdOn>
        public int EditDamageCode(PortStorageDamageDetailsProp objPortStorageDamageDetailsProp)
        {
            int value = 0;

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    var tblPSVehicalDamageDetails = (from qry in objAppWorksEntities.PSVehicleDamageDetails where qry.PSVehicleDamageDetailID == objPortStorageDamageDetailsProp.PSVehicleDamageDetailID select qry).FirstOrDefault();
                    //Sta: UPDATE PSVehicleDamageDetail
                    //Sta: SET DamageCode = @[lNewDamageCode]
                    //Sta: WHERE PSVehicleDamageDetailID = @[iInspectionsAndDamageList.iVehicleDamageDetailID]
                    if (tblPSVehicalDamageDetails != null)
                    {
                        tblPSVehicalDamageDetails.DamageCode = objPortStorageDamageDetailsProp.DamageCode;
                        value = objAppWorksEntities.SaveChanges();
                    }
                }
            }
            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(value);
        }
Esempio n. 4
0
        /// <summary>
        /// Delete system settings
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public bool DeleteSystemSettings(AdminUserProp setting)
        {
            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                bool result = false;

                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    var settingData = objAppWorksEntities.SettingTables.Where(x => x.ValueKey == setting.ValueKey).FirstOrDefault();
                    objAppWorksEntities.SettingTables.Remove(settingData);
                    objAppWorksEntities.SaveChanges();
                    result = true;
                }
                return(result);
            }
            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));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// add system settings
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public bool InsertSystemSettings(AdminUserProp setting)
        {
            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                bool result = false;

                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    SettingTable newSetting = new SettingTable();
                    newSetting.ValueKey         = setting.ValueKey;
                    newSetting.ValueDescription = setting.ValueDescription;
                    objAppWorksEntities.SettingTables.Add(newSetting);
                    objAppWorksEntities.SaveChanges();
                    result = true;
                }
                return(result);
            }
            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));
            }
        }
Esempio n. 6
0
 /// <summary>
 /// To Remove the Record of existing User
 /// </summary>
 /// <param name="AdminUserProp"></param>
 /// <returns>void</returns>
 /// <createdBy></createdBy>
 /// <createdOn>Apr-28,2016</createdOn>
 public void RemoveUserDetails(AdminUserProp objAdminUserProp)
 {
     try
     {
         CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
         using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
         {
             int userId = (from T in objAppWorksEntities.Users where T.UserCode == objAdminUserProp.UserCode && (T.Password == objAdminUserProp.Password || T.PIN == objAdminUserProp.Password) select T.UserID).FirstOrDefault();
             if (userId != 0)
             {
                 var x = (from tblUser in objAppWorksEntities.Users where tblUser.UserID == userId && tblUser.Password == objAdminUserProp.Password select tblUser).FirstOrDefault();
                 objAppWorksEntities.Users.Remove(x);
                 objAppWorksEntities.SaveChanges();
             }
         }
     }
     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));
     }
 }
Esempio n. 7
0
        /// <summary>
        /// This method is used to update code details
        /// </summary>
        /// <param name="objCodeProp"></param>
        /// <returns></returns>
        /// <createdOn>May-24-2016</createdon>
        public bool UpdateCodeAdminDetails(CodeProp objCodeProp)
        {
            bool result = false;

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                using (PortStorageEntities psEntities = new PortStorageEntities())
                {
                    Code code = psEntities.Codes.Where(c => c.CodeID == objCodeProp.CodeID).FirstOrDefault();
                    code.Code1             = objCodeProp.Code1;
                    code.CodeType          = objCodeProp.CodeType;
                    code.RecordStatus      = objCodeProp.RecordStatus;
                    code.CodeDescription   = objCodeProp.CodeDescription;
                    code.Value1            = objCodeProp.Value1;
                    code.Value1Description = objCodeProp.Value1Description;
                    code.Value2            = objCodeProp.Value2;
                    code.Value2Description = objCodeProp.Value2Description;
                    code.SortOrder         = objCodeProp.SortOrder;
                    code.UpdatedDate       = objCodeProp.UpdatedDate;
                    code.UpdatedBy         = objCodeProp.UpdatedBy;
                    psEntities.SaveChanges();
                    result = true;
                    return(result);
                }
            }
            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));
            }
        }
        /// <summary>
        /// Update table for next batch id
        /// </summary>
        /// <param name="BatchId"></param>
        /// <returns></returns>
        public bool SetPortStorageVehiclesNextBatchId(int BatchId)
        {
            bool Result = false;

            try
            {
                // creating the object of PortStorageEntities Database
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    SettingTable settingTable = objAppWorksEntities.SettingTables.Where(v => v.ValueKey.Equals("NextPortStorageVehicleImportBatchID")).FirstOrDefault();
                    settingTable.ValueDescription = Convert.ToString(BatchId + 1);
                    objAppWorksEntities.SaveChanges();          /// Check the Chenges in Table After Record update.
                    Result = true;
                }
            }
            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);
        }
Esempio n. 9
0
        /// <summary>
        /// This method is used to delete code details from database
        /// </summary>
        /// <param name="CodeID"></param>
        /// <returns></returns>
        /// <createdOn>May-24-2016</createdon>
        public bool DeleteCodeAdminDetails(int CodeID)
        {
            bool result = false;

            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                using (PortStorageEntities psEntities = new PortStorageEntities())
                {
                    var CodeData = psEntities.Codes.Where(C => C.CodeID == CodeID).FirstOrDefault();
                    if (CodeData != null)
                    {
                        psEntities.Codes.Remove(CodeData);
                        psEntities.SaveChanges();
                        result = true;
                    }
                    return(result);
                }
            }
            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));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// To Add the Record of Code
        /// </summary>
        /// <param name="objCodeProp"></param>
        /// <returns>Int</returns>
        /// <createdBy></createdBy>
        /// <createdOn>May-21,2016</createdOn>
        public int AddCodeAdmin(CodeProp objCodeProp)
        {
            using (PortStorageEntities psEntities = new PortStorageEntities())
            {
                int codeID;
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                try
                {
                    Code objCode = new Code();
                    objCode.CodeType          = objCodeProp.CodeType;
                    objCode.Code1             = objCodeProp.Code1;
                    objCode.CodeDescription   = objCodeProp.CodeDescription;
                    objCode.Value1            = objCodeProp.Value1;
                    objCode.Value1Description = objCodeProp.Value1Description;
                    objCode.Value2            = objCodeProp.Value2;
                    objCode.Value2Description = objCodeProp.Value2Description;
                    objCode.RecordStatus      = objCodeProp.RecordStatus;
                    objCode.SortOrder         = objCodeProp.SortOrder;
                    objCode.CreationDate      = objCodeProp.CreationDate;
                    objCode.CreatedBy         = objCodeProp.CreatedBy;
                    objCode.UpdatedDate       = objCodeProp.UpdatedDate;
                    objCode.UpdatedBy         = objCodeProp.UpdatedBy;
                    objCode.CodeName          = objCodeProp.CodeName;
                    objCode.Description       = objCodeProp.Description;
                    objCode.DataType          = objCodeProp.DataType;
                    objCode.DataSubType       = objCodeProp.DataSubType;
                    objCode.DAIOnlyInd        = objCodeProp.DAIOnlyInd;


                    psEntities.Codes.Add(objCode);   /// Insert the Record in BillingPeriod Table.
                    psEntities.SaveChanges();        /// Check the Chenges in Table After Record Insertion.
                    codeID = objCode.CodeID;         /// Return the BillingPeriodID of Inserted Billing Period.
                }
                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(codeID);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// For updating compnay information
        /// </summary>
        /// <param name="userCode"></param>
        /// <returns></returns>
        public bool UpdateCompanyInfo(UserApplicationConstantsProp objCompanyinfo)
        {
            try
            {
                using (PortStorageEntities psEntities = new PortStorageEntities())
                {
                    CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                    bool isSuccessfull = false;
                    // ApplicationConstant customer = psEntities.ApplicationConstants.Where(x => x.usercode == objcustomer.CustomerID).FirstOrDefault();
                    ApplicationConstant companyinfo = psEntities.ApplicationConstants.FirstOrDefault();
                    if (companyinfo != null)
                    {
                        companyinfo.CompanyName     = objCompanyinfo.CompanyName;
                        companyinfo.AddressLine1    = objCompanyinfo.AddressLine1;
                        companyinfo.AddressLine2    = objCompanyinfo.AddressLine2;
                        companyinfo.City            = objCompanyinfo.CitySep;
                        companyinfo.Phone           = objCompanyinfo.Phone;
                        companyinfo.State           = objCompanyinfo.State;
                        companyinfo.Zip             = objCompanyinfo.Zip;
                        companyinfo.FaxNumber       = objCompanyinfo.FaxNumber;
                        companyinfo.SystemName      = objCompanyinfo.SystemName;
                        companyinfo.NextOrderNumber = objCompanyinfo.NextOrderNumber;
                        companyinfo.UpdatedDate     = objCompanyinfo.UpdatedDate;
                        companyinfo.UpdatedBy       = objCompanyinfo.UpdatedBy;
                        psEntities.SaveChanges();
                        isSuccessfull = true;
                    }
                    return(isSuccessfull);
                }
            }
            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));
            }
        }
Esempio n. 12
0
        public void LogErrorToDb(ErrorLogProp errorProp)
        {
            try
            {
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                    objAppWorksEntities.ErrorLogs.Add(new ErrorLog {
                        SystemMac = errorProp.SystemMac, DateTime = DateTime.Now, Message = errorProp.Message, Level = "ERROR", Logger = errorProp.Logger, Thread = errorProp.Thread, BuildVersion = errorProp.BuildVersion
                    });
                    objAppWorksEntities.SaveChanges();
                }
            }
            catch (Exception e)
            {
                CommonDAL.logger.LogError(typeof(string), e);
            }
            finally
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "End {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Esempio n. 13
0
        /// <summary>
        /// To Add the New Role of User
        /// </summary>
        /// <param name="objAdminUserProp"></param>
        /// <returns>List</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-23,2016</createdOn>
        public List <string> NewRoleList(AdminUserProp objAdminUserProp)
        {
            List <string> objlstNewRole = new List <string>();

            CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    int userId = (from T in objAppWorksEntities.Users where T.UserCode == objAdminUserProp.UserCode && (T.Password == objAdminUserProp.Password || T.PIN == objAdminUserProp.Password) select T.UserID).FirstOrDefault();
                    if (userId != 0)
                    {
                        /// Insert the Default Role in UserRole Table
                        UserRole objTblUserRole = new UserRole();
                        objTblUserRole.RoleName     = objAdminUserProp.newRole;
                        objTblUserRole.UserID       = userId;
                        objTblUserRole.CreationDate = objAdminUserProp.CreationDate;
                        objTblUserRole.CreatedBy    = objAdminUserProp.CreatedBy;
                        objTblUserRole.UpdatedDate  = objAdminUserProp.UpdatedDate;
                        objTblUserRole.UpdatedBy    = objAdminUserProp.UpdatedBy;
                        objAppWorksEntities.UserRoles.Add(objTblUserRole);
                        objAppWorksEntities.SaveChanges();

                        objlstNewRole = (from tblList in objAppWorksEntities.UserRoles where tblList.UserID == userId select tblList.RoleName).ToList();
                    }
                }
            }
            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(objlstNewRole);
        }
Esempio n. 14
0
        /// <summary>
        ///  This Method is to update request checked vehicles
        /// </summary>
        /// <param name="locationID"></param>
        /// <returns></returns>
        public bool UpdateVehiclesStatus(PortStorageVehicleProp portStorageVehicle, string userName)
        {
            using (var transaction = new TransactionScope())
            {
                try
                {
                    CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                    bool result = false;

                    using (PortStorageEntities portalEntities = new PortStorageEntities())
                    {
                        var portStorageVehicleData = portalEntities.PortStorageVehicles.Where(x => x.PortStorageVehiclesID == portStorageVehicle.PortStorageVehiclesID).FirstOrDefault();
                        if (portStorageVehicleData != null)
                        {
                            portStorageVehicleData.VehicleStatus = "Requested";
                            portStorageVehicleData.DateRequested = DateTime.Now;
                            portStorageVehicleData.RequestedBy   = userName;
                            portalEntities.SaveChanges();
                        }
                        result = true;
                        transaction.Complete();
                        return(result);
                    }
                }
                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));
                }
            }
        }
        /// <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);
        }
Esempio n. 16
0
        /// <summary>
        /// To Update the Modified Record of existing User
        /// </summary>
        /// <param name="AdminUserProp"></param>
        /// <returns>void</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-28,2016</createdOn>
        public void UpdateUserDetails(AdminUserProp objAdminUserProp, List <RoleList> lstRoles)
        {
            try
            {
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
                {
                    var objTblUsers = (from qry in objAppWorksEntities.Users where qry.UserCode == objAdminUserProp.UserCode select qry).FirstOrDefault();//objAppWorksEntities.Users.Find(objAdminUserProp.UserCode);

                    if (objTblUsers != null)
                    {
                        objTblUsers.UserCode       = objAdminUserProp.UserCode;
                        objTblUsers.FirstName      = objAdminUserProp.FirstName;
                        objTblUsers.LastName       = objAdminUserProp.LastName;
                        objTblUsers.Password       = objAdminUserProp.Password;
                        objTblUsers.PIN            = objAdminUserProp.PIN;
                        objTblUsers.Phone          = objAdminUserProp.Phone;
                        objTblUsers.PhoneExtension = objAdminUserProp.PhoneExtension;
                        objTblUsers.CellPhone      = objAdminUserProp.CellPhone;
                        objTblUsers.EmailAddress   = objAdminUserProp.EmailAddress;
                        objTblUsers.FaxNumber      = objAdminUserProp.FaxNumber;
                        objTblUsers.LabelXOffset   = Convert.ToDecimal(objAdminUserProp.LabelXOffset);
                        objTblUsers.LabelYOffset   = Convert.ToDecimal(objAdminUserProp.LabelYOffset);
                        objTblUsers.IMEI           = objAdminUserProp.IMEI;
                        objTblUsers.LastConnection = objAdminUserProp.LastConnection;
                        if (objAdminUserProp.datsVersion != "")
                        {
                            objTblUsers.datsVersion = Convert.ToInt16(objAdminUserProp.datsVersion);
                        }
                        objTblUsers.RecordStatus     = objAdminUserProp.RecordStatus;
                        objTblUsers.CreationDate     = objAdminUserProp.CreationDate;
                        objTblUsers.CreatedBy        = objAdminUserProp.CreatedBy;
                        objTblUsers.UpdatedDate      = objAdminUserProp.UpdatedDate;
                        objTblUsers.UpdatedBy        = objAdminUserProp.UpdatedBy;
                        objTblUsers.EmployeeNumber   = objAdminUserProp.EmployeeNumber;
                        objTblUsers.PortPassIDNumber = objAdminUserProp.PortPassIDNumber;
                        objTblUsers.Department       = objAdminUserProp.Department;
                        if (objAdminUserProp.StraightTimeRate != "")
                        {
                            objTblUsers.StraightTimeRate = Convert.ToDecimal(objAdminUserProp.StraightTimeRate);
                        }
                        if (objAdminUserProp.PieceRateRate != "")
                        {
                            objTblUsers.PieceRateRate = Convert.ToDecimal(objAdminUserProp.PieceRateRate);
                        }
                        if (objAdminUserProp.PDIRate != "")
                        {
                            objTblUsers.PDIRate = Convert.ToDecimal(objAdminUserProp.PDIRate);
                        }
                        if (objAdminUserProp.FlatBenefitPayRate != "")
                        {
                            objTblUsers.FlatBenefitPayRate = Convert.ToDecimal(objAdminUserProp.FlatBenefitPayRate);
                        }
                        objTblUsers.AlternateEmailAddress = objAdminUserProp.AlternateEmailAddress;
                        objAppWorksEntities.SaveChanges();

                        if (lstRoles.Count > 0)
                        {
                            var lstUserRoles = (from roles in objAppWorksEntities.UserRoles
                                                where roles.UserID == objAdminUserProp.UserID
                                                select roles);
                            if (lstUserRoles.Count() > 0)
                            {
                                foreach (UserRole urole in lstUserRoles.ToList())
                                {
                                    objAppWorksEntities.UserRoles.Remove(urole);
                                    objAppWorksEntities.SaveChanges();
                                }
                            }

                            foreach (RoleList role in lstRoles)
                            {
                                if ((bool)role.IsSelected)
                                {
                                    UserRole userrole = new UserRole();
                                    userrole.UserID       = objAdminUserProp.UserID;
                                    userrole.RoleName     = role.RoleName;
                                    userrole.CreationDate = DateTime.Now;
                                    userrole.CreatedBy    = objTblUsers.CreatedBy;
                                    objAppWorksEntities.UserRoles.Add(userrole);
                                    objAppWorksEntities.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            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));
            }
        }
Esempio n. 17
0
        /// <summary>
        /// To Add the Record of existing User
        /// </summary>
        /// <param name="objAdminUserProp"></param>
        /// <returns>Int</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-19,2016</createdOn>
        public int AddAdminUser(AdminUserProp objAdminUserProp, List <RoleList> lstRoles)
        {
            using (PortStorageEntities objAppWorksEntities = new PortStorageEntities())
            {
                int getUserId;
                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                try
                {
                    User objTblUsers = new User();
                    objTblUsers.UserCode       = objAdminUserProp.UserCode;
                    objTblUsers.FirstName      = objAdminUserProp.FirstName;
                    objTblUsers.LastName       = objAdminUserProp.LastName;
                    objTblUsers.Password       = objAdminUserProp.Password;
                    objTblUsers.PIN            = objAdminUserProp.PIN;
                    objTblUsers.Phone          = objAdminUserProp.Phone;
                    objTblUsers.PhoneExtension = objAdminUserProp.PhoneExtension;
                    objTblUsers.CellPhone      = objAdminUserProp.CellPhone;
                    objTblUsers.EmailAddress   = objAdminUserProp.EmailAddress;
                    objTblUsers.FaxNumber      = objAdminUserProp.FaxNumber;
                    objTblUsers.LabelXOffset   = Convert.ToDecimal(objAdminUserProp.LabelXOffset);
                    objTblUsers.LabelYOffset   = Convert.ToDecimal(objAdminUserProp.LabelYOffset);
                    objTblUsers.IMEI           = objAdminUserProp.IMEI;
                    objTblUsers.LastConnection = objAdminUserProp.LastConnection;
                    if (!string.IsNullOrEmpty(objAdminUserProp.datsVersion))
                    {
                        objTblUsers.datsVersion = Convert.ToInt16(objAdminUserProp.datsVersion);
                    }
                    objTblUsers.RecordStatus     = objAdminUserProp.RecordStatus;
                    objTblUsers.CreationDate     = objAdminUserProp.CreationDate;
                    objTblUsers.CreatedBy        = objAdminUserProp.CreatedBy;
                    objTblUsers.UpdatedDate      = objAdminUserProp.UpdatedDate;
                    objTblUsers.UpdatedBy        = objAdminUserProp.UpdatedBy;
                    objTblUsers.EmployeeNumber   = objAdminUserProp.EmployeeNumber;
                    objTblUsers.PortPassIDNumber = objAdminUserProp.PortPassIDNumber;
                    objTblUsers.Department       = objAdminUserProp.Department;
                    if (!string.IsNullOrEmpty(objAdminUserProp.StraightTimeRate))
                    {
                        objTblUsers.StraightTimeRate = Convert.ToDecimal(objAdminUserProp.StraightTimeRate);
                    }
                    if (!string.IsNullOrEmpty(objAdminUserProp.PieceRateRate))
                    {
                        objTblUsers.PieceRateRate = Convert.ToDecimal(objAdminUserProp.PieceRateRate);
                    }
                    if (!string.IsNullOrEmpty(objAdminUserProp.PDIRate))
                    {
                        objTblUsers.PDIRate = Convert.ToDecimal(objAdminUserProp.PDIRate);
                    }
                    if (!string.IsNullOrEmpty(objAdminUserProp.FlatBenefitPayRate))
                    {
                        objTblUsers.FlatBenefitPayRate = Convert.ToDecimal(objAdminUserProp.FlatBenefitPayRate);
                    }
                    objTblUsers.AlternateEmailAddress = objAdminUserProp.AlternateEmailAddress;
                    objAppWorksEntities.Users.Add(objTblUsers); /// Insert the Record in Respected Table.
                    objAppWorksEntities.SaveChanges();          /// Check the Chenges in Table After Record Insertion.
                    getUserId = objTblUsers.UserID;             /// Return the UserId of Inserted User.
                    /// Insert the Default Role in UserRole Table
                    //UserRole objTblUserRole = new UserRole();
                    //objTblUserRole.RoleName = "Default Role";
                    //objTblUserRole.UserID = getUserId;
                    //objTblUserRole.CreationDate = objAdminUserProp.CreationDate;
                    //objTblUserRole.CreatedBy = objAdminUserProp.CreatedBy;
                    //objTblUserRole.UpdatedDate = objAdminUserProp.UpdatedDate;
                    //objTblUserRole.UpdatedBy = objAdminUserProp.UpdatedBy;
                    //objAppWorksEntities.UserRoles.Add(objTblUserRole);
                    //objAppWorksEntities.SaveChanges();

                    if (lstRoles.Count > 0 && getUserId > 0)
                    {
                        foreach (RoleList role in lstRoles)
                        {
                            if ((bool)role.IsSelected)
                            {
                                UserRole userrole = new UserRole();
                                userrole.UserID       = getUserId;
                                userrole.RoleName     = role.RoleName;
                                userrole.CreationDate = DateTime.Now;
                                userrole.CreatedBy    = objTblUsers.CreatedBy;
                                objAppWorksEntities.UserRoles.Add(userrole);
                                objAppWorksEntities.SaveChanges();
                            }
                        }
                    }
                }
                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(getUserId);
            }
        }
        /// <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);
        }
Esempio n. 19
0
        /// <summary>
        /// This method is used to get port storage request report from database
        /// </summary>
        /// <param name="ReportType"></param>
        /// <param name="CustomerId"></param>
        /// <param name="VIN"></param>
        /// <param name="RequestDateFrom"></param>
        /// <param name="RequestDateTo"></param>
        /// <param name="BatchId"></param>
        /// <returns></returns>
        public IList <PortStorageRequestsReportProp> GetPortStorageRequestReport(int ReportType, int CustomerId, string VIN, Nullable <DateTime> RequestDateFrom, Nullable <DateTime> RequestDateTo, int BatchId)
        {
            // creating the object of PortStorageEntities Database
            using (PortStorageEntities psEntities = new PortStorageEntities())
            {
                List <PortStorageRequestsReportProp> listPortStorageRequestsReportProp = new List <PortStorageRequestsReportProp>();

                CommonDAL.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                try
                {
                    var result = psEntities.spGetPortStorageRequestReportDetails(ReportType, CustomerId, VIN, RequestDateFrom, RequestDateTo, BatchId).ToList();

                    int previousBatchId = BatchId;
                    if (previousBatchId == 0 && result.Count > 0)
                    {
                        var previousPrintBatchSettings = psEntities.SettingTables.Where(x => x.ValueKey == "NextPSRequestPrintingBatchID").FirstOrDefault();
                        previousBatchId = int.Parse(previousPrintBatchSettings.ValueDescription);
                        previousPrintBatchSettings.ValueDescription = (previousBatchId + 1).ToString();
                        psEntities.SaveChanges();
                    }

                    if (result != null)
                    {
                        foreach (var val in result)
                        {
                            PortStorageRequestsReportProp obj = new PortStorageRequestsReportProp();
                            obj.PortStorageVehiclesID = val.PortStorageVehiclesID;
                            obj.VIN                 = val.VIN;
                            obj.ShortVIN            = "*" + val.ShortVIN + "*";
                            obj.DateRequested       = val.DateRequested;
                            obj.VehicleYear         = val.VehicleYear;
                            obj.Make                = val.Make;
                            obj.Model               = val.Model;
                            obj.Color               = val.Color;
                            obj.CustomerName        = val.CustomerName;
                            obj.AdddressLine1       = val.AddressLine1;
                            obj.AddressLine2        = val.AddressLine2;
                            obj.City                = val.City;
                            obj.State               = val.State;
                            obj.Zip                 = val.Zip;
                            obj.BayLocation         = val.BayLocation;
                            obj.DateOut             = val.DateOut;
                            obj.EstimatedPickupDate = val.EstimatedPickupDate;
                            obj.DealerPrintDate     = val.DealerPrintDate;
                            listPortStorageRequestsReportProp.Add(obj);
                            obj = null;

                            //update vehicle
                            var vehicle = psEntities.PortStorageVehicles.Where(x => x.PortStorageVehiclesID == val.PortStorageVehiclesID).FirstOrDefault();
                            vehicle.RequestPrintedInd     = 1;
                            vehicle.RequestPrintedBatchID = (previousBatchId);
                            vehicle.DateRequestPrinted    = DateTime.Now;
                            psEntities.SaveChanges();
                        }
                    }
                }
                catch (Exception ex)
                {
                    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(listPortStorageRequestsReportProp);
            }
        }