Пример #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="InMemoryPayloadRetriever"/> class.
            /// </summary>
            public InMemoryPayloadRetriever(PayloadInfo payload)
            {
                if (payload == null)
                {
                    throw new ArgumentNullException(nameof(payload));
                }

                _payload = payload;
            }
Пример #2
0
        protected ApplicationInfo GetPayload(PayloadInfo payloadInfo)
        {
            var manifestContent          = GetManifest(payloadInfo.EspaceName);
            var entityModuleNames        = GetEntityModuleNames(payloadInfo.EspaceName);
            var moduleDefinitionsContent = GetModuleDefinitions(payloadInfo.EspaceName);

            return(ApplicationInfoGenerator.GenerateApplicationInfo(manifestContent, entityModuleNames, moduleDefinitionsContent,
                                                                    payloadInfo.EspaceName, payloadInfo.EspaceId, payloadInfo.EspaceVersionId, payloadInfo.EspaceUId));
        }
Пример #3
0
        private void ButtonNextPayload_Click(object sender, RoutedEventArgs e)
        {
            PayloadInfo pi = (sender as FrameworkElement).DataContext as PayloadInfo;

            int targetPayloadId = pi.PayloadId + 1;
            int targetStreamId  = pi.StreamId;

            SelectPayload(targetPayloadId, targetStreamId, true);
        }
Пример #4
0
        protected ApplicationInfo GetPayload(PayloadInfo payloadInfo)
        {
            var manifestContent          = GetManifest(payloadInfo.EspaceName);
            var entityModuleNames        = GetEntityModuleNames(payloadInfo.EspaceName);
            var moduleDefinitionsContent = GetModuleDefinitions(payloadInfo.EspaceName);

            using (Transaction trans = DatabaseAccess.ForRuntimeDatabase.GetReadOnlyTransaction()) {
                return(ApplicationInfoGenerator.GenerateApplicationInfo(trans, RuntimeSettingsProvider.Instance, manifestContent, entityModuleNames, moduleDefinitionsContent,
                                                                        payloadInfo.EspaceName, payloadInfo.EspaceId, payloadInfo.EspaceVersionId, payloadInfo.EspaceUId, payloadInfo.StaticEntitiesKeys));
            }
        }
Пример #5
0
        public bool ProcessPayload(PayloadInfo payloadInfo)
        {
            try
            {
                string payloadInfoJson = JsonConvert.SerializeObject((object)payloadInfo);
                _logger.LogInformation("Retrieving Queue Connection properties");


                string connectionString = _configuration["AppSettings:QueueConnection"];
                string queueName        = _configuration["AppSettings:QueueName"];
                _logger.LogDebug(" queueConnectionString is " + connectionString);
                _logger.LogDebug(" queueName is " + queueName);


                _logger.LogInformation("Creating Queue Connection");
                QueueServiceClient queueServiceClient = new QueueServiceClient(connectionString, new QueueClientOptions()
                {
                    MessageEncoding = QueueMessageEncoding.Base64
                });
                _logger.LogInformation("Created Queue Connection");


                string base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes(payloadInfoJson));


                _logger.LogInformation("Retrieve the Storage Queue Client");
                QueueClient queueClient = queueServiceClient.GetQueueClient(queueName);
                _logger.LogInformation("Create the queue if it doesn't exist");

                Response response = queueClient.CreateIfNotExists();

                if (response != null)
                {
                    _logger.LogInformation($"Created queue {queueName}! Response is {response.Status}");
                }
                else
                {
                    _logger.LogInformation("The queue " + queueName + " already exists");
                }


                _logger.LogInformation("Send the base64 encoded Json Payload " + payloadInfoJson);
                _logger.LogInformation("the Message is queued " + queueClient.SendMessage(base64String).Value.MessageId);
                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Eeception occurred while queueing {ex}");
                return(false);
            }
        }
Пример #6
0
        void WaveFormControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (sender != null && ((FrameworkElement)sender).DataContext != null)
            {
                PayloadInfo payloadInfo = ((PayloadInfo)(((FrameworkElement)sender).DataContext));
                startTimeOffset = payloadInfo.PresentationTime - AsfHeaderItem.Configuration.AsfPreroll;


                if (payloadInfo != null)
                {
                    Task.Factory.StartNew((Action)(() => { ComputeWaveForm(startTimeOffset); }));
                }
            }
        }
Пример #7
0
        void WaveFormControl_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            this.yTranslate = mainCanvas.ActualHeight / 2;
            this.yScale     = mainCanvas.ActualHeight / 2;

            PayloadInfo payloadInfo = ((PayloadInfo)(((FrameworkElement)sender).DataContext));

            startTimeOffset = payloadInfo.PresentationTime - AsfHeaderItem.Configuration.AsfPreroll;


            if (payloadInfo != null)
            {
                Task.Factory.StartNew((Action)(() => { ComputeWaveForm(startTimeOffset); }));
            }
        }
Пример #8
0
        protected virtual ApplicationInfo GetCachedPayload(AppInfo appInfo)
        {
            if (payloadCache == null)
            {
                lock (typeof(ModuleServicesApiController)) {
                    if (payloadCache == null)
                    {
                        var payloadInfo = new PayloadInfo(appInfo.eSpaceId, appInfo.eSpaceVersionId, appInfo.eSpaceUID, appInfo.eSpaceName, appInfo.Properties.ClientSideTracingEnabled, appInfo.GetApplicationDefaultTimeout());
                        payloadCache = GetPayload(payloadInfo);
                    }
                }
            }

            UpdateNonCacheablePropeties(payloadCache, appInfo.Properties.ClientSideTracingEnabled, appInfo.GetApplicationDefaultTimeout());
            return(payloadCache);
        }
Пример #9
0
        public PayloadInfo GetPayloadInfo(byte[] message)
        {
            var info = new PayloadInfo();

            foreach (var payloadLengthRule in _rules)
            {
                if (payloadLengthRule.IsSatisfiedBy(message))
                {
                    info = payloadLengthRule.ApplyTo(message);
                    break;
                }
            }

            info.IsMasked = _byteHelper.ValueOfBitAt(message[1], 7);

            return info;
        }
        public UserLoginInfo GetUserInfor()
        {
            string        jsonPayload = GetAuthPayloadString();
            PayloadInfo   data        = Converter.Deserialize <PayloadInfo>(jsonPayload);
            UserLoginInfo user        = new UserLoginInfo();

            user.UserID        = data.user_id;
            user.Email         = data.email;
            user.StringeeToken = GenerateJwtStringee(_appSettings.IsUser, _appSettings.Secret, user.UserID.ToString());
            if (data.list_roles.Contains("GROUP_ADMIN"))
            {
                user.Role = 1;
            }
            else
            {
                user.Role = 0;
            }
            return(user);
        }
Пример #11
0
        public bool ProcessPayload(PayloadInfo payloadInfo)
        {
            string teamName      = this._configuration["AppSettings:GitHubTeamName"];
            string GitHubAppName = this._configuration["AppSettings:GitHubAppName"];
            string token         = this._configuration["AppSettings.GitHubToken"];

            this._logger.LogInformation("GitHubAppName  is " + GitHubAppName);
            this._logger.LogInformation("GitHubTeamName  is " + teamName);
            try
            {
                this._logger.LogInformation(" Calling ProtectRepo directly " + payloadInfo.repoName + "/" + payloadInfo.branchName);
                this._branchProtection.ProtectRepo(payloadInfo, GitHubAppName, token, teamName).GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                this._logger.LogInformation(string.Format(" Calling ProtectRepo directly failed {0}", (object)ex));
                return(false);
            }
            return(true);
        }
Пример #12
0
        public async Task <IActionResult> Receive()
        {
            Request.Headers.TryGetValue("X-GitHub-Event", out StringValues eventName);
            Request.Headers.TryGetValue("X-GitHub-Delivery", out StringValues delivery);
            Request.Headers.TryGetValue("User-Agent", out StringValues userAgent);
            _logger.LogInformation($"Delivery ID is {delivery}");
            if (!eventName.ToString().Equals("repository", StringComparison.OrdinalIgnoreCase))
            {
                _logger.LogInformation(string.Format("Escaping this call as it is not for repository creation ! The Event Name is {0}", (object)eventName));
                return(Ok());
            }
            using (StreamReader reader = new StreamReader(Request.Body))
            {
                string payloadJson = await reader.ReadToEndAsync();

                _logger.LogDebug(payloadJson);

                Request.Headers.TryGetValue("X-Hub-Signature", out StringValues signature);
                if (IsGithubPushAllowed(payloadJson, eventName, signature, userAgent))
                {
                    _logger.LogInformation("GitHub Push HMAC is OK");
                    PayloadInfo payloadInfo = _payloadParser.TexttoPayloadInfo(payloadJson);
                    if (payloadInfo.Created)
                    {
                        _logger.LogInformation("Calling to Protect Repo " + payloadInfo.repoName);
                        if (_payloadProcessor.ProcessPayload(payloadInfo))
                        {
                            _logger.LogInformation("Calling to Protect Repo completed " + payloadInfo.repoName);
                            return(Ok());
                        }
                        _logger.LogError("Queueing Payload failed");
                        return(StatusCode(500));
                    }
                    _logger.LogInformation("NOT Calling to Protect Repo  " + payloadInfo.repoName);
                    return(Ok());
                }
                _logger.LogInformation(string.Format("HMAC Signature not OK or userAgent is not Authorized {0} !", (object)signature));
                return(Unauthorized());
            }
        }
Пример #13
0
        /// <summary>
        /// Harvest a payload.
        /// </summary>
        /// <param name="path">The path of the payload.</param>
        /// <returns>A harvested payload.</returns>
        public Wix.RemotePayload HarvestRemotePayload(string path)
        {
            if (null == path)
            {
                throw new ArgumentNullException("path");
            }

            if (!File.Exists(path))
            {
                throw new WixException(UtilErrors.FileNotFound(path));
            }

            PayloadInfo payloadInfo = new PayloadInfo()
            {
                SourceFile = Path.GetFullPath(path),
                SuppressSignatureValidation = false // assume signed, if its unsigned it won't get the certificate properties
            };

            PayloadInfoRow.ResolvePayloadInfo(payloadInfo);

            return(payloadInfo);
        }
 private void onPacketQueue(PayloadInfo inf)
 {
 }
Пример #15
0
        private void OnPayloadReceived(GatewayPayload payload, PayloadInfo info)
        {
            if (payload.DispatchType == null)
            {
                return;
            }
            _logManager.Info("Bridge", $"Received {payload.DispatchType}");
            string methodName;

            switch (payload.DispatchType)
            {
            case GatewayDispatchType.MessageCreate:
                methodName = "RelayMessageCreated";
                break;

            case GatewayDispatchType.MessageUpdate:
                methodName = "RelayMessageUpdated";
                break;

            case GatewayDispatchType.MessageDelete:
                methodName = "RelayMessageDeleted";
                break;

            case GatewayDispatchType.MessageDeleteBulk:
                methodName = "RelayMessageDeletedBulk";
                break;

            case GatewayDispatchType.MessageReactionAdd:
                methodName = "RelayReactionAdded";
                break;

            case GatewayDispatchType.MessageReactionRemove:
                methodName = "RelayReactionRemoved";
                break;

            case GatewayDispatchType.MessageReactionRemoveAll:
                methodName = "RelayReactionRemovedBulk";
                break;

            case GatewayDispatchType.GuildMemberAdd:
                methodName = "RelayUserJoined";
                break;

            case GatewayDispatchType.GuildMemberRemove:
                methodName = "RelayUserLeft";
                break;

            case GatewayDispatchType.GuildMemberUpdate:

                methodName = "RelayUserLeft";
                break;

            case GatewayDispatchType.PresenceUpdate:
                methodName = "RelayPresenceUpdate";
                break;

            default:
                return;
            }

            var json = _serializer.WriteUtf8String(payload.Data).ToString();

            _hub.InvokeAsync(methodName, json).GetAwaiter().GetResult();
        }
Пример #16
0
 private static string GetPayloadInfo(PayloadInfo payload)
 {
     return(payload.MassKilograms.HasValue ? $"{payload.Name} ({payload.MassKilograms} kg)" : payload.Name);
 }
Пример #17
0
        /// <summary>
        /// Harvest a payload.
        /// </summary>
        /// <param name="path">The path of the payload.</param>
        /// <returns>A harvested payload.</returns>
        public Wix.RemotePayload HarvestRemotePayload(string path)
        {
            if (null == path)
            {
                throw new ArgumentNullException("path");
            }

            if (!File.Exists(path))
            {
                throw new WixException(UtilErrors.FileNotFound(path));
            }

            PayloadInfo payloadInfo = new PayloadInfo() 
            {
                SourceFile = Path.GetFullPath(path),
                SuppressSignatureValidation = false // assume signed, if its unsigned it won't get the certificate properties
            };

            PayloadInfoRow.ResolvePayloadInfo(payloadInfo);

            return payloadInfo;
        }
Пример #18
0
        private void ShowRocketData()
        {
            rocketNameLabel.Text     = _rocketInfo.Name;
            launchDateLabel.Text     = $"{_missionData.DateLocal} Local\n{_missionData.DateUtc} UTC\n";
            launchSiteNameLabel.Text = _launchpadInfo.FullName;

            _payloadInfo = JObject.Parse(new RestClient($"{MainForm.ApiUrl}/payloads/{_missionData.PayloadsId[0]}")
                                         .Get(new RestRequest("/")).Content).ToObject <PayloadInfo>();

            switch (_rocketInfo.Name)
            {
            case "Falcon Heavy" when _payloadInfo.Type == "Satellite":
                ShowRocketImage("$this.falconHeavyPayloadImage");
                break;

            case "Falcon 9" when _payloadInfo.Type == "Satellite":
                ShowRocketImage("$this.falcon9PayloadImage");
                break;

            case "Falcon 9" when _payloadInfo.Type == "Crew Dragon":
                ShowRocketImage("$this.falcon9CrewDragonImage");
                break;

            case "Falcon 9" when _payloadInfo.Type.Contains("Dragon 1.") ||
                _payloadInfo.Type.Contains("Dragon 2.") ||
                _payloadInfo.Type.Contains("Dragon 3.") ||
                _payloadInfo.Type.Contains("Dragon 4."):
                ShowRocketImage("$this.falcon9DragonImage");

                break;
            }

            var cores     = _missionData.Cores;
            var coresData = new List <string>();

            if (cores.Count > 0)
            {
                var coreNumber = 1;
                foreach (var core in cores)
                {
                    coresData.Add($" — Core: {coreNumber} — ");
                    if (!string.IsNullOrEmpty(core.CoreId))
                    {
                        var coreInfo = JObject.Parse(new RestClient($"{MainForm.ApiUrl}/cores/{core.CoreId}")
                                                     .Get(new RestRequest("/")).Content).ToObject <CoreInfo>();
                        coresData.Add(coreInfo.Serial != null ? $"Core serial: {coreInfo.Serial}" : "Core serial: -");
                        coresData.Add(coreInfo.Block != null ? $"Block: {coreInfo.Block}" : "Block: -");
                        coresData.Add($"Launches: {coreInfo.Launches.Count}");
                        coresData.Add(coreInfo.ReuseCount != null ? $"Reuses: {coreInfo.ReuseCount}" : "Reuses: -");
                        coresData.Add($"Status: {coreInfo.Status}");
                        coresData.Add(coreInfo.AsdsLandings != null ? $"ASDS Landings: {coreInfo.AsdsLandings}" : "ASDS Landings: -");
                        coresData.Add(coreInfo.RtlsLandings != null ? $"RTLS Landings: {coreInfo.RtlsLandings}" : "RTLS Landings: -");
                    }
                    else
                    {
                        coresData.Add("!No details!");
                    }
                    coresData.Add(string.Empty);
                    coreNumber++;
                }

                coresData.RemoveAt(coresData.Count - 1);
                firstStageTextBox.Text = string.Join(Environment.NewLine, coresData);
            }
            else
            {
                firstStageTextBox.TextAlign = HorizontalAlignment.Center;
                firstStageTextBox.Text      = " — No data — ";
            }

            var payloads     = _missionData.PayloadsId;
            var payloadsData = new List <string>();

            if (payloads.Count > 0)
            {
                var payloadNumber = 1;
                foreach (var payload in payloads)
                {
                    _payloadInfo = JObject.Parse(new RestClient($"{MainForm.ApiUrl}/payloads/{payload}")
                                                 .Get(new RestRequest("/")).Content).ToObject <PayloadInfo>();

                    payloadsData.Add($" — Payload: {payloadNumber} — ");
                    if (!string.IsNullOrEmpty(_payloadInfo.Id))
                    {
                        payloadsData.Add(_payloadInfo.Name != null ? $"Name: {_payloadInfo.Name}" : "Name: -");
                        payloadsData.Add(_payloadInfo.Customers != null ? $"Customers: {string.Join(", ", _payloadInfo.Customers)}" : "Customers: -");
                        payloadsData.Add(_payloadInfo.Nationalities != null ? $"Nationalities: {string.Join(", ", _payloadInfo.Nationalities)}" : "Nationalities: -");
                        payloadsData.Add(_payloadInfo.Manufacturers != null ? $"Manufacturers: {string.Join(", ", _payloadInfo.Manufacturers)}" : "Manufacturers: -");
                        payloadsData.Add(_payloadInfo.MassKilograms != null ? $"Mass (kg): {_payloadInfo.MassKilograms}" : "Mass (kg): -");
                        payloadsData.Add(_payloadInfo.MassPounds != null ? $"Mass (lbs): {_payloadInfo.MassPounds}" : "Mass (lbs): -");
                        payloadsData.Add(_payloadInfo.Type != null ? $"Type: {_payloadInfo.Type}" : "Type: -");
                        payloadsData.Add(_payloadInfo.Orbit != null ? $"Orbit: {_payloadInfo.Orbit}" : "Orbit: -");
                    }
                    else
                    {
                        coresData.Add("!No details!");
                    }
                    payloadsData.Add(string.Empty);
                    payloadNumber++;
                }

                payloadsData.RemoveAt(payloadsData.Count - 1);
                secondStageTextBox.Text = string.Join(Environment.NewLine, payloadsData);
            }
            else
            {
                secondStageTextBox.TextAlign = HorizontalAlignment.Center;
                secondStageTextBox.Text      = " — No data — ";
            }
        }