コード例 #1
0
 public void UploadEventByMach(sqlEventByMachRec _eventByMachRec)
 {
     //upload the event by mach record to the AWS / mySQL database
     while (isSendingEventByMach)
     {
         //keep looping until the file is sent
         Application.DoEvents();
     }
     ;
     isSendingEventByMach = true;
     RunAsyncCreateEventByMach(_eventByMachRec).GetAwaiter();
     while (isSendingEventByMach)
     {
         //keep looping until the file is sent
         Application.DoEvents();
     }
     ;
 }
コード例 #2
0
        //for the event by machine
        static async Task RunAsyncCreateEventByMach(sqlEventByMachRec _eventByMachRec)
        {
            //client had to be setup prior to entering here
            try
            {
                HttpResponseMessage response = await client3.PostAsJsonAsync <sqlEventByMachRec>(
                    "api/eventbymach", _eventByMachRec);

                response.EnsureSuccessStatusCode();
                var isCreateSuccessful = response.IsSuccessStatusCode;

                isSendingEventByMach = false;
            }
            catch (Exception e)
            {
                Console.WriteLine("---an error occurred");
                Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
        public void UploadAllEventsByMach()
        {
            // Update port # in the following line.
            client3.BaseAddress = new Uri("https://devnetlogger.herokuapp.com/");
            client3.DefaultRequestHeaders.Accept.Clear();
            client3.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            //refresh the events by mach
            if (LogFiles.Disp_LogMachEvents_table.Count() > 0)
            {
                for (int i = 0; i < LogFiles.Disp_LogMachEvents_table.Count(); i++)
                {
                    sqlEventByMachRec eventByMachRec = new sqlEventByMachRec();
                    //check to see if the record should be added
                    if ((LogFiles.Disp_LogMachEvents_table[i].machNum == "") || (LogFiles.LeftStr(LogFiles.Disp_LogMachEvents_table[i].machNum, 1) == "-") || (LogFiles.LeftStr(LogFiles.Disp_LogMachEvents_table[i].machNum, 1) != "M"))
                    {
                        //do nothing
                    }
                    else
                    {
                        eventByMachRec.machNumStr   = LogFiles.LeftStr(LogFiles.Disp_LogMachEvents_table[i].machNum, 3);
                        eventByMachRec.machNum      = LogFiles.RightStr(eventByMachRec.machNumStr, 2);
                        eventByMachRec.eventStr     = LogFiles.Disp_LogMachEvents_table[i].machNum;
                        eventByMachRec.startTimeStr = LogFiles.Disp_LogMachEvents_table[i].timeStartStr;
                        eventByMachRec.endTimeStr   = LogFiles.Disp_LogMachEvents_table[i].timeStopStr;

                        string tempTimeString = eventByMachRec.startTimeStr;
                        string tempString     = tempTimeString.Substring(0, 4);
                        eventByMachRec.starttime_utc_yr = int.Parse(tempString);
                        tempString = tempTimeString.Substring(5, 2);
                        eventByMachRec.starttime_utc_mon = int.Parse(tempString);
                        tempString = tempTimeString.Substring(8, 2);
                        eventByMachRec.starttime_utc_day = int.Parse(tempString);

                        tempString = tempTimeString.Substring(11, 2);
                        eventByMachRec.starttime_utc_hr = int.Parse(tempString);
                        tempString = tempTimeString.Substring(14, 2);
                        eventByMachRec.starttime_utc_min = int.Parse(tempString);
                        tempString = tempTimeString.Substring(17, 2);
                        eventByMachRec.starttime_utc_sec = int.Parse(tempString);


                        //end time
                        tempTimeString = eventByMachRec.endTimeStr;
                        tempString     = tempTimeString.Substring(0, 4);
                        eventByMachRec.endtime_utc_yr = int.Parse(tempString);
                        tempString = tempTimeString.Substring(5, 2);
                        eventByMachRec.endtime_utc_mon = int.Parse(tempString);
                        tempString = tempTimeString.Substring(8, 2);
                        eventByMachRec.endtime_utc_day = int.Parse(tempString);

                        tempString = tempTimeString.Substring(11, 2);
                        eventByMachRec.endtime_utc_hr = int.Parse(tempString);
                        tempString = tempTimeString.Substring(14, 2);
                        eventByMachRec.endtime_utc_min = int.Parse(tempString);
                        tempString = tempTimeString.Substring(17, 2);
                        eventByMachRec.endtime_utc_sec = int.Parse(tempString);

                        Console.WriteLine($"Sending # {i} : {LogFiles.Disp_LogMachEvents_table[i].timeStartStr}");
                        UploadEventByMach(eventByMachRec);
                    };
                }
                ;
            }
            ;
        }