public void RegisterDeleteOrderObject(OrderObject newObj) {
			Logger.info("Пользователь удалил оборудование", Logger.LoggerSource.objectsContext);
			try {
				if (!CurrentUser.AllowEditTree) {
					throw new DomainException("У вас нет прав редактировать оборудование");
				}
				VotGESOrdersEntities context=new VotGESOrdersEntities();
				VotGESOrders.Web.ADONETEntities.Orders orderDB=new Orders();
				OrderObjects objDB=(from o in context.OrderObjects where o.objectID == newObj.ObjectID select o).First();

				deleteOrderObject(context, objDB);
				//context.OrderObjects.DeleteObject(objDB);
				
				
				context.SaveChanges();
				OrderObject.init();
				Logger.info("===Сохранено", Logger.LoggerSource.objectsContext);

			} catch (Exception e) {
				Logger.error(String.Format("===Ошибка при удалении оборудования: {0}", e), Logger.LoggerSource.objectsContext);
				if (e is DomainException) {
					throw e;
				}
				throw new DomainException("Ошибка при удалении оборудования, возможно на оборудование (или дочернее оборудование) ссылаются заявки");
			}
		}
        public void RegisterDeleteOrderObject(OrderObject newObj)
        {
            Logger.info("Пользователь удалил оборудование", Logger.LoggerSource.objectsContext);
            try {
                if (!CurrentUser.AllowEditTree)
                {
                    throw new Exception("У вас нет прав редактировать оборудование");
                }
                VotGESOrdersEntities context = new VotGESOrdersEntities();
                VotGESOrders.Web.ADONETEntities.Orders orderDB = new Orders();
                OrderObjects objDB = (from o in context.OrderObjects where o.objectID == newObj.ObjectID select o).First();

                deleteOrderObject(context, objDB);
                //context.OrderObjects.DeleteObject(objDB);


                context.SaveChanges();
                OrderObject.init();
                Logger.info("===Сохранено", Logger.LoggerSource.objectsContext);
            } catch (Exception e) {
                Logger.error(String.Format("===Ошибка при удалении оборудования: {0}", e), Logger.LoggerSource.objectsContext);
                if (e is Exception)
                {
                    throw e;
                }
                throw new Exception("Ошибка при удалении оборудования, возможно на оборудование (или дочернее оборудование) ссылаются заявки");
            }
        }
Esempio n. 3
0
        protected static void createNames()
        {
            foreach (KeyValuePair <int, OrderObject> de in allObjects)
            {
                OrderObject obj = de.Value;

                obj.FullName = obj.getFullName();
            }
        }
Esempio n. 4
0
 public static OrderObject getFromDB(OrderObjects objectDB)
 {
     try {
         OrderObject obj = new OrderObject();
         obj.ObjectName     = objectDB.objectName;
         obj.ObjectID       = objectDB.objectID;
         obj.ParentObjectID = objectDB.parentID;
         obj.ShowInFullName = objectDB.showInFullName;
         return(obj);
     } catch (Exception e) {
         Logger.error(String.Format("Ошибка при получении информации об оборудовании: {0}", e), Logger.LoggerSource.server);
     }
     return(null);
 }
Esempio n. 5
0
        public string getFullName()
        {
            OrderObject   parent = getByID(ParentObjectID);
            List <string> names  = new List <string>();

            names.Add(ObjectName);
            while (parent != null)
            {
                if (parent.ShowInFullName)
                {
                    names.Add(parent.ObjectName);
                }
                parent = getByID(parent.ParentObjectID);
            }
            names.Reverse();
            return(String.Join(" => ", names));
        }
        public void RegisterChangeOrderObject(OrderObject newObj)
        {
            Logger.info("Пользователь изменил оборудование", Logger.LoggerSource.objectsContext);
            try {
                if (!CurrentUser.AllowEditTree)
                {
                    throw new Exception("У вас нет прав редактировать оборудование");
                }
                VotGESOrdersEntities context = new VotGESOrdersEntities();

                IQueryable <OrderObjects> objectsDB = (from o in context.OrderObjects where o.objectID == newObj.ObjectID select o);
                OrderObjects objDB = null;
                if (objectsDB.Count() == 0)
                {
                    Logger.info("===Новое оборудование", Logger.LoggerSource.objectsContext);
                    objDB = new OrderObjects();
                    context.OrderObjects.AddObject(objDB);
                }
                else
                {
                    objDB = objectsDB.First();
                }
                objDB.objectName     = newObj.ObjectName;
                objDB.parentID       = newObj.ParentObjectID;
                objDB.showInFullName = newObj.ShowInFullName;

                context.SaveChanges();

                newObj.ObjectID   = objDB.objectID;
                newObj.ObjectName = objDB.objectName;
                OrderObject.init();
                newObj.FullName = OrderObject.getByID(newObj.ObjectID).getFullName();
                Logger.info("===Сохранено", Logger.LoggerSource.objectsContext);
            } catch (Exception e) {
                Logger.error(String.Format("===Ошибка при изменении оборудования: {0}", e), Logger.LoggerSource.objectsContext);
                if (e is Exception)
                {
                    throw e;
                }
                throw new Exception("Ошибка при изменении/создании оборудования");
            }
        }
		public void RegisterChangeOrderObject(OrderObject newObj) {
			Logger.info("Пользователь изменил оборудование", Logger.LoggerSource.objectsContext);
			try {
				if (!CurrentUser.AllowEditTree) {
					throw new DomainException("У вас нет прав редактировать оборудование");
				}
				VotGESOrdersEntities context=new VotGESOrdersEntities();

				IQueryable<OrderObjects> objectsDB=(from o in context.OrderObjects where o.objectID == newObj.ObjectID select  o);
				OrderObjects objDB=null;
				if (objectsDB.Count()==0) {
					Logger.info("===Новое оборудование", Logger.LoggerSource.objectsContext);
					objDB = new OrderObjects();
					context.OrderObjects.AddObject(objDB);
				} else {
					objDB = objectsDB.First();
				}
				objDB.objectName = newObj.ObjectName;
				objDB.parentID = newObj.ParentObjectID;
				objDB.showInFullName = newObj.ShowInFullName;

				context.SaveChanges();

				newObj.ObjectID = objDB.objectID;
				newObj.ObjectName = objDB.objectName;
				OrderObject.init();
				newObj.FullName = OrderObject.getByID(newObj.ObjectID).getFullName();
				Logger.info("===Сохранено", Logger.LoggerSource.objectsContext);

			} catch (Exception e) {
				Logger.error(String.Format("===Ошибка при изменении оборудования: {0}", e), Logger.LoggerSource.objectsContext);
				if (e is DomainException) {
					throw e;
				}
				throw new DomainException("Ошибка при изменении/создании оборудования");
			}
		}
Esempio n. 8
0
		public static OrderObject getFromDB(OrderObjects objectDB) {
			try {
				OrderObject obj=new OrderObject();
				obj.ObjectName = objectDB.objectName;
				obj.ObjectID = objectDB.objectID;
				obj.ParentObjectID = objectDB.parentID;
				obj.ShowInFullName = objectDB.showInFullName;
				return obj;
			} catch (Exception e) {
				Logger.error(String.Format("Ошибка при получении информации об оборудовании: {0}", e), Logger.LoggerSource.server);
			}
			return null;
		}
		public void RegisterDeleteObject(OrderObject newObject) {
			Logger.info("удаление оборудования " + newObject.ObjectName, Logger.LoggerSource.service);
			objContext.RegisterDeleteOrderObject(newObject);
		}
		public void UpdateOrderObject(OrderObject obj) {
			//Logger.info("Сервис: Update " + obj.ObjectName);
			//context.UpdateOrder(order);
		}
 /// <summary>
 /// Вызывает метод "RegisterDeleteObject" указанной сущности <see cref="OrderObject"/>.
 /// </summary>
 /// <param name="newObject">Экземпляр сущности <see cref="OrderObject"/>.</param>
 public void RegisterDeleteObject(OrderObject newObject)
 {
     newObject.RegisterDeleteObject();
 }
 /// <summary>
 /// Вызывает метод "RegisterChangeObject" указанной сущности <see cref="OrderObject"/>.
 /// </summary>
 /// <param name="newObject">Экземпляр сущности <see cref="OrderObject"/>.</param>
 public void RegisterChangeObject(OrderObject newObject)
 {
     newObject.RegisterChangeObject();
 }
 private bool FilterParentObject(OrderObject entity)
 {
     return (entity.ObjectID == this.ParentObjectID);
 }
 private bool FilterChildObjects(OrderObject entity)
 {
     return (entity.ParentObjectID == this.ObjectID);
 }
 private bool FilterSelOrderObject(OrderObject entity)
 {
     return (entity.ObjectID == this.SelOrderObjectID);
 }
Esempio n. 16
0
		private void deleteObject(OrderObject obj) {
			foreach (OrderObject child in obj.ChildObjects) {
				OrdersContext.Current.Context.OrderObjects.Detach(child);
			}
		}
Esempio n. 17
0
		private void btnAddItem_Click(object sender, RoutedEventArgs e) {
			refreshSelObject();	
			OrderObject newObj=new OrderObject();
			newObj.ObjectID = CurrentObjectNumber--;
			SelParentOrderObject = SelObject;
			newObj.ParentObjectID = SelObject.ObjectID;
			objectForm.CurrentItem = newObj;
			isNew = true;
			SelObject = newObj;
		}
Esempio n. 18
0
		private void treeObjects_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) {
			if (SelObject != null) {
				OrderObject selectedObject=treeObjects.SelectedItem as OrderObject;
				if ((selectedObject != null)&&(selectedObject!=SelObject)) {
					OrderObject parent=selectedObject.ParentObject;
					bool log=true;
					while (parent != null) {
						if (parent.ObjectID == SelObject.ObjectID) {
							log = false;
						}
						parent = parent.ParentObject;						
					}
					if (log) {
						SelParentOrderObject = selectedObject;
					}
				}

			}
		}
Esempio n. 19
0
		protected void refreshSelObject(){
			OrderObject selectedObject=treeObjects.SelectedItem as OrderObject;
				cancelEdit();				
			if (selectedObject != null) {
				SelObject = selectedObject;
				SelParentOrderObject = selectedObject.ParentObject;
			}
			isNew = false;
		}
Esempio n. 20
0
        public void refreshOrderFromDB(Orders dbOrder, OrdersUser currentUser, bool readRelated, List <Order> listOrders)
        {
            if (listOrders != null)
            {
                if (!listOrders.Contains(this))
                {
                    listOrders.Add(this);
                }
            }

            OrderOperation = OrderOperationEnum.none;
            checkPremissions(dbOrder, currentUser);


            SelOrderObject = OrderObject.getByID(dbOrder.orderObjectID);

            OrderNumber = dbOrder.orderNumber;
            if (dbOrder.orderYearNumber.HasValue)
            {
                OrderYearNumber = dbOrder.orderYearNumber.Value;
            }
            else
            {
                OrderYearNumber = OrderNumber;
            }

            OrderType = (OrderTypeEnum)Enum.Parse(typeof(OrderTypeEnum), dbOrder.orderType, true);
            ReadyTime = dbOrder.readyTime;

            CreateText         = dbOrder.createText;
            ReviewText         = dbOrder.reviewText;
            OpenText           = dbOrder.openText;
            CloseText          = dbOrder.closeText;
            CompleteText       = dbOrder.completeText;
            CancelText         = dbOrder.cancelText;
            OrderObjectAddInfo = dbOrder.orderObjectAddInfo;

            OrderText         = dbOrder.orderText;
            AgreeText         = dbOrder.agreeText;
            AgreeUsersIDSText = dbOrder.agreeUsersIDS;
            refreshAgreeUsers();

            FaktStartDate    = dbOrder.faktStartDate;
            FaktStopDate     = dbOrder.faktStopDate;
            FaktCompleteDate = dbOrder.faktCompleteDate;
            PlanStartDate    = dbOrder.planStartDate;
            PlanStopDate     = dbOrder.planStopDate;

            OrderDateReview   = dbOrder.orderDateReview;
            OrderDateClose    = dbOrder.orderDateClose;
            OrderDateOpen     = dbOrder.orderDateOpen;
            OrderDateCreate   = dbOrder.orderDateCreate;
            OrderDateComplete = dbOrder.orderDateComplete;
            OrderDateCancel   = dbOrder.orderDateCancel;

            ExpiredReglamentHours = dbOrder.expiredReglamentHours;
            ExpiredOpenHours      = dbOrder.expiredOpenHours;
            ExpiredCompleteHours  = dbOrder.expiredCompleteHours;
            ExpiredCloseHours     = dbOrder.expiredCloseHours;

            OrderIsExpiredClose     = ExpiredCloseHours.HasValue && ExpiredCloseHours.Value < 0;
            OrderIsExpiredOpen      = ExpiredOpenHours.HasValue && ExpiredOpenHours.Value < 0;
            OrderIsExpriredComplete = ExpiredCompleteHours.HasValue && ExpiredCompleteHours.Value < 0;
            OrderIsExpiredReglament = ExpiredReglamentHours.HasValue && ExpiredReglamentHours.Value < 0;


            CommentsText = dbOrder.commentsText;
            HasComments  = !String.IsNullOrEmpty(CommentsText) || !String.IsNullOrEmpty(CreateText);


            UserCreateOrder = OrdersUser.loadFromCache(dbOrder.userCreateOrderID);

            if (dbOrder.userReviewOrderID != null)
            {
                UserReviewOrder = OrdersUser.loadFromCache(dbOrder.userReviewOrderID.Value);
            }
            if (dbOrder.userCloseOrderID != null)
            {
                UserCloseOrder = OrdersUser.loadFromCache(dbOrder.userCloseOrderID.Value);
            }
            if (dbOrder.userCancelOrderID != null)
            {
                UserCancelOrder = OrdersUser.loadFromCache(dbOrder.userCancelOrderID.Value);
            }
            if (dbOrder.userOpenOrderID != null)
            {
                UserOpenOrder = OrdersUser.loadFromCache(dbOrder.userOpenOrderID.Value);
            }
            if (dbOrder.userCompleteOrderID != null)
            {
                UserCompleteOrder = OrdersUser.loadFromCache(dbOrder.userCompleteOrderID.Value);
            }



            if (OrderExtended || OrderAskExtended || OrderCompletedWithoutEnter)
            {
                if (readRelated)
                {
                    ChildOrder = GetOrder(dbOrder.childOrderNumber.Value, currentUser, readRelated, listOrders);
                }
                else
                {
                    ChildOrderNumber = dbOrder.childOrderNumber.Value;
                }
                ChildOrderYearNumber = Math.Floor(OrderYearNumber) + ChildOrderNumber - Math.Floor(ChildOrderNumber);
            }
            else
            {
                ChildOrderNumber     = 0;
                ChildOrderYearNumber = 0;
            }


            if (OrderIsExtend || OrderIsFixErrorEnter)
            {
                if (readRelated)
                {
                    ParentOrder = GetOrder(dbOrder.parentOrderNumber.Value, currentUser, readRelated, listOrders);
                }
                else
                {
                    ParentOrderNumber = dbOrder.parentOrderNumber.Value;
                }
                ParentOrderYearNumber = Math.Floor(OrderYearNumber) + ParentOrderNumber - Math.Floor(ParentOrderNumber);
            }
            else
            {
                ParentOrderNumber     = 0;
                ParentOrderYearNumber = 0;
            }

            OrderYearNumber       = checkOrderNumber(OrderYearNumber);
            ParentOrderYearNumber = checkOrderNumber(ParentOrderYearNumber);
            ChildOrderYearNumber  = checkOrderNumber(ChildOrderYearNumber);

            if (OrderIsExtend || OrderIsFixErrorEnter)
            {
                try {
                    OrderYear = GetOrder(Math.Floor(OrderNumber), currentUser, false, null).OrderDateCreate.Year;
                } catch (Exception e) {
                    OrderYear = OrderDateCreate.Year;
                }
            }
            else
            {
                OrderYear = OrderDateCreate.Year;
            }
            OrderNumberFloor = Math.Floor(OrderNumber).ToString();
            OrderNumberExp   = Math.Round(((OrderNumber - Math.Floor(OrderNumber)) * 100)).ToString();
            if (OrderNumberExp.Length == 1)
            {
                OrderNumberExp = "0" + OrderNumberExp;
            }
            IsCurrentYear       = OrderYear == DateTime.Now.Year;
            OrderHasChildOrder  = ChildOrderNumber > 0;
            OrderHasParentOrder = ParentOrderNumber > 0;
            checkTimeToOpen();
        }