Пример #1
0
        public bool CreateLink(TagData tagData, ArticleData articleData)
        {
            Logger.GetInstance().Log("TDB: Initialising Link creation");

            bool returnValue = false;

            // Check if a conenction is open
            if (!_hasOpenedConnection)
            {
                return(false);
            }

            // Create query
            string query =
                "INSERT INTO links (tag_id, tag_timestamp, tag_data, article_id, article_name, article_note, article_cost) VALUES ('"
                + tagData.Id + "','" + tagData.TimeStamp.ToString("dd.MM.yyyy HH:mm:ss") + "','" + tagData.Data + "','"
                + articleData.Id + "','" + articleData.Name + "','" + articleData.Note + "','" + articleData.Cost + "');";

            Logger.GetInstance().Log("DB: Creating link query: " + query);

            Logger.GetInstance().Log("DB: Creating link");

            try
            {
                // Executing the command
                returnValue = CreateAndExecuteCommand(query);
            }
            catch (Exception e)
            {
                Logger.GetInstance().Log("--Exception caught in TDB: " + e.Message);
            }

            Logger.GetInstance().Log("DB: Link created");

            return(returnValue);
        }
Пример #2
0
 private void OnNewTagScanned(TagData scannedTag)
 {
     // Trigger event if the handler isnt null (if there are subscribers)
     NewTagScanned?.Invoke(scannedTag);
 }
Пример #3
0
        /* tasked method which searches for new tasks in the field of the reader
         * adds only distinct chips the the list of scanned tags */
        private void Scanner()
        {
            while (Scanning)
            {
                try
                {
                    var tagList = _reader.TagInventory(true, 0x00, 1);

                    if (tagList.Count > 0)
                    {
                        Logger.GetInstance().Log($"tagList.Count = {tagList.Count}");
                        var listTagHandler = tagList.Values;

                        foreach (FedmIscTagHandler th in listTagHandler)
                        {
                            if (th == null)
                            {
                                continue;
                            }

                            FedmIscTagHandler tagHandler;

                            try
                            {
                                tagHandler = _reader.TagSelect(th, 0);
                            }
                            catch (Exception e)
                            {
                                Logger.GetInstance().Log("--Exception caught in SC: " + e.Message);
                                continue;
                            }

                            Logger.GetInstance().Log("SC: Called TagSelect");

                            // Check if the scanned tag is of the correct type
                            if (!(tagHandler is FedmIscTagHandler_ISO15693))
                            {
                                continue;
                            }

                            try
                            {
                                // Create TagData from tag
                                TagData scannedTag = FormatTagHandlerToTagData((FedmIscTagHandler_ISO15693)tagHandler);

                                lock (_scannedTags
                                      ) // lock object because same list is used as return value in asynchronous main thread
                                {
                                    if (!_scannedTags.Contains(scannedTag))
                                    {
                                        _scannedTags
                                        .Add(
                                            scannedTag);     // info about tag gets saved into list if its not already inside
                                        OnNewTagScanned(scannedTag);
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                Logger.GetInstance().Log("--Exception caught in SC: " + e.Message);
                            }
                        }

                        System.Threading.Thread.Sleep(100); // if tags could have been found, wait for 100 ms
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(200); // if no tags could have been found, wait for 200 ms
                    }
                }
                catch (Exception e)
                {
                    Logger.GetInstance().Log("SC: --EXCEPTION caught while scanning: " + e.Message + e.GetType());
                }
            }
        }
Пример #4
0
 public ArticleData GetArticleDataByTagData(TagData tagData)
 {
     return(GetArticleDataByTagData(tagData.Id));
 }