示例#1
0
    private void CollectFields(DatabaseStub stub, NameValueCollection input)
    {
        foreach (string key in input)
        {
            DatabaseStubElement element = new DatabaseStubElement()
            {
                Key   = HttpUtility.HtmlDecode(key),
                Value = HttpUtility.HtmlDecode(input[key]),
            };

            stub.Contents.Add(element);
        }
    }
示例#2
0
    private static DatabaseStub CreateStub(DatabaseWebCampaign webCampaign)
    {
        DatabaseStub stub = new DatabaseStub()
        {
            PostTime = DateTime.Now,
        };

        if (webCampaign != null)
        {
            stub.WebCampaignId = webCampaign._id;
        }

        return(stub);
    }
示例#3
0
    private void AddOprindelse(DatabaseStub stub)
    {
        if (Request.UrlReferrer == null || stub.Contents.Any(lElement => lElement.Key == "new_oprindelse"))
        {
            return;
        }

        DatabaseStubElement element = new DatabaseStubElement()
        {
            Key   = "new_oprindelse",
            Value = Request.UrlReferrer.AbsoluteUri,
        };

        stub.Contents.Add(element);
    }
示例#4
0
    private void AddOprindelseIp(DatabaseStub stub)
    {
        if (stub.Contents.Any(lElement => lElement.Key == "new_oprindelseip"))
        {
            return;
        }

        DatabaseStubElement element = new DatabaseStubElement()
        {
            Key   = "new_oprindelseip",
            Value = Request.UserHostAddress,
        };

        stub.Contents.Add(element);
    }
示例#5
0
    //private string _defaultRedirect = "http://kirkenskorshaer.dk";

    protected void Page_Load(object sender, EventArgs e)
    {
        //string errorRedirect = "http://kirkenskorshaer.dk";

        NameValueCollection input = Request.Form;

        if (Request.HttpMethod == "POST")
        {
            input = Request.Form;
            //Response.Redirect(errorRedirect);
        }
        else
        {
            input = Request.QueryString;
        }

        string          databaseName    = ConfigurationManager.AppSettings["mongoDatabaseName"];
        MongoConnection mongoConnection = MongoConnection.GetConnection(databaseName);

        Guid formId = Guid.Empty;

        Guid.TryParse(input["formId"], out formId);

        DatabaseWebCampaign webCampaign = DatabaseWebCampaign.ReadSingleOrDefault(mongoConnection, formId);

        DatabaseStub stub = CreateStub(webCampaign);

        CollectFields(stub, input);

        AddOprindelseIp(stub);

        AddOprindelse(stub);

        DatabaseStubPusher.GetInstance(mongoConnection).Push(stub);

        Redirect(webCampaign);
    }