public static void SendOrders(int[] orderIds, out string errorMessage) { IDalSession session = NHSessionFactory.CreateSession(); errorMessage = ""; try { FSExportFile exportfile = new FSExportFile(); exportfile.FilePath = (string)(System.Configuration.ConfigurationManager.AppSettings.Get("FSExportFilePath")); //exportfile.FilePath = (string)(System.Configuration.ConfigurationSettings.AppSettings.Get("FSExportFilePath")); IList<IOrder> orders = OrderMapper.GetOrders(session, orderIds); foreach (Order order in orders) { exportfile.ExportedOrders.Add(order); ((IStgOrder)order).Send(); order.ExportFile = (IFSExportFile)exportfile; } session.BeginTransaction(); FSExportFileMapper.Update(session, exportfile); if (exportfile.CreateExportFile()) session.CommitTransaction(); } catch (Exception ex) { errorMessage = ex.Message; } finally { session.Close(); } }
/// <summary> /// Saves the data of an existing FSExportFile. /// </summary> /// <param name="DataSession">data session object</param> /// <param name="obj">existing object</param> public static bool Update(IDalSession DataSession, FSExportFile obj) { NHibernate.ISession session = ((NHSession)DataSession).Session; bool transCommitt = true; NHibernate.ITransaction nTrans = null; try { //Get a transaction if (session.Transaction == null) { nTrans = session.BeginTransaction(); } else { nTrans = session.Transaction; transCommitt = false; } session.Save(obj); if (transCommitt) nTrans.Commit(); return true; } catch (Exception ex) { nTrans.Rollback(); throw new ApplicationException(ex.InnerException.ToString()); } }
/// <summary> /// Deletes an existing FSExportFile. /// </summary> /// <param name="DataSession">data session object</param> /// <param name="obj">existing object</param> public static void Delete(IDalSession DataSession, FSExportFile obj) { DataSession.Delete(obj); }
/// <summary> /// Makes newly created FSExportFile persistent. /// </summary> /// <param name="DataSession">data session object</param> /// <param name="obj">newly created object</param> public static void Insert(IDalSession DataSession, FSExportFile obj) { DataSession.Insert(obj); }