csharp 对我们来说更新

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 对我们来说更新相关的知识,希望对你有一定的参考价值。

string strTweetText = String.Format("Всем большой-большой привет из {0} :)))))", project.Variables["str_privet_from"].Value);
string strJobAttachments = project.Directory + @"\images\image1.jpg;" + 
    project.Directory + @"\images\image2.jpg";

SibboraHelper.FarmHelper fHelper = new SibboraHelper.FarmHelper();
SibboraHelper.WebHelper wHelper = new SibboraHelper.WebHelper();
fHelper.FarmDBConnstring = project.Variables["str_db_connstring"].Value;

Tab Tab1 = instance.ActiveTab;

HtmlElement elLeftSidebar = Tab1.FindElementByXPath("//div[@class='dashboard dashboard-left']",0);		
wHelper.ClickElementXPath(Tab1, false, elLeftSidebar, "//a", 0, false, new int[3] {1500, 1500, 25000});		
wHelper.WaitElementPresenceXPath(Tab1, true, null, "//button[@class='UserActions-editButton edit-button btn']", 0, "present", new int[3] {0, 1500, 25000});
wHelper.ClickElementXPath(Tab1, true, null, "//button[@id='global-new-tweet-button']", 0, false, new int[3] {2000, 1500, 15000});		

try{
	//Иногда кнопка "твитнуть" почему-то ндоступна
	wHelper.WaitElementStyleXPath(Tab1, true, null, "//div[@id='global-tweet-dialog']", 0, "display:block", false, new int[3] {0, 1500, 25000});
}catch{
	Tab1.Navigate(Tab1.URL);
	wHelper.ClickElementXPath(Tab1, true, null, "//button[@id='global-new-tweet-button']", 0, false, new int[3] {2000, 1500, 15000});
	wHelper.WaitElementStyleXPath(Tab1, true, null, "//div[@id='global-tweet-dialog']", 0, "display:block", false, new int[3] {0, 1500, 25000});
}

HtmlElement elGlobalTweetDialog = Tab1.FindElementByXPath("//div[@id='global-tweet-dialog']",0);		
wHelper.SetElementValueXPath(Tab1, true, elGlobalTweetDialog, "//div[@id='tweet-box-global']", 0, strTweetText, "Middle", false, false, new int[3] {1000, 1500, 15000});

//Грузим картинки
if (strJobAttachments!=String.Empty) {
	instance.SetFileUploadPolicy("ok", "");
	string[] arrFilesPathes = strJobAttachments.Split(new Char [] {';'});
	int intImagesUploaded=0;
	foreach (string strFilePath in arrFilesPathes) {
		instance.SetFilesForUpload(strFilePath);
		HtmlElement elTweetModal = Tab1.FindElementByXPath("//div[@id='global-tweet-dialog']",0);
		HtmlElement elImageUpload = elTweetModal.FindChildByAttribute("input:file", "fulltag", "input:file", "text", 0);
		elImageUpload.RiseEvent("click", instance.EmulationLevel);
		intImagesUploaded++;
		
		wHelper.WaitElementCountXPath(Tab1, true, elTweetModal, "//div[@class='thumbnail-container' or @class='previews']/descendant::*[contains(@class, 'close') or contains(@class, 'dismiss')]", intImagesUploaded, "equal",  new int[3] {0, 1500, 25000});
	}
}
//Кликаем на "опубликовать", проверяем
wHelper.AddInfoToLog("Кликаем на -Опубликовать, проверяем что твит опубликовался");
//wHelper.ClickElementXPath(Tab1, true, elGlobalTweetDialog, "//div[@class='tweet-button']/button", 0, false, new int[3] {0, 1500, 5000});
wHelper.ClickElementXPath(Tab1, true, elGlobalTweetDialog, "//span[@class='Icon Icon--tweet']/ancestor::button[1]", 0, false, new int[3] {0, 1500, 15000});
wHelper.WaitElementStyleXPath(Tab1, true, null, "//div[@id='global-tweet-dialog']", 0, "display:none", true, new int[3] {0, 1500, 35000});
wHelper.WaitElementAttributeAttr(Tab1, true, null, "p", "class", "TweetTextSize", "regexp", 0, "InnerHtml", 
 strTweetText, "contains", new int[3] {0, 1500, 25000});

//Сохраняем скриншот опубликованного твита
System.Threading.Thread.Sleep(4500); //Ждём скрытия оповещения "ваш твит опубликован"
string strScreenFileName = project.Directory+"\\screenshots\\job_" + DateTime.Now.ToString("HHmmss") + ".png";
if (File.Exists(strScreenFileName))
	File.Delete(strScreenFileName);
HtmlElement elLastTweet =  Tab1.FindElementByAttribute("li", "id", "stream-item-tweet", "regexp", 0).FindChildByXPath(".//div[@class='content']",0);
System.IO.File.WriteAllBytes(strScreenFileName, Convert.FromBase64String(elLastTweet.DrawToBitmap(false)));

以上是关于csharp 对我们来说更新的主要内容,如果未能解决你的问题,请参考以下文章

EC2的维护更新

对DataTable(或者DataSet)修改后,提交修改到数据库

csharp 更新相关子实体

csharp C# - 更新UI控件线程安全

csharp 更新数据库

csharp 更新