Esempio n. 1
0
        /// <summary>
        /// Verifica o tempo de vida de todos os ficheiros
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public static bool VerifyUFilesDate(int uid)
        {
            DataBaseManager db       = new DataBaseManager();
            List <Filettl>  f        = db.GetUFiles(uid);
            List <Filettl>  toRemove = f.FindAll(x => DateTime.Now.Subtract(x.FVal) > new TimeSpan(0, 0, 0));

            toRemove.ForEach(x => { DeleteUserFile(x.Uid, x.FName); db.RemoveFilettl(x.Uid, x.FName); });
            return(null != toRemove);

            //DataBaseManager db = new DataBaseManager();
            //List<Filettl> f = db.GetUFiles(uid);
            //List<Filettl> toRemove = f.FindAll(x => DateTime.Now.Subtract(x.FVal) > new TimeSpan(0, 0, 0));
            //if (f != null)
            //{
            //    toRemove.ForEach(x =>
            //    {
            //        DeleteUserFile(x.Uid, x.FName);
            //        db.RemoveFilettl(x.Uid, x.FName);
            //    });
            //    return true;
            //}
            //else return false;

            //DataBaseManager db = new DataBaseManager();
            //List<Filettl> f = db.GetUFiles(uid);
            //if (f != null)
            //{
            //    foreach (Filettl t in f)
            //    {
            //        DateTime now = DateTime.Now;
            //        TimeSpan diff = now.Subtract(t.FVal);
            //        if (diff > new TimeSpan(0, 0, 0))
            //        {
            //            DeleteUserFile(t.Uid, t.FName);
            //            db.RemoveFilettl(t.Uid,t.FName);
            //            return true;
            //        }
            //    }
            //}
            //return false;
        }
Esempio n. 2
0
        static Random rand         = new Random();       //Gerador de números á sorte para os tokens
        #endregion
        #region Methods

        /// <summary>
        /// Verfica se os ficheiros de um dado utilizador estão dentro do prazo de vida
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static bool VerifyUFilesDate(int uid, string filename)
        {
            DataBaseManager db = new DataBaseManager();
            List <Filettl>  f  = db.GetUFiles(uid);

            if (f != null)
            {
                foreach (Filettl t in f)
                {
                    if (t.FName.CompareTo(filename) == 0)
                    {
                        DateTime now  = DateTime.Now;
                        TimeSpan diff = now.Subtract(t.FVal);
                        if (diff > new TimeSpan(0, 0, 0))
                        {
                            DeleteUserFile(t.Uid, t.FName);
                            db.RemoveFilettl(uid, t.FName);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }