Esempio n. 1
0
    private string StartCampaign(int iItem, int iFileID, ref string strErrorCode)
    {
        string         ReturnMessage = string.Empty;
        ServiceManager sm            = new ServiceManager();

        using (LP2ServiceClient service = sm.StartServiceClient())
        {
            StartCampaignRequest req = new StartCampaignRequest();
            req.hdr = new ReqHdr();
            req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data
            req.hdr.UserId        = this.CurrUser.iUserID;
            req.CampaignId        = iItem;
            req.FileId            = new int[1] {
                iFileID
            };

            StartCampaignResponse respone = null;
            try
            {
                respone = service.StartCampaign(req);
                if (respone.hdr.Successful)
                {
                    ReturnMessage = "";
                }
                else
                {
                    strErrorCode  = respone.ErrorCode;
                    ReturnMessage = respone.hdr.StatusInfo;
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                string sExMsg = string.Format("Exception happened when StartCampaign (FileID={0}): {1}", iFileID, "Marketing Manager is not running.");
                LPLog.LogMessage(LogType.Logerror, sExMsg);
                ReturnMessage = sExMsg;
            }
            catch (Exception ex)
            {
                string sExMsg = string.Format("Exception happened when StartCampaign (FileID={0}): {1}", iFileID, ex.Message);
                LPLog.LogMessage(LogType.Logerror, sExMsg);
                ReturnMessage = sExMsg;
            }

            return(ReturnMessage);
        }
    }