public AdoSqlModel(IContext output, IConnectionFactory cf)
        {
            var starFields = output.Process.GetStarFields().ToArray();
            var ordered    = new List <Field>();

            foreach (Field field in starFields[0].Where(f => f.System))
            {
                ordered.Add(field);
            }
            foreach (Field field in starFields[0].Where(f => !f.System).Union(starFields[1]).OrderBy(f => f.Alias))
            {
                ordered.Add(field);
            }

            Fields               = ordered.ToArray();
            Aliases              = Fields.Select(f => cf.Enclose(f.Alias)).ToArray();
            FieldNames           = Fields.Select(f => f.FieldName()).ToArray();
            Flat                 = cf.Enclose(output.Process.Name + output.Process.FlatSuffix);
            Star                 = cf.Enclose(output.Process.Name + output.Process.StarSuffix);
            Threshold            = output.Process.Entities.Select(e => e.BatchId).ToArray().Min() - 1;
            MasterEntity         = output.Process.Entities.First();
            Master               = cf.Enclose(MasterEntity.OutputTableName(output.Process.Name));
            KeyLongName          = Constants.TflKey;
            KeyShortName         = MasterEntity.Fields.First(f => f.Name == Constants.TflKey).FieldName();
            EnclosedKeyShortName = cf.Enclose(KeyShortName);
            EnclosedKeyLongName  = cf.Enclose(Constants.TflKey);
            Batch                = cf.Enclose(MasterEntity.Fields.First(f => f.Name == Constants.TflBatchId).FieldName());
            AdoProvider          = cf.AdoProvider;
        }
Exemplo n.º 2
0
        public MasterEntity GetData()
        {
            MasterEntity dataStorage = new MasterEntity();

            // Environment:
            EnvironmentData environment = envHandler.GetEnvironmentData();

            // Check for IIS:
            Version iisVersion = iisHandler.GetIisVersion();

            environment.hasIis = iisVersion != null;

            // Save Environment to MasterEntity
            dataStorage.environment = environment;
            dataStorage.Id          = environment.machineName;

            // IIS:
            if (environment.hasIis)
            {
                IISData            iis          = iisHandler.CreateIisDataObject(iisVersion);
                IISStringContainer iisContainer = iisHandler.StoreIIS(iis);

                // Save IIS to MasterEntity
                dataStorage.iis = iisContainer;
            }

            // Services:
            dataStorage.services = serHandler.ListServices();

            return(dataStorage);
        }
Exemplo n.º 3
0
 private void Awake()
 {
     Instance = this;
     SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
     MasterEntity.Create();
     Entity.Create <TimerComponent>();
     MasterEntity.Instance.AddComponent <ConfigManageComponent>(ConfigsCollector);
     if (ExampleType == ExampleType.Rpg)
     {
         Entity.Create <CombatContext>();
     }
     if (ExampleType == ExampleType.TurnBase)
     {
         Entity.Create <CombatContext>();
         var heroRoot = GameObject.Find("CombatRoot/HeroRoot").transform;
         for (int i = 0; i < heroRoot.childCount; i++)
         {
             var hero     = heroRoot.GetChild(i);
             var turnHero = hero.gameObject.AddComponent <TurnHero>();
             turnHero.Setup(i);
             turnHero.CombatEntity.JumpToTime = JumpToTime;
         }
         var monsterRoot = GameObject.Find("CombatRoot/MonsterRoot").transform;
         for (int i = 0; i < monsterRoot.childCount; i++)
         {
             var hero        = monsterRoot.GetChild(i);
             var turnMonster = hero.gameObject.AddComponent <TurnMonster>();
             turnMonster.Setup(i);
             turnMonster.CombatEntity.JumpToTime = JumpToTime;
         }
     }
 }
Exemplo n.º 4
0
 private void Awake()
 {
     Instance = this;
     SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
     MasterEntity.Create();
     Entity.Create <TimerComponent>();
     Entity.Create <CombatContext>();
     MasterEntity.Instance.AddComponent <ConfigManageComponent>(ConfigsCollector);
 }
Exemplo n.º 5
0
    private void Awake()
    {
        Instance = this;

        MasterEntity.Create();
        Entity.Create <TimerComponent>();
        Entity.Create <CombatContext>();
        MasterEntity.Instance.AddComponent <ConfigManageComponent>(ConfigsCollector);
    }
Exemplo n.º 6
0
 //Reset the game
 private void ResetApp()
 {
     gbColor.Enabled           = cmbPosition.Enabled = true;
     btnMain.Text              = "Add";
     gbCurrentLine.Text        = "Select Color To Guess";
     txtHistory.Text           = txtField.Text = txtCombination.Text = string.Empty;
     cmbPosition.SelectedIndex = 0;
     masterCombination         = new MasterEntity();
     currentLine     = new MasterEntity();
     resultLines     = new List <ValidationEntity>();
     showCombination = false;
 }
        public void GetData_ReturnsEnvironmentData()
        {
            //Assemble
            var sut = Setup();

            //Act
            MasterEntity result = sut.GetData();

            Console.Write(result.GetType());

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.environment is EnvironmentData);
        }
Exemplo n.º 8
0
        public void ExtractAndSerializeData()
        {
            // Initialize MasterEntity to hold data
            MasterEntity dataStorage = dataExtractor.GetData();

            // Serialize to JSON
            JSONParser parser = new JSONParser();
            string     json   = parser.SerializeObject(dataStorage);

            //System.IO.File.WriteAllText(@"C:\Users\extadmnizi\Desktop\json.txt", json);

            //Post Data
            httpHandler.PostMasterEntity(uri, json);
        }
Exemplo n.º 9
0
 //Validate if the 4 colors have been added
 private bool LineValidationIsComplete(MasterEntity line)
 {
     if (line.FirstPosition.Equals(CodePeg.None) ||
         line.SecondPosition.Equals(CodePeg.None) ||
         line.ThirdPosition.Equals(CodePeg.None) ||
         line.FourthPosition.Equals(CodePeg.None)
         )
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        public void GetData_ListsServices()
        {
            //Assemble
            var sut      = Setup();
            var servList = new List <ServiceData>();

            servHandlerMoq.Setup(m => m.ListServices()).Returns(servList);

            //Act
            MasterEntity result = sut.GetData();

            //Assert
            Assert.IsNotNull(result.services);
            Assert.IsTrue(result.services is List <ServiceData>);
        }
        public void GetData_HasIIS_StoresIISdata()
        {
            //Assemble
            var sut = Setup();

            iisHandlerMoq.Setup(m => m.GetIisVersion()).Returns(new Version());
            iisHandlerMoq.Setup(m => m.StoreIIS(It.IsAny <IISData>())).Returns(new IISStringContainer());

            //Act
            MasterEntity result = sut.GetData();

            //Assert
            Assert.IsNotNull(result.iis);
            Assert.IsTrue(result.iis is IISStringContainer);
        }
Exemplo n.º 12
0
        private PostController Setup()
        {
            entity = new MasterEntity(new EnvironmentData {
                logTime = DateTime.Now
            }, null, null);

            httpHandlerMoq = new Mock <IHTTPHandler>();
            dataExtractMoq = new Mock <IDataExtract>();
            dataExtractMoq.Setup(m => m.GetData()).Returns(entity);
            //httpHandlerMoq.Setup(m => m.PostMasterEntity)).


            var sut = new PostController("", httpHandlerMoq.Object, dataExtractMoq.Object);

            return(sut);
        }
Exemplo n.º 13
0
        //Validate to send multiple options
        private void btnMain_Click(object sender, System.EventArgs e)
        {
            //When the game is over, restart the game
            if (!cmbPosition.Enabled)
            {
                ResetApp();
            }
            //Check if the initial combination is complete, to proceed to guess
            else if (LineValidationIsComplete(masterCombination) && !masterCombination.IsComplete)
            {
                masterCombination.IsComplete = true;
                gbHistory.Enabled            = true;
                gbCurrentLine.Text           = "Find the Combination";
                btnMain.Text = "Validate";
                cmbPosition.SelectedIndex = 0;
                cmbPosition_SelectedIndexChanged(null, null);
            }
            //Validates if the current combination of the player to guess is complete
            else if (LineValidationIsComplete(currentLine) && !currentLine.IsComplete)
            {
                var masterMind = new MasterMind(masterCombination);
                var result     = masterMind.GetHints(currentLine);

                if (result != null)
                {
                    if (result.Count > 0)
                    {
                        ValidationEntity entity = new ValidationEntity(currentLine, result);
                        entity.IsEqual = (result.Contains(ResultPeg.None) || result.Contains(ResultPeg.White)) ? false : true;
                        resultLines.Add(entity);
                        ShowHistory();
                        currentLine = new MasterEntity();
                        cmbPosition.SelectedIndex = 0;
                        cmbPosition_SelectedIndexChanged(null, null);

                        if (resultLines[resultLines.Count - 1].IsEqual)
                        {
                            showCombination = true;
                            btnShow_Click(null, null);
                            gbColor.Enabled = cmbPosition.Enabled = false;
                            btnMain.Text    = "Reset";
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public List <ResultPeg> GetHints(MasterEntity lineGuess)
        {
            List <CodePeg> guess = ConvertMasterEntityToCodePegList(lineGuess);

            try
            {
                var result = new List <ResultPeg>();

                for (int i = 0; i < 4; i++)
                {
                    result.Add(ResultPeg.None);
                }

                int line = 0;
                foreach (var item in guess)
                {
                    if (code.Contains(item))
                    {
                        for (int i = line; i < code.Count; i++)
                        {
                            if (result[i] == ResultPeg.Black)
                            {
                                continue;
                            }
                            else if (result[i] == ResultPeg.White)
                            {
                                result[i] = ValidateTwoCodePeg(item, code[i]);
                            }
                            else
                            {
                                result[i] = ValidateTwoCodePeg(item, code[i]);
                            }
                            break;
                        }
                    }
                    line++;
                }
                return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(string.Format("{0} - {1} --> {2}", "Mastermind", "GetHints", ex.Message));
                return(null);
            }
        }
Exemplo n.º 15
0
        private List <CodePeg> ConvertMasterEntityToCodePegList(MasterEntity line)
        {
            try
            {
                List <CodePeg> codes = new List <CodePeg>();
                codes.Add(line.FirstPosition);
                codes.Add(line.SecondPosition);
                codes.Add(line.ThirdPosition);
                codes.Add(line.FourthPosition);

                return(codes);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(string.Format("{0} - {1} --> {2}", "Mastermind", "ConvertMasterEntityToCodePegList", ex.Message));
                return(null);
            }
        }
        public void GetData_HasIIS_CallsCreateIisDataObject()
        {
            //Assemble
            var sut     = Setup();
            var version = new Version();
            var iisData = new IISData();

            iisHandlerMoq.Setup(m => m.GetIisVersion()).Returns(version);
            iisHandlerMoq.Setup(m => m.CreateIisDataObject(version)).Returns(iisData);
            iisHandlerMoq.Setup(m => m.StoreIIS(iisData)).Returns(new IISStringContainer());

            //Act
            MasterEntity result = sut.GetData();

            //Assert
            iisHandlerMoq.Verify(m => m.CreateIisDataObject(version), "CreateIisDataObject was not called");
            iisHandlerMoq.Verify(m => m.StoreIIS(iisData), "StoreIIS was not called");
        }
Exemplo n.º 17
0
        //Displays the information of the selected in the color field
        private void LoadText(MasterEntity line)
        {
            switch (cmbPosition.SelectedIndex)
            {
            case 0:
                txtField.Text = line.FirstPosition == CodePeg.None ? string.Empty : line.FirstPosition.ToString();
                break;

            case 1:
                txtField.Text = line.SecondPosition == CodePeg.None ? string.Empty : line.SecondPosition.ToString();
                break;

            case 2:
                txtField.Text = line.ThirdPosition == CodePeg.None ? string.Empty : line.ThirdPosition.ToString();
                break;

            case 3:
                txtField.Text = line.FourthPosition == CodePeg.None ? string.Empty : line.FourthPosition.ToString();
                break;
            }
        }
Exemplo n.º 18
0
        public object Post([FromBody] MasterEntity content)
        {
            var json = this.Request.Content.ReadAsStringAsync().Result;

            Console.WriteLine(json);

            using (var db = new ServerDb())
            {
                // Check if the server already exists in the DB
                var old = db.Servers.Where(m => m.Id == content.Id)
                          .Include(m => m.environment)
                          .Include(m => m.iis)
                          .FirstOrDefault();

                // Save Existing Server
                if (old != null)
                {
                    db.Servers.Remove(old);

                    db.Servers.Add(content);

                    db.SaveChanges();
                }
                // Save New Server
                else
                {
                    db.Servers.Add(content);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (System.Data.Entity.Validation.DbEntityValidationException e)
                    {
                        throw;
                    }
                }
            }

            return(Request.CreateResponse(HttpStatusCode.OK, "OK"));
        }
Exemplo n.º 19
0
        //Add the color to the object
        private void SaveLine(MasterEntity line, int button)
        {
            switch (cmbPosition.SelectedIndex)
            {
            case 0:
                line.FirstPosition = (CodePeg)button;
                break;

            case 1:
                line.SecondPosition = (CodePeg)button;
                break;

            case 2:
                line.ThirdPosition = (CodePeg)button;
                break;

            case 3:
                line.FourthPosition = (CodePeg)button;
                break;
            }

            cmbPosition.SelectedIndex = (cmbPosition.SelectedIndex != 3) ? cmbPosition.SelectedIndex + 1 : 0;
        }
Exemplo n.º 20
0
 void Awake()
 {
     MasterEntity.Create();
     Entity.Create <UIStage>();
 }
Exemplo n.º 21
0
 private void Awake()
 {
     MasterEntity.Create();
     Entity.Create <TimerComponent>();
     Entity.Create <CombatContext>();
 }
Exemplo n.º 22
0
 public MasterMind(MasterEntity line)
 {
     this.code = ConvertMasterEntityToCodePegList(line);
 }
Exemplo n.º 23
0
 private void OnApplicationQuit()
 {
     Entity.Destroy(MasterEntity.Instance);
     MasterEntity.Destroy();
 }