Пример #1
0
        private TblRecoveryPoint setupRecoveryPoint()
        {
            TblRecoveryPoint rec_RceoveryPoint = new TblRecoveryPoint
            {
                Name   = m_Rid.ToString() + " " + m_RegnskabsNavn,
                Rptime = DateTime.Now
            };

            m_dbRecovery.TblRecoveryPoint.InsertOnSubmit(rec_RceoveryPoint);

            TblRecoveryPointLine rec_RecoveryPointLine = new TblRecoveryPointLine
            {
                Recoverypath   = m_PlaceringPath,
                Recoveryisfile = false
            };

            rec_RceoveryPoint.TblRecoveryPointLine.Add(rec_RecoveryPointLine);

            rec_RecoveryPointLine = new TblRecoveryPointLine
            {
                Recoverypath   = m_FraPBSPath,
                Recoveryisfile = false
            };
            rec_RceoveryPoint.TblRecoveryPointLine.Add(rec_RecoveryPointLine);

            rec_RecoveryPointLine = new TblRecoveryPointLine
            {
                Recoverypath   = m_TilPBSPath,
                Recoveryisfile = false
            };
            rec_RceoveryPoint.TblRecoveryPointLine.Add(rec_RecoveryPointLine);

            rec_RecoveryPointLine = new TblRecoveryPointLine
            {
                Recoverypath   = m_DataBasePath,
                Recoveryisfile = true
            };
            rec_RceoveryPoint.TblRecoveryPointLine.Add(rec_RecoveryPointLine);
            m_dbRecovery.SubmitChanges();
            return(rec_RceoveryPoint);
        }
Пример #2
0
        private void restorefile(TblRecoveryPointLine RecoveryPointLine)
        {
            var files = from rc in RecoveryPointLine.TblRecoveryPointContent
                        join c in m_dbRecovery.TblContent on rc.Contentid equals c.Id
                        join f in m_dbRecovery.TblDirectory on c.Directoryid equals f.Id
                        select new
            {
                RecoveryIsfile = RecoveryPointLine.Recoveryisfile,
                RestorePath    = RecoveryPointLine.Restorepath,
                fileName       = f.Name,
                parent         = f.Parentid,
                Data           = c.Data,
                Mtime          = c.Mtime,
                Atime          = c.Atime
            };
            int antal = files.Count();

            foreach (var fil in files)
            {
                string RestoreFileName = fil.fileName;
                string RestorePathOnly;
                if (fil.RecoveryIsfile == true)
                {
                    FileInfo fi = new FileInfo(fil.RestorePath);
                    RestorePathOnly = fi.DirectoryName;
                }
                else
                {
                    RestorePathOnly = fil.RestorePath;
                }
                string RestorePathAndName = RestorePathOnly + @"\" + RestoreFileName;
                File.WriteAllBytes(RestorePathAndName, ZipUncompressStream2(fil.Data.ToArray()));
                FileInfo nfi = new FileInfo(RestorePathAndName);
                nfi.LastWriteTime  = fil.Mtime;
                nfi.LastAccessTime = fil.Atime;
            }
        }
Пример #3
0
 private void detach_TblRecoveryPointLine(TblRecoveryPointLine entity)
 {
     this.SendPropertyChanging();
     entity.TblRecoveryPoint = null;
 }
Пример #4
0
 partial void DeleteTblRecoveryPointLine(TblRecoveryPointLine instance);
Пример #5
0
 partial void UpdateTblRecoveryPointLine(TblRecoveryPointLine instance);
Пример #6
0
 partial void InsertTblRecoveryPointLine(TblRecoveryPointLine instance);
Пример #7
0
        private void backupfile(TblRecoveryPointLine rec_RceoveryPointLine, string filepath)
        {
            string backupFilepath = filepath;

            FileInfo fi = new FileInfo(backupFilepath);

            //Directories ------------------------------------------------------------
            string[]     strPaths = fi.DirectoryName.Split(new char[] { '\\' });
            TblDirectory per_rec_Directory;
            TblDirectory rec_Directory;
            TblDirectory rec_File;

            try
            {
                per_rec_Directory = (from d in m_dbRecovery.TblDirectory where d.Name == strPaths[0] && d.Parentid == null select d).First();
            }
            catch (InvalidOperationException)
            {
                per_rec_Directory = new TblDirectory
                {
                    Name   = strPaths[0],
                    Isfile = false
                };
                m_dbRecovery.TblDirectory.InsertOnSubmit(per_rec_Directory);
                m_dbRecovery.SubmitChanges();
            }

            for (int i = 1; i < strPaths.Length; i++)
            {
                try
                {
                    rec_Directory = (from d in per_rec_Directory.Dirindir where d.Name == strPaths[i] select d).First();
                }
                catch (InvalidOperationException)
                {
                    rec_Directory = new TblDirectory
                    {
                        Name   = strPaths[i],
                        Isfile = false
                    };
                    per_rec_Directory.Dirindir.Add(rec_Directory);
                    m_dbRecovery.SubmitChanges();
                }
                per_rec_Directory = rec_Directory;
            }

            //File ------------------------------------------------------------------
            try
            {
                rec_File = (from d in per_rec_Directory.Dirindir where d.Name == fi.Name select d).First();
            }
            catch (InvalidOperationException)
            {
                rec_File = new TblDirectory
                {
                    Name   = fi.Name,
                    Isfile = true
                };
                per_rec_Directory.Dirindir.Add(rec_File);
                m_dbRecovery.SubmitChanges();
            }

            //Content ---------------------------------------------------------------

            MD5           md5 = MD5.Create();
            StringBuilder sb  = new StringBuilder();

            byte[] bData = File.ReadAllBytes(fi.FullName);
            foreach (byte b in md5.ComputeHash(bData))
            {
                sb.Append(b.ToString("x2").ToLower());
            }

            TblContent rec_Content;

            try
            {
                rec_Content = (from d in rec_File.TblContent where d.Checksum == sb.ToString() select d).First();
            }
            catch (InvalidOperationException)
            {
                rec_Content = new TblContent
                {
                    Checksum = sb.ToString(),
                    Size     = fi.Length,
                    Mtime    = fi.LastWriteTime,
                    Atime    = fi.LastAccessTime,
                    Data     = ZipCompressStream2(bData, fi.Name, fi.LastWriteTime)
                };
                rec_File.TblContent.Add(rec_Content);
                m_dbRecovery.SubmitChanges();
            }

            //RecoveryPoint_Content -------------------------------------------------
            TblRecoveryPointContent rec_RecoveryPointContent = new TblRecoveryPointContent {
            };

            rec_Content.TblRecoveryPointContent.Add(rec_RecoveryPointContent);
            rec_RceoveryPointLine.TblRecoveryPointContent.Add(rec_RecoveryPointContent);
            m_dbRecovery.SubmitChanges();
        }