public static HAP.Data.Quota.QuotaInfo GetQuota(string username, string share) { QuotaServer server = null; foreach (QuotaServer s in hapConfig.Current.MyFiles.QuotaServers) { if (share.ToLower().StartsWith(s.Expression.Replace("%username%", username).ToLower())) { server = s; } } if (server == null) { throw new Exception("Can't find quota server"); } string endPointAddr = "net.tcp://" + server.Server + ":8010/HAPQuotaService"; NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress endpointAddress = new EndpointAddress(endPointAddr); ServiceClient c = new ServiceClient(tcpBinding, endpointAddress); if (server.FSRM) { return(c.GetQuotaFromPath(string.IsNullOrWhiteSpace(server.DFSTarget) ? share : server.DFSTarget.ToLower().Replace("%username%", username.ToLower()))); } return(c.GetQuota(username, server.Drive.ToString() + ":")); }
public int UpdateQServer(string origserver, string origexpression, string server, string expression, string drive) { origexpression = origexpression.Replace('/', '\\'); expression = expression.Replace('/', '\\'); hapConfig Config = HttpContext.Current.Cache["tempConfig"] as hapConfig; QuotaServer q = Config.MyFiles.QuotaServers.Find(origserver, origexpression); q.Server = server; q.Drive = drive.ToCharArray()[0]; q.Expression = expression; Config.MyFiles.QuotaServers.Update(origserver, origexpression, q); return(0); }