예제 #1
0
      internal void Handle(StopCampaign request) {
         var resp = new StopCampaignResponse() { swlr = SwlResult.GENERAL_FAIL };

         using (var dbConn = DatabaseManager.DbConn()) {
            var ci = dbConn.ExecuteBpl(new CampaignGetById(request.CampaignId));
            if (ci == null) {
               Log.Error("Campaign with Id {0} not found in database", request.CampaignId);
               resp.swlr = SwlResult.NOT_FOUND;
               goto Exit;
            }

            var targets = dbConn.ExecuteBpl(new CampaignTargetGetByCampaignId { CampaignId = ci.CampaignId });
            foreach (var target in targets) {
               if ((int)target.Status < 3) {
                  resp.swlr = LogisticsHelpers.CampaignTargetSetStatus(dbConn, target.TargetId, CampaignTargetStatus.Canceled);
                  if (resp.swlr != SwlResult.OK) {
                     goto Exit;
                  }
               }
            }

            resp.swlr = LogisticsHelpers.CampaignCheckStatus(dbConn, ci.CampaignId); ;
         }

         Exit:
         Reply(resp);
      }
예제 #2
0
      private void _btnStopOnClick(object sender, EventArgs e) {
         if (listCampaigns.SelectedItems.Count == 0) {
            return;
         }

         var campaignItem = (CampaignListItem)listCampaigns.SelectedItems[0];

         if (campaignItem.Campaign.WorkStatus == CampaignWorkStatus.Closed) {
            return;
         }

         var b = MessageBox.Show("All running tasks of the campaign will be stopped\r\nAre your sure to stop ?", "Stop Campaign \x22" + campaignItem.Campaign.Name + "\x22", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (b != DialogResult.Yes) {
            return;
         }

         var req = new StopCampaign();
         req.CampaignId = campaignItem.Campaign.CampaignId;

         SendRequest(req);
      }