Exemplo n.º 1
0
 public static void addDirectory(DirectoryInfo AInfo)
 {
     Document doc = new Document(-1,"Repertoire",AInfo.FullName,AInfo.LastWriteTime,0,"","Ok");
     database.addFileInfo(ref doc);
 }
Exemplo n.º 2
0
 public static int addFile(FileInfo AInfo)
 {
     Document doc = new Document(-1,"Fichier",AInfo.FullName,AInfo.LastWriteTime,AInfo.Length,"MD5","Nouveau");
     return database.addFileInfo(ref doc);
 }
Exemplo n.º 3
0
 private static void readerToDocument(ref SqlDataReader AReader,ref Document ADoc)
 {
     ADoc.Id = Convert.ToInt32(AReader["DocumentId"].ToString());
     ADoc.Type = AReader["Type"].ToString();
     ADoc.Nom = AReader["Nom"].ToString();
     ADoc.DateModification = Convert.ToDateTime(AReader["DateModification"].ToString());
     ADoc.Taille = Convert.ToInt64(AReader["Taille"].ToString());
     ADoc.Hash = AReader["Hash"].ToString();
     ADoc.Etat = AReader["Etat"].ToString();
 }
Exemplo n.º 4
0
        private static int addFileInfo(ref Document ADoc)
        {
            int id=-1;

            SqlConnection connect = new SqlConnection(connecstring);
            connect.Open();
            SqlCommand command = new SqlCommand("insert into Documents (Type,Nom,DateModification,Taille,Hash,Etat) values (@type,@file,@date,@taille,@hash,@etat) select @@identity as id",connect);
            command.Parameters.Add("@type",SqlDbType.VarChar).Value  = ADoc.Type;
            command.Parameters.Add("@file",SqlDbType.VarChar).Value  = ADoc.Nom;
            command.Parameters.Add("@date",SqlDbType.DateTime).Value  = ADoc.DateModification;
            command.Parameters.Add("@taille",SqlDbType.Int).Value  = ADoc.Taille;
            command.Parameters.Add("@hash",SqlDbType.VarChar).Value = "md5";
            command.Parameters.Add("@etat",SqlDbType.VarChar).Value = ADoc.Etat;
            SqlDataReader dr = command.ExecuteReader();
            dr.Read();
            id = Convert.ToInt32(dr["id"].ToString());
            connect.Close();

            return id;
        }
Exemplo n.º 5
0
 public static void updateFileInfo(ref Document ADoc)
 {
     SqlConnection connect = new SqlConnection(connecstring);
     connect.Open();
     SqlCommand command = new SqlCommand("update Documents set Type=@type,Nom=@file,DateModification=@date,Taille=@taille,Hash=@hash,Etat=@etat where DocumentId=@id",connect);
     command.Parameters.Add("@id",SqlDbType.VarChar).Value  = ADoc.Id;
     command.Parameters.Add("@type",SqlDbType.VarChar).Value  = ADoc.Type;
     command.Parameters.Add("@file",SqlDbType.VarChar).Value  = ADoc.Nom;
     command.Parameters.Add("@date",SqlDbType.DateTime).Value  = ADoc.DateModification;
     command.Parameters.Add("@taille",SqlDbType.Int).Value  = ADoc.Taille;
     command.Parameters.Add("@hash",SqlDbType.VarChar).Value = "md5";
     command.Parameters.Add("@etat",SqlDbType.VarChar).Value = ADoc.Etat;
     command.ExecuteNonQuery();
     connect.Close();
 }
Exemplo n.º 6
0
        public static Document[] searchDocument(string AClauseWhere,int limit)
        {
            string top = "";

            if (limit>0)
            {
                top = "top " + limit.ToString();
            }

            string sql = "select " + top + " documents.* from documents inner join  documentclef on documents.documentid=documentclef.documentid where " + AClauseWhere;

            SqlConnection connect = new SqlConnection(connecstring);
            connect.Open();

            SqlCommand command = new SqlCommand(sql,connect);
            ArrayList list = new ArrayList();
            SqlDataReader dr = database.ReaderMesureTime(ref command);
            try
            {
                while (dr.Read())
                {
                    Document doc = new Document();
                    readerToDocument(ref dr,ref doc);
                    list.Add(doc);
                }
            }
            finally
            {
                if (dr != null) dr.Close();
                command.Dispose();
                connect.Close();
            }

            return (Document[])list.ToArray(typeof(Document));
        }
Exemplo n.º 7
0
        public static Document GetNextIndex()
        {
            Document doc = new Document();

            SqlConnection connect = new SqlConnection(connecstring);
            connect.Open();
            SqlCommand command = new SqlCommand("select top 1 * from documents where type='fichier' and etat<>'OK' and etat<>'Erreur' and etat<>'FullText'",connect);
            SqlDataReader dr = command.ExecuteReader();
            if (dr.Read())
            {
                database.readerToDocument(ref dr,ref doc);
            }
            connect.Close();

            return doc;
        }