Пример #1
0
        public void TestCreateNewCampaign()
        {
            _campaignCode = GetNewCampaignName();
            _creatorEmailAddress = TestUser;
            CampaignDto dto = new CampaignDto(_campaignCode, _creatorEmailAddress);

            _currentCampaign = FormRegistry.CampaignDao.Create(dto);
            Assert.IsNotNull(_currentCampaign);
        }
Пример #2
0
        public CampaignDto CreateNewCampaign()
        {            
            _campaignCode = GetNewCampaignName();
            _creatorEmailAddress = TestUser;

            _currentCampaign = FormRegistry.CampaignDao.Create(new CampaignDto(_campaignCode, _creatorEmailAddress));
            Assert.IsNotNull(_currentCampaign);
            _createdCampaigns.Add(_campaignCode);
            return _currentCampaign;
        }
Пример #3
0
 public void CreateNewQuestionnairePage()
 {
     _validCampaign = CreateNewCampaign();
     _validQuestionnaire = CreateNewQuestionnaire();
     _validPage = CreateNewFormPage();
     CreateNewPage(PageType.ClosurePage);
     _inValidQuestionnaire = CreateNewQuestionnaire(false);
     _inValidPage = CreateNewFormPage();
     CreateNewPage(PageType.ClosurePage);
     //if(setup)CreateNewQuestionairePage(out _validCampaign, out _validQuestionnaire, out _validPage, false);
     //if (setup) CreateNewQuestionairePage(out _inValidCampaign, out _inValidQuestionnaire, out _inValidPage, true);
 }
Пример #4
0
        public void TestCreateListDelete()
        {
            string campaignCode = GetNewCampaignName();
            string creatorEmailAddress = TestUser;
            CampaignDto dto = new CampaignDto(campaignCode, creatorEmailAddress);

            CampaignDto pers = FormRegistry.CampaignDao.Create(dto);
            Assert.IsNotNull(pers);
            _createdCampaigns.Add(pers.CampaignCode);
            
            List<CampaignDto> list = FormRegistry.CampaignDao.List(null, null, null, 1);
            Assert.IsTrue(list.Exists(delegate(CampaignDto cur) { return cur.CampaignCode == pers.CampaignCode && cur.CreatorEmailAddress == pers.CreatorEmailAddress; }));

            Assert.IsTrue(FormRegistry.CampaignDao.Delete(campaignCode, creatorEmailAddress));
            _createdCampaigns.Remove(pers.CampaignCode);
            
            list = FormRegistry.CampaignDao.List(null, null, null, 1);
            Assert.IsFalse(list.Exists(delegate(CampaignDto cur) { return cur.CampaignCode == pers.CampaignCode && cur.CreatorEmailAddress == pers.CreatorEmailAddress; }));
        }
Пример #5
0
        public CampaignDto Create(CampaignDto dto)
        {
            CampaignDto retval = null;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "insert_campaign";
                sp.CommandType = CommandType.StoredProcedure;
                _dbLayer.AddParameter(sp, "@campaign_code", ParameterDirection.Input, DbType.String, dto.CampaignCode);
                _dbLayer.AddParameter(sp, "@creator_user_FK", ParameterDirection.Input, DbType.String, dto.CreatorEmailAddress);
                _dbLayer.AddReturnParameter(sp);
                sp.ExecuteNonQuery();
                retval = dto;
            }
            catch (DbException e)
            {
                Trace.WriteLine("CampaignDao.Create(" + dto.CampaignCode + ", " + dto.CreatorEmailAddress + "): " + e.Message);
                retval = null;
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
                if (sp != null)
                    sp.Dispose();
                if (connection != null)
                {
                    _dbLayer.ReturnConnection(connection);
                }
                else
                {
                    _dbLayer.ReturnConnection(connection, true);
                }
            }
            return retval;
        }
Пример #6
0
		protected void create_btn_Click(object sender, System.EventArgs e)
		{
			//Verbindung herstellen
			//.NET 1.1: string connstr = ConfigurationSettings.AppSettings["dbconnstring"];
            //string connstr = ConfigurationManager.AppSettings["dbconnstring"];
            //SqlConnection cnn = new SqlConnection(connstr);
			
			mssg_campaign_exists.Text = string.Empty;

			string input_campaign_name;
			input_campaign_name = campaign_name.Text;

            //cnn.Open(); // soll explizit gemacht werden, bei SqlCommand

            if (this.IsValid)
            {
                CampaignDto campaign = new CampaignDto();
                campaign.CampaignCode = input_campaign_name;
                campaign.CreatorEmailAddress = permss.EmailAddress;

                try
                {
                    if (CampaignFacade.CreateNewCampaign(campaign) != null)
                    {
                        themeheaderTable.Visible = input_section.Visible = secondButtonTable.Visible = false;
                        creation_confirm.Visible = true;
                    }
                    else
                    {
                        mssg_campaign_exists.Text = "This campaign already exists - please choose another name";
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.StartsWith("Violation of PRIMARY KEY constraint 'PK_campaigns'"))
                    {
                        mssg_campaign_exists.Text = "This campaign already exists - please choose another name";
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }

            //SqlCommand cmd_campaign_in_stock = new SqlCommand("SELECT COUNT(campaign_code) AS campaign_exists FROM [campaigns] WHERE campaign_code = '" + input_campaign_name + "'", cnn);
            //SqlDataReader data_campaign_in_stock = cmd_campaign_in_stock.ExecuteReader();
            //data_campaign_in_stock.Read();
            //string campaign_exists;
            //campaign_exists = data_campaign_in_stock.GetValue(0).ToString();
            //data_campaign_in_stock.Close();
            //int int_campaign_exists;
            //int_campaign_exists = Int32.Parse(campaign_exists);
			
            //if (this.IsValid && int_campaign_exists == 0) // wenn campaign_name noch nicht vorhanden ist, dann einfügen
            //{
                //string insertstr = "INSERT INTO campaigns (campaign_code, creator_user_FK) VALUES ('" + input_campaign_name + "', '" + permss.user + "')";
                //SqlCommand cmd_insert_campaign = new SqlCommand(insertstr, cnn);
                //cmd_insert_campaign.ExecuteNonQuery();
                //cnn.Close();
            //    themeheaderTable.Visible=false;
            //    creation_confirm.Visible=true;
            //    input_section.Visible=false;
            //    secondButtonTable.Visible=false;
            //}
            //else
            //{
            //    if (int_campaign_exists != 0)
            //    {
            //        mssg_campaign_exists.Text = "This campaign already exists";
            //    }

            //}

            //cnn.Close(); // soll explizit gemacht werden, bei SqlCommand
		
		}
Пример #7
0
        public void CreateNewQuestionnairePage(out CampaignDto currentCampaign, out QuestionnaireDto currentQuestionnaire, out PageDto currentPage, bool registeredPersonalized)
        {

            List<PageTagDto> listOfPageTags = FormRegistry.QuestionnaireDao.GetPageTags();
            PageTagDto metaUserProfile = listOfPageTags.Find(pt => !String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("user_profile") &&
                    pt.TagValue.Equals("Non-targeted"));
            _campaignCode = GetNewCampaignName();
            _creatorEmailAddress = TestUser;

            currentCampaign = FormRegistry.CampaignDao.Create(new CampaignDto(_campaignCode, _creatorEmailAddress));
            
            QuestionnaireType type = QuestionnaireType.Questionnaire;
            string creatorEmailAddress = TestUser;
            string campaignCode = currentCampaign.CampaignCode;
            string countryCode = "UK";
            string languageCode = "EN";
            string qidTitle = "qidt" + GetNewStamp();
            bool isActive = true;
            DateTime expireDate = DateTime.Today.AddDays(10);
            string expireRedirect = "expire redirect";
            bool sendToCrm = true;
            string crmMrmCode = "crm mrm code";
            string crmWaveCode = "crm wave code";
            string treatmentCode = "treatment code";
            bool anyAsset = false;
            bool hppEnabled = false;
            bool personalized = false;
            //bool registeredPersonalized = false;
            bool hasClosurePage = true;
            string externalClosurePage = "external closure page";
            bool hasThankYouEmail = true;
            bool hasNotificationEmail = true;
            string themeColor = "#000000";
            string mainImage = "main image";
            string leftNavHtml = "left nav";
            string comments = "comments";
            int metaPageContent = 1;
            int metaSegment = 1;
            DateTime creationDate = DateTime.Today;
            string businessOwner = currentCampaign.CreatorEmailAddress;
            string urlLayoutForm = "url layout form";
            bool hasNotificationEmailAstro2 = true;
            DateTime? offlineStart = DateTime.Today.AddDays(7);
            DateTime? offlineEnd = DateTime.Today.AddDays(8);
            int? offlineMode = 1;
            DateTime? offlineRecurEnd = DateTime.Today.AddDays(9);
            string offlineRedirect = "offline redirect";
            string region = "EMEA";
            DateTime? datePublished = DateTime.Today.AddDays(10);
            DateTime? dateModified = DateTime.Today.AddDays(11);
            string metaPageContentValue = "meta content value";
            string metaSegmentValue = "meta segment value";
            string htmlLang = "html lang";
            int userProfile = metaUserProfile.TagId;
            string userProfileValue = metaUserProfile.TagValue;
            bool isGofaForm = false;
            DateTime? publishDate = DateTime.Today.AddDays(12);
            QuestionnaireDto dto = new QuestionnaireDto(type, creatorEmailAddress, campaignCode, countryCode, languageCode, qidTitle, isActive, expireDate, expireRedirect, sendToCrm, crmMrmCode, personalized, registeredPersonalized, hasClosurePage, externalClosurePage, hasThankYouEmail, hasNotificationEmail, themeColor, mainImage, leftNavHtml, comments, metaPageContent, metaSegment, creationDate, businessOwner, urlLayoutForm, hasNotificationEmailAstro2, offlineStart, offlineEnd, offlineMode, offlineRecurEnd, offlineRedirect, region, datePublished, dateModified, metaPageContentValue, metaSegmentValue, htmlLang, publishDate, crmWaveCode, hppEnabled, anyAsset, treatmentCode, userProfile, userProfileValue,isGofaForm,0,0,false,-1,0,null,0,0,0,1);
            currentQuestionnaire = FormRegistry.QuestionnaireDao.Create(dto, "insert");

            PageType pageType = PageType.FormPage;
            int questionnaireId = currentQuestionnaire.QuestionnaireId;
            string pageTitle = "test page";
            int? mdaId = null;
            string mdaFileName = null;
            string introduction = "intro";
            string requiredSentence = "required sentence";
            string buttonText = "save button";
            string leftNavHtml2 = "left nav html2";
            string pageTagline = "page tagline";
            string privacySentence = "privacy sentence";
            currentPage = FormRegistry.PageDao.Create(new PageDto(pageType, questionnaireId, pageTitle, mdaId, mdaFileName, introduction, requiredSentence, buttonText, leftNavHtml2, pageTagline, privacySentence));

        }
Пример #8
0
 private CampaignDto Read(IDataReader reader, ref bool alreadyRead)
 {
     CampaignDto retval = null;
     string campaignCode = reader.GetString(0);
     string creatorEmailAddress = reader.GetString(1);
     retval = new CampaignDto(campaignCode, creatorEmailAddress);
     alreadyRead = reader.Read();
     return retval;
 }
Пример #9
0
 protected virtual void TearDown()
 {
     bool failed = false;
     foreach (int id in _createdMasterReports)
     {
         try
         {
             FormRegistry.MasterReportDao.DeleteMasterReport(id);
         }
         catch (Exception e)
         {
             Trace.WriteLine("Exception during master report deletion: " + e);
             failed = true;
         }
     }
     _createdMasterReports.Clear();
     foreach (int pagePredefinedQuestionChoiceId in _createdPagePredefinedQuestionChoices)
     {
         try
         {
             FormRegistry.PredefinedQuestionDao.DeletePagePredefinedChoice(pagePredefinedQuestionChoiceId);
         }
         catch
         {
             failed = true;
         }
     }
     _createdPagePredefinedQuestionChoices.Clear();
     foreach (int pagePredefinedQuestionId in _createdPagePredefinedQuestions)
     {
         try
         {
             FormRegistry.PredefinedQuestionDao.DeletePagePredefinedQuestion(pagePredefinedQuestionId);
         }
         catch
         {
             failed = true;
         }
     }
     _createdPagePredefinedQuestions.Clear();
     foreach (int predefinedChoiceId in _createdPredefinedQuestionChoices)
     {
         try
         {
             FormRegistry.PredefinedQuestionDao.DeleteChoice(predefinedChoiceId);
         }
         catch
         {
             failed = true;
         }
     }
     _createdPredefinedQuestionChoices.Clear();
     foreach (int predefinedQuestionId in _createdPredefinedQuestions)
     {
         try
         {
             FormRegistry.PredefinedQuestionDao.DeletePredefinedQuestion(predefinedQuestionId);
         }
         catch
         {
             failed = true;
         }
     }
     _createdPredefinedQuestions.Clear();
     foreach (int questionnaireId in _createdQuestionnaires)
     {
         if (!FormRegistry.QuestionnaireDao.Delete(questionnaireId, TestUser))
         {
             failed = true;
         }
     }
     _createdQuestionnaires.Clear();
     foreach (string campaignCode in _createdCampaigns)
     {
         if (!FormRegistry.CampaignDao.Delete(campaignCode, _currentCampaign.CreatorEmailAddress))
         {
             failed = true;
         }
     }
     _createdCampaigns.Clear();
     
     
     _currentCampaign = null;
     _currentQuestionnaire = null;
     _currentPage = null;
     _currentPredefinedQuestion = null;
     _currentPredefinedChoices = null;
     _currentPagePredefinedQuestion = null;
     _currentPagePredefinedChoices = null;
     Assert.IsFalse(failed, "errors during deletion");
 }
Пример #10
0
 public static CampaignDto CreateNewCampaign(CampaignDto dto)
 {
     return FormRegistry.CampaignDao.Create(dto);
 }