/[H9]/trunk/FlisServer/FlisServerDlg.cpp
ViewVC logotype

Annotation of /trunk/FlisServer/FlisServerDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 130 - (hide annotations) (download)
Mon Dec 3 09:22:26 2007 UTC (16 years, 5 months ago) by kevin
File size: 17987 byte(s)
updated flisserver software - rdy for sms indput
1 kevin 70 // FlisServerDlg.cpp : implementation file
2     //
3    
4     #include "stdafx.h"
5     #include "FlisServer.h"
6     #include "FlisServerDlg.h"
7     #include <vector>
8 kevin 121 #include ".\flisserverdlg.h"
9 kevin 70
10     #ifdef _DEBUG
11     #define new DEBUG_NEW
12     #endif
13    
14    
15     // CAboutDlg dialog used for App About
16    
17     class CAboutDlg : public CDialog
18     {
19     public:
20     CAboutDlg();
21    
22     // Dialog Data
23     enum { IDD = IDD_ABOUTBOX };
24    
25     protected:
26     virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
27    
28     // Implementation
29     protected:
30     DECLARE_MESSAGE_MAP()
31     };
32    
33     CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
34     {
35     }
36    
37     void CAboutDlg::DoDataExchange(CDataExchange* pDX)
38     {
39     CDialog::DoDataExchange(pDX);
40     }
41    
42     BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
43     END_MESSAGE_MAP()
44    
45    
46     // CFlisServerDlg dialog
47    
48    
49    
50     CFlisServerDlg::CFlisServerDlg(CWnd* pParent /*=NULL*/)
51     : CDialog(CFlisServerDlg::IDD, pParent)
52     {
53     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
54     }
55    
56     void CFlisServerDlg::DoDataExchange(CDataExchange* pDX)
57     {
58     CDialog::DoDataExchange(pDX);
59     DDX_Control(pDX, IDC_Textwindow, m_Textwindow);
60     }
61    
62     BEGIN_MESSAGE_MAP(CFlisServerDlg, CDialog)
63     ON_WM_SYSCOMMAND()
64     ON_WM_PAINT()
65     ON_WM_QUERYDRAGICON()
66 kevin 110 ON_MESSAGE(UWM_MYMESSAGE, OnShowString)
67 kevin 70 //}}AFX_MSG_MAP
68 kevin 103 ON_BN_CLICKED(IDCLOSE, OnBnClickedClose)
69 kevin 105 ON_BN_CLICKED(IDC_GSMPIN, OnBnClickedGsmpin)
70 kevin 121 ON_BN_CLICKED(IDC_Start, OnBnClickedStart)
71 kevin 70 END_MESSAGE_MAP()
72    
73    
74     // CFlisServerDlg message handlers
75    
76     BOOL CFlisServerDlg::OnInitDialog()
77     {
78     CDialog::OnInitDialog();
79    
80     // Add "About..." menu item to system menu.
81    
82     // IDM_ABOUTBOX must be in the system command range.
83     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
84     ASSERT(IDM_ABOUTBOX < 0xF000);
85    
86     CMenu* pSysMenu = GetSystemMenu(FALSE);
87     if (pSysMenu != NULL)
88     {
89     CString strAboutMenu;
90     strAboutMenu.LoadString(IDS_ABOUTBOX);
91     if (!strAboutMenu.IsEmpty())
92     {
93     pSysMenu->AppendMenu(MF_SEPARATOR);
94     pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
95     }
96     }
97    
98     // Set the icon for this dialog. The framework does this automatically
99     // when the application's main window is not a dialog
100     SetIcon(m_hIcon, TRUE); // Set big icon
101     SetIcon(m_hIcon, FALSE); // Set small icon
102    
103     // TODO: Add extra initialization here
104     StartSerial();
105 kevin 81 DBConnect();
106 kevin 113 ResetSms = 0;
107 kevin 70
108     return TRUE; // return TRUE unless you set the focus to a control
109     }
110    
111     void CFlisServerDlg::OnSysCommand(UINT nID, LPARAM lParam)
112     {
113     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
114     {
115     CAboutDlg dlgAbout;
116     dlgAbout.DoModal();
117     }
118     else
119     {
120     CDialog::OnSysCommand(nID, lParam);
121     }
122     }
123    
124     // If you add a minimize button to your dialog, you will need the code below
125     // to draw the icon. For MFC applications using the document/view model,
126     // this is automatically done for you by the framework.
127    
128     void CFlisServerDlg::OnPaint()
129     {
130     if (IsIconic())
131     {
132     CPaintDC dc(this); // device context for painting
133    
134     SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
135    
136     // Center icon in client rectangle
137     int cxIcon = GetSystemMetrics(SM_CXICON);
138     int cyIcon = GetSystemMetrics(SM_CYICON);
139     CRect rect;
140     GetClientRect(&rect);
141     int x = (rect.Width() - cxIcon + 1) / 2;
142     int y = (rect.Height() - cyIcon + 1) / 2;
143    
144     // Draw the icon
145     dc.DrawIcon(x, y, m_hIcon);
146     }
147     else
148     {
149     CDialog::OnPaint();
150     }
151     }
152    
153     // The system calls this function to obtain the cursor to display while the user drags
154     // the minimized window.
155     HCURSOR CFlisServerDlg::OnQueryDragIcon()
156     {
157     return static_cast<HCURSOR>(m_hIcon);
158     }
159     int CFlisServerDlg::StartSerial(void)
160     {
161     int Baud;
162     CString SerialPort = "COM3";
163    
164     Baud = 1200;
165     if( Serial.isOpen() ){
166     Serial.close();
167     Serial.open( SerialPort, Baud );
168     }
169     else {
170     Serial.open( SerialPort, Baud );
171     }
172    
173    
174     return 0;
175     }
176     std::vector<unsigned char> CFlisServerDlg::readFrame()
177     {
178     std::vector<unsigned char> buf;
179     while(Serial.getComstat().cbInQue > 0)
180     {
181     unsigned char data = Serial.readByte();
182    
183     buf.push_back(data);
184     }
185     return buf;
186     }
187    
188     void CFlisServerDlg::writeFrame(std::vector<unsigned char> data)
189     {
190     for (int i=0; i<data.size(); i++)
191     {
192     Serial.writeByte( data[i] );
193     Sleep(5);
194     }
195     Serial.writeByte(0x0D);
196     Sleep(100);
197    
198     }
199 kevin 110 void CFlisServerDlg::SetPin()
200 kevin 70 {
201 kevin 81 CString tekst;
202 kevin 70 std::vector<unsigned char> data;
203     data.push_back('a');
204     data.push_back('t');
205     data.push_back('+');
206     data.push_back('c');
207     data.push_back('p');
208     data.push_back('i');
209     data.push_back('n');
210     data.push_back('=');
211     data.push_back('2');
212     data.push_back('5');
213     data.push_back('9');
214     data.push_back('5');
215    
216     writeFrame(data);
217 kevin 113 /* Sleep(750);
218 kevin 70 if(Serial.getComstat().cbInQue > 0)
219     {
220     std::vector<unsigned char> answer = readFrame();
221     Sleep(50);
222     char array1[25];
223     int i;
224     for (int i=0; i<answer.size(); i++)
225     {
226     array1[i] = answer[i];
227     }
228    
229     for (int i=0; i<answer.size(); i++)
230     {
231     if ((array1[i] != 0x0A) && (array1[i] != 0x0D))
232     {
233     tekst.AppendChar(array1[i]);
234     }
235     }
236 kevin 81 m_Textwindow.SetWindowText(tekst);
237 kevin 70 }
238 kevin 113 */
239 kevin 70 }
240     void CFlisServerDlg::SendSmsData(std::vector<unsigned char> data)
241 kevin 103 {
242    
243 kevin 70 for (int i=0; i<data.size(); i++)
244     {
245     Serial.writeByte( data[i] );
246     Sleep(5);
247     }
248     Serial.writeByte(0x1A);
249 kevin 105 Sleep(3000);
250     if(Serial.getComstat().cbInQue > 0)
251     {
252     CString tekst;
253     std::vector<unsigned char> answer = readFrame();
254     Sleep(50);
255 kevin 130 char array1[150];
256 kevin 105 int i;
257     for (int i=0; i<answer.size(); i++)
258     {
259     array1[i] = answer[i];
260     }
261    
262     for (int i=0; i<answer.size(); i++)
263     {
264     if ((array1[i] != 0x0A) && (array1[i] != 0x0D))
265     {
266     tekst.AppendChar(array1[i]);
267     }
268     }
269     m_Textwindow.SetWindowText(tekst);
270     }
271 kevin 70
272     }
273     void CFlisServerDlg::SendSmsHead(std::vector<unsigned char> data)
274     {
275 kevin 103 vector<unsigned char> atcommand;
276     atcommand.push_back('a');
277     atcommand.push_back('t');
278     atcommand.push_back('+');
279     atcommand.push_back('c');
280     atcommand.push_back('m');
281     atcommand.push_back('g');
282     atcommand.push_back('s');
283     atcommand.push_back('=');
284     atcommand.push_back('"');
285     int s = (atcommand.size() -1 );
286    
287     for (int i=0; i<(atcommand.size()); i++)
288     {
289     Serial.writeByte( atcommand[i] );
290     Sleep(5);
291     }
292    
293 kevin 70 for (int i=0; i<data.size(); i++)
294     {
295     Serial.writeByte( data[i] );
296     Sleep(5);
297     }
298 kevin 103 Serial.writeByte(atcommand[s]);
299 kevin 70 Serial.writeByte(0x0D);
300 kevin 103 Sleep(250);
301 kevin 70 }
302 kevin 81 void CFlisServerDlg::DBConnect()
303 kevin 70 {
304     CString dsn;
305 kevin 130 //dsn.Format("ODBC;Description=asd;DRIVER=PostgreSQL ANSI;SERVER=t-hoerup.dk; uid=serrenab;password=furnacemonitor;database=flisfyr;sslmode=prefer"); //Torben
306     dsn.Format("ODBC;Description=asd;DRIVER=PostgreSQL ANSI;SERVER=192.168.134.132; uid=serrenab;password=furnacemonitor;database=flisfyr;sslmode=prefer"); //skole server
307 kevin 103 db.OpenEx(dsn, CDatabase::noOdbcDialog);
308 kevin 81 }
309 kevin 103 vector<Commands> CFlisServerDlg::DBRead(void)
310 kevin 81 {
311 kevin 103 vector<Commands> buffer;
312 kevin 81
313 kevin 103 CString SQL, IDnr, CommandID, InstallationsID;
314     SQL = "select id,date_trunc('second', created) as created,executed,commandid,installationid from command WHERE executed IS NULL;";
315     CRecordset rs(&db);
316     rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL);
317     if (rs.GetRecordCount()>0)
318     {
319     rs.MoveFirst();
320     while(!rs.IsEOF())
321     {
322 kevin 130 Commands Mycom;
323     rs.GetFieldValue((short)0, IDnr);
324     rs.GetFieldValue(3, CommandID);
325     rs.GetFieldValue(4, InstallationsID);
326    
327     Mycom.IDnr = IDnr;
328     Mycom.CommandID = CommandID;
329     Mycom.InstallationsID = InstallationsID;
330 kevin 103
331 kevin 130 buffer.push_back(Mycom);
332     rs.MoveNext();
333 kevin 103 }
334     }
335     rs.Close();
336     return buffer;
337 kevin 81 }
338     void CFlisServerDlg::ReadSms()
339     {
340     CString tekst, oldtekst;
341     Sleep(950);
342     if(Serial.getComstat().cbInQue > 0)
343     {
344     std::vector<unsigned char> answer = readFrame();
345     Sleep(50);
346     char array1[250];
347     int i;
348     for (int i=0; i<answer.size(); i++)
349     {
350     array1[i] = answer[i];
351     }
352    
353     for (int i=0; i<answer.size(); i++)
354     {
355     if ((array1[i] != 0x0A) && (array1[i] != 0x0D))
356     {
357     tekst.AppendChar(array1[i]);
358     }
359     }
360    
361     m_Textwindow.GetWindowText(oldtekst);
362     oldtekst.Append("\r\n");
363     oldtekst.Append(tekst);
364     m_Textwindow.SetWindowText(oldtekst);
365     SmsSplit(tekst);
366     }
367     }
368     void CFlisServerDlg::SmsSplit(CString data)
369     {
370     CString FyrData, TlfNr, SmsCount, Temper, Flamme, Flis, FremFejl, PowerFail, oldtekst;
371     char CharData[150];
372     strcpy(CharData,data);
373    
374 kevin 113 int s=24;
375 kevin 81 for (int i=0; i<=7; i++)
376     {
377     TlfNr.AppendChar(CharData[s]);
378     s++;
379     }
380    
381 kevin 113 for (int s=57; s<=(data.GetLength()-3); s++)
382 kevin 81 {
383     FyrData.AppendChar(CharData[s]);
384     }
385     FyrData.Append(":");
386    
387     SmsCount = Splitter(FyrData);
388     Temper = Splitter(FyrData);
389     Flamme = Splitter(FyrData);
390     Flis = Splitter(FyrData);
391     FremFejl = Splitter(FyrData);
392     PowerFail = Splitter(FyrData);
393     ///////////////////////////////////////////////////////////////////////////////////////////////////////
394 kevin 121 ///////////////////// Her skal sendes data til databasen ////NÅR HEDIN KAN SENDE SMS///////////////////
395 kevin 81 m_Textwindow.GetWindowText(oldtekst);
396     oldtekst.Append("\r\n");
397     oldtekst.Append("På næste linie kommer SmsCount. \r\n");
398     oldtekst.Append(SmsCount);
399     oldtekst.Append("\r\n");
400     oldtekst.Append("På næste linie kommer Temper. \r\n");
401     oldtekst.Append(Temper);
402     oldtekst.Append("\r\n");
403     oldtekst.Append("På næste linie kommer Flamme. \r\n");
404     oldtekst.Append(Flamme);
405     oldtekst.Append("\r\n");
406     oldtekst.Append("På næste linie kommer Flis. \r\n");
407     oldtekst.Append(Flis);
408     oldtekst.Append("\r\n");
409     oldtekst.Append("På næste linie kommer FremFejl. \r\n");
410     oldtekst.Append(FremFejl);
411     oldtekst.Append("\r\n");
412     oldtekst.Append("På næste linie kommer PowerFail. \r\n");
413     oldtekst.Append(PowerFail);
414 kevin 110 oldtekst.Append("\r\n");
415     oldtekst.Append("På næste linie kommer TlfNR. \r\n");
416     oldtekst.Append(TlfNr);
417 kevin 81 m_Textwindow.SetWindowText(oldtekst);
418     ///////////////////////////////////////////////////////////////////////////////////////////////////////
419     ///////////////////// Her skal sendes data til databasen //////////////////////////////////////////////
420     }
421     CString CFlisServerDlg::Splitter(CString& fyrdata)
422     {
423     CString Output;
424    
425     int pos = fyrdata.Find(':',0);
426     if (pos != -1)
427     {
428     Output = fyrdata.Left(pos);
429     fyrdata = fyrdata.Right( fyrdata.GetLength() - pos -1);
430     }
431     return Output;
432 kevin 103 }
433     void CFlisServerDlg::OnBnClickedClose()
434     {
435     // TODO: Add your control notification handler code here
436 kevin 113 continueThread = 0;
437     DeleteSms(); //<--- crasher, men gider ikke bruge flere af mine penge på at teste det med sms'er, hele close laver crash, bare ikke når jeg stepper. :S
438    
439     Sleep(500);
440 kevin 103 if( Serial.isOpen() )
441     {
442     Serial.close();
443     }
444    
445     if(db.IsOpen())
446     {
447     db.Close();
448     }
449 kevin 113
450 kevin 103 OnOK();
451 kevin 113
452 kevin 103 }
453 kevin 105
454     void CFlisServerDlg::OnBnClickedGsmpin()
455     {
456     // TODO: Add your control notification handler code here
457     SetPin();
458 kevin 121 Sleep(35000);
459     OnBnClickedStart();
460 kevin 105 }
461 kevin 110 void CFlisServerDlg::DeleteSms()
462     {
463     vector<unsigned char> atcommand;
464     atcommand.push_back('a');
465     atcommand.push_back('t');
466     atcommand.push_back('+');
467     atcommand.push_back('c');
468     atcommand.push_back('m');
469     atcommand.push_back('g');
470     atcommand.push_back('d');
471     atcommand.push_back('=');
472     atcommand.push_back('1');
473     atcommand.push_back(',');
474     atcommand.push_back('3');
475    
476     writeFrame(atcommand);
477     Sleep(500);
478     }
479     LRESULT CFlisServerDlg::OnShowString(WPARAM wParam, LPARAM lParam)
480     {
481     CString *s = (CString*) lParam;
482     GetDlgItem(IDC_Textwindow)->SetWindowText(*s);
483    
484     delete s;
485     return 0;
486    
487     }UINT threadWrapper(LPVOID thread)
488     {
489     CFlisServerDlg *t = (CFlisServerDlg*) thread;
490     t->runthread();
491     return 0;
492     }
493    
494     void CFlisServerDlg::startthread()
495     {
496     AfxBeginThread(threadWrapper, (LPVOID) this);
497     }
498    
499     void CFlisServerDlg::runthread()
500     {
501 kevin 113 while (continueThread != 0)
502 kevin 110 {
503     Reader();
504     }
505     }
506     void CFlisServerDlg::Reader()
507     {
508 kevin 113 if(Serial.getComstat().cbInQue > 0)
509 kevin 110 {
510 kevin 113 Sleep(250);
511 kevin 110 std::vector<unsigned char> answer = readFrame();
512     Sleep(500);
513     CString tekst, oldtekst;
514     int lol;
515     char array1[250];
516     int i;
517     for (int i=0; i<answer.size(); i++)
518     {
519     array1[i] = answer[i];
520     }
521    
522     for (int i=0; i<answer.size(); i++)
523     {
524     if ((array1[i] != 0x0A) && (array1[i] != 0x0D))
525     {
526     tekst.AppendChar(array1[i]);
527     }
528     }
529     tekst.Append(":");
530    
531     CString command;
532     bool plus;
533     int pos = tekst.Find('+',0);
534     if (pos != -1)
535     {
536     plus = true;
537     tekst = tekst.Right( tekst.GetLength() - pos -1);
538     pos = tekst.Find(':');
539     command = tekst.Left(pos);
540     tekst = tekst.Right( tekst.GetLength() - pos -1);
541     }
542    
543    
544     if(tekst == "OK")
545     {
546     m_Textwindow.GetWindowText(oldtekst);
547     oldtekst.Append("\r\n");
548     oldtekst.Append("OK tekst modtaget");
549     m_Textwindow.SetWindowText(oldtekst);
550     }
551     else if (tekst == "error")
552     {
553     m_Textwindow.GetWindowText(oldtekst);
554     oldtekst.Append("\r\n");
555     oldtekst.Append("error tekst");
556     oldtekst.Append(tekst);
557     m_Textwindow.SetWindowText(oldtekst);
558     }
559     else if (plus = true)
560     {
561     if (command = "cmti")
562     {
563 kevin 113 CString smscount, oldteskst;
564 kevin 110 int pos = tekst.Find(',',0);
565     if (pos != -1)
566     {
567     smscount = tekst.Right( tekst.GetLength() - pos -1);
568     smscount.Remove(':');
569     ResetSms++;
570     }
571     ////////////////Read sms ting//////////////////
572     std::vector<unsigned char> data;
573     data.push_back('a');
574     data.push_back('t');
575     data.push_back('+');
576     data.push_back('c');
577     data.push_back('m');
578     data.push_back('g');
579     data.push_back('r');
580     data.push_back('=');
581    
582     for (int i=0; i< smscount.GetLength(); i++)
583     {
584     data.push_back(smscount[i]);
585     }
586 kevin 113 for (int i=0; i<data.size();i++)
587     {
588     oldteskst.AppendChar(data[i]);
589     }
590     m_Textwindow.SetWindowText(oldteskst);
591 kevin 110 writeFrame(data);
592 kevin 113 Sleep(200);
593 kevin 110 ReadSms();
594 kevin 121 ResetSms++;
595 kevin 110
596     }
597 kevin 113 else if(command = "wind")
598     {
599     m_Textwindow.GetWindowText(oldtekst);
600     oldtekst.Append("\r\n");
601     oldtekst.Append("Først lidt tekst på næste linie\r\n");
602     oldtekst.Append(tekst);
603     m_Textwindow.SetWindowText(oldtekst);
604     }
605 kevin 110 }
606 kevin 113 if(ResetSms == 50)
607 kevin 110 {
608     DeleteSms();
609     }
610 kevin 113
611     }
612     if (continueThread = 1)
613     {
614 kevin 110
615 kevin 121 CString testdata, dataframe,testprint, sIDnr, sCommandID, sInstallationsID, sImei;
616 kevin 130 int commandtest = 0;
617     int iAll = 1;
618 kevin 113 std::vector<Commands> data;
619     data = DBRead();
620     for (int i=0; i<data.size(); i++)
621     {
622     testdata.Append(data[i].IDnr);
623     testdata.Append(":");
624     testdata.Append(data[i].CommandID);
625     testdata.Append(":");
626 kevin 130 commandtest = atoi(data[i].CommandID);
627    
628     if(commandtest > 1)
629     {
630 kevin 113 testdata.Append(data[i].InstallationsID);
631     testdata.Append(":");
632 kevin 130 }
633 kevin 113 }
634     sIDnr = Splitter(testdata);
635     sCommandID = Splitter(testdata);
636 kevin 130 sInstallationsID = "0";
637     if (commandtest > 1)
638     {
639 kevin 113 sInstallationsID = Splitter(testdata);
640 kevin 130 iAll = 0;
641     }
642 kevin 113
643     if (sIDnr.GetLength() > 0)
644     {
645     DBReadData(sIDnr,sCommandID,sInstallationsID);
646     }
647     Sleep(500);
648 kevin 110 }
649 kevin 113 }
650     void CFlisServerDlg::DBReadData(CString IDnr,CString CommandID,CString InstallationsID)
651     {
652 kevin 130 CString ServerTlfNr;
653     int i = 0;
654 kevin 121 ServerTlfNr = "29860132";
655 kevin 113
656 kevin 130
657 kevin 113 std::vector<Installation> inst;
658     inst = DBReadPhone(InstallationsID);
659 kevin 130 while (i < inst.size())
660 kevin 113 {
661 kevin 130 CString TlfNr, Imei, updaterate;
662     TlfNr.Empty();
663     Imei.Empty();
664     updaterate.Empty();
665    
666 kevin 113 CString dataen = inst[i].InstPhoneNr;
667     TlfNr.Append(dataen);
668 kevin 121 CString Imeidata = inst[i].Imei;
669     Imei.Append(Imeidata);
670     CString updaterat = inst[i].Updaterate;
671     updaterate.Append(updaterat);
672 kevin 130 i++;
673    
674 kevin 113 vector<unsigned char> tlfnr;
675     for (int i=0; i<TlfNr.GetLength(); i++)
676     {
677     tlfnr.push_back(TlfNr[i]);
678     }
679 kevin 121
680     int calcimei;
681 kevin 130 __int64 buf;
682 kevin 113
683 kevin 121 buf = atof(Imei);
684    
685     calcimei = tversum(buf);
686    
687     Imei.Format("%d",calcimei);
688    
689 kevin 113 SendSmsHead(tlfnr);
690 kevin 130 Sleep(250);
691    
692 kevin 113 vector<unsigned char> smsdata;
693 kevin 121
694     for (int i=0; i<Imei.GetLength(); i++)
695     {
696     smsdata.push_back(Imei[i]);
697     }
698 kevin 113 smsdata.push_back(':');
699 kevin 121 for (int i=0; i<ServerTlfNr.GetLength(); i++)
700     {
701     smsdata.push_back(ServerTlfNr[i]);
702     }
703 kevin 113 smsdata.push_back(':');
704 kevin 121 for (int i=0; i<updaterate.GetLength(); i++)
705     {
706     smsdata.push_back(updaterate[i]);
707     }
708 kevin 113
709     SendSmsData(smsdata);
710 kevin 130 Sleep(500);
711    
712     }
713     CString SQL, Textwindow;
714     SQL.Format("update command set executed=now() where id=%s",IDnr);
715     db.ExecuteSQL(SQL);
716     m_Textwindow.GetWindowText(Textwindow);
717     Textwindow.Append("\r\n");
718     Textwindow.Append("Command executed");
719     m_Textwindow.SetWindowText(Textwindow);
720     Sleep(150);
721 kevin 113
722     }
723     vector<Installation> CFlisServerDlg::DBReadPhone(CString sInstallationsID)
724     {
725     vector<Installation> buffer;
726    
727 kevin 121 CString SQL, phonenr, imei, updaterate;
728 kevin 130 int installernull;
729     Installation Myinst;
730     installernull = atoi(sInstallationsID);
731     if (installernull > 1)
732     {
733     SQL.Format("select installationphonenr, imei, updaterate from installation WHERE id = %s", sInstallationsID);
734     }
735     else if(installernull < 2)
736     {
737     SQL.Format("select installationphonenr, imei, updaterate from installation");
738     }
739 kevin 113 CRecordset rs(&db);
740     rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL);
741     if (rs.GetRecordCount()>0)
742     {
743     rs.MoveFirst();
744     while(!rs.IsEOF())
745     {
746 kevin 130
747     rs.GetFieldValue((short)0,phonenr);
748     rs.GetFieldValue(1,imei);
749     rs.GetFieldValue(2,updaterate);
750 kevin 113
751 kevin 130 Myinst.InstPhoneNr = phonenr;
752     Myinst.Imei = imei;
753     Myinst.Updaterate = updaterate;
754 kevin 113
755 kevin 130 buffer.push_back(Myinst);
756     rs.MoveNext();
757 kevin 113 }
758     }
759     rs.Close();
760     return buffer;
761 kevin 121 }
762 kevin 130 int CFlisServerDlg::tversum(__int64 input)
763 kevin 121 {
764     int sum = 0;
765     while (input > 0)
766     {
767     sum += (input %10);
768     input /= 10;
769     }
770     return sum;
771     }
772     void CFlisServerDlg::OnBnClickedStart()
773     {
774     // TODO: Add your control notification handler code here
775    
776     continueThread = 1;
777    
778     AfxBeginThread(threadWrapper,AfxGetMainWnd());
779     }

  ViewVC Help
Powered by ViewVC 1.1.20