Ejemplo n.º 1
0
        public void SetExceptionLog(string api_key, ExceptionObj objParam, out int ReturnVal, out string ReturnMsg)
        {
            try
            {
                List <DBParameter> pList = new List <DBParameter>();
                pList.Add(new DBParameter("studio_id", SqlDbType.BigInt, 0, ParameterDirection.Input, objParam.studio_id));
                pList.Add(new DBParameter("api_key", SqlDbType.VarChar, 255, ParameterDirection.Input, api_key));
                pList.Add(new DBParameter("excp_message", SqlDbType.VarChar, 50000, ParameterDirection.Input, objParam.excp_message));
                pList.Add(new DBParameter("excp_source", SqlDbType.VarChar, 50000, ParameterDirection.Input, objParam.excp_source));
                pList.Add(new DBParameter("target_site", SqlDbType.VarChar, 50000, ParameterDirection.Input, objParam.target_site));
                pList.Add(new DBParameter("stack_trace", SqlDbType.VarChar, 50000, ParameterDirection.Input, objParam.stack_trace));
                pList.Add(new DBParameter("inner_exception", SqlDbType.VarChar, 50000, ParameterDirection.Input, objParam.inner_exception));
                pList.Add(new DBParameter("form_name", SqlDbType.VarChar, 1000, ParameterDirection.Input, objParam.form_name));
                pList.Add(new DBParameter("page_url", SqlDbType.VarChar, 1000, ParameterDirection.Input, objParam.page_url));
                pList.Add(new DBParameter("inserted_by_uid", SqlDbType.BigInt, 0, ParameterDirection.Input, objParam.inserted_by_uid));
                pList.Add(new DBParameter("ReturnVal", SqlDbType.Int, 0, ParameterDirection.Output, 0));
                pList.Add(new DBParameter("ReturnMsg", SqlDbType.VarChar, 50000, ParameterDirection.Output, ""));

                objDAO = new DAO(_constr);
                objDAO.ExecuteNonQuery("dbo.Set_EXCEPTION_LOG", DAO.QueryType.StoredProcedure, pList, out ReturnVal, out ReturnMsg);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public IActionResult Commit([FromRoute] string RegistryKey, [FromRoute] string ApiKey, [FromBody] object ParamJson)
        {
            IActionResult  response;
            CommitResponse resp = new CommitResponse();

            try
            {
                #region Call Set_Data

                string Parameters = ParamJson == null ? null : ParamJson.ToString();

                RoutineDAO ObjResponseDAO = new RoutineDAO(_ConStr);

                int    ReturnVal;
                string ReturnMsg;

                string objParams = JsonConvert.SerializeObject(ParamJson);

                ObjResponseDAO.SetData(RegistryKey, ApiKey, Parameters, out ReturnVal, out ReturnMsg);

                if (ReturnVal == 1)
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.Success;
                    resp.message    = "success";

                    response = Ok(resp);
                }
                else
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.SqlException;
                    resp.message    = ReturnMsg;

                    response = Conflict(resp);
                }

                #endregion
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "RoutineController";
                exobj.page_url  = "api/Routine/Commit";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Ejemplo n.º 3
0
        public IActionResult SetBody([FromRoute] string ApiKey, [FromBody] SetBodyObj Param)
        {
            IActionResult  response;
            CommitResponse resp = new CommitResponse();

            try
            {
                #region Call Set_Data

                BodyDAO ObjResponseDAO = new BodyDAO(_ConStr);

                string parameters = JsonConvert.SerializeObject(Param);

                int    ReturnVal;
                string ReturnMsg;

                ObjResponseDAO.SetBody(ApiKey, Param.studio_id, parameters, out ReturnVal, out ReturnMsg);

                if (ReturnVal == 1)
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.Success;
                    resp.message    = "success";

                    response = Ok(resp);
                }
                else
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.SqlException;
                    resp.message    = ReturnMsg;

                    response = Conflict(resp);
                }

                #endregion
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "BodyController";
                exobj.page_url  = "api/Body/SetBody";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Ejemplo n.º 4
0
        public IActionResult FetchStudioConfig([FromRoute] string ApiKey, [FromBody] StudioConfigObj Obj)
        {
            IActionResult response;
            StudioConfig  resp = new StudioConfig();

            StudioDAO ObjResponseDAO = new StudioDAO(_ConStr);

            //Func<DataTable> funcGetSettings = () => ObjResponseDAO.FetchStudioConfig();
            //DataTable dt = CacheHelper.Get(funcGetSettings, "SITE_SETTING", "100002", "", false);

            try
            {
                DataSet ds = ObjResponseDAO.FetchStudioConfig(ApiKey, Obj);

                Studio st = new Studio();
                st.studio_id     = int.Parse(ds.Tables[0].Rows[0]["studio_id"].ToString());
                st.api_key       = ds.Tables[0].Rows[0]["studio_id"].ToString();
                st.lg_logo_name  = ds.Tables[0].Rows[0]["lg_logo_name"].ToString();
                st.md_logo_name  = ds.Tables[0].Rows[0]["md_logo_name"].ToString();
                st.sm_logo_name  = ds.Tables[0].Rows[0]["sm_logo_name"].ToString();
                st.fav_icon_name = ds.Tables[0].Rows[0]["fav_icon_name"].ToString();

                GeneralSetting gs = new GeneralSetting();
                gs.studio_id    = int.Parse(ds.Tables[1].Rows[0]["studio_id"].ToString());
                gs.studio_name  = ds.Tables[1].Rows[0]["studio_name"].ToString();
                gs.studio_title = ds.Tables[1].Rows[0]["studio_title"].ToString();

                resp.statuscode      = (int)Common.ResponseStatusCode.Success;
                resp.message         = "success";
                resp.studio          = st;
                resp.general_setting = gs;

                response = Ok(resp);
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "StudioController";
                exobj.page_url  = "api/Studio/FetchStudioConfig";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
        public IActionResult GenerateNewApiToken([FromRoute] string ApiKey, [FromBody] UserObj obj)
        {
            IActionResult        response = Unauthorized();
            UserApiTokenResponse resp     = new UserApiTokenResponse();

            try
            {
                UserJwt uj = GenerateJSONWebToken();

                int    ReturnVal;
                string ReturnMsg;

                UserApiTokenObj utj = new UserApiTokenObj();
                utj.user_id      = obj.user_id;
                utj.api_token    = uj.token_String;
                utj.token_expiry = uj.expiry;

                SetUserApiToken(ApiKey, utj, out ReturnVal, out ReturnMsg);

                if (ReturnVal == 1)
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.Success;
                    resp.message    = "success";
                    resp.api_token  = uj.token_String;
                    response        = Ok(resp);
                }
                else
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.SqlException;
                    resp.message    = ReturnMsg;
                    response        = Conflict(resp);
                }
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "AuthentcationController";
                exobj.page_url  = "api/Authentication/GenerateNewApiToken";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Ejemplo n.º 6
0
        public ExceptionObj GetExceptionObjBase(Exception ex)
        {
            ExceptionObj exobj = new ExceptionObj();

            exobj.excp_message    = ex.Message;
            exobj.excp_source     = ex.Source == null ? "" : ex.Source;
            exobj.stack_trace     = ex.StackTrace == null ? "" : ex.StackTrace;
            exobj.inner_exception = ex.InnerException == null ? "" : ex.InnerException.Message;
            exobj.target_site     = ex.TargetSite == null ? "" : ex.TargetSite.Name;

            return(exobj);
        }
Ejemplo n.º 7
0
        public IActionResult FetchLookup([FromRoute] string ApiKey, [FromBody] LookupObj Param)
        {
            IActionResult  response;
            LookupResponse resp = new LookupResponse();

            try
            {
                #region Call Get_Data_Set

                LookupDAO ObjResponseDAO = new LookupDAO(_ConStr);
                DataSet   ds             = ObjResponseDAO.FetchLookup(ApiKey, Param);

                #endregion

                var lookups = (from r in ds.Tables[0].AsEnumerable()
                               select new Lookup()
                {
                    lookup_id = r.Field <int>("lookup_id"),
                    lookup_code = r.Field <string>("lookup_code"),
                    lookup_description = r.Field <string>("lookup_description"),
                    lookup_name = r.Field <string>("lookup_name")
                }).ToList();


                resp.statuscode = (int)Common.ResponseStatusCode.Success;
                resp.message    = "success";
                resp.rows       = lookups;

                response = Ok(resp);
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "BodyController";
                exobj.page_url  = "api/Body/List";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Ejemplo n.º 8
0
        public IActionResult FetchBodyList([FromRoute] string ApiKey, [FromBody] BodyListObj Param)
        {
            IActionResult response;
            ListResponse  resp = new ListResponse();

            try
            {
                #region Call Get_Data_Set

                BodyDAO ObjResponseDAO = new BodyDAO(_ConStr);

                string parameters = JsonConvert.SerializeObject(Param);

                DataSet ds = ObjResponseDAO.FetchBodyList(ApiKey, Param.studio_id, parameters);

                #endregion

                resp.statuscode = (int)Common.ResponseStatusCode.Success;
                resp.message    = "success";
                resp.columns    = Regex.Unescape(JsonConvert.SerializeObject(ds.Tables[0]).Replace(@"\", ""));
                resp.rows       = Regex.Unescape(JsonConvert.SerializeObject(ds.Tables[1]).Replace(@"\", ""));

                response = Ok(resp);
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "BodyController";
                exobj.page_url  = "api/Body/FetchBodyList";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
Ejemplo n.º 9
0
        public IActionResult Collection([FromRoute] string RegistryKey, [FromRoute] string ApiKey, [FromBody] object ParamJson)
        {
            IActionResult response;
            ListResponse  resp = new ListResponse();

            try
            {
                #region Call Get_Data_Set

                string Parameters = ParamJson == null ? null : ParamJson.ToString();

                RoutineDAO ObjResponseDAO = new RoutineDAO(_ConStr);
                DataSet    ds             = ObjResponseDAO.GetData(RegistryKey, ApiKey, Parameters);

                #endregion

                resp.statuscode = (int)Common.ResponseStatusCode.Success;
                resp.message    = "success";
                resp.columns    = Regex.Unescape(JsonConvert.SerializeObject(ds.Tables[0]).Replace(@"\", ""));
                resp.rows       = Regex.Unescape(JsonConvert.SerializeObject(ds.Tables[1]).Replace(@"\", ""));

                response = Ok(resp);
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "RoutineController";
                exobj.page_url  = "api/Routine/Collection";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }
        public IActionResult AuthorizationToken([FromRoute] string ApiKey, [FromBody] LoginObj obj)
        {
            IActionResult response          = Unauthorized();
            UserAuthenticationResponse resp = new UserAuthenticationResponse();

            try
            {
                DataSet ds;
                int     ReturnVal;
                string  ReturnMsg;

                var IsAuth = AuthenticateApiCaller(ApiKey, obj, out ds, out ReturnVal, out ReturnMsg);

                if (IsAuth)
                {
                    var tokenString = "";
                    if (String.IsNullOrEmpty(ds.Tables[0].Rows[0]["active_api_token"].ToString()))
                    {
                        UserJwt uj = GenerateJSONWebToken();
                        tokenString = uj.token_String;

                        int    ReturnVal_utj;
                        string ReturnMsg_utj;

                        UserApiTokenObj utj = new UserApiTokenObj();
                        utj.user_id      = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                        utj.api_token    = uj.token_String;
                        utj.token_expiry = uj.expiry;

                        SetUserApiToken(ApiKey, utj, out ReturnVal_utj, out ReturnMsg_utj);

                        if (ReturnVal_utj != 1)
                        {
                            resp.statuscode = (int)Common.ResponseStatusCode.SqlException;
                            resp.message    = ReturnMsg_utj;
                            response        = Conflict(resp);

                            return(response);
                        }
                    }
                    else
                    {
                        tokenString = ds.Tables[0].Rows[0]["active_api_token"].ToString();
                    }

                    resp.statuscode = (int)Common.ResponseStatusCode.Success;
                    resp.message    = "success";
                    resp.user_id    = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                    resp.studio_id  = int.Parse(ds.Tables[0].Rows[0]["studio_id"].ToString());
                    resp.full_name  = ds.Tables[0].Rows[0]["full_name"].ToString();
                    resp.api_key    = ds.Tables[0].Rows[0]["api_key"].ToString();
                    resp.api_token  = tokenString;

                    response = Ok(resp);
                }
                else
                {
                    resp.statuscode = (int)Common.ResponseStatusCode.ValidationException;
                    resp.message    = ReturnMsg;
                    response        = Unauthorized(resp);
                }
            }
            catch (Exception ex)
            {
                Common       c     = new Common();
                ExceptionObj exobj = c.GetExceptionObjBase(ex);
                exobj.form_name = "AuthentcationController";
                exobj.page_url  = "api/Authentication/AuthorizationToken";

                int    ReturnVal;
                string ReturnMsg;

                ExceptionDAO exd = new ExceptionDAO(_ConStr);
                exd.SetExceptionLog(ApiKey, exobj, out ReturnVal, out ReturnMsg);

                resp.statuscode = (int)Common.ResponseStatusCode.Exception;
                resp.message    = ex.Message.ToString();

                response = BadRequest(resp);
            }

            return(response);
        }