Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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()));
        }
Esempio n. 4
0
        private string DecryptAuthData(string encData)
        {
            string           decData = "";
            paramFile        PF      = new paramFile(ParamsPath);
            ManagedAesSample MAS     = new ManagedAesSample();

            try
            {
                decData = MAS.DecryptData(encData, PF.getKey(DBConstants.Token));
            }
            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(decData);
        }
Esempio n. 5
0
        public string getEncryptData(string decString, string decType)
        {
            ManagedAesSample MAS     = new ManagedAesSample();
            paramFile        PF      = new paramFile(ParamsPath);
            string           encData = "";

            try
            {
                encData = MAS.EncryptData(decString, PF.getKey(decType));
            }
            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(encData);
        }
Esempio n. 6
0
        public string getSignature(string userCredentials)
        {
            string encCredentials = "";

            try
            {
                paramFile        PF  = new paramFile(ParamsPath);
                string           key = PF.getKey(DBConstants.Token);
                ManagedAesSample aes = new ManagedAesSample();
                encCredentials = aes.EncryptData(userCredentials, key);
            }
            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(encCredentials);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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");
            }
        }
Esempio n. 9
0
        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);
        }