public DataSet getAuthData(authRequest authObj) { DataSet ds = new DataSet(); paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDB); DataOperation DO = new DataOperation(dbCon); sp_AuthCheck authCheck = new sp_AuthCheck(); authCheck.uName = authObj.name; authCheck.pwd = authObj.password; authCheck.action = "select"; DO.BeginTRansaction(); ds = DO.iteratePropertyObjectsSP(authCheck, "sp_AuthCheck"); DO.EndTRansaction(); } catch (Exception ex) { var st = new StackTrace(); var sf = st.GetFrame(0); string currentMethodName = sf.GetMethod().Name; Exception customex = new Exception(currentMethodName + " | " + this.GetType().Name + " | " + ex.Message + " : " + ex.StackTrace); throw customex; } return(ds); }
public string LogResponse(string className, string methodName, string response, string workflow, string tui) { paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDBLog); DataOperation DO = new DataOperation(dbCon); RequestLog log = new RequestLog(); log.ClassName = className; // this.GetType().Name; log.MethodName = methodName; log.Request = ""; log.Response = response; log.TUI = tui; log.IP = IP; log.WorkFlow = workflow; DO.BeginTRansaction(); int result = DO.iteratePropertyObjectsAndInsert(log, "requestLog", false); DO.EndTRansaction(); return("success"); } catch (Exception) { return("fail"); } }
public string getEntityStructure(string Name, string ConnectionName, string type) { string resultStructure = ""; paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(ConnectionName); DataOperation DO = new DataOperation(dbCon); DO.BeginTRansaction(); if (type == "SP") { resultStructure = resultStructure = DO.getSPStructure(Name); } else if (type == "TBL") { resultStructure = resultStructure = DO.getEntityStructure(Name); } DO.EndTRansaction(); } catch (Exception ex) { Exception exec = new Exception("getEntityStructure | " + this.GetType().Name + " | " + ex.Message + " : " + ex.StackTrace); throw exec; } return(resultStructure); }
public int ProcessInsertEntity(department entityObject) { int result = 0; string TableName = "department"; string skipAttributes = "DepartmentId,CreatedDate,ModifiedDate,"; paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDB); DataOperation DO = new DataOperation(dbCon); DO.BeginTRansaction(); entityObject.RecordStatus = 0; result = DO.iteratePropertyObjectsAndInsert(entityObject, TableName, true, skipAttributes); DO.EndTRansaction(); result = 1; } catch (Exception ex) { var st = new StackTrace(); var sf = st.GetFrame(0); string currentMethodName = sf.GetMethod().Name; currentMethodName = ex.Message.ToString().Split('|').Count() > 0 ? ex.Message.ToString().Split('|')[0] : currentMethodName; string currentControllerName = ex.Message.ToString().Split('|').Count() > 1 ? ex.Message.ToString().Split('|')[1] : this.GetType().Name; Exception customex = new Exception(currentMethodName + " | " + currentControllerName + " | " + ex.Message + " : " + ex.StackTrace); throw customex; } return(result); }
public int DeleteTheData(department entityObject) { DataSet ds = new DataSet(); paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDB); DataOperation DO = new DataOperation(dbCon); sp_manageDepartment spParams = new sp_manageDepartment(); spParams.depName = entityObject.DepartmentName; spParams.depCode = entityObject.DepartmentCode; spParams.depId = entityObject.DepartmentId; spParams.userID = entityObject.CreatedUser; spParams.action = "Delete"; spParams.operation = "D"; DO.BeginTRansaction(); ds = DO.iteratePropertyObjectsSP(spParams, "sp_manageDepartment"); DO.EndTRansaction(); } catch (Exception ex) { var st = new StackTrace(); var sf = st.GetFrame(0); string currentMethodName = sf.GetMethod().Name; currentMethodName = ex.Message.ToString().Split('|').Count() > 0 ? ex.Message.ToString().Split('|')[0] : currentMethodName; string currentControllerName = ex.Message.ToString().Split('|').Count() > 1 ? ex.Message.ToString().Split('|')[1] : this.GetType().Name; Exception customex = new Exception(currentMethodName + " | " + currentControllerName + " | " + ex.Message + " : " + ex.StackTrace); throw customex; } return(Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString())); }
public bool CheckTheDataExistance(department entityObject) { bool result = false; DataSet ds = new DataSet(); paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDB); DataOperation DO = new DataOperation(dbCon); sp_manageDepartment spParams = new sp_manageDepartment(); spParams.depName = entityObject.DepartmentName; spParams.depCode = entityObject.DepartmentCode; spParams.depId = 0; spParams.action = "select"; spParams.operation = "S"; DO.BeginTRansaction(); ds = DO.iteratePropertyObjectsSP(spParams, "sp_manageDepartment"); if (ds != null && ds.Tables != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { result = true; } DO.EndTRansaction(); } catch (Exception ex) { var st = new StackTrace(); var sf = st.GetFrame(0); string currentMethodName = sf.GetMethod().Name; currentMethodName = ex.Message.ToString().Split('|').Count() > 0 ? ex.Message.ToString().Split('|')[0] : currentMethodName; string currentControllerName = ex.Message.ToString().Split('|').Count() > 1 ? ex.Message.ToString().Split('|')[1] : this.GetType().Name; Exception customex = new Exception(currentMethodName + " | " + currentControllerName + " | " + ex.Message + " : " + ex.StackTrace); throw customex; } return(result); }
public string LogError(string className, string methodName, string remarks, string tui) { paramFile PF = new paramFile(ParamsPath); try { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDBLog); DataOperation DO = new DataOperation(dbCon); ErrorLog log = new ErrorLog(); log.ClassName = className; // this.GetType().Name; log.MethodName = methodName; log.Remarks = remarks; log.TUI = tui; log.IP = IP; DO.BeginTRansaction(); int result = DO.iteratePropertyObjectsAndInsert(log, "errorlog", false); DO.EndTRansaction(); return("success"); } catch (Exception) { return("fail"); } }
public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext) { BaseResponse resObj = new BaseResponse(); resObj.code = "401"; resObj.message = "Un-Authorized"; resObj.tui = ""; resObj.signature = ""; try { if (actionContext.Request.Headers.Authorization != null) { string path = @System.Configuration.ConfigurationManager.AppSettings["params"]; paramFile PF = new paramFile(path); string authString = actionContext.Request.Headers.Authorization.Parameter; ManagedAesSample MAS = new ManagedAesSample(); string dec = MAS.DecryptData(authString, PF.getKey(DBConstants.Token)); if (dec.Split('|').Length >= 3) { if ((DateTime.Now - DateTime.Parse(dec.Split('|')[2].ToString())).TotalMinutes <= 20) { string dbCon = PF.getDatabaseConnectionString(DBConstants.MainDB); DataOperation DO = new DataOperation(dbCon); sp_AuthCheck authCheck = new sp_AuthCheck(); authCheck.uName = dec.Split('|')[0]; authCheck.pwd = dec.Split('|')[1]; authCheck.action = "select"; DO.BeginTRansaction(); DataSet ds = DO.iteratePropertyObjectsSP(authCheck, "sp_AuthCheck"); if (ds == null || ds.Tables == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized, resObj); } else { string enc = MAS.EncryptData(authCheck.uName + "|" + authCheck.pwd + "|" + DateTime.Now.ToString() + "|" + ds.Tables[0].Rows[0]["UserId"].ToString(), PF.getKey(DBConstants.Token)); AuthenticationHeaderValue headerValues = new AuthenticationHeaderValue(actionContext.Request.Headers.Authorization.Scheme, enc); actionContext.Request.Headers.Authorization = headerValues; } DO.EndTRansaction(); } else { actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized, resObj); } } else { actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized, resObj); } } else { actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized, resObj); } } catch (Exception) { actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized, resObj); } // actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized); }