示例#1
0
        //This parses out the keywords and replaces them with the dynamic data
        private string ParseFeed(string content)
        {
            ReplacerController controller = new ReplacerController();

            List <ReplacerModel> replacerModels = controller.LoadReplacers();

            StringBuilder builder = new StringBuilder(content);

            State state = new State();

            foreach (ReplacerModel replacerModel in replacerModels)
            {
                try
                {
                    PropertyInfo property = typeof(CustomerModel).GetProperty(replacerModel.DataField);

                    builder.Replace(replacerModel.Keyword, System.Convert.ToString(property.GetValue(customer, null)));
                }
                catch (Exception ex)
                {
                    Logger.CreateLog(CustomerId, Referrer, "Parsing of content failed. " + ex.InnerException, 1);
                    state.Cache().SetError(ex);
                    Response.Redirect("Error.aspx");
                }
            }

            return(builder.ToString());
        }
示例#2
0
        private void ReplacerItemDelete(RepeaterCommandEventArgs e)
        {
            ReplacerController controller = new ReplacerController();

            Label id = (Label)e.Item.FindControl("IdLabel");

            ReplacerModel replacer = new ReplacerModel();

            replacer.Id = System.Convert.ToInt32(id.Text);

            controller.DeleteReplacer(replacer);
        }
示例#3
0
        private void ReplacerItemAdd(Repeater source, RepeaterCommandEventArgs e)
        {
            ReplacerController controller = new ReplacerController();

            TextBox addKeywordTextbox   = (TextBox)e.Item.FindControl("AddKeywordTextbox");
            TextBox addDataFieldTextBox = (TextBox)e.Item.FindControl("AddDataFieldTextBox");

            ReplacerModel replacer = new ReplacerModel();

            replacer.Keyword   = addKeywordTextbox.Text;
            replacer.DataField = addDataFieldTextBox.Text;

            controller.SaveReplacer(replacer);
        }
示例#4
0
        private void ReplacerItemSave(RepeaterCommandEventArgs e)
        {
            ReplacerController controller = new ReplacerController();

            Label   id        = (Label)e.Item.FindControl("IdLabel");
            TextBox keyword   = (TextBox)e.Item.FindControl("KeywordTextBox");
            TextBox dataField = (TextBox)e.Item.FindControl("DataFieldTextBox");

            ReplacerModel replacer = new ReplacerModel();

            if (id.Text != "")
            {
                replacer.Id = System.Convert.ToInt32(id.Text);
            }

            replacer.Keyword   = keyword.Text;
            replacer.DataField = dataField.Text;

            controller.SaveReplacer(replacer);
        }
示例#5
0
        private void LoadReplacers()
        {
            ReplacerController replacerController = new ReplacerController();

            List <ReplacerModel> replaceModels = replacerController.LoadReplacers();

            ReplacerList.DataSource = replaceModels;
            ReplacerList.DataBind();

            List <string> possibleFields = new List <string>();

            //loading customer object to iterate through properties and display them
            CustomerModel model = new CustomerModel();

            PropertyInfo[] properties = model.GetType().GetProperties();

            foreach (PropertyInfo prop in properties)
            {
                possibleFields.Add(prop.Name);
            }

            PossibleFields.Text = string.Join(", ", possibleFields.ToArray());
        }