Пример #1
0
        private static void ProcessCsvLine(string strLine, PwDatabase pwStorage,
                                           SortedDictionary <string, PwGroup> dictGroups)
        {
            if (strLine == StrHeader)
            {
                return;                                  // Skip header
            }
            List <string> list = ImportUtil.SplitCsvLine(strLine, ",");

            Debug.Assert(list.Count == 13);
            if (list.Count != 13)
            {
                return;
            }

            string strType      = ParseCsvWord(list[0]);
            string strGroupName = ParseCsvWord(list[12]) + " - " + strType;

            SplashIdMapping mp = null;

            foreach (SplashIdMapping mpFind in SplashIdMappings)
            {
                if (mpFind.TypeName == strType)
                {
                    mp = mpFind;
                    break;
                }
            }

            PwIcon pwIcon = ((mp != null) ? mp.Icon : PwIcon.Key);

            PwGroup pg = null;

            if (dictGroups.ContainsKey(strGroupName))
            {
                pg = dictGroups[strGroupName];
            }
            else
            {
                PwIcon pwGroupIcon = ((pwIcon == PwIcon.Key) ?
                                      PwIcon.FolderOpen : pwIcon);

                pg = new PwGroup(true, true, strGroupName, pwGroupIcon);
                pwStorage.RootGroup.AddGroup(pg, true);
                dictGroups.Add(strGroupName, pg);
            }

            PwEntry pe = new PwEntry(true, true);

            pg.AddEntry(pe, true);

            pe.IconId = pwIcon;

            for (int iField = 0; iField < 9; ++iField)
            {
                string strData = ParseCsvWord(list[iField + 1]);
                if (strData.Length == 0)
                {
                    continue;
                }

                string strLookup = ((mp != null) ? mp.FieldNames[iField] :
                                    null);
                string strField = (strLookup ?? ("Field " + (iField + 1).ToString()));

                pe.Strings.Set(strField, new ProtectedString(false,
                                                             strData));
            }

            pe.Strings.Set(PwDefs.NotesField, new ProtectedString(
                               pwStorage.MemoryProtection.ProtectNotes,
                               ParseCsvWord(list[11])));
        }
Пример #2
0
        private static void ProcessCsvLine(string[] vLine, PwDatabase pwStorage,
                                           SortedDictionary <string, PwGroup> dictGroups)
        {
            string strType = ParseCsvWord(vLine[0]);

            string strGroupName = ParseCsvWord(vLine[12]);             // + " - " + strType;

            if (strGroupName.Length == 0)
            {
                strGroupName = strType;
            }

            SplashIdMapping mp = null;

            foreach (SplashIdMapping mpFind in SplashIdCsv402.SplashIdMappings)
            {
                if (mpFind.TypeName == strType)
                {
                    mp = mpFind;
                    break;
                }
            }

            PwIcon pwIcon = ((mp != null) ? mp.Icon : PwIcon.Key);

            PwGroup pg = null;

            if (dictGroups.ContainsKey(strGroupName))
            {
                pg = dictGroups[strGroupName];
            }
            else
            {
                // PwIcon pwGroupIcon = ((pwIcon == PwIcon.Key) ?
                //	PwIcon.FolderOpen : pwIcon);
                // pg = new PwGroup(true, true, strGroupName, pwGroupIcon);

                pg      = new PwGroup(true, true);
                pg.Name = strGroupName;

                pwStorage.RootGroup.AddGroup(pg, true);
                dictGroups[strGroupName] = pg;
            }

            PwEntry pe = new PwEntry(true, true);

            pg.AddEntry(pe, true);

            pe.IconId = pwIcon;

            StrUtil.AddTags(pe.Tags, StrUtil.StringToTags(strType));

            for (int iField = 0; iField < 9; ++iField)
            {
                string strData = ParseCsvWord(vLine[iField + 1]);
                if (strData.Length == 0)
                {
                    continue;
                }

                string strLookup = ((mp != null) ? mp.FieldNames[iField] :
                                    null);
                string strField = (strLookup ?? ("Field " + (iField + 1).ToString()));

                ImportUtil.AppendToField(pe, strField, strData, pwStorage);
            }

            ImportUtil.AppendToField(pe, PwDefs.NotesField, ParseCsvWord(vLine[11]),
                                     pwStorage);

            DateTime?odt = TimeUtil.ParseUSTextDate(ParseCsvWord(vLine[10]),
                                                    DateTimeKind.Local);

            if (odt.HasValue)
            {
                DateTime dt = TimeUtil.ToUtc(odt.Value, false);
                pe.LastAccessTime       = dt;
                pe.LastModificationTime = dt;
            }
        }