Пример #1
0
 private void CreateTemplate(object sender, ExecutedRoutedEventArgs e)
 {
     var tmp = new GrabTemplate()
                   {
                       Name = "Untitled",
                       TemplateID = string.Empty
                   };
     Templates.Add(tmp);
     lstTemplates.SelectedItem = tmp;
 }
Пример #2
0
 public void EditGrabTemplate(GrabTemplate template)
 {
     Execute(conn =>
     {
         using (SQLiteCommand cmd = conn.CreateCommand()) {
             cmd.CommandText = "UPDATE GrabTemplates SET Name = @Name, Description = @Description, UrlFormatString = @UrlFormatString, GrabParameters = @GrabParameters, GrabMode = @GrabMode WHERE TemplateID = @TemplateID";
             cmd.Parameters.AddWithValue("@TemplateID", template.TemplateID);
             cmd.Parameters.AddWithValue("@Description", template.Description);
             cmd.Parameters.AddWithValue("@Name", template.Name);
             cmd.Parameters.AddWithValue("@UrlFormatString", template.UrlFormatString);
             cmd.Parameters.AddWithValue("@GrabParameters", template.GrabParameters.Serialize());
             cmd.Parameters.AddWithValue("@GrabMode", (int)template.GrabMode);
             cmd.ExecuteNonQuery();
         }
     });
 }
Пример #3
0
        public void DeleteGrabTemplate(GrabTemplate template)
        {
            Execute(conn =>
            {
                using (SQLiteCommand cmd = conn.CreateCommand()) {
                    cmd.Parameters.AddWithValue("@TemplateID", template.TemplateID);

                    cmd.CommandText = "DELETE FROM GrabTemplates WHERE TemplateID = @TemplateID";
                    cmd.ExecuteNonQuery();
                }
            });
        }
Пример #4
0
 public static GrabTemplate FromXElement(XElement element)
 {
     try {
         GrabTemplate template = new GrabTemplate()
         {
             TemplateID = HtmlUtils.HtmlDecode(element.Element("id").Value),
             Name = HtmlUtils.HtmlDecode(element.Element("name").Value),
             Description = HtmlUtils.HtmlDecode(element.Element("description").Value).Trim(),
             GrabMode = (Constants.GrabModes)Enum.Parse(typeof(Constants.GrabModes),element.Element("grabmode").Value,true),
             UrlFormatString = HtmlUtils.HtmlDecode(element.Element("urlformatstring").Value),
               GrabParameters= GrabEventArgs.Deserialize(element.Element("params").Value),
             GrabSchedule = (Constants.GrabSchedules)Enum.Parse(typeof(Constants.GrabSchedules), element.Element("grabschedule").Value, true),
         };
         return template;
     } catch { // usually NullReferenceException, but if something's invalid the recipe will be invalid
         throw new Exception("Invalid template");
     }
 }
Пример #5
0
 public WinManageTemplates(GrabTemplate template)
     : this()
 {
     this.CurrentTemplate = template;
     this.Title = "Edit Template";
 }
Пример #6
0
 public WinManageTemplates()
 {
     InitializeComponent();
     CurrentTemplate = new GrabTemplate();
 }