public async void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("DONE");
            string         ip    = context.Request["ip"];
            string         nazwa = context.Request["name"];
            DB2DataContext db    = new
                                   DB2DataContext();



            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri($"http://{ip}");
            HttpResponseMessage response = await client.GetAsync("/status");

            RootObject rt = new RootObject();

            rt = await response.Content.ReadAsAsync <RootObject>();

            string str = await response.Content.ReadAsStringAsync();

            shelly s = new shelly();

            s.datetime_ev = DateTime.Now;
            s.nazwa       = nazwa;
            s.hum         = (int)rt.hum.value;
            s.tC          = (int)rt.tmp.tC;
            s.tF          = (int)rt.tmp.tF;
            s.bat_lvl     = (int)rt.bat.value;

            db.shellies.InsertOnSubmit(s);
            db.SubmitChanges();
        }
        public void Wyczysc_zlecenie_z_telewizora(int nr_zlecenia)
        {
            try
            {
                string test = SendToTCPListener("192.168.7.23", 10005, nr_zlecenia.ToString());
                test = SendToTCPListener("192.168.7.24", 10005, nr_zlecenia.ToString());



                test = SendToTCPListener("192.168.7.25", 10005, nr_zlecenia.ToString());

                DB2DataContext db        = new DB2DataContext();
                var            zl_do_akt = from c in db.IPO_ZDAWKA_PW where c.Nr_zlecenia_IPO == nr_zlecenia select c;
                foreach (var z in zl_do_akt)
                {
                    z.do_kontroli = -1;
                    db.SubmitChanges();
                }



                Service1 srv = new Service1();
                //srv.SendAlert("*****@*****.**", "TELEWIZOR - zlec IPO " + nr_zlecenia.ToString(), "skasowano zlecenie z telewizora");
            }
            catch
            {
            }
        }
        public List <IPO_ZLECENIA> GAL_dane_zlecenia(int id_zlec)
        {
            DB2DataContext db = new DB2DataContext();


            return(db.IPO_ZLECENIA.Where(x => x.ipo_nr_zlec == id_zlec).ToList());
        }
Exemple #4
0
        public async void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
            string ip    = context.Request["ip"];
            string nazwa = context.Request["name"];

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri($"http://{ip}");
            string get_string = await client.GetStringAsync("/json");

            get_string = get_string.Replace("Free RAM", "FreeRAM").Replace("nan", "0").Replace(".00", "");;


            RootObject ro = JsonConvert.DeserializeObject <RootObject>(get_string);

            ip = "";


            DB2DataContext db = new
                                DB2DataContext();

            shelly s = new shelly();

            s.datetime_ev = DateTime.Now;
            s.nazwa       = nazwa;
            s.hum         = (int)ro.Sensors[0].Humidity;
            s.tC          = (int)ro.Sensors[0].Temperature;
            s.tF          = 0;
            s.bat_lvl     = 0;

            db.shellies.InsertOnSubmit(s);
            db.SubmitChanges();
        }
        public void Wyczysc_zlecenia_na_telewizorze()
        {
            DB2DataContext db = new DB2DataContext();

            var lista = (from c in db.IPO_ZDAWKA_PW
                         where c.HALA_PROD == "[GA]" & c.RW_PW == "RW" && c.do_kontroli != -1
                         select c.Nr_zlecenia_IPO).Distinct().ToList();

            foreach (var zl in lista)
            {
                Wyczysc_zlecenie_z_telewizora(zl.Value);
            }
        }
Exemple #6
0
        public void Log_operation(int order_id, int id_oper, int ilosc, string komentarz, string operacja, string opis_operacji)
        {
            var db = new DB2DataContext();
            IPO_LOG_OPERACJI_ZEWN log = new IPO_LOG_OPERACJI_ZEWN();

            log.Data_zdarzenia = DateTime.Now;
            log.id_operacji    = id_oper;
            log.Ilosc          = ilosc;
            log.Komentarz      = komentarz;
            log.Nr_zlecenia    = order_id;
            log.Operacja       = operacja;
            log.Opis_operacji  = opis_operacji;
            db.IPO_LOG_OPERACJI_ZEWNs.InsertOnSubmit(log);
            db.SubmitChanges();
        }
        public string SendItemsToOVS()
        {
            DB2DataContext  db    = new DB2DataContext();
            var             oitem = (from c in db.STAN_OVs select c).ToList();
            List <OVS.item> list  = new List <item>();

            foreach (var i in oitem)
            {
                OVS.item it = new item();
                it.litm = i.PJLITM.Trim();
                it.qty  = (int)i.ILOSC025;
                list.Add(it);
            }

            var t = SendData(list, DateTime.Now);

            return(oitem.Count().ToString() + ";" + t.Result.ToString());
        }
Exemple #8
0
        public async void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                string     ip     = context.Request["ip"];
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri($"http://{ip}");
                HttpResponseMessage response = await client.GetAsync("/status.xml");

                string str = await response.Content.ReadAsStringAsync();

                var reader = new StringReader(str.Replace("iso-8859-1", "utf-8"));

                XmlSerializer  serializer = new XmlSerializer(typeof(Response));
                Response       resp       = (Response)serializer.Deserialize(reader);
                DB2DataContext db         = new DB2DataContext();
                shelly         temp       = new shelly();
                temp.bat_lvl = 100;
                temp.tC      = (int)resp.Temp1;
                temp.tF      = 0;
                if (ip == "192.168.1.2")
                {
                    temp.nazwa = "Wysyłane - kotłownia";
                }
                else
                {
                    temp.nazwa = "?";
                }
                temp.datetime_ev = DateTime.Now;
                temp.hum         = -1;
                db.shellies.InsertOnSubmit(temp);
                db.SubmitChanges();
            }
            catch
            {
            }

            context.Response.Write("OK");
        }
Exemple #9
0
        public static byte[] GenPDFFile_A4_new(metka m_)
        {
            PdfDocument document = new PdfDocument();

            Zen.Barcode.Code128BarcodeDraw bc  = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
            Zen.Barcode.Code128BarcodeDraw bc1 = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
            DB2DataContext db2 = new DB2DataContext();

            bool tylko_poler_wyk = false;// m_.komentarz.Contains("!!");


            int ilosc = 0;

            for (int i = 0; i < m_.il_stron; i++)
            {
                PdfPage page = document.AddPage();
                page.Size = PdfSharp.PageSize.A4;
                // Get an XGraphics object for drawing
                XGraphics gfx   = XGraphics.FromPdfPage(page);
                XFont     font  = new XFont("Verdana", 15, XFontStyle.Bold);
                XFont     font1 = new XFont("Verdana", 10, XFontStyle.Regular);
                XFont     font2 = new XFont("Verdana", 8, XFontStyle.Regular);
                XFont     font3 = new XFont("Verdana", 8, XFontStyle.Italic);

                // kod kreskowy
                Image  im  = bc.Draw(m_.nr_zlec_szlif + "_" + (i + 1).ToString(), 35, 2);
                XImage xim = XImage.FromGdiPlusImage(im);
                gfx.DrawImage(xim, new Point(10, 10));
                gfx.DrawString("Utw.: " + DateTime.Now.ToString(), font1, XBrushes.Black,
                               new XRect(210, 10, 300, 22),
                               XStringFormats.TopLeft);



                gfx.DrawString(m_.nazwa, font, XBrushes.Black,
                               new XRect(5, 40, 400, 22),
                               XStringFormats.Center);



                gfx.DrawString("Kod części: " + m_.kod_zlecenia + " (partia nr " + (i + 1).ToString() + " z " + m_.il_stron.ToString() + ")", font1, XBrushes.Black,
                               new XRect(5, 65, 300, 22),
                               XStringFormats.TopLeft);
                gfx.DrawString("Ilość szt: " + m_.ilosc_szt[i].ToString(), font1, XBrushes.Black,
                               new XRect(240, 65, 300, 22),
                               XStringFormats.TopLeft);
                ilosc = (int)m_.ilosc_szt[0];
                gfx.DrawString("Nr rysunku: " + m_.nr_rysunku, font1, XBrushes.Black,
                               new XRect(5, 80, 300, 22),
                               XStringFormats.TopLeft);



                //gfx.DrawString("Kod po wykonczeniu: " + m_.kod_po_wykonczeniu, font1, XBrushes.Black,
                //  new XRect(5, 95, 300, 22),
                // XStringFormats.TopLeft);
                gfx.DrawString("Kolor: " + m_.kolor, font1, XBrushes.Black,
                               new XRect(240, 75, 300, 22),
                               XStringFormats.TopLeft);
                gfx.DrawString("Nr_zlec: " + m_.nr_zlec_szlif, font1, XBrushes.Black,
                               new XRect(240, 95, 300, 22),
                               XStringFormats.TopLeft);

                var rw = from c in db2.IPO_ZDAWKA_PW
                         where c.RW_PW == "RW" && c.Nr_zlecenia_IPO == m_.nr_zlec_szlif
                         group c by new { c.Magazyn_IPO, c.Nr_indeksu } into fgr

                    select new { Magazyn_IPO = fgr.Key.Magazyn_IPO, Nr_indeksu = fgr.Key.Nr_indeksu, Ilosc = fgr.Sum(g => g.Ilosc) };
                int poz = 105;
                foreach (var d in rw.Where(c => c.Ilosc != 0))
                {
                    gfx.DrawString(d.Magazyn_IPO + " " + d.Nr_indeksu + " :" + d.Ilosc.ToString(), font1, XBrushes.Black,
                                   new XRect(240, poz, 300, 22),
                                   XStringFormats.TopLeft);



                    poz = poz + 10;
                }



                double st = 170;
                szlif_operacjeDataContext db1 = new szlif_operacjeDataContext();
                var oper = from c in db1.Marszruty_szlifiernia_s
                           where c.Id_wyrobu == m_.kod_zlecenia
                           orderby c.Nr_kol_operacji ascending
                           select new { c.Id_operacji, OPERACJA = c.Id_operacji + " " + c.Nazwa_operacji, c.IloscSztZm, c.NormaZatwierdzona, c.Nazwa_operacji, c.Nr_kol_operacji };

                if (tylko_poler_wyk)
                {
                    oper = oper.Where(x => x.Nazwa_operacji == "Polerowanie wykańczające");
                }
                else
                {
                    oper = oper.Where(x => x.Nazwa_operacji != "Polerowanie wykańczające");
                }

                foreach (var o in oper)
                {
                    string wst = "";

                    if (o.NormaZatwierdzona.Contains("*"))
                    {
                        wst = "*";
                    }
                    if (!o.Nr_kol_operacji.Value.ToString().EndsWith("0"))
                    {
                        wst = "A" + wst;                                                     //operacja nie kończy się na zero - to alternatywa!!!
                    }
                    //jeżeli wst zawiera A to drukuj pochyłą czcionką
                    if (wst.Contains("A"))
                    {
                        gfx.DrawString(wst + o.OPERACJA, font3, XBrushes.Black,
                                       new XRect(240, st, 300, 22),
                                       XStringFormats.TopLeft);
                    }
                    //lub normalną jeżeli nie alternatywna
                    else
                    {
                        gfx.DrawString(wst + o.OPERACJA, font2, XBrushes.Black,
                                       new XRect(240, st, 300, 22),
                                       XStringFormats.TopLeft);
                    }


                    im  = bc1.Draw("OPER_" + o.Id_operacji.ToString(), 15, 2);
                    xim = XImage.FromGdiPlusImage(im);
                    gfx.DrawImage(xim, new Point(230, (int)(st + 15)));
                    gfx.DrawString(((decimal)((decimal)m_.ilosc_szt[i] * 480m) / (decimal)o.IloscSztZm).ToString("####.#") + "/" + o.IloscSztZm.ToString(), font1, XBrushes.Black,
                                   new XRect(240, st + 26, 300, 22),
                                   XStringFormats.TopLeft);
                    st = st + 55;
                }


                MemoryStream ms = new MemoryStream();
                m_.rysunek.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                Image  n_rys    = System.Drawing.Image.FromStream(ms);
                double r_width  = 150;
                double ratio    = r_width / n_rys.Width;
                double r_height = (double)n_rys.Height * ratio;
                XImage rys      = XImage.FromGdiPlusImage(n_rys);

                gfx.DrawImage(rys, 10, 130, r_width, r_height);
                Image  im1  = bc.Draw(m_.kod_zlecenia, 20, 3);
                XImage xim1 = XImage.FromGdiPlusImage(im1);
                gfx.DrawImage(xim1, new Point(15, 150 + (int)r_height));
            }



            // Save the document...
            //string filename = "HelloWorld.pdf";
            MemoryStream str = new MemoryStream();

            document.Save(str, true);
            Metki_PDF m_pdf = new Metki_PDF();

            m_pdf.Nr_zlecenia = m_.nr_zlec_szlif.ToString();
            m_pdf.Data_utw    = DateTime.Now;
            m_pdf.PDF         = str.ToArray();
            m_pdf.Ilosc       = ilosc;
            baza_metekDataContext db = new baza_metekDataContext();

            db.Metki_PDFs.InsertOnSubmit(m_pdf);
            db.SubmitChanges();


            return(str.ToArray());
        }