本文整理汇总了C#中IRepository.BeginTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.BeginTransaction方法的具体用法?C# IRepository.BeginTransaction怎么用?C# IRepository.BeginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.BeginTransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FacebookStreamReader
/// <summary>
/// default constructor of the object
/// </summary>
public FacebookStreamReader(
Action<long, StreamUpdateStatus> statusNotificationHandler,
Action<long, int, int> likesRetrivalNotificationHandler,
long uniqueStatusIndentifier,
string fbFilePath,
ILogger logger,
FacebookClient fbApp,
IRepository repository)
{
Logger = logger;
Logger.Info("Started");
UniqueStatusIndentifier = uniqueStatusIndentifier;
StatusNotificationHandler = statusNotificationHandler;
LikesRetrivalNotificationHandler =
likesRetrivalNotificationHandler;
Status = new List<StreamUpdateStatus>();
FbStreamUpdated += FacebookStreamReaderFbStreamUpdated;
/* settings of the application */
SavedFbInfoPath = fbFilePath;
/* facebook application interface */
FbApp = fbApp;
Repository = repository;
Repository.BeginTransaction();
}
示例2: catch
public static int 批量生成费用(IRepository rep, 车辆产值 票, IEnumerable 箱, string 费用项编号, 收付标志? 收付标志)
{
int cnt = 0;
// 需按照委托人合同和付款合同生成相应费用和费用理论值
// 如果总体来生成,则按照:
// 如果费用已经打了完全标志,则不生成。如果相应理论值已经生成过,也不生成。
// 如果单个费用项来生成,则不管理论值是否已经生成过
// Todo: 理论值可能显示生成票的,后来信息完全了再生成箱的,此时要删除票的
//using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository(票.GetType()))
{
try
{
rep.BeginTransaction();
IList<业务费用理论值> llzs = (rep as Feng.NH.INHibernateRepository).List<业务费用理论值>(NHibernate.Criterion.DetachedCriteria.For<业务费用理论值>()
.Add(NHibernate.Criterion.Expression.Eq("费用实体.ID", 票.ID)));
rep.Initialize(票.费用, 票);
process_fy_generate.批量生成费用(rep, 票, 箱, 费用项编号, 收付标志, llzs);
//// 有几项(发票税,贴息费)要看收款费用
// 不行,会多生成
//批量生成费用付款(rep, 费用实体类型, 票, 箱, 费用项编号, 收付标志, llzs);
rep.CommitTransaction();
}
catch (Exception ex)
{
rep.RollbackTransaction();
ServiceProvider.GetService<IExceptionProcess>().ProcessWithNotify(ex);
}
}
return cnt;
}
示例3: SaveFiles
private void SaveFiles(IRepository rep, KeyValuePair<string, IList<string>> fileList)
{
foreach (string file in fileList.Value)
{
try
{
rep.BeginTransaction();
if (File.Exists(file))
{
byte[] bytes = ReadFile(file);
if (bytes == null || bytes.Length == 0)
{
Console.WriteLine("ForWatcher Error:<" + fileList.Key + ">" + Environment.NewLine
+ "Nor found the file or fileStream length is 0 \"" + file + "\"");
continue;
}
FileInfo fileInfo = new FileInfo(file);
AttachmentInfo newAtt = new AttachmentInfo();
newAtt.EntityName = m_EntityName;
newAtt.EntityId = fileList.Key;
newAtt.FileName = fileInfo.Name;
newAtt.Data = bytes;
newAtt.Description = "附件";
newAtt.Created = fileInfo.CreationTime;
newAtt.CreatedBy = "服务";
newAtt.Updated = fileInfo.LastWriteTime;
rep.Save(newAtt);
}
rep.CommitTransaction();
}
catch (Exception ex)
{
rep.RollbackTransaction();
Console.WriteLine("ForWatcher Error:<" + fileList.Key + ">" + Environment.NewLine + ex.Message);
System.Windows.Forms.MessageBox.Show("<" + fileList.Key + ">" + Environment.NewLine + ex.Message, "ForWatcher Error");
continue;
}
}
}