Ejemplo n.º 1
0
        public static void OpenDatabase()
        {
            m_DBFile = FileInteraction.CreateDirectory("ADSFE") + "ADS_DB";

            try
            {
                //FileInfo fi = new FileInfo(m_DBFile);
                //fi.Delete();

                m_Conn = new SQLiteConnection(m_DBFile);

                if (m_Conn != null)
                {
                    m_Conn.CreateTable <ProfileRecord>();
                    m_Conn.CreateTable <RawDataRecord>();
                    m_Conn.CreateTable <Options>();
                    m_Conn.CreateTable <BadgeType>();
                    m_Conn.CreateTable <Levels>();



                    if (m_Conn.Table <Options>().Count() == 0)
                    {
                        m_Conn.Insert(new Options(), typeof(Options));
                    }
                }
            }
            catch (Exception ee)
            {
            }
        }
Ejemplo n.º 2
0
        public static void LoadProfileLevelsFromFile()
        {
            string        FileName  = FileInteraction.CreateDirectory("DEF") + "PROFILE.DEF";
            List <Levels> LevelList = new List <Levels>();

            try
            {
                FileInfo fi = new FileInfo(FileName);
                if (fi.Exists)
                {
                    string StopString = "THIS line MUST remain";
                    string FileData   = FileInteraction.ReadCompleteFile("DEF", "PROFILE.DEF");

                    if (FileData != "")
                    {
                        string[] FileInfo = FileData.Split('\n');

                        if (FileInfo.Length > 2)
                        {
                            int    OrderValue = 0;
                            string curLevel   = "";
                            string FileLevel  = FileInfo[1].Trim();
                            int    OffSet     = 73;
                            if (FileLevel.Length >= 8)
                            {
                                OffSet += 10;
                            }

                            while (curLevel.IndexOf(StopString) == -1)
                            {
                                curLevel = FileInfo[OffSet + OrderValue].Trim();
                                if (curLevel.IndexOf(StopString) == -1)
                                {
                                    Levels ll = new Levels();
                                    OrderValue++;

                                    ll.Order = OrderValue;
                                    ll.Level = curLevel;
                                    LevelList.Add(ll);
                                }
                            }
                        }



                        DataAccess.UpdateLevelsTable(LevelList);
                    }
                }
            }
            catch (Exception ee)
            {
            }
        }
Ejemplo n.º 3
0
        public static void LoadBadgesFromFile()
        {
            string           FileName  = FileInteraction.CreateDirectory("DEF") + "BADGE.DEF";
            List <BadgeType> BadgeList = new List <BadgeType>();

            try
            {
                FileInfo fi = new FileInfo(FileName);
                if (fi.Exists)
                {
                    string FileData = FileInteraction.ReadCompleteFile("DEF", "BADGE.DEF");

                    if (FileData != "")
                    {
                        string[] FileInfo = FileData.Split('\n');

                        for (int Count = 2; Count < FileInfo.Length - 1; Count += 2)
                        {
                            string[]  strItems = FileInfo[Count].Split(';');
                            BadgeType bt       = new BadgeType();
                            bt.Type1 = strItems[1];
                            bt.Type2 = strItems[2];

                            bt.BadgeID     = strItems[3];
                            bt.Description = strItems[6];
                            bt.Misc        = strItems[7];
                            bt.ButtonID    = strItems[5];
                            bt.Details     = "";

                            BadgeList.Add(bt);
                        }


                        DataAccess.UpdateBadgeTable(BadgeList);
                    }
                }
            }
            catch (Exception ee)
            {
            }
        }
Ejemplo n.º 4
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();
            }
        }