コード例 #1
0
ファイル: GuestController.cs プロジェクト: cssuarez/DocStar
        private mvc.ActionResult CreateDocumentAndRedirect(ProxyAuthRequestResult req, JObject jArgs, Guid instanceId)
        {
            var fSvc = SvcBldr.FormsV2();
            var cdsr = fSvc.CreateDocument(new FormDocumentCreateArgs
            {
                IsTemporary    = true,
                FormTemplateId = new Guid(jArgs["FormTemplateId"].Value <string>()) //Convert failure when .Value<Guid> is used.
            });

            ExceptionsML.Check(cdsr.Error);
            var vrId = Functions.NewSeq();

            jArgs["DocumentVersionId"] = cdsr.Result.Version.Id;
            jArgs["FormRequestId"]     = req.Id;
            jArgs["ViewRequestId"]     = vrId;
            jArgs["UseRecaptcha"]      = false;
            ExceptionsML.Check(cdsr.Error);
            var secSvc    = SvcBldr.SecurityV2();
            var viewerCPR = new ProxyAuthRequest
            {
                Id              = vrId,
                ExpirationType  = ExpirationMode.CustomCount,
                ExpirationValue = "1", //Expires as soon as the form is submitted.
                RequestType     = ProxyAuthRequestType.AccessViewer,
                Token           = req.Token,
                Parameters      = JsonConvert.SerializeObject(jArgs)
            };
            var cprSR = secSvc.CreateProxyRequest(viewerCPR);

            ExceptionsML.Check(cprSR.Error);
            var fsc = GuestSessionCookie.Create(Response, cprSR.Result, instanceId, req.Id);

            return(RedirectToAction("Index", fsc));
        }
コード例 #2
0
ファイル: GuestViewerModel.cs プロジェクト: cssuarez/DocStar
      internal void Load(string baseUri, ProxyAuthRequestResult par)
      {
          _svcBldr.Token = par.Token;
          EncryptedToken = par.Token;
          Options        = par.Arguments;

          var svc = _svcBldr.BulkDataV2();
          var sr  = svc.GetBulkGuestData();

          ExceptionsML.Check(sr.Error);
          var result = sr.Result;

          BulkData = JsonConvert.SerializeObject(sr);
          if (result.LicenseTokens != null)
          {
              Licenses = new List <TokenKey>((result.LicenseTokens));
          }

          User        = result.CurrentUser;
          CurrentUser = JsonConvert.SerializeObject(new { Name = result.CurrentUser.Username, Id = result.CurrentUser.Id });
          CompanyName = result.CompanyName;

          HttpRuntimeSection httpRuntimeSection = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;

          MaxRequestLength  = httpRuntimeSection.MaxRequestLength;
          IsReadOnlyUser    = result.CurrentUser.ReadOnlyUser;
          Version           = Functions.GetVersion();
          SystemPreferences = JsonConvert.SerializeObject(result.CompanySettings);
          var views = GetCachedViews(baseUri);

          CommonTemplates = JsonConvert.SerializeObject(views);
      }
コード例 #3
0
ファイル: GuestController.cs プロジェクト: cssuarez/DocStar
        public System.Web.Mvc.ActionResult Kiosk()
        {
            try
            {
                var kioskId    = Request.QueryString["Id"];
                var instanceId = Request.QueryString["IId"];
                var machineId  = Request.QueryString["MId"];

                if (String.IsNullOrWhiteSpace(kioskId) || String.IsNullOrWhiteSpace(instanceId) || String.IsNullOrWhiteSpace(machineId))
                {
                    throw new Exception(Constants.i18n("invalidRequest"));
                }

                SvcBldr.Source = "GuestRequest";
                var userSvc = SvcBldr.UserV2();
                var sr      = userSvc.LogInKiosk(new KioskLoginArgs {
                    Id = kioskId, InstanceId = new Guid(instanceId)
                });
                ExceptionsML.Check(sr.Error);
                SignIn(sr.Result.Token, sr.Result.CurrentUser, false);

                var url = String.Format("{0}://{1}/{2}#Capture/{3}", Request.Url.Scheme, Request.Url.Host, Request.ApplicationPath, machineId);
                return(Redirect(url));
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }
コード例 #4
0
        public System.Web.Mvc.ActionResult AddAttachment(FormCollection form)
        {
            try
            {
                var f = SvcBldr.FileTransferV2();
                foreach (string item in Context.Request.Files)
                {
                    var file = Context.Request.Files.Get(item);
                    if (String.IsNullOrEmpty(file.FileName))
                    {
                        continue;
                    }

                    f.UploadFile(String.Format(@"{0}\{1}", AstriaCookie.GetUserId(), Path.GetFileName(file.FileName)), file.InputStream);
                }

                var sr = f.GetFileInSubDirectory(AstriaCookie.GetUserId().ToString());
                ExceptionsML.Check(sr.Error);
                return(View(sr.Result));
            }
            catch (Exception ex)
            {
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
            }
        }
コード例 #5
0
ファイル: ReportViewer.aspx.cs プロジェクト: cssuarez/DocStar
        private ReportPackage GetReportPackage()
        {
            var reportSvc = _sb.ReportingV2();
            var rptSR     = reportSvc.Get(_reportId);

            ExceptionsML.Check(rptSR.Error);
            return(rptSR.Result);
        }
コード例 #6
0
        private static void ValidatePasswordFillModelProxyRequest(ProxyAuthRequestResult par, GuestChallengeModel model, HttpRequestBase request, ServiceBuilder svcBldr)
        {
            var pass = request.Form["password"];
            var svc  = svcBldr.SecurityV2();

            if (par.HasPassword && !String.IsNullOrWhiteSpace(pass)) //Has a password and one has been provided by the user
            {
                var pwSR = svc.GetProxyRequest(new GetProxyRequestArgs {
                    Id = par.Id, InstanceId = par.InstanceId, Password = pass
                });
                if (pwSR.Error != null)
                {
                    model.ErrorMessages.Add(pwSR.Error.Message);
                    model.ShowPassword = true;
                }
                else
                {
                    model.ProxyRequest = pwSR.Result;
                }
            }
            else if (!par.HasPassword && !model.ShowRecaptcha) //Does not have a password and is not showing the recaptcha, get the full ProxyAuthRequest (decrements counts, returns a restricted token).
            {
                var prSR = svc.GetProxyRequest(new GetProxyRequestArgs {
                    Id = par.Id, InstanceId = par.InstanceId, Password = pass
                });
                if (prSR.Error != null)
                {
                    if (prSR.Error.Type == typeof(ProxyAuthRequestExpiredException).ToString())
                    {
                        switch (par.RequestType)
                        {
                        case ProxyAuthRequestType.DownloadFiles:
                            throw new Exception(Constants.i18n("downloadFilesProxyRequestExpired"));

                        case ProxyAuthRequestType.AccessViewer:
                            throw new Exception(Constants.i18n("accessViewerProxyRequestExpired"));

                        case ProxyAuthRequestType.CreateForm:
                            throw new Exception(Constants.i18n("createFormProxyRequestExpired"));

                        default:
                            ExceptionsML.Check(prSR.Error);
                            break;
                        }
                    }
                    ExceptionsML.Check(prSR.Error);
                }
                model.ProxyRequest = prSR.Result;
            }
            else //Has a password and it has not been filled out yet or is showing recaptcha
            {
                model.ProxyRequest = par;
                model.ShowPassword = par.HasPassword;
            }
        }
コード例 #7
0
ファイル: ReportViewer.aspx.cs プロジェクト: cssuarez/DocStar
        private XElement GetReportDefinition()
        {
            var reportSvc = _sb.ReportingV2();
            var rSR       = reportSvc.GetRdlc(_reportId);

            ExceptionsML.Check(rSR.Error);
            var reportStream = new MemoryStream(rSR.Result);

            ReportViewer1.LocalReport.LoadReportDefinition(reportStream);
            ReportViewer1.LocalReport.DataSources.Clear();
            reportStream.Seek(0, SeekOrigin.Begin);
            return(XElement.Load(reportStream));
        }
コード例 #8
0
 public System.Web.Mvc.ActionResult AddAttachment()
 {
     try
     {
         var f  = SvcBldr.FileTransferV2();
         var sr = f.GetFileInSubDirectory(AstriaCookie.GetUserId().ToString());
         ExceptionsML.Check(sr.Error);
         return(View(sr.Result));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
コード例 #9
0
ファイル: GuestController.cs プロジェクト: cssuarez/DocStar
        public mvc.ActionResult ProcessDownloadRequestResult()
        {
            Guid id         = new Guid(Request.QueryString["id"]);
            Guid instanceId = new Guid(Request.QueryString["instanceId"]);
            var  password   = Request.QueryString["password"];
            var  fileId     = Request.QueryString["fileId"];
            SR <ProxyAuthRequestResult> sr = null;

            try
            {
                var client = SvcBldr.SecurityV2();
                sr = client.GetProxyRequest(new GetProxyRequestArgs {
                    Id = id, InstanceId = instanceId, Password = password
                });
                ExceptionsML.Check(sr.Error);

                BaseToken = sr.Result.Token;

                var ip       = GetIP();
                var server   = GetServerURI();
                var sb       = new ServiceBuilder(server, BaseToken, ip);
                var fileName = Path.GetFileName(fileId);
                var mimeType = fileId.GetMIMEType();
                var ftSvc    = sb.FileTransferV2();
                var bytes    = RemoteFileHandler.DownloadFile(fileId, ftSvc);
                return(File(bytes, mimeType, fileName));
            }
            catch (LoginRequiredException lex)
            {
                if (lex.Reason == LoginRequiredReason.ProxyMoveInProgress)
                {
                    var proxyUrl = Functions.GetAuthenticationProxyUrl();
                    var domain   = Functions.GetProxyCookieDomain();
                    var url      = Functions.CombineUri(proxyUrl, "Guest");
                    url += String.Format("?RequestId={0}&InstanceId={1}&auto={2}", id, instanceId, String.IsNullOrEmpty(password));
                    return(View("../Home/Oops", new ExceptionsML {
                        Message = url, Type = LoginRequiredReason.ProxyMoveInProgress.ToString()
                    }));
                }
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(lex)));
            }
            catch (RecordNotFoundException rex)
            {
                return(View("../Home/Oops", new ExceptionsML {
                    Message = Constants.i18n("invalidGuestDownloadRequest"), Type = rex.GetType().ToString()
                }));
            }
            catch (Exception ex) { return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex))); }
        }
コード例 #10
0
ファイル: GuestController.cs プロジェクト: cssuarez/DocStar
        private mvc.ActionResult RedirectToLastSession(GuestSessionCookie fsc)
        {
            var client = SvcBldr.SecurityV2();
            var sr     = client.GetProxyRequest(new GetProxyRequestArgs {
                Id = fsc.RequestId, InstanceId = fsc.InstanceId, DontGetToken = true
            });

            if (sr.Error != null)
            {
                if (sr.Error.Type == typeof(ProxyAuthRequestExpiredException).ToString())
                {
                    fsc.Delete(Request, Response);
                    return(null);
                }
                ExceptionsML.Check(sr.Error);
            }
            return(RedirectToAction("Index", fsc));
        }
コード例 #11
0
 public ViewResult MonitorHub()
 {
     try
     {
         var client = SvcBldr.UserV2();
         var sr     = client.GetCurrent();
         ExceptionsML.Check(sr.Error);
         if (!sr.Result.Flags.HasFlag(UserFlags.SuperAdmin))
         {
             throw new Exception("Super Admin Permissions Required");
         }
         var model = new ServerUriModel {
             ServerUri = GetServerURI()
         };
         return(View(model));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
コード例 #12
0
 public System.Web.Mvc.ActionResult LiveChat()
 {
     try
     {
         var companyClient = SvcBldr.CompanyV2();
         var cd            = companyClient.GetChatData();
         if (String.IsNullOrEmpty(cd.Result.Channel))
         {
             cd.Result.Channel = @Functions.GetSetting("ChatChannelId", "716209851");
         }
         if (cd.Result.IsGuest)
         {
             cd.Result.UserName = "******" + cd.Result.UserName;
         }
         ExceptionsML.Check(cd.Error);
         return(View(cd.Result));
     }
     catch (Exception ex)
     {
         return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex)));
     }
 }
コード例 #13
0
ファイル: GuestController.cs プロジェクト: cssuarez/DocStar
        public mvc.ActionResult ProcessDownloadRequest()
        {
            Guid id           = new Guid(Request.QueryString["id"]);
            Guid instanceId   = new Guid(Request.QueryString["instanceId"]);
            var  password     = Request.QueryString["password"];
            var  connectionId = Request.QueryString["connectionId"];
            SR <ProxyAuthRequestResult> sr = null;

            try
            {
                var client = SvcBldr.SecurityV2();
                sr = client.GetProxyRequest(new GetProxyRequestArgs {
                    Id = id, InstanceId = instanceId, Password = password
                });
                ExceptionsML.Check(sr.Error);
                return(DownloadFiles(sr.Result, connectionId));
            }
            catch (LoginRequiredException lex)
            {
                if (lex.Reason == LoginRequiredReason.ProxyMoveInProgress)
                {
                    var proxyUrl = Functions.GetAuthenticationProxyUrl();
                    var domain   = Functions.GetProxyCookieDomain();
                    var url      = Functions.CombineUri(proxyUrl, "Guest");
                    url += String.Format("?{0}={1}&{2}={3}&{4}={5}", Constants.REQUESTID, id, Constants.INSTANCEID, instanceId, Constants.AUTO, String.IsNullOrEmpty(password));
                    return(View("../Home/Oops", new ExceptionsML {
                        Message = url, Type = LoginRequiredReason.ProxyMoveInProgress.ToString()
                    }));
                }
                return(View("../Home/Oops", ExceptionsML.GetExceptionML(lex)));
            }
            catch (RecordNotFoundException rex)
            {
                return(View("../Home/Oops", new ExceptionsML {
                    Message = Constants.i18n("invalidGuestDownloadRequest"), Type = rex.GetType().ToString()
                }));
            }
            catch (Exception ex) { return(View("../Home/Oops", ExceptionsML.GetExceptionML(ex))); }
        }
コード例 #14
0
        public System.Web.Mvc.ActionResult GetStampsSprite(bool imageStamps)
        {
            var client = SvcBldr.StampsV2();

            byte[] png = null;
            try
            {
                var sr = client.GetAllForUser(new AnnoStampGetPackage {
                    IncludeAdmin = true, IncludeImage = imageStamps, IncludeDeleted = false
                });
                ExceptionsML.Check(sr.Error);
                var iStamps = imageStamps ? sr.Result.ImageStamps.Cast <IStamp>() : sr.Result.TextStamps.Cast <IStamp>();
                png = AnnoEngine.GetSpriteSheet(iStamps.ToList());
            }
            catch (Exception ex)
            {
                string key = string.Concat(AstriaCookie.GetToken(), "AnnoEngine");
                _cache.Remove(key);
                png = StandardResult.CreateBitmapImage(ExceptionsML.GetExceptionML(ex).Message);
            }
            return(File(png, "image/png"));
        }
コード例 #15
0
        internal static GuestChallengeModel GetOrValidate(Guid reqId, Guid instanceId, HttpRequestBase request, ServiceBuilder svcBldr)
        {
            var model = new GuestChallengeModel();

            var client = svcBldr.SecurityV2();
            var sr     = client.GetProxyRequest(new GetProxyRequestArgs {
                DontGetToken = true, Id = reqId, InstanceId = instanceId
            });

            ExceptionsML.Check(sr.Error);
            var par = sr.Result;

            model.SubmitMessage = GetSubmitMessage(par.RequestType);
            //Temporary: Bug 13104  - Update Guest Downloads so they follow the same model as Form Links and Guest viewer links
            if (par.RequestType == ProxyAuthRequestType.DownloadFiles)
            {
                model.ProxyRequest = par;
                return(model);
            }

            ValidateRecaptcha(par, model, request);
            ValidatePasswordFillModelProxyRequest(par, model, request, svcBldr);
            return(model);
        }
コード例 #16
0
ファイル: ReportViewer.aspx.cs プロジェクト: cssuarez/DocStar
        private void LoadReportData(ReportPackage report, Dictionary <String, String> parameters, XElement reportDef, ServiceBuilder sb)
        {
            try
            {
                var reportParams = ReportViewer1.LocalReport.GetParameters();
                sb.SendTimeout = TimeSpan.FromMinutes(30);
                var dlSvc     = sb.DataLinkV2();
                var newParams = new Dictionary <String, String>();
                var xmlns     = reportDef.GetDefaultNamespace().ToString();
                var rd        = reportDef.GetNamespaceOfPrefix("rd").ToString();

                var dataSets = reportDef.Descendants(XName.Get("DataSet", xmlns));
                if (dataSets == null)
                {
                    throw new Exception("DataSet not found in report"); //We control writing this, so we should never see this occur.
                }
                foreach (var dataSet in dataSets)
                {
                    var dsName = dataSet.SafeAttributeValue <String>("Name", Constants.ECLIPSE_DATASOURCE);
                    var rds    = report.ReportDataSets.FirstOrDefault(r => r.Name == dsName);
                    var dlSR   = dlSvc.GetReportData(new GetReportDataArgs {
                        Parameters = parameters, QueryDefinition = rds.QueryDefinition
                    });
                    ExceptionsML.Check(dlSR.Error);
                    newParams.AddRange(dlSR.Result.Parameters);
                    var dt     = new DataTable(dsName);
                    var fields = dataSet.Descendants(XName.Get("Field", xmlns));
                    if (fields != null)
                    {
                        foreach (var field in fields)
                        {
                            var fieldName = field.Element(XName.Get("DataField", xmlns)).Value;
                            var fieldType = field.Element(XName.Get("TypeName", rd)).Value;
                            dt.Columns.Add(new DataColumn(fieldName, Converter.GetType(fieldType)));
                        }
                        if (dlSR.Result != null)
                        {
                            dlSR.Result.FillDataTable(dt);
                        }
                    }
                    var rptData = new ReportDataSource(dsName, dt);
                    ReportViewer1.LocalReport.DataSources.Add(rptData);
                }
                // Set the parameters for the report
                var length     = reportParams == null ? 0 : reportParams.Count;
                var setParams  = new ReportParameter[length];
                var eclipseURL = String.Format("{0}://{1}:{2}{3}",
                                               Request.IsSecureConnection ? "https" : "http",
                                               Request.ServerVariables["SERVER_NAME"],
                                               Request.ServerVariables["SERVER_PORT"],
                                               Request.ApplicationPath);
                var idx = 0;
                foreach (var param in reportParams)
                {
                    // Add a hardcoded EclipseURL parameter so the report can use it to navigate documents
                    var name          = param.Name;
                    var newParamsName = "@" + name;
                    if (name == Constants.REPORTS_ECLIPSE_URL)
                    {
                        setParams[idx] = new ReportParameter(name, eclipseURL);
                    }
                    else if (newParams.ContainsKey(newParamsName)) // newParams names begin with "@", where as name does not
                    {
                        setParams[idx] = new ReportParameter(name, newParams[newParamsName]);
                    }
                    else
                    {
                        setParams[idx] = new ReportParameter(name);
                    }
                    idx++;
                }
                setParams = setParams.RemoveNulls();    // Prevents setting null parameters (ones' that have been deleted)
                ReportViewer1.LocalReport.SetParameters(setParams);
            }
            catch (LocalProcessingException lex)
            {
                ErrorHandler(lex.InnerMost());
            }
            catch (Exception ex)
            {
                ErrorHandler(ex);
            }
        }
コード例 #17
0
ファイル: HomeModel.cs プロジェクト: cssuarez/DocStar
        /// <summary>
        /// load data for the home model
        /// </summary>
        public void LoadData(string baseUri)
        {
            var bulkClient   = _sb.BulkDataV2();
            var hostBulkData = bulkClient.GetHostData();

            ExceptionsML.Check(hostBulkData.Error);

            HostBulkData = JsonConvert.SerializeObject(hostBulkData);

            CurrentDBName         = hostBulkData.Result.CurrentDB;
            DefaultDBName         = hostBulkData.Result.DefaultDB;
            DefaultInstanceId     = hostBulkData.Result.DefaultInstanceId;
            Instances             = hostBulkData.Result.UserCompanyInstances;
            SystemPreferences     = JsonConvert.SerializeObject(hostBulkData.Result.CompanySettings);
            SystrayConnections    = JsonConvert.SerializeObject(hostBulkData.Result.SysTrayConnections);
            AutomationConnections = JsonConvert.SerializeObject(hostBulkData.Result.AutomationConnections);
            HttpRuntimeSection httpRuntimeSection = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection;

            MaxRequestLength = httpRuntimeSection.MaxRequestLength;
            DateTime?lastChecked = null;

            if (hostBulkData.Result.UserSettings.ContainsKey(Constants.WORKFLOW_LAST_CHECKED))
            {
                lastChecked = DateTime.Parse(hostBulkData.Result.UserSettings[Constants.WORKFLOW_LAST_CHECKED]);
            }

            var bulkData = bulkClient.Get(lastChecked);

            ExceptionsML.Check(bulkData.Error);
            BulkData = JsonConvert.SerializeObject(bulkData);
            var result = bulkData.Result;

            UserMessages = result.ExpiringMessage;
            var importData    = new AdvancedImportData();
            var licenseTokens = result.LicenseTokens;

            if (licenseTokens != null)
            {
                Licenses.AddRange(licenseTokens);
            }
            if (!Licenses.Any(r => (TokenKey)r == TokenKey.View))
            {
                Unlicensed = true;
            }
            // Gateway permissions
            importData.GatewayPermissions = result.GatewayPermissions;
            var user = result.CurrentUser;

            _baseCache.Remove(USERINFO + user.Id.ToString());
            _baseCache.Add(USERINFO + user.Id.ToString(), new object[] { user, result.GatewayPermissions }, new CacheItemPolicy());
            LoadUserData();
            CurrentUser           = JsonConvert.SerializeObject(new { Name = user.Username, Id = user.Id, HasPassword = HasPassword });
            importData.RootFolder = result.RootFolders;
            var rootNode = new JSTreeData(Constants.i18n("folders"));

            rootNode.children = JSTreeFormat.ConvertToJSTreeFormat(importData.RootFolder);
            FolderData        = JsonConvert.SerializeObject(rootNode);

            // Inbox data
            var inboxes = new JSTreeData(Constants.i18n("inboxes"));

            importData.Inboxes = result.Inboxes.ToList();
            inboxes.children   = JSTreeFormat.ConvertToJSTreeFormat(result.Inboxes);
            InboxData          = JsonConvert.SerializeObject(inboxes);
            // Security Class Data
            importData.SecurityClasses = result.SecurityClasses.ToList();
            // Content Type Data
            ContentTypes            = result.ContentTypes;
            importData.ContentTypes = new List <ContentTypeLight>();
            foreach (var ct in ContentTypes)
            {
                importData.ContentTypes.Add(new ContentTypeLight
                {
                    Id   = ct.Id,
                    Name = ct.Name,
                    DefaultFolderName      = "", //TODO: scain need to obtain the default folder Name
                    DefaultFolderId        = ct.DefaultFolderId,
                    DefaultInboxId         = ct.DefaultInboxId,
                    DefaultSecurityClassid = ct.DefaultSecurityClassId,
                    DefaultWorkflowId      = ct.DefaultWorkflowId,
                    EffectivePermissions   = ct.EffectivePermissions
                });
            }

            NewApprovals         = result.NewApprovals;
            NewWorkflows         = result.NewWorkflows;
            importData.Workflows = result.Workflows.ToList();
            ImportData           = JsonConvert.SerializeObject(importData);
            var views = GetCachedViews(baseUri);

            CommonTemplates = JsonConvert.SerializeObject(views);
        }
コード例 #18
0
ファイル: ReportViewer.aspx.cs プロジェクト: cssuarez/DocStar
        private List <ReportParameterPackage> GetReportParameterPackages(ReportPackage report, XElement reportDef)
        {
            var dataSets            = report.ReportDataSets;
            var xmlns               = reportDef.GetDefaultNamespace().ToString();
            var reportParams        = reportDef.Descendants(XName.Get("ReportParameter", xmlns));
            var localReportParams   = ReportViewer1.LocalReport.GetParameters();
            var reportParameterPkgs = new List <ReportParameterPackage>();

            foreach (var reportParam in reportParams)
            {
                var reportParamName = reportParam.SafeAttributeValue("Name", "");
                // Skip internal hidden parameter "EclipseURL" (Used to link documents)
                if (reportParamName == Constants.REPORTS_ECLIPSE_URL)
                {
                    continue;
                }
                //TODO: Use the report parameter prompt instead of the name
                var multiValue     = reportParam.Element(XName.Get("MultiValue", xmlns));
                var hasMultiValues = false;
                if (multiValue != null)
                {
                    Boolean.TryParse(multiValue.Value, out hasMultiValues);
                }
                var allowBlank    = reportParam.Element(XName.Get("AllowBlank", xmlns));
                var hasAllowBlank = false;
                if (allowBlank != null)
                {
                    Boolean.TryParse(allowBlank.Value, out hasAllowBlank);
                }


                var    validValues      = reportParam.Descendants(XName.Get("ValidValues", xmlns));
                var    paramValidValues = new List <ParameterValidValue>();
                var    hasValidValues   = false;
                String lrpLabel         = String.Empty;
                String lrpValue         = String.Empty;
                var    rpPkg            = new ReportParameterPackage
                {
                    Name = reportParamName
                };
                foreach (var validValue in validValues)
                {
                    hasValidValues = true;
                    var paramValue = validValue.Descendants(XName.Get("ParameterValue", xmlns));
                    foreach (var param in paramValue)
                    {
                        var vvLabel = param.Element(XName.Get("Label", xmlns));
                        var vvValue = param.Element(XName.Get("Value", xmlns));
                        var lblVal  = vvLabel == null ? null : vvLabel.Value;
                        GetReportParameters(localReportParams, reportParamName, lblVal, out lrpLabel, out lrpValue);
                        paramValidValues.Add(new ParameterValidValue
                        {
                            Name  = reportParamName,
                            Label = lrpLabel,
                            Value = lrpValue
                        });
                    }
                }
                rpPkg.ValidValues = paramValidValues.ToArray();
                var defaultValues      = reportParam.Descendants(XName.Get("DefaultValue", xmlns));
                var paramDefaultValues = new List <String>();
                foreach (var defaultValue in defaultValues)
                {
                    var defParamValues = defaultValue.Descendants(XName.Get("Values", xmlns));
                    foreach (var defParamValue in defParamValues)
                    {
                        var dvValue = defParamValue.Element(XName.Get("Value", xmlns));
                        var val     = dvValue == null ? null : dvValue.Value;
                        GetReportParameters(localReportParams, reportParamName, val, out lrpLabel, out lrpValue);
                        paramDefaultValues.Add(lrpValue);
                    }
                }
                rpPkg.DefaultValues = paramDefaultValues.ToArray();
                if (hasValidValues)
                {
                    var dataSetRefs = reportParam.Descendants(XName.Get("DataSetReference", xmlns));
                    foreach (var dataSetRef in dataSetRefs)
                    {
                        var fieldValue  = dataSetRef.Element(XName.Get("ValueField", xmlns)).Value;
                        var fieldLabel  = dataSetRef.Element(XName.Get("LabelField", xmlns)).Value;
                        var dataSetName = dataSetRef.Element(XName.Get("DataSetName", xmlns)).Value;
                        // Obtain the dataset from the reports data sets, matched on name
                        int idx;
                        var dataSetsLen = dataSets.SafeLength();
                        for (idx = 0; idx < dataSetsLen; idx++)
                        {
                            var queryParams = new Dictionary <String, String>();
                            if (dataSets[idx].Name == dataSetName)
                            {
                                var sqlQuery = DLUtility.Deserialize <SQLQuery>(dataSets[idx].QueryDefinition);
                                if (sqlQuery.Params.Count == 0)
                                {
                                    var args = new GetReportDataArgs {
                                        QueryDefinition = dataSets[idx].QueryDefinition
                                    };
                                    _sb.SendTimeout = TimeSpan.FromMinutes(30);
                                    var dlSvc = _sb.DataLinkV2();
                                    var rdSR  = dlSvc.GetReportData(args);
                                    ExceptionsML.Check(rdSR.Error);

                                    var colLen = rdSR.Result.Columns[fieldLabel].SafeLength();
                                    for (int colIdx = 0; colIdx < colLen; colIdx++)
                                    {
                                        paramValidValues.Add(new ParameterValidValue
                                        {
                                            Name  = reportParamName,
                                            Label = rdSR.Result.Columns[fieldLabel][colIdx],
                                            Value = rdSR.Result.Columns[fieldValue][colIdx] ?? String.Empty
                                        });
                                    }
                                    rpPkg.ValidValues = paramValidValues.ToArray();
                                }
                                else
                                {
                                    rpPkg.Name        = reportParamName;
                                    rpPkg.ValidValues = new ParameterValidValue[0];
                                    rpPkg.IsTypeAhead = true;
                                    rpPkg.DataSetId   = dataSets[idx].Id;
                                }
                            }
                        }
                    }
                    rpPkg.IsMultiValued = hasMultiValues;
                    rpPkg.AllowBlank    = hasAllowBlank;
                }
                else
                {
                    var type   = reportParam.Descendants(XName.Get("DataType", xmlns));
                    var values = reportParam.Descendants(XName.Get("Value", xmlns));
                    var vals   = GetStandardReportParameters(localReportParams, reportParamName);
                    rpPkg.Values = vals;
                    rpPkg.Type   = reportParam.Element(XName.Get("DataType", xmlns)).Value;
                }
                rpPkg.ValidValues.Sort <ParameterValidValue>((a, b) => a.Label.CompareTo(b.Label));
                reportParameterPkgs.Add(rpPkg);
            }

            return(reportParameterPkgs);
        }