Exemple #1
0
 public static void SharingFile_Update(SharingInfo sf)
 {
     if (PreKeyring.SharingFile_Query(sf.CopyRef) == null)
     {
         SharingFile_Insert(sf);
     }
     else
     {
         lock (PreKeyring.conn)
         {
             String sql = string.Format(SQLStatement.SharingFile_Update,
                                        sf.CopyRef,
                                        sf.FileName,
                                        sf.ID_From,
                                        sf.CKEY_E,
                                        sf.CKEY_F,
                                        sf.CKEY_U,
                                        sf.CKEY_W);
             if (conn.State == ConnectionState.Closed)
             {
                 conn.Open();
             }
             using (SqliteCommand cmd = new SqliteCommand())
             {
                 cmd.Connection  = PreKeyring.conn;
                 cmd.CommandText = sql;
                 if (cmd.ExecuteNonQuery() != 1)
                 {
                     throw new DBException();
                 }
             }
         }
     }
 }
Exemple #2
0
        public static void SharingFile_TEST()
        {
            PreKeyring.SharingFile_Update(
                new SharingInfo
            {
                CopyRef  = "ref1",
                FileName = "file",
                ID_From  = "Hjnubys",
                CKEY_E   = "testE",
                CKEY_F   = "testF",
                CKEY_U   = "testU",
                CKEY_W   = "testW"
            });
            PreKeyring.SharingFile_Update(new SharingInfo
            {
                CopyRef  = "ref2",
                FileName = "file2",
                ID_From  = "Hjnubys",
                CKEY_E   = "testE",
                CKEY_F   = "testF",
                CKEY_U   = "testU",
                CKEY_W   = "testW"
            }); PreKeyring.SharingFile_Update(new SharingInfo
            {
                CopyRef  = "ref3",
                FileName = "file2",
                ID_From  = "Hjnubys",
                CKEY_E   = "testE",
                CKEY_F   = "testF",
                CKEY_U   = "testU",
                CKEY_W   = "testW"
            });
            SharingInfo sf = PreKeyring.SharingFile_Query("ref1");

            Console.WriteLine(
                (sf == null) ? "The SharingFileInfo is not exist" :
                "Find the file info of the copyref with ref");
            PreKeyring.SharingFile_Delete(new String[] { "ref1", "ref3" });
            List <SharingInfo> sharingfileList = PreKeyring.GetSharingFileList();

            foreach (SharingInfo f in sharingfileList)
            {
                Console.WriteLine(f.CopyRef + "   " +
                                  f.FileName + "  " +
                                  f.ID_From + "   " +
                                  f.CKEY_E + "   " +
                                  f.CKEY_F + "   " +
                                  f.CKEY_U + "   " +
                                  f.CKEY_W + "   ");
            }
        }