Exemple #1
0
        public void LoadFile(string FileUri)
        {
            ResetModel();

            IndexerModel db = new IndexerModel();
            GenericRepository<Files> uRep = new GenericRepository<Files>(db);

            try
            {
                var r = db.Files;
                if (r.Any())
                {
                    ReportMessage("First : " + r.Count().ToString());
                }
            }
            catch (Exception)
            {

                ReportMessage("First doesnot work. ");
            }

            try
            {
                using (db = new IndexerModel())
                {
                    var r = db.Files;
                    if (r.Any())
                    {
                        ReportMessage("Second : " + r.Count().ToString());
                    }
                }
            }
            catch (Exception)
            {

                ReportMessage("Second doesnot work. ");
            }

            try
            {
              //  Expression<Func<Files, bool>> filter = (x) => x.size > 325666;

                var q = uRep.GetAllTest((x)=>x.size>325666);

                if (q.Any())
                {
                    ReportMessage("Repository : " + q.Count().ToString());
                }
            }
            catch (Exception)
            {

                ReportMessage("Repository doesnot work. ");
            }

            var fi = new FileInfo(FileUri);
            if (fi != null)
            {
                FilesRep.FilesExistsResult res = FilesRep.CheckFileExists(fi.FullName, fi.Name, fi.Length, fi.LastWriteTime.ToLongDateString(), fi.LastWriteTime.ToFileTime());
                if (res == FilesRep.FilesExistsResult.FileDoesNotExist)
                {
                    var item = new Files();
                    item.FileID = Guid.NewGuid();
                    item.Uri = fi.FullName;
                    item.size = fi.Length;
                    item.Date = fi.LastWriteTime;
                    item.FileTime = fi.LastWriteTime.ToFileTime();
                    item.strDate = fi.LastWriteTime.ToLongDateString();
                    FileNameOnly = item.Uri;

                    // Test GitHub
                    // Test GitHub 2

                    FilesRep.AddFileToDB(item);
                }

            }
        }