Esempio n. 1
0
        public static void ProcessUser(Config.Config config, uint userId, ProtocolType ftpFileType)
        {
            var userRoot  = Path.Combine(config.RootDir, userId.ToString());
            var pricesDir = Directory.CreateDirectory(Path.Combine(userRoot, "prices"));
            var marker    = pricesDir.EnumerateFiles("request.txt").FirstOrDefault();

            if (marker != null)
            {
                using (var session = Factory.OpenSession())
                    using (var trx = session.BeginTransaction()) {
                        PriceHelper.ExportPrices(session, userId, pricesDir, ftpFileType);
                        trx.Commit();
                    }
                marker.Delete();
            }

            var ordersDir = Directory.CreateDirectory(Path.Combine(userRoot, "orders"));

            OrderHelper.ImportOrders(ordersDir, userId, ftpFileType);

            var waybillsDir = Directory.CreateDirectory(Path.Combine(userRoot, "waybills"));

            using (var session = Factory.OpenSession())
                using (var trx = session.BeginTransaction()) {
                    WaybillsHelper.ExportWaybills(waybillsDir, session, userId, ftpFileType);
                    trx.Commit();
                }
        }