本文整理汇总了C#中Config.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Config.SubmitChanges方法的具体用法?C# Config.SubmitChanges怎么用?C# Config.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config.SubmitChanges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test
public void Test(object sender, System.Timers.ElapsedEventArgs e)
{
bool result = false;
DataClassesDataContext context = null;
try
{
Url url = GetUrlFromDatabase(out context);
if (url != null)
{
lock (webrequestlock)
{
result = TestUrl(url, RequestTimeout);
if (result)
OnSucces(url, context);
else
OnFailure(url, context, sender);
using (DataClassesDataContext context2 = new Config().GetNewContext())
{
int aantal = context.ServiceStatus.Count();
if (aantal != 0)
{
context2.ServiceStatus.First().VolgendePulse = DateTime.Now.AddMilliseconds(((Timer)sender).Interval);
context2.SubmitChanges();
}
}
url.LaatstePulse = DateTime.Now;
context.SubmitChanges();
}
}
}
catch (Exception exc)
{
Dictionary<string, object> props = new Dictionary<string, object>();
props.Add("exception", exc);
props.Add("url", this);
props.Add("result", result);
Service1.LogCriticalError("Fout tijdens verwerken van het test resulaat"
, "Verwerken testresultaat ging fout"
, props);
}
finally
{
if (context != null)
context.Dispose();
}
}
示例2: TestUrl
private bool TestUrl(Url url, int milliseconds)
{
try
{
using (DataClassesDataContext context = new Config().GetNewContext())
{
int aantal = context.ServiceStatus.Count();
if (aantal == 0)
{
context.ServiceStatus.InsertOnSubmit(new ServiceStatus() { LaatstePulse = DateTime.Now });
context.SubmitChanges();
}
else
{
context.ServiceStatus.First().LaatstePulse = DateTime.Now;
context.SubmitChanges();
}
}
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url.UrlAsUri);
request.Timeout = milliseconds;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if (response == null || response.StatusCode != HttpStatusCode.OK)
return false;
else
return true;
}
}
catch
{
return false;
}
}