Ejemplo n.º 1
0
        public QuotaInfo GetQuota(string username, string fileshare)
        {
            DiskQuotaControlClass dqc = new DiskQuotaControlClass();
            QuotaInfo             qi  = new QuotaInfo();

            //Initializes the control to the specified path
            dqc.Initialize(fileshare, true);
            qi.Used  = dqc.FindUser(username).QuotaUsed;
            qi.Total = dqc.FindUser(username).QuotaLimit;
            return(qi);
        }
Ejemplo n.º 2
0
        public QuotaInfo GetQuotaFromPath(string path)
        {
            IFsrmQuotaManager FSRMQuotaManager = new FsrmQuotaManagerClass();
            IFsrmQuota        Quota            = null;
            QuotaInfo         q      = new QuotaInfo();
            Decimal           qFree  = 0;
            Decimal           qTotal = 0;
            Decimal           qUsed  = 0;

            try
            {
                Quota   = FSRMQuotaManager.GetQuota(path);
                qFree   = Math.Round((Decimal)Quota.QuotaLimit - (Decimal)Quota.QuotaUsed, 0);
                qUsed   = (Decimal)Quota.QuotaUsed;
                qTotal  = (Decimal)Quota.QuotaLimit;
                q.Free  = Convert.ToDouble(qFree.ToString());
                q.Total = Convert.ToDouble(qTotal.ToString());
                q.Used  = Convert.ToDouble(qUsed.ToString());
            }
            catch
            {
                path = GetPath(path);
                try
                {
                    Quota   = FSRMQuotaManager.GetQuota(path);
                    qFree   = (Decimal)Quota.QuotaLimit - (Decimal)Quota.QuotaUsed;
                    qUsed   = (Decimal)Quota.QuotaUsed;
                    qTotal  = (Decimal)Quota.QuotaLimit;
                    q.Free  = Convert.ToDouble(qFree.ToString());
                    q.Total = Convert.ToDouble(qTotal.ToString());
                    q.Used  = Convert.ToDouble(qUsed.ToString());
                }
                catch
                {
                }
            }
            return(q);
        }