示例#1
0
        public async Task <bool> PutSchedule(SingleSend singleSend, string singleSendId)
        {
            string        json = JsonConvert.SerializeObject(singleSend);
            StringContent data = new StringContent(json, Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await Apihelper.apiClient.PutAsync($"https://api.sendgrid.com/v3/marketing/singlesends/{singleSendId}/schedule", data))
            {
                return(response.IsSuccessStatusCode);
            }
        }
示例#2
0
        public async Task PathSingleSend(SingleSend singleSend, string singleSendId)
        {
            HttpClientPath PathAsync = new HttpClientPath(Apihelper.apiClient);
            string         json      = JsonConvert.SerializeObject(singleSend);
            StringContent  data      = new StringContent(json, Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await PathAsync.PatchAsync($"https://api.sendgrid.com/v3/marketing/singlesends/{singleSendId}", data))
            {
                //if (response.IsSuccessStatusCode)
                //    result = response.Content.ReadAsStringAsync().Result;
            }
        }
示例#3
0
        private void CreateSingleSend(IOrganizationService service, CrmEarlyBound.Campaign campaign, ApiRoot root)
        {
            EmailConfig emailConfig = new EmailConfig(campaign.find_Subject);
            SingleSend  singleSend  = new SingleSend(campaign.Name, emailConfig);

            Task <MailChimpCampaign> t = Task.Run(() => root.PostSingleSend(singleSend));

            t.Wait();
            if (t.IsCompleted)
            {
                campaign.find_SendGridId = t.Result.Id;
                service.Update(campaign);
            }
        }
示例#4
0
        private void AssociateMarketingListToSendGrid(ApiRoot root, List <List> listLists, CrmEarlyBound.Campaign campaign)
        {
            List <string> listSendGridId = new List <string>();

            foreach (List lists in listLists)
            {
                listSendGridId.Add(lists.find_SendGridId);
            }

            SendTo     sendTo     = new SendTo(listSendGridId);
            SingleSend singleSend = new SingleSend(sendTo);

            Task t = Task.Run(() => root.PathSingleSend(singleSend, campaign.find_SendGridId));

            t.Wait();
        }
示例#5
0
        private bool PutScheduleNow(Campaign campaign, find_marketingautomationintegration mailChimpObj, ApiRoot root)
        {
            Apihelper.InitializeClient(mailChimpObj.find_SendGridIntegration);
            SingleSend singleSend = new SingleSend("now");

            Task <bool> t = Task.Run(() => root.PutSchedule(singleSend, campaign.find_SendGridId));

            t.Wait();
            if (t.IsCompleted)
            {
                return(t.Result);
            }
            else
            {
                throw new Exception();
            }
        }
示例#6
0
        /// <summary>
        /// 开始选人,创建选人房间
        /// </summary>
        /// <param name="team1"></param>
        /// <param name="team2"></param>
        /// <param name="clientList"></param>
        public void CreateRoom(List <int> team1, List <int> team2)
        {
            SelectRoom room = null;

            //取不出来重用房间
            if (!roomQue.TryDequeue(out room))
            {
                room = new SelectRoom(index, team1.Count + team2.Count);
                index++;
            }
            //能取出来
            room.InitRoom(team1, team2);
            //绑定玩家ID和房间ID
            foreach (int item in team1)
            {
                playerRoomDict.TryAdd(item, room.Id);
            }
            foreach (int item in team2)
            {
                playerRoomDict.TryAdd(item, room.Id);
            }
            //绑定房间ID和房间
            idRoomDict.TryAdd(room.Id, room);

            //创建成功了
            //开启一个定时任务,通知玩家 10S之内进入房间 否则房间自动销毁
            room.StartSchedule(DateTime.UtcNow.AddSeconds(10),
                               () =>
            {
                //销毁房间的回调
                if (!room.IsAllEnter)
                {
                    SingleSend ss = new SingleSend();
                    foreach (int item in playerRoomDict.Keys)
                    {
                        MobaClient c = playerCache.GetClient(item);
                        ss.Send(c, OpCode.SelectCode, OpSelect.Destroy, 0, "有人未进入 解散当前选人");
                    }

                    room.Brocast(OpCode.SelectCode, OpSelect.Destroy, 0, "有人未进入 解散当前选人");
                }
                Destroy(room.Id);
            });
        }
示例#7
0
        private void PutScheduleNow(IOrganizationService service, Campaign campaign, find_marketingautomationintegration mailChimpObj, ApiRoot root, string dateTime)
        {
            Apihelper.InitializeClient(mailChimpObj.find_SendGridIntegration);
            SingleSend singleSend = new SingleSend(dateTime);

            Task <bool> t = Task.Run(() => root.PutSchedule(singleSend, campaign.find_SendGridId));

            t.Wait();
            if (t.IsCompleted && t.Result)
            {
                campaign.find_mail_integration_started = true;
                campaign.find_Schedule = DateTime.Parse(dateTime);
                service.Update(campaign);
            }
            else
            {
                throw new Exception();
            }
        }
示例#8
0
        public async Task <MailChimpCampaign> PostSingleSend(SingleSend singleSend)
        {
            string        json = JsonConvert.SerializeObject(singleSend);
            StringContent data = new StringContent(json, Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await Apihelper.apiClient.PostAsync("https://api.sendgrid.com/v3/marketing/singlesends", data))
            {
                if (response.IsSuccessStatusCode)
                {
                    string objResponse = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <MailChimpCampaign>(objResponse));
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }