Esempio n. 1
0
            private attachmentInfo(Dictionary <string, string> newinfo)
            {
                metaInfo = newinfo;

                if (!newinfo.ContainsKey("Path") || newinfo["Path"] == "")
                {
                    throw new InvalidDataException();
                }

                securePath = newinfo["Path"];

                foreach (string tag in newinfo.Keys) // Classifier line could be in several places, we have to search everywhere for it
                {
                    if (tag.Contains("rtnipcontrolcode") || tag.Contains("rtnexportcontrolcountry"))
                    {
                        classification = new classificationData(newinfo[tag]);
                    }
                }

                if (classification is null)
                {
                    classification = new classificationData();
                    Debug.Print("unclassified attachment found.");
                }
            }
Esempio n. 2
0
                internal classificationData(string data)
                {
                    classificationData temp = parseClassification(data);

                    controlCodes        = temp.controlCodes;
                    validClassification = temp.validClassification;
                    emptyClassification = temp.emptyClassification;
                }
Esempio n. 3
0
                internal classificationData()
                {
                    classificationData temp = new classificationData(true);

                    controlCodes        = temp.controlCodes;
                    validClassification = temp.validClassification;
                    emptyClassification = temp.emptyClassification;
                }
Esempio n. 4
0
                private static classificationData parseClassification(string classification) // String manipulation stuff
                {                                                                            // Far as I can tell, the classification tool sets up to five keywords, always ordered in the same way, seperated by |
                    if (classification == "")
                    {
                        return(new classificationData());
                    }

                    // Sanitize input
                    classification = classification.Trim();
                    classification = classification.Replace("[", "");
                    classification = classification.Replace("]", "");
                    string[] keywords = classification.Split('|');
                    if (keywords.Length != 5)
                    {
                        Debug.Print("Invalid classification string found?");
                        return(new classificationData());
                    } // Replace invalid classification with default

                    classificationData tempObject = new classificationData(false); // Prepopulated, valid classification object

                    for (int x = 0; x < 5; x++)
                    {
                        string code = keywords[x];
                        if (String.IsNullOrEmpty(code))
                        {
                            continue;
                        }
                        string[] codeparts = code.Split(':');
                        if (codeparts.Length != 2)
                        {
                            continue;
                        }
                        if (tempObject.controlCodes.ContainsKey(codeparts[0]))
                        {
                            tempObject.controlCodes[codeparts[0]] = codeparts[1];
                        }
                        else
                        {
                            Debug.Print("invalid control code key: " + codeparts[0] + " with value " + codeparts[1] + ", skipping");
                        }
                    }

                    tempObject.validate();
                    return(tempObject);
                }