コード例 #1
0
ファイル: Designer.cs プロジェクト: jkwchunjae/ProjectSIA
 public static void Caching(ProjectSIAEntities db)
 {
     using (var wl = new WriteLock())
     {
         _designerList = db.Designer.ToList().Select(x => new Designer(x)).ToList();
     }
 }
コード例 #2
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static List<ProductInfo> GetByType1(ProjectSIAEntities db, string type1)
		{
			using (var rl = new ReadLock())
			{
				return GetAllProductInfoList(db).Where(x => x.Type1 == type1).ToList();
			}
		}
コード例 #3
0
ファイル: Order.cs プロジェクト: jkwchunjae/ProjectSIA
        public static Order AddNewOrder(ProjectSIAEntities db, int memberId, DateTime orderDate, string orgName, string phone, string address, IEnumerable<ProductCount> receipts, int storeId)
        {
            using (var wl = new WriteLock())
            {
                if (receipts == null || receipts.Count() == 0) throw new AutistarException("주문물품이 없습니다.");
                if (receipts.Where(x => x.Count <= 0).Any()) throw new AutistarException("주문내역에 0 이하의 수량이 있습니다.");

                var newOrder = db.OrderInfo.Add(new OrderInfo
                {
                    memberId = memberId,
                    status = OrderStatus.Prepare.ToString(),
                    orderDate = orderDate,
                    isPay = false,
                    isOrg = !string.IsNullOrEmpty(orgName),
                    orgName = orgName,
                    phone = phone,
                    address = address,
                    storeId = storeId,
                });
                var rows = db.SaveChanges();

                if (rows != 1)
                    throw new AutistarException("주문 추가 DB 작업이 실패했습니다.");

                foreach (var receipt in receipts)
                {
                    ProductManager.Ordering(db, receipt.ProductInfoId, receipt.Count, receipt.Price, newOrder.id, storeId);
                }
                return new Order(newOrder);
            }
        }
コード例 #4
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static List<string> GetType2ListByType1(ProjectSIAEntities db, string type1)
		{
			using (var rl = new ReadLock())
			{
				return GetAllProductInfoList(db).Where(x => x.Type1 == type1).Select(x => x.Type2)
					.Distinct().OrderBy(x => x).ToList();
			}
		}
コード例 #5
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static List<ProductInfo> GetAllProductInfoList(ProjectSIAEntities db, bool reload = false)
		{
			using (var rl = new ReadLock())
			{
				if (_productInfoList == null || reload)
					Caching(db);
				return _productInfoList;
			}
		}
コード例 #6
0
ファイル: Designer.cs プロジェクト: jkwchunjae/ProjectSIA
 public static Designer AddNewDesigner(ProjectSIAEntities db, string name, string phone, string picture)
 {
     using (var wl = new WriteLock())
     {
         var newDesigner = db.Designer.Add(new ProjectSIA.Designer { name = name, phone = phone, picture = picture });
         var rows = db.SaveChanges();
         if (rows != 1)
             throw new AutistarException("디자이너 추가 DB 작업이 실패했습니다.");
         return new Designer(newDesigner);
     }
 }
コード例 #7
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
        public static void BringProduct(ProjectSIAEntities db, int storeId, IEnumerable<ProductCount> productCountList)
        {
            using (var wl = new WriteLock())
            {
                if (productCountList.Count() == 0)
                    throw new AutistarException("행사장(거래처) 가져갈 물품을 입력하지 않았습니다.");
                if (productCountList.Where(x => x.Count <= 0).Any())
                    throw new AutistarException("행사장(거래처) 가져갈 물품 중 수량이 0보다 작은 항목이 있습니다.");

                // Id 검사. Invalid 한 Id이면 exception 나겠지
                productCountList.Select(x => ProductInfoManager.GetByProductInfoId(db, x.ProductInfoId)).ToList();
                GetStore(db, storeId);

                foreach (var productCount in productCountList)
                {
                    ProductManager.BringStore(db, storeId, productCount.ProductInfoId, productCount.Count);
                }
            }
        }
コード例 #8
0
ファイル: LogWarehouse.cs プロジェクト: jkwchunjae/ProjectSIA
        public static LogWarehouse AddNewLogWarehouse(ProjectSIAEntities db, int productInfoId, int warehouseCount, DateTime warehouseDate, string others)
        {
            using (var wl = new WriteLock())
            {
                var newLogWarehouse = db.LogWarehouse.Add(new ProjectSIA.LogWarehouse
                {
                    productInfoId = productInfoId,
                    warehouseCount = warehouseCount,
                    warehouseDate = warehouseDate,
                    badCount = 0,
                    others = ""
                });
                var rows = db.SaveChanges();

                if (rows != 1)
                    throw new Exception("상품 입고 처리 중 DB 작업이 실패하였습니다.");

                return new LogWarehouse(newLogWarehouse);
            }
        }
コード例 #9
0
ファイル: Member.cs プロジェクト: jkwchunjae/ProjectSIA
 public static Member AddNewMember(ProjectSIAEntities db, string name, string phone, string address, string orgName)
 {
     using (var wl = new WriteLock())
     {
         if (name == "dummy")
         {
             // thread-safe 하게 하기 위해서 WriteLock 걸고 한번 더 체크해 줘야 함.
             var dummy = db.Member.Where(x => x.name == "dummy").FirstOrDefault();
             if (dummy != null)
                 return GetDummyMember(db);
         }
         var isOrg = string.IsNullOrEmpty(orgName) ? false : true;
         var newMember = db.Member.Add(new ProjectSIA.Member { name = name, phone = phone, address = address, isOrg = isOrg, orgName = orgName, isVip = false });
         var rows = db.SaveChanges();
         if (rows != 1)
             throw new AutistarException("사용자 추가 DB 작업이 실패했습니다.");
         var member = new Member(newMember);
         _memberList.Add(member);
         return member;
     }
 }
コード例 #10
0
ファイル: Order.cs プロジェクト: jkwchunjae/ProjectSIA
 public static Order GetOrder(ProjectSIAEntities db, int orderId)
 {
     using (var rl = new ReadLock())
     {
         var dbOrder = db.OrderInfo.Where(x => x.id == orderId).FirstOrDefault();
         if (dbOrder == null)
             throw new AutistarException("등록되지 않은 주문번호입니다. (id: {0})".With(orderId));
         return new Order(dbOrder);
     }
 }
コード例 #11
0
ファイル: Designer.cs プロジェクト: jkwchunjae/ProjectSIA
 public static List<Designer> GetAllDesingerList(ProjectSIAEntities db, bool reload = false)
 {
     using (var rl = new ReadLock())
     {
         if (_designerList == null || reload)
         {
             Caching(db);
         }
         return _designerList;
     }
 }
コード例 #12
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static ProductInfo AddNewProductInfo(ProjectSIAEntities db, string type1, string type2, string type3, string name, long price, DateTime regDate)
		{
			using (var wl = new WriteLock())
			{
				var newProductInfo = db.ProductInfo.Add(new ProjectSIA.ProductInfo { type1 = type1, type2 = type2, type3 = type3, name = name, price = price, regDate = regDate });
				var rows = db.SaveChanges();
				if (rows != 1)
					throw new AutistarException("신규 상품 등록 중 DB 작업이 실패하였습니다.");
				return new ProductInfo(newProductInfo);
			}
		}
コード例 #13
0
ファイル: Order.cs プロジェクト: jkwchunjae/ProjectSIA
 public static List<Order> GetOrderList(ProjectSIAEntities db, DateTime beginDate, DateTime endDate)
 {
     using (var rl = new ReadLock())
     {
         return db.OrderInfo.Where(x => x.payDate >= beginDate && x.payDate <= endDate)
             .ToList()
             .Select(x => new Order(x))
             .ToList();
         //return GetAllOrderList(db).Where(x => (x.PayDate >= beginDate && x.PayDate <= endDate)).ToList();
     }
 }
コード例 #14
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		/// <summary> 매핑된 디자이너 이름 포함 검색 </summary>
		public static List<ProductInfo> SearchWithDesignerName(ProjectSIAEntities db, string[] keywords)
		{
			using (var rl = new ReadLock())
			{
				var result = new List<ProductInfo>();

				#region 디자이너 이름 전처리
				var DesignerNameDic = DesignerMappingManager.GetAllMappingList(db)
					.Join(DesignerManager.GetAllDesingerList(db), x => x.DesignerId, y => y.Id, (x, y) => new { x.ProductInfoId, y.Name })
					.GroupBy(x => new { x.ProductInfoId })
					.Select(x => new { x.Key.ProductInfoId, DesignerNames = x.Select(e => e.Name).StringJoin(" ") })
					.ToDictionary(x => x.ProductInfoId, y => y.DesignerNames);
				#endregion

				var productList = GetAllProductInfoList(db);
				foreach (var product in productList)
				{
					var str = product.Type1 + product.Type2 + product.Type3 + product.Name;
					if (DesignerNameDic.ContainsKey(product.Id))
						str += DesignerNameDic[product.Id];
					var allChecked = true;
					foreach (var keyword in keywords)
					{
						if (!str.Contains(keyword))
						{
							allChecked = false;
							break;
						}
					}
					if (allChecked)
						result.Add(product);
				}
				return result;
			}
		}
コード例 #15
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static List<string> SearchType2ByType1(ProjectSIAEntities db, string type1, string[] keywords)
		{
			using (var rl = new ReadLock())
			{
				var type2List = GetType2ListByType1(db, type1);
				if (keywords.Contains("."))
					return type2List;
				var result = new List<string>();
				foreach (var type2 in type2List)
				{
					var allChecked = true;
					foreach (var keyword in keywords)
					{
						if (!type2.Contains(keyword))
						{
							allChecked = false;
							break;
						}
					}
					if (allChecked)
						result.Add(type2);
				}
				return result;
			}
		}
コード例 #16
0
ファイル: Order.cs プロジェクト: jkwchunjae/ProjectSIA
        /// <summary> 주문 결재 </summary>
        public static void PayingOrder(ProjectSIAEntities db, int orderId, DateTime payDate)
        {
            using (var wl = new WriteLock())
            {
                var dbOrder = db.OrderInfo.Where(x => x.id == orderId).FirstOrDefault();

                if (dbOrder == null)
                    throw new AutistarException("결재: 등록되지 않은 주문번호입니다. (id: {0})".With(orderId));

                dbOrder.payDate = payDate;
                dbOrder.isPay = true;
                var rows = db.SaveChanges();
                if (rows != 1)
                    throw new AutistarException("주문 결재 처리 DB 작업이 실패했습니다.");
            }
        }
コード例 #17
0
ファイル: Order.cs プロジェクト: jkwchunjae/ProjectSIA
 public static List<Order> GetAllOrderList(ProjectSIAEntities db)
 {
     using (var rl = new ReadLock())
     {
         return db.OrderInfo.ToList().Select(x => new Order(x)).ToList();
     }
 }
コード例 #18
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
 public static Store GetLocalStore(ProjectSIAEntities db)
 {
     using (var rl = new ReadLock())
     {
         var localStore = GetAllStoreList(db).Where(x => x.Type == StoreType.Local).FirstOrDefault();
         if (localStore == null)
         {
             using (var wl = new WriteLock())
             {
                 var dbLocalStore = db.Store.Add(new ProjectSIA.Store() { name = "사무실", beginDate = new DateTime(2012, 1, 1), endDate = DateTime.MaxValue, type = StoreType.Local.ToString(), rule = StoreRule.None.ToString(), value = 0 });
                 var rows = db.SaveChanges();
                 if (rows != 1)
                     throw new AutistarException("사무실 Store를 만드는 과정 중 DB 작업을 실패했습니다.");
                 localStore = new Store(dbLocalStore);
             }
         }
         return localStore;
     }
 }
コード例 #19
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
 public static List<Store> GetAllStoreList(ProjectSIAEntities db, bool reload = false)
 {
     using (var rl = new ReadLock())
     {
         if (_storeList == null || reload)
         {
             _storeList = db.Store.ToList().Select(x => new Store(x)).ToList();
         }
         return _storeList;
     }
 }
コード例 #20
0
ファイル: Order.cs プロジェクト: jkwchunjae/ProjectSIA
        /// <summary> 주문된 상품 출고하기 </summary>
        public static void ReleaseOrder(ProjectSIAEntities db, int orderId, DateTime releaseDate)
        {
            using (var wl = new WriteLock())
            {
                var dbOrder = db.OrderInfo.Where(x => x.id == orderId).FirstOrDefault();

                if (dbOrder == null)
                    throw new AutistarException("출고: 등록되지 않은 주문번호입니다. (id: {0})".With(orderId));

                if (dbOrder.status != OrderStatus.Prepare.ToString())
                    throw new AutistarException("출고: 상태가 주문 준비중이지 않습니다. (id: {0})".With(orderId));

                dbOrder.status = OrderStatus.Release.ToString();
                dbOrder.releaseDate = releaseDate;
                db.SaveChanges();

                ProductManager.ReleaseProduct(db, orderId);
            }
        }
コード例 #21
0
ファイル: Designer.cs プロジェクト: jkwchunjae/ProjectSIA
 public static Designer GetDesigner(ProjectSIAEntities db, int designerId)
 {
     using (var rl = new ReadLock())
     {
         var designer = GetAllDesingerList(db).Where(x => x.Id == designerId).FirstOrDefault();
         if (designer == null)
             throw new AutistarException("등록되지 않은 디자이너입니다. (id: {0})".With(designerId));
         return designer;
     }
 }
コード例 #22
0
ファイル: Designer.cs プロジェクト: jkwchunjae/ProjectSIA
 public static List<Designer> Search(ProjectSIAEntities db, string keyword)
 {
     using (var rl = new ReadLock())
     {
         return GetAllDesingerList(db)
             .Where(x => x.Name.Contains(keyword))
             .ToList();
     }
 }
コード例 #23
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
 public static bool DeleteStore(ProjectSIAEntities db, int storeId)
 {
     using (var wl = new WriteLock())
     {
         var dbStore = db.Store.Where(x => x.id == storeId).FirstOrDefault();
         if (dbStore == null)
             throw new AutistarException("등록되지 않은 행사장(거래처) Id 입니다. (id: {0})".With(storeId));
         db.Store.Remove(dbStore);
         var rows = db.SaveChanges();
         if (rows == 1)
         {
             var store = _storeList.Where(x => x.Id == storeId).FirstOrDefault();
             if (store != null)
                 _storeList.Remove(store);
         }
         return rows == 1;
     }
 }
コード例 #24
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static ProductInfo GetByProductInfoId(ProjectSIAEntities db, int productInfoId)
		{
			using (var rl = new ReadLock())
			{
				if (_productInfoDic == null) GetAllProductInfoList(db, true);
				if (!_productInfoDic.ContainsKey(productInfoId))
					throw new AutistarException("등록되지 않은 상품 기본정보 일련번호입니다. (id: {0})".With(productInfoId));
				return _productInfoDic[productInfoId];
			}
		}
コード例 #25
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
 public static List<Store> GetCurrentOpenedStore(ProjectSIAEntities db)
 {
     using (var rl = new ReadLock())
     {
         return GetAllStoreList(db).Where(x => x.BeginDate < DateTime.Now && x.EndDate > DateTime.Now).ToList();
     }
 }
コード例 #26
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static List<ProductInfo> GetListByProductInfoId(ProjectSIAEntities db, IEnumerable<int> productInfoIdList)
		{
			using (var rl = new ReadLock())
			{
				if (_productInfoDic == null) GetAllProductInfoList(db, true);
				if (productInfoIdList.Where(x => !_productInfoDic.ContainsKey(x)).Any())
					throw new AutistarException("등록되지 않은 ProductInfo Id가 있습니다.");
				return productInfoIdList.Select(x => _productInfoDic[x]).ToList();
			}
		}
コード例 #27
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
 public static Store GetStore(ProjectSIAEntities db, int storeId)
 {
     using (var rl = new ReadLock())
     {
         var store = GetAllStoreList(db).Where(x => x.Id == storeId).FirstOrDefault();
         if (store == null)
             throw new AutistarException("등록되지 않은 행사장(거래처) 번호입니다. (id: {0})".With(storeId));
         return store;
     }
 }
コード例 #28
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		public static void Caching(ProjectSIAEntities db)
		{
			using (var wl = new WriteLock())
			{
				_productInfoList = db.ProductInfo.ToList().Select(x => new ProductInfo(x)).ToList();
				try
				{
					_productInfoDic = _productInfoList.ToDictionary(x => x.Id, x => x);
				}
				catch (ArgumentException)
				{
					_productInfoDic = null;
					throw new AutistarException("중복된 ProductInfo Id가 존재합니다.");
				}
			}
		}
コード例 #29
0
ファイル: Store.cs プロジェクト: jkwchunjae/ProjectSIA
        public static Store CreateStore(ProjectSIAEntities db, string name, DateTime beginDate, DateTime endDate, StoreType type, StoreRule rule, double value)
        {
            using (var wl = new WriteLock())
            {
                if (endDate <= beginDate)
                    throw new AutistarException("종료일이 시작일보다 빠릅니다.");

                var newStore = db.Store.Add(new ProjectSIA.Store { name = name, beginDate = beginDate, endDate = endDate, type = type.ToString(), rule = rule.ToString(), value = value });
                var rows = db.SaveChanges();
                if (rows != 1)
                    throw new AutistarException("행사장(거래처) 추가 중 DB 작업이 실패했습니다.");
                var store = new Store(newStore);
                _storeList.Add(store);
                return store;
            }
        }
コード例 #30
0
ファイル: ProductInfo.cs プロジェクト: jkwchunjae/ProjectSIA
		/// <summary> 분류1,2,3 + 이름 검색 </summary>
		public static List<ProductInfo> Search(ProjectSIAEntities db, string[] keywords)
		{
			using (var rl = new ReadLock())
			{
				var result = new List<ProductInfo>();
				var productList = GetAllProductInfoList(db);
				foreach (var product in productList)
				{
					var str = product.Type1 + product.Type2 + product.Type3 + product.Name;
					var allChecked = true;
					foreach (var keyword in keywords)
					{
						if (!str.Contains(keyword))
						{
							allChecked = false;
							break;
						}
					}
					if (allChecked)
						result.Add(product);
				}
				return result;
			}
		}