/// <summary> /// /// </summary> /// <param name="UserName"></param> /// <param name="vehicleID"></param> /// <param name="password"></param> /// <param name="companyID"></param> /// <param name="deviceToken"></param> /// <param name="deviceTime"></param> /// <param name="VersionNo"></param> /// <param name="UserType"></param> /// <param name="DeviceID"></param> /// <param name="GMT"></param> /// <returns></returns> protected String ServerCurrentVersion(String UserName, String vehicleID, String password, String companyID, String deviceToken, DateTime deviceTime, String VersionNo, String UserType, String DeviceID, DateTime GMT) { String CurrentVersion = VersionNo; ISession session = null; session = GetSession(); try { CurrentVersion = DALMethods.GetVersionNo(VersionNo, session); } catch (Exception ex) { if (session != null) { CloseSession(session); } // 2013.06.24 FSWW, Ramesh M Added For CR#58976 To Add More Details about calling function in Error log file. Logging.LogError(ex, "CustomerID-" + companyID + ", UserName-" + UserName + "vehicleID-" + vehicleID + "UserType-" + UserType + "\n"); } finally { if (session != null) { CloseSession(session); } } return(CurrentVersion); }
/// <summary> /// UpdateLoadStatus /// Function to update the load status /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="loadNo">Load number</param> /// <param name="loadStatus">Load Status</param> /// <param name="VersionNo">VersionNo</param> public void UpdateLoadStatus(string companyID, string password, string loadNo, string loadStatus, String VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateLoadStatus(session, loadNo, loadStatus, companyID, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } Logging.WriteLog("LoadNo: " + loadNo, System.Diagnostics.EventLogEntryType.Error); Logging.LogError(ex); throw ex; } }
/// <summary> /// UpdateLoad /// Function to update the load records /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="loadNo">Load number</param> /// <param name="vehicleID">Vehicle ID</param> /// <param name="driverID">Driver ID</param> /// <param name="VersionNo">VersionNo</param> public void UpdateLoad(string companyID, string password, string loadNo, int vehicleID, int driverID, String VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateLoad(session, loadNo, vehicleID, driverID, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } Logging.LogError(ex); throw ex; } }
/// <summary> /// Save Button - Edit Modal - Event Handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEditSave_Click(object sender, EventArgs e) { Page.Validate("valgrpEditPerson"); if (Page.IsValid == true) { int nPersonId = 0; if (string.IsNullOrEmpty(txtHiddenPersonID.Text) == false) { nPersonId = Convert.ToInt32(txtHiddenPersonID.Text); } string strFirstName = Convert.ToString(txtEditFirstName.Text.Trim()); string strLastName = Convert.ToString(txtEditLastName.Text.Trim()); int nStateId = Convert.ToInt32(ddlEditState.SelectedItem.Value.Trim()); char cGender = Convert.ToChar(rblEditGender.SelectedItem.Value.Trim()); DateTime dtDob = Convert.ToDateTime(DateTime.Parse(txtEditDOB.Text.Trim()).Date); DALMethods dalMethods = new DALMethods(); if (dalMethods.SavePerson(nPersonId, strFirstName, strLastName, nStateId, cGender, dtDob) == -1) { LoadPersonGridView(strFirstName, strLastName, nStateId, cGender, dtDob); } ResetUpdatePersonFields(); } }
/// <summary> /// Function to Update the BOLImage /// </summary> /// <param name="companyID">companyID</param> /// <param name="password">password</param> /// <param name="BOLImage">BOLImage</param> /// <param name="sysTrxNo">sysTrxNo</param> public void UpdateBOLImage(string companyID, string password, byte[] bolimage, byte[] bolimagePdf, int SystrxNo, string Bolno, String VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateBOLImage(session, bolimage, bolimagePdf, SystrxNo, Bolno, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } Logging.LogError(ex); throw ex; } }
/// <summary> /// UpdateBOLWaitTimeDetails /// Function to update the BOLWaitTime details /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="VersionNo">VersionNo</param> public void UpdateBOLWaitTimeDetails(string companyID, string password, string ClientID, decimal SysTrxNo, string BOLNo, DateTime BOLWaitTimeStart, DateTime BOLWaitTimeEnd, string BOLWaitTimeComment, String VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateBOLWaitTimeDetails(session, ClientID, SysTrxNo, BOLNo, BOLWaitTimeStart, BOLWaitTimeEnd, BOLWaitTimeComment, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); session = GetSession(); } throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } Logging.LogError(ex); throw ex; } }
/// <summary> /// Method to load the Person Search Results gridview /// </summary> protected void LoadPersonGridView() { string strFirstName = Convert.ToString(txtFirstName.Text.Trim()); string strLastName = Convert.ToString(txtLastName.Text.Trim()); int?nStateId = null; if (Convert.ToInt32(ddlState.SelectedItem.Value) != -1) { nStateId = Convert.ToInt32(ddlState.SelectedItem.Value); } char?cGender = null; if (rblGender.SelectedIndex != -1) { cGender = Convert.ToChar(rblGender.SelectedItem.Value); } DateTime?dtDob = null; if (!(String.IsNullOrEmpty(txtDOB.Text))) { dtDob = Convert.ToDateTime(DateTime.Parse(txtDOB.Text.Trim()).Date); } List <DTOPerson> lstPerson = new List <DTOPerson>(); DALMethods dalMethods = new DALMethods(); lstPerson = dalMethods.GetPersonDetails(strFirstName, strLastName, nStateId, cGender, dtDob); GridViewPerson.DataSource = lstPerson; GridViewPerson.DataBind(); lblSearchResults.Visible = true; }
/// <summary> /// Function to Update the Undo ShipDoc /// </summary> /// <param name="companyID">companyID</param> /// <param name="password">password</param> /// <param name="sysTrxNo">SystrxNo</param> /// <param name="inStatus">inStatus</param> public void UndoShipDoc(string companyID, string password, int SystrxNo, char inStatus, String VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateUndoShipDoc(session, SystrxNo, inStatus, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } Logging.LogError(ex); throw ex; } }
/// <summary> /// UpdateFreightBreakdown /// Function to update the FreightBreakdown details /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="VersionNo">VersionNo</param> public void UpdateFreightBreakdown(string companyID, string password, Int32 SysTrxNo, Int32 FrtBrkdownline, char LegType, String OriginCity, String DestinationCity, String OriginState, String DestinationState, decimal CalcMiles, decimal ActualMiles, decimal OriginLat, decimal OriginLong, decimal DestLat, decimal DestLong, String VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateFreightBreakdown(session, companyID, SysTrxNo, FrtBrkdownline, LegType, OriginCity, DestinationCity, OriginState, DestinationState, CalcMiles, ActualMiles, OriginLat, OriginLong, DestLat, DestLong, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } Logging.LogError(ex); throw ex; } }
/// <summary> /// Method to load the Person Search Results gridview /// </summary> /// <param name="strFirstName"></param> /// <param name="strLastName"></param> /// <param name="nStateId"></param> /// <param name="Gender"></param> /// <param name="dtDOB"></param> protected void LoadPersonGridView(string strFirstName, string strLastName, int nStateId, char Gender, DateTime dtDOB) { List <DTOPerson> lstPerson = new List <DTOPerson>(); DALMethods dalMethods = new DALMethods(); lstPerson = dalMethods.GetPersonDetails(strFirstName, strLastName, nStateId, Gender, dtDOB); GridViewPerson.DataSource = lstPerson; GridViewPerson.DataBind(); lblSearchResults.Visible = true; }
/// <summary> /// Method to load the State dropdown /// </summary> /// <param name="ddl"></param> public void LoadStates(DropDownList ddl) { List <DTOStates> lstStates = new List <DTOStates>(); DALMethods dalMethods = new DALMethods(); lstStates = dalMethods.GetStates(); ddl.DataSource = lstStates; ddl.DataBind(); }
public void UpdateRejectedLoads(string loadNumber, string rejectedNote, string customerId) { ISession session = null; try { session = GetSession(); DALMethods.InsertRejectedLoad(session, loadNumber, rejectedNote, customerId); } catch (Exception ex) { Logging.WriteLog(string.Format("UpdateRejectedLoads - Error - {0}", ex.Message), EventLogEntryType.Error); } }
/// <summary> /// UpdateShipment /// Function to update the shipment details /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="shipmentReq">ShipmentRequest object</param> /// <returns>ShipmentResponse object</returns> /// <param name="VersionNo">VersionNo</param> public ShipmentResponse UpdateShipment(string companyID, string password, ShipmentRequest shipmentReq, String VersionNo = "") { ShipmentResponse shipmentResponse = null; ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); shipmentResponse = DALMethods.UpdateShipment(session, shipmentReq, VersionNo); DALMethods.ClearShipmentErrors(shipmentReq.SysTrxNo, shipmentReq.SysTrxLine, session, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); session = GetSession(); } //Logging.WriteToFile1("Dinesh 3- "); //Logging.WriteToFile1("Dinesh 4- "); DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } //session = GetSession(); //DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); Logging.LogError(ex); //Logging.WriteToFile1("Dinesh 4- "); //shipmentResponse = new ShipmentResponse(); //shipmentResponse.ErrorMessage = ex.Message + " - " + ex.StackTrace; //Logging.WriteToFile1("Dinesh 5- "); //return shipmentResponse; throw ex; } return(shipmentResponse); }
public void UpdateDeliveryNotes(string sysTrsNo, string deliveryNote) { ISession session = null; int isUpdated = 0; try { session = GetSession(); isUpdated = DALMethods.UpdateDeliveryNotes(session, sysTrsNo, deliveryNote); Logging.WriteToFile1(string.Format("Delivery notes update for sysTrsNo = {0}", sysTrsNo)); } catch (Exception ex) { Logging.WriteLog(string.Format("UpdateDeliveryNotes - Error - {0}", ex.Message), EventLogEntryType.Error); } }
/// <summary> /// UpdateDeliveryDetails /// Function to update the delivery details /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="deliveryReq">DeliveryRequest object</param> public Boolean UpdateDeliveryDetails(string companyID, string password, DeliveryRequest deliveryReq, String VersionNo = "") { ISession session = null; Boolean UpdDlvryDtls = false; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.UpdateDeliveryDetails(session, deliveryReq, VersionNo); DALMethods.ClearDeliveryErrors(deliveryReq.SysTrxNo, session, VersionNo); session.CommitTransaction(); CloseSession(session); UpdDlvryDtls = true; } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } session = GetSession(); DALMethods.UpdateDeliveryErrors(deliveryReq, true, ex.StackTrace, ex.Message, session, VersionNo); //throw ex; UpdDlvryDtls = false; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); session = GetSession(); } DALMethods.UpdateDeliveryErrors(deliveryReq, true, ex.StackTrace, ex.Message, session, VersionNo); Logging.LogError(ex); //throw ex; UpdDlvryDtls = false; } return(UpdDlvryDtls); }
/// <summary> /// UpdateShipment /// Function to update the shipment details /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="shipmentReq">ShipmentRequest object</param> /// <returns>ShipmentResponse object</returns> /// <param name="VersionNo">VersionNo</param> public String UpdateWagonShipment(string companyID, string password, TWBOLDetails shipmentReq, String VersionNo = "") { //ShipmentResponse shipmentResponse = null; string WagonShipment; ISession session = null; try { ValidateCustomerLogin(companyID, password, VersionNo); session = GetSession(); session.BeginTransaction(); WagonShipment = DALMethods.UpdateWagonShipment(session, shipmentReq, VersionNo); // DALMethods.ClearShipmentErrors(shipmentReq.SysTrxNo, shipmentReq.SysTrxLine, session, VersionNo); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); session = GetSession(); } // DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } session = GetSession(); //DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); Logging.LogError(ex); throw ex; } return(WagonShipment); }
private DbCommand PrepareDbCommand(ref int daysResend, GetLastResult _lastExportDate) { // 3. Get all records from a day before 'last export date' to now with SQL in pages of 20 records each if (_lastExportDate.Status == System.Net.HttpStatusCode.OK) { // searchFrom = searchFrom.AddDays(-1); var result = Math.Ceiling(DateTime.Now.Subtract(_lastExportDate.DateLastVenta).TotalDays); if (_config.DaysToResend < result) { daysResend = int.Parse(Math.Ceiling(result).ToString()); Debug.WriteLine($"Getting from {daysResend} days ago: {DateTime.Now.AddDays(daysResend * -1).ToString("yyyy-MM-dd")}."); } else { Debug.WriteLine($"Getting from {_config.DaysToResend} days ago: {DateTime.Now.AddDays(_config.DaysToResend * -1).ToString("yyyy-MM-dd")}."); } } else if (_lastExportDate.Status == System.Net.HttpStatusCode.NotFound) { // no hay registros, configurar para que envie todo (5 años) var dOld = DateTime.Now.AddYears(-5); var result = DateTime.Now.Subtract(dOld); Debug.WriteLine($"Getting all currrent records from {dOld.ToString("yyyy-MM-dd")}"); daysResend = int.Parse(Math.Ceiling(result.TotalDays).ToString()); } DALMethods dal = new DALMethods(_config); dal.ConnectionOpen(out DbConnection connection); var command = connection.CreateCommand(); command.CommandType = System.Data.CommandType.Text; command.CommandText = dal._parametrizedSelectVentas; SqlParameter days = new SqlParameter { ParameterName = "@daysToRepeat", Value = daysResend * -1 }; command.Parameters.Add(days); return(command); }
private DbCommand SetCommand(int daysResend) { DALMethods dal = new DALMethods(Config); dal.ConnectionOpen(out DbConnection connection); var command = connection.CreateCommand(); command.CommandType = System.Data.CommandType.Text; command.CommandText = dal._parametrizedSelectVentas; SqlParameter days = new SqlParameter { ParameterName = "@daysToRepeat", Value = daysResend * -1 }; command.Parameters.Add(days); return(command); }
/// <summary> /// Save Button - Add Modal - Event Handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAddSave_Click(object sender, EventArgs e) { Page.Validate("valgrpAddPerson"); if (Page.IsValid == true) { int nPersonId = 0; string strFirstName = Convert.ToString(txtAddFirstName.Text.Trim()); string strLastName = Convert.ToString(txtAddLastName.Text.Trim()); int nStateId = Convert.ToInt32(ddlAddState.SelectedItem.Value.Trim()); char cGender = Convert.ToChar(rblAddGender.SelectedItem.Value.Trim()); DateTime dtDob = Convert.ToDateTime(DateTime.Parse(txtAddDOB.Text.Trim()).Date); DALMethods dalMethods = new DALMethods(); if (dalMethods.SavePerson(nPersonId, strFirstName, strLastName, nStateId, cGender, dtDob) == -1) { LoadPersonGridView(strFirstName, strLastName, nStateId, cGender, dtDob); } ResetAddPersonModalFields(); } }
/// <summary> /// EODInventoryProcess /// Function to Process the Inventory EOD /// </summary> /// <param name="companyID">Company ID</param> /// <param name="password">Password</param> /// <param name="shipmentReq">ShipmentRequest object</param> /// <returns>ShipmentResponse object</returns> /// <param name="VersionNo">VersionNo</param> public bool EODInventoryProcess(int inClientID, string password, string inToSite, string inSupplierCode, string inSupplyPtCode, string inProductCode, decimal inOrgQty, decimal inAvailableQty, decimal inNetQty, int inOrderSysTrxNo, int inOrderSysTrxLineNo, int invehicleID, int inDriverID, string inUserID, string inBOLNo, DateTime inBOLDtTm, string inBOLSessionID, string inOverShort, string VersionNo = "") { ISession session = null; try { ValidateCustomerLogin(inClientID.ToString(), password, VersionNo); session = GetSession(); session.BeginTransaction(); DALMethods.InsertEODInventoryProcess(session, inToSite, inSupplierCode, inSupplyPtCode, inProductCode, inOrgQty, inAvailableQty, inNetQty, inOrderSysTrxNo, inOrderSysTrxLineNo, invehicleID, inDriverID, inUserID, inBOLNo, inBOLDtTm, inBOLSessionID, inOverShort, inClientID); session.CommitTransaction(); CloseSession(session); } catch (ApplicationException ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); session = GetSession(); } // DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); throw ex; } catch (Exception ex) { if (session != null) { session.RollbackTransaction(); CloseSession(session); } session = GetSession(); //DALMethods.UpdateShipmentErrors(shipmentReq, true, ex.StackTrace, ex.Message, session, VersionNo); Logging.LogError(ex); throw ex; } return(true); }
/// <summary> /// Modify the GPS history table to add STATE column. /// Do reverse geo-coding to get State and update the column in GPS history. /// </summary> public static void UpdateGPSHistoryState() { VersionNo = Assembly.GetEntryAssembly().GetName().Version.ToString().Replace(".0", ""); ISession session = null; try { session = GetNewSession(); // 2014.01.03 FSWW, Ramesh M Added For CR#61563 DALMethods.UpdateStateCodeInSQL(session, VersionNo); // 2014.01.03 FSWW, Ramesh M Commented For CR#61563 #region StateCodeUpdation Using Google API //XmlDocument doc = new XmlDocument(); //string latitude = string.Empty; //string longitude = string.Empty; //// 2013.12.09 FSWW, Ramesh M Added For CR#60647 //string sVehicleID = string.Empty; //string sCompanyID = string.Empty; //string sSessionID = string.Empty; //List<DAL.GPSHistoryRow> lstGPSHistory = DALMethods.GPSHistoryData(session); //foreach (DAL.GPSHistoryRow GPSHistory in lstGPSHistory) //{ // // 2013.12.09 FSWW, Ramesh M Added For CR#60647 // List<DAL.LoginHistoryRow> lstLoginHistory = DALMethods.GetLoginHistoryDetails(GPSHistory.SessionID, session); // foreach (DAL.LoginHistoryRow LoginHistory in lstLoginHistory) // { // sVehicleID = LoginHistory.VehicleID.ToString(); // sCompanyID = LoginHistory.CustomerID.ToString(); // sSessionID = LoginHistory.SessionID.ToString(); // } // string state = ""; // if (GPSHistory.Latitude == latitude && GPSHistory.Longitude == longitude) // { // continue; // } // else // { // latitude = GPSHistory.Latitude; // longitude = GPSHistory.Longitude; // try // { // doc.Load("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + latitude + "," + longitude + "&sensor=false"); // XmlNode element = doc.SelectSingleNode("//GeocodeResponse/status"); // if (element == null) // { // continue; // } // if (element.InnerText == "ZERO_RESULTS") // { // // 2013.12.09 FSWW, Ramesh M Added For CR#60647 modified error log message added,VehicleId,CustomerId,SessionID // throw new Exception("No data available for the specified location; latitude,longitude (" + latitude + "," + longitude + "), CompanyID-" + sCompanyID + ", VehicleID-" + sVehicleID + ", SessionID" + sSessionID); // } // else // { // element = doc.SelectSingleNode("//GeocodeResponse/result/formatted_address"); // XmlNode xNode = doc.SelectNodes("//GeocodeResponse/result/address_component[type='administrative_area_level_1']")[0]; // if (xNode == null) // { // xNode = doc.SelectNodes("//GeocodeResponse/result/address_component[type='country']")[0]; // if (xNode == null) // { // continue; // } // } // if (xNode["short_name"] != null) // { // state = xNode["short_name"].InnerText; // } // if (state.Length > 2) // { // try // { // string path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); // doc.Load(path + "//States.xml"); // xNode = doc.SelectSingleNode("//States/State[key='" + state + "']"); // if (xNode != null) // { // if (!String.IsNullOrEmpty(xNode["code"].InnerText)) // { // state = xNode["code"].InnerText; // } // } // } // catch (Exception ex) // { // // // } // } // } // if (!string.IsNullOrEmpty(state)) // { // //update Table // DALMethods.UpdateState(state, longitude, latitude, session); // } // } // catch (Exception ex) // { // Logging.LogError(ex); // } // } //} #endregion } catch (Exception ex) { Logging.LogError(ex); } finally { if (session != null) { CloseSession(session); } } }
public UserBLL() { _db = new UserContext(); _repository = new DALMethods <User>(_db); }
/// <summary> /// 2013.4.30, Suresh Madhesan, CR#? /// New login validate function and to return the user type /// </summary> /// <param name="userID"></param> /// <param name="password"></param> /// <param name="companyID"></param> /// <param name="vehicleID"></param> /// <param name="UserType"></param> /// <returns></returns> // 2013.08.07 FSWW, Ramesh M Added For CR#59829... To Validate User with User type Added UserType Parameter as input protected String ValidateUserLogin3(String userID, String password, String companyID, String vehicleID, String UserType, String VersionNo = "") { ISession session = null; String sResult = "F"; try { session = GetSession(); String ePassword = Encryption.doEncrypt(password); sResult = DataAccess.DALMethods.ValidateUserAndGetType(userID, ePassword, companyID, UserType, session, VersionNo); if (UserType.ToLower() == "g") { sResult = DataAccess.DALMethods.ValidateUserAndGetType(userID, ePassword, companyID, "D", session, VersionNo); } else { sResult = DataAccess.DALMethods.ValidateUserAndGetType(userID, ePassword, companyID, UserType, session, VersionNo); } if (sResult == "F") { throw new ApplicationException(ApplicationConstants.Errors.InvalidUserCredentials); } //// 2013.09.05 FSWW, Ramesh M Added For CR#59829... To validate site code if user type is "W" Warehouse user if (UserType.ToLower() == "d") { if (String.IsNullOrWhiteSpace(vehicleID) || DataAccess.DALMethods.GetVehicleID(vehicleID, companyID, session, VersionNo) == 0) { throw new ApplicationException(ApplicationConstants.Errors.InvalidVehicleCode); } } // 2013.12.02 FSWW, Ramesh M Added For CR#60893 validate SiteCode else if (UserType.ToLower() == "w") { if (String.IsNullOrWhiteSpace(vehicleID) || DataAccess.DALMethods.GetSiteID(vehicleID, companyID, session, VersionNo) == 0) { throw new ApplicationException(ApplicationConstants.Errors.InvalidSiteCode); } } if (UserType.ToLower() == "g") { sResult = "G"; if (DALMethods.GetVehicleTypeCount(DALMethods.GetVehicleID(vehicleID, companyID, session, VersionNo), Convert.ToInt32(companyID), session, VersionNo) == 0) { throw new ApplicationException(ApplicationConstants.Errors.InvalidTankWagonVehicle); } } CloseSession(session); } catch (ApplicationException ex) { CloseSession(session); throw ex; } catch (Exception ex) { CloseSession(session); // 2013.06.24 FSWW, Ramesh M Added For CR#58976 To Add More Details about calling function in Error log file. Logging.LogError(ex, "CustomerID-" + companyID + ", LoginUserID-" + userID + "\n"); throw ex; } finally { if (session != null) { CloseSession(session); } } return(sResult); }
/// <summary> /// validateUser /// Function to validate user login /// </summary> /// <param name="UserName">User name</param> /// <param name="vehicleID">Vehicle ID</param> /// <param name="password">Password</param> /// <param name="companyID">Company ID</param> /// <param name="deviceToken">Device Token</param> /// <param name="deviceTime">deviceTime</param> /// <param name="dateTime">dateTime</param> /// <param name="isNewLogin">Is New Login</param> /// <returns>SessionID</returns> protected Guid validateUser(String UserName, String vehicleID, String password, String companyID, String deviceToken, DateTime deviceTime, DateTime dateTime, bool isNewLogin, String DeviceID, DateTime GMT, String TrailerCode, String IOSVersion, String VersionNo = "") { Guid sessionID = new Guid(); ISession session = GetSession(); try { // 2013.5.6, Suresh Madhesan, CR#?, To avoid multiple logins //if (DataAccess.DALMethods.GetLoginCount(UserName, companyID, session) > 0) //{ // throw new ApplicationException(ApplicationConstants.Errors.MultipleLoginError); //} if (ValidateUserLogin(UserName, password, companyID, vehicleID, VersionNo)) { // Comment and created the session variable in the beginning of the function // 2013.5.6, Suresh Madhesan, CR#?, To avoid multiple logins //ISession session = null; //try //{ session = GetSession(); Int32 userID = DataAccess.DALMethods.GetUserID(UserName, companyID, session, VersionNo); Int32 iVehicleID = DataAccess.DALMethods.GetVehicleID(vehicleID, companyID, session, VersionNo); sessionID = GetSessionDetail(UserName, password, companyID, vehicleID, deviceTime, VersionNo); if (!isNewLogin) { return(sessionID); } else if (sessionID != Guid.Empty) { //LogOff Current session DALMethods.UpdateLoginHistory(sessionID, deviceTime, session, VersionNo); DALMethods.removeLoginSession(sessionID, session, VersionNo); } sessionID = Guid.NewGuid(); Entities.LoginHistory history = new Entities.LoginHistory(); history.LoginID = userID; history.VehicleID = iVehicleID; history.CustomerID = companyID; history.DeviceToken = deviceToken; history.DateTime = dateTime; history.IsValidToken = IsValidDevideToken(deviceToken); history.DeviceTime = deviceTime; history.SessionID = sessionID; //2013.12.19 FSWW, Ramesh M Added For CR#61549 added String DeviceID, DateTime GMT history.DeviceID = DeviceID; history.GMT = GMT; // 2014.02.10 Ramesh M Added TrailerCode For CR#62211 history.TrailerCode = TrailerCode; history.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginHistory(history, session, VersionNo); Entities.LoginSession loginSession = new Entities.LoginSession(); loginSession.SessionID = sessionID; loginSession.LoginID = userID; loginSession.CurrentVehicle = iVehicleID; loginSession.Active = true; loginSession.LogonTime = deviceTime; //TODO: Check for DeviceID loginSession.DeviceID = DeviceID; loginSession.Version = VersionNo; loginSession.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginSession(loginSession, session, VersionNo); CloseSession(session); } } catch (Exception ex) { if (session != null) { CloseSession(session); } // 2013.06.24 FSWW, Ramesh M Added For CR#58976 To Add More Details about calling function in Error log file. Logging.LogError(ex, "CustomerID-" + companyID + ", SessionID-" + sessionID + "\n"); throw ex; } finally { if (session != null) { CloseSession(session); } } return(sessionID); }
/// <summary> /// 2013.4.30, Suresh Madhesan, CR#? /// Function to added to get the usertype while login /// </summary> /// <param name="UserName"></param> /// <param name="vehicleID"></param> /// <param name="password"></param> /// <param name="companyID"></param> /// <param name="deviceToken"></param> /// <param name="deviceTime"></param> /// <param name="dateTime"></param> /// <param name="isNewLogin"></param> /// <param name="VersionNo"></param> /// <param name="UserType"></param> /// <param name="DeviceID"></param> /// <param name="GMT"></param> /// <returns></returns> /// 2013.08.07 FSWW, Ramesh M Added For CR#?... To Validate User with User type Added UserType Parameter as input /// 2013.11.27 FSWW, Ramesh M Added For CR#60210 Added deviceID in parameter /// 2013.12.04 FSWW, Ramesh M Added For CR#61305 Added GMT in parameter /// 2014.02.10 Ramesh M Added TrailerCode For CR#62211 protected String validateUser3(String UserName, String vehicleID, String password, String companyID, String deviceToken, DateTime deviceTime, DateTime dateTime, bool isNewLogin, String VersionNo, String UserType, String DeviceID, DateTime GMT, String TrailerCode, String IOSVersion = "") { Guid sessionID = new Guid(); String sUserType = null; ISession session = null; session = GetSession(); //2013.06-21 Fsww Ramesh M Added For CR#?.. To Validate application Version in Database //if (DataAccess.DALMethods.GetVersionNo(VersionNo,session)>0) //{ sUserType = ValidateUserLogin3(UserName, password, companyID, vehicleID, UserType, VersionNo); // 2014.01.28 Ramesh M Added For CR#62026 Prompt to update the version if ((VersionNo != "1.27") && ((sUserType.ToLower() == "d") || (sUserType.ToLower() == "w") || (sUserType.ToLower() == "g"))) { if (sUserType != "F") { try { Int32 userID = DataAccess.DALMethods.GetUserID(UserName, companyID, session, VersionNo); Int32 iVehicleID = DataAccess.DALMethods.GetVehicleID(vehicleID, companyID, session, VersionNo); sessionID = GetSessionDetail(UserName, password, companyID, vehicleID, deviceTime, VersionNo); // 2013-5-29, Fsww Ramesh M added for CR?.. for avoiding multiple logins,added following a line code and if condition Int32 iLoginIDCount = DataAccess.DALMethods.GetCurrentLoginIDCountByUserNameAndCustomerID(UserName, companyID, session, VersionNo); if (iLoginIDCount == 0) { if (!isNewLogin) { return(sessionID.ToString()); } else if (sessionID != Guid.Empty) { //LogOff Current session DALMethods.UpdateLoginHistory(sessionID, deviceTime, session, VersionNo); DALMethods.removeLoginSession(sessionID, session, VersionNo); } sessionID = Guid.NewGuid(); Entities.LoginHistory history = new Entities.LoginHistory(); history.LoginID = userID; history.VehicleID = iVehicleID; history.CustomerID = companyID; history.DeviceToken = deviceToken; history.DateTime = dateTime; history.IsValidToken = IsValidDevideToken(deviceToken); history.DeviceTime = deviceTime; history.SessionID = sessionID; history.DeviceID = DeviceID; // 2013.12.04 FSWW, Ramesh M Added For CR#61305 Added GMT in parameter history.GMT = GMT; // 2014.02.10 Ramesh M Added TrailerCode For CR#62211 history.TrailerCode = TrailerCode; history.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginHistory(history, session, VersionNo); Entities.LoginSession loginSession = new Entities.LoginSession(); loginSession.SessionID = sessionID; loginSession.LoginID = userID; loginSession.CurrentVehicle = iVehicleID; loginSession.Active = true; loginSession.LogonTime = deviceTime; //TODO: Check for DeviceID //loginSession.DeviceID = ""; loginSession.DeviceID = DeviceID; loginSession.Version = VersionNo; loginSession.IOSVersion = IOSVersion; DataAccess.DALMethods.AddLoginSession(loginSession, session, VersionNo); CloseSession(session); } else { // 2013.12.09 FSWW, Ramesh M Added For CR#61409. make the session id to be empty value sessionID = Guid.Empty; sUserType = "N"; } } catch (Exception ex) { if (session != null) { CloseSession(session); } // 2013.06.24 FSWW, Ramesh M Added For CR#58976 To Add More Details about calling function in Error log file. Logging.LogError(ex, "CustomerID-" + companyID + ", SessionID-" + sessionID + "\n"); } finally { if (session != null) { CloseSession(session); } } } //} //else //{ // sUserType = "V"; //} } else { sUserType = "V"; } //2014.02.24 Ramesh M Added For CR#62406 For DriverID,VechileID,UserLoginID on login itself so the user type putted as comma return(sessionID.ToString() + "," + sUserType); }