예제 #1
0
        public void Sync_Clicked(object sender, EventArgs e)
        {
            bool bBadgeReceived   = false;
            bool bProfileReceived = false;
            //send data
            //get badge.def
            //get profile.def

            //List<RawDataRecord> RawList = DataAccess.GetRecordTable(false);
            List <RawDataRecord> RawList = DataAccess.GetPendingData();
            string RawData = DataTrack.GetRawFileHeader(m_Options.ProbeName);

            for (int Count = 0; Count < RawList.Count; Count++)
            {
                RawData += string.Format("{0}0 HH {1,-12}{2}\r\n", DataTrack.GetTimeStamp(RawList[Count].TimeStamp), RawList[Count].ScanValue, RawList[Count].Flags);
            }
            RawData += string.Format("T 000\r\n");
            RawData += string.Format("S {0}\r\n", AccountInfo.GetDeviceID());


            NameValueCollection RawValues = WebInteraction.GetRawFileSendValues(m_Options.CompanyID, m_Options.WebFolder, m_Options.ProbeName);

            RawValues.Add("filedata", RawData);
            RawValues.Add("FileLen", RawData.Length.ToString());

            string result = WebInteraction.SendHttpPostValues(WebInteraction.m_FileSyncURL, RawValues);

            if (result.IndexOf("<adsdelimiter>") >= 0)
            {
                result += "<adsdelimiter>";
                string Temp = result.Substring(0, result.IndexOf("<adsdelimiter>"));
                result = result.Substring(result.IndexOf("<adsdelimiter>") + 14);
                if (Temp == RawValues["fname"])
                {
                    Temp = result.Substring(0, result.IndexOf("<adsdelimiter>"));
                    if (Temp == RawValues["FileLen"])
                    {
                        //DataAccess.UpdateRecordTable();


                        //DataAccess.UpdateProfileRecordStatus();
                    }
                }
            }


            NameValueCollection UseMe = WebInteraction.GenerateDefFileRequest(m_Options.CompanyID, m_Options.WebFolder, "BADGE.DEF");

            result = WebInteraction.SendHttpPostValues(WebInteraction.m_FileSyncURL, UseMe);
            if (result != "")
            {
                //process badge.def
                FileInteraction.WriteCompleteFile("DEF", "BADGE.DEF", result);
                bBadgeReceived = true;
            }



            UseMe  = WebInteraction.GenerateDefFileRequest(m_Options.CompanyID, m_Options.WebFolder, "PROFILE.DEF");
            result = WebInteraction.SendHttpPostValues(WebInteraction.m_FileSyncURL, UseMe);
            if (result != "")
            {
                //process badge.def
                FileInteraction.WriteCompleteFile("DEF", "PROFILE.DEF", result);
                bProfileReceived = true;
            }

            if (bBadgeReceived)
            {
                DataTrack.LoadBadgesFromFile();
            }
            if (bProfileReceived)
            {
                DataTrack.LoadProfileLevelsFromFile();
            }
        }