private string GetReusedPartsData(LaunchInfo launch)
        {
            var reusedPartsList = new List <string>();

            if (launch.Cores[0].Reused ?? false)
            {
                reusedPartsList.Add("Core");
            }

            if (launch.Capsules.Count > 0 && launch.Capsules[0].Value.ReuseCount > 0)
            {
                reusedPartsList.Add("Capsule");
            }

            if (launch.Fairings?.Reused ?? false)
            {
                reusedPartsList.Add("Fairings");
            }

            if (launch.Cores.Count == 3 && (launch.Cores[1].Reused ?? false))
            {
                reusedPartsList.Add("First side core");
            }

            if (launch.Cores.Count == 3 && (launch.Cores[2].Reused ?? false))
            {
                reusedPartsList.Add("Second side core");
            }

            return(reusedPartsList.Count > 0 ? string.Join(", ", reusedPartsList) : "none");
        }
Example #2
0
            public NotificationState(LaunchInfo launch, DateTime utcNow)
            {
                Launch = launch;

                TimeToLaunch  = launch.DateUtc - utcNow;
                LaunchTimeUtc = launch.DateUtc;
            }
        private string GetLinksData(LaunchInfo info)
        {
            var links = new List <string>();

            if (info.Links.Webcast != null)
            {
                links.Add($"__**[YT stream]({info.Links.Webcast})**__");
            }

            if (info.Links.Presskit != null)
            {
                links.Add($"[Presskit]({info.Links.Presskit})");
            }

            if (info.Links.Reddit.Campaign != null)
            {
                links.Add($"[Campaign]({info.Links.Reddit.Campaign})");
            }

            if (info.Links.Reddit.Launch != null)
            {
                links.Add($"[Launch]({info.Links.Reddit.Launch})");
            }

            if (info.Links.Reddit.Media != null)
            {
                links.Add($"[Media]({info.Links.Reddit.Media})");
            }

            return(string.Join(", ", links));
        }
Example #4
0
 virtual public void Setup(BoardCursorActualCore c, TweenHandler t, BlockHandler bh, Vector2 nexterPos, bool smallNext, bool show = true, bool touch = false)
 {
     GetPersistData();
     usingTouchControls  = touch;
     topoffset           = 1;
     shiftall            = false; dead = false; cursor = c; deathTile = 3; isShown = show; th = t;
     launchInfo          = new LaunchInfo(-1, 0, deathTile, 0, 1.0f, false);
     countdownFromLaunch = 0; actionDelay = 0;
     changes             = new List <MirrorChange>();
     keyStates           = new int[4] {
         -1, -1, -1, -1
     };
     tileSheet     = GetTileSheet();
     shapeSheet    = GetShapeSheet();
     overlaySprite = GetOverlaySprite();
     bn            = ScriptableObject.CreateInstance <BlockNexter>();
     if (isShown)
     {
         bn.SetupUniversalPrefabAndSheet(PD.universalPrefab, tileSheet, overlaySprite);
     }
     bn.Initialize(bh, nexterPos.x, nexterPos.y, player, isShown, smallNext, ((smallNext || !PD.IsLeftAlignedHUD()) && player == 1) ? 1 : -1);
     SetupTilesList();
     bn.SetupTileGraphics();
     CreateBG();
     chain = 0; misses = 0;
 }
Example #5
0
        public void Launch(LaunchInfo launchInfo)
        {
            var device = db.Set <Device>().FirstOrDefault(o => o.CPUSerialNumber == launchInfo.CPUSerialNumber);

            if (device == null)
            {
                device = new Device
                {
                    ComputerName    = launchInfo.ComputerName,
                    CPUSerialNumber = launchInfo.CPUSerialNumber,
                    MACAddress      = launchInfo.MACAddress,
                    ExpirationDate  = DateTime.Now.AddDays(30).Date,
                    Name            = launchInfo.Name,
                    CreateOn        = DateTime.Now,
                    ProductKey      = launchInfo.ProductKey,
                    SystemType      = launchInfo.SystemType,
                    UpdateOn        = DateTime.Now
                };
                db.Set <Device>().Add(device);
            }
            else
            {
                device.Name     = launchInfo.Name;
                device.UpdateOn = DateTime.Now;
            }

            var launchHis = new LaunchHis {
                DevieID = device.ID, StartOn = DateTime.Now
            };

            db.Set <LaunchHis>().Add(launchHis);
            db.SaveChanges();
        }
Example #6
0
    public void SetLaunchInfoForLaunch()
    {
        int x = cursor.getX();

        int[] lengthTypeTopy = GetLaunchDetails(x);
        int   length         = lengthTypeTopy[0];
        int   type           = lengthTypeTopy[1];
        int   topy           = lengthTypeTopy[2];

        if (length < 2)
        {
            HandleShitRow(); return;
        }
        float launchBonus = launchInfo.bonus;

        if (countdownFromLaunch > 0)
        {
            chain++; launchBonus += 0.2f;
        }
        else
        {
            chain = 0; launchBonus = 1.0f;
        }
        launchInfo = new LaunchInfo(x, length, type, topy, launchBonus);
    }
Example #7
0
        private async Task <NotificationState> SendNotification([NotNull] LaunchInfo launch, string message)
        {
            var subs = await _notifications.GetSubscriptions();

            await subs.EnumerateAsync(async s =>
            {
                if (!(_client.GetChannel(s.Channel) is ITextChannel channel))
                {
                    return;
                }

                var m = message;
                if (s.MentionRole.HasValue && channel is IGuildChannel gc)
                {
                    var role = gc.Guild.GetRole(s.MentionRole.Value);
                    if (role != null)
                    {
                        m = $"{role.Mention} {message}";
                    }
                }

                await channel.SendMessageAsync(m);
            });

            return(new NotificationState(launch, DateTime.UtcNow));
        }
Example #8
0
        public void AddLaunchToMruList(LaunchInfo launchInfo)
        {
            var newEntry = new LaunchMruEntry
            {
                ExecutablePath      = launchInfo.FileName ?? string.Empty,
                Arguments           = launchInfo.Arguments ?? string.Empty,
                MonitorAllFromStart = launchInfo.Options.HasFlag(LaunchOptions.MonitorAllFromStart)
            };

            lock (mSync)
            {
                int existingIndex = mLaunchMruEntries.FindIndex(existingEntry =>
                                                                string.Equals(existingEntry.ExecutablePath, newEntry.ExecutablePath, StringComparison.OrdinalIgnoreCase) &&
                                                                string.Equals(existingEntry.Arguments, newEntry.Arguments, StringComparison.Ordinal));

                if (existingIndex >= 0)
                {
                    mLaunchMruEntries.RemoveAt(existingIndex);
                }

                mLaunchMruEntries.Insert(0, newEntry);
                if (mLaunchMruEntries.Count > cMaxMruListSize)
                {
                    mLaunchMruEntries.RemoveAt(cMaxMruListSize);
                }

                Settings.LaunchMruList = Serialize(mLaunchMruEntries);
                Settings.Save();
            }
        }
Example #9
0
        void launchTitleWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            LaunchInfo lmi = (LaunchInfo)e.Argument;

            Program.XBox.LaunchTitle(lmi.FileInfo.FullName);
            e.Result = lmi.Module;
        }
Example #10
0
        public static bool LaunchProcess(ref LaunchInfo info)
        {
            if (!voices.Contains(info.voice))
            {
                return(false);
            }
            if (!langs.Contains(info.lang))
            {
                return(false);
            }

            ProcessStartInfo psi = new ProcessStartInfo($@"{path}\VoiceroidCLI.exe", $"--seed={seed} --voice={info.voice} --lang={info.lang}");

            psi.UseShellExecute        = false;
            psi.RedirectStandardError  = true;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardInput  = true;
            psi.CreateNoWindow         = true;
            psi.WorkingDirectory       = path;

            voiceroid.Add(++id, Process.Start(psi));
            info.id = id;

            iconProcess.StandardInput.WriteLine($"Add,{id},{info.voice},{info.lang}");

            return(true);
        }
Example #11
0
        private async Task <NotificationState> SendNotification(LaunchInfo launch, string message)
        {
            var subs = _notifications.GetSubscriptions();

            await foreach (var s in subs)
            {
                if (_client.GetChannel(s.Channel) is not ITextChannel channel)
                {
                    continue;
                }

                var m = message;
                if (s.MentionRole.HasValue && channel is IGuildChannel gc)
                {
                    var role = gc.Guild.GetRole(s.MentionRole.Value);
                    if (role != null)
                    {
                        m = $"{role.Mention} {message}";
                    }
                }

                await channel.SendMessageAsync(m);
            }

            return(new NotificationState(launch, DateTime.UtcNow));
        }
Example #12
0
        void ExecutableFileModule_Click(object sender, EventArgs e)
        {
            LaunchInfo li = (LaunchInfo)((ToolStripMenuItem)sender).Tag;

            lblStatus.Text = "Launching: " + li.FileInfo.Name;
            probar.Style   = ProgressBarStyle.Marquee;
            this.Enabled   = false;
            launchTitleWorker.RunWorkerAsync(li);
        }
        public DiscordEmbed Build(LaunchInfo launch, ulong?guildId, bool informAboutSubscription)
        {
            var embed = new DiscordEmbedBuilder
            {
                Title       = $"{launch.FlightNumber}. {launch.Name} ({launch.Rocket.Value.Name} {launch.Rocket.Value.Type})",
                Description = launch.Details.ShortenString(1024) ?? "*No description at this moment :(*",
                Color       = new DiscordColor(Constants.EmbedColor),
                Thumbnail   = new DiscordEmbedBuilder.EmbedThumbnail
                {
                    Url = launch.Links.Patch.Large ?? Constants.SpaceXLogoImage
                }
            };

            var launchDateTime = DateFormatter.GetDateStringWithPrecision(
                launch.DateUtc ?? DateTime.MinValue,
                launch.DatePrecision ?? DatePrecision.Year,
                true, true, true);

            embed.AddField(":clock4: Launch time (UTC)", launchDateTime, true);

            if (guildId != null)
            {
                var localLaunchDateTime = GetLocalLaunchDateTime(
                    guildId.Value,
                    launch.DateUtc ?? DateTime.MinValue,
                    launch.DatePrecision ?? DatePrecision.Year);

                var timeZoneName = _timeZoneService.GetTimeZoneForGuild(guildId.Value);

                if (timeZoneName != null)
                {
                    embed.AddField($":clock230: Launch time ({timeZoneName})", localLaunchDateTime);
                }
            }

            var googleMapsLink = $"[Map]({GoogleMapsLinkFormatter.GetGoogleMapsLink(launch.Launchpad.Value.Latitude ?? 0.0, launch.Launchpad.Value.Longitude ?? 0.0)})";

            embed.AddField(":stadium: Launchpad", $"{launch.Launchpad.Value.FullName} **[{googleMapsLink}]**");
            embed.AddField($":rocket: First stages ({1 + launch.Rocket.Value.Boosters})", GetCoresData(launch.Cores));
            embed.AddField($":package: Payloads ({launch.Payloads.Count})", GetPayloadsData(launch.Payloads));
            embed.AddField(":recycle: Reused parts", GetReusedPartsData(launch));

            var linksData = GetLinksData(launch);

            if (linksData.Length > 0)
            {
                embed.AddField(":newspaper: Links", linksData);
            }

            if (informAboutSubscription)
            {
                embed.AddField("\u200b", "*Click the reaction below to subscribe this flight and be notified on DM 10 minutes before the launch.*");
            }

            return(embed);
        }
Example #14
0
        //

        public MissionDataForm(LaunchInfo launchInfo)
        {
            _missionData   = launchInfo;
            _imagesInMedia = _missionData.Links.FlickrImages.Count;
            InitializeComponent();
            CenterToScreen();
            rocketDetailsButton.Select();
            HideMediaControls();
            ShowRocketData();
        }
Example #15
0
    public LaunchInfo Launch()
    {
        LaunchInfo info = GetLaunchInfo();

        rb.isKinematic = false;
        rb.useGravity  = true;
        rb.velocity    = info.initialVelocity;
        launching      = true;
        return(info);
    }
Example #16
0
        //List<Idiom> items = _idioms.Find(new BsonDocument()).ToList();
        //foreach (var item in items)
        //{
        //    if (item.Name.Length < 4)
        //    {
        //        item.Name = item.Name + ",需要订正";
        //        _idioms.FindOneAndReplace(x => x.Id == item.Id, item);
        //        Console.WriteLine("已标注:" + item.Name);
        //    }
        //}
        //}

        //public string GenerateIdiom()
        //{
        //    Dictionary<string, string> dic = new Dictionary<string, string>
        //    {
        //        { "5beghawgsagsaga7eb855e3e94", "66hhh" },
        //        { "5bebec2a2hgbhghhhhhhhh855e3e94", "6gggggh" }
        //    };
        //    Definition def = new Definition { Text = "hahaha", Addition = "666", IsBold = false, Source = "hhh", Links = dic };
        //    Definition def2 = new Definition { Text = "haa", Addition = "345sgsdgsdgc6", IsBold = false, Source = "hhh", Links = dic };
        //    List<Definition> defs = new List<Definition>
        //    {
        //        def,
        //        def2
        //    };
        //    _idioms.InsertOne(new Idiom { Name = "TEST", Definitions = defs, LastEditor = "fssssss", UpdateTimeUT = 666666, Index = 'C' });
        //    return "Done!";
        //}

        //public string GenerateLaunchInf()
        //{
        //    Dictionary<string, string> i = new Dictionary<string, string> {                { "aaaaaaaa", "6ggggh" },
        //        { "5bshedfhdfh4", "6gadfadah" }};
        //    _launchInf.InsertOne(new LaunchInf { Text = "23333", DailyIdiom = null, /*DailyIdiomName = "6666",*/  ThemeColor = null, LogoUrl = null, DisableAds = false, /*FloatEasterEggs = i, */DateUT = DateTimeOffset.MinValue.ToUnixTimeSeconds() });
        //    return "Done!";
        //}
        //public async Task<string> ToPinyin()
        //{
        //    using (var httpClient = new HttpClient())
        //    {
        //        List<Idiom> items = _idioms.Find(new BsonDocument()).ToList();
        //        foreach (var item in items)
        //        {
        //            if (items.IndexOf(item) >= 9200)
        //            {
        //                var res = await httpClient.GetStringAsync("http://v1.alapi.cn/api/pinyin?word=" + item.Name + "&tone=1");
        //                try
        //                {
        //                    JObject json = JObject.Parse(res);
        //                    if (json["msg"].ToString() == "success")
        //                    {
        //                        var filter = Builders<Idiom>.Filter.Eq("_id", new ObjectId(item.Id));
        //                        var update = Builders<Idiom>.Update.Set("Pinyin", json["data"]["pinyin"]);
        //                        _idioms.UpdateOne(filter, update);
        //                    }
        //                }
        //                catch (Exception)
        //                {

        //                }
        //                Console.WriteLine("Progress: " + (100.0 / items.Count) * (items.IndexOf(item) + 1) + "%");
        //            }

        //        }

        //        System.Threading.Thread.Sleep(200);
        //    }
        //    return "Complete!";
        //}
        //public void Test()
        //{
        //    List<Idiom> list = _idioms.Find(x => x.Definitions[1].Text.Contains("③")).ToList();
        //    foreach (var item in list)
        //    {
        //        //if (item.Definitions[0].Text.Length >= 5)
        //        //{
        //        //    try
        //        //    {
        //        //        string name = item.Definitions[0].Text.Substring(item.Definitions[0].Text.IndexOf("亦作") + 2, 4);
        //        //        Console.WriteLine(name);
        //        //        Idiom target = _idioms.Find(x => x.Name == name).FirstOrDefault();
        //        //        if (target != null)
        //        //        {
        //        //            Dictionary<string, string> dic = new Dictionary<string, string>();
        //        //            dic.Add(target.Id, target.Name);
        //        //            item.Definitions[0].Links = dic;
        //        //            List<Definition> df = item.Definitions;
        //        //            UpdateDefinition<Idiom> upd = Builders<Idiom>.Update.Set("Definitions", df);
        //        //            _idioms.UpdateOne(x => x.Id == item.Id, upd);
        //        //        }
        //        //    }
        //        //    catch
        //        //    {
        //        //        continue;
        //        //    }

        //        //}

        //        try
        //        {
        //            //string[] def = item.Definitions[0].Text.Split("②");
        //            Console.WriteLine(item.Id+" "+item.Name);
        //            //Idiom target = _idioms.Find(x => x.Id == item.Id).FirstOrDefault();
        //            //if (target != null)
        //            //{
        //            //    item.Definitions[0].Text = def[0].Replace("①", "");
        //            //    item.Definitions.Add(new Definition { Text = def[1], Addition = null, Examples = null, IsBold = false, Links = null, Source = item.Definitions[0].Source });
        //            //    List<Definition> df = item.Definitions;
        //            //    UpdateDefinition<Idiom> upd = Builders<Idiom>.Update.Set("Definitions", df);
        //            //    _idioms.UpdateOne(x => x.Id == item.Id, upd);
        //            //    Console.WriteLine(item.Id + ":" + item.Name + " 已修正!");
        //            //}
        //        }
        //        catch
        //        {
        //            continue;
        //        }

        //    }
        //    Console.WriteLine("Done");
        //}
        #endregion
        //这里生成每日成语。
        public void GenLI()
        {
            DateTimeOffset dateUT = DateTimeOffset.Now;
            int            hour   = dateUT.Hour;
            int            min    = dateUT.Minute;
            int            sec    = dateUT.Second;
            long           dateL  = dateUT.AddSeconds(-sec).AddMinutes(-min).AddHours(-hour).ToUnixTimeSeconds();
            //默认的每日成语。
            Idiom      deftIdiom = _launchInfo.Find(x => x.DateUT == DateTimeOffset.MinValue.ToUnixTimeSeconds()).FirstOrDefault().DailyIdiom;
            LaunchInfo info      = _launchInfo.Find(x => x.DateUT == dateL).FirstOrDefault();
            //从数据库里随机抽取一条成语。
            Idiom idi = _idioms.Aggregate().AppendStage <Idiom>("{$sample:{size:1}}").FirstOrDefault();

            //当idi不为null才运行。
            if (idi != null)
            {
                if (info == null)
                {
                    //这种情况说明当天的info还没有生成。
                    if (deftIdiom == null)
                    {
                        //若默认成语为空,则生成每日成语。
                        LaunchInfo ins = new() { Version = null, ArgsDic = null, Text = null, ThemeColor = null, LogoUrl = null, DailyIdiom = idi, IdiomsCount = 0, DateUT = dateL };
                        _launchInfo.InsertOne(ins);
                    }
                    else
                    {
                        //不为空则将默认成语写入当天的启动信息,方便以后查询记录。
                        LaunchInfo ins = new() { Version = null, ArgsDic = null, Text = null, ThemeColor = null, LogoUrl = null, DailyIdiom = deftIdiom, IdiomsCount = 0, DateUT = dateL };
                        _launchInfo.InsertOne(ins);
                    }
                }
                else
                {
                    //这种情况说明当天的info已经提前编辑好了,根据需要补全。
                    if (info.DailyIdiom == null)
                    {
                        if (deftIdiom == null)
                        {
                            //若默认成语为空,则生成每日成语。
                            UpdateDefinition <LaunchInfo> upd = Builders <LaunchInfo> .Update.Set("DailyIdiom", idi);

                            _launchInfo.UpdateOne(x => x.DateUT == dateL, upd);
                        }
                        else
                        {
                            //不为空则将默认成语写入当天的启动信息,方便以后查询记录。
                            UpdateDefinition <LaunchInfo> upd = Builders <LaunchInfo> .Update.Set("DailyIdiom", deftIdiom);

                            _launchInfo.UpdateOne(x => x.DateUT == dateL, upd);
                        }
                    }
                }
            }
        }
Example #17
0
        [NotNull] private static string DescribeLaunch([NotNull] LaunchInfo launch)
        {
            var date  = launch.LaunchDateUtc.HasValue ? launch.LaunchDateUtc.Value.Humanize() : "";
            var num   = launch.FlightNumber;
            var site  = launch.LaunchSite;
            var name  = launch.MissionName;
            var reuse = launch.Reuse;
            var type  = launch.Rocket.RocketName;

            return($"Flight {num} will launch '{name}' from {site.SiteName} on a{(reuse.Core ?? false ? " reused" : "")} {type} rocket {date}");
        }
Example #18
0
        [NotNull] private static string PeriodicReminderMessage([NotNull] LaunchInfo launch)
        {
            //Append video link if there is one.
            var video = "";

            if (launch.Links.VideoLink != null)
            {
                video = $". Watch it here: {launch.Links.VideoLink}.";
            }

            return($"SpaceX launch {launch.MissionName} will launch in {launch.LaunchDateUtc.Humanize()} {video}");
        }
Example #19
0
        private static string PeriodicReminderMessage(LaunchInfo launch)
        {
            //Append video link if there is one.
            var video = "";

            if (launch.Links.Webcast != null)
            {
                video = $". Watch it here: {launch.Links.Webcast}.";
            }

            return($"SpaceX launch {launch.Name} will launch in {launch.DateUtc.Humanize()} {video}");
        }
Example #20
0
        public LaunchInfo MergeLI(LaunchInfo current, LaunchInfo deft, bool proed)
        {
            if (current == null)
            {
                current = new LaunchInfo {
                    Version = null, ArgsDic = null, Text = null, ThemeColor = null, LogoUrl = null, DailyIdiom = null, IdiomsCount = 0, DateUT = 0
                }
            }
            ;
            //将当前启动信息与默认启动信息合并并返回。
            current.Version = DEBUG ? version.ToString() + "-dev" : version.ToString();
            current.ArgsDic = deft.ArgsDic;
            if (current.IdiomsCount == 0 && deft.IdiomsCount == 0)
            {
                current.IdiomsCount = _idioms.CountDocuments(new BsonDocument());
            }
            else if (current.IdiomsCount == 0)
            {
                current.IdiomsCount = deft.IdiomsCount;
            }
            if (current.Text == null)
            {
                current.Text = deft.Text;
            }
            if (current.ThemeColor == null)
            {
                current.ThemeColor = deft.ThemeColor;
            }
            if (current.LogoUrl == null)
            {
                current.LogoUrl = deft.LogoUrl;
            }
            if (current.DailyIdiom == null)
            {
                current.DailyIdiom = deft.DailyIdiom;
            }
            Idiom raw = current.DailyIdiom;

            if (Config.EnableProtection && proed && raw != null)
            {
                List <Definition> defs     = raw.Definitions;
                List <Definition> modified = new();
                foreach (Definition def in defs)
                {
                    def.Source = "网络";
                    modified.Add(def);
                }
                raw.Definitions    = modified;
                current.DailyIdiom = raw;
            }
            return(current);
        }
        public void Launch(LaunchInfo launchInfo)
        {
            if (NextToLaunch == null)
            {
                return;
            }
            _projectileHolder.AddChild(NextToLaunch);
            var toTranslate = launchInfo.Location - NextToLaunch.GlobalTransform.origin;

            NextToLaunch.GlobalTranslate(toTranslate);
            NextToLaunch.LinearVelocity = launchInfo.Velocity;
            NextToLaunch = (RigidBody)ProjectileScene.Instance();
        }
 public ActionResult <LaunchInfo> Post(LaunchInfo info)
 {
     info.id = null;
     if (Program.LaunchProcess(ref info))
     {
         presets.Add(info);
     }
     else
     {
         return(BadRequest());
     }
     return(info);
 }
Example #23
0
        private bool CheckIfReminderShouldBeSend(LaunchInfo launch)
        {
            if (launch.DatePrecision != DatePrecision.Hour)
            {
                return(false);
            }

            var minutesToLaunch = ((launch.DateUtc ?? DateTime.MaxValue) - DateTime.Now.ToUniversalTime()).TotalMinutes;

            var previousStateMinutesToLaunch = minutesToLaunch + 1;
            var newStateMinutesToLaunch      = minutesToLaunch;

            return(_notificationTimes.Any(p => p < previousStateMinutesToLaunch && p >= newStateMinutesToLaunch));
        }
Example #24
0
        public MissionDataForm(LaunchInfo launchInfo, RocketInfo rocketInfo, LaunchpadInfo launchpadInfo)
        {
            _missionData   = launchInfo;
            _rocketInfo    = rocketInfo;
            _launchpadInfo = launchpadInfo;
            _imagesInMedia = _missionData.Links.Flickr.Original.Count;

            InitializeComponent();
            CenterToScreen();
            rocketDetailsButton.Select();
            ShowMediaControls(false);
            ShowRocketData();
            AppTips();
        }
        private async Task SendLaunchNotificationToUserAsync(DiscordMember member, LaunchInfo nextLaunch)
        {
            var launchInfoEmbed = _launchInfoEmbedGenerator.Build(nextLaunch, null, false);
            await member.SendMessageAsync($"**{MinutesToLaunchToNotify} minutes to launch!**", false, launchInfoEmbed);

            if (nextLaunch.Links.Webcast != null)
            {
                await member.SendMessageAsync($"Watch launch at stream: {nextLaunch.Links.Webcast}");
            }

            await member.SendMessageAsync("*You received this message because we noticed that you subscribed this launch. Remember that " +
                                          "subscription is one-time and you have to do it again if you want to receive similar notification " +
                                          "about next launch in the future.*");
        }
Example #26
0
        public static Process LaunchtheSpyApp(LaunchInfo info)
        {
            string  arguments  = HandleInfo(info);
            Process appProcess = null;

            try
            {
                appProcess = LaunchtheSpyAppWithArg(arguments);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message.ToString());
            }
            return(appProcess);
        }
 private void CreateRegistry(LaunchInfo launchInfo)
 {
     if (!WindowsRegistry.IsRegeditKeyExist(Constants.EXPIRATION_DATE))
     {
         WindowsRegistry.SetRegistryValue(Constants.EXPIRATION_DATE, launchInfo.ExpirationDate.ToShortDateString());
     }
     if (!WindowsRegistry.IsRegeditKeyExist(Constants.ENCRYPTED_TEXT))
     {
         WindowsRegistry.SetRegistryValue(Constants.ENCRYPTED_TEXT, launchInfo.EncryptedText);
     }
     if (!WindowsRegistry.IsRegeditKeyExist(Constants.PRODUCT_KEY))
     {
         WindowsRegistry.SetRegistryValue(Constants.PRODUCT_KEY, launchInfo.ProductKey);
     }
 }
        public void TestMethod1()
        {
            var publicKey = @"
                            MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7PyjMEuniN6BPn8oqzIZ6AO1N
                            jSTO9R3adCCIwKfKIEoWXXM+tHDpktdPKSaAsWJPTNAGvEvtxOfzXib/EMXKqD0e
                            Uy5MatfpRjRdf1hJVimmfrb09Qx2j7CsKLy7nD23m4xubdYBwvkjMwt/L3JxB5D6
                            qryW1wei/j1c+/OCxQIDAQAB
                            ";


            var privateKey = @"MIICXQIBAAKBgQC7PyjMEuniN6BPn8oqzIZ6AO1NjSTO9R3adCCIwKfKIEoWXXM+
tHDpktdPKSaAsWJPTNAGvEvtxOfzXib/EMXKqD0eUy5MatfpRjRdf1hJVimmfrb0
9Qx2j7CsKLy7nD23m4xubdYBwvkjMwt/L3JxB5D6qryW1wei/j1c+/OCxQIDAQAB
AoGAT7vGYJgRNf4f6qgNS4pKHTu10RcwPFyOOM7IZ9M5380+HyXuBB6MEjowKwpH
1fcy+LepwaR+5KG7b5uBGY4H2ticMtdysBd9gLwnY4Eh4j7LCWE54HvELpeWXkWp
FQdb/NQhcqMAGwYsTnRPdBqkrUmJBTYqEGkIlqCQ5vUJOCECQQDhe0KGmbq1RWp6
TDvgpA2dUmlt2fdP8oNW8O7MvbDaQRduoZnVRTPYCDKfzFqpNXL1hAYgth1N0vzD
nv3VoLcpAkEA1JcY+rLv5js1g5Luv8LaI5/3uOg0CW7fmh/LfGuz8k/OxASN+cAO
UjPHrxtc5xn1zat4/bnV5GEdlOp/DhquPQJBAIV2Fsdi4M+AueiPjPWHRQO0jvDV
jfwFOFZSn5YSRUa6NmtmPY6tumUJXSWWqKb1GwlVTuc3xBqXYsNLLUWwLhkCQQDJ
UJCiD0LohhdGEqUuSKnj5H9kxddJO4pZXFSI7UEJbJQDwcBkyn+FTm2BH+tZGZdQ
fVnlA89OJr0poOpSg+eNAkAKY85SR9KASaTiDBoPpJ8N805XEhd0Kq+ghzSThxL3
fVtKUQLiCh7Yd8oMd/G5S3xWJHUXSioATT8uPRH2bOb/";


            var launchInfo = new LaunchInfo
            {
                ComputerName    = MachineInfo.Instance.GetComputerName(),
                CPUSerialNumber = MachineInfo.Instance.GetCPUSerialNumber(),
                MACAddress      = MachineInfo.Instance.GetMacAddress(),
                Name            = "测试",
                ProductKey      = "G5S3xWJHUXSioATT8uPRH2bOb",
                SystemType      = MachineInfo.Instance.GetSystemType(),
                ExpirationDate  = DateTime.Now.AddDays(30)
            };

            var serializedText = JsonConvert.SerializeObject(launchInfo);


            var privateCryto = new RSACryptoService(privateKey);
            var publickCryto = new RSACryptoService(null, publicKey);

            var encryptedText = publickCryto.Encrypt(serializedText);

            var decryptedText = privateCryto.Decrypt(encryptedText);

            Assert.IsTrue(serializedText == decryptedText);
        }
        /// <summary>
        /// 离线验证
        /// </summary>
        /// <returns></returns>
        private bool OfflineVerify(LaunchInfo launchInfo)
        {
            //远程验证失败,开始离线验证
            var expirationDate = EncryptionService.EncryptText(WindowsRegistry.GetRegistryValue(Constants.EXPIRATION_DATE));
            var encryptedText  = WindowsRegistry.GetRegistryValue(Constants.ENCRYPTED_TEXT);
            var prdkey         = WindowsRegistry.GetRegistryValue(Constants.PRODUCT_KEY);

            if (encryptedText == launchInfo.EncryptedText && prdkey == launchInfo.ProductKey)
            {
                return(expirationDate == encryptedText);
            }
            else
            {
                return(false);
            }
        }
Example #30
0
        public MainForm(List <LaunchInfo> launchesData, LaunchInfo nextLaunch)
        {
            InitializeComponent();
            CenterToScreen();
            AppTips();

            _nextFlightNumber = int.Parse(nextLaunch.FlightNumber.ToString());
            _launchesData     = launchesData;

            _indexOfMission = _launchesData.FindIndex(mission
                                                      => mission.FlightNumber != null && mission.FlightNumber.Value.ToString()
                                                      .Contains(_nextFlightNumber.ToString()));
            _nextFlightNumber = _indexOfMission;

            MissionData(_nextFlightNumber);
        }
		/*
		* @see Flash.Tools.Debugger.SessionManager#playerForUri(java.lang.String)
		*/
        public override Player playerForUri(String url)
		{
			// Find the Netscape plugin
			if (Environment.OSVersion.Platform == PlatformID.Unix)
			{
				FileInfo flashPlugin = new FileInfo("/Library/Internet Plug-Ins/Flash Player.plugin"); //$NON-NLS-1$
				return new NetscapePluginPlayer(m_debuggerCallbacks.getHttpExe(), flashPlugin);
			}
			else
			{
				LaunchInfo launchInfo = new LaunchInfo(this, url);
				if (launchInfo.WebBrowserNativeLaunch())
				{
					FileInfo httpExe = m_debuggerCallbacks.getHttpExe();
					if (httpExe.Name.ToUpper().Equals("iexplore.exe".ToUpper()))
					//$NON-NLS-1$
					{
						// IE on Windows: Find the ActiveX control
						String activeXFile = null;
						try
						{
							activeXFile = m_debuggerCallbacks.queryWindowsRegistry("HKEY_CLASSES_ROOT\\CLSID\\{D27CDB6E-AE6D-11cf-96B8-444553540000}\\InprocServer32", null); //$NON-NLS-1$
						}
						catch (IOException)
						{
							// ignore
						}
						if (activeXFile == null)
							return null; // we couldn't find the player
						FileInfo file = new FileInfo(activeXFile);
						return new ActiveXPlayer(httpExe, file);
					}
					else
					{
						// Find the Netscape plugin
						FileInfo browserDir = new FileInfo(httpExe.DirectoryName);
						
						// Opera puts plugins under "program\plugins" rather than under "plugins"
						if (httpExe.Name.ToUpper().Equals("opera.exe".ToUpper()))
						//$NON-NLS-1$
							browserDir = new FileInfo(browserDir.FullName + "\\" + "program"); //$NON-NLS-1$
						
						FileInfo pluginsDir = new FileInfo(browserDir.FullName + "\\" + "plugins"); //$NON-NLS-1$
						FileInfo flashPlugin = new FileInfo(pluginsDir.FullName + "\\" + "NPSWF32.dll"); // WARNING, Windows-specific //$NON-NLS-1$
						
						// Bug 199175: The player is now installed via a registry key, not
						// in the "plugins" directory.
						//
						// Although Mozilla does not document this, the actual behavior of
						// the browser seems to be that it looks first in the "plugins" directory,
						// and then, if the file is not found there, it looks in the registry.
						// So, we mimic that behavior.
						bool tmpBool;
						if (File.Exists(flashPlugin.FullName))
							tmpBool = true;
						else
							tmpBool = Directory.Exists(flashPlugin.FullName);
						if (!tmpBool)
						{
							FileInfo pathFromRegistry = WindowsMozillaPlayerPathFromRegistry;
							
							if (pathFromRegistry != null)
								flashPlugin = pathFromRegistry;
						}
						
						return new NetscapePluginPlayer(httpExe, flashPlugin);
					}
				}
				else if (launchInfo.PlayerNativeLaunch())
				{
					FileInfo playerExe = m_debuggerCallbacks.getPlayerExe();
					return new StandalonePlayer(playerExe);
				}
			}
			
			return null;
		}
		/*
		* @see Flash.Tools.Debugger.SessionManager#launch(java.lang.String, Flash.Tools.Debugger.AIRLaunchInfo, boolean, Flash.Tools.Debugger.IProgress)
		*/
        public override Session launch(String uri, AIRLaunchInfo airLaunchInfo, bool forDebugging, IProgress waitReporter)
		{
			bool modify = (getPreference(SessionManager.PREF_URI_MODIFICATION) != 0);
			LaunchInfo launchInfo = new LaunchInfo(this, uri);
			bool nativeLaunch = launchInfo.WebBrowserNativeLaunch() || launchInfo.PlayerNativeLaunch();
			
			// one of these is assigned to launchAction
			const int NO_ACTION = 0; // no special action
            const int SHOULD_LISTEN = 1; // create a ProcessListener
            const int WAIT_FOR_LAUNCH = 2; // block until process completes
			
			int launchAction; // either NO_ACTION, SHOULD_LISTEN, or WAIT_FOR_LAUNCH
			
			uri = uri.Trim();

            // bool isMacOSX = false;
            bool isWindows = false;
			// if isMacOSX and isWindows are both false, then it's *NIX
            if (Environment.OSVersion.Platform == PlatformID.MacOSX)
            {
                // isMacOSX = true;
            }
            else if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                isWindows = true;
            }
			
			if (airLaunchInfo == null)
			{
				// first let's see if it's an HTTP URL or not
				if (launchInfo.HttpOrAbout)
				{
					if (modify && forDebugging && !uri.StartsWith("about:"))
					//$NON-NLS-1$
					{
						// escape spaces if we have any
						uri = URLHelper.escapeSpace(uri);
						
						// be sure that ?debug=true is included in query string
						URLHelper urlHelper = new URLHelper(uri);
						System.Collections.IDictionary parameters = urlHelper.getParameterMap();
						parameters["debug"] = "true"; //$NON-NLS-1$ //$NON-NLS-2$
                        urlHelper.setParameterMap(parameters);
						
						uri = urlHelper.URL;
					}
				}
				else
				{
					// ok, its not an http: type request therefore we should be able to see
					// it on the file system, right?  If not then it's probably not valid
					FileInfo f = null;
					if (uri.StartsWith("file:")) //$NON-NLS-1$
					{
						f = new FileInfo(new Uri(uri).LocalPath);
					}
					else
					{
						f = new FileInfo(uri);
					}
					
					if (f != null && f.Exists)
						uri = f.FullName;
					else
						throw new FileNotFoundException(uri);
				}
				
				if (nativeLaunch)
				{
					// We used to have
					//
					//		launchAction = SHOULD_LISTEN;
					//
					// However, it turns out that when you launch Firefox, if there
					// is another instance of Firefox already running, then the
					// new instance just passes a message to the old one and then
					// immediately exits.  So, it doesn't work to abort when our
					// child process dies.
					launchAction = NO_ACTION;
				}
				else
				{
					launchAction = NO_ACTION;
				}
				
				/*
				* Various ways to launch this stupid thing.  If we have the exe
				* values for the player, then we can launch it directly, monitor
				* it and kill it when we die; otherwise we launch it through
				* a command shell (cmd.exe, open, or bash) and our Process object
				* dies right away since it spawned another process to run the
				* Player within.
				*/
#if false
				if (isMacOSX)
				{
					if (launchInfo.WebBrowserNativeLaunch)
					{
						FileInfo httpExe = m_debuggerCallbacks.getHttpExe();
						m_launchCommand = new String[]{"/usr/bin/open", "-a", httpExe.ToString(), uri}; //$NON-NLS-1$ //$NON-NLS-2$
					}
					else if (launchInfo.PlayerNativeLaunch)
					{
						FileInfo playerExe = m_debuggerCallbacks.getPlayerExe();
						m_launchCommand = new String[]{"/usr/bin/open", "-a", playerExe.ToString(), uri}; //$NON-NLS-1$ //$NON-NLS-2$
					}
					else
					{
						m_launchCommand = new String[]{"/usr/bin/open", uri}; //$NON-NLS-1$
					}
				}
				else
#endif
				{
					
					if (launchInfo.WebBrowserNativeLaunch())
					{
						FileInfo httpExe = m_debuggerCallbacks.getHttpExe();
						m_launchCommand = new String[]{httpExe.ToString(), uri};
					}
					else if (launchInfo.PlayerNativeLaunch())
					{
						FileInfo playerExe = m_debuggerCallbacks.getPlayerExe();
						m_launchCommand = new String[]{playerExe.ToString(), uri};
					}
					else
					{
						if (isWindows)
						{
							// We must quote all ampersands in the URL; if we don't, then
							// cmd.exe will interpret the ampersand as a command separator.
							uri = uri.Replace("&", "\"&\""); //$NON-NLS-1$ //$NON-NLS-2$
							
							m_launchCommand = new String[]{"cmd", "/c", "start", uri}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
						}
						else
						{
							String exeName;
							if (launchInfo.WebPage)
								exeName = m_debuggerCallbacks.HttpExeName;
							else
								exeName = m_debuggerCallbacks.PlayerExeName;
							throw new FileNotFoundException(exeName);
						}
					}
				}
			}
			// else, AIR
			else
			{
				if (forDebugging)
					launchAction = SHOULD_LISTEN;
				// wait inside accept() until ADL exits
				else
					launchAction = NO_ACTION; // just launch it
				
                LinkedList<String> cmdList = new LinkedList<String>();
				
				cmdList.AddLast(airLaunchInfo.airDebugLauncher.FullName);
				
				if (airLaunchInfo.airRuntimeDir != null && airLaunchInfo.airRuntimeDir.Length > 0)
				{
                    cmdList.AddLast("-runtime"); //$NON-NLS-1$
                    cmdList.AddLast(airLaunchInfo.airRuntimeDir.FullName);
				}
				
				if (airLaunchInfo.airSecurityPolicy != null && airLaunchInfo.airSecurityPolicy.Length > 0)
				{
                    cmdList.AddLast("-security-policy"); //$NON-NLS-1$
                    cmdList.AddLast(airLaunchInfo.airSecurityPolicy.FullName);
				}
				
				if (airLaunchInfo.airPublisherID != null && airLaunchInfo.airPublisherID.Length > 0)
				{
                    cmdList.AddLast("-pubid"); //$NON-NLS-1$
                    cmdList.AddLast(airLaunchInfo.airPublisherID);
				}
				
				// If it's a "file:" URL, then pass the actual filename; otherwise, use the URL
				// ok, its not an http: type request therefore we should be able to see
				// it on the file system, right?  If not then it's probably not valid
				FileInfo f = null;
				if (uri.StartsWith("file:"))
				//$NON-NLS-1$
				{
                    f = new FileInfo(new Uri(uri).LocalPath);
                    cmdList.AddLast(f.FullName);
				}
				else
				{
                    cmdList.AddLast(uri);
				}
				
				if (airLaunchInfo.applicationContentRootDir != null)
				{
                    cmdList.AddLast(airLaunchInfo.applicationContentRootDir.FullName);
				}
				
				if (airLaunchInfo.applicationArguments != null && airLaunchInfo.applicationArguments.Length > 0)
				{
                    cmdList.AddLast("--"); //$NON-NLS-1$

                    foreach (String arg in splitArgs(airLaunchInfo.applicationArguments))
                    {
                        cmdList.AddLast(arg);
                    }
				}

                m_launchCommand = new String[cmdList.Count];
                int index = 0;

                foreach (String arg in cmdList)
                {
                    m_launchCommand[index++] = arg;
                }
			}
			
			ProcessListener pl = null;
			PlayerSession session = null;
			try
			{
				// create the process and attach a thread to watch it during our accept phase
				System.Diagnostics.Process proc = m_debuggerCallbacks.launchDebugTarget(m_launchCommand);
				
				m_processMessages = new StringWriter();
				new StreamListener(proc.StandardOutput, m_processMessages).Start();
                new StreamListener(proc.StandardError, m_processMessages).Start();
#if false
				try
				{
					Stream stm = proc.StandardOutput.BaseStream;
					if (stm != null)
						stm.Close();
				}
				catch (IOException)
				{
					/* not serious; ignore */
				}
#endif				
				switch (launchAction)
				{
					case NO_ACTION: 
						break;

					case SHOULD_LISTEN: 
					{
						// allows us to hear when the process dies
						pl = new ProcessListener(this, proc);
						pl.Start();
						break;
					}

					case WAIT_FOR_LAUNCH: 
					{
						// block until the process completes
						bool done = false;
						while (!done)
						{
							try
							{
								proc.WaitForExit();
								Int32 generatedAux = proc.ExitCode;
								done = true;
							}
							catch (System.Threading.ThreadInterruptedException)
							{
								/* do nothing */
							}
						}
						if (proc.ExitCode != 0)
						{
							throw new IOException(m_processMessages.ToString());
						}
						break;
					}
				}
				
				if (forDebugging)
				{
					/* now wait for a connection */
					session = (PlayerSession) accept(waitReporter, airLaunchInfo != null);
					session.LaunchProcess = proc;
					session.LaunchUrl = uri;
					session.AIRLaunchInfo = airLaunchInfo;
				}
			}
			finally
			{
				if (pl != null)
					pl.Finish();
			}
			return session;
		}