private void btnCreate_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtAuthors.Text)) { return; } var authors = txtAuthors.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); using (var dal = new Dal(MySqlConnectionString)) { var userDal = new UserDal(dal); foreach (var author in authors) { if (string.IsNullOrEmpty(author.Trim())) { continue; } userDal.InsertUser(author.Trim(),_options.BlogHost); } } MessageBox.Show("Done"); }
public OptionsDal(Dal dal) { _dal = dal; }
public CategoryDal(Dal dal) { _dal = dal; }
public BlogCache(Dal dal) { _dal = dal; }
private void fixFeatureImageErrorToolStripMenuItem_Click(object sender, EventArgs e) { if (!_blogSelected) { MessageBox.Show("First connect to blog from File>Connect!"); return; } var thumbnailMetaData = new Dictionary<int, string>(); var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); using (var dal = new Dal(MySqlConnectionString)) { var postDal = new PostDal(dal); var allYoastMeta = postDal.GetAllPostMeta("_yoast_wpseo_focuskw_text_input"); if (allYoastMeta.Tables.Count == 0) return; if (allYoastMeta.Tables[0].Rows.Count == 0) return; var thumbnailMeta = postDal.GetAllPostMeta("_thumbnail_id"); if (thumbnailMeta.Tables.Count > 0) { if (thumbnailMeta.Tables[0].Rows.Count > 0) { foreach (DataRow row in thumbnailMeta.Tables[0].Rows) { var postId = Int32.Parse(row["post_id"].ToString()); var meta_value = row["meta_value"].ToString(); if (!thumbnailMetaData.ContainsKey(postId)) { thumbnailMetaData.Add(postId, meta_value); } } } } barStatus.Maximum = allYoastMeta.Tables[0].Rows.Count; barStatus.Visible = true; foreach (DataRow row in allYoastMeta.Tables[0].Rows) { barStatus.PerformStep(); var postId = Int32.Parse(row["post_id"].ToString()); var meta_value = row["meta_value"].ToString(); if (thumbnailMetaData.ContainsKey(postId) && !string.IsNullOrEmpty(thumbnailMetaData[postId])) { continue; } Application.DoEvents(); SetStatus(string.Format("Fixing {0} ", postId)); postDal.SetPostMetaData(postId, "_thumbnail_id", meta_value); } barStatus.Visible = false; } MessageBox.Show("Finished"); }
private void btnGo_Click(object sender, EventArgs e) { if (!_blogSelected) { MessageBox.Show("First connect to blog from File>Connect!"); return; } if (lvItems.SelectedItems.Count == 0) { MessageBox.Show("Select items to transfer!"); return; } var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); _stopWatch = new Stopwatch(); _stopWatch.Start(); EnDisItems(false); lblDateTime.Text = "Started at " + DateTime.Now.ToLongTimeString(); using (var dal = new Dal(MySqlConnectionString)) { _blogCache = new BlogCache(dal); if (_options.UseCache) { SetStatus("Loading present posts and tags in the blog(this may take some time)..."); Application.DoEvents(); _blogCache.Start(_options.BlogUrl); Application.DoEvents(); } SetStatus("Ready"); ResetBarStatus(true); barStatus.Maximum = lvItems.SelectedItems.Count; _postFactory = new PostFactory( SiteConfig, new Ftp(FtpConfiguration), _blogCache, dal, _options); var items = ItemsFromListView(lvItems.SelectedItems); _postFactory.PostCreated += PostCreated; _postFactory.PostBeingCreated += PostBeingCreated; _postFactory.PostsCreated += PostsCreated; _postFactory.PostCreationStopped += PostCreationStopped; _postFactory.Create(items); } }
private void btnStart_Click(object sender, EventArgs e) { if (txtUrl.Text == "") { MessageBox.Show("Enter Keyword!"); return; } var sitesCount = chkSites.CheckedItems.Count; if (sitesCount == 0) { MessageBox.Show("Select sites!"); return; } EnDis(false); numPage_ValueChanged(null, null); Cursor.Current = Cursors.WaitCursor; ResetBarStatus(true); btnGo.Enabled = false; lblTotalResults.Text = ""; var pageStart = (int)numPage.Value; var pageEnd = chkAllPages.Checked ? (int)numPageTo.Maximum : (int)numPageTo.Value; ///barStatus.Maximum = pageEnd - pageStart; barStatus.Maximum = 0; lblDateTime.Text = ""; _stopWatch = new Stopwatch(); _stopWatch.Start(); var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); HashSet<string> existingIds = null; if (_options.SkipSearchingPosted) { using (var dal = new Dal(MySqlConnectionString)) { _blogCache = new BlogCache(dal); if (_options.UseCache) { SetStatus("Loading present posts and tags in the blog(this may take some time)..."); Application.DoEvents(); existingIds = _blogCache.IdsPresent(_options.BlogUrl); Application.DoEvents(); } } } _sourceItemFactory = new SourceItemFactory(); _sourceItemFactory.NoSourceFound += NoSourceFound; _sourceItemFactory.GettingSourceItemsStopped += GettingSourceItemsStopped; _sourceItemFactory.ProcessFinished += GettingSourceItemsFinished; _sourceItemFactory.SourceItemGot += SourceItemGot; _sourceItemFactory.TotalResultsFound += TotalResultsFound; _sourceItemFactory.SourceItemsGot += SourceItemsGot; _sourceItemFactory.ExceptionOccured += ExceptionOccuredWhileGettingItems; var checkedSites = (from object checkedItem in chkSites.CheckedItems select checkedItem.ToString()).ToList(); _sourceItemFactory.GetSourceItems(checkedSites, txtUrl.Text, pageStart, pageEnd, lvItems.Items.Count + 1, existingIds); }
private void SetPluginData() { var checkedSites = (from object checkedItem in lstPlugins.CheckedItems select checkedItem.ToString()).ToList(); var programOptionsFactory = new ProgramOptionsFactory(); _options = programOptionsFactory.Get(); using (var dal = new Dal(MySqlConnectionString)) { var optionsDal = new OptionsDal(dal); var currentActivePluginsValue = optionsDal.GetValue("active_plugins"); var currentActivePlugins = new HashSet<string>(PhpSerializer.Deserialize(currentActivePluginsValue)); var pluginsToPut = new HashSet<string>(); var pluginPaths = GetPluginFiles(); var pluginNames = GetPluginNames(); for (int i = 0; i < pluginNames.Count; i++) { if (checkedSites.Contains(pluginNames[i])) { pluginsToPut.Add(pluginPaths[i]); } } currentActivePlugins.UnionWith(pluginsToPut); var newActivePluginData = PhpSerializer.Serialize(currentActivePlugins.ToList()); optionsDal.SetValue("active_plugins", newActivePluginData); var optionFiles = Directory.EnumerateFiles("blog", "*.bosf", SearchOption.AllDirectories); foreach (var optionFile in optionFiles) { var optionFileInfo = new FileInfo(optionFile); if (optionFileInfo.Directory.Name == "plugins") { var fileName = Path.GetFileNameWithoutExtension(optionFile); if (!checkedSites.Contains(fileName)) { continue; } } var contentLines = File.ReadAllLines(optionFileInfo.FullName); foreach (var content in contentLines) { var splitted = content.Split('\t'); if (splitted.Length > 0) { optionsDal.SetValue(splitted[0], splitted[1]); } else { optionsDal.SetValue(content, ""); } } } } }
private void btnTestMySqlConnection_Click(object sender, EventArgs e) { using (var dal = new Dal(MySqlConnectionString)) { var testConnection = dal.TestConnection(); if (testConnection != null) { foreach (var result in testConnection) { MessageBox.Show(result); } } } }
public TagDal(Dal dal) { _dal = dal; }
private void FtpDirectoryDeletionFinished(object sender, EventArgs e) { if(btnCleanup.Enabled)//file deletion canceled, don't continue to mysql part before cleaning up files { return; } try { EnDis(false); using (var dal = new Dal(MySqlConnectionString)) { var postDal = new PostDal(dal); postDal.DeleteAll(); } } catch (Exception exception) { EnDis(true); MessageBox.Show(exception.ToString()); Logger.LogExceptions(exception); return; } EnDis(true); MessageBox.Show("Finished!"); }
public PostDal(Dal dal) { _dal = dal; }