/// <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(); }
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; }
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; } } }