public void Test() { TaskCommon <string, object> taskCommon = new TaskCommon <string, object>(20); List <Users> userses = new List <Users>(); for (var i = 0; i < 30; i++) { userses.Add(new Users() { Name = "我的名字是" + i }); } foreach (var item in userses) { taskCommon.Add(item.Name, (name, cts) => { cts.Cancel(); //取消任务 Console.WriteLine("我的名字是:" + name); Thread.Sleep(new Random().Next(1000, 3999)); return("结束了" + "我的名字是:" + name); }, (state, res, exception) => { if (state) { } }); } }
public void ParallelExecute() { DateTime startTime = DateTime.Now; List <string> studentList = "小李,小王,小红".ConvertStrToList <string>(','); List <JobItem> jobItems = studentList.Select(x => new JobItem(x)).ToList(); var list = TaskCommon.ParallelExecute((item) => { if (item.Source.ToString() == "小王") { item.SetResponse("优秀"); Thread.Sleep(3000); } else if (item.Source.ToString() == "小李") { item.SetResponse("良好"); Thread.Sleep(1000); } else if (item.Source.ToString() == "小红") { item.SetResponse("学渣"); Thread.Sleep(2000); } //线程等待是为了估计造成计算缓慢的情况 }, jobItems); double duration = (DateTime.Now - startTime).TotalMilliseconds; }
/// <summary> 获取奖励字符串 </summary> public string GetRewardString(string maxc, string maxr, string mc, string mr, string reward, RoleItem role) { role = role.CloneEntity(); if (TaskCommon.CheckRewardCondition(maxc, role)) { return(maxr); } return(TaskCommon.CheckRewardCondition(mc, role) ? mr : reward); }
public InboundConnector(TenantInboundConnector ic) { this.Identity = (ADObjectId)ic.Identity; this.Name = ic.Name; this.TLSSenderCertificateName = TaskCommon.ToStringOrNull(ic.TlsSenderCertificateName); this.ConnectorType = ic.ConnectorType; this.ConnectorSource = ic.ConnectorSource; this.SenderDomains = ic.SenderDomains; this.RequireTls = ic.RequireTls; this.CloudServicesMailEnabled = ic.CloudServicesMailEnabled; }
public InboundConnector(string name, SmtpX509Identifier tlsSenderCertificateName) { MultiValuedProperty <AddressSpace> multiValuedProperty = new MultiValuedProperty <AddressSpace>(); multiValuedProperty.Add(new AddressSpace("*")); this.Name = name; this.TLSSenderCertificateName = TaskCommon.ToStringOrNull(tlsSenderCertificateName); this.ConnectorType = TenantConnectorType.OnPremises; this.SenderDomains = multiValuedProperty; this.RequireTls = true; this.CloudServicesMailEnabled = true; }
public OutboundConnector(TenantOutboundConnector oc) { this.Identity = (ADObjectId)oc.Identity; this.Name = oc.Name; this.TlsDomain = TaskCommon.ToStringOrNull(oc.TlsDomain); this.ConnectorType = oc.ConnectorType; this.ConnectorSource = oc.ConnectorSource; this.RecipientDomains = oc.RecipientDomains; this.SmartHosts = oc.SmartHosts; this.TlsSettings = oc.TlsSettings; this.CloudServicesMailEnabled = oc.CloudServicesMailEnabled; this.RouteAllMessagesViaOnPremises = oc.RouteAllMessagesViaOnPremises; }
public SendConnector(SmtpSendConnectorConfig sc) { this.Identity = (ADObjectId)sc.Identity; this.Name = sc.Name; this.AddressSpaces = sc.AddressSpaces; this.SourceTransportServers = sc.SourceTransportServers; this.DNSRoutingEnabled = sc.DNSRoutingEnabled; this.SmartHosts = sc.SmartHosts; this.RequireTLS = sc.RequireTLS; this.TlsAuthLevel = sc.TlsAuthLevel; this.TlsDomain = TaskCommon.ToStringOrNull(sc.TlsDomain); this.ErrorPolicies = sc.ErrorPolicies; this.TlsCertificateName = sc.TlsCertificateName; this.CloudServicesMailEnabled = sc.CloudServicesMailEnabled; this.Fqdn = TaskCommon.ToStringOrNull(sc.Fqdn); }
private static string ToString <T>(MultiValuedProperty <T> value) { Func <T, string> func = null; if (value == null) { return(string.Empty); } string separator = ", "; if (func == null) { func = ((T v) => TaskCommon.ToStringOrNull(v)); } return(string.Join(separator, value.Select(func))); }
private IList <Tuple <string, string> > GetHybridConfigurationObjectValues() { HybridConfiguration dataObject = this.DataObject; return(new List <Tuple <string, string> > { new Tuple <string, string>("Features", UpdateHybridConfiguration.ToString <HybridFeature>(dataObject.Features)), new Tuple <string, string>("Domains", UpdateHybridConfiguration.ToString <AutoDiscoverSmtpDomain>(dataObject.Domains)), new Tuple <string, string>("OnPremisesSmartHost", TaskCommon.ToStringOrNull(dataObject.OnPremisesSmartHost)), new Tuple <string, string>("ClientAccessServers", UpdateHybridConfiguration.ToString <ADObjectId>(dataObject.ClientAccessServers)), new Tuple <string, string>("EdgeTransportServers", UpdateHybridConfiguration.ToString <ADObjectId>(dataObject.EdgeTransportServers)), new Tuple <string, string>("ReceivingTransportServers", UpdateHybridConfiguration.ToString <ADObjectId>(dataObject.ReceivingTransportServers)), new Tuple <string, string>("SendingTransportServers", UpdateHybridConfiguration.ToString <ADObjectId>(dataObject.SendingTransportServers)), new Tuple <string, string>("TlsCertificateName", TaskCommon.ToStringOrNull(dataObject.TlsCertificateName)), new Tuple <string, string>("ServiceInstance", TaskCommon.ToStringOrNull(dataObject.ServiceInstance)) }); }
public void Test2() { TaskCommon <string> taskCommon = new TaskCommon <string>(20); List <Users> userses = new List <Users>(); for (var i = 0; i < 30; i++) { userses.Add(new Users() { Name = "我的名字是" + i }); } foreach (var item in userses) { taskCommon.Add(item.Name, (name, cts) => { Console.WriteLine("我的名字是:" + name); Thread.Sleep(new Random().Next(1000, 3999)); }); } }
public bool Equals(ISendConnector obj) { return(this.CloudServicesMailEnabled == obj.CloudServicesMailEnabled && string.Equals(this.Name, obj.Name, StringComparison.InvariantCultureIgnoreCase) && this.RequireTLS == obj.RequireTLS && this.DNSRoutingEnabled == obj.DNSRoutingEnabled && this.TlsAuthLevel == obj.TlsAuthLevel && this.ErrorPolicies == obj.ErrorPolicies && string.Equals(this.TlsDomain, obj.TlsDomain, StringComparison.InvariantCultureIgnoreCase) && TaskCommon.AreEqual(this.TlsCertificateName, obj.TlsCertificateName) && TaskCommon.ContainsSame <AddressSpace>(this.AddressSpaces, obj.AddressSpaces) && TaskCommon.ContainsSame <SmartHost>(this.SmartHosts, obj.SmartHosts) && TaskCommon.ContainsSame <ADObjectId>(this.SourceTransportServers, obj.SourceTransportServers) && string.Equals(this.Fqdn, obj.Fqdn, StringComparison.InvariantCultureIgnoreCase)); }
public bool Equals(IInboundConnector obj) { return(this.RequireTls == obj.RequireTls && this.ConnectorType == obj.ConnectorType && this.CloudServicesMailEnabled == obj.CloudServicesMailEnabled && string.Equals(this.Name, obj.Name, StringComparison.InvariantCultureIgnoreCase) && string.Equals(this.TLSSenderCertificateName, obj.TLSSenderCertificateName, StringComparison.InvariantCultureIgnoreCase) && TaskCommon.ContainsSame <AddressSpace>(this.SenderDomains, obj.SenderDomains)); }
public bool Equals(IOutboundConnector obj) { return(this.TlsSettings == obj.TlsSettings && this.ConnectorType == obj.ConnectorType && this.CloudServicesMailEnabled == obj.CloudServicesMailEnabled && this.RouteAllMessagesViaOnPremises == obj.RouteAllMessagesViaOnPremises && TaskCommon.ContainsSame <SmartHost>(this.SmartHosts, obj.SmartHosts) && string.Equals(this.Name, obj.Name, StringComparison.InvariantCultureIgnoreCase) && string.Equals(this.TlsDomain, obj.TlsDomain, StringComparison.InvariantCultureIgnoreCase) && TaskCommon.ContainsSame <SmtpDomainWithSubdomains>(this.RecipientDomains, obj.RecipientDomains)); }
public bool Equals(IReceiveConnector obj) { return(obj != null && string.Equals(this.Server.Name, obj.Server.Name, StringComparison.InvariantCultureIgnoreCase) && TaskCommon.AreEqual(this.TlsCertificateName, obj.TlsCertificateName) && ReceiveConnector.AreEqual(this.TlsDomainCapabilities, obj.TlsDomainCapabilities)); }
/// <summary> /// 初始化职业任务 /// </summary> private static void VocationTaskInit(Int64 userid, int identify, int vocation) { var newtasks = TaskCommon.GetNewVocationTasks(identify, userid, vocation); tg_task.GetListInsert(newtasks); }