private bool dbDelete(ref int totalRecordCount) { string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string signatureId = Request.Form["SignatureId"]; List <dynamic> rows = new List <dynamic>(); GIGridInitModel giGridInitModel = new GIGridInitModel() { ColumnList = new List <GIGridColumn>() }; try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_DeleteSignature]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@SignatureId", signatureId); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; sqlCommand.ExecuteNonQuery(); } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(true); }
private dynamic dbGetTask(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); string taskId = Request.Query["taskId"]; TaskModel model = new TaskModel(); //List<dynamic> rows = new List<dynamic>(); try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetTask]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@TaskId", taskId); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; if (recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("TaskId")]) != System.DBNull.Value) { model.TaskId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("TaskName")]) != System.DBNull.Value) { model.TaskName = (string)value; } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(model); }
//private IEnumerable<dynamic> dbGetProviderList(ref int totalRecordCount ) private dynamic dbGetClaimsList(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; bool exportGrid = Request.Query["type"].ToString() == "exportGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); List <dynamic> rows = new List <dynamic>(); GIGridInitModel giGridInitModel = new GIGridInitModel() { ColumnList = new List <GIGridColumn>() }; try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetAutoPolicyList]"; sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); if (Request != null && Request.Query != null && Request.Query.Keys != null && Request.Query.Keys.Count > 0) { foreach (string key in Request.Query.Keys) { if (!key.StartsWith("_")) { string param = $"@{key}"; sqlCommand.Parameters.AddWithValue(param, Request.Query[key].ToString()); } } } ; SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; while (recordSet.Read()) { dynamic model = null; if (initGrid == true) { model = new GIGridColumn(); } else { model = new ContractListModel(); ///////////////// !!!!!!!! ////////// } var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": el.SetValue(model, (decimal)value); break; case "DateTime": el.SetValue(model, (DateTime)value); break; } } } if (initGrid == true) { giGridInitModel.ColumnList.Add(model); } else { rows.Add(model); } } if (initGrid == true && recordSet.NextResult() && recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) { giGridInitModel.Title = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Toolbar")]) != System.DBNull.Value) { giGridInitModel.Toolbar = (string)value; } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } if (initGrid == false) { return(rows); } return(giGridInitModel); }
private IEnumerable<dynamic> dbGetUserTaskPermissionList(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); string taskId = Request.Query["TaskId"]; List<dynamic> rows = new List<dynamic>(); try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetTaskPermisionList]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@TaskId", taskId); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; while (recordSet.Read()) { UserPermissionModel model = new UserPermissionModel(); //if ((value = recordSet[recordSet.GetOrdinal("rootId")]) != System.DBNull.Value) model.rootId = (int)value; //if ((value = recordSet[recordSet.GetOrdinal("id")]) != System.DBNull.Value) model.id = (int)value; //if ((value = recordSet[recordSet.GetOrdinal("pid")]) != System.DBNull.Value) model.pid = (int)value; //if ((value = recordSet[recordSet.GetOrdinal("leaf")]) != System.DBNull.Value) model.leaf = (bool)value; //if ((value = recordSet[recordSet.GetOrdinal("hasAccess")]) != System.DBNull.Value) model.hasAccess = (bool)value; //if ((value = recordSet[recordSet.GetOrdinal("expanded")]) != System.DBNull.Value) model.expanded = (bool)value; //if ((value = recordSet[recordSet.GetOrdinal("loaded")]) != System.DBNull.Value) model.loaded = (bool)value; //if ((value = recordSet[recordSet.GetOrdinal("text")]) != System.DBNull.Value) model.text = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("cls")]) != System.DBNull.Value) model.cls = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("iconCls")]) != System.DBNull.Value) model.iconCls = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("reference")]) != System.DBNull.Value) model.reference = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("url")]) != System.DBNull.Value) model.url = (string)value; //rows.Add(model); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; } } } rows.Add(model); } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) totalRecordCount = (int)outputValue.Value; } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return rows; }
private dynamic dbGetList(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; bool exportGrid = Request.Query["type"].ToString() == "exportGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); List <dynamic> rows = new List <dynamic>(); GIGridInitModel giGridInitModel = new GIGridInitModel() { ColumnList = new List <GIGridColumn>() }; try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_CallCenterGetDocList]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@ExportGrid", exportGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@page", page); sqlCommand.Parameters.AddWithValue("@start", start); sqlCommand.Parameters.AddWithValue("@limit", limit); sqlCommand.Parameters.AddWithValue("@sort", Request.Query["sort"].ToString()); //sqlCommand.Parameters.AddWithValue("@saxeobaId", Request.Query["saxeobaId"].ToString()); //sqlCommand.Parameters.AddWithValue("@docId", Request.Query["docId"].ToString()); //sqlCommand.Parameters.AddWithValue("@policyNo", Request.Query["policyNo"].ToString()); //sqlCommand.Parameters.AddWithValue("@pin", Request.Query["pin"].ToString()); //sqlCommand.Parameters.AddWithValue("@policyHolder", Request.Query["policyHolder"].ToString()); //sqlCommand.Parameters.AddWithValue("@policyHolderParent", Request.Query["policyHolderParent"].ToString()); //sqlCommand.Parameters.AddWithValue("@organizationName", Request.Query["organizationName"].ToString()); //sqlCommand.Parameters.AddWithValue("@contractNom", Request.Query["contractNom"].ToString()); //sqlCommand.Parameters.AddWithValue("@docCreateDateStart", Request.Query["docCreateDateStart"].ToString()); //sqlCommand.Parameters.AddWithValue("@docCreateDateStart", Request.Query["docCreateDateStart"].ToString()); //sqlCommand.Parameters.AddWithValue("@operatorId", Request.Query["operatorId"].ToString()); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; while (recordSet.Read()) { dynamic model = null; GIGridColumn model_c = new GIGridColumn(); CallCenterDocListModel model_r = new CallCenterDocListModel(); if (initGrid == true) { model = model_c; } else { model = model_r; } var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; } } } if (initGrid == true) { giGridInitModel.ColumnList.Add(model); } else { rows.Add(model); } } if (initGrid == true && recordSet.NextResult() && recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) { giGridInitModel.Title = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Toolbar")]) != System.DBNull.Value) { giGridInitModel.Toolbar = (string)value; } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } if (initGrid == false) { return(rows); } return(giGridInitModel); }
private dynamic dbList(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; bool exportGrid = Request.Query["type"].ToString() == "exportGrid" ? true : false; bool isUtil = Request.Query["subtype"].ToString() == "isUtil" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); List <dynamic> rows = new List <dynamic>(); GIGridInitModel giGridInitModel = new GIGridInitModel() { ColumnList = new List <GIGridColumn>() }; try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_lookup_GetPositionList]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@ExportGrid", exportGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@page", page); sqlCommand.Parameters.AddWithValue("@start", start); sqlCommand.Parameters.AddWithValue("@limit", limit); sqlCommand.Parameters.AddWithValue("@utilityFilter", Request.Query["utilityFilter"].ToString()); // when typing in dropdown sqlCommand.Parameters.AddWithValue("@sort", Request.Query["sort"].ToString()); //sqlCommand.Parameters.AddWithValue("@userDescription", Request.Query["userDescription"].ToString()); //sqlCommand.Parameters.AddWithValue("@userCode", Request.Query["userCode"].ToString()); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; while (recordSet.Read()) { if (initGrid == true) { GIGridColumn column = new GIGridColumn(); if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) { column.Title = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DataIndex")]) != System.DBNull.Value) { column.DataIndex = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("ValueType")]) != System.DBNull.Value) { column.ValueType = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Width")]) != System.DBNull.Value) { column.Width = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Flex")]) != System.DBNull.Value) { column.Flex = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Renderer")]) != System.DBNull.Value) { column.Renderer = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("IsFilter")]) != System.DBNull.Value) { column.IsFilter = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsNotColumn")]) != System.DBNull.Value) { column.IsNotColumn = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsHidden")]) != System.DBNull.Value) { column.IsHidden = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsMenuDisabled")]) != System.DBNull.Value) { column.IsMenuDisabled = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsGridSummaryRow")]) != System.DBNull.Value) { column.IsGridSummaryRow = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsLocked")]) != System.DBNull.Value) { column.IsLocked = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("SummaryRenderer")]) != System.DBNull.Value) { column.SummaryRenderer = (string)value; } giGridInitModel.ColumnList.Add(column); } else { GILookupModel model = new GILookupModel(); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; } } } rows.Add(model); } } if (initGrid == true && recordSet.NextResult() && recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) { giGridInitModel.Title = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Toolbar")]) != System.DBNull.Value) { giGridInitModel.Toolbar = (string)value; } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } if (initGrid == false) { return(rows); } return(giGridInitModel); }
private IEnumerable <dynamic> dbGetUserLeftMenuList(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); List <dynamic> rows = new List <dynamic>(); try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetUserLeftMenuList]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); //sqlCommand.Parameters.AddWithValue("@page", page); //sqlCommand.Parameters.AddWithValue("@start", start); //sqlCommand.Parameters.AddWithValue("@limit", limit); //sqlCommand.Parameters.AddWithValue("@sort", Request.Query["sort"].ToString()); //sqlCommand.Parameters.AddWithValue("@userDescription", Request.Query["userDescription"].ToString()); //sqlCommand.Parameters.AddWithValue("@userCode", Request.Query["userCode"].ToString()); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; while (recordSet.Read()) { //if (initGrid == true) //{ // GIGridColumn column = new GIGridColumn(); // if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) column.Title = (string)value; // rows.Add(column); //} //else { LeftMenu model = new LeftMenu(); if ((value = recordSet[recordSet.GetOrdinal("rootId")]) != System.DBNull.Value) { model.rootId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("id")]) != System.DBNull.Value) { model.id = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("pid")]) != System.DBNull.Value) { model.pid = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("leaf")]) != System.DBNull.Value) { model.leaf = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("expanded")]) != System.DBNull.Value) { model.expanded = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("loaded")]) != System.DBNull.Value) { model.loaded = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("text")]) != System.DBNull.Value) { model.text = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("iconCls")]) != System.DBNull.Value) { model.iconCls = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("isMenuGroup")]) != System.DBNull.Value) { model.isMenuGroup = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("isDashboard")]) != System.DBNull.Value) { model.isDashboard = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("reference")]) != System.DBNull.Value) { model.reference = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("url")]) != System.DBNull.Value) { model.url = (string)value; } rows.Add(model); } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(rows); }
private dynamic dbActivateAccountToken(UserModel user, ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); UserModel model = new UserModel(); try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_ActivateAccountToken]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@UserId", user.UserId); sqlCommand.Parameters.AddWithValue("@ActivationToken", user.ActivationToken); sqlCommand.Parameters.AddWithValue("@NewPassword", user.NewPassword); sqlCommand.Parameters.AddWithValue("@RePassword", user.RePassword); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { //object value; if (recordSet.Read()) { //if ((value = recordSet[recordSet.GetOrdinal("UserId")]) != System.DBNull.Value) model.UserId = (int)value; //if ((value = recordSet[recordSet.GetOrdinal("Username")]) != System.DBNull.Value) model.Username = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("FirstName")]) != System.DBNull.Value) model.FirstName = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("LastName")]) != System.DBNull.Value) model.LastName = (string)value; //if ((value = recordSet[recordSet.GetOrdinal("Email")]) != System.DBNull.Value) model.Email = (string)value; } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(model); }
private dynamic dbSetUserUser(UserModel user, ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); //********************************************************* // If new userd and needs to activate Account if (!string.IsNullOrWhiteSpace(user.ActivationToken)) { return(dbActivateAccountToken(user, ref totalRecordCount)); } UserModel model = new UserModel(); try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_SetUser]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@FirstName", user.FirstName); sqlCommand.Parameters.AddWithValue("@LastName", user.LastName); sqlCommand.Parameters.AddWithValue("@DOB", user.DOB); sqlCommand.Parameters.AddWithValue("@Address", user.Address); sqlCommand.Parameters.AddWithValue("@BirthPlace", user.BirthPlace); sqlCommand.Parameters.AddWithValue("@PIN", user.PIN); sqlCommand.Parameters.AddWithValue("@PassportNom", user.PassportNom); sqlCommand.Parameters.AddWithValue("@CitizenshipId", user.CitizenshipId); sqlCommand.Parameters.AddWithValue("@ContractNom", user.ContractNom); sqlCommand.Parameters.AddWithValue("@DateStart", user.DateStart); sqlCommand.Parameters.AddWithValue("@DateEnd", user.DateEnd); sqlCommand.Parameters.AddWithValue("@StatusId", user.StatusId); sqlCommand.Parameters.AddWithValue("@DepartmentId", user.DepartmentId); sqlCommand.Parameters.AddWithValue("@PositionId", user.PositionId); sqlCommand.Parameters.AddWithValue("@UserId", user.UserId); sqlCommand.Parameters.AddWithValue("@StaffId", user.StaffId); sqlCommand.Parameters.AddWithValue("@IsMed", user.IsMed == null ? false : Convert.ToBoolean(user.IsMed.ToString())); sqlCommand.Parameters.AddWithValue("@IsBlocked", user.IsBlocked == null ? false : Convert.ToBoolean(user.IsBlocked.ToString())); sqlCommand.Parameters.AddWithValue("@IsSales", user.IsSales == null ? false : Convert.ToBoolean(user.IsSales.ToString())); sqlCommand.Parameters.AddWithValue("@Code", user.Code); sqlCommand.Parameters.AddWithValue("@Permissions", user.Permissions); sqlCommand.Parameters.AddWithValue("@Email", user.Email); sqlCommand.Parameters.AddWithValue("@ResetOnly", user.ResetOnly); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; if (recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("UserId")]) != System.DBNull.Value) { model.UserId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("StaffId")]) != System.DBNull.Value) { model.StaffId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("FirstName")]) != System.DBNull.Value) { model.FirstName = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("LastName")]) != System.DBNull.Value) { model.LastName = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DOB")]) != System.DBNull.Value) { model.DOB = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Address")]) != System.DBNull.Value) { model.Address = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("PIN")]) != System.DBNull.Value) { model.PIN = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("PassportNom")]) != System.DBNull.Value) { model.PassportNom = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("CitizenshipId")]) != System.DBNull.Value) { model.CitizenshipId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("Citizenship")]) != System.DBNull.Value) { model.Citizenship = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("ContractNom")]) != System.DBNull.Value) { model.ContractNom = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DateStart")]) != System.DBNull.Value) { model.DateStart = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DateEnd")]) != System.DBNull.Value) { model.DateEnd = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("StatusId")]) != System.DBNull.Value) { model.StatusId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("StatusDescription")]) != System.DBNull.Value) { model.StatusDescription = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DepartmentId")]) != System.DBNull.Value) { model.DepartmentId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("DepartmentDescription")]) != System.DBNull.Value) { model.DepartmentDescription = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("PositionId")]) != System.DBNull.Value) { model.PositionId = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("PositionDescription")]) != System.DBNull.Value) { model.PositionDescription = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Code")]) != System.DBNull.Value) { model.Code = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Username")]) != System.DBNull.Value) { model.Username = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("IsBlocked")]) != System.DBNull.Value) { model.IsBlocked = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsMed")]) != System.DBNull.Value) { model.IsMed = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsSales")]) != System.DBNull.Value) { model.IsSales = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("BirthPlace")]) != System.DBNull.Value) { model.BirthPlace = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Email")]) != System.DBNull.Value) { model.Email = (string)value; } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(model); }
//private IEnumerable<dynamic> dbGetAgentList(ref int totalRecordCount ) private dynamic dbGetAgentList(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; bool exportGrid = Request.Query["type"].ToString() == "exportGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); List <dynamic> rows = new List <dynamic>(); GIGridInitModel giGridInitModel = new GIGridInitModel() { ColumnList = new List <GIGridColumn>() }; try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetAgentBrokerList]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@ExportGrid", exportGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@page", page); sqlCommand.Parameters.AddWithValue("@start", start); sqlCommand.Parameters.AddWithValue("@limit", limit); sqlCommand.Parameters.AddWithValue("@sort", Request.Query["sort"].ToString()); sqlCommand.Parameters.AddWithValue("@code", Request.Query["ode"].ToString()); sqlCommand.Parameters.AddWithValue("@description", Request.Query["description"].ToString()); sqlCommand.Parameters.AddWithValue("@pin", Request.Query["pin"].ToString()); sqlCommand.Parameters.AddWithValue("@address", Request.Query["address"].ToString()); sqlCommand.Parameters.AddWithValue("@phone", Request.Query["phone"].ToString()); sqlCommand.Parameters.AddWithValue("@isBroker", Request.Query["isBroker"].ToString()); sqlCommand.Parameters.AddWithValue("@isIndMetsarme", Request.Query["isIndMetsarme"].ToString()); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; while (recordSet.Read()) { if (initGrid == true) { #region helper properties GIGridColumn column = new GIGridColumn(); if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) { column.Title = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DataIndex")]) != System.DBNull.Value) { column.DataIndex = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("DisplayField")]) != System.DBNull.Value) { column.DisplayField = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("ValueField")]) != System.DBNull.Value) { column.ValueField = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("ValueType")]) != System.DBNull.Value) { column.ValueType = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Width")]) != System.DBNull.Value) { column.Width = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Flex")]) != System.DBNull.Value) { column.Flex = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Renderer")]) != System.DBNull.Value) { column.Renderer = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("IsFilter")]) != System.DBNull.Value) { column.IsFilter = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsNotColumn")]) != System.DBNull.Value) { column.IsNotColumn = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsHidden")]) != System.DBNull.Value) { column.IsHidden = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsMenuDisabled")]) != System.DBNull.Value) { column.IsMenuDisabled = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsGridSummaryRow")]) != System.DBNull.Value) { column.IsGridSummaryRow = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsLocked")]) != System.DBNull.Value) { column.IsLocked = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("SummaryRenderer")]) != System.DBNull.Value) { column.SummaryRenderer = (string)value; } giGridInitModel.ColumnList.Add(column); #endregion } else { AgentBrokerListModel model = new AgentBrokerListModel(); if ((value = recordSet[recordSet.GetOrdinal("RowNum")]) != System.DBNull.Value) { model.RowNum = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("Id")]) != System.DBNull.Value) { model.Id = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("Code")]) != System.DBNull.Value) { model.Code = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Description")]) != System.DBNull.Value) { model.Description = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Pin")]) != System.DBNull.Value) { model.Pin = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Address")]) != System.DBNull.Value) { model.Address = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Phone")]) != System.DBNull.Value) { model.Phone = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("IsBroker")]) != System.DBNull.Value) { model.IsBroker = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("IsIndMetsarme")]) != System.DBNull.Value) { model.IsIndMetsarme = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("EntityType")]) != System.DBNull.Value) { model.EntityType = (int)value; } if ((value = recordSet[recordSet.GetOrdinal("clrfg")]) != System.DBNull.Value) { model.clrfg = (int)value; } rows.Add(model); } } if (initGrid == true && recordSet.NextResult() && recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("Title")]) != System.DBNull.Value) { giGridInitModel.Title = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Toolbar")]) != System.DBNull.Value) { giGridInitModel.Toolbar = (string)value; } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } if (initGrid == false) { return(rows); } return(giGridInitModel); }
private dynamic dbList(ref int totalRecordCount) { //bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; //bool exportGrid = Request.Query["type"].ToString() == "exportGrid" ? true : false; //bool isUtil = Request.Query["subtype"].ToString() == "isUtil" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string src = Request.Query["src"].ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); DashboardModel dashboardModel = new DashboardModel() { SaxeobaList = new List <SaxeobaModel>(), PieDataList = new List <PieDataModel>(), ActivityList = new List <ActivityModel> (), EntityList = new List <EntityModel>(), PieColorList = new List <PieColorModel>() }; try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetDashboard]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@Src", src); //sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); //sqlCommand.Parameters.AddWithValue("@ExportGrid", exportGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@page", page); sqlCommand.Parameters.AddWithValue("@start", start); sqlCommand.Parameters.AddWithValue("@limit", limit); //sqlCommand.Parameters.AddWithValue("@utilityFilter", Request.Query["query"].ToString()); // when typing in dropdown //sqlCommand.Parameters.AddWithValue("@sort", Request.Query["sort"].ToString()); //sqlCommand.Parameters.AddWithValue("@userDescription", Request.Query["userDescription"].ToString()); //sqlCommand.Parameters.AddWithValue("@userCode", Request.Query["userCode"].ToString()); //SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); //outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; // 1. SaxeobaList while (recordSet.Read()) { dynamic model = new SaxeobaModel(); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": el.SetValue(model, (decimal)value); break; case "DateTime": el.SetValue(model, (DateTime)value); break; } } } dashboardModel.SaxeobaList.Add(model); } // 2. PieChartData recordSet.NextResult(); while (recordSet.Read()) { dynamic model = new PieDataModel(); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": el.SetValue(model, (decimal)value); break; case "DateTime": el.SetValue(model, (DateTime)value); break; } } } dashboardModel.PieDataList.Add(model); } // 3. ActivityData recordSet.NextResult(); while (recordSet.Read()) { dynamic model = new ActivityModel(); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": el.SetValue(model, (decimal)value); break; case "DateTime": el.SetValue(model, (DateTime)value); break; } } } dashboardModel.ActivityList.Add(model); } // 4. Entity recordSet.NextResult(); while (recordSet.Read()) { dynamic model = new EntityModel(); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": el.SetValue(model, (decimal)value); break; case "DateTime": el.SetValue(model, (DateTime)value); break; } } } dashboardModel.EntityList.Add(model); } // 4. Entity recordSet.NextResult(); while (recordSet.Read()) { dynamic model = new PieColorModel(); var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": el.SetValue(model, (decimal)value); break; case "DateTime": el.SetValue(model, (DateTime)value); break; } } } dashboardModel.PieColorList.Add(model); } recordSet.Close(); recordSet.Dispose(); } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(dashboardModel); }
private bool dbIssueSessionToken(ref LoginRequestJson req, ref LoginResponseJson resp) { try { string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); //string passwordEncr = GIxUtils.EncryptString(req.password); using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_IssueSessionToken]"; sqlCommand.Parameters.AddWithValue("@APIKey", req.apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@Username", req.username); sqlCommand.Parameters.AddWithValue("@Password", req.password); SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; if (recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("IsOk")]) != System.DBNull.Value) { resp.success = (bool)value; } if ((value = recordSet[recordSet.GetOrdinal("UniqueID")]) != System.DBNull.Value) { req.salt = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("UserWho")]) != System.DBNull.Value) { resp.userWho = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Email")]) != System.DBNull.Value) { resp.email = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Avatar")]) != System.DBNull.Value) { resp.avatar = (string)value; } if ((value = recordSet[recordSet.GetOrdinal("Version")]) != System.DBNull.Value) { resp.version = (string)value; } resp.user = _loginRequest.username; req.version = resp.version; } recordSet.Close(); recordSet.Dispose(); } } ///// /// JWT Base64 user credentials as sessionvarialbelHas + guid from DB var token = new JwtBuilder() .WithAlgorithm(new HMACSHA256Algorithm()) // symmetric .WithSecret(GIxUtils.DecyptString(_configuration["JWTSecretEncypted"])) .AddClaim("exp", DateTimeOffset.UtcNow.AddDays(1).ToUnixTimeSeconds()) // .AddClaim("LoginRequest", req) .Encode(); //Console.WriteLine(token); resp.token = token; sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { throw new Exception(ex.Message); } if (!resp.success) { throw new Exception("პაროლი ან მომხმარებლის სახელი არასწორად არის შეყვანილი."); } return(resp.success); }
private bool dbCheckAPIKey(ref LoginRequestJson req, ref LoginResponseJson resp) { bool rezult = false; try { string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); //string localHost = HttpContext.Features.Get()?.RemoteIpAddress?.ToString(); //var a = HttpContext.Features.Get(); using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_ChekAPIKey]"; sqlCommand.Parameters.AddWithValue("@APIKey", req.apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@Username", req.username); //sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); //sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; if (recordSet.Read()) { if ((value = recordSet[recordSet.GetOrdinal("IsOk")]) != System.DBNull.Value) { rezult = (bool)value; } } recordSet.Close(); recordSet.Dispose(); } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { throw new Exception(ex.Message); } if (!rezult) { throw new Exception("ავტორიზაციის შეცდომა! Invalid access token."); } return(rezult); }
private dynamic dbGetSignature(ref int totalRecordCount) { bool initGrid = Request.Query["type"].ToString() == "initGrid" ? true : false; string remoteIP = this.HttpContext.Connection.RemoteIpAddress.ToString(); string localIP = this.HttpContext.Connection.LocalIpAddress.ToString(); string page = Request.Query["page"].ToString(); string start = Request.Query["start"].ToString(); string limit = Request.Query["limit"].ToString(); string signatureId = Request.Query["SignatureId"]; SignatureModel model = new SignatureModel(); try { using (SqlConnection sqlConnection = new SqlConnection( GIxUtils.DecodeConnectionString( _configuration, ref _loginRequest, Request.Headers["X-WebGI-Authentication"], Request.Headers["X-WebGI-Version"]))) { sqlConnection.Open(); using (SqlCommand sqlCommand = sqlConnection.CreateCommand()) { sqlCommand.Connection = sqlConnection; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "dbo.[usp_WebGI_GetSignature]"; //sqlCommand.Parameters.AddWithValue("@APIKey", apiKey); sqlCommand.Parameters.AddWithValue("@IP_Local", localIP); sqlCommand.Parameters.AddWithValue("@IP_Remote", remoteIP); sqlCommand.Parameters.AddWithValue("@InitGrid", initGrid); sqlCommand.Parameters.AddWithValue("@Salt", _loginRequest.salt); sqlCommand.Parameters.AddWithValue("@Version", _loginRequest.version); sqlCommand.Parameters.AddWithValue("@SignatureId", signatureId); SqlParameter outputValue = sqlCommand.Parameters.Add("@totalCount", SqlDbType.Int); outputValue.Direction = ParameterDirection.Output; SqlDataReader recordSet = sqlCommand.ExecuteReader(); using (recordSet) { object value; if (recordSet.Read()) { var properties = model.GetType().GetProperties(); foreach (var el in properties) { string name = el.Name; value = recordSet[recordSet.GetOrdinal(name)]; if (value != System.DBNull.Value) { switch (el.PropertyType.Name) { case "Int32": el.SetValue(model, (int)value); break; case "String": el.SetValue(model, (string)value); break; case "Boolean": el.SetValue(model, (bool)value); break; case "Decimal": //case "Nullable'1": el.SetValue(model, (decimal)value); break; } } } } recordSet.Close(); recordSet.Dispose(); if (outputValue.Value != null) { totalRecordCount = (int)outputValue.Value; } } } sqlConnection.Close(); sqlConnection.Dispose(); } } catch (Exception ex) { GIxUtils.Log(ex); throw new Exception(ex.Message); } return(model); }