Exemplo n.º 1
0
        public void copies_grammars()
        {
            const string fixtureKey = "a key";

            var lib      = new FixtureLibrary();
            var original = new FixtureModel(fixtureKey);

            lib.Models[fixtureKey] = original;

            original.AddGrammar(new Sentence {
                key = "sentence", format = "a format"
            });

            var overrides = new FixtureLibrary();
            var overriden = new FixtureModel(fixtureKey);

            overrides.Models[fixtureKey] = overriden;

            var result = lib.ApplyOverrides(overrides);

            result.Models.Count.ShouldBe(1);

            var fixture = result.Models[fixtureKey];

            ReferenceEquals(fixture, overrides.Models[fixtureKey]).ShouldBeFalse();
            fixture.key.ShouldBe(fixtureKey);

            fixture.grammars.Length.ShouldBe(1);

            var sentence = fixture.grammars[0] as Sentence;

            sentence.key.ShouldBe("sentence");
            sentence.format.ShouldBe("a format");
        }
Exemplo n.º 2
0
        public ActionResult AddResult(FixtureModel FixtureObj)
        {
            AddResultViewModel rvm = new AddResultViewModel();

            rvm.Details = FixtureObj;
            if (FixtureObj.FixtureType == 0)
            {
                rvm.FixtureTypeList = resRepo.LeagueResult_GetFixtureTypes();
            }

            var players = resRepo.LeagueResult_GetTeamsForFixture(FixtureObj.FixtureRef);

            rvm.HomePlayers = new List <PlayerModel>();
            rvm.AwayPlayers = new List <PlayerModel>();

            foreach (var p in players)
            {
                PlayerModel play = new PlayerModel();
                play.Id             = p.PlayerRef;
                play.RegistrationId = p.RegistrationId;
                play.Name           = p.Forename.Substring(0, 1) + " " + p.Surname;

                if (p.TeamRef == FixtureObj.HomeTeamRef)
                {
                    rvm.HomePlayers.Add(play);
                }
                else
                {
                    rvm.AwayPlayers.Add(play);
                }
            }

            return(PartialView("Partial_AddResult", rvm));
        }
        public void derive_the_key_from_a_title_3()
        {
            var fixture = FixtureModel.BuildFromKeyOrTitle("Going to the store - Walmart");

            fixture.title.ShouldBe("Going to the store - Walmart");
            fixture.key.ShouldBe("GoingToTheStoreWalmart");
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            List <TemporaryFixtureInfo> infos = new List <TemporaryFixtureInfo>();

            try
            {
                using (FixtureModel model = new FixtureModel())
                {
                    var fixes = model.JDJS_WMS_Fixture_Temporary_Table;
                    foreach (var item in fixes)
                    {
                        TemporaryFixtureInfo info = new TemporaryFixtureInfo()
                        {
                            Id = item.Id,
                            FixtureOrderNum      = item.FixtureOrderNum,
                            FixtureSpecification = item.FixtureSpecification,
                            InTime   = item.InTime,
                            Name     = item.Name,
                            Remark   = item.Remark == null?"":item.Remark,
                            StockNum = item.StockNum == null?0:Convert.ToInt32(item.StockNum)
                        };
                        infos.Add(info);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            var json = serializer.Serialize(infos);

            context.Response.Write(json);
            return;
        }
        public void create_a_fixture_from_a_key()
        {
            var fixture = FixtureModel.BuildFromKeyOrTitle("Something");

            fixture.key.ShouldBe("Something");
            fixture.title.ShouldBe("Something");
        }
        public void derive_the_title_for_a_complex_key()
        {
            var fixture = FixtureModel.BuildFromKeyOrTitle("SomethingElse");

            fixture.key.ShouldBe("SomethingElse");
            fixture.title.ShouldBe("Something Else");
        }
Exemplo n.º 7
0
        public string CreateFixture(string keyOrTitle)
        {
            var fixture = FixtureModel.BuildFromKeyOrTitle(keyOrTitle);
            var file    = FileFor(fixture.key);

            if (File.Exists(file))
            {
                ConsoleWriter.Write(ConsoleColor.White, $"Fixture file '{file}' already exists");
            }
            else
            {
                _watcher.Latch(() =>
                {
                    FixtureWriter.Write(fixture, file);
                });

                _overrides.Models[fixture.key] = fixture;

                sendUpdatesToClient();

                ConsoleWriter.Write(ConsoleColor.Green, $"Successfully created a new Fixture {fixture.key}: {fixture.title}");
            }

            return(file);
        }
Exemplo n.º 8
0
        public static string Write(FixtureModel model)
        {
            var writer = new StringWriter();
            Write(model, writer);

            return writer.ToString();
        }
Exemplo n.º 9
0
 public TableMode(string key, string title, FixtureModel fixture)
 {
     _table       = new Table();
     _table.key   = key;
     _table.title = title;
     fixture.AddGrammar(_table);
 }
Exemplo n.º 10
0
        public void overrides_original_title()
        {
            const string key = "a key";

            var lib      = new FixtureLibrary();
            var original = new FixtureModel(key);

            original.title          = "A title";
            original.implementation = "some implementation";
            lib.Models[key]         = original;

            var overrides = new FixtureLibrary();
            var overriden = new FixtureModel(key);

            overriden.title       = "A new title";
            overrides.Models[key] = overriden;

            var result = lib.ApplyOverrides(overrides);

            result.Models.Count.ShouldBe(1);

            var fixture = result.Models[key];

            ReferenceEquals(fixture, overrides.Models[key]).ShouldBeFalse();
            fixture.title.ShouldBe(overriden.title);
            fixture.implementation.ShouldBe(original.implementation);
        }
Exemplo n.º 11
0
        private void processFixtures(Task <IDocument> response)
        {
            Fixtures.ClearItems();
            IDocument document = response.Result;
            var       tables   = document.QuerySelectorAll(".FTable");

            foreach (var table in tables)
            {
                var fixture   = new FixtureModel();
                var headerRow = table.QuerySelector(".FHeader");
                fixture.Date = headerRow.QuerySelector("td").TextContent;
                var matches = table.QuerySelectorAll(".FRow");
                foreach (var match in matches)
                {
                    var matchModel = new MatchModel();
                    matchModel.Time = match.QuerySelector(".FDate").TextContent;
                    try {
                        matchModel.TeamA     = match.QuerySelector(".FHomeTeam").TextContent;
                        matchModel.TeamAHref = match.QuerySelector(".FHomeTeam").QuerySelector("a").GetAttribute("href");

                        matchModel.TeamB     = match.QuerySelector(".FAwayTeam").TextContent;
                        matchModel.TeamBHref = match.QuerySelector(".FAwayTeam").QuerySelector("a").GetAttribute("href");

                        matchModel.Court = match.QuerySelector(".FPlayingArea").TextContent;
                        matchModel.Score = match.QuerySelector(".FScore").TextContent;
                    }
                    catch (Exception ex) {
                    }

                    fixture.Matches.AddOnUIThread(matchModel);
                }
                Fixtures.AddOnUIThread(fixture);
            }
        }
Exemplo n.º 12
0
    protected void Page_Init(object sender, EventArgs e)
    {
        doc  = SiteCache.FixtureData;
        doc1 = SiteCache.HandicapData;

        model  = new FixtureModel();
        model2 = new PlayerModel();
    }
Exemplo n.º 13
0
        public ActionResult DeleteConfirmed(int id)
        {
            FixtureModel fixtureModel = db.Fixtures.Find(id);

            db.Fixtures.Remove(fixtureModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public static string Write(FixtureModel model)
        {
            var writer = new StringWriter();

            Write(model, writer);

            return(writer.ToString());
        }
Exemplo n.º 15
0
 public void ReadTotalSamplesTest(FixtureModel model)
 {
     if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor))
     {
         Fin <ulong> totalSamples = Flac.ReadTotalSamples(model.ToTargetInformation(this.RealFileSystem).FileStream);
         Assert.True(totalSamples.IsSucc);
         ((ulong)totalSamples).Should().Be(model.Record.TotalSamples);
     }
 }
        public void to_missing_code_if_nothing_is_missing()
        {
            var fixture = new FixtureModel("Something")
            {
                IsMissing = false
            };

            fixture.missingCode.ShouldBe(FixtureModel.FullyImplementedMessage);
        }
        public void HasLogFileTest(FixtureModel model)
        {
            if (model.Process.ContainsKey(FixtureModel.FrontierLabsLogFileExtractor))
            {
                TargetInformation ti = model.ToTargetInformation(this.RealFileSystem);

                Assert.True(ti.TargetSupportFiles.ContainsKey(LogFile.LogFileKey));
            }
        }
Exemplo n.º 18
0
 public void ReadSampleRateTest(FixtureModel model)
 {
     if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor))
     {
         Fin <uint> sampleRate = Flac.ReadSampleRate(model.ToTargetInformation(this.RealFileSystem).FileStream);
         Assert.True(sampleRate.IsSucc);
         ((uint)sampleRate).Should().Be(model.Record.SampleRateHertz);
     }
 }
Exemplo n.º 19
0
 public void ReadNumChannelsTest(FixtureModel model)
 {
     if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor))
     {
         Fin <byte> channels = Flac.ReadNumChannels(model.ToTargetInformation(this.RealFileSystem).FileStream);
         Assert.True(channels.IsSucc);
         ((byte)channels).Should().Be((byte)model.Record.Channels);
     }
 }
Exemplo n.º 20
0
 public void ReadBitDepthTest(FixtureModel model)
 {
     if (model.Process.ContainsKey(FixtureModel.FlacHeaderExtractor))
     {
         Fin <byte> bitDepth = Flac.ReadBitDepth(model.ToTargetInformation(this.RealFileSystem).FileStream);
         Assert.True(bitDepth.IsSucc);
         ((byte)bitDepth).Should().Be(model.Record.BitDepth);
     }
 }
Exemplo n.º 21
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int id = int.Parse(context.Request["id"]);//id
                using (FixtureModel model = new FixtureModel())
                {
                    var fx = model.JDJS_WMS_Fixture_System_Table.Where(r => r.Id == id).FirstOrDefault();
                    if (fx == null)
                    {
                        context.Response.Write("该治具不存在!");
                        return;
                    }


                    using (System.Data.Entity.DbContextTransaction mytran = model.Database.BeginTransaction())
                    {
                        try
                        {
                            model.JDJS_WMS_Fixture_System_Table.Remove(fx);
                            model.SaveChanges();
                            mytran.Commit();
                            PathInfo info = new PathInfo();
                            if (System.IO.File.Exists(System.IO.Path.Combine(info.GetFixtrue_SurfMillFilePath(), fx.FileName)))
                            {
                                System.IO.File.Delete(System.IO.Path.Combine(info.GetFixtrue_SurfMillFilePath(), fx.FileName));
                            }
                            using (JDJS_WMS_DB_USEREntities wms = new JDJS_WMS_DB_USEREntities())
                            {
                                var status = wms.JDJS_WMS_Device_Status_Table.Where(r => r.SystemId == id).FirstOrDefault();
                                if (status != null)
                                {
                                    wms.JDJS_WMS_Device_Status_Table.Remove(status);
                                }
                                wms.SaveChanges();
                            }
                            string str = "";
                            Fixture_SurfMill.DeleteChildJIG(fx.Name, fx.Desc, fx.StockAllNum.ToString(), fx.StockCurrNum.ToString(), ref str);
                            context.Response.Write(str);
                            return;
                        }
                        catch (Exception ex)
                        {
                            mytran.Rollback();
                            context.Response.Write(ex.Message);
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
                return;
            }
        }
        public void to_missing_code_with_the_fixture_itself_being_missing()
        {
            var fixture = new FixtureModel("Something")
            {
                IsMissing = true
            };

            fixture.missingCode.ShouldNotBe(FixtureModel.FullyImplementedMessage);

            fixture.missingCode.ShouldContain("public class SomethingFixture");
        }
Exemplo n.º 23
0
 public ActionResult Edit([Bind(Include = "FixtureId,FixtureName,Team1Id,Team2Id,Matchdate,Executed")] FixtureModel fixtureModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fixtureModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Team1Id = new SelectList(db.Teams, "TeamId", "TeamName", fixtureModel.Team1Id);
     ViewBag.Team2Id = new SelectList(db.Teams, "TeamId", "TeamName", fixtureModel.Team2Id);
     return(View(fixtureModel));
 }
Exemplo n.º 24
0
        public MetadataDurationBugTests(FixtureHelper.FixtureData data)
        {
            this.fixture = data[FixtureModel.MetadataDurationBug];
            this.target  = TempFile.FromExisting(this.fixture.AbsoluteFixturePath);

            this.fileUtilities = new FileUtilities(Helpers.NullLogger <FileUtilities>(), new FileSystem());
            this.fixer         = new MetadataDurationBug(Helpers.NullLogger <MetadataDurationBug>(), this.fileUtilities);

            this.dryRunLogger = Helpers.NullLogger <DryRun>();
            this.data         = data;
            this.fileSystem   = new FileSystem();
        }
Exemplo n.º 25
0
        public static void Write(FixtureModel model, TextWriter writer)
        {
            writer.WriteLine($"# {model.title}");
            writer.WriteLine();
            writer.WriteLine();

            var grammars = model.grammars.Where(x => x.key != "TODO").OrderBy(x => x.key);
            foreach (var grammar in grammars)
            {
                writeGrammar(model, writer, grammar, false);
            }
        }
        public static void Write(FixtureModel model, TextWriter writer)
        {
            writer.WriteLine($"# {model.title}");
            writer.WriteLine();
            writer.WriteLine();

            var grammars = model.grammars.Where(x => x.key != "TODO").OrderBy(x => x.key);

            foreach (var grammar in grammars)
            {
                writeGrammar(model, writer, grammar, false);
            }
        }
Exemplo n.º 27
0
        private (byte[] FormatChunk, RangeHelper.Range DataChunk) ReadChunkRanges(FixtureModel model)
        {
            using var stream = model.ToTargetInformation(this.RealFileSystem).FileStream;

            var riffChunk   = Wave.FindRiffChunk(stream);
            var waveChunk   = riffChunk.Bind(r => Wave.FindWaveChunk(stream, r));
            var formatChunk = waveChunk.Bind(w => Wave.FindFormatChunk(stream, w));
            var dataChunk   = waveChunk.Bind(w => Wave.FindDataChunk(stream, w));

            var formatSpan = RangeHelper.ReadRange(stream, (RangeHelper.Range)formatChunk);

            return(formatSpan.ToArray(), (RangeHelper.Range)dataChunk);
        }
        public static void Write(FixtureModel model, string file)
        {
            using (var stream = new FileStream(file, FileMode.Create))
            {
                var writer = new StreamWriter(stream);

                Write(model, writer);
            }

            var text = Write(model);

            new FileSystem().WriteStringToFile(file, text);
        }
Exemplo n.º 29
0
        private static void writeParagraph(Paragraph paragraph, FixtureModel model, TextWriter writer)
        {
            for (int i = 0; i < paragraph.children.Length; i++)
            {
                var child = paragraph.children[i];
                if (child is Silent) continue;

                writeGrammar(model, writer, child, true);
            }

            writer.WriteLine();
            writer.WriteLine();
        }
Exemplo n.º 30
0
        // GET: FixtureModels/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FixtureModel fixtureModel = db.Fixtures.Find(id);

            if (fixtureModel == null)
            {
                return(HttpNotFound());
            }
            return(View(fixtureModel));
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                int         id    = int.Parse(context.Request["id"]);
                string      fxNum = "";
                List <File> file  = new List <File>();
                using (FixtureModel wms = new FixtureModel())
                {
                    var fx = wms.JDJS_WMS_Fixture_System_Table.Where(r => r.Id == id).FirstOrDefault();
                    if (fx != null)
                    {
                        fxNum = fx.FixtureOrderNum;
                    }
                }
                if (fxNum != "")
                {
                    PathInfo      info = new PathInfo();
                    string        path = System.IO.Path.Combine(info.upLoadPath(), @"特殊治具管理", fxNum, @"设计文件");
                    DirectoryInfo root = new DirectoryInfo(path);
                    if (root.Exists)
                    {
                        FileInfo[] files = root.GetFiles();



                        foreach (var item in files)
                        {
                            file.Add(new File
                            {
                                fileName = item.Name,
                                filePath = item.FullName,
                                fileSize = (item.Length / 1024).ToString() + "  kB",
                                fileTime = item.CreationTime.ToString()
                            });
                        }
                    }
                }
                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                var model = new { msg = "", code = 0, count = file.Count, data = file };
                var json  = serializer.Serialize(model);
                context.Response.Write(json);
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.Message);
            }
        }
        private static void writeParagraph(Paragraph paragraph, FixtureModel model, TextWriter writer)
        {
            for (int i = 0; i < paragraph.children.Length; i++)
            {
                var child = paragraph.children[i];
                if (child is Silent)
                {
                    continue;
                }

                writeGrammar(model, writer, child, true);
            }

            writer.WriteLine();
            writer.WriteLine();
        }
Exemplo n.º 33
0
        public void does_not_overwrite_an_existing_fixture()
        {
            var file     = theFixtureDirectory.AppendPath("One.md");
            var original = new FixtureModel("One")
            {
                title = "a fancier title"
            };

            FixtureWriter.Write(original, file);

            theController.CreateFixture("One");

            FixtureReader.ReadFromFile(file)
            .title.ShouldBe(original.title);

            theClient.ReceivedCalls().Any().ShouldBeFalse();
        }
Exemplo n.º 34
0
        private static void writeGrammar(FixtureModel model, TextWriter writer, GrammarModel grammar, bool inParagraph)
        {
            if (inParagraph)
            {
                writer.WriteLine($"* {grammar.TitleOrFormat()}");                
            }
            else
            {
                writer.WriteLine($"## {grammar.key}");
                writer.WriteLine($"### {grammar.TitleOrFormat()}");
            }


            if (grammar is Sentence)
            {
                writeSentence((Sentence) grammar, writer);
            }

            if (grammar is Table)
            {
                writeTable((Table) grammar, writer);
            }

            if (grammar is EmbeddedSection)
            {
                writeEmbed((EmbeddedSection) grammar, writer);
            }

            if (grammar is Paragraph)
            {
                writeParagraph(grammar.As<Paragraph>(), model, writer);
            }

            

            if (!inParagraph)
            {
                writer.WriteLine();
                writer.WriteLine();
            }
        }
Exemplo n.º 35
0
 public GrammarMode(FixtureModel fixture, Action<GrammarModel> adder)
 {
     _fixture = fixture;
     _adder = adder;
 }
Exemplo n.º 36
0
 public ParagraphMode(Paragraph paragraph, FixtureModel fixture)
 {
     _paragraph = paragraph;
     _fixture = fixture;
 }
Exemplo n.º 37
0
 public HeaderMode(FixtureModel fixture)
 {
     _fixture = fixture;
 }
Exemplo n.º 38
0
 public CommentMode(FixtureModel fixture)
 {
     _fixture = fixture;
 }
Exemplo n.º 39
0
        public static void Write(FixtureModel model, string file)
        {
            using (var stream = new FileStream(file, FileMode.Create))
            {
                var writer = new StreamWriter(stream);

                Write(model, writer);
            }

            var text = Write(model);
            new FileSystem().WriteStringToFile(file, text);
        }