private void ShowResult(List <ResultModel> result, PatternModel pattern)
        {
            IResultView           resultFrm       = new FrmResult();
            SearchResultPresenter resultPresenter = new SearchResultPresenter(resultFrm);

            resultPresenter.RenderResult(result, pattern);
        }
        // GET: Pattern
        public ActionResult GetNotActifPatterns()
        {
            List <PatternModel> listPatterns = new List <PatternModel>();

            //PatternModel PatternModels = new PatternModel();
            HttpClient listPattern = new HttpClient();

            listPattern.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var response = listPattern.GetAsync("http://localhost:18080/Epione_JEE-web/epione/doctor/getListDisabledPatternByDoctor/" + Session["id"]).Result;

            if (response.IsSuccessStatusCode)
            {
                foreach (var pattern in response.Content.ReadAsAsync <IEnumerable <PatternModel> >().Result)
                {
                    PatternModel PatternModel = new PatternModel {
                        id = pattern.id, label = pattern.label, periode = pattern.periode, price = pattern.price
                    };

                    listPatterns.Add(PatternModel);
                }
                return(Json(new { data = listPatterns }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                ViewBag.result = "error";
                return(ViewBag.result);
            }
        }
Beispiel #3
0
/// <summary>
/// 更新信息
/// </summary>
        public int UpdateInfo(SqlTransaction trans, PatternModel patModel, long ID)
        {
            string key = "Cache_Pattern_Model_" + ID;

            CacheHelper.RemoveCache(key);
            return(patDAL.UpdateInfo(trans, patModel, ID));
        }
        public ActionResult Create(PatternModel pattmodel)
        {
            pattmodel.idDoctor = Convert.ToInt32(Session["id"]);

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://127.0.0.1:18080");
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var response = client.PostAsJsonAsync <PatternModel>("Epione_JEE-web/epione/doctor/addPattern", pattmodel).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                Session["alertMessageSucc"]  = "Pattern added successfully";
                Session["alertMessageError"] = null;
                return(RedirectToAction("Index", "Pattern"));
            }
            if (response.StatusCode == HttpStatusCode.OK) //

            {
                Session["alertMessageSucc"]  = null;
                Session["alertMessageError"] = "Pattern not added";
                return(View());
            }
            ViewBag.response = client.PostAsJsonAsync <PatternModel>("Epione_JEE-web/epione/doctor/addPattern", pattmodel).Result;
            return(View());
        }
        public void PopulateControls()
        {
            var cat = new PatternModel {
                NickName = "Please Select", ID = 0
            };
            var cats = new List <PatternModel> {
                cat
            };

            cats.AddRange(GetPattern());
            ddlPattern.DataSource = cats;
            ddlPattern.DataBind();

            var coordinator = new UserModel {
                ID = 0, Username = "******"
            };
            var coordinators = new List <UserModel> {
                coordinator
            };

            coordinators.AddRange(GetCordinator());
            ddlCoordinator.DataSource = coordinators;
            ddlCoordinator.DataBind();

            var distributor = new DistributorModel {
                ID = 0, Name = "Please select"
            };
            var distributors = new List <DistributorModel> {
                distributor
            };

            distributors.AddRange(GetDistributor());
            ddlDistributor.DataSource = distributors;
            ddlDistributor.DataBind();
        }
Beispiel #6
0
        internal override TileModelMapping GetTileModelMapping(Topology topology)
        {
            if (frequencies.Sum() == 0.0)
            {
                throw new Exception("No tiles have assigned frequences.");
            }

            var patternModel = new PatternModel
            {
                Propagator  = propagator.Select(x => x.Select(y => y.ToArray()).ToArray()).ToArray(),
                Frequencies = frequencies.ToArray(),
            };
            var tilesToPatternsByOffset = new Dictionary <int, IReadOnlyDictionary <Tile, ISet <int> > >()
            {
                { 0, tilesToPatterns.ToLookup(x => x.Key, x => x.Value).ToDictionary(g => g.Key, g => (ISet <int>) new HashSet <int>(g)) }
            };
            var patternsToTilesByOffset = new Dictionary <int, IReadOnlyDictionary <int, Tile> >
            {
                { 0, tilesToPatterns.ToDictionary(x => x.Value, x => x.Key) },
            };

            return(new TileModelMapping
            {
                PatternTopology = topology,
                PatternModel = patternModel,
                PatternsToTilesByOffset = patternsToTilesByOffset,
                TilesToPatternsByOffset = tilesToPatternsByOffset,
                TileCoordToPatternCoord = null,
            });
        }
Beispiel #7
0
        private static void RunScriptOnAllCallback(FileSelectionModel model)
        {
            if (model == null)
            {
                return;
            }

            TestArgs args = model.Args as TestArgs;

            if (args == null)
            {
                throw new Exception("Args must be of type TestArgs!");
            }

            args.Files = model.Files;
            args.Pattern.SelectedFiles = model.Files;

            ThreadPool.QueueUserWorkItem(d =>
            {
                var sw = new Stopwatch("Saving Pattern Selected Files");
                // Remember which files where selected for the next Run - Sara
                var m = new PatternModel()
                {
                    Item = args.Pattern, Mode = InputMode.Edit
                };
                PatternCRUDService.SavePattern(m);
                sw.Stop(0);
            });

            Run(args);
        }
Beispiel #8
0
 public SearchPatternEventArgs(PatternModel pattern, bool matchWord, bool matchCase, bool wrapSearch)
 {
     this.Pattern    = pattern;
     this.MatchWord  = matchWord;
     this.MatchCase  = matchCase;
     this.WrapSearch = wrapSearch;
 }
        public void TestChessboard()
        {
            var model = new PatternModel
            {
                Frequencies = new double[] { 1, 1 },
                Propagator  = new int[][][]
                {
                    new int[][] { new int[] { 1 }, new int[] { 1 }, new int[] { 1 }, new int[] { 1 }, },
                    new int[][] { new int[] { 0 }, new int[] { 0 }, new int[] { 0 }, new int[] { 0 }, },
                }
            };
            var width      = 10;
            var height     = 10;
            var topology   = new Topology(width, height, true);
            var propagator = new WavePropagator(model, topology);
            var status     = propagator.Run();

            Assert.AreEqual(Resolution.Decided, status);
            var a       = propagator.ToTopoArray().ToArray2d();
            var topLeft = a[0, 0];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    Assert.IsTrue((a[x, y] == topLeft) ^ (x % 2 == 0) ^ (y % 2 == 0));
                }
            }

            // Should be impossible with an odd sized region
            topology   = new Topology(width + 1, height + 1, true);
            propagator = new WavePropagator(model, topology);
            status     = propagator.Run();
            Assert.AreEqual(Resolution.Contradiction, status);
        }
Beispiel #10
0
        private void lstPattern_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }

            e.DrawBackground();
            Graphics g = e.Graphics;

            // Hightlight selected item.
            g.FillRectangle(new SolidBrush(Color.White), e.Bounds);
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.LightGray), e.Bounds);
            }

            // Change font color according to KeywordsType.
            ListBox      lb      = (ListBox)sender;
            PatternModel pattern = (PatternModel)lb.Items[e.Index];

            if (pattern.Type == PatternType.Normal)
            {
                g.DrawString(pattern.ToString(), e.Font, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
            }
            else
            {
                g.DrawString(pattern.ToString(), e.Font, new SolidBrush(Color.Blue), new PointF(e.Bounds.X, e.Bounds.Y));
            }

            e.DrawFocusRectangle();
        }
        public Guid Add([FromBody] PatternModel viewModel)
        {
            var pattern = PatternMapper.MapPatternViewModelToPattern(viewModel);

            viewModel.Id = _patternService.Create(pattern);

            return(viewModel.Id);
        }
Beispiel #12
0
        private PatternModel GetPattern()
        {
            List <string> patternText = GetPatternText();
            PatternType   type        = toolBtnRegExp.Checked == true ? PatternType.RegExp : PatternType.Normal;
            PatternModel  pattern     = new PatternModel(patternText, type);

            return(pattern);
        }
        public void RenderResult(List <ResultModel> resultList, PatternModel pattern)
        {
            result       = resultList;
            this.pattern = pattern;
            string resultText = FormatResult(resultList, pattern.PatternText.Count);

            view.ShowResult(resultText);
        }
        public void TestBacktracking()
        {
            // Reproduces the wang tiles found at
            // https://en.wikipedia.org/wiki/Wang_tile
            // They only have aperiodic tiling, so they are a hard set to put down.
            // Clockwise from top
            var tileBorders = new[]
            {
                "rrrg",
                "brbg",
                "rggg",
                "wbrb",
                "bbwb",
                "wwrw",
                "rgbw",
                "bwbr",
                "brwr",
                "ggbr",
                "rwrg",
            };
            var propagator = tileBorders.Select(tile1 =>

                                                tile1.Select((c, i) =>
            {
                var d = new[] { 3, 0, 2, 1 }[i];
                var o = (i + 2) % 4;
                return(Tuple.Create(d, tileBorders
                                    .Select((tile2, i2) => Tuple.Create(tile2, i2))
                                    .Where(t => t.Item1[o] == c)
                                    .Select(t => t.Item2)
                                    .ToArray()));
            })
                                                .OrderBy(x => x.Item1)
                                                .Select(x => x.Item2)
                                                .ToArray()
                                                ).ToArray();

            var model = new PatternModel
            {
                Frequencies = tileBorders.Select(x => 1.0).ToArray(),
                Propagator  = propagator,
            };
            var topology = new GridTopology(10, 10, false);

            var seed = Environment.TickCount;
            var r    = new Random(seed);

            Console.WriteLine("Seed {0}", seed);

            var wavePropagator = new WavePropagator(model, topology, 10, randomDouble: r.NextDouble);

            var status = wavePropagator.Run();

            Assert.AreEqual(Resolution.Decided, status);

            Console.WriteLine($"Backtrack Count {wavePropagator.BacktrackCount}");
        }
Beispiel #15
0
 private void toolStripBtnSearch_Click(object sender, EventArgs e)
 {
     if (SearchPattern != null)
     {
         PatternModel           pattern = GetPattern();
         SearchPatternEventArgs args    = new SearchPatternEventArgs(pattern, toolBtnMatchWord.Checked, toolBtnMatchCase.Checked, toolBtnWrapSearch.Checked);
         SearchPattern(null, args);
     }
 }
        private List <ResultModel> PerformSearchFull(PatternModel pattern, bool matchWord, bool matchCase)
        {
            int keywordNum = pattern.PatternText.Count;
            List <ResultModel>   results   = new List <ResultModel>();
            List <LineInfoModel> positions = new List <LineInfoModel>();

            using (Scintilla sci = new Scintilla())
            {
                for (int keywordIdx = 0; keywordIdx < keywordNum; keywordIdx++)
                {
                    sci.SetCurrentPos(0);
                    sci.SetAnchor(0);

                    string keyword  = pattern.PatternText[keywordIdx].ToString();
                    bool   isRegExp = pattern.Type == PatternType.RegExp;
                    if (keyword == "")
                    {
                        keyword  = @"^\s*\n";
                        isRegExp = true;
                    }

                    int pos = sci.SearchForwardSilent(keyword, isRegExp, matchWord, matchCase);
                    while (pos != -1)
                    {
                        positions.Add(new LineInfoModel(pos, keywordIdx));
                        pos = sci.SearchForwardSilent(keyword, isRegExp, matchWord, matchCase);
                    }
                }

                positions = positions.OrderBy(o => o.Position).ToList();

                ResultModel resultModel    = new ResultModel(pattern.PatternText.Count);
                int         lastKeywordIdx = -1;
                foreach (LineInfoModel line in positions)
                {
                    int lineNum = sci.GetLineFromPosition(line.Position);
                    line.LineNumber = lineNum + 1;
                    string text = sci.GetLine(lineNum);
                    line.LineText = text;
                    if (line.KeywordId <= lastKeywordIdx)
                    {
                        results.Add(resultModel);
                        resultModel = new ResultModel(pattern.PatternText.Count);
                    }
                    lastKeywordIdx = line.KeywordId;
                    resultModel.Result.Add(line);
                    resultModel.MatchCount++;
                }
                if (resultModel.Result.Count != 0)
                {
                    results.Add(resultModel);
                }
            }

            return(results);
        }
 private void SwapPatternAt(Object sender, SwapPatternPositionEventArgs args)
 {
     if (args.Src >= 0 && args.Src < patterns.Count && args.Dest >= 0 && args.Dest < patterns.Count)
     {
         PatternModel tmp = patterns[args.Src];
         patterns[args.Src]  = patterns[args.Dest];
         patterns[args.Dest] = tmp;
         view.SelectPatternAt(args.Dest);
     }
 }
Beispiel #18
0
        private void ShowPatternProperties(PatternModel pm)
        {
            StringBuilder sb = new StringBuilder();

            foreach (PropertyInfo prop in typeof(PatternModel).GetProperties())
            {
                sb.Append(prop.Name + ": " + prop.GetValue(pm, null) + Environment.NewLine);
            }
            rtxPatternProperties.Text = sb.ToString();
        }
        public static Pattern MapPatternViewModelToPattern(PatternModel viewModel)
        {
            var pattern = new Pattern
            {
                IsEnabled = viewModel.IsEnabled,
                IsWorking = viewModel.IsEnabled,
                Value     = viewModel.Pattern
            };

            return(pattern);
        }
        public void TestChessboard(ModelConstraintAlgorithm algorithm)
        {
            var model = new PatternModel
            {
                Frequencies = new double[] { 1, 1 },
                Propagator  = new int[][][]
                {
                    new int[][] { new int[] { 1 }, new int[] { 1 }, new int[] { 1 }, new int[] { 1 }, },
                    new int[][] { new int[] { 0 }, new int[] { 0 }, new int[] { 0 }, new int[] { 0 }, },
                }
            };
            var width    = 10;
            var height   = 10;
            var topology = new GridTopology(width, height, true);
            var options  = new WavePropagatorOptions {
                ModelConstraintAlgorithm = algorithm
            };
            var propagator = new WavePropagator(model, topology, options);
            var status     = propagator.Run();

            Assert.AreEqual(Resolution.Decided, status);
            var a       = propagator.ToTopoArray().ToArray2d();
            var topLeft = a[0, 0];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    Assert.IsTrue((a[x, y] == topLeft) ^ (x % 2 == 0) ^ (y % 2 == 0));
                }
            }

            // Should be impossible with an odd sized region
            topology   = new GridTopology(width + 1, height + 1, true);
            propagator = new WavePropagator(model, topology, options);
            status     = propagator.Run();
            Assert.AreEqual(Resolution.Contradiction, status);

            // Should be possible with an odd sized region, if we have the right mask
            var mask = new bool[(width + 1) * (height + 1)];

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    mask[x + y * (width + 1)] = true;
                }
            }
            topology   = new GridTopology(width + 1, height + 1, true).WithMask(mask);
            propagator = new WavePropagator(model, topology, options);
            status     = propagator.Run();
            Assert.AreEqual(Resolution.Decided, status);
        }
 public PatternEdit(PatternModel p)
 {
     InitializeComponent();
     RefreshbtnUse();
     _patternModel = p;
     if (_patternModel.Title == null)
     {
         RenamePattern();
     }
     RefreshName();
     btnRecord_Rename();
 }
Beispiel #22
0
        public PartialViewResult Partial_GetAllPatterns()
        {
            PatternModel pattern = new PatternModel();
            //Get data from Db
            var allPaternsDal = bll.BllGetAllDataTableFromDb(new Patterns());

            //Map class on class - return List<1st parameter method>
            DataStorePlace.allPatternsModel = helpMethod.HandMapper(new PatternModel(), allPaternsDal);
            //Here call a function for creating DropDownList
            pattern.AllPatternsFromDb = helpMethod.MakeDropDownList(DataStorePlace.allPatternsModel);
            return(PartialView(pattern));
        }
        // GET: Patterns
        public ActionResult Random()
        {
            var logger = new Logger("RobertWeb");
            var conf   = new PatternConfig("Test", "ETHBTC", "15m");

            var pattern = new PatternModel();

            pattern.Name     = "TestModel";
            pattern.Symbol   = "BTCUSD";
            pattern.Interval = "1d";
            return(View(pattern));
        }
Beispiel #24
0
        public static String  FromDatabase(PatternModel cSharpFormat)
        {
            String result = String.Empty;

            result += FacePatternArray[cSharpFormat.AFacePatternId].Insert(4, "A");
            result += FacePatternArray[cSharpFormat.BFacePatternId].Insert(4, "B");
            result += FacePatternArray[cSharpFormat.CFacePatternId].Insert(4, "C");
            result += FacePatternArray[cSharpFormat.XFacePatternId].Insert(4, "X");
            result += FacePatternArray[cSharpFormat.YFacePatternId].Insert(4, "Y");
            result += FacePatternArray[cSharpFormat.ZFacePatternId].Insert(4, "Z");

            return(result);
        }
Beispiel #25
0
        public static PatternModel DeletePattern(int patternId)
        {
            var data = XmlDal.DataModel;

            var model = new PatternModel
            {
                Mode = InputMode.Delete,
                Item = data.GetPattern(patternId)
            };

            SavePattern(model);
            XmlDal.DataModel.PatternCacheDataController.Invalidate();
            return(model);
        }
        public void CanSerializeAndDeserializeModel()
        {
            var pattern = new PatternModel
            {
                DelayInMinutes = 30,
                Force          = true,
                Name           = "SD",
                Operation      = ShutDownOperation.ShutDown
            };
            string s            = pattern.ToSerializableString();
            var    deserialized = PatternModel.Parse(s);

            Assert.AreEqual(pattern.Description, deserialized.Description);
        }
        public static PatternModel MapPatternToPatternViewModel(Pattern entity)
        {
            var pattern = new PatternModel
            {
                Id         = entity.Id,
                CreateDate = entity.CreateDate,
                UpdateDate = entity.UpdateDate,
                IsEnabled  = entity.IsEnabled,
                IsWorking  = entity.IsEnabled,
                Pattern    = entity.Value
            };

            return(pattern);
        }
Beispiel #28
0
/// <summary>
/// 从缓存读取信息
/// </summary>
        public PatternModel GetCacheInfo(SqlTransaction trans, long ID)
        {
            string key   = "Cache_Pattern_Model_" + ID;
            object value = CacheHelper.GetCache(key);

            if (value != null)
            {
                return((PatternModel)value);
            }
            else
            {
                PatternModel patModel = patDAL.GetInfo(trans, ID);
                CacheHelper.AddCache(key, patModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null);
                return(patModel);
            }
        }
Beispiel #29
0
        public void Render(PatternModel model)
        {
            switch (model.Mode)
            {
            case InputMode.Add:
                Text = @"Add Pattern";
                break;

            case InputMode.Edit:
                Text = @"Edit Pattern";
                break;
            }

            Model       = model;
            tbName.Text = Model.Item.Name;
        }
Beispiel #30
0
        public void TestMemoizeIndices()
        {
            var model = new PatternModel
            {
                Frequencies = new double[] { 1, 1 },
                // Free model
                Propagator = new int[][][]
                {
                    new int[][] { new int[] { 0, 1 }, new int[] { 0, 1 }, new int[] { 0, 1 }, new int[] { 0, 1 }, },
                    new int[][] { new int[] { 0, 1 }, new int[] { 0, 1 }, new int[] { 0, 1 }, new int[] { 0, 1 }, },
                }
            };
            var width           = 10;
            var height          = 10;
            var topology        = new GridTopology(width, height, true);
            var indexPicker     = new CustomIndexPicker();
            var memoIndexPicker = new MemoizeIndexPicker(indexPicker);
            var options         = new WavePropagatorOptions {
                BacktrackPolicy = new ConstantBacktrackPolicy(1),
                IndexPicker     = memoIndexPicker,
                PatternPicker   = new SimpleOrderedPatternPicker(),
                Constraints     = new[] { new  DontBanOneConstraint() },
            };
            var propagator = new WavePropagator(model, topology, options);

            // Attempts to pick pattern 0 at index 0, should contradict and backtrack
            var status = propagator.Step();

            Assert.AreEqual(Resolution.Undecided, status);
            Assert.AreEqual(1, propagator.BacktrackCount);
            CollectionAssert.AreEqual(propagator.GetPossiblePatterns(0), new[] { 1 });
            Assert.AreEqual(1, indexPicker.Count);
            // Should re-attempt index zero, with no effect.
            propagator.Step();
            Assert.AreEqual(Resolution.Undecided, status);
            Assert.AreEqual(1, propagator.BacktrackCount);
            CollectionAssert.AreEqual(propagator.GetPossiblePatterns(0), new[] { 1 });
            Assert.AreEqual(1, indexPicker.Count);
            // Attempts to pick pattern 0 at index 1, should contradict and backtrack
            propagator.Step();
            Assert.AreEqual(Resolution.Undecided, status);
            Assert.AreEqual(2, propagator.BacktrackCount);
            CollectionAssert.AreEqual(propagator.GetPossiblePatterns(1), new[] { 1 });
            Assert.AreEqual(2, indexPicker.Count);
            // etc
        }
Beispiel #31
0
    private void CreatePattern(PatternModel patternModel) {
        for (int i = 0; i < patternModel.points.Length; i++) {
            _verteces.Add(Instantiate(VertexPF));
            _verteces[_verteces.Count - 1].location = patternModel.points[i];
            _verteces[_verteces.Count - 1].Place();
        }


        for (int i = 0; i < patternModel.edges.Count; i++) {
            Segment seg = Instantiate(SegmentPF);

            _segments.Add(seg);
            seg.Init(Players.Count, SegmentLifetime);
            seg.VertexA = _verteces[patternModel.edges[i][0]];
            seg.VertexB = _verteces[patternModel.edges[i][1]];
            seg.Place();
        }
    }
Beispiel #32
0
	void GameClient_onLevelStarted (PatternModel obj)
	{
		this.pattern = obj;
		Debug.Log ("Level started");
	}
Beispiel #33
0
    private void ServerLevelStarted(PatternModel patternModel) {
        PatternProxyInst.UpdatePattern(patternModel);
        _pendingMainThreadAction = true;
        _pendingActions = PendingActions.StartRound;
        
}
Beispiel #34
0
 internal void UpdatePattern(PatternModel patternModel) {
     _patternModel = patternModel;
     _patternNedsUpdate = true;
 }
Beispiel #35
0
	void HandleLevelStartMessage (object obj)
	{
		IDictionary<string, object> data = (IDictionary<string, object>)obj;
		data = (IDictionary<string, object>)data ["pattern"];
		PatternModel pattern = new PatternModel ();
		List<object> points = (List<object>)data ["points"];
		List<object> edges = (List<object>)data ["edges"];
		pattern.points = points.ConvertAll<Vector2>(ParseVector2).ToArray();
		pattern.edges = edges.ConvertAll<int[]>(ParseEdge);
		onLevelStarted.Invoke (pattern);
	}