Пример #1
0
        private void saveProfileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    NodeProfile newProfile = (NodeProfile)profileController.ActiveProfile.Clone(
                        Path.GetFileNameWithoutExtension(saveFileDialog.FileName),
                        Path.GetDirectoryName(saveFileDialog.FileName));

                    profileController.SaveProfile(newProfile);
                }

                catch (System.Runtime.Serialization.SerializationException ouch)
                {
                    WriteLogLine(
                        "ERROR: Failed to save profile at the specified located \"",
                        saveFileDialog.FileName,
                        "\". Make sure your file doesn't already exist, ",
                        "you have with read/write permissions, ",
                        "the file name is valid, you've TURNED OFF THE UAC, ",
                        "and the file is not corrupt before trying again.");
                }
            }

            else
            {
                WriteLogLine("Action cancelled.");
            }
        }
Пример #2
0
        public void TestNodeProfile()
        {
            var nodeProfile = new NodeProfile(new NodeId(123), "testNode");

            Assert.That(nodeProfile.Id.value, Is.EqualTo(123));
            Assert.That(nodeProfile.Name, Is.EqualTo("testNode"));
        }
Пример #3
0
        private async ValueTask AddConnectionAsync(IConnection connection, OmniAddress address, ConnectionHandshakeType handshakeType, CancellationToken cancellationToken = default)
        {
            var status = new ConnectionStatus(connection, address, handshakeType);

            var myNodeProflie = new NodeProfile(await _connectionController.GetListenEndpointsAsync(cancellationToken));

            var myHelloMessage = new NodeExplorerHelloMessage(_myId, myNodeProflie);
            NodeExplorerHelloMessage?otherHelloMessage = null;

            var enqueueTask = connection.EnqueueAsync((bufferWriter) => myNodeProflie.Export(bufferWriter, _bytesPool), cancellationToken);
            var dequeueTask = connection.DequeueAsync((sequence) => otherHelloMessage = NodeExplorerHelloMessage.Import(sequence, _bytesPool), cancellationToken);

            await ValueTaskHelper.WhenAll(enqueueTask, dequeueTask);

            if (otherHelloMessage == null)
            {
                return;
            }

            status.Id          = otherHelloMessage.Id;
            status.NodeProfile = otherHelloMessage.NodeProfile;

            lock (_lockObject)
            {
                _connections.Add(status);
            }
        }
Пример #4
0
        public void TestNodeProfileName()
        {
            var nodeProfile = new NodeProfile(new NodeId(123), "hoge");

            nodeProfile.Name = "testNode";
            Assert.That(nodeProfile.Name, Is.EqualTo("testNode"));
        }
Пример #5
0
        public void TestNodeProfileEquals()
        {
            var profile1 = new NodeProfile(new NodeId(111), "testNode1");
            var profile2 = new NodeProfile(new NodeId(222), "testNode1");
            var profile3 = new NodeProfile(new NodeId(111), "testNode2");
            var profile4 = new NodeProfile(new NodeId(111), "testNode1");

            Assert.That(profile1, Is.EqualTo(profile1));
            Assert.That(profile1, Is.Not.EqualTo(profile2));
            Assert.That(profile1, Is.Not.EqualTo(profile3));
            Assert.That(profile1, Is.EqualTo(profile4));
        }
Пример #6
0
        public void TestSetRequireNodes()
        {
            var node = new HashSetDependencyNode(new NodeProfile(new NodeId(0), "node0"));
            var p1   = new NodeProfile(new NodeId(1), "node1");
            var p2   = new NodeProfile(new NodeId(2), "node2");
            var p3   = new NodeProfile(new NodeId(3), "node3");

            node.Sources.Add(p3);
            node.SetRequireNodes(new[] { p1, p2 });
            Assert.That(node.Destinations.Count, Is.EqualTo(2));
            Assert.That(node.Destinations.Any(x => x.Equals(p1)));
            Assert.That(node.Destinations.Any(x => x.Equals(p2)));
            Assert.That(node.Sources.Count, Is.Zero);
        }
Пример #7
0
 internal PhpWorkloadResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, WorkloadKind kind, WorkloadsSku sku, PhpWorkloadResourceIdentity identity, AzureLocation?appLocation, ManagedRGConfiguration managedResourceGroupConfiguration, UserProfile adminUserProfile, VmssNodesProfile webNodesProfile, NodeProfile controllerProfile, NetworkProfile networkProfile, DatabaseProfile databaseProfile, SiteProfile siteProfile, FileshareProfile fileshareProfile, PhpProfile phpProfile, SearchProfile searchProfile, CacheProfile cacheProfile, BackupProfile backupProfile, PhpWorkloadProvisioningState?provisioningState) : base(id, name, resourceType, systemData, tags, location)
 {
     Kind        = kind;
     Sku         = sku;
     Identity    = identity;
     AppLocation = appLocation;
     ManagedResourceGroupConfiguration = managedResourceGroupConfiguration;
     AdminUserProfile  = adminUserProfile;
     WebNodesProfile   = webNodesProfile;
     ControllerProfile = controllerProfile;
     NetworkProfile    = networkProfile;
     DatabaseProfile   = databaseProfile;
     SiteProfile       = siteProfile;
     FileshareProfile  = fileshareProfile;
     PhpProfile        = phpProfile;
     SearchProfile     = searchProfile;
     CacheProfile      = cacheProfile;
     BackupProfile     = backupProfile;
     ProvisioningState = provisioningState;
 }
Пример #8
0
        private void GBGMain_Load(Object sender, EventArgs e)
        {
            ttUpdater.Interval = 500;
            ttUpdater.Tick    += new EventHandler((o, ev) =>
            {
                long mil = totalRunTime.ElapsedMilliseconds,
                seconds  = mil / 1000,
                minutes  = seconds / 60 % 60,
                hours    = minutes / 60,
                days     = hours / 24;

                lblCurrentRunTime.Text = "Approx. " + days + "d " + (hours % 24) + "h " + (minutes % 60) + "m " + (seconds % 60) + "s";
            });

            bgw.WorkerSupportsCancellation = true;
            bgw.WorkerReportsProgress      = true;
            bgw.DoWork             += new DoWorkEventHandler(RunBot_Work);
            bgw.ProgressChanged    += new ProgressChangedEventHandler(bgw_ProgressChanged);
            bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgw_RunWorkerCompleted);

            Hotkey hkRunBot = new Hotkey(Keys.F12, false, true, true, false);

            hkRunBot.Pressed += delegate
            {
                if (btnStopBot.Enabled)
                {
                    StopBot();
                }
                else if (btnRunBot.Enabled)
                {
                    RunBot();
                }
            };

            hkRunBot.Register(this);

            Text += ASMVersion;

            WriteLogLine("Version: ", ASMVersion);
            WriteLogLine("Disclaimer: if you get caught, it's not my nor anyone else's problem. "
                         + "This understanding should be tacit. Deal with it (or don't use the "
                         + "program). By using this program you are agreeing to hold no one "
                         + "other than your cheating self responsible if anything goes wrong. "
                         + "Don't even attempt to contact me.");
            WriteLogLine("Oh, and you should probably consider disabling the UAC when running ",
                         "this bot, especially if you're encountering problems.");
            WriteLogLine("Finishing initialization...");
            ResetRunStatistics();

            long frequency      = Stopwatch.Frequency;
            long nanosecPerTick = (1000L * 1000L * 1000L) / frequency;

            WriteLogLine("**Timer frequency in ticks per second = ", frequency);
            WriteLogLine("*-*Duration stopwatch estimated to be accurate to within ",
                         nanosecPerTick, " nanoseconds on this system");

            // Load/Save dialogs
            saveFileDialog       = new SaveFileDialog();
            saveFileDialog.Title = "Choose Profile Location...";

            openFileDialog       = new OpenFileDialog();
            openFileDialog.Title = "Select Profile...";

            saveFileDialog.InitialDirectory = openFileDialog.InitialDirectory = profileController.DefaultSaveDirectory;
            saveFileDialog.DefaultExt       = openFileDialog.DefaultExt = Properties.Settings.Default.ProfileFileExtension;
            saveFileDialog.Filter           = openFileDialog.Filter = "profiles (*."
                                                                      + Properties.Settings.Default.ProfileFileExtension
                                                                      + ")|*."
                                                                      + Properties.Settings.Default.ProfileFileExtension
                                                                      + "|All files (*.*)|*.*";

            // Set up MouseTracker
            Timer mouseTrackerTimer = new Timer();

            mouseTrackerTimer.Interval = 200;
            mouseTrackerTimer.Tick    += new EventHandler(mouseTrackerTimer_Tick);

            // Set up events
            profileController.Profiles.ListChanged += new ListChangedEventHandler((o, ev) =>
            {
                if (profileController.Profiles.Count > 0)
                {
                    cbProfileSelector.Enabled = true;
                }
                else
                {
                    cbProfileSelector.Enabled = false;
                }
            });

            lbNodesListChangedEventHandler = new ListChangedEventHandler(nodeList_ListChanged);

            // ListControls
            cbProfileSelector.DataSource    = profileController.Profiles;
            lbNodes.DisplayMember           = "Display";
            cbProfileSelector.DisplayMember = "Display";

            // Load/Create the default profile
            profileController.ProfileControllerAction +=
                new ProfileController.ProfileControllerActionHandler(profileController_ProfileControllerAction);

            String errpath = "(unknown location)";

            mouseTrackerTimer.Enabled = true;

            try
            {
                EnableInitialControls();

                if (File.Exists(profileController.PathOfDefaultProfile))
                {
                    profileController.LoadProfile(errpath = profileController.PathOfDefaultProfile);
                }

                else
                {
                    NodeProfile profile =
                        new NodeProfile("default", profileController.DefaultSaveDirectory, new BindingList <GenericNode>());

                    errpath = profile.FilePath;
                    profileController.SaveProfile(profile);
                    profileController.LoadProfile(profile.FilePath);
                }

                SetCurrentAction("Idle (fully initialized)");
                elbNodes = new ExtendedListControl <GenericNode>(lbNodes);
                profileController.Profiles.ResetBindings();
            }

            catch (System.Runtime.Serialization.SerializationException ouch)
            {
                WriteLogLine(
                    "ERROR: Failed to mutate your default profile.",
                    "If you continue to see this error, please  ",
                    "delete the following file: \"", errpath, "\".");
                WriteLogLine("WARNING: Due to Profile functionality being unavailable for the duration ",
                             "of this session, program functionality has become limited.");

                menuStripMain.Enabled = false;
                SetCurrentAction("Idle (bad startup; check logs)");
            }
        }
Пример #9
0
        internal static PhpWorkloadResourceData DeserializePhpWorkloadResourceData(JsonElement element)
        {
            WorkloadKind            kind = default;
            Optional <WorkloadsSku> sku  = default;
            Optional <PhpWorkloadResourceIdentity> identity     = default;
            IDictionary <string, string>           tags         = default;
            AzureLocation                           location    = default;
            ResourceIdentifier                      id          = default;
            string                                  name        = default;
            ResourceType                            type        = default;
            SystemData                              systemData  = default;
            Optional <AzureLocation>                appLocation = default;
            Optional <ManagedRGConfiguration>       managedResourceGroupConfiguration = default;
            Optional <UserProfile>                  adminUserProfile  = default;
            Optional <VmssNodesProfile>             webNodesProfile   = default;
            Optional <NodeProfile>                  controllerProfile = default;
            Optional <NetworkProfile>               networkProfile    = default;
            Optional <DatabaseProfile>              databaseProfile   = default;
            Optional <SiteProfile>                  siteProfile       = default;
            Optional <FileshareProfile>             fileshareProfile  = default;
            Optional <PhpProfile>                   phpProfile        = default;
            Optional <SearchProfile>                searchProfile     = default;
            Optional <CacheProfile>                 cacheProfile      = default;
            Optional <BackupProfile>                backupProfile     = default;
            Optional <PhpWorkloadProvisioningState> provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = new WorkloadKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = WorkloadsSku.DeserializeWorkloadsSku(property.Value);
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = PhpWorkloadResourceIdentity.DeserializePhpWorkloadResourceIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("appLocation"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            appLocation = new AzureLocation(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("managedResourceGroupConfiguration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            managedResourceGroupConfiguration = ManagedRGConfiguration.DeserializeManagedRGConfiguration(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("adminUserProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            adminUserProfile = UserProfile.DeserializeUserProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("webNodesProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            webNodesProfile = VmssNodesProfile.DeserializeVmssNodesProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("controllerProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            controllerProfile = NodeProfile.DeserializeNodeProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("networkProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("databaseProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            databaseProfile = DatabaseProfile.DeserializeDatabaseProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("siteProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            siteProfile = SiteProfile.DeserializeSiteProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("fileshareProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            fileshareProfile = FileshareProfile.DeserializeFileshareProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("phpProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            phpProfile = PhpProfile.DeserializePhpProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("searchProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            searchProfile = SearchProfile.DeserializeSearchProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("cacheProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            cacheProfile = CacheProfile.DeserializeCacheProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("backupProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            backupProfile = BackupProfile.DeserializeBackupProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new PhpWorkloadProvisioningState(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new PhpWorkloadResourceData(id, name, type, systemData, tags, location, kind, sku.Value, identity.Value, Optional.ToNullable(appLocation), managedResourceGroupConfiguration.Value, adminUserProfile.Value, webNodesProfile.Value, controllerProfile.Value, networkProfile.Value, databaseProfile.Value, siteProfile.Value, fileshareProfile.Value, phpProfile.Value, searchProfile.Value, cacheProfile.Value, backupProfile.Value, Optional.ToNullable(provisioningState)));
        }
 public static bool IsConnectedTo(this IDependencyNode node, NodeProfile nodeProfile)
 {
     return(node.Sources.Contains(nodeProfile) || node.Destinations.Contains(nodeProfile));
 }