Beispiel #1
0
        //here's my parameters for the filtered hwms and data files i want
        //GET:
        public PartialViewResult FilteredApprovals(FormCollection fc)
        {
            try
            {
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;

                string eventId   = fc["EVENT_ID"];
                string StateName = fc["STATE_NAME"];
                string MemberId  = fc["MEMBER_ID"];

                var request = new RestRequest();
                request.Resource    = "/HWMS?IsApproved={approved}&Event={eventId}&TeamMember={memberId}&State={state}";
                request.RootElement = "ArrayOfHWM";
                request.AddParameter("approved", false, ParameterType.UrlSegment);
                request.AddParameter("eventId", eventId, ParameterType.UrlSegment);
                request.AddParameter("memberId", MemberId, ParameterType.UrlSegment);
                request.AddParameter("state", StateName, ParameterType.UrlSegment);
                HWMList theResultingHWMs = serviceCaller.Execute <HWMList>(request);

                List <FilteredApprovals.hwmApproval> Listhwm = new List <FilteredApprovals.hwmApproval>();

                //populate model for display
                if (theResultingHWMs != null && theResultingHWMs.HWMs.Count() > 0)
                {
                    foreach (SimpleHWM h in theResultingHWMs.HWMs)
                    {
                        FilteredApprovals.hwmApproval hwmApproval = new FilteredApprovals.hwmApproval();
                        hwmApproval.HWM_ID  = h.HWM_ID;
                        hwmApproval.ELEV_FT = h.ELEV_FT;
                        hwmApproval.SiteNo  = h.SITE_NO;
                        Listhwm.Add(hwmApproval);
                    }
                    ViewData["hwmList"] = Listhwm;
                }

                request             = new RestRequest();
                request.Resource    = "/DataFiles?IsApproved={approved}&Event={eventId}&Processor={memberId}&State={state}";
                request.RootElement = "ArrayOfDATA_FILE";
                request.AddParameter("approved", false, ParameterType.UrlSegment);
                request.AddParameter("eventId", eventId, ParameterType.UrlSegment);
                request.AddParameter("memberId", MemberId, ParameterType.UrlSegment);
                request.AddParameter("state", StateName, ParameterType.UrlSegment);
                List <DATA_FILE> theResultingDFs = serviceCaller.Execute <List <DATA_FILE> >(request);

                List <FilteredApprovals.dataFileApproval> ListDFs = new List <FilteredApprovals.dataFileApproval>();
                if (theResultingDFs != null && theResultingDFs.Count() > 0)
                {
                    foreach (DATA_FILE df in theResultingDFs)
                    {
                        FilteredApprovals.dataFileApproval dfApproval = new FilteredApprovals.dataFileApproval();
                        dfApproval.DF_ID    = df.DATA_FILE_ID;
                        dfApproval.Inst_ID  = df.INSTRUMENT_ID;
                        request             = new RestRequest();
                        request.Resource    = "Instruments/{entityId}";
                        request.RootElement = "INSTRUMENT";
                        request.AddParameter("entityId", df.INSTRUMENT_ID, ParameterType.UrlSegment);
                        INSTRUMENT thisInstrument = serviceCaller.Execute <INSTRUMENT>(request);

                        request             = new RestRequest();
                        request.Resource    = "/SensorTypes/{entityId}";
                        request.RootElement = "SENSOR_TYPE";
                        request.AddParameter("entityId", thisInstrument.SENSOR_TYPE_ID, ParameterType.UrlSegment);
                        dfApproval.SensorType = serviceCaller.Execute <SENSOR_TYPE>(request).SENSOR;

                        request             = new RestRequest();
                        request.Resource    = "Sites/{entityId}";
                        request.RootElement = "SITE";
                        request.AddParameter("entityId", thisInstrument.SITE_ID, ParameterType.UrlSegment);
                        dfApproval.SiteNo = serviceCaller.Execute <SITE>(request).SITE_NO;
                        ListDFs.Add(dfApproval);
                    }

                    ViewData["dataFileList"] = ListDFs;
                }

                return(PartialView());
            }
            catch (Exception e)
            {
                return(PartialView("../Shared/Error", e));
            }
        }
Beispiel #2
0
        //This function is now hidden on the page...GET all the hwms and data files that need to be approved
        public PartialViewResult ShowAllApproval()
        {
            try
            {
                STNServiceCaller serviceCaller = STNServiceCaller.Instance;
                var request = new RestRequest();

                request.Resource    = "/HWMs?IsApproved={boolean}";
                request.RootElement = "ArrayOfHWMs";
                request.AddParameter("boolean", false, ParameterType.UrlSegment);
                List <HWM> allHWMs = serviceCaller.Execute <List <HWM> >(request);

                List <FilteredApprovals.hwmApproval> Listhwm = new List <FilteredApprovals.hwmApproval>();
                //populate model for display
                foreach (HWM h in allHWMs)
                {
                    FilteredApprovals.hwmApproval hwmApproval = new FilteredApprovals.hwmApproval();
                    hwmApproval.HWM_ID  = h.HWM_ID;
                    hwmApproval.ELEV_FT = h.ELEV_FT;

                    request             = new RestRequest();
                    request.Resource    = "Sites/{entityId}";
                    request.RootElement = "SITE";
                    request.AddParameter("entityId", h.SITE_ID, ParameterType.UrlSegment);
                    SITE thisOne = serviceCaller.Execute <SITE>(request);
                    hwmApproval.SiteNo = thisOne != null ? thisOne.SITE_NO : "";

                    Listhwm.Add(hwmApproval);
                }
                ViewData["hwmList"] = Listhwm;

                request             = new RestRequest();
                request.Resource    = "/DataFiles?IsApproved={boolean}";
                request.RootElement = "ArrayOfDATA_FILE";
                request.AddParameter("boolean", false, ParameterType.UrlSegment);
                List <DATA_FILE> allDFs = serviceCaller.Execute <List <DATA_FILE> >(request);
                List <FilteredApprovals.dataFileApproval> ListDFs = new List <FilteredApprovals.dataFileApproval>();

                foreach (DATA_FILE df in allDFs)
                {
                    FilteredApprovals.dataFileApproval dfApproval = new FilteredApprovals.dataFileApproval();
                    dfApproval.DF_ID   = df.DATA_FILE_ID;
                    dfApproval.Inst_ID = df.INSTRUMENT_ID;

                    request             = new RestRequest();
                    request.Resource    = "Instruments/{entityId}";
                    request.RootElement = "INSTRUMENT";
                    request.AddParameter("entityId", df.INSTRUMENT_ID, ParameterType.UrlSegment);
                    INSTRUMENT thisInstrument = serviceCaller.Execute <INSTRUMENT>(request);

                    if (thisInstrument != null)
                    {
                        request             = new RestRequest();
                        request.Resource    = "/SensorTypes/{entityId}";
                        request.RootElement = "SENSOR_TYPE";
                        request.AddParameter("entityId", thisInstrument.SENSOR_TYPE_ID, ParameterType.UrlSegment);
                        dfApproval.SensorType = serviceCaller.Execute <SENSOR_TYPE>(request).SENSOR;

                        request             = new RestRequest();
                        request.Resource    = "Sites/{entityId}";
                        request.RootElement = "SITE";
                        request.AddParameter("entityId", thisInstrument.SITE_ID, ParameterType.UrlSegment);
                        SITE thisOne = serviceCaller.Execute <SITE>(request);
                        dfApproval.SiteNo = thisOne != null ? thisOne.SITE_NO : "";
                    }
                    ListDFs.Add(dfApproval);
                }

                ViewData["dataFileList"] = ListDFs;

                return(PartialView("FilteredApprovals"));
            }
            catch (Exception e)
            {
                return(PartialView("../Shared/Error", e));
            }
        }