//functions internal void AddPermutation(string cleanPermutation, Doubly <TimeData> .Node refNode) { Permutations newPermutation = new Permutations(cleanPermutation, refNode); Permutations.Add(newPermutation); TotalPermutationTypesCount++; TotalQuantity++; }
//c'tor public Permutations(string permutation, Doubly <TimeData> .Node refNode) { Permutation = permutation; Ref = refNode; if (refNode != null) { Count++; } }
//c'tor public Document(string key, string documentContent, Doubly <TimeData> .Node refNode) { Permutations = new BST <Permutations>(); TotalQuantity = 0; TotalPermutationTypesCount = 0; _refNode = refNode; AddPermutation(documentContent, refNode); MainPermutation = key; }
public bool IsDuplicated(string documentContent, out string msg) { string cleanPermutation; string key; bool isContentOk = Descriptor.GetKey(documentContent, out cleanPermutation, out key); msg = "The document content you entered is not legal"; if (!isContentOk) { return(false); } Doubly <TimeData> .Node refNode = null; if (_documentsManagementSystem.ContainsKey(key)) // key exists, Document is in the system { Permutations foundItem; bool isPermutationExist = _documentsManagementSystem[key].IsPermutationExist(cleanPermutation, out foundItem); if (!isPermutationExist) { TimeData newDocumentTimeStamp = new TimeData(cleanPermutation); _timeStamps.EnQueue(newDocumentTimeStamp, out refNode); _documentsManagementSystem[key].AddPermutation(cleanPermutation, refNode); msg = "The document was already in the system, but the permutation wasn't in the system. It is now. The quantities were updated"; } else { _timeStamps._QueueDoubly.RemoveNode(foundItem.Ref); TimeData newDocumentTimeStamp = new TimeData(cleanPermutation); _timeStamps.EnQueue(newDocumentTimeStamp, out refNode); foundItem.Ref = refNode; msg = "The document and the permutation were already in the system. The quantities were updated."; } return(true); } else // create new document { TimeData newDocumentTimeStamp = new TimeData(cleanPermutation); _timeStamps.EnQueue(newDocumentTimeStamp, out refNode); Document doc = new Document(key, cleanPermutation, refNode); _documentsManagementSystem.Add(key, doc); msg = "The document wasn't in the system. It is now. The quantities were updated."; return(false); } }