示例#1
0
 public RequestErrorEventArgs(RequestDetails request, Exception exception) : base(request)
 {
     _exception = exception;
 }
示例#2
0
 private string GetQueueInfoComplete(IWebServer arg1, RequestDetails arg2)
 {
     sentQueueInfoComplete = true;
     return(queueInfoComplete);
 }
 public HttpResponseMessageResponseDetails(RequestDetails request, HttpResponseMessage response)
 {
     _request = request;
     _response = response;
 }
示例#4
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "decodebodycontent")]
            HttpRequest req, ILogger log)
        {
            // Get Request Details
            RequestDetails requestDetails = new RequestDetails(req, LogId);

            string logPrefix = $"{LogId}:{requestDetails.TrackingId}: ";

            // Add the tracking ID to the Response Headers
            if (!string.IsNullOrWhiteSpace(requestDetails.TrackingId))
            {
                req.HttpContext.Response.Headers[HeaderConstants.AimTrackingId] = requestDetails.TrackingId;
            }

            log.LogDebug($"{logPrefix}Called with parameters messageContentType: {requestDetails.RequestContentType}, messageContentEncoding: {requestDetails.RequestContentEncoding}, messageTransferEncoding: {requestDetails.RequestTransferEncoding}, headerTrackingId: {requestDetails.TrackingId}, clearCache: {requestDetails.ClearCache}, enableTrace: {requestDetails.EnableTrace}");

            // Validate the request
            IActionResult result = ValidateRequest(requestDetails, logPrefix, log);

            if (result != null)
            {
                return(await Task.FromResult <IActionResult>(result));
            }

            log.LogDebug($"{logPrefix}Request parameters are valid");

            // Attempt to parse the envelope
            Envelope envelope;

            try
            {
                log.LogDebug($"{logPrefix}Parsing the request body as an envelope");
                envelope = new Envelope(requestDetails);
                requestDetails.UpdateTrackingId(envelope.TrackingId);

                // Add TrackingId header
                if (!string.IsNullOrEmpty(requestDetails.TrackingId) && req?.HttpContext?.Response?.Headers?.ContainsKey(HeaderConstants.AimTrackingId) == false)
                {
                    req?.HttpContext?.Response?.Headers?.Add(HeaderConstants.AimTrackingId, requestDetails.TrackingId);
                }
            }
            catch (Exception ex)
            {
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, $"An exception occurred trying to parse the received envelope message", ex, logPrefix, log)));
            }

            // Attempt to get the decoded root part content
            object decodedContent;

            try
            {
                decodedContent = envelope.GetDecodedRootPartContent();
            }
            catch (Exception ex)
            {
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, $"An error occurred trying to decode the root part content", ex, logPrefix, log)));
            }

            log.LogDebug($"{logPrefix}Finished getting content - returning response");

            // Special hack for XML content - OkObjectResult doesn't support XmlDocument in Functions at this time
            // without adding the XmlSerializerFormmatter to the list of services
            // See here: https://github.com/Azure/azure-functions-host/issues/2896
            if (decodedContent is XmlDocument)
            {
                return(await Task.FromResult <IActionResult>(new ContentResult()
                {
                    Content = ((XmlDocument)decodedContent).OuterXml,
                    ContentType = "application/xml",
                    StatusCode = 200
                }));
            }

            return(await Task.FromResult <IActionResult>(new OkObjectResult(decodedContent)));
        }
示例#5
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "mergeproperties")]
            HttpRequest req, ILogger log)
        {
            // Get Request Details
            RequestDetails requestDetails = new RequestDetails(req, LogId);

            string logPrefix = $"{LogId}:{requestDetails.TrackingId}: ";

            // Add the tracking ID to the Response Headers
            if (!string.IsNullOrWhiteSpace(requestDetails.TrackingId))
            {
                req.HttpContext.Response.Headers[HeaderConstants.AimTrackingId] = requestDetails.TrackingId;
            }

            log.LogDebug($"{logPrefix}Called with parameters messageContentType: {requestDetails.RequestContentType}, messageContentEncoding: {requestDetails.RequestContentEncoding}, messageTransferEncoding: {requestDetails.RequestTransferEncoding}, headerTrackingId: {requestDetails.TrackingId}, clearCache: {requestDetails.ClearCache}, enableTrace: {requestDetails.EnableTrace}");

            // Validate the request
            IActionResult result = ValidateRequest(requestDetails, logPrefix, log);

            if (result != null)
            {
                return(await Task.FromResult <IActionResult>(result));
            }

            log.LogDebug($"{logPrefix}Request parameters are valid");

            // We expect the body to be an array of property bags
            // e.g.
            // [
            //    {
            //       "properties":
            //        {
            //            "property1": "value1"
            //        }
            //    },
            //    {
            //       "properties":
            //        {
            //            "property2": "value2"
            //        }
            //    }
            // ]

            // Check we have a JSON array in the body content
            if (!(requestDetails.RequestBodyAsJson is JArray))
            {
                // We need an array to be supplied
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, "The supplied request body is not a JSON array", logPrefix, log)));
            }

            JArray propertiesArray = requestDetails.RequestBodyAsJson as JArray;

            // Check we have at least one element in the array
            if (propertiesArray.Count == 0)
            {
                // We need at least one element in the supplied array
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, "The supplied request body contains an empty JSON array", logPrefix, log)));
            }

            // Check that all the array elements are JSON Objects
            if (!propertiesArray.All(j => j is JObject))
            {
                // All elements in the array must be JSON Objects
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, "All elements in the supplied JSON Array must be JSON Objects", logPrefix, log)));
            }

            JObject firstElement = propertiesArray[0] as JObject;

            log.LogDebug($"{logPrefix}Merging property objects");

            try
            {
                // Merge every subsequent element in the array (other than the first) with the first array element
                for (int arrayIndex = 1; arrayIndex < propertiesArray.Count; arrayIndex++)
                {
                    firstElement.Merge(propertiesArray[arrayIndex] as JObject, new JsonMergeSettings
                    {
                        // Union array values together to avoid duplicates
                        MergeArrayHandling = MergeArrayHandling.Union
                    });
                }
            }
            catch (Exception ex)
            {
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, $"An exception occurred trying to merge the property bags", ex, logPrefix, log)));
            }

            return(await Task.FromResult <IActionResult>(new OkObjectResult(firstElement)));
        }
        private void RemoteService_ExecCompleted(object sender, ExecCompletedEventArgs e)
        {
            try
            {
                IsRequestInProgress = false;

                RequestDetails currentResponseRequest = _activeRequestDetails;
                _activeRequestDetails = null; // Doing this now instead of at end, as code called by this method might kick off a new request

                if (e.Error != null)
                {
                    if (currentResponseRequest.ResponseCallBack != null)
                        currentResponseRequest.ResponseCallBack(false, null);

                    ApplicationEx.Instance.DisplayMessageBox(e.Error.Message, "Error Message");

                    _chunking = false;
                    RequestQueue.Clear(); // Future requests made invalid due to error, so clear the queue. TODO: Determine whether there is a better strategy for dealing with queued requests after an error.

                    return;
                }

                if (!string.IsNullOrEmpty(e.errors))
                {
                    if (currentResponseRequest.ResponseCallBack != null)
                        currentResponseRequest.ResponseCallBack(false, null);

                    ApplicationEx.Instance.DisplayMessageBox(e.errors, "Server Message");

                    _chunking = false;
                    RequestQueue.Clear(); // Future requests made invalid due to error, so clear the queue. TODO: Determine whether there is a better strategy for dealing with queued requests after an error.

                    return;
                }

                if (e.Result.Length > 0)
                {
                    Response = XDocument.Parse(e.Result);

                    // Write the message to the output window
            //                    System.Diagnostics.Debug.WriteLine("RAW RESPONSE:");

            //#if WINDOWS_PHONE
            //                    int startPos = 0;

            //                    string debugString = Response.ToString();

            //                    while (startPos < debugString.Length)
            //                    {
            //                        if (startPos + 700 > e.Result.Length)
            //                            System.Diagnostics.Debug.WriteLine(debugString.Substring(startPos));
            //                        else
            //                            System.Diagnostics.Debug.WriteLine(debugString.Substring(startPos, 700));

            //                        startPos += 700;
            //                    }
            //#else
            //                    System.Diagnostics.Debug.WriteLine(Response.ToString());
            //#endif

                    if (ServerResponse != null)
                        ServerResponse(Response.ToString());

                    bool lastSuccess = Common.boolValue(Response.Document.Root.Attribute(Common.ResultSuccess).Value);

                    if (Response.Document.Root.Attribute(Common.serverMsg) != null)
                    {
                        string msg = Response.Document.Root.Attribute(Common.serverMsg).Value;

                        if (msg.Length > 0)
                        {
                            ApplicationEx.Instance.DisplayMessageBox(msg, "Server Broadcast Message");
                            Response.Document.Root.Attribute(Common.serverMsg).Remove();
                        }
                    }

                    #region Chunking
                    if (Response.Document.Root.Attribute(Common.Chunking.chunking) != null &&
                        Common.boolValue(Response.Document.Root.Attribute(Common.Chunking.chunking).Value))
                    {
                        this._chunking = true;

                        // Create cancel window
                        _chunkProgressText = Response.Document.Root.Attribute(Common.Chunking.chunkProgress).Value;
                        string progress = Response.Document.Root.Attribute(Common.Chunking.chunkProgressPercentage).Value;
                        _chunkProgressPercentage = 0;

                        if (progress.Length > 0)
                            int.TryParse(progress, out _chunkProgressPercentage);

                        if (_cancelChunkForm == null && !_chunkThreadStarted)
                        {
                            _chunkingCancelled = false;
                            //Thread t = new Thread(new ThreadStart(createLongOperationCancelForm));
                            //t.SetApartmentState( ApartmentState.STA);
                            //t.Priority = ThreadPriority.AboveNormal;
                            //t.Start();
                            _chunkThreadStarted = true;
                        }

                        if (_cancelChunkForm != null)
                        {
                            _cancelChunkForm.Description = _chunkProgressText;
                            _cancelChunkForm.Progress = _chunkProgressPercentage;
                            _chunkThreadStarted = false;
                        }
                    }
                    else if (_chunking)
                    {
                        this._chunking = false;
                        if (_cancelChunkForm != null)
                        {
                            _cancelChunkForm.Close();
                            _cancelChunkForm = null;
                        }
                    }

                    if (_chunking)
                    {
                        Request.Document.Root.RemoveAll();
                        XElement elt;

                        if (_cancelChunkForm != null && this._chunkingCancelled)
                        {
                            elt = new XElement(Common.Chunking.CancelChunk);
                            _cancelChunkForm.Close();
                            _cancelChunkForm = null;
                        }
                        else
                        {
                            elt = new XElement(Common.Chunking.KeepChunking);
                        }

                        Request.Document.Add(elt);
                    }
                }
                #endregion

                if (currentResponseRequest.ResponseCallBack != null)
                    currentResponseRequest.ResponseCallBack(true, Response);

                if (!_chunking)
                {
                    if (!_dontAutoPublishResponse)
                        PublishResponse(new XDocument(Response)); // NOTE: Doing a new in order to get a deep copy, not affected by other actions on it while it's being parsed
                }
            }
            finally
            {
                ApplicationEx.Instance.IsBusy = false;

                // Now that this request has been processed, move to the next entry in the queue
                if (RequestQueue.Count != 0)
                    SendRequestToServerPortal(RequestQueue.Dequeue());
            }
        }
示例#7
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "getbodycontent")]
            HttpRequest req, ILogger log)
        {
            // Get Request Details
            RequestDetails requestDetails = new RequestDetails(req, LogId);

            string logPrefix = $"{LogId}:{requestDetails.TrackingId}: ";

            // Add the tracking ID to the Response Headers
            if (!string.IsNullOrWhiteSpace(requestDetails.TrackingId))
            {
                req.HttpContext.Response.Headers[HeaderConstants.AimTrackingId] = requestDetails.TrackingId;
            }

            log.LogDebug($"{logPrefix}Called with parameters messageContentType: {requestDetails.RequestContentType}, messageContentEncoding: {requestDetails.RequestContentEncoding}, messageTransferEncoding: {requestDetails.RequestTransferEncoding}, headerTrackingId: {requestDetails.TrackingId}, clearCache: {requestDetails.ClearCache}, enableTrace: {requestDetails.EnableTrace}");

            // Validate the request
            IActionResult result = ValidateRequest(requestDetails, logPrefix, log);

            if (result != null)
            {
                return(await Task.FromResult <IActionResult>(result));
            }

            log.LogDebug($"{logPrefix}Request parameters are valid");

            // Attempt to parse the envelope
            Envelope envelope;

            try
            {
                log.LogDebug($"{logPrefix}Parsing the request body as an envelope");
                envelope = new Envelope(requestDetails);
                requestDetails.UpdateTrackingId(envelope.TrackingId);

                // Add TrackingId header
                if (!string.IsNullOrEmpty(requestDetails.TrackingId) && req?.HttpContext?.Response?.Headers?.ContainsKey(HeaderConstants.AimTrackingId) == false)
                {
                    req?.HttpContext?.Response?.Headers?.Add(HeaderConstants.AimTrackingId, requestDetails.TrackingId);
                }
            }
            catch (Exception ex)
            {
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, $"An exception occurred trying to parse the received envelope message", ex, logPrefix, log)));
            }

            // Attempt to get the encoded root part content
            JObject decodedContent;

            try
            {
                decodedContent = envelope.GetEncodedRootPartContent();
            }
            catch (Exception ex)
            {
                return(await Task.FromResult <IActionResult>(AzureResponseHelper.CreateFaultObjectResult(requestDetails, $"An error occurred trying to encode the root part content", ex, logPrefix, log)));
            }

            log.LogDebug($"{logPrefix}Finished getting content - returning response");

            return(await Task.FromResult <IActionResult>(new OkObjectResult(decodedContent)));
        }
        public override async Task HandleMessageAsync(DeviceTelemetryMessage requestBody, RequestDetails requestDetails, RequestMessageHeaders headers, IExtensionGatewayClient client, ILogger log)
        {
            //write telemetry to statestore
            await client.PutDeviceTelemetryAsync(requestDetails.DeviceName, requestBody);

            // Create a secret client using the DefaultAzureCredential

            DefaultAzureCredential cred  = new DefaultAzureCredential();
            DigitalTwinsClient     dtcli = new DigitalTwinsClient(new Uri("https://mobility-vss.api.wus2.digitaltwins.azure.net"), cred);

            DTUnit du = JsonSerializer.Deserialize <DTUnit>((string)requestBody.Payload);

            var updateOps = new UpdateOperationsUtility();

            if (du.type == "boolean")
            {
                updateOps.AppendAddOp(du.path, bool.Parse(du.value));
            }
            else if ((du.type == "date") || (du.type == "datetime") || (du.type == "time"))
            {
                updateOps.AppendAddOp(du.path, DateTime.Parse(du.value));
            }
            else if (du.type == "double")
            {
                updateOps.AppendAddOp(du.path, double.Parse(du.value));
            }
            else if (du.type == "float")
            {
                updateOps.AppendAddOp(du.path, float.Parse(du.value));
            }
            else if (du.type == "integer")
            {
                updateOps.AppendAddOp(du.path, int.Parse(du.value));
            }
            else if (du.type == "long")
            {
                updateOps.AppendAddOp(du.path, long.Parse(du.value));
            }
            else
            {
                updateOps.AppendAddOp(du.path, du.value);
            }

            string patchPayload = updateOps.Serialize();
            await dtcli.UpdateDigitalTwinAsync(du.dtID, patchPayload);

            // send stuff to the analytics pipeline
            var telemetryItem = new
            {
                VehicleId     = requestDetails.VehicleId,
                TelemetryName = requestBody.TelemetryName,
                Time          = requestBody.Time,
                Payload       = patchPayload
            };

            await client.SendToAnalyticsPipeline(telemetryItem);
        }
 internal RequestDetailsUnion(RequestDetails requestDetails)
 {
     this.requestDetails = requestDetails;
     this.tag            = 0;
 }
示例#10
0
        public List <RequestDetails> getTrainerRequests(string trainerCode)
        {
            RequestDetails r = new RequestDetails();

            return(r.GetTrainerRequests(trainerCode));
        }
 public HttpResponseMessageResponseDetails(RequestDetails request, HttpResponseMessage response)
 {
     _request  = request;
     _response = response;
 }
示例#12
0
        public List <RequestDetails> getBranchRequests(string branchCode)
        {
            RequestDetails r = new RequestDetails();

            return(r.GetBranchRequests(branchCode));
        }
        private void RemoteService_ExecCompleted(object sender, ExecCompletedEventArgs e)
        {
            try
            {
                IsRequestInProgress = false;

                RequestDetails currentResponseRequest = _activeRequestDetails;
                _activeRequestDetails = null; // Doing this now instead of at end, as code called by this method might kick off a new request

                if (e.Error != null)
                {
                    if (currentResponseRequest.ResponseCallBack != null)
                    {
                        currentResponseRequest.ResponseCallBack(false, null);
                    }

                    ApplicationEx.Instance.DisplayMessageBox(e.Error.Message, "Error Message");

                    _chunking = false;
                    RequestQueue.Clear(); // Future requests made invalid due to error, so clear the queue. TODO: Determine whether there is a better strategy for dealing with queued requests after an error.

                    return;
                }

                if (!string.IsNullOrEmpty(e.errors))
                {
                    if (currentResponseRequest.ResponseCallBack != null)
                    {
                        currentResponseRequest.ResponseCallBack(false, null);
                    }

                    ApplicationEx.Instance.DisplayMessageBox(e.errors, "Server Message");

                    _chunking = false;
                    RequestQueue.Clear(); // Future requests made invalid due to error, so clear the queue. TODO: Determine whether there is a better strategy for dealing with queued requests after an error.

                    return;
                }

                if (e.Result.Length > 0)
                {
                    Response = XDocument.Parse(e.Result);

                    // Write the message to the output window
//                    System.Diagnostics.Debug.WriteLine("RAW RESPONSE:");

//#if WINDOWS_PHONE
//                    int startPos = 0;

//                    string debugString = Response.ToString();

//                    while (startPos < debugString.Length)
//                    {
//                        if (startPos + 700 > e.Result.Length)
//                            System.Diagnostics.Debug.WriteLine(debugString.Substring(startPos));
//                        else
//                            System.Diagnostics.Debug.WriteLine(debugString.Substring(startPos, 700));

//                        startPos += 700;
//                    }
//#else
//                    System.Diagnostics.Debug.WriteLine(Response.ToString());
//#endif

                    if (ServerResponse != null)
                    {
                        ServerResponse(Response.ToString());
                    }

                    bool lastSuccess = Common.boolValue(Response.Document.Root.Attribute(Common.ResultSuccess).Value);

                    if (Response.Document.Root.Attribute(Common.serverMsg) != null)
                    {
                        string msg = Response.Document.Root.Attribute(Common.serverMsg).Value;

                        if (msg.Length > 0)
                        {
                            ApplicationEx.Instance.DisplayMessageBox(msg, "Server Broadcast Message");
                            Response.Document.Root.Attribute(Common.serverMsg).Remove();
                        }
                    }

                    #region Chunking
                    if (Response.Document.Root.Attribute(Common.Chunking.chunking) != null &&
                        Common.boolValue(Response.Document.Root.Attribute(Common.Chunking.chunking).Value))
                    {
                        this._chunking = true;

                        // Create cancel window
                        _chunkProgressText = Response.Document.Root.Attribute(Common.Chunking.chunkProgress).Value;
                        string progress = Response.Document.Root.Attribute(Common.Chunking.chunkProgressPercentage).Value;
                        _chunkProgressPercentage = 0;

                        if (progress.Length > 0)
                        {
                            int.TryParse(progress, out _chunkProgressPercentage);
                        }

                        if (_cancelChunkForm == null && !_chunkThreadStarted)
                        {
                            _chunkingCancelled = false;
                            //Thread t = new Thread(new ThreadStart(createLongOperationCancelForm));
                            //t.SetApartmentState( ApartmentState.STA);
                            //t.Priority = ThreadPriority.AboveNormal;
                            //t.Start();
                            _chunkThreadStarted = true;
                        }

                        if (_cancelChunkForm != null)
                        {
                            _cancelChunkForm.Description = _chunkProgressText;
                            _cancelChunkForm.Progress    = _chunkProgressPercentage;
                            _chunkThreadStarted          = false;
                        }
                    }
                    else if (_chunking)
                    {
                        this._chunking = false;
                        if (_cancelChunkForm != null)
                        {
                            _cancelChunkForm.Close();
                            _cancelChunkForm = null;
                        }
                    }

                    if (_chunking)
                    {
                        Request.Document.Root.RemoveAll();
                        XElement elt;

                        if (_cancelChunkForm != null && this._chunkingCancelled)
                        {
                            elt = new XElement(Common.Chunking.CancelChunk);
                            _cancelChunkForm.Close();
                            _cancelChunkForm = null;
                        }
                        else
                        {
                            elt = new XElement(Common.Chunking.KeepChunking);
                        }

                        Request.Document.Add(elt);
                    }
                }
                #endregion

                if (currentResponseRequest.ResponseCallBack != null)
                {
                    currentResponseRequest.ResponseCallBack(true, Response);
                }

                if (!_chunking)
                {
                    if (!_dontAutoPublishResponse)
                    {
                        PublishResponse(new XDocument(Response)); // NOTE: Doing a new in order to get a deep copy, not affected by other actions on it while it's being parsed
                    }
                }
            }
            finally
            {
                ApplicationEx.Instance.IsBusy = false;

                // Now that this request has been processed, move to the next entry in the queue
                if (RequestQueue.Count != 0)
                {
                    SendRequestToServerPortal(RequestQueue.Dequeue());
                }
            }
        }
示例#14
0
 public RequestEventArgs(RequestDetails request)
 {
     _request = request;
 }
示例#15
0
文件: UI.cs 项目: apxlee/SAP
        public static string GetDetails(int requestId)
        {
            Role userRole = SnapSession.CurrentUser.CurrentRole;
            bool includeADManager = false;
            int[] commentFilter;
            switch (userRole)
            {
                case Role.AccessTeam:
                case Role.SuperUser:
                    commentFilter = new int[]{(int)CommentsType.Access_Notes_Requestor,
                        (int)CommentsType.Access_Notes_ApprovingManager,
                        (int)CommentsType.Access_Notes_AccessTeam};
                    includeADManager = true;
                    break;

                case Role.ApprovingManager:
                    commentFilter = new int[]{(int)CommentsType.Access_Notes_Requestor,
                        (int)CommentsType.Access_Notes_ApprovingManager};
                    break;

                case Role.Requestor:
                default:
                    commentFilter = new int[] { (int)CommentsType.Access_Notes_Requestor };
                    break;
            }

            using (var db = new SNAPDatabaseDataContext())
            {
                var textIds = from a in db.SNAP_Access_User_Texts
                              where a.requestId == requestId
                              group a by new { a.access_details_formId } into grp
                              select new { ID = grp.Max(s => s.pkId) };

                List<int> currentTextIds = new List<int>();

                foreach (var id in textIds)
                {
                    currentTextIds.Add(id.ID);
                }

                var details = from r in db.SNAP_Requests
                              join ut in db.SNAP_Access_User_Texts on r.pkId equals ut.requestId
                              join adf in db.SNAP_Access_Details_Forms on ut.access_details_formId equals adf.pkId
                              where r.pkId == requestId && adf.isActive == true && currentTextIds.Contains(ut.pkId)
                              orderby adf.pkId ascending
                              select new
                              {
                                  Title = r.userTitle,
                                  Manager = r.managerDisplayName,
                                  ADManager = r.managerUserId,
                                  Requestor = r.submittedBy,
                                  UserId = r.userId,
                                  Label = adf.label,
                                  Text = ut.userText
                              };
                var comments = from r in db.SNAP_Requests
                               join rc in db.SNAP_Request_Comments on r.pkId equals rc.requestId
                               where r.pkId == requestId && commentFilter.Contains(rc.commentTypeEnum)
                               orderby rc.createdDate descending
                               select new
                               {
                                   Audience = MakeFriendlyCommentAudience((CommentsType)rc.commentTypeEnum),
                                   CreatedDate = rc.createdDate,
                                   Text = rc.commentText
                               };

                if (details != null)
                {
                    RequestDetails newDetails = new RequestDetails();
                    List<RequestFormField> newForm = new List<RequestFormField>();
                    string ADManager = String.Empty;
                    foreach (var detail in details)
                    {
                        if (ADManager == String.Empty) { ADManager = (includeADManager ? CompareManagerName(detail.UserId, detail.ADManager) : null); }
                        newDetails.Title = detail.Title;
                        newDetails.Manager = detail.Manager;
                        newDetails.ADManager = ADManager;
                        newDetails.Requestor = detail.Requestor;
                        newDetails.SearchLinkUrl= Model.Utilities.WebRootUrl + Model.PageNames.SEARCH + ".aspx?requestId=" +  requestId.ToString();

                        RequestFormField newField = new RequestFormField();
                        newField.Label = detail.Label;
                        newField.Text = detail.Text;
                        newForm.Add(newField);
                    }
                    newDetails.Details = newForm;

                    if (comments != null)
                    {

                        List<RequestComments> newComments = new List<RequestComments>();

                        foreach (var comment in comments)
                        {
                            RequestComments newComment = new RequestComments();
                            newComment.Audience = comment.Audience;
                            newComment.CreatedDate = comment.CreatedDate.ToString("MMM d, yyyy") + " at " + comment.CreatedDate.ToString("h:mm tt");
                            newComment.Text = comment.Text;
                            newComments.Add(newComment);
                        }
                        newDetails.Comments = newComments;
                    }

                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(newDetails.GetType());
                    using (MemoryStream ms = new MemoryStream())
                    {
                        serializer.WriteObject(ms, newDetails);
                        string retVal = Encoding.Default.GetString(ms.ToArray());
                        return retVal;
                    }
                }
                return string.Empty;
            }
        }
        public Dictionary <string, object> CollateParams(TargetDeliveryRequest deliveryRequest = default, RequestDetails requestDetails = default)
        {
            var result  = new Dictionary <string, object>();
            var address = requestDetails?.Address ?? deliveryRequest?.DeliveryRequest?.Context?.Address;
            var url     = this.referring ? address?.ReferringUrl : address?.Url;

            if (string.IsNullOrEmpty(url))
            {
                return(result);
            }

            try
            {
                var parsed     = new Uri(url);
                var domainInfo = this.domainParser.Parse(url);
                var subdomain  = GetSubDomain(domainInfo.SubDomain);

                result.Add(PageUrl, parsed.OriginalString);
                result.Add(PageUrlLower, parsed.OriginalString.ToLowerInvariant());
                result.Add(PageDomain, parsed.Host);
                result.Add(PageDomainLower, parsed.Host.ToLowerInvariant());
                result.Add(PageSubdomain, subdomain);
                result.Add(PageSubdomainLower, subdomain.ToLowerInvariant());
                result.Add(PageTopLevelDomain, domainInfo.Tld);
                result.Add(PageTopLevelDomainLower, domainInfo.Tld.ToLowerInvariant());
                result.Add(PagePath, parsed.AbsolutePath);
                result.Add(PagePathLower, parsed.AbsolutePath.ToLowerInvariant());
                result.Add(PageQuery, parsed.Query);
                result.Add(PageQueryLower, parsed.Query.ToLowerInvariant());
                result.Add(PageFragment, parsed.Fragment);
                result.Add(PageFragmentLower, parsed.Fragment.ToLowerInvariant());
            }
            catch (UriFormatException)
            {
                this.logger?.LogWarning(Messages.MalformedAddressUrl + url);
            }

            return(result);
        }
 void Continue(RequestDetails item, WebRequest request, IAsyncResult result)
 {
     item.Callback(request, result);
     Run();
 }
示例#18
0
 public ResponseEventArgs(RequestDetails request, ResponseDetails response) : base(request)
 {
     _response = response;
 }
        private void SendRequestToServerPortal(RequestDetails requestDetails)
        {
            ApplicationEx.Instance.IsBusy = true;
            _activeRequestDetails = requestDetails;

            if (string.IsNullOrEmpty(_currentOperation))
                _currentOperation = "Calling Server...";

            if (ApplicationEx.Instance.WebServiceInformDelegate != null)
                ApplicationEx.Instance.WebServiceInformDelegate(true, _currentOperation);

            Request.Document.Root.RemoveAll();

            if (Response != null)
                Response.Document.Root.RemoveAll();

            for (int payloadEntryIndex = 0; payloadEntryIndex < requestDetails.RequestPayload.GetLength(0); payloadEntryIndex++)
            {
                if (requestDetails.RequestPayload[payloadEntryIndex].Document == Request)
                {
                    Request.Document.Root.Add(requestDetails.RequestPayload[payloadEntryIndex]);
                }
                else
                {
                    XElement child = new XElement(requestDetails.RequestPayload[payloadEntryIndex]);
                    Request.Document.Root.Add(child);
                }
            }

            string errorMessage = string.Empty;
            string request = Request.ToString();

            if (ServerRequest != null)
                ServerRequest(request);

            RemoteService.ExecAsync(request, ApplicationEx.Instance.ActiveSession.SessionToken, errorMessage);
            IsRequestInProgress = true;
        }
示例#20
0
 public RequestEventArgs(RequestDetails request)
 {
     _request = request;
 }