Merge branch 'master' of https://github.com/ONLYOFFICE/CommunityServer-AspNetCore
This commit is contained in:
commit
937c1de58f
@ -90,11 +90,10 @@ namespace ASC.Api.Core
|
||||
if (data.Length < 7) throw new ArgumentException("invalid date time format");
|
||||
|
||||
var offsetPart = data.Substring(data.Length - 6, 6);
|
||||
DateTime dateTime;
|
||||
if (DateTime.TryParseExact(data, Formats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out dateTime))
|
||||
if (DateTime.TryParseExact(data, Formats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var dateTime))
|
||||
{
|
||||
//Parse time
|
||||
TimeSpan tzOffset = TimeSpan.Zero;
|
||||
var tzOffset = TimeSpan.Zero;
|
||||
if (offsetPart.Contains(":") && TimeSpan.TryParse(offsetPart.TrimStart('+'), out tzOffset))
|
||||
{
|
||||
return new ApiDateTime(dateTime, tzOffset);
|
||||
@ -277,7 +276,7 @@ namespace ASC.Api.Core
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
DateTime localUtcTime = UtcTime;
|
||||
var localUtcTime = UtcTime;
|
||||
|
||||
if (!UtcTime.Equals(DateTime.MinValue))
|
||||
localUtcTime = UtcTime.Add(TimeZoneOffset);
|
||||
|
@ -43,7 +43,7 @@ namespace ASC.Common.Data.Sql.Expressions
|
||||
|
||||
public override string ToString(ISqlDialect dialect)
|
||||
{
|
||||
string format = exp1 is JunctionExp && ((JunctionExp)exp1).and != and ? "({0})" : "{0}";
|
||||
var format = exp1 is JunctionExp && ((JunctionExp)exp1).and != and ? "({0})" : "{0}";
|
||||
format += " {1} ";
|
||||
format += exp2 is JunctionExp && ((JunctionExp)exp2).and != and ? "({2})" : "{2}";
|
||||
return Not
|
||||
|
@ -70,11 +70,11 @@ namespace ASC.Common.Data.Sql
|
||||
sql.Append(replaceExists ? "replace" : "insert");
|
||||
}
|
||||
sql.AppendFormat(" into {0}", table);
|
||||
bool identityInsert = IsIdentityInsert();
|
||||
var identityInsert = IsIdentityInsert();
|
||||
if (0 < columns.Count)
|
||||
{
|
||||
sql.Append("(");
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
for (var i = 0; i < columns.Count; i++)
|
||||
{
|
||||
if (identityInsert && identityPosition == i) continue;
|
||||
sql.AppendFormat("{0},", columns[i]);
|
||||
@ -87,7 +87,7 @@ namespace ASC.Common.Data.Sql
|
||||
return sql.ToString();
|
||||
}
|
||||
sql.Append(" values (");
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
for (var i = 0; i < values.Count; i++)
|
||||
{
|
||||
if (identityInsert && identityPosition == i)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ namespace ASC.Common.Data.Sql
|
||||
|
||||
if (0 < joins.Count)
|
||||
{
|
||||
foreach (JoinInfo join in joins)
|
||||
foreach (var join in joins)
|
||||
{
|
||||
if (join.JoinType == SqlJoin.Inner) sql.Append(" inner join ");
|
||||
if (join.JoinType == SqlJoin.LeftOuter) sql.Append(" left outer join ");
|
||||
@ -108,7 +108,7 @@ namespace ASC.Common.Data.Sql
|
||||
if (0 < groups.Count)
|
||||
{
|
||||
sql.Append(" group by ");
|
||||
foreach (object group in groups)
|
||||
foreach (var group in groups)
|
||||
{
|
||||
sql.AppendFormat("{0}, ", group.ToString());
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace ASC.Common.Data.Sql
|
||||
var parameters = new List<object>();
|
||||
columns.ForEach(column => parameters.AddRange(column.GetParameters()));
|
||||
tables.ForEach(table => parameters.AddRange(table.GetParameters()));
|
||||
foreach (JoinInfo join in joins)
|
||||
foreach (var join in joins)
|
||||
{
|
||||
parameters.AddRange(join.With.GetParameters());
|
||||
parameters.AddRange(join.On.GetParameters());
|
||||
|
@ -89,7 +89,7 @@ namespace ASC.Common.Data.Sql
|
||||
parameters.AddRange(@join.On.GetParameters());
|
||||
}
|
||||
|
||||
foreach (object parameter in sets.Values)
|
||||
foreach (var parameter in sets.Values)
|
||||
{
|
||||
if (parameter is ISqlInstruction)
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ public static class StreamExtension
|
||||
if (dstStream == null) throw new ArgumentNullException("dstStream");
|
||||
|
||||
var buffer = new byte[BufferSize];
|
||||
int totalRead = 0;
|
||||
var totalRead = 0;
|
||||
int readed;
|
||||
while ((readed = srcStream.Read(buffer, 0, length - totalRead > BufferSize ? BufferSize : length - totalRead)) > 0 && totalRead < length)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace ASC.Common.Security
|
||||
var num2 = 161803398 - num4;
|
||||
seeds[seeds.Length - 1] = num2;
|
||||
var num3 = 1;
|
||||
for (int i = 1; i < seeds.Length - 1; i++)
|
||||
for (var i = 1; i < seeds.Length - 1; i++)
|
||||
{
|
||||
var index = (21 * i) % (seeds.Length - 1);
|
||||
seeds[index] = num3;
|
||||
@ -60,9 +60,9 @@ namespace ASC.Common.Security
|
||||
}
|
||||
num2 = seeds[index];
|
||||
}
|
||||
for (int j = 1; j < 5; j++)
|
||||
for (var j = 1; j < 5; j++)
|
||||
{
|
||||
for (int k = 1; k < seeds.Length; k++)
|
||||
for (var k = 1; k < seeds.Length; k++)
|
||||
{
|
||||
seeds[k] -= seeds[1 + ((k + 30) % (seeds.Length - 1))];
|
||||
if (seeds[k] < 0)
|
||||
@ -107,7 +107,7 @@ namespace ASC.Common.Security
|
||||
{
|
||||
inextp = 1;
|
||||
}
|
||||
int num = seeds[inext] - seeds[inextp];
|
||||
var num = seeds[inext] - seeds[inextp];
|
||||
if (num == int.MaxValue)
|
||||
{
|
||||
num--;
|
||||
|
@ -49,7 +49,7 @@ namespace ASC.Common.Security.Authorizing
|
||||
if (actions == null || actions.Length == 0) throw new ArgumentNullException("actions");
|
||||
Subject = subject;
|
||||
Actions = actions;
|
||||
string sactions = "";
|
||||
var sactions = "";
|
||||
Array.ForEach(actions, action => { sactions += action.ToString() + ", "; });
|
||||
_Message = String.Format(
|
||||
"\"{0}\" access denied \"{1}\"",
|
||||
@ -96,10 +96,10 @@ namespace ASC.Common.Security.Authorizing
|
||||
if (denyActions == null || denyActions.Length == 0) throw new ArgumentNullException("denyActions");
|
||||
if (actions.Length != denySubjects.Length || actions.Length != denyActions.Length)
|
||||
throw new ArgumentException();
|
||||
string reasons = "";
|
||||
for (int i = 0; i < actions.Length; i++)
|
||||
var reasons = "";
|
||||
for (var i = 0; i < actions.Length; i++)
|
||||
{
|
||||
string reason = "";
|
||||
var reason = "";
|
||||
if (denySubjects[i] != null && denyActions[i] != null)
|
||||
reason = String.Format("{0}:{1} access denied {2}.",
|
||||
actions[i].Name,
|
||||
@ -112,9 +112,9 @@ namespace ASC.Common.Security.Authorizing
|
||||
reason += ", ";
|
||||
reasons += reason;
|
||||
}
|
||||
string sactions = "";
|
||||
var sactions = "";
|
||||
Array.ForEach(actions, action => { sactions += action.ToString() + ", "; });
|
||||
string message = String.Format(
|
||||
var message = String.Format(
|
||||
"\"{0}\" access denied \"{1}\". Cause: {2}.",
|
||||
(subject is IRole ? "role:" : "") + subject.Name,
|
||||
sactions,
|
||||
|
@ -66,8 +66,8 @@ namespace ASC.Common.Security.Authorizing
|
||||
|
||||
public IEnumerable<IRole> GetObjectRoles(ISubject account)
|
||||
{
|
||||
IEnumerable<IRole> roles = currSecObjProvider.GetObjectRoles(account, currObjId, callContext);
|
||||
foreach (IRole role in roles)
|
||||
var roles = currSecObjProvider.GetObjectRoles(account, currObjId, callContext);
|
||||
foreach (var role in roles)
|
||||
{
|
||||
if (!callContext.RolesList.Contains(role)) callContext.RolesList.Add(role);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace ASC.Security.Cryptography
|
||||
|
||||
public static byte[] Encrypt(byte[] data)
|
||||
{
|
||||
Rijndael hasher = Rijndael.Create();
|
||||
var hasher = Rijndael.Create();
|
||||
hasher.Key = EKey();
|
||||
hasher.IV = new byte[hasher.BlockSize >> 3];
|
||||
using (var ms = new MemoryStream())
|
||||
@ -64,7 +64,7 @@ namespace ASC.Security.Cryptography
|
||||
|
||||
public static byte[] Decrypt(byte[] data)
|
||||
{
|
||||
Rijndael hasher = Rijndael.Create();
|
||||
var hasher = Rijndael.Create();
|
||||
hasher.Key = EKey();
|
||||
hasher.IV = new byte[hasher.BlockSize >> 3];
|
||||
|
||||
@ -72,7 +72,7 @@ namespace ASC.Security.Cryptography
|
||||
using (var ss = new CryptoStream(ms, hasher.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
{
|
||||
var buffer = new byte[data.Length];
|
||||
int size = ss.Read(buffer, 0, buffer.Length);
|
||||
var size = ss.Read(buffer, 0, buffer.Length);
|
||||
hasher.Clear();
|
||||
var newBuffer = new byte[size];
|
||||
Array.Copy(buffer, newBuffer, size);
|
||||
|
@ -39,7 +39,7 @@ namespace ASC.Common.Tests.Security.Cryptography
|
||||
[Test]
|
||||
public void DoHash()
|
||||
{
|
||||
string str = "Hello, Jhon!";
|
||||
var str = "Hello, Jhon!";
|
||||
|
||||
Assert.AreEqual(
|
||||
Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(str))),
|
||||
|
@ -37,7 +37,7 @@ namespace ASC.Common.Tests.Utils
|
||||
[Test]
|
||||
public void GetTextBr()
|
||||
{
|
||||
string html = "Hello";
|
||||
var html = "Hello";
|
||||
Assert.AreEqual("Hello", HtmlUtil.GetText(html));
|
||||
|
||||
html = "Hello anton";
|
||||
@ -49,7 +49,7 @@ namespace ASC.Common.Tests.Utils
|
||||
|
||||
public void Hard()
|
||||
{
|
||||
string html = @"<a href=""http://mediaserver:8080/Products/Community/Modules/Blogs/ViewBlog.aspx?blogID=94fae49d-2faa-46d3-bf34-655afbc6f7f4""><font size=""+1"">XXX</font></a>
|
||||
var html = @"<a href=""http://mediaserver:8080/Products/Community/Modules/Blogs/ViewBlog.aspx?blogID=94fae49d-2faa-46d3-bf34-655afbc6f7f4""><font size=""+1"">XXX</font></a>
|
||||
<div class=""moz-text-html"" lang=""x-unicode""><hr />
|
||||
A "b" c, d:<br />
|
||||
<blockquote>mp3 "s"<br />
|
||||
|
@ -253,7 +253,7 @@ namespace ASC.Common.Threading.Workers
|
||||
{
|
||||
try
|
||||
{
|
||||
bool stopAfterFinsih = false;
|
||||
var stopAfterFinsih = false;
|
||||
if (state != null && state is bool)
|
||||
{
|
||||
stopAfterFinsih = (bool)state;
|
||||
@ -279,7 +279,7 @@ namespace ASC.Common.Threading.Workers
|
||||
try
|
||||
{
|
||||
localAction(item.Item);
|
||||
bool fallSleep = false;
|
||||
var fallSleep = false;
|
||||
lock (Items)
|
||||
{
|
||||
PostComplete(item);
|
||||
|
@ -195,8 +195,7 @@ namespace System.Web
|
||||
s = HttpUtility.UrlDecode(s);
|
||||
}
|
||||
|
||||
Uri result;
|
||||
Uri.TryCreate(s, UriKind.Absolute, out result);
|
||||
Uri.TryCreate(s, UriKind.Absolute, out var result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ namespace ASC.Common.Utils
|
||||
public static string Generate(int length)
|
||||
{
|
||||
const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
StringBuilder res = new StringBuilder();
|
||||
Random rnd = new Random();
|
||||
var res = new StringBuilder();
|
||||
var rnd = new Random();
|
||||
while (0 < length--)
|
||||
{
|
||||
res.Append(valid[rnd.Next(valid.Length)]);
|
||||
|
@ -182,9 +182,8 @@ namespace ASC.Common.Utils
|
||||
|
||||
if (string.IsNullOrEmpty(offsetStr)) return null;
|
||||
|
||||
TimeSpan offset;
|
||||
|
||||
if (!TimeSpan.TryParse(offsetStr, out offset))
|
||||
if (!TimeSpan.TryParse(offsetStr, out var offset))
|
||||
return null;
|
||||
|
||||
return systemTimeZones.FirstOrDefault(tz => tz.BaseUtcOffset == offset);
|
||||
|
@ -85,9 +85,8 @@ namespace ASC.Common.Utils
|
||||
|
||||
using (var writer = new StringWriter())
|
||||
{
|
||||
Template template;
|
||||
var key = templateText.GetHashCode().ToString();
|
||||
if (!patterns.TryGetValue(key, out template))
|
||||
if (!patterns.TryGetValue(key, out var template))
|
||||
{
|
||||
template = Velocity.GetTemplate(templateText);
|
||||
patterns.TryAdd(key, template);
|
||||
|
@ -49,8 +49,8 @@ namespace ASC.Common.Utils
|
||||
|
||||
public static bool IsMatch(string pattern, string input, bool ignoreCase)
|
||||
{
|
||||
int offsetInput = 0;
|
||||
bool isAsterix = false;
|
||||
var offsetInput = 0;
|
||||
var isAsterix = false;
|
||||
int i;
|
||||
while (true)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ namespace ASC.Common.Web
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
foreach (IDisposable item in Items.Values)
|
||||
foreach (var item in Items.Values)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -155,10 +155,9 @@ namespace ASC.Core.Billing
|
||||
|
||||
foreach (var p in products)
|
||||
{
|
||||
string url;
|
||||
var paymentUrl = (Uri)null;
|
||||
var upgradeUrl = (Uri)null;
|
||||
if (paymentUrls.TryGetValue(p, out url) && !string.IsNullOrEmpty(url))
|
||||
if (paymentUrls.TryGetValue(p, out var url) && !string.IsNullOrEmpty(url))
|
||||
{
|
||||
paymentUrl = new Uri(url);
|
||||
}
|
||||
@ -359,8 +358,7 @@ namespace ASC.Core.Billing
|
||||
return default;
|
||||
}
|
||||
var sep = CultureInfo.InvariantCulture.NumberFormat.CurrencyDecimalSeparator;
|
||||
decimal value;
|
||||
return Decimal.TryParse(xelement.Value.Replace(".", sep).Replace(",", sep), NumberStyles.Currency, CultureInfo.InvariantCulture, out value) ? value : default;
|
||||
return Decimal.TryParse(xelement.Value.Replace(".", sep).Replace(",", sep), NumberStyles.Currency, CultureInfo.InvariantCulture, out var value) ? value : default;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
|
@ -286,8 +286,7 @@ namespace ASC.Core.Billing
|
||||
|
||||
ResetCacheExpiration();
|
||||
|
||||
Tuple<Uri, Uri> tuple;
|
||||
if (!string.IsNullOrEmpty(quota.AvangateId) && urls.TryGetValue(quota.AvangateId, out tuple))
|
||||
if (!string.IsNullOrEmpty(quota.AvangateId) && urls.TryGetValue(quota.AvangateId, out var tuple))
|
||||
{
|
||||
var result = tuple.Item2;
|
||||
|
||||
|
@ -46,8 +46,7 @@ namespace ASC.Core.Caching
|
||||
|
||||
public IEnumerable<AzRecord> Get(string objectId)
|
||||
{
|
||||
List<AzRecord> aces;
|
||||
byObjectId.TryGetValue(objectId ?? string.Empty, out aces);
|
||||
byObjectId.TryGetValue(objectId ?? string.Empty, out var aces);
|
||||
return aces ?? new List<AzRecord>();
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,7 @@ namespace ASC.Core.Caching
|
||||
var users = GetUsers(tenant);
|
||||
lock (users)
|
||||
{
|
||||
UserInfo u;
|
||||
users.TryGetValue(id, out u);
|
||||
users.TryGetValue(id, out var u);
|
||||
return u;
|
||||
}
|
||||
}
|
||||
@ -198,8 +197,7 @@ namespace ASC.Core.Caching
|
||||
var groups = GetGroups(tenant);
|
||||
lock (groups)
|
||||
{
|
||||
Group g;
|
||||
groups.TryGetValue(id, out g);
|
||||
groups.TryGetValue(id, out var g);
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
@ -324,8 +324,7 @@ namespace ASC.Core.Common.Configuration
|
||||
|
||||
public static Consumer GetByName(string name)
|
||||
{
|
||||
object result;
|
||||
if (Builder.TryResolveNamed(name, typeof(Consumer), out result))
|
||||
if (Builder.TryResolveNamed(name, typeof(Consumer), out var result))
|
||||
{
|
||||
return (Consumer)result;
|
||||
}
|
||||
@ -335,8 +334,7 @@ namespace ASC.Core.Common.Configuration
|
||||
|
||||
public static T GetByName<T>(string name) where T : Consumer, new()
|
||||
{
|
||||
object result;
|
||||
if (Builder.TryResolveNamed(name, typeof(T), out result))
|
||||
if (Builder.TryResolveNamed(name, typeof(T), out var result))
|
||||
{
|
||||
return (T)result;
|
||||
}
|
||||
@ -346,8 +344,7 @@ namespace ASC.Core.Common.Configuration
|
||||
|
||||
public static T Get<T>() where T : Consumer, new()
|
||||
{
|
||||
T result;
|
||||
if (Builder.TryResolve(out result))
|
||||
if (Builder.TryResolve(out T result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
@ -63,9 +63,8 @@ namespace ASC.Core
|
||||
if (ConfigurationManager.AppSettings["core.enable-quota-cache"] == null)
|
||||
return true;
|
||||
|
||||
bool enabled;
|
||||
|
||||
return !bool.TryParse(ConfigurationManager.AppSettings["core.enable-quota-cache"], out enabled) || enabled;
|
||||
return !bool.TryParse(ConfigurationManager.AppSettings["core.enable-quota-cache"], out var enabled) || enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,9 +75,8 @@ namespace ASC.Core
|
||||
if (personalMaxSpace.HasValue)
|
||||
return personalMaxSpace.Value;
|
||||
|
||||
long value;
|
||||
|
||||
if (!long.TryParse(ConfigurationManager.AppSettings["core.personal.maxspace"], out value))
|
||||
if (!long.TryParse(ConfigurationManager.AppSettings["core.personal.maxspace"], out var value))
|
||||
value = long.MaxValue;
|
||||
|
||||
personalMaxSpace = value;
|
||||
@ -169,7 +168,7 @@ namespace ASC.Core
|
||||
{
|
||||
throw new ArgumentNullException("key");
|
||||
}
|
||||
byte[] bytes = tenantService.GetTenantSettings(tenant, key);
|
||||
var bytes = tenantService.GetTenantSettings(tenant, key);
|
||||
|
||||
var result = bytes != null ? Encoding.UTF8.GetString(Crypto.GetV(bytes, 2, false)) : null;
|
||||
|
||||
|
@ -86,13 +86,6 @@ namespace ASC.Core
|
||||
{
|
||||
if (!string.IsNullOrEmpty(cookie))
|
||||
{
|
||||
int tenant;
|
||||
Guid userid;
|
||||
string login;
|
||||
string password;
|
||||
int indexTenant;
|
||||
DateTime expire;
|
||||
int indexUser;
|
||||
|
||||
if (cookie.Equals("Bearer", StringComparison.InvariantCulture))
|
||||
{
|
||||
@ -106,7 +99,7 @@ namespace ASC.Core
|
||||
}
|
||||
log.InfoFormat("Empty Bearer cookie: {0} {1}", ipFrom, address);
|
||||
}
|
||||
else if (CookieStorage.DecryptCookie(cookie, out tenant, out userid, out login, out password, out indexTenant, out expire, out indexUser))
|
||||
else if (CookieStorage.DecryptCookie(cookie, out var tenant, out var userid, out var login, out var password, out var indexTenant, out var expire, out var indexUser))
|
||||
{
|
||||
if (tenant != CoreContext.TenantManager.GetCurrentTenant().TenantId)
|
||||
{
|
||||
|
@ -126,8 +126,7 @@ namespace TMResourceData
|
||||
|
||||
protected override ResourceSet InternalGetResourceSet(CultureInfo culture, bool createIfNotExists, bool tryParents)
|
||||
{
|
||||
ResourceSet set;
|
||||
resourceSets.TryGetValue(culture.Name, out set);
|
||||
resourceSets.TryGetValue(culture.Name, out var set);
|
||||
if (set == null)
|
||||
{
|
||||
var invariant = culture == CultureInfo.InvariantCulture ? base.InternalGetResourceSet(CultureInfo.InvariantCulture, true, true) : null;
|
||||
@ -291,8 +290,7 @@ namespace TMResourceData
|
||||
{
|
||||
try
|
||||
{
|
||||
string text;
|
||||
whiteLabelDictionary.TryRemove(tenantId, out text);
|
||||
whiteLabelDictionary.TryRemove(tenantId, out var text);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -314,8 +312,7 @@ namespace TMResourceData
|
||||
var tenant = CoreContext.TenantManager.GetCurrentTenant(false);
|
||||
if (tenant == null) return resourceValue;
|
||||
|
||||
string newText;
|
||||
if (whiteLabelDictionary.TryGetValue(tenant.TenantId, out newText))
|
||||
if (whiteLabelDictionary.TryGetValue(tenant.TenantId, out var newText))
|
||||
{
|
||||
var newTextReplacement = newText;
|
||||
|
||||
|
@ -147,8 +147,7 @@ namespace ASC.Core.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
SubscriptionMethod r;
|
||||
if (common.TryGetValue(key, out r))
|
||||
if (common.TryGetValue(key, out var r))
|
||||
{
|
||||
result.Remove(r);
|
||||
}
|
||||
@ -226,8 +225,7 @@ namespace ASC.Core.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
SubscriptionRecord r;
|
||||
if (common.TryGetValue(key, out r))
|
||||
if (common.TryGetValue(key, out var r))
|
||||
{
|
||||
result.Remove(r);
|
||||
}
|
||||
|
@ -93,8 +93,7 @@ namespace ASC.Notify
|
||||
{
|
||||
lock (channels)
|
||||
{
|
||||
ISenderChannel channel;
|
||||
channels.TryGetValue(senderName, out channel);
|
||||
channels.TryGetValue(senderName, out var channel);
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
|
@ -173,10 +173,10 @@ namespace ASC.Notify.Cron
|
||||
|
||||
public virtual bool IsSatisfiedBy(DateTime dateUtc)
|
||||
{
|
||||
DateTime test =
|
||||
var test =
|
||||
new DateTime(dateUtc.Year, dateUtc.Month, dateUtc.Day, dateUtc.Hour, dateUtc.Minute, dateUtc.Second).
|
||||
AddSeconds(-1);
|
||||
DateTime? timeAfter = GetTimeAfter(test);
|
||||
var timeAfter = GetTimeAfter(test);
|
||||
if (timeAfter.HasValue && timeAfter.Value.Equals(dateUtc))
|
||||
{
|
||||
return true;
|
||||
@ -196,12 +196,12 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
long difference = 1000;
|
||||
|
||||
DateTime lastDate =
|
||||
var lastDate =
|
||||
new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second).AddSeconds(-1);
|
||||
|
||||
while (difference == 1000)
|
||||
{
|
||||
DateTime newDate = GetTimeAfter(lastDate).Value;
|
||||
var newDate = GetTimeAfter(lastDate).Value;
|
||||
difference = (long)(newDate - lastDate).TotalMilliseconds;
|
||||
if (difference == 1000)
|
||||
{
|
||||
@ -262,14 +262,14 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
years = new TreeSet();
|
||||
}
|
||||
int exprOn = Second;
|
||||
var exprOn = Second;
|
||||
#if NET_20
string[] exprsTok = expression.Trim().Split(new char[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
#else
|
||||
string[] exprsTok = expression.Trim().Split(new[] { ' ', '\t', '\r', '\n' });
|
||||
var exprsTok = expression.Trim().Split(new[] { ' ', '\t', '\r', '\n' });
|
||||
#endif
|
||||
foreach (string exprTok in exprsTok)
|
||||
foreach (var exprTok in exprsTok)
|
||||
{
|
||||
string expr = exprTok.Trim();
|
||||
var expr = exprTok.Trim();
|
||||
if (expr.Length == 0)
|
||||
{
|
||||
continue;
|
||||
@ -290,8 +290,8 @@ namespace ASC.Notify.Cron
|
||||
throw new FormatException(
|
||||
"Support for specifying 'L' with other days of the week is not implemented");
|
||||
}
|
||||
string[] vTok = expr.Split(',');
|
||||
foreach (string v in vTok)
|
||||
var vTok = expr.Split(',');
|
||||
foreach (var v in vTok)
|
||||
{
|
||||
StoreExpressionVals(0, v, exprOn);
|
||||
}
|
||||
@ -305,11 +305,11 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
StoreExpressionVals(0, "*", Year);
|
||||
}
|
||||
TreeSet dow = GetSet(DayOfWeek);
|
||||
TreeSet dom = GetSet(DayOfMonth);
|
||||
var dow = GetSet(DayOfWeek);
|
||||
var dom = GetSet(DayOfMonth);
|
||||
|
||||
bool dayOfMSpec = !dom.Contains(NoSpec);
|
||||
bool dayOfWSpec = !dow.Contains(NoSpec);
|
||||
var dayOfMSpec = !dom.Contains(NoSpec);
|
||||
var dayOfWSpec = !dow.Contains(NoSpec);
|
||||
if (dayOfMSpec && !dayOfWSpec)
|
||||
{
|
||||
}
|
||||
@ -335,18 +335,18 @@ namespace ASC.Notify.Cron
|
||||
|
||||
protected virtual int StoreExpressionVals(int pos, string s, int type)
|
||||
{
|
||||
int incr = 0;
|
||||
int i = SkipWhiteSpace(pos, s);
|
||||
var incr = 0;
|
||||
var i = SkipWhiteSpace(pos, s);
|
||||
if (i >= s.Length)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
char c = s[i];
|
||||
var c = s[i];
|
||||
if ((c >= 'A') && (c <= 'Z') && (!s.Equals("L")) && (!s.Equals("LW")))
|
||||
{
|
||||
String sub = s.Substring(i, 3);
|
||||
var sub = s.Substring(i, 3);
|
||||
int sval;
|
||||
int eval = -1;
|
||||
var eval = -1;
|
||||
if (type == Month)
|
||||
{
|
||||
sval = GetMonthNumber(sub) + 1;
|
||||
@ -542,7 +542,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
else if (c >= '0' && c <= '9')
|
||||
{
|
||||
int val = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
var val = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
i++;
|
||||
if (i >= s.Length)
|
||||
{
|
||||
@ -553,7 +553,7 @@ namespace ASC.Notify.Cron
|
||||
c = s[i];
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
ValueSet vs = GetValue(val, s, i);
|
||||
var vs = GetValue(val, s, i);
|
||||
val = vs.theValue;
|
||||
i = vs.pos;
|
||||
}
|
||||
@ -570,14 +570,14 @@ namespace ASC.Notify.Cron
|
||||
|
||||
protected virtual int CheckNext(int pos, string s, int val, int type)
|
||||
{
|
||||
int end = -1;
|
||||
int i = pos;
|
||||
var end = -1;
|
||||
var i = pos;
|
||||
if (i >= s.Length)
|
||||
{
|
||||
AddToSet(val, end, -1, type);
|
||||
return i;
|
||||
}
|
||||
char c = s[pos];
|
||||
var c = s[pos];
|
||||
if (c == 'L')
|
||||
{
|
||||
if (type == DayOfWeek)
|
||||
@ -589,7 +589,7 @@ namespace ASC.Notify.Cron
|
||||
throw new FormatException(string.Format(CultureInfo.InvariantCulture,
|
||||
"'L' option is not valid here. (pos={0})", i));
|
||||
}
|
||||
TreeSet data = GetSet(type);
|
||||
var data = GetSet(type);
|
||||
data.Add(val);
|
||||
i++;
|
||||
return i;
|
||||
@ -605,7 +605,7 @@ namespace ASC.Notify.Cron
|
||||
throw new FormatException(string.Format(CultureInfo.InvariantCulture,
|
||||
"'W' option is not valid here. (pos={0})", i));
|
||||
}
|
||||
TreeSet data = GetSet(type);
|
||||
var data = GetSet(type);
|
||||
data.Add(val);
|
||||
i++;
|
||||
return i;
|
||||
@ -631,7 +631,7 @@ namespace ASC.Notify.Cron
|
||||
throw new FormatException(
|
||||
"A numeric value between 1 and 5 must follow the '#' option");
|
||||
}
|
||||
TreeSet data = GetSet(type);
|
||||
var data = GetSet(type);
|
||||
data.Add(val);
|
||||
i++;
|
||||
return i;
|
||||
@ -651,7 +651,7 @@ namespace ASC.Notify.Cron
|
||||
throw new FormatException(string.Format(CultureInfo.InvariantCulture,
|
||||
"'C' option is not valid here. (pos={0})", i));
|
||||
}
|
||||
TreeSet data = GetSet(type);
|
||||
var data = GetSet(type);
|
||||
data.Add(val);
|
||||
i++;
|
||||
return i;
|
||||
@ -660,7 +660,7 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
i++;
|
||||
c = s[i];
|
||||
int v = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
var v = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
end = v;
|
||||
i++;
|
||||
if (i >= s.Length)
|
||||
@ -671,8 +671,8 @@ namespace ASC.Notify.Cron
|
||||
c = s[i];
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
ValueSet vs = GetValue(v, s, i);
|
||||
int v1 = vs.theValue;
|
||||
var vs = GetValue(v, s, i);
|
||||
var v1 = vs.theValue;
|
||||
end = v1;
|
||||
i = vs.pos;
|
||||
}
|
||||
@ -680,7 +680,7 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
i++;
|
||||
c = s[i];
|
||||
int v2 = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
var v2 = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
i++;
|
||||
if (i >= s.Length)
|
||||
{
|
||||
@ -690,8 +690,8 @@ namespace ASC.Notify.Cron
|
||||
c = s[i];
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
ValueSet vs = GetValue(v2, s, i);
|
||||
int v3 = vs.theValue;
|
||||
var vs = GetValue(v2, s, i);
|
||||
var v3 = vs.theValue;
|
||||
AddToSet(val, end, v3, type);
|
||||
i = vs.pos;
|
||||
return i;
|
||||
@ -712,7 +712,7 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
i++;
|
||||
c = s[i];
|
||||
int v2 = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
var v2 = Convert.ToInt32(c.ToString(), CultureInfo.InvariantCulture);
|
||||
i++;
|
||||
if (i >= s.Length)
|
||||
{
|
||||
@ -722,8 +722,8 @@ namespace ASC.Notify.Cron
|
||||
c = s[i];
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
ValueSet vs = GetValue(v2, s, i);
|
||||
int v3 = vs.theValue;
|
||||
var vs = GetValue(v2, s, i);
|
||||
var v3 = vs.theValue;
|
||||
AddToSet(val, end, v3, type);
|
||||
i = vs.pos;
|
||||
return i;
|
||||
@ -795,10 +795,10 @@ namespace ASC.Notify.Cron
|
||||
return "*";
|
||||
}
|
||||
var buf = new StringBuilder();
|
||||
bool first = true;
|
||||
var first = true;
|
||||
foreach (int iVal in data)
|
||||
{
|
||||
string val = iVal.ToString(CultureInfo.InvariantCulture);
|
||||
var val = iVal.ToString(CultureInfo.InvariantCulture);
|
||||
if (!first)
|
||||
{
|
||||
buf.Append(",");
|
||||
@ -829,7 +829,7 @@ namespace ASC.Notify.Cron
|
||||
|
||||
protected virtual void AddToSet(int val, int end, int incr, int type)
|
||||
{
|
||||
TreeSet data = GetSet(type);
|
||||
var data = GetSet(type);
|
||||
if (type == Second || type == Minute)
|
||||
{
|
||||
if ((val < 0 || val > 59 || end > 59) && (val != AllSpecInt))
|
||||
@ -884,8 +884,8 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
return;
|
||||
}
|
||||
int startAt = val;
|
||||
int stopAt = end;
|
||||
var startAt = val;
|
||||
var stopAt = end;
|
||||
if (val == AllSpecInt && incr <= 0)
|
||||
{
|
||||
incr = 1;
|
||||
@ -958,7 +958,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
}
|
||||
|
||||
int max = -1;
|
||||
var max = -1;
|
||||
if (stopAt < startAt)
|
||||
{
|
||||
switch (type)
|
||||
@ -988,7 +988,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
stopAt += max;
|
||||
}
|
||||
for (int i = startAt; i <= stopAt; i += incr)
|
||||
for (var i = startAt; i <= stopAt; i += incr)
|
||||
{
|
||||
if (max == -1)
|
||||
{
|
||||
@ -996,7 +996,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
else
|
||||
{
|
||||
int i2 = i % max;
|
||||
var i2 = i % max;
|
||||
|
||||
if (i2 == 0 && (type == Month || type == DayOfWeek || type == DayOfMonth))
|
||||
{
|
||||
@ -1032,8 +1032,8 @@ namespace ASC.Notify.Cron
|
||||
|
||||
protected virtual ValueSet GetValue(int v, string s, int i)
|
||||
{
|
||||
char c = s[i];
|
||||
string s1 = v.ToString(CultureInfo.InvariantCulture);
|
||||
var c = s[i];
|
||||
var s1 = v.ToString(CultureInfo.InvariantCulture);
|
||||
while (c >= '0' && c <= '9')
|
||||
{
|
||||
s1 += c;
|
||||
@ -1059,8 +1059,8 @@ namespace ASC.Notify.Cron
|
||||
|
||||
protected virtual int GetNumericValue(string s, int i)
|
||||
{
|
||||
int endOfVal = FindNextWhiteSpace(i, s);
|
||||
string val = s.Substring(i, endOfVal - i);
|
||||
var endOfVal = FindNextWhiteSpace(i, s);
|
||||
var val = s.Substring(i, endOfVal - i);
|
||||
return Convert.ToInt32(val, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
@ -1124,16 +1124,16 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
afterTimeUtc = afterTimeUtc.AddSeconds(1);
|
||||
|
||||
DateTime d = CreateDateTimeWithoutMillis(afterTimeUtc);
|
||||
var d = CreateDateTimeWithoutMillis(afterTimeUtc);
|
||||
|
||||
d = TimeZoneInfo.ConvertTimeFromUtc(d, TimeZone);
|
||||
bool gotOne = false;
|
||||
var gotOne = false;
|
||||
|
||||
while (!gotOne)
|
||||
{
|
||||
ISortedSet st;
|
||||
int t;
|
||||
int sec = d.Second;
|
||||
var sec = d.Second;
|
||||
|
||||
st = seconds.TailSet(sec);
|
||||
if (st != null && st.Count != 0)
|
||||
@ -1146,8 +1146,8 @@ namespace ASC.Notify.Cron
|
||||
d = d.AddMinutes(1);
|
||||
}
|
||||
d = new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, sec, d.Millisecond);
|
||||
int min = d.Minute;
|
||||
int hr = d.Hour;
|
||||
var min = d.Minute;
|
||||
var hr = d.Hour;
|
||||
t = -1;
|
||||
|
||||
st = minutes.TailSet(min);
|
||||
@ -1169,7 +1169,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
d = new DateTime(d.Year, d.Month, d.Day, d.Hour, min, d.Second, d.Millisecond);
|
||||
hr = d.Hour;
|
||||
int day = d.Day;
|
||||
var day = d.Day;
|
||||
t = -1;
|
||||
|
||||
st = hours.TailSet(hr);
|
||||
@ -1185,7 +1185,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
if (hr != t)
|
||||
{
|
||||
int daysInMonth = DateTime.DaysInMonth(d.Year, d.Month);
|
||||
var daysInMonth = DateTime.DaysInMonth(d.Year, d.Month);
|
||||
if (day > daysInMonth)
|
||||
{
|
||||
d =
|
||||
@ -1201,12 +1201,12 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
d = new DateTime(d.Year, d.Month, d.Day, hr, d.Minute, d.Second, d.Millisecond);
|
||||
day = d.Day;
|
||||
int mon = d.Month;
|
||||
var mon = d.Month;
|
||||
t = -1;
|
||||
int tmon = mon;
|
||||
var tmon = mon;
|
||||
|
||||
bool dayOfMSpec = !daysOfMonth.Contains(NoSpec);
|
||||
bool dayOfWSpec = !daysOfWeek.Contains(NoSpec);
|
||||
var dayOfMSpec = !daysOfMonth.Contains(NoSpec);
|
||||
var dayOfWSpec = !daysOfWeek.Contains(NoSpec);
|
||||
if (dayOfMSpec && !dayOfWSpec)
|
||||
{
|
||||
st = daysOfMonth.TailSet(day);
|
||||
@ -1222,8 +1222,8 @@ namespace ASC.Notify.Cron
|
||||
t = day;
|
||||
day = GetLastDayOfMonth(mon, d.Year);
|
||||
var tcal = new DateTime(d.Year, mon, day, 0, 0, 0);
|
||||
int ldom = GetLastDayOfMonth(mon, d.Year);
|
||||
DayOfWeek dow = tcal.DayOfWeek;
|
||||
var ldom = GetLastDayOfMonth(mon, d.Year);
|
||||
var dow = tcal.DayOfWeek;
|
||||
if (dow == System.DayOfWeek.Saturday && day == 1)
|
||||
{
|
||||
day += 2;
|
||||
@ -1253,8 +1253,8 @@ namespace ASC.Notify.Cron
|
||||
t = day;
|
||||
day = (int)daysOfMonth.First();
|
||||
var tcal = new DateTime(d.Year, mon, day, 0, 0, 0);
|
||||
int ldom = GetLastDayOfMonth(mon, d.Year);
|
||||
DayOfWeek dow = tcal.DayOfWeek;
|
||||
var ldom = GetLastDayOfMonth(mon, d.Year);
|
||||
var dow = tcal.DayOfWeek;
|
||||
if (dow == System.DayOfWeek.Saturday && day == 1)
|
||||
{
|
||||
day += 2;
|
||||
@ -1283,7 +1283,7 @@ namespace ASC.Notify.Cron
|
||||
t = day;
|
||||
day = (int)st.First();
|
||||
|
||||
int lastDay = GetLastDayOfMonth(mon, d.Year);
|
||||
var lastDay = GetLastDayOfMonth(mon, d.Year);
|
||||
if (day > lastDay)
|
||||
{
|
||||
day = (int)daysOfMonth.First();
|
||||
@ -1303,7 +1303,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
else
|
||||
{
|
||||
int lDay = DateTime.DaysInMonth(d.Year, mon);
|
||||
var lDay = DateTime.DaysInMonth(d.Year, mon);
|
||||
if (day <= lDay)
|
||||
{
|
||||
d = new DateTime(d.Year, mon, day, 0, 0, 0);
|
||||
@ -1322,8 +1322,8 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
var dow = ((int)daysOfWeek.First());
|
||||
|
||||
int cDow = ((int)d.DayOfWeek);
|
||||
int daysToAdd = 0;
|
||||
var cDow = ((int)d.DayOfWeek);
|
||||
var daysToAdd = 0;
|
||||
if (cDow < dow)
|
||||
{
|
||||
daysToAdd = dow - cDow;
|
||||
@ -1332,7 +1332,7 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
daysToAdd = dow + (7 - cDow);
|
||||
}
|
||||
int lDay = GetLastDayOfMonth(mon, d.Year);
|
||||
var lDay = GetLastDayOfMonth(mon, d.Year);
|
||||
if (day + daysToAdd > lDay)
|
||||
{
|
||||
if (mon == 12)
|
||||
@ -1363,8 +1363,8 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
var dow = ((int)daysOfWeek.First());
|
||||
|
||||
int cDow = ((int)d.DayOfWeek);
|
||||
int daysToAdd = 0;
|
||||
var cDow = ((int)d.DayOfWeek);
|
||||
var daysToAdd = 0;
|
||||
if (cDow < dow)
|
||||
{
|
||||
daysToAdd = dow - cDow;
|
||||
@ -1373,13 +1373,13 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
daysToAdd = dow + (7 - cDow);
|
||||
}
|
||||
bool dayShifted = false;
|
||||
var dayShifted = false;
|
||||
if (daysToAdd > 0)
|
||||
{
|
||||
dayShifted = true;
|
||||
}
|
||||
day += daysToAdd;
|
||||
int weekOfMonth = day / 7;
|
||||
var weekOfMonth = day / 7;
|
||||
if (day % 7 > 0)
|
||||
{
|
||||
weekOfMonth++;
|
||||
@ -1408,7 +1408,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
else
|
||||
{
|
||||
int cDow = ((int)d.DayOfWeek);
|
||||
var cDow = ((int)d.DayOfWeek);
|
||||
var dow = ((int)daysOfWeek.First());
|
||||
|
||||
st = daysOfWeek.TailSet(cDow);
|
||||
@ -1416,7 +1416,7 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
dow = ((int)st.First());
|
||||
}
|
||||
int daysToAdd = 0;
|
||||
var daysToAdd = 0;
|
||||
if (cDow < dow)
|
||||
{
|
||||
daysToAdd = dow - cDow;
|
||||
@ -1425,7 +1425,7 @@ namespace ASC.Notify.Cron
|
||||
{
|
||||
daysToAdd = dow + (7 - cDow);
|
||||
}
|
||||
int lDay = GetLastDayOfMonth(mon, d.Year);
|
||||
var lDay = GetLastDayOfMonth(mon, d.Year);
|
||||
if (day + daysToAdd > lDay)
|
||||
{
|
||||
if (mon == 12)
|
||||
@ -1453,7 +1453,7 @@ namespace ASC.Notify.Cron
|
||||
}
|
||||
d = new DateTime(d.Year, d.Month, day, d.Hour, d.Minute, d.Second);
|
||||
mon = d.Month;
|
||||
int year = d.Year;
|
||||
var year = d.Year;
|
||||
t = -1;
|
||||
|
||||
if (year > 2099)
|
||||
@ -1509,7 +1509,7 @@ namespace ASC.Notify.Cron
|
||||
|
||||
protected static DateTime SetCalendarHour(DateTime date, int hour)
|
||||
{
|
||||
int hourToSet = hour;
|
||||
var hourToSet = hour;
|
||||
if (hourToSet == 24)
|
||||
{
|
||||
hourToSet = 0;
|
||||
|
@ -78,15 +78,15 @@ namespace ASC.Notify.Cron
|
||||
|
||||
public new bool Add(object obj)
|
||||
{
|
||||
bool inserted = AddWithoutSorting(obj);
|
||||
var inserted = AddWithoutSorting(obj);
|
||||
Sort(comparator);
|
||||
return inserted;
|
||||
}
|
||||
|
||||
public bool AddAll(ICollection c)
|
||||
{
|
||||
IEnumerator e = new ArrayList(c).GetEnumerator();
|
||||
bool added = false;
|
||||
var e = new ArrayList(c).GetEnumerator();
|
||||
var added = false;
|
||||
while (e.MoveNext())
|
||||
{
|
||||
if (AddWithoutSorting(e.Current))
|
||||
@ -105,7 +105,7 @@ namespace ASC.Notify.Cron
|
||||
|
||||
public override bool Contains(object item)
|
||||
{
|
||||
IEnumerator tempEnumerator = GetEnumerator();
|
||||
var tempEnumerator = GetEnumerator();
|
||||
while (tempEnumerator.MoveNext())
|
||||
{
|
||||
if (comparator.Compare(tempEnumerator.Current, item) == 0)
|
||||
@ -119,7 +119,7 @@ namespace ASC.Notify.Cron
|
||||
public ISortedSet TailSet(object limit)
|
||||
{
|
||||
ISortedSet newList = new TreeSet();
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
while ((i < Count) && (comparator.Compare(this[i], limit) < 0))
|
||||
{
|
||||
i++;
|
||||
|
@ -25,6 +25,6 @@ namespace ASC.Common.Notify.Engine
|
||||
/// <param name="name">The name of the item in the call context.</param>
|
||||
/// <returns>The object in the call context associated with the specified name, or <see langword="null"/> if not found.</returns>
|
||||
public static object GetData(string name) =>
|
||||
state.TryGetValue(name, out AsyncLocal<object> data) ? data.Value : null;
|
||||
state.TryGetValue(name, out var data) ? data.Value : null;
|
||||
}
|
||||
}
|
||||
|
@ -408,8 +408,7 @@ namespace ASC.Notify.Engine
|
||||
|
||||
request.CurrentSender = channel.SenderName;
|
||||
|
||||
NoticeMessage noticeMessage;
|
||||
var oops = CreateNoticeMessageFromNotifyRequest(tenantId, request, channel.SenderName, out noticeMessage);
|
||||
var oops = CreateNoticeMessageFromNotifyRequest(tenantId, request, channel.SenderName, out var noticeMessage);
|
||||
if (oops != null) return oops;
|
||||
|
||||
request.CurrentMessage = noticeMessage;
|
||||
|
@ -115,7 +115,7 @@ namespace ASC.Notify.Engine
|
||||
return null;
|
||||
}
|
||||
|
||||
int index = Array.IndexOf(SenderNames, senderName);
|
||||
var index = Array.IndexOf(SenderNames, senderName);
|
||||
if (index < 0)
|
||||
{
|
||||
throw new ApplicationException(String.Format("Sender with tag {0} dnot found", senderName));
|
||||
|
@ -46,8 +46,7 @@ namespace ASC.Notify.Model
|
||||
|
||||
public INotifyAction GetAction(string id)
|
||||
{
|
||||
INotifyAction action;
|
||||
actions.TryGetValue(id, out action);
|
||||
actions.TryGetValue(id, out var action);
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ namespace ASC.Notify
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendFormat("SendResult: {0} whith {1} sub-results", Result, Responses.Count);
|
||||
foreach (SendResponse responce in Responses)
|
||||
foreach (var responce in Responses)
|
||||
{
|
||||
string recipient = "<recipient:nomessage>";
|
||||
string error = "";
|
||||
var recipient = "<recipient:nomessage>";
|
||||
var error = "";
|
||||
if (responce.NoticeMessage != null)
|
||||
{
|
||||
if (responce.NoticeMessage.Recipient != null)
|
||||
|
@ -106,8 +106,7 @@ namespace ASC.Notify.Patterns
|
||||
|
||||
public IPattern GetPattern(INotifyAction action, string senderName)
|
||||
{
|
||||
IPattern p;
|
||||
if (patterns.TryGetValue(action.ID + senderName, out p))
|
||||
if (patterns.TryGetValue(action.ID + senderName, out var p))
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
@ -100,8 +100,7 @@ namespace ASC.Core.Notify
|
||||
{
|
||||
if (recipient == null) throw new ArgumentNullException("recipient");
|
||||
|
||||
Guid userID;
|
||||
if (TryParseGuid(recipient.ID, out userID))
|
||||
if (TryParseGuid(recipient.ID, out var userID))
|
||||
{
|
||||
var user = CoreContext.UserManager.GetUsers(tenantId, userID);
|
||||
if (user.ID != Constants.LostUser.ID)
|
||||
|
@ -62,7 +62,7 @@ namespace ASC.Core.Common.Notify
|
||||
if (String.IsNullOrEmpty(entity) || !EntityType.Match(entity).Success) throw new ArgumentException(@"Not supported entity type", entity);
|
||||
if (String.IsNullOrEmpty(entityId)) throw new ArgumentException(@"Entity Id is null or empty", entityId);
|
||||
|
||||
string pId = parentId != Guid.Empty.ToString() && parentId != null ? parentId : String.Empty;
|
||||
var pId = parentId != Guid.Empty.ToString() && parentId != null ? parentId : String.Empty;
|
||||
return new TagValue(TagName, String.Format("reply_{0}_{1}_{2}@{3}", entity, entityId, pId, AutoreplyDomain));
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ namespace ASC.Notify.Model
|
||||
public virtual void UnSubscribe(Tenant tenant, INotifyAction action, IRecipient recipient)
|
||||
{
|
||||
var objects = GetSubscriptions(tenant, action, recipient);
|
||||
foreach (string objectID in objects)
|
||||
foreach (var objectID in objects)
|
||||
{
|
||||
subscriptionProvider.UnSubscribe(action, objectID, recipient);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ namespace ASC.Common.Security.Authorizing
|
||||
do
|
||||
{
|
||||
if (!secObjProviderHelper.ObjectRolesSupported) continue;
|
||||
foreach (IRole role in secObjProviderHelper.GetObjectRoles(subject))
|
||||
foreach (var role in secObjProviderHelper.GetObjectRoles(subject))
|
||||
{
|
||||
if (!subjects.Contains(role)) subjects.Add(role);
|
||||
}
|
||||
|
@ -96,8 +96,7 @@ namespace ASC.Security.Cryptography
|
||||
var parts = key.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length != 2) return ValidationResult.Invalid;
|
||||
|
||||
long ms = 0;
|
||||
if (!Int64.TryParse(parts[0], out ms)) return ValidationResult.Invalid;
|
||||
if (!Int64.TryParse(parts[0], out var ms)) return ValidationResult.Invalid;
|
||||
|
||||
var hash = GetMashineHashedData(BitConverter.GetBytes(ms), Encoding.ASCII.GetBytes(email));
|
||||
var key2 = DoStringFromBytes(hash);
|
||||
@ -109,7 +108,7 @@ namespace ASC.Security.Cryptography
|
||||
|
||||
internal static string DoStringFromBytes(byte[] data)
|
||||
{
|
||||
string str = Convert.ToBase64String(data);
|
||||
var str = Convert.ToBase64String(data);
|
||||
str = str.Replace("=", "").Replace("+", "").Replace("/", "").Replace("\\", "");
|
||||
return str.ToUpperInvariant();
|
||||
}
|
||||
|
@ -43,8 +43,7 @@ namespace ASC.Core.Tenants
|
||||
{
|
||||
MinLength = 6;
|
||||
|
||||
int defaultMinLength;
|
||||
if (int.TryParse(ConfigurationManager.AppSettings["web:alias:min"], out defaultMinLength))
|
||||
if (int.TryParse(ConfigurationManager.AppSettings["web:alias:min"], out var defaultMinLength))
|
||||
{
|
||||
MinLength = Math.Max(1, Math.Min(MaxLength, defaultMinLength));
|
||||
}
|
||||
|
@ -178,8 +178,7 @@ namespace ASC.Core.Tenants
|
||||
{
|
||||
var features = (Features ?? string.Empty).Split(' ', ',', ';').ToList();
|
||||
var portals = features.FirstOrDefault(f => f.StartsWith("portals:"));
|
||||
int countPortals;
|
||||
if (portals == null || !Int32.TryParse(portals.Replace("portals:", ""), out countPortals) || countPortals <= 0)
|
||||
if (portals == null || !Int32.TryParse(portals.Replace("portals:", ""), out var countPortals) || countPortals <= 0)
|
||||
{
|
||||
countPortals = 0;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ namespace ASC.Common.Tests.Security.Authorizing
|
||||
[Test]
|
||||
public void GetAzManagerObjectAcl()
|
||||
{
|
||||
AzManager azMan = new AzManager(Domain.RoleProvider, Domain.PermissionProvider);
|
||||
var azMan = new AzManager(Domain.RoleProvider, Domain.PermissionProvider);
|
||||
AzManager.AzManagerAcl acl = null;
|
||||
|
||||
var c1 = new Class1(1);
|
||||
|
@ -47,15 +47,8 @@ namespace ASC.Core.Common.Tests
|
||||
|
||||
var cookie = CookieStorage.EncryptCookie(t1, id1, login1, pwd1, it1, expire1, iu1);
|
||||
|
||||
int t2;
|
||||
Guid id2;
|
||||
string login2;
|
||||
string pwd2;
|
||||
int it2;
|
||||
DateTime expire2;
|
||||
int iu2;
|
||||
|
||||
CookieStorage.DecryptCookie(cookie, out t2, out id2, out login2, out pwd2, out it2, out expire2, out iu2);
|
||||
CookieStorage.DecryptCookie(cookie, out var t2, out var id2, out var login2, out var pwd2, out var it2, out var expire2, out var iu2);
|
||||
|
||||
Assert.AreEqual(t1, t2);
|
||||
Assert.AreEqual(id1, id2);
|
||||
|
@ -141,16 +141,14 @@ namespace ASC.Common.Tests.Security.Authorizing
|
||||
|
||||
public void AddAccountInRole(ISubject account, IRole role)
|
||||
{
|
||||
List<IRole> roles = null;
|
||||
if (!AccountRoles.TryGetValue(account, out roles))
|
||||
if (!AccountRoles.TryGetValue(account, out var roles))
|
||||
{
|
||||
roles = new List<IRole>(10);
|
||||
AccountRoles.Add(account, roles);
|
||||
}
|
||||
if (!roles.Contains(role)) roles.Add(role);
|
||||
|
||||
List<ISubject> accounts = null;
|
||||
if (!RoleAccounts.TryGetValue(role, out accounts))
|
||||
if (!RoleAccounts.TryGetValue(role, out var accounts))
|
||||
{
|
||||
accounts = new List<ISubject>(10);
|
||||
RoleAccounts.Add(role, accounts);
|
||||
@ -162,15 +160,13 @@ namespace ASC.Common.Tests.Security.Authorizing
|
||||
|
||||
public List<IRole> GetRoles(Tenant tenant, ISubject account)
|
||||
{
|
||||
List<IRole> roles = null;
|
||||
if (!AccountRoles.TryGetValue(account, out roles)) roles = new List<IRole>();
|
||||
if (!AccountRoles.TryGetValue(account, out var roles)) roles = new List<IRole>();
|
||||
return roles;
|
||||
}
|
||||
|
||||
public List<ISubject> GetSubjects(IRole role)
|
||||
{
|
||||
List<ISubject> accounts = null;
|
||||
if (!RoleAccounts.TryGetValue(role, out accounts)) accounts = new List<ISubject>();
|
||||
if (!RoleAccounts.TryGetValue(role, out var accounts)) accounts = new List<ISubject>();
|
||||
return accounts;
|
||||
}
|
||||
|
||||
@ -264,7 +260,7 @@ namespace ASC.Common.Tests.Security.Authorizing
|
||||
|
||||
allAces.AddRange(GetAcl(subject, action, fullObjectId));
|
||||
|
||||
bool inherit = GetObjectAcesInheritance(objectId);
|
||||
var inherit = GetObjectAcesInheritance(objectId);
|
||||
if (inherit)
|
||||
{
|
||||
var providerHelper = new AzObjectSecurityProviderHelper(objectId, secObjProvider);
|
||||
|
@ -39,7 +39,7 @@ namespace ASC.Common.Tests.Security.Cryptography
|
||||
public void PasswordDerivedBytes_Test()
|
||||
{
|
||||
|
||||
byte[] randBytes = new byte[5];
|
||||
var randBytes = new byte[5];
|
||||
new Random(10032010).NextBytes(randBytes);
|
||||
|
||||
|
||||
|
@ -38,8 +38,7 @@ namespace ASC.Core.Users
|
||||
{
|
||||
get
|
||||
{
|
||||
int count;
|
||||
if (!int.TryParse(ConfigurationManager.AppSettings["core:users"], out count))
|
||||
if (!int.TryParse(ConfigurationManager.AppSettings["core:users"], out var count))
|
||||
{
|
||||
count = 10000;
|
||||
}
|
||||
|
@ -123,8 +123,7 @@ namespace ASC.Core.Users
|
||||
}
|
||||
if (forceFormat != null) return forceFormat;
|
||||
var culture = Thread.CurrentThread.CurrentCulture.Name;
|
||||
Dictionary<DisplayUserNameFormat, string> formats = null;
|
||||
if (!DisplayFormats.TryGetValue(culture, out formats))
|
||||
if (!DisplayFormats.TryGetValue(culture, out var formats))
|
||||
{
|
||||
var twoletter = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
|
||||
if (!DisplayFormats.TryGetValue(twoletter, out formats)) formats = DisplayFormats["default"];
|
||||
@ -135,10 +134,9 @@ namespace ASC.Core.Users
|
||||
public static DisplayUserNameFormat GetUserDisplayDefaultOrder()
|
||||
{
|
||||
var culture = Thread.CurrentThread.CurrentCulture.Name;
|
||||
Dictionary<DisplayUserNameFormat, string> formats = null;
|
||||
if (!DisplayFormats.TryGetValue(culture, out formats))
|
||||
if (!DisplayFormats.TryGetValue(culture, out var formats))
|
||||
{
|
||||
string twoletter = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
|
||||
var twoletter = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;
|
||||
if (!DisplayFormats.TryGetValue(twoletter, out formats)) formats = DisplayFormats["default"];
|
||||
}
|
||||
var format = formats[DisplayUserNameFormat.Default];
|
||||
|
@ -105,8 +105,8 @@ namespace ASC.Data.Reassigns
|
||||
var tenant = CoreContext.TenantManager.SetCurrentTenant(_tenantId);
|
||||
SecurityContext.AuthenticateMe(_tenantId, _currentUserId);
|
||||
|
||||
long docsSpace, crmSpace, mailSpace, talkSpace;
|
||||
GetUsageSpace(tenant, out docsSpace, out mailSpace, out talkSpace);
|
||||
long crmSpace;
|
||||
GetUsageSpace(tenant, out var docsSpace, out var mailSpace, out var talkSpace);
|
||||
|
||||
logger.InfoFormat("deleting user data for {0} ", _userId);
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace ASC.Data.Storage.DiscStorage
|
||||
|
||||
if (File.Exists(target))
|
||||
{
|
||||
FileStream stream = File.OpenRead(target);
|
||||
var stream = File.OpenRead(target);
|
||||
if (0 < offset) stream.Seek(offset, SeekOrigin.Begin);
|
||||
return stream;
|
||||
}
|
||||
@ -634,7 +634,7 @@ namespace ASC.Data.Storage.DiscStorage
|
||||
|
||||
private static void CreateDirectory(string target)
|
||||
{
|
||||
string targetDirectory = Path.GetDirectoryName(target);
|
||||
var targetDirectory = Path.GetDirectoryName(target);
|
||||
if (!Directory.Exists(targetDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(targetDirectory);
|
||||
|
@ -270,7 +270,7 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
|
||||
var storage = GetStorage();
|
||||
|
||||
UploadObjectOptions uploadObjectOptions = new UploadObjectOptions
|
||||
var uploadObjectOptions = new UploadObjectOptions
|
||||
{
|
||||
PredefinedAcl = acl == ACL.Auto ? GetDomainACL(domain) : GetGoogleCloudAcl(acl)
|
||||
};
|
||||
@ -606,7 +606,7 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
|
||||
var size = GetFileSize(srcdomain, srcpath);
|
||||
|
||||
CopyObjectOptions options = new CopyObjectOptions();
|
||||
var options = new CopyObjectOptions();
|
||||
|
||||
options.DestinationPredefinedAcl = GetDomainACL(newdomain);
|
||||
|
||||
@ -649,7 +649,7 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
var objectKey = MakePath(domain, path);
|
||||
var buffered = stream.GetBuffered();
|
||||
|
||||
UploadObjectOptions uploadObjectOptions = new UploadObjectOptions
|
||||
var uploadObjectOptions = new UploadObjectOptions
|
||||
{
|
||||
PredefinedAcl = PredefinedObjectAcl.BucketOwnerFullControl
|
||||
};
|
||||
@ -690,9 +690,8 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
|
||||
if (string.IsNullOrEmpty(privateExpireKey)) continue;
|
||||
|
||||
long fileTime;
|
||||
|
||||
if (!long.TryParse(privateExpireKey, out fileTime)) continue;
|
||||
if (!long.TryParse(privateExpireKey, out var fileTime)) continue;
|
||||
if (DateTime.UtcNow <= DateTime.FromFileTimeUtc(fileTime)) continue;
|
||||
|
||||
storage.DeleteObject(_bucket, MakePath(domain, path));
|
||||
@ -722,17 +721,17 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
long chunkLength)
|
||||
{
|
||||
|
||||
String bytesRangeStart = Convert.ToString((chunkNumber - 1) * defaultChunkSize);
|
||||
String bytesRangeEnd = Convert.ToString((chunkNumber - 1) * defaultChunkSize + chunkLength - 1);
|
||||
var bytesRangeStart = Convert.ToString((chunkNumber - 1) * defaultChunkSize);
|
||||
var bytesRangeEnd = Convert.ToString((chunkNumber - 1) * defaultChunkSize + chunkLength - 1);
|
||||
|
||||
String totalBytes = "*";
|
||||
var totalBytes = "*";
|
||||
|
||||
int BufferSize = 2 * 4096;
|
||||
var BufferSize = 2 * 4096;
|
||||
|
||||
if (chunkLength != defaultChunkSize)
|
||||
totalBytes = Convert.ToString((chunkNumber - 1) * defaultChunkSize + chunkLength);
|
||||
|
||||
String contentRangeHeader = String.Format("bytes {0}-{1}/{2}", bytesRangeStart, bytesRangeEnd, totalBytes);
|
||||
var contentRangeHeader = String.Format("bytes {0}-{1}/{2}", bytesRangeStart, bytesRangeEnd, totalBytes);
|
||||
|
||||
var request = HttpWebRequest.CreateHttp(uploadUri);
|
||||
|
||||
@ -740,7 +739,7 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
request.ContentLength = chunkLength;
|
||||
request.Headers.Add("Content-Range", contentRangeHeader);
|
||||
|
||||
using (Stream rs = request.GetRequestStream())
|
||||
using (var rs = request.GetRequestStream())
|
||||
{
|
||||
var buffer = new byte[BufferSize];
|
||||
|
||||
@ -757,9 +756,9 @@ namespace ASC.Data.Storage.GoogleCloud
|
||||
long MAX_RETRIES = 100;
|
||||
int millisecondsTimeout;
|
||||
|
||||
for (int i = 0; i < MAX_RETRIES; i++)
|
||||
for (var i = 0; i < MAX_RETRIES; i++)
|
||||
{
|
||||
Random random = new Random();
|
||||
var random = new Random();
|
||||
|
||||
millisecondsTimeout = Math.Min(Convert.ToInt32(Math.Pow(2, i)) + random.Next(0, 1000), 32 * 1000);
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace ASC.Data.Storage.RackspaceCloud
|
||||
|
||||
private CloudFilesProvider GetClient()
|
||||
{
|
||||
CloudIdentity cloudIdentity = new CloudIdentity()
|
||||
var cloudIdentity = new CloudIdentity()
|
||||
{
|
||||
Username = _username,
|
||||
APIKey = _apiKey
|
||||
@ -216,7 +216,7 @@ namespace ASC.Data.Storage.RackspaceCloud
|
||||
|
||||
public override Stream GetReadStream(string domain, string path, int offset)
|
||||
{
|
||||
Stream outputStream = TempStream.Create();
|
||||
var outputStream = TempStream.Create();
|
||||
|
||||
var client = GetClient();
|
||||
|
||||
@ -689,7 +689,7 @@ namespace ASC.Data.Storage.RackspaceCloud
|
||||
|
||||
public override string UploadChunk(string domain, string path, string filePath, Stream stream, long defaultChunkSize, int chunkNumber, long chunkLength)
|
||||
{
|
||||
int BufferSize = 4096;
|
||||
var BufferSize = 4096;
|
||||
|
||||
var mode = chunkNumber == 0 ? FileMode.Create : FileMode.Append;
|
||||
|
||||
|
@ -676,7 +676,7 @@ namespace ASC.Data.Storage.S3
|
||||
Verb = HttpVerb.GET
|
||||
};
|
||||
|
||||
string url = client.GetPreSignedURL(pUrlRequest);
|
||||
var url = client.GetPreSignedURL(pUrlRequest);
|
||||
//TODO: CNAME!
|
||||
return url;
|
||||
}
|
||||
@ -699,8 +699,7 @@ namespace ASC.Data.Storage.S3
|
||||
var privateExpireKey = metadata.Metadata["private-expire"];
|
||||
if (string.IsNullOrEmpty(privateExpireKey)) continue;
|
||||
|
||||
long fileTime;
|
||||
if (!long.TryParse(privateExpireKey, out fileTime)) continue;
|
||||
if (!long.TryParse(privateExpireKey, out var fileTime)) continue;
|
||||
if (DateTime.UtcNow <= DateTime.FromFileTimeUtc(fileTime)) continue;
|
||||
//Delete it
|
||||
var deleteObjectRequest = new DeleteObjectRequest
|
||||
@ -724,9 +723,8 @@ namespace ASC.Data.Storage.S3
|
||||
{
|
||||
var key = MakePath(domain, directoryPath) + "/";
|
||||
//Generate policy
|
||||
string sign;
|
||||
var policyBase64 = GetPolicyBase64(key, string.Empty, contentType, contentDisposition, maxUploadSize,
|
||||
out sign);
|
||||
out var sign);
|
||||
var postBuilder = new StringBuilder();
|
||||
postBuilder.Append("{");
|
||||
postBuilder.AppendFormat("\"key\":\"{0}${{filename}}\",", key);
|
||||
@ -754,9 +752,8 @@ namespace ASC.Data.Storage.S3
|
||||
var destBucket = GetUploadUrl();
|
||||
var key = MakePath(domain, directoryPath) + "/";
|
||||
//Generate policy
|
||||
string sign;
|
||||
var policyBase64 = GetPolicyBase64(key, redirectTo, contentType, contentDisposition, maxUploadSize,
|
||||
out sign);
|
||||
out var sign);
|
||||
|
||||
var formBuilder = new StringBuilder();
|
||||
formBuilder.AppendFormat("<form action=\"{0}\" method=\"post\" enctype=\"multipart/form-data\">", destBucket);
|
||||
|
@ -56,8 +56,7 @@ namespace ASC.Data.Storage
|
||||
|
||||
public static IDataStore GetStorage(string configpath, string tenant, string module)
|
||||
{
|
||||
int tenantId;
|
||||
int.TryParse(tenant, out tenantId);
|
||||
int.TryParse(tenant, out var tenantId);
|
||||
return GetStorage(configpath, tenant, module, new TennantQuotaController(tenantId));
|
||||
}
|
||||
|
||||
@ -105,8 +104,7 @@ namespace ASC.Data.Storage
|
||||
throw new InvalidOperationException("config section not found");
|
||||
}
|
||||
|
||||
int tenantId;
|
||||
int.TryParse(tenant, out tenantId);
|
||||
int.TryParse(tenant, out var tenantId);
|
||||
return GetDataStore(tenant, module, consumer, new TennantQuotaController(tenantId));
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,7 @@ namespace ASC.Data.Storage
|
||||
throw new ArgumentNullException("tenant");
|
||||
}
|
||||
|
||||
long tennantId;
|
||||
if (long.TryParse(tenant, NumberStyles.Integer, CultureInfo.InvariantCulture, out tennantId))
|
||||
if (long.TryParse(tenant, NumberStyles.Integer, CultureInfo.InvariantCulture, out var tennantId))
|
||||
{
|
||||
var culture = CultureInfo.InvariantCulture;
|
||||
return tennantId == 0 ? tennantId.ToString(culture) : tennantId.ToString("00/00/00", culture);
|
||||
|
@ -32,8 +32,7 @@ namespace ASC.FederatedLogin.Helpers
|
||||
{
|
||||
public static TValue Get<T, TValue>(this IDictionary<T, TValue> disct, T key)
|
||||
{
|
||||
TValue def;
|
||||
disct.TryGetValue(key, out def);
|
||||
disct.TryGetValue(key, out var def);
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
@ -118,8 +118,7 @@ namespace ASC.FederatedLogin
|
||||
{
|
||||
if (_params.ContainsKey("min"))
|
||||
{
|
||||
bool result;
|
||||
bool.TryParse(_params.Get("min"), out result);
|
||||
bool.TryParse(_params.Get("min"), out var result);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
|
@ -46,8 +46,7 @@ namespace ASC.FederatedLogin.LoginProviders
|
||||
var response = Openid.GetResponse();
|
||||
if (response == null)
|
||||
{
|
||||
Identifier id;
|
||||
if (Identifier.TryParse(@params["oid"], out id))
|
||||
if (Identifier.TryParse(@params["oid"], out var id))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -109,8 +109,7 @@ namespace ASC.FederatedLogin
|
||||
OriginJson = json,
|
||||
};
|
||||
|
||||
long expiresIn;
|
||||
if (long.TryParse(parser.Value<string>("expires_in"), out expiresIn))
|
||||
if (long.TryParse(parser.Value<string>("expires_in"), out var expiresIn))
|
||||
token.ExpiresIn = expiresIn;
|
||||
|
||||
try
|
||||
|
@ -145,9 +145,8 @@ namespace ASC.VoipService.Twilio
|
||||
return new VoiceResponse().Play(Uri.EscapeUriString(settings.HoldAudio), 0);
|
||||
}
|
||||
|
||||
Guid newCallerId;
|
||||
|
||||
if (Guid.TryParse(to, out newCallerId))
|
||||
if (Guid.TryParse(to, out var newCallerId))
|
||||
{
|
||||
SecurityContext.AuthenticateMe(CoreContext.TenantManager.GetCurrentTenant().TenantId, newCallerId);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ namespace ASC.Employee.Core.Controllers
|
||||
includeGroups.Add(adminGroups);
|
||||
}
|
||||
|
||||
var users = CoreContext.UserManager.GetUsers(Tenant.TenantId, isAdmin, employeeStatus, includeGroups, excludeGroups, activationStatus, ApiContext.FilterValue, ApiContext.SortBy, !ApiContext.SortDescending, ApiContext.Count - 1, ApiContext.StartIndex, out int total);
|
||||
var users = CoreContext.UserManager.GetUsers(Tenant.TenantId, isAdmin, employeeStatus, includeGroups, excludeGroups, activationStatus, ApiContext.FilterValue, ApiContext.SortBy, !ApiContext.SortDescending, ApiContext.Count - 1, ApiContext.StartIndex, out var total);
|
||||
|
||||
ApiContext.SetTotalCount(total);
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace ASC.Web.Core.Calendars
|
||||
|
||||
public virtual string ToiCalFormat()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("BEGIN:VEVENT");
|
||||
sb.AppendLine(String.Format("UID:{0}", string.IsNullOrEmpty(this.Uid) ? this.Id : this.Uid));
|
||||
|
@ -78,7 +78,7 @@ namespace ASC.Web.Core.Calendars
|
||||
|
||||
public virtual string ToiCalFormat()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine("BEGIN:TODO");
|
||||
sb.AppendLine(String.Format("UID:{0}", string.IsNullOrEmpty(this.Uid) ? this.Id : this.Uid));
|
||||
|
@ -58,7 +58,7 @@ namespace ASC.Web.Core.Calendars
|
||||
|
||||
public static int GetDayOfWeekInMonth(this DateTime date)
|
||||
{
|
||||
int count = 0;
|
||||
var count = 0;
|
||||
var d = date;
|
||||
while (date.Month == d.Month)
|
||||
{
|
||||
@ -472,7 +472,7 @@ namespace ASC.Web.Core.Calendars
|
||||
while (d.Year <= endDate.Year && CheckCount(dates, fromDate, maxCount))
|
||||
{
|
||||
var dateRange = new List<DateTime>();
|
||||
bool isFirst = true;
|
||||
var isFirst = true;
|
||||
|
||||
if (ByMonth != null)
|
||||
{
|
||||
@ -946,8 +946,7 @@ namespace ASC.Web.Core.Calendars
|
||||
|
||||
foreach (var date in val.Split(','))
|
||||
{
|
||||
DateTime dt;
|
||||
if (DateTime.TryParseExact(date.ToUpper(), _dateTimeFormats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out dt))
|
||||
if (DateTime.TryParseExact(date.ToUpper(), _dateTimeFormats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out var dt))
|
||||
rr.ExDates.Add(new ExDate() { Date = dt, isDateTime = (date.ToLower().IndexOf('t') >= 0) });
|
||||
|
||||
}
|
||||
@ -965,7 +964,7 @@ namespace ASC.Web.Core.Calendars
|
||||
if (this.Freq == Frequency.Never)
|
||||
return String.Empty;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("RRULE:" + this.ToString(true));
|
||||
|
||||
if (this.ExDates.Count > 0)
|
||||
|
@ -52,7 +52,7 @@ namespace ASC.Web.Core
|
||||
if (crop) alignWidth = (minSide == realWidth);
|
||||
else alignWidth = (maxSide == realWidth);
|
||||
|
||||
double scaleFactor = (alignWidth) ? (realWidth / (1.0 * width)) : (realHeight / (1.0 * height));
|
||||
var scaleFactor = (alignWidth) ? (realWidth / (1.0 * width)) : (realHeight / (1.0 * height));
|
||||
|
||||
if (scaleFactor < 1) scaleFactor = 1;
|
||||
|
||||
@ -80,7 +80,7 @@ namespace ASC.Web.Core
|
||||
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
|
||||
using (ImageAttributes wrapMode = new ImageAttributes())
|
||||
using (var wrapMode = new ImageAttributes())
|
||||
{
|
||||
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||
graphic.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
|
||||
|
@ -30,8 +30,7 @@ namespace System
|
||||
{
|
||||
public static T TryParseEnum<T>(this Type enumType, string value, T defaultValue) where T : struct
|
||||
{
|
||||
bool isDefault;
|
||||
return TryParseEnum<T>(enumType, value, defaultValue, out isDefault);
|
||||
return TryParseEnum<T>(enumType, value, defaultValue, out var isDefault);
|
||||
}
|
||||
|
||||
public static T TryParseEnum<T>(this Type enumType, string value, T defaultValue, out bool isDefault) where T : struct
|
||||
|
@ -558,8 +558,7 @@ namespace ASC.Web.Core.Files
|
||||
|
||||
public static void ProcessResponseError(string errorCode)
|
||||
{
|
||||
ErrorCode code;
|
||||
if (!Enum.TryParse(errorCode, true, out code))
|
||||
if (!Enum.TryParse(errorCode, true, out ErrorCode code))
|
||||
{
|
||||
code = ErrorCode.Unknown;
|
||||
}
|
||||
|
@ -59,8 +59,7 @@ namespace ASC.Web.Core.Files
|
||||
public static string GetInternalExtension(string fileName)
|
||||
{
|
||||
var extension = GetFileExtension(fileName);
|
||||
string internalExtension;
|
||||
return InternalExtension.TryGetValue(GetFileTypeByExtention(extension), out internalExtension)
|
||||
return InternalExtension.TryGetValue(GetFileTypeByExtention(extension), out var internalExtension)
|
||||
? internalExtension
|
||||
: extension;
|
||||
}
|
||||
|
@ -141,8 +141,7 @@ namespace ASC.Web.Core.Helpers
|
||||
|
||||
private static string SendToApi(string absoluteApiUrl, string apiPath, string httpMethod, string data = null)
|
||||
{
|
||||
Uri uri;
|
||||
if (!Uri.TryCreate(absoluteApiUrl, UriKind.Absolute, out uri))
|
||||
if (!Uri.TryCreate(absoluteApiUrl, UriKind.Absolute, out var uri))
|
||||
{
|
||||
var appUrl = CommonLinkUtility.GetFullAbsolutePath("/");
|
||||
absoluteApiUrl = string.Format("{0}/{1}", appUrl.TrimEnd('/'), absoluteApiUrl.TrimStart('/')).TrimEnd('/');
|
||||
|
@ -35,8 +35,7 @@ namespace ASC.Web.Core.Helpers
|
||||
{
|
||||
public static bool ProcessBasicAuthorization(HttpContext context)
|
||||
{
|
||||
string authCookie;
|
||||
return ProcessBasicAuthorization(context, out authCookie);
|
||||
return ProcessBasicAuthorization(context, out var authCookie);
|
||||
}
|
||||
|
||||
public static bool ProcessBasicAuthorization(HttpContext context, out string authCookie)
|
||||
|
@ -40,7 +40,7 @@ namespace ASC.Web.Core.Helpers
|
||||
int[] formsTable = { 2, 0, 1, 1, 1, 2, 2, 2, 2, 2 };
|
||||
|
||||
number = Math.Abs(number);
|
||||
int res = formsTable[((((number % 100) / 10) != 1) ? 1 : 0) * (number % 10)];
|
||||
var res = formsTable[((((number % 100) / 10) != 1) ? 1 : 0) * (number % 10)];
|
||||
switch (res)
|
||||
{
|
||||
case 0:
|
||||
|
@ -143,35 +143,35 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public void DoThumbnail(string path, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
DoThumbnail(fs, outputPath, ref imageInfo);
|
||||
}
|
||||
}
|
||||
public void DoThumbnail(Stream image, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
using (Image img = Image.FromStream(image))
|
||||
using (var img = Image.FromStream(image))
|
||||
{
|
||||
DoThumbnail(img, outputPath, ref imageInfo);
|
||||
}
|
||||
}
|
||||
public void DoThumbnail(Image image, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
int realWidth = image.Width;
|
||||
int realHeight = image.Height;
|
||||
var realWidth = image.Width;
|
||||
var realHeight = image.Height;
|
||||
|
||||
imageInfo.OriginalWidth = realWidth;
|
||||
imageInfo.OriginalHeight = realHeight;
|
||||
|
||||
EncoderParameters ep = new EncoderParameters(1);
|
||||
var ep = new EncoderParameters(1);
|
||||
|
||||
ep.Param[0] = new EncoderParameter(Encoder.Quality, (long)90);
|
||||
|
||||
ImageCodecInfo icJPG = getCodecInfo("image/jpeg");
|
||||
var icJPG = getCodecInfo("image/jpeg");
|
||||
|
||||
if (!String.IsNullOrEmpty(imageInfo.Name) && imageInfo.Name.Contains("."))
|
||||
{
|
||||
int indexDot = imageInfo.Name.ToLower().LastIndexOf(".");
|
||||
var indexDot = imageInfo.Name.ToLower().LastIndexOf(".");
|
||||
|
||||
if (imageInfo.Name.ToLower().IndexOf("png", indexDot) > indexDot)
|
||||
icJPG = getCodecInfo("image/png");
|
||||
@ -190,7 +190,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
else
|
||||
{
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
var ms = new MemoryStream();
|
||||
image.Save(ms, icJPG, ep);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
store.Save(outputPath, ms);
|
||||
@ -202,16 +202,16 @@ namespace ASC.Web.Studio.Helpers
|
||||
{
|
||||
thumbnail = new Bitmap(_width < realWidth ? _width : realWidth, _heigth < realHeight ? _heigth : realHeight);
|
||||
|
||||
int maxSide = realWidth > realHeight ? realWidth : realHeight;
|
||||
int minSide = realWidth < realHeight ? realWidth : realHeight;
|
||||
var maxSide = realWidth > realHeight ? realWidth : realHeight;
|
||||
var minSide = realWidth < realHeight ? realWidth : realHeight;
|
||||
|
||||
bool alignWidth = true;
|
||||
var alignWidth = true;
|
||||
if (_crop)
|
||||
alignWidth = (minSide == realWidth);
|
||||
else
|
||||
alignWidth = (maxSide == realWidth);
|
||||
|
||||
double scaleFactor = (alignWidth) ? (realWidth / (1.0 * _width)) : (realHeight / (1.0 * _heigth));
|
||||
var scaleFactor = (alignWidth) ? (realWidth / (1.0 * _width)) : (realHeight / (1.0 * _heigth));
|
||||
|
||||
if (scaleFactor < 1) scaleFactor = 1;
|
||||
|
||||
@ -225,13 +225,13 @@ namespace ASC.Web.Studio.Helpers
|
||||
locationY = (int)(((_heigth < realHeight ? _heigth : realHeight) / 2.0) - (finalHeigth / 2.0));
|
||||
locationX = (int)(((_width < realWidth ? _width : realWidth) / 2.0) - (finalWidth / 2.0));
|
||||
|
||||
Rectangle rect = new Rectangle(locationX, locationY, finalWidth, finalHeigth);
|
||||
var rect = new Rectangle(locationX, locationY, finalWidth, finalHeigth);
|
||||
|
||||
imageInfo.ThumbnailWidth = thumbnail.Width;
|
||||
imageInfo.ThumbnailHeight = thumbnail.Height;
|
||||
|
||||
|
||||
using (Graphics graphic = Graphics.FromImage(thumbnail))
|
||||
using (var graphic = Graphics.FromImage(thumbnail))
|
||||
{
|
||||
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
@ -245,7 +245,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
else
|
||||
{
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
var ms = new MemoryStream();
|
||||
thumbnail.Save(ms, icJPG, ep);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
store.Save(outputPath, ms);
|
||||
@ -259,28 +259,28 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public void DoPreviewImage(string path, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
DoPreviewImage(fs, outputPath, ref imageInfo);
|
||||
}
|
||||
}
|
||||
public void DoPreviewImage(Stream image, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
using (Image img = Image.FromStream(image))
|
||||
using (var img = Image.FromStream(image))
|
||||
{
|
||||
DoPreviewImage(img, outputPath, ref imageInfo);
|
||||
}
|
||||
}
|
||||
public void DoPreviewImage(Image image, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
int realWidth = image.Width;
|
||||
int realHeight = image.Height;
|
||||
var realWidth = image.Width;
|
||||
var realHeight = image.Height;
|
||||
|
||||
int heightPreview = realHeight;
|
||||
int widthPreview = realWidth;
|
||||
var heightPreview = realHeight;
|
||||
var widthPreview = realWidth;
|
||||
|
||||
EncoderParameters ep = new EncoderParameters(1);
|
||||
ImageCodecInfo icJPG = getCodecInfo("image/jpeg");
|
||||
var ep = new EncoderParameters(1);
|
||||
var icJPG = getCodecInfo("image/jpeg");
|
||||
ep.Param[0] = new EncoderParameter(Encoder.Quality, (long)90);
|
||||
|
||||
if (realWidth <= _widthPreview && realHeight <= _heightPreview)
|
||||
@ -293,7 +293,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
else
|
||||
{
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
var ms = new MemoryStream();
|
||||
image.Save(ms, icJPG, ep);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
store.Save(outputPath, ms);
|
||||
@ -322,9 +322,9 @@ namespace ASC.Web.Studio.Helpers
|
||||
imageInfo.PreviewWidth = widthPreview;
|
||||
imageInfo.PreviewHeight = heightPreview;
|
||||
|
||||
Bitmap preview = new Bitmap(widthPreview, heightPreview);
|
||||
var preview = new Bitmap(widthPreview, heightPreview);
|
||||
|
||||
using (Graphics graphic = Graphics.FromImage(preview))
|
||||
using (var graphic = Graphics.FromImage(preview))
|
||||
{
|
||||
graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
@ -337,7 +337,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
else
|
||||
{
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
var ms = new MemoryStream();
|
||||
preview.Save(ms, icJPG, ep);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
store.Save(outputPath, ms);
|
||||
@ -389,9 +389,9 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
private static ImageCodecInfo getCodecInfo(string mt)
|
||||
{
|
||||
ImageCodecInfo[] ici = ImageCodecInfo.GetImageEncoders();
|
||||
int idx = 0;
|
||||
for (int ii = 0; ii < ici.Length; ii++)
|
||||
var ici = ImageCodecInfo.GetImageEncoders();
|
||||
var idx = 0;
|
||||
for (var ii = 0; ii < ici.Length; ii++)
|
||||
{
|
||||
if (ici[ii].MimeType == mt)
|
||||
{
|
||||
@ -411,7 +411,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void GenerateThumbnail(string path, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
@ -422,7 +422,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void GenerateThumbnail(string path, string outputPath, ref ImageInfo imageInfo, int maxWidth, int maxHeight)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxWidth,
|
||||
maxHeight,
|
||||
maxWidthPreview,
|
||||
@ -432,7 +432,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
}
|
||||
public static void GenerateThumbnail(Stream stream, string outputPath, ref ImageInfo imageInfo, int maxWidth, int maxHeight)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxWidth,
|
||||
maxHeight,
|
||||
maxWidthPreview,
|
||||
@ -443,7 +443,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void GenerateThumbnail(string path, string outputPath, ref ImageInfo imageInfo, int maxWidth, int maxHeight, IDataStore store)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxWidth,
|
||||
maxHeight,
|
||||
maxWidthPreview,
|
||||
@ -454,7 +454,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
}
|
||||
public static void GenerateThumbnail(Stream stream, string outputPath, ref ImageInfo imageInfo, int maxWidth, int maxHeight, IDataStore store)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxWidth,
|
||||
maxHeight,
|
||||
maxWidthPreview,
|
||||
@ -467,7 +467,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void GenerateThumbnail(Stream stream, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
@ -478,7 +478,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void GenerateThumbnail(Stream stream, string outputPath, ref ImageInfo imageInfo, IDataStore store)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
@ -491,7 +491,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void GeneratePreview(string path, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
@ -502,7 +502,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
}
|
||||
public static void GeneratePreview(Stream stream, string outputPath, ref ImageInfo imageInfo)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
@ -513,7 +513,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
}
|
||||
public static void GeneratePreview(Stream stream, string outputPath, ref ImageInfo imageInfo, IDataStore store)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
@ -527,7 +527,7 @@ namespace ASC.Web.Studio.Helpers
|
||||
|
||||
public static void RotateImage(string path, string outputPath, bool back, IDataStore store)
|
||||
{
|
||||
ThumbnailGenerator _generator = new ThumbnailGenerator(null, true,
|
||||
var _generator = new ThumbnailGenerator(null, true,
|
||||
maxSize,
|
||||
maxSize,
|
||||
maxWidthPreview,
|
||||
|
@ -60,16 +60,15 @@ namespace ASC.Web.Core.Helpers
|
||||
/// <returns></returns>
|
||||
private LookupTable GetLookupTable(CultureInfo culture)
|
||||
{
|
||||
LookupTable result = null;
|
||||
if (culture == null)
|
||||
culture = CultureInfo.CurrentCulture;
|
||||
|
||||
if (!_lookupTables.TryGetValue(culture, out result))
|
||||
if (!_lookupTables.TryGetValue(culture, out var result))
|
||||
{
|
||||
result = new LookupTable();
|
||||
foreach (object value in GetStandardValues())
|
||||
foreach (var value in GetStandardValues())
|
||||
{
|
||||
string text = GetValueText(culture, value);
|
||||
var text = GetValueText(culture, value);
|
||||
if (text != null)
|
||||
{
|
||||
result.Add(text, value);
|
||||
@ -88,9 +87,9 @@ namespace ASC.Web.Core.Helpers
|
||||
/// <returns>The localized text</returns>
|
||||
private string GetValueText(CultureInfo culture, object value)
|
||||
{
|
||||
Type type = value.GetType();
|
||||
string resourceName = string.Format("{0}_{1}", type.Name, value.ToString());
|
||||
string result = _resourceManager.GetString(resourceName, culture);
|
||||
var type = value.GetType();
|
||||
var resourceName = string.Format("{0}_{1}", type.Name, value.ToString());
|
||||
var result = _resourceManager.GetString(resourceName, culture);
|
||||
if (result == null)
|
||||
result = resourceName;
|
||||
return result;
|
||||
@ -133,14 +132,14 @@ namespace ASC.Web.Core.Helpers
|
||||
//
|
||||
ulong lValue = Convert.ToUInt32(value);
|
||||
string result = null;
|
||||
foreach (object flagValue in _flagValues)
|
||||
foreach (var flagValue in _flagValues)
|
||||
{
|
||||
ulong lFlagValue = Convert.ToUInt32(flagValue);
|
||||
if (IsSingleBitValue(lFlagValue))
|
||||
{
|
||||
if ((lFlagValue & lValue) == lFlagValue)
|
||||
{
|
||||
string valueText = GetValueText(culture, flagValue);
|
||||
var valueText = GetValueText(culture, flagValue);
|
||||
if (result == null)
|
||||
{
|
||||
result = valueText;
|
||||
@ -163,9 +162,8 @@ namespace ASC.Web.Core.Helpers
|
||||
/// <returns>The enum value</returns>
|
||||
private object GetValue(CultureInfo culture, string text)
|
||||
{
|
||||
LookupTable lookupTable = GetLookupTable(culture);
|
||||
object result = null;
|
||||
lookupTable.TryGetValue(text, out result);
|
||||
var lookupTable = GetLookupTable(culture);
|
||||
lookupTable.TryGetValue(text, out var result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -177,14 +175,13 @@ namespace ASC.Web.Core.Helpers
|
||||
/// <returns>The enum value</returns>
|
||||
private object GetFlagValue(CultureInfo culture, string text)
|
||||
{
|
||||
LookupTable lookupTable = GetLookupTable(culture);
|
||||
string[] textValues = text.Split(',');
|
||||
var lookupTable = GetLookupTable(culture);
|
||||
var textValues = text.Split(',');
|
||||
ulong result = 0;
|
||||
foreach (string textValue in textValues)
|
||||
foreach (var textValue in textValues)
|
||||
{
|
||||
object value = null;
|
||||
string trimmedTextValue = textValue.Trim();
|
||||
if (!lookupTable.TryGetValue(trimmedTextValue, out value))
|
||||
var trimmedTextValue = textValue.Trim();
|
||||
if (!lookupTable.TryGetValue(trimmedTextValue, out var value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -202,7 +199,7 @@ namespace ASC.Web.Core.Helpers
|
||||
: base(type)
|
||||
{
|
||||
_resourceManager = resourceManager;
|
||||
object[] flagAttributes = type.GetCustomAttributes(typeof(FlagsAttribute), true);
|
||||
var flagAttributes = type.GetCustomAttributes(typeof(FlagsAttribute), true);
|
||||
_isFlagEnum = flagAttributes.Length > 0;
|
||||
if (_isFlagEnum)
|
||||
{
|
||||
@ -221,7 +218,7 @@ namespace ASC.Web.Core.Helpers
|
||||
{
|
||||
if (value is string)
|
||||
{
|
||||
object result = (_isFlagEnum) ?
|
||||
var result = (_isFlagEnum) ?
|
||||
GetFlagValue(culture, (string)value) : GetValue(culture, (string)value);
|
||||
if (result == null)
|
||||
{
|
||||
@ -264,7 +261,7 @@ namespace ASC.Web.Core.Helpers
|
||||
/// <returns>The localized string value for the enum</returns>
|
||||
static public string ConvertToString(Enum value)
|
||||
{
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(value.GetType());
|
||||
var converter = TypeDescriptor.GetConverter(value.GetType());
|
||||
return converter.ConvertToString(value);
|
||||
}
|
||||
|
||||
@ -284,11 +281,11 @@ namespace ASC.Web.Core.Helpers
|
||||
/// </remarks>
|
||||
static public List<KeyValuePair<Enum, string>> GetValues(Type enumType, CultureInfo culture)
|
||||
{
|
||||
List<KeyValuePair<Enum, string>> result = new List<KeyValuePair<Enum, string>>();
|
||||
TypeConverter converter = TypeDescriptor.GetConverter(enumType);
|
||||
var result = new List<KeyValuePair<Enum, string>>();
|
||||
var converter = TypeDescriptor.GetConverter(enumType);
|
||||
foreach (Enum value in Enum.GetValues(enumType))
|
||||
{
|
||||
KeyValuePair<Enum, string> pair = new KeyValuePair<Enum, string>(value, converter.ConvertToString(null, culture, value));
|
||||
var pair = new KeyValuePair<Enum, string>(value, converter.ConvertToString(null, culture, value));
|
||||
result.Add(pair);
|
||||
}
|
||||
return result;
|
||||
|
@ -154,10 +154,9 @@ namespace ASC.Web.Core.Mail
|
||||
.Select(r => Convert.ToString(r[0]))
|
||||
.FirstOrDefault();
|
||||
|
||||
IPAddress ipAddress;
|
||||
string hostname;
|
||||
|
||||
if (IPAddress.TryParse(ip, out ipAddress))
|
||||
if (IPAddress.TryParse(ip, out var ipAddress))
|
||||
{
|
||||
selectQuery = new SqlQuery("greylisting_whitelist")
|
||||
.Select("Comment")
|
||||
|
@ -65,9 +65,8 @@ namespace ASC.Web.Core.Mobile
|
||||
|
||||
var fromCache = cache.Get<String>(GetCacheKey(userEmail, appType));
|
||||
|
||||
bool cachedValue;
|
||||
|
||||
if (bool.TryParse(fromCache, out cachedValue))
|
||||
if (bool.TryParse(fromCache, out var cachedValue))
|
||||
{
|
||||
return cachedValue;
|
||||
}
|
||||
|
@ -63,9 +63,8 @@ namespace ASC.Web.Core.Mobile
|
||||
{
|
||||
var key = "mobileDetector/" + ua.GetHashCode();
|
||||
|
||||
bool fromCache;
|
||||
|
||||
if (bool.TryParse(cache.Get<string>(key), out fromCache))
|
||||
if (bool.TryParse(cache.Get<string>(key), out var fromCache))
|
||||
{
|
||||
result = fromCache;
|
||||
}
|
||||
|
@ -244,10 +244,8 @@ namespace ASC.Web.Studio.Core.Notify
|
||||
}
|
||||
}
|
||||
|
||||
IProduct product;
|
||||
IModule module;
|
||||
//TODOL httpContext
|
||||
CommonLinkUtility.GetLocationByRequest(tenant, out product, out module, null);
|
||||
CommonLinkUtility.GetLocationByRequest(tenant, out var product, out var module, null);
|
||||
if (product == null && CallContext.GetData("asc.web.product_id") != null)
|
||||
{
|
||||
product = WebItemManager.Instance[(Guid)CallContext.GetData("asc.web.product_id")] as IProduct;
|
||||
|
@ -1062,7 +1062,7 @@ namespace ASC.Web.Studio.Core.Notify
|
||||
Func<string> greenButtonText = () => string.Empty;
|
||||
var greenButtonUrl = string.Empty;
|
||||
|
||||
int sendCount = 0;
|
||||
var sendCount = 0;
|
||||
|
||||
CoreContext.TenantManager.SetCurrentTenant(tenant.TenantId);
|
||||
|
||||
|
@ -248,8 +248,7 @@ namespace ASC.Web.Studio.Core.Notify
|
||||
var hourToSend = 7;
|
||||
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["web.whatsnew-time"]))
|
||||
{
|
||||
var hour = 0;
|
||||
if (int.TryParse(ConfigurationManager.AppSettings["web.whatsnew-time"], out hour))
|
||||
if (int.TryParse(ConfigurationManager.AppSettings["web.whatsnew-time"], out var hour))
|
||||
{
|
||||
hourToSend = hour;
|
||||
}
|
||||
|
@ -51,8 +51,7 @@ namespace ASC.Web.Core.Sms
|
||||
KeyLength = 6;
|
||||
}
|
||||
|
||||
int store;
|
||||
if (!int.TryParse(ConfigurationManager.AppSettings["sms:keystore"], out store))
|
||||
if (!int.TryParse(ConfigurationManager.AppSettings["sms:keystore"], out var store))
|
||||
{
|
||||
store = 10;
|
||||
}
|
||||
@ -125,8 +124,7 @@ namespace ASC.Web.Core.Sms
|
||||
}
|
||||
|
||||
var cacheCheck = BuildCacheKey("check" + phone);
|
||||
int counter;
|
||||
int.TryParse(CheckCache.Get<String>(cacheCheck), out counter);
|
||||
int.TryParse(CheckCache.Get<String>(cacheCheck), out var counter);
|
||||
if (++counter > AttemptCount)
|
||||
return Result.TooMuch;
|
||||
CheckCache.Insert(cacheCheck, counter.ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(StoreInterval));
|
||||
|
@ -82,8 +82,7 @@ namespace ASC.Web.Studio.Core.SMS
|
||||
|
||||
if (SmsKeyStorage.ExistsKey(mobilePhone) && !again) return;
|
||||
|
||||
string key;
|
||||
if (!SmsKeyStorage.GenerateKey(mobilePhone, out key)) throw new Exception(Resource.SmsTooMuchError);
|
||||
if (!SmsKeyStorage.GenerateKey(mobilePhone, out var key)) throw new Exception(Resource.SmsTooMuchError);
|
||||
if (SmsSender.SendSMS(mobilePhone, string.Format(Resource.SmsAuthenticationMessageToUser, key)))
|
||||
{
|
||||
CoreContext.TenantManager.SetTenantQuotaRow(new TenantQuotaRow { Tenant = TenantProvider.CurrentTenantID, Path = "/sms", Counter = 1 }, true);
|
||||
|
@ -286,8 +286,7 @@ namespace ASC.Web.Core.Sms
|
||||
|
||||
public bool ValidateKeys()
|
||||
{
|
||||
double balance;
|
||||
return double.TryParse(GetBalance(true), NumberStyles.Number, CultureInfo.InvariantCulture, out balance) && balance > 0;
|
||||
return double.TryParse(GetBalance(true), NumberStyles.Number, CultureInfo.InvariantCulture, out var balance) && balance > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,7 @@ namespace ASC.Web.Studio.Core.TFA
|
||||
|
||||
if (string.IsNullOrEmpty(code)) throw new Exception(Resource.ActivateTfaAppEmptyCode);
|
||||
|
||||
int counter;
|
||||
int.TryParse(Cache.Get<string>("tfa/" + user.ID), out counter);
|
||||
int.TryParse(Cache.Get<string>("tfa/" + user.ID), out var counter);
|
||||
if (++counter > SetupInfo.LoginThreshold)
|
||||
{
|
||||
throw new BruteForceCredentialException(Resource.TfaTooMuchError);
|
||||
|
@ -88,7 +88,7 @@ namespace ASC.Web.Core.Users.Import
|
||||
var fieldsCount = GetFieldsMapping(fileLines[0], infos, mappedProperties);
|
||||
|
||||
//Begin read file
|
||||
for (int i = 1; i < fileLines.Count; i++)
|
||||
for (var i = 1; i < fileLines.Count; i++)
|
||||
{
|
||||
users.Add(GetExportedUser(fileLines[i], mappedProperties, fieldsCount));
|
||||
}
|
||||
@ -102,14 +102,14 @@ namespace ASC.Web.Core.Users.Import
|
||||
exportedUser.ID = Guid.NewGuid();
|
||||
|
||||
var dataFields = GetDataFields(line);
|
||||
for (int j = 0; j < Math.Min(fieldsCount, dataFields.Length); j++)
|
||||
for (var j = 0; j < Math.Min(fieldsCount, dataFields.Length); j++)
|
||||
{
|
||||
//Get corresponding property
|
||||
var propinfo = mappedProperties[j];
|
||||
if (propinfo != null)
|
||||
{
|
||||
//Convert value
|
||||
object value = ConvertFromString(dataFields[j], propinfo.PropertyType);
|
||||
var value = ConvertFromString(dataFields[j], propinfo.PropertyType);
|
||||
if (value != null)
|
||||
{
|
||||
propinfo.SetValue(exportedUser, value, new object[] { });
|
||||
@ -140,7 +140,7 @@ namespace ASC.Web.Core.Users.Import
|
||||
private int GetFieldsMapping(string firstLine, IEnumerable<PropertyInfo> infos, IDictionary<int, PropertyInfo> mappedProperties)
|
||||
{
|
||||
var fields = firstLine.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
for (var i = 0; i < fields.Length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
//Find apropriate field in UserInfo
|
||||
|
@ -54,7 +54,7 @@ namespace ASC.Web.Core.Users
|
||||
|
||||
public int Compare(UserInfo x, UserInfo y)
|
||||
{
|
||||
int result = 0;
|
||||
var result = 0;
|
||||
switch (SortOrder)
|
||||
{
|
||||
case UserSortOrder.DisplayName:
|
||||
|
@ -113,7 +113,7 @@ namespace ASC.Web.Core.Users
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int result = UserId.GetHashCode();
|
||||
var result = UserId.GetHashCode();
|
||||
result = (result * 397) ^ MaxFileSize.GetHashCode();
|
||||
result = (result * 397) ^ Size.GetHashCode();
|
||||
return result;
|
||||
@ -516,8 +516,7 @@ namespace ASC.Web.Core.Users
|
||||
|
||||
public static string SaveOrUpdatePhoto(Tenant tenant, Guid userID, byte[] data)
|
||||
{
|
||||
string fileName;
|
||||
return SaveOrUpdatePhoto(tenant, userID, data, -1, OriginalFotoSize, true, out fileName);
|
||||
return SaveOrUpdatePhoto(tenant, userID, data, -1, OriginalFotoSize, true, out var fileName);
|
||||
}
|
||||
|
||||
public static void RemovePhoto(Tenant tenant, Guid idUser)
|
||||
@ -528,10 +527,7 @@ namespace ASC.Web.Core.Users
|
||||
|
||||
private static string SaveOrUpdatePhoto(Tenant tenant, Guid userID, byte[] data, long maxFileSize, Size size, bool saveInCoreContext, out string fileName)
|
||||
{
|
||||
ImageFormat imgFormat;
|
||||
int width;
|
||||
int height;
|
||||
data = TryParseImage(data, maxFileSize, size, out imgFormat, out width, out height);
|
||||
data = TryParseImage(data, maxFileSize, size, out var imgFormat, out var width, out var height);
|
||||
|
||||
var widening = CommonPhotoManager.GetImgFormatName(imgFormat);
|
||||
fileName = string.Format("{0}_orig_{1}-{2}.{3}", userID, width, height, widening);
|
||||
@ -739,10 +735,7 @@ namespace ASC.Web.Core.Users
|
||||
|
||||
public static string SaveTempPhoto(byte[] data, long maxFileSize, int maxWidth, int maxHeight)
|
||||
{
|
||||
ImageFormat imgFormat;
|
||||
int width;
|
||||
int height;
|
||||
data = TryParseImage(data, maxFileSize, new Size(maxWidth, maxHeight), out imgFormat, out width, out height);
|
||||
data = TryParseImage(data, maxFileSize, new Size(maxWidth, maxHeight), out var imgFormat, out var width, out var height);
|
||||
|
||||
var fileName = Guid.NewGuid() + "." + CommonPhotoManager.GetImgFormatName(imgFormat);
|
||||
|
||||
|
@ -77,8 +77,7 @@ namespace ASC.Web.Core.Utility
|
||||
{
|
||||
_default = new PasswordSettings { MinLength = 6, UpperCase = false, Digits = false, SpecSymbols = false };
|
||||
|
||||
int defaultMinLength;
|
||||
if (int.TryParse(ConfigurationManager.AppSettings["web.password.min"], out defaultMinLength))
|
||||
if (int.TryParse(ConfigurationManager.AppSettings["web.password.min"], out var defaultMinLength))
|
||||
{
|
||||
_default.MinLength = Math.Max(1, Math.Min(MaxLength, defaultMinLength));
|
||||
}
|
||||
|
@ -130,8 +130,7 @@ namespace ASC.Web.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
IWebItem i;
|
||||
items.TryGetValue(id, out i);
|
||||
items.TryGetValue(id, out var i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +136,7 @@ namespace ASC.Web.Core.WhiteLabel
|
||||
var cookie = request.Cookies["is_retina"];
|
||||
if (cookie != null && !String.IsNullOrEmpty(cookie))
|
||||
{
|
||||
bool result;
|
||||
if (Boolean.TryParse(cookie, out result))
|
||||
if (Boolean.TryParse(cookie, out var result))
|
||||
{
|
||||
isRetina = result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user