Пример #1
0
        public List <ElementP> GetData(string time)
        {
            List <ElementP> elementPs = new List <ElementP>();

            try
            {
                con.Open();
                DateTime dateTime = DateTime.Parse(time);
                dateTime = new DateTime(2000, 1, 1, dateTime.Hour, dateTime.Minute, dateTime.Second);

                string sqlP = "SELECT IdentifikacioniKod,RedniBroj,DatumPretrage FROM ElementP";

                SqlCommand cmdP = new SqlCommand(sqlP, con);

                using (SqlDataReader oReader = cmdP.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        if (dateTime < DateTime.Parse(oReader["DatumPretrage"].ToString()))
                        {
                            ElementP ELP = new ElementP();
                            ELP.IdentifikacioniKod = oReader["IdentifikacioniKod"].ToString();
                            ELP.RedniBroj          = Int32.Parse(oReader["RedniBroj"].ToString());
                            elementPs.Add(ELP);
                            Console.WriteLine("Citanje Podataka P");
                        }
                    }
                }

                foreach (var item in elementPs)
                {
                    List <ElementC> elementCs = new List <ElementC>();
                    string          IDenKod   = item.IdentifikacioniKod;
                    string          sqlC      = "SELECT Grupa,Vrednost FROM ElementC WHERE IDKOD=@IDenKod";
                    SqlCommand      cmdC      = new SqlCommand(sqlC, con);
                    cmdC.Parameters.AddWithValue("@IDenKod", IDenKod);
                    using (SqlDataReader oReader = cmdC.ExecuteReader())
                    {
                        while (oReader.Read())
                        {
                            ElementC ELC = new ElementC(oReader["Grupa"].ToString().ToCharArray()[0], Int32.Parse(oReader["Vrednost"].ToString()));
                            elementCs.Add(ELC);
                        }
                    }
                    item.AddCs(elementCs);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                con.Close();
            }
            return(elementPs);
        }
Пример #2
0
 private void AddElement(string name, string value = "")
 {
     ElementC element = new ElementC();
     element.ElementName = name;
     if ("" != value)
     {
         element.ElementValue = value;
     }
     element.Text = element.ElementName;
     Element.children.Add(element);
     Element.Nodes.Add(element);
     MyTreeViewControlC.AddElement(element);
 }
Пример #3
0
        private void AddElement(string name, string value = "")
        {
            ElementC element = new ElementC();

            element.ElementName = name;
            if ("" != value)
            {
                element.ElementValue = value;
            }
            element.Text = element.ElementName;
            Element.children.Add(element);
            Element.Nodes.Add(element);
            MyTreeViewControlC.AddElement(element);
        }
Пример #4
0
        public void OverrideMetadataDefaultValueTest()
        {
            ElementA element1 = new ElementA();
            ElementB element2 = new ElementB();
            ElementC element3 = new ElementC();
            ElementD element4 = new ElementD();

            int propertyChangedCount = 0;

            element1.PropertyChanged += (sender, e) => propertyChangedCount++;
            element2.PropertyChanged += (sender, e) => propertyChangedCount++;
            element3.PropertyChanged += (sender, e) => propertyChangedCount++;
            element4.PropertyChanged += (sender, e) => propertyChangedCount++;

            Assert.AreEqual(1, element1.GetValue(ElementA.Value1Property));
            Assert.AreEqual(2, element2.GetValue(ElementA.Value1Property));
            Assert.AreEqual(3, element3.GetValue(ElementA.Value1Property));
            Assert.AreEqual(4, element4.GetValue(ElementA.Value1Property));

            Assert.AreEqual(1, element1.GetValue(ElementA.Value2Property));
            Assert.AreEqual(2, element2.GetValue(ElementA.Value2Property));
            Assert.AreEqual(3, element3.GetValue(ElementA.Value2Property));
            Assert.AreEqual(4, element4.GetValue(ElementA.Value2Property));

            element1.SetValue(ElementA.Value1Property, 1);
            element2.SetValue(ElementA.Value1Property, 2);
            element3.SetValue(ElementA.Value1Property, 3);
            element4.SetValue(ElementA.Value1Property, 4);

            Assert.AreEqual(0, propertyChangedCount);

            element1.SetValue(ElementA.Value1Property, 100);

            Assert.AreEqual(1, propertyChangedCount);

            element1.SetValue(ElementA.Value2Property, 1);
            element2.SetValue(ElementA.Value2Property, 2);
            element3.SetValue(ElementA.Value2Property, 3);
            element4.SetValue(ElementA.Value2Property, 4);

            Assert.AreEqual(1, propertyChangedCount);

            element1.SetValue(ElementA.Value2Property, 100);

            Assert.AreEqual(2, propertyChangedCount);
        }
Пример #5
0
        public void AttachedOverrideMetadataCallbackTest()
        {
            ElementA element1 = new ElementA();
            ElementB element2 = new ElementB();
            ElementC element3 = new ElementC();
            ElementD element4 = new ElementD();

            int changeIndex         = 1;
            int value2AChangedIndex = 0;
            int value2BChangedIndex = 0;
            int value2CChangedIndex = 0;
            int value2DChangedIndex = 0;

            ElementA.Value2ChangedA += (sender, e) => value2AChangedIndex = changeIndex++;
            ElementB.Value2ChangedB += (sender, e) => value2BChangedIndex = changeIndex++;
            ElementC.Value2ChangedC += (sender, e) => value2CChangedIndex = changeIndex++;
            ElementD.Value2ChangedD += (sender, e) => value2DChangedIndex = changeIndex++;

            element1.SetValue(ElementA.Value2Property, 100);

            Assert.AreEqual(1, value2AChangedIndex);
            Assert.AreEqual(0, value2BChangedIndex);
            Assert.AreEqual(0, value2CChangedIndex);
            Assert.AreEqual(0, value2DChangedIndex);

            element2.SetValue(ElementA.Value2Property, 100);

            Assert.AreEqual(2, value2AChangedIndex);
            Assert.AreEqual(3, value2BChangedIndex);
            Assert.AreEqual(0, value2CChangedIndex);
            Assert.AreEqual(0, value2DChangedIndex);

            element3.SetValue(ElementA.Value2Property, 100);

            Assert.AreEqual(4, value2AChangedIndex);
            Assert.AreEqual(5, value2BChangedIndex);
            Assert.AreEqual(6, value2CChangedIndex);
            Assert.AreEqual(0, value2DChangedIndex);

            element4.SetValue(ElementA.Value2Property, 100);

            Assert.AreEqual(7, value2AChangedIndex);
            Assert.AreEqual(5, value2BChangedIndex);
            Assert.AreEqual(6, value2CChangedIndex);
            Assert.AreEqual(8, value2DChangedIndex);
        }
Пример #6
0
 public void SetSelectedElement(ElementC element)
 {
     pElement = element;
     btn_new_class.Enabled = true;
 }
Пример #7
0
        static void Main(string[] args)
        {
            try
            {
                var ctx = new ElementiContext();

                _elementPService = new ElementPService(ctx);
                _pretragaService = new PretragaService(ctx);
                _elementCService = new ElementCService(ctx);

                Random rnd = new Random();

                int n = 0;
                int k = 0;
                int p = 0;

                int brojPretraga = 0;

                Console.WriteLine("Unesite zeljeni broj elemenata tipa ElementP.");
                n = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Unesite zeljeni broj elemenata tipa ElementC.");
                k = Convert.ToInt32(Console.ReadLine());

                for (int i = 0; i < n; i++)
                {
                    string   idenTifikacioniKod = String.Format("elementp_{0}", i);
                    ElementP elP = new ElementP()
                    {
                        IdentifikacioniKod = idenTifikacioniKod, RedniBroj = i
                    };

                    for (int j = 0; j < k; j++)
                    {
                        char grupa    = (char)rnd.Next(97, 122);
                        int  vrednost = rnd.Next(1, 9);

                        ElementC elC = new ElementC()
                        {
                            Grupa = grupa, Vrednost = vrednost
                        };
                        elP.Elementi.Add(elC);
                    }

                    _elementPService.KreirajElementP(elP);
                }

                Console.WriteLine("Unesite zeljeni broj pretraga: ");
                brojPretraga = Convert.ToInt32(Console.ReadLine());

                for (int i = 0; i < brojPretraga; i++)
                {
                    Console.WriteLine("Unesite zeljeni prag za koji će se vršiti pretraga Elemenata P  po sumi njihovih članova ElementC");
                    p = Convert.ToInt32(Console.ReadLine());

                    List <DataLayer.Models.ElementP> elementiP = _elementPService.VratiSvePSaSumomCVecomOd(p);

                    Pretraga pret = new Pretraga()
                    {
                        VremePretrage = DateTime.Now
                    };
                    foreach (var el in elementiP)
                    {
                        pret.PronadjeniElementi.Add(el);
                    }

                    _pretragaService.KreirajElementP(pret);
                }

                ctx.Dispose();
            }
            catch (Exception e)
            {
            }
        }
Пример #8
0
 public void KreirajElementC(ElementC element)
 {
     _context.ElementiC.Add(element);
     _context.SaveChanges();
 }
Пример #9
0
 public void SetSelectedElement(ElementC element)
 {
     pElement = element;
     btn_new_class.Enabled = true;
 }