692 lines
28 KiB
C#
692 lines
28 KiB
C#
namespace VECV_WebApi.Models.User
|
|
{
|
|
#region Namespaces
|
|
|
|
using DBHelper;
|
|
using LoggingHelper;
|
|
using Npgsql;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using VECV_WebApi.Models.Authorization;
|
|
|
|
#endregion
|
|
|
|
#region Repository Class
|
|
|
|
/// <summary>
|
|
/// This class contain methods releted to user management
|
|
/// </summary>
|
|
public class UserRepository
|
|
{
|
|
#region Global Variables
|
|
|
|
/// <summary>
|
|
/// making object of LoggingUtility class available to this class
|
|
/// </summary>
|
|
LoggingUtility objLog = new LoggingUtility();
|
|
|
|
/// <summary>
|
|
/// making the data-log file path available to this class
|
|
/// </summary>
|
|
string path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]);
|
|
|
|
/// <summary>
|
|
/// making error log file path available to this class
|
|
/// </summary>
|
|
string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]);
|
|
|
|
/// <summary>
|
|
/// making the Database connection string available to this class
|
|
/// </summary>
|
|
private string _connStr;
|
|
|
|
/// <summary>
|
|
/// making User Model object available to this class
|
|
/// </summary>
|
|
UserModel objUserModel;
|
|
|
|
/// <summary>
|
|
/// making Authentication Repository object available to this class
|
|
/// </summary>
|
|
AuthenticationRepository objAuthorization;
|
|
|
|
#endregion
|
|
|
|
#region Contructors
|
|
|
|
/// <summary>
|
|
/// Default constructor intialize connection string of vecv database
|
|
/// </summary>
|
|
public UserRepository(string connString)
|
|
{
|
|
this._connStr = connString;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region API Methods
|
|
|
|
/// <summary>
|
|
/// To get user detail user name wise
|
|
/// </summary>
|
|
/// <param name="model">Represent object of usermodel class contain user name</param>
|
|
/// <returns>status and user detail user name wise</returns>
|
|
public UserModel GetUserDetailUserNameWise(UserModel model)
|
|
{
|
|
objUserModel = new UserModel();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inusername ", model.UserName);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_user_details_user_wise"], nSqlParam);
|
|
if (ds.Tables[0].Rows[0]["id"].ToString().Trim() != null && ds.Tables[0].Rows[0]["id"].ToString().Trim() != "")
|
|
{
|
|
|
|
//added on 19-11-2020 start
|
|
if (ds.Tables[0].Rows[0]["is_deleted"].ToString() == "True")
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = "User is not exist";
|
|
}
|
|
//added on 19-11-2020 end
|
|
else
|
|
{
|
|
objUserModel.Status = "1";
|
|
objUserModel.AuthEngineId = ds.Tables[0].Rows[0]["auth_engine_id"].ToString();
|
|
objUserModel.City = ds.Tables[0].Rows[0]["city"].ToString();
|
|
objUserModel.Designation = ds.Tables[0].Rows[0]["designation"].ToString();
|
|
objUserModel.DisplayId = ds.Tables[0].Rows[0]["display_id"].ToString();
|
|
objUserModel.DisplayName = ds.Tables[0].Rows[0]["display_name"].ToString();
|
|
objUserModel.Language = ds.Tables[0].Rows[0]["language"].ToString();
|
|
//objUserModel.Message = ds.Tables[0].Rows[0][""].ToString();
|
|
objUserModel.ObjectId = ds.Tables[0].Rows[0]["object_id"].ToString();
|
|
objUserModel.OffsetInMinute = Convert.ToDouble(ds.Tables[0].Rows[0]["offset_in_minutes"].ToString());
|
|
objUserModel.OrganizationAlias = ds.Tables[0].Rows[0]["organization_alias"].ToString();
|
|
objUserModel.OrganizationCity = ds.Tables[0].Rows[0]["organization_city"].ToString();
|
|
objUserModel.OrganizationColor = ds.Tables[0].Rows[0]["color"].ToString();
|
|
objUserModel.OrganizationCountry = ds.Tables[0].Rows[0]["asorganization_country"].ToString();
|
|
objUserModel.OrganizationDepth = ds.Tables[0].Rows[0]["depth"].ToString();
|
|
objUserModel.OrganizationDescription = ds.Tables[0].Rows[0]["organization_description"].ToString();
|
|
objUserModel.OrganizationId = Convert.ToInt32(ds.Tables[0].Rows[0]["organization_id"].ToString());
|
|
objUserModel.OrganizationName = ds.Tables[0].Rows[0]["organization_name"].ToString();
|
|
objUserModel.OrganizationPath = ds.Tables[0].Rows[0]["path"].ToString();
|
|
objUserModel.OrganizationRegion = ds.Tables[0].Rows[0]["organization_region"].ToString();
|
|
objUserModel.OrganizationState = ds.Tables[0].Rows[0]["organization_state"].ToString();
|
|
objUserModel.Region = ds.Tables[0].Rows[0]["region"].ToString();
|
|
objUserModel.State = ds.Tables[0].Rows[0]["state"].ToString();
|
|
objUserModel.TimeZoneId = Convert.ToInt64(ds.Tables[0].Rows[0]["timezone_id"].ToString());
|
|
objUserModel.UserId = Convert.ToInt64(ds.Tables[0].Rows[0]["id"].ToString());
|
|
objUserModel.UserName = ds.Tables[0].Rows[0]["user_name"].ToString();
|
|
objUserModel.VehicleTagging = ds.Tables[0].Rows[0]["vehicle_tagging"].ToString();
|
|
objUserModel.FirstName = ds.Tables[0].Rows[0]["first_name"].ToString();
|
|
objUserModel.LastName = ds.Tables[0].Rows[0]["last_name"].ToString();
|
|
objUserModel.StateId = ds.Tables[0].Rows[0]["state_id"].ToString();
|
|
objUserModel.CityId = ds.Tables[0].Rows[0]["city_id"].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = "User is not exist";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
}
|
|
return objUserModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
objLog.ErrorLogFile("GetUserDetailUserNameWise", Ex.Message, path, errorlogtf);
|
|
return objUserModel;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To create new user
|
|
/// </summary>
|
|
/// <param name="model">user info</param>
|
|
/// <returns>contain status 0 or 1</returns>
|
|
public UserModel InsertNewUserDetail(UserModel model)
|
|
{
|
|
objUserModel = new UserModel();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[13];
|
|
nSqlParam[0] = new NpgsqlParameter("inauth_engine_id ", model.AuthEngineId);
|
|
nSqlParam[1] = new NpgsqlParameter("inuser_name ", model.UserName);
|
|
nSqlParam[2] = new NpgsqlParameter("indesignation ", model.Designation);
|
|
nSqlParam[3] = new NpgsqlParameter("inobject_id ", model.ObjectId);
|
|
nSqlParam[4] = new NpgsqlParameter("inorganization_id ", model.OrganizationId);
|
|
nSqlParam[5] = new NpgsqlParameter("incity ", model.City);
|
|
nSqlParam[6] = new NpgsqlParameter("instate ", model.State);
|
|
nSqlParam[7] = new NpgsqlParameter("inregion ", model.Region);
|
|
nSqlParam[8] = new NpgsqlParameter("inlanguage ", model.Language);
|
|
nSqlParam[9] = new NpgsqlParameter("intimezone_id ", model.TimeZoneId);
|
|
nSqlParam[10] = new NpgsqlParameter("invehicle_tagging ", model.VehicleTagging);
|
|
nSqlParam[11] = new NpgsqlParameter("infirst_name ", model.FirstName);
|
|
nSqlParam[12] = new NpgsqlParameter("inlast_name ", model.LastName);
|
|
NpgSqlHelper.ExecuteNonQuery(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_insert_users"], nSqlParam);
|
|
|
|
// For Telematics Use
|
|
// NpgSqlHelper.ExecuteNonQuery(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_sync_users"]);
|
|
objUserModel.Status = "1";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["UserSuccessfulCreateionMessage"].ToString();
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
}
|
|
|
|
return objUserModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
objLog.ErrorLogFile("InsertNewUserDetail", Ex.Message, path, errorlogtf);
|
|
return objUserModel;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// To update or delte user
|
|
/// </summary>
|
|
/// <param name="model">user info</param>
|
|
/// <returns>contain status 0 or 1</returns>
|
|
public UserModel UpdateOrDeleteUserDetail(UserModel model)
|
|
{
|
|
objUserModel = new UserModel();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[14];
|
|
nSqlParam[0] = new NpgsqlParameter("inauth_engine_id ", model.AuthEngineId);
|
|
nSqlParam[1] = new NpgsqlParameter("inuser_name ", model.UserName);
|
|
nSqlParam[2] = new NpgsqlParameter("indesignation ", model.Designation);
|
|
nSqlParam[3] = new NpgsqlParameter("inobject_id ", model.ObjectId);
|
|
|
|
if (model.OrganizationId == 0)
|
|
{
|
|
nSqlParam[4] = new NpgsqlParameter("inorganization_id", null);
|
|
}
|
|
else
|
|
{
|
|
nSqlParam[4] = new NpgsqlParameter("inorganization_id", model.OrganizationId);
|
|
}
|
|
|
|
|
|
nSqlParam[5] = new NpgsqlParameter("incity ", model.City);
|
|
nSqlParam[6] = new NpgsqlParameter("instate ", model.State);
|
|
nSqlParam[7] = new NpgsqlParameter("inregion ", model.Region);
|
|
nSqlParam[8] = new NpgsqlParameter("inlanguage ", model.Language);
|
|
nSqlParam[9] = new NpgsqlParameter("intimezone_id ", model.TimeZoneId);
|
|
nSqlParam[10] = new NpgsqlParameter("invehicle_tagging ", model.VehicleTagging);
|
|
nSqlParam[11] = new NpgsqlParameter("infirst_name ", model.FirstName);
|
|
nSqlParam[12] = new NpgsqlParameter("inlast_name ", model.LastName);
|
|
nSqlParam[13] = new NpgsqlParameter("inis_deleted ", model.IsDeleted);
|
|
|
|
NpgSqlHelper.ExecuteNonQuery(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_update_users"], nSqlParam);
|
|
|
|
// For Telematics Use
|
|
// NpgSqlHelper.ExecuteNonQuery(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_sync_users"]);
|
|
objUserModel.Status = "1";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["UserSuccessfulUpdateMessage"].ToString();
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
}
|
|
|
|
return objUserModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
objLog.ErrorLogFile("UpdateOrDeleteUserDetail", Ex.Message, path, errorlogtf);
|
|
return objUserModel;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// To get dealer detail user id wise
|
|
/// </summary>
|
|
/// <param name="model">user info</param>
|
|
/// <returns>status and dealer detail user id wise</returns>
|
|
public List<DealerModel> GetNonUserDealer(DealerModel model)
|
|
{
|
|
List<DealerModel> objModel = new List<DealerModel>();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inuserid ", model.UserId);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_dealer_are_not_user"], nSqlParam);
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
objModel = ds.Tables[0].AsEnumerable().Select(s => new DealerModel
|
|
{
|
|
DealerCity = s.Field<string>("dealer_city"),
|
|
DealerDefaultLatitude = s.Field<string>("dealer_dealer_default_lattitude"),
|
|
DealerDefaultLongitude = s.Field<string>("dealer_dealer_default_longitude"),
|
|
DealerId = s.Field<string>("dealer_id"),
|
|
DealerName = s.Field<string>("dealer_dealer_name"),
|
|
DealerState = s.Field<string>("dealer_state"),
|
|
OrganizationId = s.Field<int?>("dealer_organization_id")
|
|
}).ToList();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DealerModel objdealer = new DealerModel();
|
|
objdealer.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
objModel.Add(objdealer);
|
|
}
|
|
return objModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
DealerModel objdealer = new DealerModel();
|
|
objdealer.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString();
|
|
objModel.Add(objdealer);
|
|
objLog.ErrorLogFile("GetNonUserDealer", Ex.Message, path, errorlogtf);
|
|
return objModel;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// To get user detail user id wise
|
|
/// </summary>
|
|
/// <param name="model">user info</param>
|
|
/// <returns>status and user detail user id wise</returns>
|
|
public List<UserModel> GetUserListUserIdWise(UserModel model)
|
|
{
|
|
List<UserModel> objList = new List<UserModel>();
|
|
objUserModel = new UserModel();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inuserid ", model.UserId);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_vecv_user"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["id"].ToString().Trim() != null && ds.Tables[0].Rows[0]["id"].ToString().Trim() != "")
|
|
{
|
|
objList = ds.Tables[0].AsEnumerable().Select(s => new UserModel
|
|
{
|
|
Status = "1",
|
|
AuthEngineId = s.Field<string>("auth_engine_id"),
|
|
City = s.Field<string>("city"),
|
|
Designation = s.Field<string>("designation"),
|
|
DisplayId = s.Field<string>("display_id"),
|
|
DisplayName = s.Field<string>("display_name"),
|
|
Language = s.Field<string>("language"),
|
|
ObjectId = s.Field<string>("object_id"),
|
|
OffsetInMinute = s.Field<double?>("offset_in_minutes"),
|
|
OrganizationAlias = s.Field<string>("organization_alias"),
|
|
OrganizationCity = s.Field<string>("organization_city"),
|
|
OrganizationColor = s.Field<string>("color"),
|
|
OrganizationCountry = s.Field<string>("asorganization_country"),
|
|
OrganizationDepth = s.Field<string>("depth"),
|
|
OrganizationDescription = s.Field<string>("organization_description"),
|
|
OrganizationId = s.Field<int>("organization_id"),
|
|
OrganizationName = s.Field<string>("organization_name"),
|
|
OrganizationPath = s.Field<string>("path"),
|
|
OrganizationRegion = s.Field<string>("organization_region"),
|
|
OrganizationState = s.Field<string>("organization_state"),
|
|
Region = s.Field<string>("region"),
|
|
State = s.Field<string>("state"),
|
|
TimeZoneId = s.Field<Int64>("timezone_id"),
|
|
UserId = s.Field<Int64>("id"),
|
|
UserName = s.Field<string>("user_name"),
|
|
VehicleTagging = s.Field<string>("vehicle_tagging"),
|
|
FirstName = s.Field<string>("first_name"),
|
|
LastName = s.Field<string>("last_name"),
|
|
IsDeleted = s.Field<bool>("is_deleted")
|
|
}).ToList();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
objList.Add(objUserModel);
|
|
}
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetUserListUserIdWise", Ex.Message, path, errorlogtf);
|
|
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
objList.Add(objUserModel);
|
|
return objList;
|
|
}
|
|
}
|
|
public string GetUserAppVersion(string userid, string token)
|
|
{
|
|
string strsucess = "";
|
|
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inuserid ", userid);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_app_version_userwise"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
strsucess = Convert.ToString(ds.Tables[0].Rows[0]["sp_app_version_userwise"]);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetDealerListUserIdWise", Ex.Message, path, errorlogtf);
|
|
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
|
|
}
|
|
return strsucess;
|
|
|
|
}
|
|
|
|
|
|
public string updateUserAppVersion(string userid, string token, string app_version)
|
|
{
|
|
string strsucess = "";
|
|
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[2];
|
|
nSqlParam[0] = new NpgsqlParameter("inuserid ", userid);
|
|
nSqlParam[1] = new NpgsqlParameter("inappversion ", app_version);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_update_app_version_userwise"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
string appversion = Convert.ToString(ds.Tables[0].Rows[0]["sp_update_app_version_userwise"]);
|
|
if (appversion == "" || appversion == null)
|
|
{
|
|
strsucess = "Invalid userid";
|
|
}
|
|
else
|
|
{
|
|
strsucess = "success";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetDealerListUserIdWise", Ex.Message, path, errorlogtf);
|
|
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
|
|
}
|
|
return strsucess;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string updateDealerAppVersion(string userid, string token, string app_version)
|
|
{
|
|
string strsucess = "";
|
|
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[2];
|
|
nSqlParam[0] = new NpgsqlParameter("inuserid ", userid);
|
|
nSqlParam[1] = new NpgsqlParameter("inappversion ", app_version);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_update_app_version_dealerwise"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
string appversion = Convert.ToString(ds.Tables[0].Rows[0]["sp_update_app_version_dealerwise"]);
|
|
if (appversion == "" || appversion == null)
|
|
{
|
|
strsucess = "Invalid userid";
|
|
}
|
|
else
|
|
{
|
|
strsucess = "success";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetDealerListUserIdWise", Ex.Message, path, errorlogtf);
|
|
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
|
|
}
|
|
return strsucess;
|
|
|
|
}
|
|
/// <summary>
|
|
/// To get dealer detail user id wise
|
|
/// </summary>
|
|
/// <param name="model">user info</param>
|
|
/// <returns>status and dealer detail user id wise</returns>
|
|
public List<UserModel> GetDealerListUserIdWise(UserModel model)
|
|
{
|
|
List<UserModel> objList = new List<UserModel>();
|
|
objUserModel = new UserModel();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inuserid ", model.UserId);
|
|
ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_dealer_user"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["id"].ToString().Trim() != null && ds.Tables[0].Rows[0]["id"].ToString().Trim() != "")
|
|
{
|
|
objList = ds.Tables[0].AsEnumerable().Select(s => new UserModel
|
|
{
|
|
Status = "1",
|
|
AuthEngineId = s.Field<string>("auth_engine_id"),
|
|
City = s.Field<string>("city"),
|
|
Designation = s.Field<string>("designation"),
|
|
DisplayId = s.Field<string>("display_id"),
|
|
DisplayName = s.Field<string>("display_name"),
|
|
Language = s.Field<string>("language"),
|
|
ObjectId = s.Field<string>("object_id"),
|
|
OffsetInMinute = s.Field<double?>("offset_in_minutes"),
|
|
OrganizationAlias = s.Field<string>("organization_alias"),
|
|
OrganizationCity = s.Field<string>("organization_city"),
|
|
OrganizationColor = s.Field<string>("color"),
|
|
OrganizationCountry = s.Field<string>("asorganization_country"),
|
|
OrganizationDepth = s.Field<string>("depth"),
|
|
OrganizationDescription = s.Field<string>("organization_description"),
|
|
OrganizationId = s.Field<int>("organization_id"),
|
|
OrganizationName = s.Field<string>("organization_name"),
|
|
OrganizationPath = s.Field<string>("path"),
|
|
OrganizationRegion = s.Field<string>("organization_region"),
|
|
OrganizationState = s.Field<string>("organization_state"),
|
|
Region = s.Field<string>("region"),
|
|
State = s.Field<string>("state"),
|
|
TimeZoneId = s.Field<Int64>("timezone_id"),
|
|
UserId = s.Field<Int64>("id"),
|
|
UserName = s.Field<string>("user_name"),
|
|
VehicleTagging = s.Field<string>("vehicle_tagging"),
|
|
FirstName = s.Field<string>("first_name"),
|
|
LastName = s.Field<string>("last_name"),
|
|
IsDeleted = s.Field<bool>("is_deleted")
|
|
}).ToList();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
objList.Add(objUserModel);
|
|
}
|
|
return objList;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objLog.ErrorLogFile("GetDealerListUserIdWise", Ex.Message, path, errorlogtf);
|
|
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
objList.Add(objUserModel);
|
|
return objList;
|
|
}
|
|
}
|
|
public UserModel UpdateEPSStatus(UserModel model)
|
|
{
|
|
objUserModel = new UserModel();
|
|
try
|
|
{
|
|
objAuthorization = new AuthenticationRepository();
|
|
if (objAuthorization.AuthenticateDevice(model.Token))
|
|
{
|
|
DataSet ds = new DataSet();
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[2];
|
|
nSqlParam[0] = new NpgsqlParameter("inauth_engine_id ", model.AuthEngineId);
|
|
nSqlParam[1] = new NpgsqlParameter("inEpsStatus", model.Status);
|
|
|
|
NpgSqlHelper.ExecuteNonQuery(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_update_users_Eps"], nSqlParam);
|
|
|
|
// For Telematics Use
|
|
// NpgSqlHelper.ExecuteNonQuery(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_sync_users"]);
|
|
objUserModel.Status = "1";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["UserSuccessfulUpdateMessage"].ToString();
|
|
}
|
|
else
|
|
{
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["DeviceConfigurationTokenMessage"].ToString();
|
|
}
|
|
|
|
return objUserModel;
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
// write error log into file
|
|
objUserModel.Status = "0";
|
|
objUserModel.Message = ConfigurationManager.AppSettings["PwdErrorMsg"].ToString() + Ex.Message;
|
|
objLog.ErrorLogFile("UpdateOrDeleteUserDetail", Ex.Message, path, errorlogtf);
|
|
return objUserModel;
|
|
}
|
|
}
|
|
|
|
public string getEPSStatus(string authId)
|
|
{
|
|
string strmessage = "";
|
|
try
|
|
{
|
|
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inauth_engine_id", authId);
|
|
|
|
DataSet ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_users_Eps_status"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
strmessage = Convert.ToString(ds.Tables[0].Rows[0]["sp_get_users_Eps_status"]);
|
|
// strmessage = "success";//ds.Tables[0].Rows[0]["_ticket_id"].ToString(); // getting ticket id alias
|
|
// errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]) + ticketIdAlias;
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objLog.ErrorLogFile("usp_get_users_Eps_status", Ex.Message, path, errorlogtf);
|
|
}
|
|
return strmessage;
|
|
}
|
|
|
|
public string getEPSStatusByUserId(string userid)
|
|
{
|
|
string strmessage = "";
|
|
try
|
|
{
|
|
|
|
NpgsqlParameter[] nSqlParam = new NpgsqlParameter[1];
|
|
nSqlParam[0] = new NpgsqlParameter("inuser_id", userid);
|
|
|
|
DataSet ds = NpgSqlHelper.ExecuteDataset(_connStr, CommandType.StoredProcedure, ConfigurationManager.AppSettings["usp_get_users_Eps_status_by_userid"], nSqlParam);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
strmessage = Convert.ToString(ds.Tables[0].Rows[0]["sp_get_users_Eps_status_by_userid"]);
|
|
// strmessage = "success";//ds.Tables[0].Rows[0]["_ticket_id"].ToString(); // getting ticket id alias
|
|
// errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]) + ticketIdAlias;
|
|
}
|
|
}
|
|
catch (Exception Ex)
|
|
{
|
|
objLog.ErrorLogFile("usp_get_users_Eps_status_by_userid", Ex.Message, path, errorlogtf);
|
|
}
|
|
return strmessage;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |