public bool AddGremlinToDataBase(Gremlin gremlin)
 {
     _Count++;
     gremlin.ID = _Count;
     _gremlinDatabase.Add(_Count, gremlin);
     return(true);
 }
        private void AddGremlin()
        {
            Console.Clear();

            Gremlin gremlin = new Gremlin();

            Console.WriteLine("Please enter a name");
            string userInputName = Console.ReadLine();

            gremlin.Name = userInputName;

            Console.WriteLine("Is gremlin naughty?(y/n)");
            string userInputIsNaughty = Console.ReadLine().ToLower();

            if (userInputIsNaughty == "y")
            {
                gremlin.IsNaughty = true;
            }
            else
            {
                gremlin.IsNaughty = false;
            }

            bool isSuccessful = _gRepo.AddGremlinToDataBase(gremlin);

            if (isSuccessful)
            {
                Console.WriteLine("Created");
            }
            else
            {
                Console.WriteLine("Failed");
            }
            Console.ReadKey();
        }
示例#3
0
        /// <summary>
        /// Creates a Vertex with given label and properties
        /// </summary>
        /// <param name="label">Label of created vertex</param>
        /// <param name="properties">Properties of created vertex</param>
        /// <returns>Created IVertex</returns>
        public IVertex AddVertex(string label, IVertexProperties properties = null)
        {
            IVertex           tmpVertex        = new OrientVertex();
            IVertexProperties orientProperties = properties;

            tmpVertex.Label = label;
            tmpVertex.ID    = localId.ToString();
            localId++;
            tmpVertex.Properties = orientProperties;

            try
            {
                IVertex createdVert = Gremlin.CreateVertexAndLabel(label, (Dictionary <string, List <IVertexValue> >)properties);
                logger.Info("Vertex " + createdVert.ID + "has been created.");
                tmpVertex = createdVert;
            }
            catch (WebSocketException we)
            {
                logger.Error("Can not connect to Server. " + we);
                throw;
            }
            catch (JsonReaderException jre)
            {
                logger.Error("Can not read JSON. " + jre.Data + jre.StackTrace);
                throw;
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
            return(tmpVertex);
        }
示例#4
0
        /// <summary>
        /// working constructor
        /// </summary>
        /// <param name="directory"></param>
        public RedirectJobIOProcessor(string directory)
        {
            Directory = directory;

            if (System.IO.Directory.GetFiles(Directory, "*.xlsx").Length != 0)
            {
                Console.WriteLine("WARNING: Folder contains one or more xlsx files. Please change any xlsx file types to csv.");
                Gremlin.SendEmail("*****@*****.**", "xlsx files detected", "WARNING: Folder contains one or more xlsx files. Please change any xlsx file types to csv.");
            }

            InputOldUrlFile      = System.IO.Directory.GetFiles(Directory, "OldSiteUrls.csv")[0];
            InputNewUrlFile      = System.IO.Directory.GetFiles(Directory, "NewSiteUrls.csv")[0];
            InputExisting301File = System.IO.Directory.GetFiles(Directory, "Existing301s.csv")[0];
            if (File.Exists(Path.Combine(Directory, @"SubProjects.csv")))
            {
                InputSubProjectFile = System.IO.Directory.GetFiles(Directory, "SubProjects.csv")[0];
            }
            LogFile               = Directory + @"\Log.txt";
            OutputFolder          = Path.Combine(Directory, @"Output");
            OutputFoundUrlFile    = Path.Combine(OutputFolder, @"FoundRedirects.csv");
            OutputLostUrlFile     = Path.Combine(OutputFolder, @"LostRedirects.csv");
            Output301CatchAllFile = Path.Combine(OutputFolder, @"Possible301Catchalls.csv");

            checkForLog();
        }
 // Use this for initialization
 void Start()
 {
     player = this;
     rb2d   = GetComponent <Rigidbody2D>();
     anim   = GetComponent <Animator>();
     coll2d = GetComponent <PolygonCollider2D>();
 }
示例#6
0
 public void OnActionsCompleted(Gremlin monster)
 {
     if (Monsters.Find(x => x == monster))
     {
         Destroy(monster.gameObject);
         Monsters.Remove(monster);
     }
 }
示例#7
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("          \\,,,/");
            Console.WriteLine("          (o o)");
            Console.WriteLine(" -----oOOo-(3)-oOOo-----");
            Console.WriteLine("");
            Console.WriteLine(" hacked by moonchoi");
            Console.WriteLine("");

            string endpointUri = "https://[cosmosdbID].documents.azure.com:443/";
            string authKey     = "[key]";
            string databaseId  = "graphdb";
            string graphId     = "Persons";

            Gremlin gremlin = new Gremlin(endpointUri, authKey, databaseId);

            try
            {
                Console.WriteLine("connection test...");
                Task <List <dynamic> > task = Task.Run(async() => await gremlin.GremlinQuery <dynamic>(graphId, "g.V()"));
                var test = task.Result;
                Console.WriteLine("connected!");
            }
            catch
            {
                Console.WriteLine("check your endpointURI, authKey, databaseId");
                return;
            }

            Console.Write("gremlin>");

            string strLine = string.Empty;

            while (true)
            {
                string line = Console.ReadLine();

                try
                {
                    Task <List <dynamic> > task = Task.Run(async() => await gremlin.GremlinQuery <dynamic>(graphId, line));
                    var    result  = task.Result;
                    string strJson = JsonConvert.SerializeObject(result);

                    Console.WriteLine(strJson);
                    Console.WriteLine();
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                Console.Write("gremlin>");
                line = "";
            }
        }
示例#8
0
        public void RunGherkinBasedTests(IMessageSerializer messageSerializer)
        {
            WriteOutput($"Starting Gherkin-based tests with serializer: {messageSerializer.GetType().Name}");
            Gremlin.InstantiateTranslationsForTestRun();
            var stepDefinitionTypes = GetStepDefinitionTypes();
            var results             = new List <ResultFeature>();

            using var scenarioData   = new ScenarioData(messageSerializer);
            CommonSteps.ScenarioData = scenarioData;
            foreach (var feature in GetFeatures())
            {
                var resultFeature = new ResultFeature(feature);
                results.Add(resultFeature);
                foreach (var child in feature.Children)
                {
                    var scenario    = (Scenario)child;
                    var failedSteps = new Dictionary <Step, Exception>();
                    resultFeature.Scenarios[scenario] = failedSteps;
                    if (IgnoredScenarios.TryGetValue(scenario.Name, out var reason))
                    {
                        failedSteps.Add(scenario.Steps.First(), new IgnoreException(reason));
                        continue;
                    }

                    StepBlock?     currentStep    = null;
                    StepDefinition stepDefinition = null;
                    foreach (var step in scenario.Steps)
                    {
                        var previousStep = currentStep;
                        currentStep = GetStepBlock(currentStep, step.Keyword);
                        if (currentStep == StepBlock.Given && previousStep != StepBlock.Given)
                        {
                            stepDefinition = GetStepDefinitionInstance(stepDefinitionTypes, step.Text);
                        }

                        if (stepDefinition == null)
                        {
                            throw new NotSupportedException(
                                      $"Step '{step.Text} not supported without a 'Given' step first");
                        }

                        scenarioData.CurrentScenario = scenario;
                        var result = ExecuteStep(stepDefinition, currentStep.Value, step);
                        if (result != null)
                        {
                            failedSteps.Add(step, result);
                            // Stop processing scenario
                            break;
                        }
                    }
                }
            }

            OutputResults(results);
            WriteOutput($"Finished Gherkin-based tests with serializer: {messageSerializer.GetType().Name}.");
        }
示例#9
0
 internal void Run()
 {
     jobList = setUpJobs();
     if (jobList.Count > 0)
     {
         Gremlin.Info($"Number of new jobs: {jobList.Count}");
     }
     //Console.WriteLine($"number of jobs: {jobList.Count}");
     startJobs(jobList);
 }
示例#10
0
        public void TranslateTraversal(string traversalText)
        {
            if (_g == null)
            {
                throw new InvalidOperationException("g should be a traversal source");
            }

            _traversal =
                Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters);
        }
示例#11
0
        /// <summary>
        /// Sets a composite index (see http://s3.thinkaurelius.com/docs/titan/1.0.0/indexes.html#_composite_index )
        /// </summary>
        /// <param name="propertykey">Propertykey to index</param>
        public virtual void CreateIndexOnProperty(string propertykey)
        {
            object indexPropertyKey = Gremlin.GetScalar(new GremlinScript("mgmt = graph.openManagement(); mgmt.getPropertyKey('" + propertykey + "')"));

            if (indexPropertyKey == null)
            {
                Gremlin.Execute(
                    new GremlinScript("graph.tx().rollback(); mgmt = graph.openManagement(); name = mgmt.makePropertyKey('" + propertykey + "').dataType(String.class).make(); mgmt.buildIndex('" + propertykey + "', Vertex.class).addKey(name).buildCompositeIndex(); mgmt.commit();")
                    );
            }
        }
示例#12
0
        public void InitTraversal(string traversalText)
        {
            var traversal =
                Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters);

            traversal.Iterate();

            // We may have modified the so-called `empty` graph
            if (_graphName == "empty")
            {
                ScenarioData.ReloadEmptyData();
            }
        }
示例#13
0
        private void startJobs(List <RedirectJob> jobList)
        {
            string emailAddresses = "";

            foreach (var job in jobList)
            {
                job.Start();
                emailAddresses += job.EmailAddresses + ";";
            }
            if (jobList.Count > 0)
            {
                Gremlin.SendEmail("*****@*****.**", $"There are {jobList.Count} new jobs.", $"Emails are being sent to {emailAddresses}");
            }
        }
示例#14
0
        public void TranslateTraversal(string traversalText)
        {
            if (_g == null)
            {
                throw new InvalidOperationException("g should be a traversal source");
            }

            if (ScenarioData.CurrentFeature.Tags.Select(t => t.Name).ToList().Contains("@GraphComputerOnly"))
            {
                _g = _g.WithComputer();
            }

            _traversal =
                Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters);
        }
        public bool UpdateGremlin(int oldGrim, Gremlin newGremlinData)
        {
            //used method above to pull this off
            Gremlin oldGremlin = GetGremlinByKey(oldGrim);

            if (oldGremlin == null)
            {
                return(false);
            }
            else
            {
                oldGremlin.Name      = newGremlinData.Name;
                oldGremlin.IsNaughty = newGremlinData.IsNaughty;
                return(true);
            }
        }
示例#16
0
        /// <summary>
        /// Let the games begin
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Gremlin.Init(Environment.MachineName);
            Gremlin.EmailTo = "*****@*****.**";


            string            root = @"S:\S-Z\Timothy Darrow\Redirect Machine";
            RedirectJobFinder jobs = new RedirectJobFinder(root);

            int jobCount = jobs.returnJobCount();

            //Gremlin.Info("Starting Redirect Machine. Number of jobs: " + jobCount, sendEmail: true);
            jobs.Run();


            Console.WriteLine("closing gremlin");
            Gremlin.Close();
        }
示例#17
0
        static void Main(string[] args)
        {
            Gremlin.Init(Environment.MachineName);
            Gremlin.EmailTo = "*****@*****.**";

            Console.WriteLine("Starting redirect machine...");

            string            root = @"S:\M-R\Marcus LeGault\Redirect Machine";
            RedirectJobFinder jobs = new RedirectJobFinder(root);

            int jobCount = jobs.returnJobCount();

            jobs.Run();

            Console.WriteLine("Done!");

            Gremlin.Close();
        }
示例#18
0
        public void AssertTraversalCount(int expectedCount, string traversalText)
        {
            if (traversalText.StartsWith("\""))
            {
                traversalText = traversalText.Substring(1, traversalText.Length - 2);
            }

            var traversal =
                Gremlin.UseTraversal(ScenarioData.CurrentScenario.Name, _g, _parameters);

            var count = 0;

            while (traversal.MoveNext())
            {
                count++;
            }
            Assert.Equal(expectedCount, count);
        }
示例#19
0
        public void Start()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            EmailAddresses = jobIOProcessor.getEmailAddresses();
            jobIOProcessor.addToLogDump($"job started at {DateTime.Now.ToString("MM/dd/yyyy HH:mm")}");
            jobIOProcessor.CreateOutputDirectory();
            Console.WriteLine("starting");
            importExisting301s();
            importUrlHeaderMaps();

            startRedirectFinder();

            jobIOProcessor.writeToLogDump();
            Console.WriteLine($"Sending email to {EmailAddresses}");
            Gremlin.SendEmail(EmailAddresses, $"Your redirect job for {Path.GetFileName(jobIOProcessor.Directory)} is done.", $"Your redirect job for {jobIOProcessor.Directory} is done. Please retrieve it within 24 hours");
        }
        private void UpdateGremlinByKey()
        {
            Console.Clear();

            //getting gremlin key....
            Console.WriteLine("Input Gremlin by key");
            int userInputGremlinKey = int.Parse(Console.ReadLine());

            //create new Gremlin data....
            Gremlin newGremlinData = new Gremlin();

            Console.WriteLine("Please enter a name");
            string userInputName = Console.ReadLine();

            newGremlinData.Name = userInputName;

            Console.WriteLine("Is gremlin naughty?(y/n)");
            string userInputIsNaughty = Console.ReadLine().ToLower();

            if (userInputIsNaughty == "y")
            {
                newGremlinData.IsNaughty = true;
            }
            else
            {
                newGremlinData.IsNaughty = false;
            }

            var isSuccessful = _gRepo.UpdateGremlin(userInputGremlinKey, newGremlinData);

            if (isSuccessful)
            {
                Console.WriteLine("Success");
            }
            else
            {
                Console.WriteLine("FAILED");
            }

            Console.ReadKey();
        }
        private void ViewGremlinByKey()
        {
            Console.Clear();
            Console.WriteLine("Input Gremlin by key");
            int userInputGremlinKey = int.Parse(Console.ReadLine());

            Gremlin gremlin = _gRepo.GetGremlinByKey(userInputGremlinKey);

            if (gremlin == null)
            {
                Console.WriteLine("Does not exist");
            }
            else
            {
                Console.WriteLine($"{gremlin.ID}\n" +
                                  $"{gremlin.Name}\n" +
                                  $"{gremlin.IsNaughty}\n");
            }

            Console.ReadKey();
        }
示例#22
0
        /// <summary>
        /// Creates a directed Edge and saves to DB
        /// </summary>
        /// <param name="label">Label of created edge</param>
        /// <param name="InVertex">Ingoing vertex to connect</param>
        /// <param name="OutVertex">Outgoing vertex to connect</param>
        /// <param name="Properties">Properties of created edge</param>
        /// <returns>Created IEdge</returns>
        public IEdge AddDirectedEdge(string label, IVertex OutVertex, IVertex InVertex, IEdgeProperties Properties = null)
        {
            IEdge           tmpEdge          = new OrientEdge();
            IVertex         orientOutVertex  = OutVertex;
            IVertex         orientInVertex   = InVertex;
            IEdgeProperties orientProperties = Properties;

            tmpEdge.Label = label;
            tmpEdge.ID    = localId.ToString();
            localId++;
            tmpEdge.InVertexLabel  = InVertex.Label;
            tmpEdge.OutVertexLabel = OutVertex.Label;
            tmpEdge.Properties     = orientProperties;
            tmpEdge.InVertex       = orientInVertex.ID;
            tmpEdge.OutVertex      = orientOutVertex.ID;

            try
            {
                IEdge createdEdge = Gremlin.CreateEdge(tmpEdge.OutVertex.ToString(), tmpEdge.InVertex.ToString(), label);
                logger.Info("Edge " + createdEdge.ID + "has been created.");
                tmpEdge = createdEdge;
            }
            catch (WebSocketException we)
            {
                logger.Error("Can not connect to Server. " + we);
                throw;
            }
            catch (JsonReaderException jre)
            {
                logger.Error("Can not read JSON. " + jre.Data + jre.StackTrace);
                throw;
            }
            catch (Exception e)
            {
                logger.Error("Unhandled Exception occured: " + e);
                throw;
            }
            return(tmpEdge);
        }
        /// <summary>
        /// start redirect job methods
        /// </summary>
        public void Start()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            EmailAddresses = jobIOProcessor.getEmailAddresses();
            jobIOProcessor.addToLogDump($"job started at {DateTime.Now.ToString("MM/dd/yyyy HH:mm")}");
            jobIOProcessor.CreateOutputDirectory();
            Console.WriteLine("starting");
            importListsFromFiles();
            startRedirectFinder();
            exportListsToFiles();
            Console.WriteLine($"Sending email to {EmailAddresses}");
            stopwatch.Stop();
            TimeSpan ts          = stopwatch.Elapsed;
            string   elapsedTime = "Elapsed time: " + String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

            jobIOProcessor.addToLogDump(elapsedTime);
            jobIOProcessor.writeToLogDump();

            Gremlin.SendEmail(EmailAddresses, $"Your redirect job for {Path.GetFileName(jobIOProcessor.Directory)} is done.", $"Your redirect job for {jobIOProcessor.Directory} is done. Please retrieve it within 24 hours");
        }
示例#24
0
    public void OnMonsterAttack(Gremlin monster)
    {
        if (!Running)
        {
            return;
        }

        PlayerHealth -= monster.Damage;
        HUDManager._HealthBar.UpdateHealth(PlayerHealth / 100f);

        if (PlayerHealth <= 0)
        {
            Running = false;
            HUDManager.ShowGameOverScreen();

            foreach (Gremlin g in Monsters)
            {
                if (g != monster)
                {
                    g.Stop();
                }
            }
        }
    }
示例#25
0
 public void OnMonsterKilled(Gremlin monster)
 {
     PlayerScore += 50;
     HUDManager.UpdateScore(PlayerScore);
 }
示例#26
0
 /// <summary>
 /// Deletes all vertices and edges of current graph
 /// </summary>
 public void DeleteExistingGraph()
 {
     Gremlin.Execute(new GremlinScript("graph.executeSql(\"delete vertex V\")"));
 }
示例#27
0
 /// <summary>
 /// OrientDB implementation for creating an Index on a Propertykey
 /// </summary>
 /// <param name="propertykey">Key to index</param>
 /// <param name="label">Label of Vertex</param>
 public void CreateIndexOnProperty(string propertykey, string label)
 {
     Gremlin.Execute(new GremlinScript("def config = new BaseConfiguration(); graph.prepareIndexConfiguration(config); graph.createVertexIndex(\"" + propertykey + "\", \"" + label + "\", config)"));
 }
示例#28
0
 /// <summary>
 /// Commits all changes
 /// </summary>
 public void CommitChanges()
 {
     Gremlin.Execute(new GremlinScript("graph.tx().commit()"));
 }
示例#29
0
 void Awake()
 {
     Instance = this;
 }
示例#30
0
        private void MoveTo(Location newLocation)
        {
            //See if a pass is needed for location
            if (!player.HasRequiredItemToEnterThisLocation(newLocation))
            {
                rtbMessages.Text += "You need a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine;
                return;
            }

            player.CurrentLocation = newLocation;

            //Show available movements
            btnNorth.Visible = (newLocation.LocationToNorth != null);
            btnEast.Visible  = (newLocation.LocationToEast != null);
            btnSouth.Visible = (newLocation.LocationToSouth != null);
            btnWest.Visible  = (newLocation.LocationToWest != null);

            //Display location name and description
            rtbLocation.Text  = newLocation.Name + Environment.NewLine;
            rtbLocation.Text += newLocation.Description + Environment.NewLine;

            //Heal the player
            player.CurrentPoints = player.MaximumPoints;
            lblPoints.Text       = player.CurrentPoints.ToString();

            //See if quest exists at this location
            if (newLocation.QuestAvailableHere != null)
            {
                handleQuest(newLocation);
            }

            // Does the location have a monster?
            if (newLocation.GremlinLivingHere != null)
            {
                rtbMessages.Text += "You see a " + newLocation.GremlinLivingHere.Name + Environment.NewLine;

                // Make a new monster, using the values from the standard monster in the Swamp.Ogre list
                Gremlin standardMonster = Swamp.GremlinByID(newLocation.GremlinLivingHere.ID);

                currentMonster = new Gremlin(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage,
                                             standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentPoints, standardMonster.MaximumPoints);

                foreach (Treasure lootItem in standardMonster.TreasureChest)
                {
                    currentMonster.TreasureChest.Add(lootItem);
                }

                comboBoxWeapons.Visible = true;
                comboBoxPotions.Visible = true;
                btnUseWeapon.Visible    = true;
                btnUsePotion.Visible    = true;
            }
            else
            {
                currentMonster = null;

                comboBoxWeapons.Visible = false;
                comboBoxPotions.Visible = false;
                btnUseWeapon.Visible    = false;
                btnUsePotion.Visible    = false;
            }

            // Refresh player's inventory list
            UpdateInventoryListInUI();

            // Refresh player's quest list
            UpdateQuestListInUI();

            // Refresh player's weapons combobox
            UpdateWeaponListInUI();

            // Refresh player's potions combobox
            UpdatePotionListInUI();
        }