예제 #1
0
        private void AddAnalyse_Click_1(object sender, EventArgs e)
        {
            AnalyseModel addmodel  = new AnalyseModel();
            DateModel    datemodel = new DateModel();

            datemodel.Day   = Program.Current_Date.Date;
            datemodel.Time += Program.Current_Date.TimeOfDay;

            addmodel.Date_Id = date.Add(datemodel);
            try
            {
                int selected = ListView.SelectedIndices[0];
                addmodel.Type_Id   = Analyse_Type.SelectedIndex + 1;
                addmodel.Client_Id = long.Parse(ListView.Items[selected].SubItems[0].Text);
                addmodel.Result    = long.Parse(ResultText.Text);
                addmodel.Coment    = Coment.Text;
                analyse.Add(addmodel);
                Coment.Clear();
                ResultText.Clear();
                MessageBox.Show("Данные внесены");
            }
            catch
            {
                MessageBox.Show("Некоторые поля не выбраны");
            }
        }
        public AnalyseModel Get_Item(string field, string value, ConditionType type)
        {
            FilterCondition filter = new FilterCondition(field, value, type);

            using (var db = new MainDb())
            {
                var query = MakeSelect(db);

                if (filter != null)
                {
                    if (filter.Field.Equals("ID", StringComparison.CurrentCultureIgnoreCase) && filter.Value != null)
                    {
                        if (filter.Type == ConditionType.Equal)
                        {
                            query = query.Where(q => q.Id.Equals(filter.Value));
                        }
                    }
                }
                AnalyseModel Result = new AnalyseModel();
                try
                {
                    Result = query.Single();
                    return(Result);
                }
                catch
                {
                    return(null);
                }
            }
        }
예제 #3
0
        public void FilterStopWordsTest_basic()
        {
            string input          = "I am a person and a man";
            string expectedResult = "person man";

            AnalyseModel model = new AnalyseModel();

            Assert.AreEqual(expectedResult, model.RemoveStopWords(input));
        }
예제 #4
0
        public void GetOccuranceWordTableTest_input_is_empty()
        {
            string input = "    ";

            AnalyseModel model  = new AnalyseModel();
            var          result = model.GetOccuranceWordTable(input);

            Assert.AreEqual(0, result.Count());
        }
예제 #5
0
        public void GetOccuranceWordTableTest_upperCharacter()
        {
            string input = "Apple apple APPLE";

            AnalyseModel model  = new AnalyseModel();
            var          result = model.GetOccuranceWordTable(input);

            Assert.IsTrue(result.Any(x => x.Key == "apple" && x.Value == 3));
        }
예제 #6
0
        public void FilterStopWordsTest_input_have_empty_space()
        {
            string input          = "I    AM     A person    aNd    A    man";
            string expectedResult = "person man";

            AnalyseModel model = new AnalyseModel();

            Assert.AreEqual(expectedResult, model.RemoveStopWords(input));
        }
예제 #7
0
        public void FilterStopWordsTest_input_is_empty()
        {
            string input          = string.Empty;
            string expectedResult = string.Empty;

            AnalyseModel model = new AnalyseModel();

            Assert.AreEqual(expectedResult, model.RemoveStopWords(input));
        }
예제 #8
0
        public ActionResult Index(AnalyseModel model)
        {
            string content = string.Empty;

            model.InvalidMessage = string.Empty;

            #region Validate input
            if (model.IsAnyOptionSelected == false)
            {
                model.InvalidMessage = "Please check at least one of the checkbox";
            }
            else if (string.IsNullOrWhiteSpace(model.Input))
            {
                model.InvalidMessage = "Please enter text or url";
            }
            else if (Uri.TryCreate(model.Input, UriKind.Absolute, out Uri uri))
            {
                content = GetHtmlText(uri);

                if (string.IsNullOrEmpty(content))
                {
                    model.InvalidMessage = "The URL you enter could not be access";
                }
            }
            else
            {
                content = model.Input;
            }
            #endregion

            if (string.IsNullOrEmpty(model.InvalidMessage))
            {
                model.IsValid = true;

                if (model.FilterStopsWordsFlag)
                {
                    content = model.RemoveStopWords(content);
                }

                if (model.CalNumOfOccuranceOfWordsFlag)
                {
                    model.OccuranceOfWordsTable = model.GetOccuranceWordTable(HttpUtility.HtmlEncode(content));
                }

                if (model.CalNumOfOccuranceOfWordsListedInMetaTagsFlag)
                {
                    model.OccuranceOfWordsInMetaTagsTable = model.GetOccuranceWordInMetaTagTable(content);
                }

                if (model.CalNumOfOccuranceOfExternalLinksFlag)
                {
                    model.OccuranceOfExternalLinksTable = model.GetOccuranceExternalLinkTable(content);
                }
            }

            return(View(model));
        }
예제 #9
0
        public void GetOccuranceWordTableTest_two_differenct_words()
        {
            string input = "Apple banana apple Banana APPLE";

            AnalyseModel model  = new AnalyseModel();
            var          result = model.GetOccuranceWordTable(input);

            Assert.IsTrue(result.Any(x => x.Key == "apple" && x.Value == 3));
            Assert.IsTrue(result.Any(x => x.Key == "banana" && x.Value == 2));
        }
예제 #10
0
        public void GetOccuranceWordTableTest()
        {
            string input = "apple apple apple";

            AnalyseModel model  = new AnalyseModel();
            var          result = model.GetOccuranceWordTable(input);

            Assert.IsTrue(result.Any(x => x.Key == "apple" && x.Value == 3));
            Assert.IsFalse(result.Any(x => x.Key == "apple" && x.Value == 1));
        }
예제 #11
0
        public void GetOccuranceExternalLinkTableTest_two_same_link()
        {
            string input = string.Empty;
            string link1 = @"https://visualstudio.microsoft.com/vso/";

            input += (link1 + " " + link1);

            AnalyseModel model  = new AnalyseModel();
            var          result = model.GetOccuranceExternalLinkTable(input);

            Assert.IsTrue(result.Any(x => x.Key == link1 && x.Value == 2));
        }
예제 #12
0
        public void GetOccuranceWordInMetaTagTableTest()
        {
            string input = @"<meta charset= ""UTF - 8\"">
                             <meta name = ""keywords"" content = ""HTML,CSS,XML,JavaScript"" >
                             <meta name = ""keywords"" content = ""HTML,CSS,XML,JavaScript"" > 
                             <meta name = ""keywords"" content = ""HTML,CSS,XML,JavaScript"" >";

            AnalyseModel model  = new AnalyseModel();
            var          result = model.GetOccuranceWordInMetaTagTable(input);

            Assert.IsTrue(result.Any(x => x.Key == "content" && x.Value == 3));
            Assert.IsTrue(result.Any(x => x.Key == "name" && x.Value == 3));
            Assert.IsTrue(result.Any(x => x.Key == "\"keywords\"" && x.Value == 3));
        }
        public long Add(AnalyseModel model)
        {
            //TODO: валидация модели

            //Сохранение
            using (var db = new MainDb())
            {
                long id = Convert.ToInt64(db.Analyse.InsertWithIdentity(() => new Kpo.Dal.MainDb.AnalyseDataModel
                {
                    Type_Id   = model.Type_Id,
                    Result    = model.Result,
                    Client_Id = model.Client_Id,
                    Coment    = model.Coment,
                    Date_Id   = model.Date_Id
                }));

                return(id);
            }
        }
        public ActionResult Display(int[] peopleIds)
        {
            var people = peopleIds
                         .Select(i => dc.Person.Where(p => p.Id == i).Single())
                         .ToArray();
            var swLog    = new StringWriter();
            var netMoney = DebtGraph.CalculateDebts(dc, people, true, swLog);

            var swGraph = new StringWriter();

            DebtGraph.WriteGraph(netMoney, swGraph);
            var svg = DebtGraph.RenderGraphAsSvg(swGraph.ToString());

            var mod = new AnalyseModel();

            mod.LogOutput = swLog.ToString();
            mod.ImageSvg  = svg;
            mod.Debtors   = DebtGraph.GreatestDebtor(netMoney);
            return(View(mod));
        }
예제 #15
0
        public ActionResult Index()
        {
            AnalyseModel model = new AnalyseModel();

            return(View(model));
        }