コード例 #1
0
        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)
                    {
                    }
                });
            }
        }
コード例 #2
0
        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;
        }
コード例 #3
0
ファイル: Common.cs プロジェクト: Lantnr/MyTest
 /// <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);
 }
コード例 #4
0
 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;
 }
コード例 #5
0
        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;
        }
コード例 #6
0
 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;
 }
コード例 #7
0
 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);
 }
コード例 #8
0
        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)));
        }
コード例 #9
0
        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))
            });
        }
コード例 #10
0
        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));
                });
            }
        }
コード例 #11
0
 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));
 }
コード例 #12
0
 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));
 }
コード例 #13
0
 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));
 }
コード例 #14
0
 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));
 }
コード例 #15
0
        /// <summary>
        /// 初始化职业任务
        /// </summary>
        private static void VocationTaskInit(Int64 userid, int identify, int vocation)
        {
            var newtasks = TaskCommon.GetNewVocationTasks(identify, userid, vocation);

            tg_task.GetListInsert(newtasks);
        }