コード例 #1
0
ファイル: FileController.cs プロジェクト: Ashwin87/OrgSys2017
        public HttpResponseMessage GetClaimFileDataForUser(string Token)
        {
            try
            {
                using (context = new OrgSys2017DataContext())
                {
                    var filters      = context.GetFilteredData(Token, "Document")?.ToList();
                    var userRoleName = context.GetUserRole(Token).FirstOrDefault().RoleName;
                    var qservice     = new QueryService("Claim_Documents", "Document", Token);

                    if (filters == null && userRoleName != "OSIUser")
                    {
                        return(Request.CreateResponse(HttpStatusCode.Forbidden));
                    }

                    var dataView = context.GetPortalPortalDataView(Token, "Document").ToList();
                    var query    = qservice.BuildQuery(dataView, filters);
                    var con      = new Connection();
                    var result   = con.SelectData(query);

                    return(Request.CreateResponse(HttpStatusCode.OK, result));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
コード例 #2
0
        public HttpResponseMessage GetPortalClaimManagerData(string Token, string StatusString, [FromBody] ClaimManagerFieldList Fields)
        {
            try
            {
                var ImportID     = GetClientImportID(Token);
                var employeeID   = context.GetOrgsysEmployeeID(Token).SingleOrDefault()?.OrgsysEmployeeID;
                var filters      = context.GetFilteredData(Token, "Claim").ToList();
                var UserRoleName = context.GetUserRole(Token).FirstOrDefault().RoleName;

                var qservice = new QueryService("OSI_New.os_employees", "Claim", ImportID, Token, employeeID);
                if (StatusString == "open")
                {
                    qservice.WhereClauseQueryList.Add($"OSI_New.os_claims.DateClosed is null "); //part of query, not permission
                    qservice.WhereClauseQueryList.Add($"OSI_New.os_claims.id is not null ");
                }
                else
                {
                    qservice.WhereClauseQueryList.Add($"OSI_New.os_claims.DateClosed is not null "); //part of query, not permission
                }

                if (filters.Count() > 0 || UserRoleName == "OSIUser")        //ensure user has some permissions or is a OSI USer for the client
                {
                    var dataView = context.GetPortalPortalDataView(Token, "Claim").ToList();
                    var query    = qservice.BuildQuery(dataView, filters);

                    using (MySqlCommand command = new MySqlCommand(query, OrgsysdbConn))
                    {
                        command.CommandType = CommandType.Text;
                        OrgsysdbConn.Open();
                        MySqlDataAdapter da = new MySqlDataAdapter(command);
                        DataTable        dt = new DataTable();
                        da.Fill(dt);
                        OrgsysdbConn.Close();

                        return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(dt, Formatting.None)));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }