本文整理汇总了C#中Update类的典型用法代码示例。如果您正苦于以下问题:C# Update类的具体用法?C# Update怎么用?C# Update使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Update类属于命名空间,在下文中一共展示了Update类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessUpdate
static async void ProcessUpdate(TelegramBotClient bot, Update update, User me)
{
// Read Configuration
var wundergroundKey = ConfigurationManager.AppSettings["WundergroundKey"];
var bingKey = ConfigurationManager.AppSettings["BingKey"];
var wolframAppId = ConfigurationManager.AppSettings["WolframAppID"];
// Process Request
try
{
var httpClient = new ProHttpClient();
var text = update.Message.Text;
var replyText = string.Empty;
var replyTextMarkdown = string.Empty;
var replyImage = string.Empty;
var replyImageCaption = string.Empty;
var replyDocument = string.Empty;
if (text != null && (text.StartsWith("/", StringComparison.Ordinal) || text.StartsWith("!", StringComparison.Ordinal)))
{
// Log to console
Console.WriteLine(update.Message.Chat.Id + " < " + update.Message.From.Username + " - " + text);
// Allow ! or /
if (text.StartsWith("!", StringComparison.Ordinal))
{
text = "/" + text.Substring(1);
}
// Strip @BotName
text = text.Replace("@" + me.Username, "");
// Parse
string command;
string body;
if (text.StartsWith("/s/", StringComparison.Ordinal))
{
command = "/s"; // special case for sed
body = text.Substring(2);
}
else
{
command = text.Split(' ')[0];
body = text.Replace(command, "").Trim();
}
var stringBuilder = new StringBuilder();
switch (command.ToLowerInvariant())
{
case "/beer":
if (body == string.Empty)
{
replyText = "Usage: /beer <Name of beer>";
break;
}
await bot.SendChatActionAsync(update.Message.Chat.Id, ChatAction.Typing);
var beerSearch = httpClient.DownloadString("http://www.beeradvocate.com/search/?q=" + HttpUtility.UrlEncode(body) + "&qt=beer").Result.Replace("\r", "").Replace("\n", "");
// Load First Result
var firstBeer = Regex.Match(beerSearch, @"<div id=""ba-content"">.*?<ul>.*?<li>.*?<a href=""(.*?)"">").Groups[1].Value.Trim();
if (firstBeer == string.Empty)
{
replyText = "The Great & Powerful Trixie was unable to find a beer name matching: " + body;
break;
}
var beer = httpClient.DownloadString("http://www.beeradvocate.com" + firstBeer).Result.Replace("\r", "").Replace("\n", "");
var beerName = Regex.Match(beer, @"<title>(.*?)</title>").Groups[1].Value.Replace(" | BeerAdvocate", string.Empty).Trim();
beer = Regex.Match(beer, @"<div id=""ba-content"">.*?<div>(.*?)<div style=""clear:both;"">").Groups[1].Value.Trim();
replyImage = Regex.Match(beer, @"img src=""(.*?)""").Groups[1].Value.Trim();
replyImageCaption = "http://www.beeradvocate.com" + firstBeer;
var beerScore = Regex.Match(beer, @"<span class=""BAscore_big ba-score"">(.*?)</span>").Groups[1].Value.Trim();
var beerScoreText = Regex.Match(beer, @"<span class=""ba-score_text"">(.*?)</span>").Groups[1].Value.Trim();
var beerbroScore = Regex.Match(beer, @"<span class=""BAscore_big ba-bro_score"">(.*?)</span>").Groups[1].Value.Trim();
var beerbroScoreText = Regex.Match(beer, @"<b class=""ba-bro_text"">(.*?)</b>").Groups[1].Value.Trim();
var beerHads = Regex.Match(beer, @"<span class=""ba-ratings"">(.*?)</span>").Groups[1].Value.Trim();
var beerAvg = Regex.Match(beer, @"<span class=""ba-ravg"">(.*?)</span>").Groups[1].Value.Trim();
var beerStyle = Regex.Match(beer, @"<b>Style:</b>.*?<b>(.*?)</b>").Groups[1].Value.Trim();
var beerAbv = beer.Substring(beer.IndexOf("(ABV):", StringComparison.Ordinal) + 10, 7).Trim();
var beerDescription = Regex.Match(beer, @"<b>Notes / Commercial Description:</b>(.*?)</div>").Groups[1].Value.Replace("|", "").Trim();
stringBuilder.Append(beerName.Replace("|", "- " + beerStyle + " by") + "\r\nScore: " + beerScore + " (" + beerScoreText + ") | Bros: " + beerbroScore + " (" + beerbroScoreText + ") | Avg: " + beerAvg + " (" + beerHads + " hads)\r\nABV: " + beerAbv + " | ");
stringBuilder.Append(HttpUtility.HtmlDecode(beerDescription).Replace("<br>"," ").Trim());
break;
case "/cat":
replyImage = "http://thecatapi.com/api/images/get?format=src&type=jpg,png";
break;
case "/doge":
replyImage = "http://dogr.io/wow/" + body.Replace(",", "/").Replace(" ", "") + ".png";
replyImageCaption = "wow";
break;
case "/echo":
replyText = body;
break;
case "/fat":
if (body == string.Empty)
{
//.........这里部分代码省略.........
示例2: ChangeFormulaYear
public string ChangeFormulaYear(string tableName,IList<FormulaYear> deleteItems, IList<FormulaYear> updateItems, IList<FormulaYear> insertItems)
{
try
{
foreach (var item in deleteItems)
{
Delete delete = new Delete(tableName);
delete.AddCriterions("KeyID","myKeyID", item.KeyID, CriteriaOperator.Equal);
delete.AddCriterions("ID","myID", item.ID, CriteriaOperator.Equal);
delete.AddSqlOperator(SqlOperator.AND);
dataFactory.Remove(delete);
}
foreach (var item in updateItems)
{
Update<FormulaYear> update = new Update<FormulaYear>(tableName, item);
update.AddCriterion("KeyID", "myKeyID",item.KeyID, CriteriaOperator.Equal);
update.AddCriterion("ID", "myID",item.ID, CriteriaOperator.Equal);
update.AddSqlOperator(SqlOperator.AND);
update.AddExcludeField("Id");
dataFactory.Save<FormulaYear>(update);
}
foreach (var item in insertItems)
{
Insert<FormulaYear> insert = new Insert<FormulaYear>(tableName, item);
insert.AddExcludeField("Id");
dataFactory.Save<FormulaYear>(insert);
}
}
catch
{
return "0";
}
return "1";
}
示例3: Equals
public bool Equals(Update update)
{
bool results = false;
if ((this.TopPatchId != null) && (update.TopPatchId != null))
{
if (this.TopPatchId.Equals(update.TopPatchId))
{
results = true;
}
}
else if ((this.VendorId != null) && (update.VendorId != null))
{
if ((this.VendorId.Equals(update.VendorId)) && (this.Name.Equals(update.Name)))
{
results = true;
}
}
else
{
if (this.Name.Equals(update.Name))
{
results = true;
}
}
return results;
}
示例4: SavePVFValues
public void SavePVFValues(IList<PVFItem> inserted, IList<PVFItem> updated, IList<PVFItem> deleted)
{
using (TransactionScope scope = new TransactionScope())
{
foreach (var item in inserted)
{
Insert<PVFItem> insert = new Insert<PVFItem>("PeakValleyFlat", item);
insert.AddExcludeField("ID");
dataFactory.Save<PVFItem>(insert);
}
foreach (var item1 in updated)
{
Update<PVFItem> update = new Update<PVFItem>("PeakValleyFlat", item1);
update.AddCriterion("ID", "ID", item1.ID, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal);
update.AddExcludeField("ID");
dataFactory.Save<PVFItem>(update);
}
foreach (var item2 in deleted)
{
Delete delete = new Delete("PeakValleyFlat");
delete.AddCriterions("ID", "ID",item2.ID, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal);
dataFactory.Remove(delete);
}
scope.Complete();
}
}
示例5: Download
public static string Download(Update update, Action<int> progressChanged)
{
var tmpFile = Path.GetTempFileName();
var waiter = new ManualResetEvent(false);
Exception ex = null;
var wc = new WebClient();
wc.DownloadProgressChanged += (sender, e) => progressChanged(e.ProgressPercentage);
wc.DownloadFileCompleted += (sender, e) =>
{
ex = e.Error;
waiter.Set();
};
wc.Headers.Add(HttpRequestHeader.UserAgent, "Azyotter.Updater v" + AssemblyUtil.GetInformationalVersion());
wc.DownloadFileAsync(update.Uri, tmpFile);
waiter.WaitOne();
if (ex != null)
{
File.Delete(tmpFile);
throw ex;
}
return tmpFile;
}
示例6: MobileGame
public MobileGame(AndroidContent.Context context, Setup setupDelegate, Update updateDelegate)
: base(context)
{
window = new Window(this);
this.setupDelegate = setupDelegate;
this.updateDelegate = updateDelegate;
}
示例7: UpdateWindow
public UpdateWindow(Update update)
{
InitializeComponent();
_update = update;
updateInfolbl.Text = update.Name;
TerminateYnoteProcess();
PopulateUpdateFiles();
}
示例8: Update_SimpleSqlCheck
public void Update_SimpleSqlCheck()
{
SubSonic.SqlQuery u = new Update(Product.Schema).Set("UnitPrice").EqualTo(100).Where("productid").IsEqualTo(1);
string sql = u.BuildSqlStatement();
//Assert.Fail("sql = " + sql);
//Assert.IsTrue(sql == "UPDATE [dbo].[Products] SET [UnitPrice][email protected]_UnitPrice\r\n WHERE [dbo].[Products].[ProductID] = @ProductID0\r\n");
Assert.IsTrue(sql == "UPDATE `main`.`Products` SET `UnitPrice`[email protected]_UnitPrice\r\n WHERE `main`.`Products`.`ProductID` = @ProductID0\r\n");
}
示例9: HandleNew
private void HandleNew(Update update)
{
Debug.Assert(update != null);
if (update.Message == null)
return;
Console.WriteLine($" >{update.Message?.From.FirstName ?? "<no fname>"}: {update.Message.Text}");
_pluginOne.Handle(new MessageContext { Update = update });
}
示例10: ReleasePlayerTest
public void ReleasePlayerTest(int playerID)
{
//Release Player to Free Agency
var repo = new Update();
repo.ReleasePlayer(playerID);
//Get Free Agency players and check for released player
var readRepo = new Read();
var players = readRepo.GetFreeAgents();
var player = players.FirstOrDefault(p => p.PlayerID == playerID);
Assert.AreEqual(player.PlayerID, playerID);
}
示例11: Update_Simple
public void Update_Simple()
{
int records = new Update(Product.Schema).Set("UnitPrice").EqualTo(100).Where("productid").IsEqualTo(1).Execute();
Assert.IsTrue(records == 1);
//pull it back out
Product p = new Product(1);
Assert.IsTrue(p.UnitPrice == 100);
//reset it to 50
p.UnitPrice = 50;
p.Save("unit test");
}
示例12: FrmGlobalStatus
/// <summary>
/// Generate the form, load configs, show initial settings if needed.
/// </summary>
/// <param name="configs">Strings passed on the commandline</param>
public FrmGlobalStatus(string[] commands)
{
InitializeComponent();
helper.UpdateSettings();
// if this is the first start: show settings
if (Properties.Settings.Default.firstStart)
{
Properties.Settings.Default.firstStart = false;
Properties.Settings.Default.Save();
ShowSettings(true);
}
ReadConfigs();
niIcon.Icon = Properties.Resources.TRAY_Disconnected;
bool checkupdate = false;
TimeSpan ts = Properties.Settings.Default.lastUpdateCheck
- DateTime.Now;
if (Properties.Settings.Default.searchUpdate == 0 ||
(ts.Days > 7 && Properties.Settings.Default.searchUpdate == 1) ||
(ts.Days > 30 && Properties.Settings.Default.searchUpdate == 2))
{
checkupdate = true;
Properties.Settings.Default.lastUpdateCheck = DateTime.Now;
Properties.Settings.Default.Save();
}
if (checkupdate)
{
Update u = new Update(true, this);
if (u.checkUpdate())
{
niIcon.ShowBalloonTip(5000,
Program.res.GetString("QUICKINFO_Update"),
Program.res.GetString("QUICKINFO_Update_More"),
ToolTipIcon.Info);
}
}
m_simpleComm.ReceivedLines += new
EventHandler<SimpleComm.ReceivedLinesEventArgs>(
m_simpleComm_ReceivedLines);
parseCommandLine(commands);
if(Properties.Settings.Default.allowRemoteControl)
m_simpleComm.startServer();
}
示例13: OnLoad
internal void OnLoad(EventArgs args)
{
this._menu= new Menu();
this.spells=new Spells();
this._update=new Update();
this._draw=new Drawings();
this.DmgIndicator=new DamageIndicator();
DmgIndicator.Initialize(this);
this.misc=new Misc();
this.targetSelected = new MyTs();
Gapcloser.OnGapcloser += this.OnGapCloser;
EloBuddy.Game.OnUpdate += this.Onupdate;
EloBuddy.Drawing.OnDraw += this.Ondraw;
}
示例14: UpdateProjectsInDB
public static void UpdateProjectsInDB(List<ChildProject> cProjects)
{
var userConnection = TerrasoftApi.GetuserConnection();
foreach (var item in cProjects)
{
Update update = new Update(userConnection, "Project")
.Set("StartDate", Column.Const(item.StartDate))
.Set("EndDate", Column.Const(item.EndDate))
.Where("Id").IsEqual(Column.Const(item.ChildId)) as Update;
update.BuildParametersAsValue = true;
using (var dbExecutor = userConnection.EnsureDBConnection())
{
try
{
dbExecutor.StartTransaction();
var affectedRowsCount = update.Execute(dbExecutor);
dbExecutor.CommitTransaction();
}
catch (Exception ex)
{
dbExecutor.RollbackTransaction();
}
}
}
var rootProjectId = cProjects[0].GetRootId();
var endDate = cProjects.Last().EndDate;
Update updateRoot = new Update(userConnection, "Project")
.Set("EndDate", Column.Const(endDate))
.Where("Id").IsEqual(Column.Const(rootProjectId)) as Update;
updateRoot.BuildParametersAsValue = true;
using (var dbExecutor = userConnection.EnsureDBConnection())
{
try
{
dbExecutor.StartTransaction();
var affectedRowsCount = updateRoot.Execute(dbExecutor);
dbExecutor.CommitTransaction();
}
catch (Exception ex)
{
dbExecutor.RollbackTransaction();
}
}
}
示例15: Main
static void Main()
{
System.Diagnostics.Process.Start("D:\\Solicitação de Prontuarios\\Sistema de Solicitação de Prontuários\\pastaDTI.bat");
Update updatando = new Update();
updatando.up();
if (updatando.Yn == true)
{
Environment.Exit(1);
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MenuUpa());
}