Ejemplo n.º 1
0
        public string SharePackage(string sender, string[] recipients, string packageCode, string[] tokens, string subject, string message)
        {
            Console.WriteLine("Sharing package from " + sender + " for package " + packageCode + " containing " + tokens.Length + " files");
            log.InfoFormat("Sharing package from \"{0}\"", sender);

            Package package = new Package() {
                Code = packageCode,
                SenderMail = sender,
                Message = subject + "\n" + message,
                Status = (char)PackageStatus.Open,
                Scanned = false,
                ExpiresAt = DateTime.UtcNow.AddDays(14),
                CreatedAt = DateTime.UtcNow
            };

            using (DataClassesDataContext db = new DataClassesDataContext()) {
                foreach (string fileHash in tokens) {
                    File f = new File() {
                        CreatedAt = DateTime.UtcNow,
                        FileHash = fileHash,
                        FileSize = 0/*Storage.GetFileSize(package.Code, fileHash)*/,
                        Package = package,
                    };
                    db.Files.InsertOnSubmit(f);
                }

                db.SubmitChanges();
            }

            string response = TransmitSettings.Instance.Setting.OutlookInjectedHtml ?? "Download: [TransmitUrl]/receive.aspx?h=[Package.Code]";
            response = response.Replace("[Package.Code]", packageCode);
            response = response.Replace("[TransmitUrl]", TransmitSettings.Instance.Setting.ExternalUrl);
            return response;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                var packages = (from p in db.Packages
                                where p.Status == (char)PackageStatus.Open
                                  orderby p.CreatedAt descending
                                  select p).Take(100);

                LvPackages.DataSource = packages;
                LvPackages.DataBind();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                // get all expired packages after page has loaded and
                // "cleanup" method has been invoked
                var latestLogs = from p in db.Logs
                                  orderby p.CreatedAt descending
                                  select p;

                DlLatestLogs.DataSource = latestLogs;
                DlLatestLogs.DataBind();
            }
        }
Ejemplo n.º 4
0
        public static Package FindByCode(string code)
        {
            Package package;
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                package = db.Packages.SingleOrDefault(p => p.Code == code);
                if (package == null) {
                    return null;
                }

                package.Files.Load();
                package.Transfers.Load();
            }
            return package;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Requests a file from one or more (internal- or external) users.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnRequest_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["Recipients[]"])) {
                ValidationError.Display(_("No recipients specified"));
            }

            if (!Page.IsValid) {
                ValidationSummary.HeaderText = _("Please correct the following:");
                //(this.Master as SiteMasterPage).Flash("You did not provide a file to share");
                return;
            }

            string[] recipients = Request["Recipients[]"].ToLower().Split(',');
            log.DebugFormat("User {0} is dispatching request emails to {1} recipients", this.CurrentUser, recipients.Length);
            foreach (string recipientEmail in recipients) {
                // try to lookup user in AD based on recipient mail
                AuthenticatedUser recipientUser = Locator.FindByMail(recipientEmail);

                Invitation invitation = new Invitation {
                    SenderMail = this.CurrentUser.Mail,
                    SenderDisplayName = this.CurrentUser.DisplayName,
                    RecipientMail = recipientEmail,
                    RecipientDisplayName = (recipientUser != null) ? recipientUser.DisplayName : recipientEmail,
                    Message = TbxMessage.Text,
                    Code = Guid.NewGuid().ToString("N"),
                    CreatedAt = DateTime.UtcNow
                };

                using (DataClassesDataContext db = new DataClassesDataContext()) {
                    db.Invitations.InsertOnSubmit(invitation);
                    db.SubmitChanges();
                }

                Dictionary<string, string> tokens = new Dictionary<string, string>();
                tokens.Add("CompanyName", TransmitSettings.Instance.Setting.CompanyName);
                tokens.Add("Sender.Mail", this.CurrentUser.Mail);
                tokens.Add("Sender.DisplayName", this.CurrentUser.DisplayName);
                tokens.Add("Recipient.Mail", invitation.RecipientMail);
                tokens.Add("Recipient.DisplayName", invitation.RecipientDisplayName);
                tokens.Add("Mail.Message", invitation.Message);
                tokens.Add("Mail.InvitationCode", invitation.Code);
                tokens.Add("Url.Location", string.Format("{0}/upload.aspx?h={1}", UserHelper.GetSiteUrl(recipientUser), invitation.Code));

                MailHelper.Send(TransmitSettings.Instance.Setting.RequestMailSubject, TransmitSettings.Instance.Setting.RequestMailBodyPlain, TransmitSettings.Instance.Setting.RequestMailBodyHtml, tokens);
            }

            this.Response.Redirect("~/request.success.aspx", true);
        }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            try {
                //log.DebugFormat("Start processing request from {0} with a content-length of {1}", HttpContext.Current.Request.UserHostAddress, context.Request.Headers["Content-Length"]);

                JumploaderWrapper.FileSystemFileSaver save = new JumploaderWrapper.FileSystemFileSaver(context, Commanigy.Transmit.Data.TransmitSettings.Instance.Setting.StorageLocation);
                JumploaderWrapper.MultUploadHandler handle = new JumploaderWrapper.MultUploadHandler(save);
                handle.FileSaved += new JumploaderWrapper.MFileEventHandler(delegate(object sender, JumploaderWrapper.FileSavedEventArgs args) {
                    log.DebugFormat("Client {0} successfully stored \"{3}\" ({1}kB) for token \"{2}\"", HttpContext.Current.Request.UserHostAddress, Math.Ceiling(int.Parse(context.Request.Headers["Content-Length"]) / 1024f), context.Request["token"], args.FileName);

                    using (DataClassesDataContext db = new DataClassesDataContext()) {
                        Package package = db.Packages.SingleOrDefault(p => p.Code == context.Request["token"]);
                        if (package == null) {
                            // create package if it doesn't already exists
                            package = new Package() {
                                Code = context.Request["token"],
                                SenderMail = "Unspecified",
                                Status = (char)PackageStatus.Open,
                                Scanned = false,
                                ExpiresAt = DateTime.Now.AddDays(14),
                                CreatedAt = DateTime.UtcNow
                            };
                        }

                        Commanigy.Transmit.Data.File file = package.Files.Where(f => f.FileHash == args.FileName).FirstOrDefault();
                        if (file == null) {
                            db.Files.InsertOnSubmit(new Commanigy.Transmit.Data.File() {
                                CreatedAt = DateTime.UtcNow,
                                FileHash = args.FileName,
                                FileSize = int.Parse(context.Request.Headers["Content-Length"]),
                                Package = package
                            });
                        }
                        else {
                            file.FileSize += int.Parse(context.Request.Headers["Content-Length"]);
                        }

                        db.SubmitChanges();
                    }
                });
                handle.ProcessRequest(context);
            }
            catch (Exception x) {
                log.Error("Failed to store received file", x);
                throw x;
            }
        }
Ejemplo n.º 7
0
        public void Clean()
        {
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                // get all old packages
                var oldPackages = from p in db.Packages
                                  where p.CreatedAt < DateTime.UtcNow.AddDays(-14)
                                  select p;

                // delete all obsoleted packages
                oldPackages.ToList().ForEach(delegate(Package p) {
                    if (Storage.DeletePath(p.Code)) {
                        db.Packages.DeleteOnSubmit(p);
                    }
                });

                db.SubmitChanges();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Download entire package to client computer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnDownload_Click(object sender, EventArgs e)
        {
            AuthenticatedUser senderUser = Locator.FindByMail(package.SenderMail);

            log.DebugFormat("User {0} downloaded package {1}", this.CurrentUser, package.Code);

            using (DataClassesDataContext db = new DataClassesDataContext()) {
                Package updatingPackage = db.Packages.SingleOrDefault(p => p.Code == package.Code);
                foreach (var f in updatingPackage.Files) {
                    f.DownloadCount += 1;
                }

                db.SubmitChanges();
            }

            string archiveFileName;
            if (package.Files.Count == 1 && package.Files[0].FileHash.ToLower().EndsWith(".zip")) {
                archiveFileName = package.Files[0].FileHash;
            }
            else {
                archiveFileName = string.Format("files-from-{0}.zip", (senderUser != null) ? senderUser.DisplayName : package.SenderMail).Replace(" ", "");
            }

            // strip invalid characters from filename
            string invalidCharacters = Regex.Escape(new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars()));
            archiveFileName = Regex.Replace(archiveFileName, "[" + invalidCharacters + "]", "");

            Response.ContentType = "application/x-zip-compressed";
            Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", archiveFileName));

            string filename = Storage.GetFullDirectoryPath(package.Code) + ".zip";

            // check if we already have a .zip archive
            if (System.IO.File.Exists(filename)) {
                //Response.WriteFile(Storage.GetFullDirectoryPath(package.Code) + ".zip");
                WriteFileToOutputStream(filename);
            }
            else {
                FastZip fz = new FastZip();
                fz.CreateZip(Response.OutputStream, Storage.GetFullDirectoryPath(package.Code), true, "", "");
            }

            Response.End();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = (this.ProfileUser != null) ? this.ProfileUser.DisplayName : string.Empty;

            if (!Page.IsPostBack) {
                if (this.ProfileUser == null) {
                    throw new HttpException(404, "Profile not found");
                }

                if (this.ProfileUser == this.CurrentUser) {
                    using (DataClassesDataContext db = new DataClassesDataContext()) {
                        var shared = (from transfer in db.Transfers
                                      where transfer.Package.SenderMail == this.CurrentUser.Mail
                                      orderby transfer.CreatedAt descending
                                      select transfer).Take(10);

                        DlSharedByUser.DataSource = shared;
                        DlSharedByUser.DataBind();

                        var received = (from transfer in db.Transfers
                                        where transfer.RecipientMail == this.CurrentUser.Mail
                                        orderby transfer.CreatedAt descending
                                        select transfer).Take(10);

                        //var requestedFromUser = from i in db.Invitations
                        //                        where i.RecipientMail == this.CurrentUser.Mail
                        //                        orderby i.CreatedAt descending
                        //                        select i;

                        DlRequestedFiles.DataSource = received;
                        DlRequestedFiles.DataBind();

                        var invited = (from invitation in db.Invitations
                                       where invitation.SenderMail == this.CurrentUser.Mail
                                       orderby invitation.CreatedAt descending
                                       select invitation).Take(10);

                        DlInvitedUsers.DataSource = invited;
                        DlInvitedUsers.DataBind();
                    }
                }
            }
        }
Ejemplo n.º 10
0
        protected void BtnCleanup_Click(object sender, EventArgs e)
        {
            int cleanedPackages = 0;
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                // get all expired packages
                var expiredPackages = ExpiredPackages(db);

                log.DebugFormat("Cleaning out {0} packages which are too old", expiredPackages.Count());

                // delete packages from file size and from database
                expiredPackages.ToList().ForEach(delegate(Package p) {
                    if (Storage.DeletePath(p.Code)) {
                        cleanedPackages++;
                        p.Status = (char)PackageStatus.Expired;
                        //db.Packages.DeleteOnSubmit(p);
                    }
                });

                db.SubmitChanges();
            }

            (this.Master as SiteMasterPage).Flash(string.Format("Cleaned up {0} packages", cleanedPackages));
        }
Ejemplo n.º 11
0
        protected void BtnShare_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["Files[]"])) {
                ValidationError.Display(_("No files uploaded"));
            }

            if (!Page.IsValid) {
                (this.Master as SiteMasterPage).Flash(_("You did not provide files to share"));
                return;
            }

            string[] fileHashes = Request["Files[]"].Split(',');

            using (DataClassesDataContext db = new DataClassesDataContext()) {
                Package p = db.Packages.SingleOrDefault(pkg => pkg.Code == HfToken.Value);
                if (p == null) {
                    // FIXME: this "if" section should be removed once Flash code has been updated to files immediately as well
                    p = new Package() {
                        Code = HfToken.Value,
                        SenderMail = this.Invitation.RecipientMail,
                        Message = TbxMessage.Text,
                        Status = (char)PackageStatus.Open,
                        Scanned = false,
                        ExpiresAt = DateTime.Now.AddDays(14),
                        CreatedAt = DateTime.UtcNow
                    };

                    foreach (string fileHash in fileHashes) {
                        Commanigy.Transmit.Data.File f = new Commanigy.Transmit.Data.File() {
                            CreatedAt = DateTime.UtcNow,
                            FileHash = fileHash,
                            FileSize = Storage.GetFileSize(p.Code, fileHash),
                            Package = p,
                        };
                        db.Files.InsertOnSubmit(f);
                    }
                }
                else {
                    p.SenderMail = this.Invitation.RecipientMail;
                    p.Message = TbxMessage.Text;
                }

                db.SubmitChanges();
            }

            // get fresh copy of package
            Package package = Package.FindByCode(HfToken.Value);

            log.Debug("Packing files into ZIP archive for faster (initial) downloads by clients");
            new Thread(new ParameterizedThreadStart(delegate(object data) {
                Package uploadedPackage = data as Package;
                Storage.Pack(uploadedPackage.Code);
            })).Start(package);

            // generate unique token allowing recipient (requester) to download file
            string uniqueHash = package.Code;

            // look up user requesting files (this should always resolve to a user) unless that
            // user has been disabled before file has been uploaded
            AuthenticatedUser recipientUser = Locator.FindByMail(this.Invitation.SenderMail);

            Dictionary<string, string> tokens = new Dictionary<string, string>();
            tokens.Add("CompanyName", TransmitSettings.Instance.Setting.CompanyName);
            tokens.Add("Sender.Mail", this.Invitation.RecipientMail);
            tokens.Add("Sender.DisplayName", this.Invitation.RecipientDisplayName);
            tokens.Add("Recipient.Mail", this.Invitation.SenderMail);
            tokens.Add("Recipient.DisplayName", (recipientUser != null) ? recipientUser.DisplayName : this.Invitation.SenderDisplayName);
            tokens.Add("Mail.Message", TbxMessage.Text ?? string.Empty);
            tokens.Add("Package.Code", package.Code);
            tokens.Add("Package.Files", PackageHelper.FilesToMailHtml(package.Files.ToList()));
            tokens.Add("File.Location", string.Format("{0}/receive.aspx?h={1}", UserHelper.GetSiteUrl(recipientUser), uniqueHash));

            MailHelper.Send(TransmitSettings.Instance.Setting.UploadMailSubject, TransmitSettings.Instance.Setting.UploadMailBodyPlain, TransmitSettings.Instance.Setting.UploadMailBodyHtml, tokens);

            this.Response.Redirect("~/upload.success.aspx", true);
        }
Ejemplo n.º 12
0
 public void Reload()
 {
     using (DataClassesDataContext db = new DataClassesDataContext()) {
         setting = db.Settings.First();
     }
 }
Ejemplo n.º 13
0
 private Invitation LoadInvitation(string invitationCode)
 {
     using (DataClassesDataContext db = new DataClassesDataContext()) {
         return db.Invitations.SingleOrDefault(invitation => invitation.Code == invitationCode);
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnShare_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request["Recipients[]"])) {
                ValidationError.Display(_("No recipients specified"));
            }

            if (string.IsNullOrEmpty(Request["Files[]"])) {
                ValidationError.Display(_("No files uploaded"));
            }

            if (!Page.IsValid) {
                ValidationSummary.HeaderText = _("Please correct the following:");
                return;
            }

            using (DataClassesDataContext db = new DataClassesDataContext()) {
                Package p = db.Packages.SingleOrDefault(pkg => pkg.Code == HfToken.Value);
                if (p == null) {
                    // FIXME: this "if" section should be removed once Flash code has been updated to files immediately as well
                    p = new Package() {
                        Code = HfToken.Value,
                        SenderMail = this.CurrentUser.Mail,
                        Message = TbxMessage.Text,
                        Status = (char)PackageStatus.Open,
                        Scanned = false,
                        ExpiresAt = DateTime.Now.AddDays(14),
                        CreatedAt = DateTime.UtcNow
                    };

                    string[] fileHashes = Request["Files[]"].Split(',');

                    foreach (string fileHash in fileHashes) {
                        db.Files.InsertOnSubmit(new File() {
                            CreatedAt = DateTime.UtcNow,
                            FileHash = fileHash,
                            FileSize = Storage.GetFileSize(p.Code, fileHash),
                            Package = p,
                        });
                    }
                }
                else {
                    p.SenderMail = this.CurrentUser.Mail;
                    p.Message = TbxMessage.Text;
                }

                db.SubmitChanges();
            }

            // get fresh copy of package
            Package package = Package.FindByCode(HfToken.Value);

            string[] recipients = Request["Recipients[]"].Split(',');

            log.DebugFormat("Packing files into ZIP archive {0} for faster (initial) downloads by clients", package.Code);
            new Thread(new ParameterizedThreadStart(delegate(object data) {
                Package uploadedPackage = data as Package;
                Storage.Pack(uploadedPackage.Code);

                ScanPackage(uploadedPackage);

                NotifyRecipients(uploadedPackage, recipients);
            })).Start(package);

            log.DebugFormat("User {0} completed sharing", this.CurrentUser);
            this.Response.Redirect("~/share.success.aspx", true);
        }
Ejemplo n.º 15
0
 private void ScanPackage(Package package)
 {
     using (DataClassesDataContext db = new DataClassesDataContext()) {
         package.Scanned = PackageHelper.Scan(package);
         db.SubmitChanges();
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Notify all recipients about new, shared downloadable package.
        /// </summary>
        /// <param name="package">Recently uploaded package</param>
        /// <param name="recipients">An array of recipient emails</param>
        private void NotifyRecipients(Package package, string[] recipients)
        {
            log.DebugFormat("User {0} is dispatching share emails to {1} recipients", this.CurrentUser, recipients.Length);
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                foreach (string recipientEmail in recipients) {
                    NotifyRecipient(package, this.CurrentUser.Mail, this.CurrentUser.DisplayName, recipientEmail, TbxMessage.Text);

                    Transfer t = new Transfer() {
                        CreatedAt = DateTime.UtcNow,
                        PackageID = package.ID,
                        RecipientMail = recipientEmail
                    };
                    db.Transfers.InsertOnSubmit(t);
                }
                db.SubmitChanges();
            }
        }
Ejemplo n.º 17
0
 private IQueryable<Package> ExpiredPackages(DataClassesDataContext db)
 {
     return from p in db.Packages
            where p.ExpiresAt < DateTime.UtcNow &&
            p.Status == (char)PackageStatus.Open
            select p;
 }
Ejemplo n.º 18
0
        public static string t(string v, params object[] a)
        {
            string key = Thread.CurrentThread.CurrentCulture.ToString() + " " + HashString(v);

            Dictionary<string, string> messages = HttpContext.Current.Cache["Transmit.Messages"] as Dictionary<string, string>;
            if (messages == null) {
                log.InfoFormat("Reading localized messages");
                messages = new Dictionary<string, string>();

                using (DataClassesDataContext db = new DataClassesDataContext()) {
                    var localizedMessages = from msg in db.Messages
                                            select msg;
                    foreach (var m in localizedMessages) {
                        messages.Add(string.Format("{0} {1}", m.Culture, m.LookupKey), m.LocalizedMessage);
                    }
                }

                HttpContext.Current.Cache.Add("Transmit.Messages", messages, null, Cache.NoAbsoluteExpiration, new TimeSpan(4, 0, 0), CacheItemPriority.Default, null);
            }

            if (messages.ContainsKey(key)) {
                return string.Format(messages[key], a);
            }

            log.DebugFormat("No localization for {0} => {1}", key, v);
            StoreLocalizedMessage(key, v);

            return string.Format(v, a);

            //string filename = "c:\\temp\\localization.resources";
            //string key = v.ToLower().Replace(" ", "_").Replace("\"", "_").Replace(".", "_");

            //if (!new FileInfo(filename).Exists) {
            //    ResourceWriter writer = new ResourceWriter(filename);
            //    writer.AddResource(key, v);
            //    writer.Generate();
            //    writer.Close();
            //    log.Debug("Writing new resource file");
            //}

            //log.Debug("looking at key: " + key);

            //ResourceSet rs = new ResourceSet(filename);
            //object o = rs.GetObject(key);
            //log.Debug("got object = " + o);

            //string x = rs.GetString(key);
            //log.Debug("got string = " + o);
            //if (x != null) {
            //    v = x;
            //}
            ////Console.WriteLine(Rs.GetDefaultReader().ToString());
            //rs.Close();

            //try {
            //    //string b = HttpContext.GetLocalResourceObject(HttpContext.Current.Request.Path, "test") as string;
            //    //if (b != null) {
            //    //    v = "OK! " + b;
            //    //}
            //}
            //catch (InvalidOperationException) {
            //}

            //			return string.Format(v, a);
        }
Ejemplo n.º 19
0
        private static void StoreLocalizedMessage(string key, string v)
        {
            string[] keyHash = key.Split(' ');

            using (DataClassesDataContext db = new DataClassesDataContext()) {
                Message m = db.Messages.FirstOrDefault(a => a.LookupKey == keyHash[1] && a.Culture == keyHash[0]);
                if (m == null) {
                    m = new Message {
                        Culture = keyHash[0],
                        LookupKey = keyHash[1],
                        LookupMessage = v,
                        LocalizedMessage = v, // default to standard lookup message
                        CreatedAt = DateTime.UtcNow
                    };

                    db.Messages.InsertOnSubmit(m);
                    db.SubmitChanges();
                }
            }
        }
Ejemplo n.º 20
0
 private string[] GetAvailableDirectories(DataClassesDataContext db)
 {
     var openPackages = OpenPackageCodes(db);
     string[] availableDirectories = Storage.GetDirectories();
     return Array.FindAll(availableDirectories, delegate(string v) {
         return !openPackages.Contains(v);
     });
 }
Ejemplo n.º 21
0
 private IQueryable<string> OpenPackageCodes(DataClassesDataContext db)
 {
     return from p in db.Packages
            where p.ExpiresAt >= DateTime.UtcNow &&
            p.Status == (char)PackageStatus.Open
            select p.Code;
 }
Ejemplo n.º 22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            using (DataClassesDataContext db = new DataClassesDataContext()) {
                // get all expired packages after page has loaded and
                // "cleanup" method has been invoked
                var expiredPackages = ExpiredPackages(db);

                DlExpiredPackages.DataSource = expiredPackages;
                DlExpiredPackages.DataBind();

                DlAvailableDirectories.DataSource = GetAvailableDirectories(db);
                DlAvailableDirectories.DataBind();
            }
        }
Ejemplo n.º 23
0
 protected void BtnDeleteUnattachedPackages_Click(object sender, EventArgs e)
 {
     using (DataClassesDataContext db = new DataClassesDataContext()) {
         Storage.PurgeDirectories(GetAvailableDirectories(db));
     }
 }