Esempio n. 1
0
            internal static int Change(Mark item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var items = new XPCollection <DB.Marks>(unitOfWork))
                    {
                        var dbItem = items.FirstOrDefault(u => u.Id == item.Id);
                        if (dbItem == null)
                        {
                            throw new Exception(Resources.Marks_Read_Марка_не_найдена_);
                        }

                        var duplicatedbItem = items.FirstOrDefault(u => u.Name == item.Name && u.Id != item.Id);
                        if (duplicatedbItem != null)
                        {
                            throw new Exception(Resources.Marks_AddNew_Такая_марка_уже_есть_);
                        }

                        dbItem.Name   = item.Name;
                        dbItem.SiteId = item.SiteId;
                    }

                    unitOfWork.CommitChanges();

                    return(item.Id);
                }
            }
Esempio n. 2
0
            internal static int Change(User user, bool changePassword)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var users = new XPCollection <DB.Users>(unitOfWork))
                    {
                        var dbUser = users.FirstOrDefault(u => u.Id == user.Id);
                        if (dbUser == null)
                        {
                            throw new Exception(Resources.Users_Read_Пользователь_не_найден_);
                        }

                        var duplicateDbUser = users.FirstOrDefault(u => u.Login == user.Login && u.Id != user.Id);
                        if (duplicateDbUser != null)
                        {
                            throw new Exception(Resources.Users_AddNew_Такой_пользователь_уже_существует_);
                        }

                        dbUser.Login  = user.Login;
                        dbUser.SiteId = user.SiteId;
                        if (changePassword)
                        {
                            dbUser.PasswordHash = user.PasswordHash;
                        }
                    }

                    unitOfWork.CommitChanges();

                    return(user.Id);
                }
            }
Esempio n. 3
0
            private static int Change(CarModel item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var items = new XPCollection <DB.CarModels>(unitOfWork))
                    {
                        var dbItem = items.FirstOrDefault(u => u.Id == item.Id);
                        if (dbItem == null)
                        {
                            throw new Exception(Resources.CarModels_Read_Модель_не_найдена_);
                        }

                        var duplicatedbItem = items.FirstOrDefault(u => u.Name == item.Name && u.Id != item.Id);
                        if (duplicatedbItem != null)
                        {
                            throw new Exception(Resources.CarModels_AddNew_Такая_модель_уже_есть_);
                        }

                        dbItem.Name = item.Name;
                    }

                    unitOfWork.CommitChanges();

                    return(item.Id);
                }
            }
Esempio n. 4
0
File: COGSBO.cs Progetto: ewin66/dev
        public COGS GetLastCOGSByIssueDate(Session session, Guid ItemUnitId, Guid CurrencyId, Guid InventoryId, DateTime IssueDate)
        {
            COGS result = null;

            try
            {
                CriteriaOperator filter = CriteriaOperator.And(
                    new BinaryOperator("ItemUnitId!Key", ItemUnitId),
                    new BinaryOperator("CurrencyId!Key", CurrencyId),
                    new BinaryOperator("InventoryId!Key", InventoryId),
                    new BinaryOperator("IssueDate", IssueDate, BinaryOperatorType.LessOrEqual));
                XPCollection <COGS> COGSList = new XPCollection <COGS>(session, filter);
                COGSList.Sorting.Add(new SortProperty("IssueDate", SortingDirection.Descending));
                COGSList.Sorting.Add(new SortProperty("CreateDate", SortingDirection.Descending));
                result = COGSList.FirstOrDefault();
                /////////////////////////////////////////
                if (result == null)
                {
                    filter = CriteriaOperator.And(
                        new BinaryOperator("ItemUnitId!Key", ItemUnitId),
                        new BinaryOperator("InventoryId!Key", InventoryId));
                    COGSList = new XPCollection <COGS>(session, filter);
                    COGSList.Sorting.Add(new SortProperty("IssuedDate", SortingDirection.Descending));
                    COGSList.Sorting.Add(new SortProperty("CreateDate", SortingDirection.Descending));
                    result = COGSList.FirstOrDefault();
                }
                /////////////////////////////////////////
            }
            catch (Exception)
            {
                return(result);
            }
            return(result);
        }
Esempio n. 5
0
            internal static int AddNew(Damage item, UnitOfWork unitOfWork, bool commit = false)
            {
                DB.Damages dbItem;
                using (var items = new XPCollection <DB.Damages>(unitOfWork))
                {
                    if (item.Id > 0)
                    {
                        dbItem = items.FirstOrDefault(q => q.Id == item.Id);
                        if (dbItem != null)
                        {
                            dbItem.Archive = false;
                        }
                    }
                    else
                    {
                        dbItem = new DB.Damages(unitOfWork)
                        {
                            Description = item.Description,
                            Detail      = item.Detail,
                        };
                    }
                    items.Add(FillDependencies(unitOfWork, dbItem, item));
                }
                if (commit)
                {
                    unitOfWork.CommitChanges();
                }

                return(dbItem.Id);
            }
Esempio n. 6
0
            internal static int Change(Service item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var items = new XPCollection <DB.Services>(unitOfWork))
                    {
                        var dbItem = items.FirstOrDefault(u => u.Id == item.Id);
                        if (dbItem == null)
                        {
                            throw new Exception(Resources.Services_Read_Услуга_не_найдена_);
                        }

                        /*  var duplicatedbItem = items.FirstOrDefault(u => u.Name == item.Name&& u.Id != item.Id&&u.User!=null&&u.User.Id==item.User.Id);
                         * if (duplicatedbItem != null)
                         *    throw new Exception(Resources.Services_AddNew_Такая_услуга_уже_существует_);
                         */
                        // dbItem.Name = item.Name;
                        dbItem.Price     = item.Price;
                        dbItem.PriceType = item.PriceType;
                        dbItem.Status    = item.Status;
                        dbItem.SiteId    = item.SiteId;
                        dbItem.CompanyId = item.CompanyId;
                    }

                    unitOfWork.CommitChanges();

                    return(item.Id);
                }
            }
Esempio n. 7
0
        public void Connect(string userName, string email)
        {
            emailIDLoaded = email;
            var id     = Context.ConnectionId;
            var uow    = new XpoDAO().ProvideUnitOfWork();
            var result = new XPCollection <ChatUserDetail>(uow);
            var item   = result.FirstOrDefault(x => x.EmailID == email);

            if (item != null)
            {
                uow.Delete(item);
                //result.Remove(item);
                uow.CommitChanges();
                // Disconnect
                Clients.All.onUserDisconnectedExisting(item.ConnectionId, item.UserName);
            }
            var Users = result;

            if (Users.Where(x => x.EmailID == email).ToList().Count == 0)
            {
                var userdetails = new ChatUserDetail(uow)
                {
                    ConnectionId = id,
                    UserName     = userName,
                    EmailID      = email
                };
                uow.CommitChanges();;

                // send to caller
                var connectedUsers = result;
                var CurrentMessage = new XPCollection <ChatMessageDetail>(uow);// dc.ChatMessageDetails.ToList();
                List <TempChatMessageDetail> lstTempChatMessageDetail = new List <TempChatMessageDetail>();
                foreach (var currentMessage in CurrentMessage)
                {
                    lstTempChatMessageDetail.Add(new TempChatMessageDetail()
                    {
                        EmailID  = currentMessage.EmailID,
                        Message  = currentMessage.Message,
                        UserName = currentMessage.UserName
                    });
                }


                List <TempChatUserDetail> lstTempChatUserDetail = new List <TempChatUserDetail>();
                foreach (var user in connectedUsers)
                {
                    var tempChatUserDetail = new TempChatUserDetail()
                    {
                        ConnectionId = user.ConnectionId,
                        EmailID      = user.EmailID,
                        UserName     = user.UserName
                    };
                    lstTempChatUserDetail.Add(tempChatUserDetail);
                }
                Clients.Caller.onConnected(id, userName, lstTempChatUserDetail, lstTempChatMessageDetail);//connectedUsers
            }

            // send to all except caller client
            Clients.AllExcept(id).onNewUserConnected(id, userName, email);
        }
Esempio n. 8
0
            internal static int AddNew(Service item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    DB.Services dbItem;
                    using (var items = new XPCollection <DB.Services>(unitOfWork))
                    {
                        dbItem = items.FirstOrDefault(u => u.Name == item.Name && u.User != null && u.User.Id == item.User.Id);
                        if (dbItem != null)
                        {
                            throw new Exception(Resources.Services_AddNew_Такая_услуга_уже_существует_);
                        }

                        dbItem = new DB.Services(unitOfWork)
                        {
                            Name      = item.Name,
                            Price     = item.Price,
                            PriceType = item.PriceType,
                            Status    = item.Status,
                            SiteId    = item.SiteId,
                            CompanyId = item.CompanyId
                        };
                        using (var usrs = new XPCollection <DB.Users>(unitOfWork))
                        {
                            dbItem.User = usrs.FirstOrDefault(q => q.Id == item.User.Id);
                        }
                        items.Add(dbItem);
                    }
                    unitOfWork.CommitChanges();

                    return(dbItem.Id);
                }
            }
Esempio n. 9
0
            internal static int Change(Rent item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var items = new XPCollection <DB.Rents>(unitOfWork))
                    {
                        var dbItem = items.FirstOrDefault(u => u.Id == item.Id);
                        if (dbItem == null)
                        {
                            throw new Exception(Resources.Rents_Read_Стоимость_аренды_не_найдена_);
                        }

                        dbItem.Status = item.Status;
                        dbItem.Price  = item.Price;
                        dbItem.To     = item.To;
                        dbItem.From   = item.From;
                        dbItem.SiteId = item.SiteId;
                        FillDependencies(unitOfWork, dbItem, item);
                    }

                    unitOfWork.CommitChanges();

                    return(item.Id);
                }
            }
Esempio n. 10
0
            internal static int AddNew(Mark item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    DB.Marks dbItem;
                    using (var items = new XPCollection <DB.Marks>(unitOfWork))
                    {
                        dbItem = items.FirstOrDefault(u => u.Name == item.Name);
                        if (dbItem != null)
                        {
                            throw new Exception(Resources.Marks_AddNew_Такая_марка_уже_есть_);
                        }

                        dbItem = new DB.Marks(unitOfWork)
                        {
                            Name   = item.Name,
                            SiteId = item.SiteId
                        };
                        items.Add(dbItem);
                    }
                    unitOfWork.CommitChanges();

                    return(dbItem.Id);
                }
            }
Esempio n. 11
0
            internal static int AddNew(User user)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    DB.Users dbUser;
                    using (var users = new XPCollection <DB.Users>(unitOfWork))
                    {
                        dbUser = users.FirstOrDefault(u => u.Login == user.Login);
                        if (dbUser != null)
                        {
                            throw new Exception(Resources.Users_AddNew_Такой_пользователь_уже_существует_);
                        }

                        dbUser = new DB.Users(unitOfWork)
                        {
                            Login        = user.Login,
                            PasswordHash = user.PasswordHash,
                            SiteId       = user.SiteId
                        };
                        users.Add(dbUser);
                    }
                    unitOfWork.CommitChanges();

                    return(dbUser.Id);
                }
            }
Esempio n. 12
0
        public InventoryLedger GetNewestInventoryLedgerByDate(Session session, Guid _ItemUnitId, Guid _InventoryId, DateTime _IssueDate)
        {
            try
            {
                ItemUnit _ItemUnit = session.GetObjectByKey <ItemUnit>(_ItemUnitId);
                NAS.DAL.Nomenclature.Inventory.Inventory _Inventory = session.GetObjectByKey <NAS.DAL.Nomenclature.Inventory.Inventory>(_InventoryId);

                if (_ItemUnit == null || _Inventory == null)
                {
                    return(null);
                }

                CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                CriteriaOperator criteria_ItemUnit  = new BinaryOperator("ItemUnitId", _ItemUnit, BinaryOperatorType.Equal);
                CriteriaOperator criteria_Inventory = new BinaryOperator("InventoryId", _Inventory, BinaryOperatorType.Equal);
                CriteriaOperator criteria_IssueDate = new BinaryOperator("IssueDate", _IssueDate, BinaryOperatorType.LessOrEqual);

                CriteriaOperator criteria = CriteriaOperator.And(criteria_Inventory, criteria_ItemUnit, criteria_RowStatus);
                XPCollection <InventoryLedger> InventoryLedgerCol = new XPCollection <InventoryLedger>(session, criteria);
                InventoryLedgerCol.Sorting.Add(new SortProperty("IssueDate", SortingDirection.Descending));
                InventoryLedgerCol.Sorting.Add(new SortProperty("CreateDate", SortingDirection.Descending));
                InventoryLedger newestLedger = InventoryLedgerCol.FirstOrDefault();
                return(newestLedger);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 13
0
            internal static int AddNew(Prokat item)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    DB.Prokats dbItem;
                    using (var items = new XPCollection <DB.Prokats>(unitOfWork))
                    {
                        dbItem = new DB.Prokats(unitOfWork)
                        {
                            Name     = item.Name,
                            Address  = item.Address,
                            Phones   = item.Phones,
                            Worktime = item.Worktime
                        };
                        using (var usrs = new XPCollection <DB.Users>(unitOfWork))
                        {
                            dbItem.User = usrs.FirstOrDefault(q => q.Id == item.User.Id);
                        }
                        items.Add(dbItem);
                    }
                    unitOfWork.CommitChanges();

                    return(dbItem.Id);
                }
            }
Esempio n. 14
0
        public static void CreateReportObjects(Session session)
        {
            IEnumerable <Type> creatorTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(
                x => x.GetTypes()).Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(ExcelReportCreator)));
            var reportObjs = new XPCollection <ExcelReport>(session);

            var hash = new HashSet <string>();

            foreach (var creatorType in creatorTypes)
            {
                object[] attributes     = creatorType.GetCustomAttributes(true);
                var      reportNameAttr = (ReportNameAttribute)attributes.FirstOrDefault(x => x.GetType() == typeof(ReportNameAttribute));
                if (reportNameAttr != null)
                {
                    if (hash.Contains(reportNameAttr.Name))
                    {
                        throw new UserFriendlyException(string.Format(
                                                            "Class '{0}' uses duplicate name '{1}'",
                                                            creatorType.Name, reportNameAttr.Name));
                    }
                    hash.Add(reportNameAttr.Name);
                    var reportObj = reportObjs.FirstOrDefault(x => x.ReportName == reportNameAttr.Name);
                    if (reportObj == null)
                    {
                        reportObj = new ExcelReport(session);
                    }
                    reportObj.ReportName = reportNameAttr.Name;
                }
            }
            session.CommitTransaction();
        }
Esempio n. 15
0
 private static DB.CarModels FillDependencies(UnitOfWork unitOfWork, DB.CarModels dbItem, CarModel item)
 {
     using (var items = new XPCollection <DB.Marks>(unitOfWork))
     {
         dbItem.Mark = items.FirstOrDefault(q => q.Id == item.MarkId);
     }
     return(dbItem);
 }
Esempio n. 16
0
 private static DB.Rents FillDependencies(UnitOfWork unitOfWork, DB.Rents dbItem, Rent item)
 {
     using (var items = new XPCollection <DB.Cars>(unitOfWork))
     {
         dbItem.Car = items.FirstOrDefault(q => q.Id == item.CarId);
     }
     return(dbItem);
 }
        public StudyYear GetCurrent()
        {
            var currentStudyYears = new XPCollection <StudyYear>(session,
                                                                 new BinaryOperator("IsCurrent", true),
                                                                 new SortProperty("Number", SortingDirection.Descending))
            {
                TopReturnedObjects = 1
            };

            return(currentStudyYears.FirstOrDefault());
        }
Esempio n. 18
0
        public void SendPrivateMessage(string toUserId, string message, string status)
        {
            string fromUserId      = Context.ConnectionId;
            var    uow             = new XpoDAO().ProvideUnitOfWork();
            var    ChatUserDetails = new XPCollection <ChatUserDetail>(uow);
            var    toUser          = ChatUserDetails.FirstOrDefault(x => x.ConnectionId == toUserId);
            var    fromUser        = ChatUserDetails.FirstOrDefault(x => x.ConnectionId == fromUserId);

            if (toUser != null && fromUser != null)
            {
                if (status == "Click")
                {
                    AddPrivateMessageinCache(fromUser.EmailID, toUser.EmailID, fromUser.UserName, message);
                }

                // send to
                Clients.Client(toUserId).sendPrivateMessage(fromUserId, fromUser.UserName, message, fromUser.EmailID, toUser.EmailID, status, fromUserId);

                // send to caller user
                Clients.Caller.sendPrivateMessage(toUserId, fromUser.UserName, message, fromUser.EmailID, toUser.EmailID, status, fromUserId);
            }
        }
Esempio n. 19
0
            public static void Delete(int id, UnitOfWork unitOfWork)
            {
                using (var items = new XPCollection <DB.Damages>(unitOfWork))
                {
                    var dbItem = items.FirstOrDefault(u => u.Id == id);
                    if (dbItem == null)
                    {
                        throw new Exception(Resources.Damages_Read_Повреждение_не_найдено_);
                    }

                    items.DeleteObjectOnRemove = true;
                    items.Remove(dbItem);
                }
            }
Esempio n. 20
0
        public BusinessObject GetOldestUnprocessedObject(Session session, Guid jobId, List <int> ObjectType)
        {
            BusinessObject oldestObject = null;

            try
            {
                ETLJob etlJob = session.GetObjectByKey <ETLJob>(jobId);
                if (etlJob == null)
                {
                    return(null);
                }

                ETLLogBO etlLogBO = new ETLLogBO();
                XPCollection <ETLBusinessObject> etlBusinessObjectCollection = etlLogBO.GetChangedIssuedDateETLBusinessObject(session, jobId);
                if (etlBusinessObjectCollection != null && etlBusinessObjectCollection.Count() != 0)
                {
                    etlBusinessObjectCollection.Sorting.Add(new SortProperty("BusinessObject.IssuedDateTimeStamp", SortingDirection.Ascending));
                    ETLBusinessObject oldestETLBusinessObject = etlBusinessObjectCollection.FirstOrDefault();
                    etlBusinessObjectCollection = etlLogBO.GetNewerETLBusinessObject(session, jobId, oldestETLBusinessObject.BusinessObjectIssuedDateTimeStamp);
                    foreach (ETLBusinessObject EBO in etlBusinessObjectCollection)
                    {
                        EBO.RowStatus = -2;
                        EBO.Save();
                    }
                    oldestETLBusinessObject.RowStatus = -2;
                    oldestETLBusinessObject.Save();
                }

                CriteriaOperator criteria_0 = new InOperator("ObjectType", ObjectType);
                CriteriaOperator criteria_1 = new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater);
                CriteriaOperator criteria   = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1);
                XPCollection <BusinessObject> businessObjectCollection = new XPCollection <BusinessObject>(session, criteria);
                businessObjectCollection.Sorting.Add(new SortProperty("ObjectIssueDate", SortingDirection.Ascending));
                businessObjectCollection.Sorting.Add(new SortProperty("IssuedDateTimeStamp", SortingDirection.Ascending));
                foreach (BusinessObject bo in businessObjectCollection)
                {
                    if (NeedToBeProcessed(session, bo.BusinessObjectId, jobId))
                    {
                        return(bo);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(oldestObject);
        }
Esempio n. 21
0
 private static DB.Cars FillDependencies(UnitOfWork unitOfWork, DB.Cars dbItem, Car item)
 {
     using (var items = new XPCollection <DB.CarModels>(unitOfWork))
     {
         dbItem.Model = items.FirstOrDefault(q => q.Id == item.Model.Id);
     }
     using (var items = new XPCollection <DB.Users>(unitOfWork))
     {
         dbItem.User = items.FirstOrDefault(q => q.Id == item.User.Id);
     }
     using (var items = new XPCollection <DB.CarRentals>(unitOfWork))
     {
         dbItem.CarRental = items.FirstOrDefault(q => q.Id == item.CarRental.Id);
     }
     return(dbItem);
 }
Esempio n. 22
0
 private static DB.Orders FillDependencies(UnitOfWork unitOfWork, DB.Orders dbItem, Order item)
 {
     using (var items = new XPCollection <DB.Cars>(unitOfWork))
     {
         var car = items.FirstOrDefault(q => q.Id == item.Car.Id);
         dbItem.Car = car;
     }
     using (var items = new XPCollection <DB.Clients>(unitOfWork))
     {
         dbItem.Client = items.FirstOrDefault(q => q.Id == item.Client.Id);
     }
     using (var items = new XPCollection <DB.Users>(unitOfWork))
     {
         dbItem.User = items.FirstOrDefault(q => q.Id == item.User.Id);
     }
     return(dbItem);
 }
Esempio n. 23
0
File: COGSBO.cs Progetto: ewin66/dev
        public COGS GetNextCOGS(Session session, Guid COGSId)
        {
            COGS result = null;

            try
            {
                XPCollection <COGS> NewerCOGSList = GetNewerCOGS(session, COGSId);
                NewerCOGSList.Sorting.Add(new SortProperty("IssuedDate", SortingDirection.Ascending));
                NewerCOGSList.Sorting.Add(new SortProperty("CreateDate", SortingDirection.Ascending));
                result = NewerCOGSList.FirstOrDefault();
            }
            catch (Exception)
            {
                return(result);
            }
            return(result);
        }
Esempio n. 24
0
        public GeneralLedger GetNextGeneralLedger(Session session, Guid GeneralLedgerId)
        {
            GeneralLedger result = null;

            try
            {
                XPCollection <GeneralLedger> NewerGeneralLedgerList = GetNewerGeneralLedger(session, GeneralLedgerId);
                NewerGeneralLedgerList.Sorting.Add(new SortProperty("IssuedDate", SortingDirection.Ascending));
                NewerGeneralLedgerList.Sorting.Add(new SortProperty("CreateDate", SortingDirection.Ascending));
                result = NewerGeneralLedgerList.FirstOrDefault();
            }
            catch (Exception)
            {
                return(result);
            }
            return(result);
        }
Esempio n. 25
0
            public static void Delete(int id)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var users = new XPCollection <DB.Users>(unitOfWork))
                    {
                        var dbUser = users.FirstOrDefault(u => u.Id == id);
                        if (dbUser == null)
                        {
                            throw new Exception(Resources.Users_Read_Пользователь_не_найден_);
                        }

                        users.DeleteObjectOnRemove = true;
                        users.Remove(dbUser);
                    }

                    unitOfWork.CommitChanges();
                }
            }
Esempio n. 26
0
            public static void Delete(int id)
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    using (var items = new XPCollection <DB.Rents>(unitOfWork))
                    {
                        var dbItem = items.FirstOrDefault(u => u.Id == id);
                        if (dbItem == null)
                        {
                            throw new Exception(Resources.Rents_Read_Стоимость_аренды_не_найдена_);
                        }

                        items.DeleteObjectOnRemove = true;
                        items.Remove(dbItem);
                    }

                    unitOfWork.CommitChanges();
                }
            }
Esempio n. 27
0
        public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled)
        {
            var uow    = new XpoDAO().ProvideUnitOfWork();
            var result = new XPCollection <ChatUserDetail>(uow);
            var item   = result.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);

            if (item != null)
            {
                //result.Remove(item);
                uow.Delete(item);
                uow.CommitChanges();

                var id = Context.ConnectionId;
                Clients.All.onUserDisconnected(id, item.EmailID);
                //Clients.All.onUserDisconnected(id, item.UserName);
            }

            return(base.OnDisconnected(stopCalled));
        }
Esempio n. 28
0
        public BusinessObject GetNextBusinessObject(Session session, Int64 businessObjectId, List <int> ObjectType)
        {
            BusinessObject result = null;

            try
            {
                BusinessObject currentBusinessObject = session.GetObjectByKey <BusinessObject>(businessObjectId);
                if (currentBusinessObject == null)
                {
                    return(null);
                }
                DateTime IssueDate = currentBusinessObject.ObjectIssueDate;
                DateTime TimeStamp = currentBusinessObject.IssuedDateTimeStamp;

                CriteriaOperator criteria_ObjectType          = new InOperator("ObjectType", ObjectType);
                CriteriaOperator criteria_RowStatus           = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
                CriteriaOperator criteria_IssueDate_1         = new BinaryOperator("ObjectIssueDate", IssueDate, BinaryOperatorType.Greater);
                CriteriaOperator criteria_IssueDate_2         = new BinaryOperator("ObjectIssueDate", IssueDate, BinaryOperatorType.GreaterOrEqual);
                CriteriaOperator criteria_IssuedDateTimeStamp = new BinaryOperator("IssuedDateTimeStamp", TimeStamp, BinaryOperatorType.Greater);
                CriteriaOperator criteria_DateTime_1          = new GroupOperator(GroupOperatorType.And, criteria_IssueDate_2, criteria_IssuedDateTimeStamp);
                CriteriaOperator criteria_DateTime            = new GroupOperator(GroupOperatorType.Or, criteria_IssueDate_1, criteria_DateTime_1);

                CriteriaOperator criteria_Id = new BinaryOperator("BusinessObjectId", currentBusinessObject.BusinessObjectId, BinaryOperatorType.NotEqual);

                CriteriaOperator criteria = new GroupOperator(GroupOperatorType.And, criteria_ObjectType, criteria_RowStatus, criteria_DateTime, criteria_Id);

                XPCollection <BusinessObject> BusinessObjectCol = new XPCollection <BusinessObject>(session, criteria);
                if (BusinessObjectCol == null || BusinessObjectCol.Count == 0)
                {
                    return(null);
                }
                BusinessObjectCol.Sorting.Add(new SortProperty("ObjectIssueDate", DevExpress.Xpo.DB.SortingDirection.Ascending));
                BusinessObjectCol.Sorting.Add(new SortProperty("IssuedDateTimeStamp", DevExpress.Xpo.DB.SortingDirection.Ascending));
                //BusinessObjectCol.OrderByDescending(r => r.ObjectIssueDate);
                //BusinessObjectCol.OrderByDescending(r => r.IssuedDateTimeStamp);
                result = BusinessObjectCol.FirstOrDefault();
            }
            catch (Exception)
            {
                return(null);
            }
            return(result);
        }
Esempio n. 29
0
        private static void EliminaSchifanoia2018()
        {
            using (Session ses = new Session())
            {
                var dt = new DateTime(2018, 1, 1);

                var allv = new XPCollection <Variante>(ses);
                Console.WriteLine("Caricate {0} varianti", allv.Count);

                var cv = new XPCollection <Vendita>(ses, new BinaryOperator("DataContabile", new DateTime(2018, 1, 1), BinaryOperatorType.GreaterOrEqual));
                foreach (var v in cv)
                {
                    var t1 = v.RigheVenditaVariante.Where(a => a.Variante.Descrizione.Contains("Cumulativo"));
                    if (t1.Count() > 0)
                    {
                        Console.WriteLine("Cumulativo venduto il " + v.DataContabile + " v:" + v.CodiceLeggibile);

                        foreach (var rvv in v.RigheVenditaVariante)
                        {
                            Console.WriteLine(" " + rvv.Variante.Biglietto.Percorso.Descrizione);

                            if (v.DataContabile > dt && rvv.Variante.Biglietto.Percorso.Descrizione.Contains("OLD"))
                            {
                                var nv = allv.FirstOrDefault(a =>
                                                             a.Biglietto.Percorso.Descrizione == "Cumulativo Musei d'Arte Antica e Museo della Cattedrale" &&
                                                             a.TipologiaUno == rvv.Variante.TipologiaUno &&
                                                             a.TipologiaDue == rvv.Variante.TipologiaDue &&
                                                             a.TipologiaTre == rvv.Variante.TipologiaTre
                                                             );

                                if (nv != null)
                                {
                                    Console.WriteLine(" Cambio con " + nv.Biglietto.Percorso.Descrizione);
                                    rvv.Variante = nv;
                                    rvv.Save();
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 30
0
        public ETLBusinessObject GetLastProcessedObject(Session session, Guid jobId)
        {
            ETLBusinessObject etlBusinessObject = null;

            try
            {
                ETLJob           job        = session.GetObjectByKey <ETLJob>(jobId);
                CriteriaOperator criteria_0 = new BinaryOperator("ETLJobId", job, BinaryOperatorType.Equal);
                CriteriaOperator criteria_1 = new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater);
                CriteriaOperator criteria   = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1);
                XPCollection <ETLBusinessObject> etlBusinessObjectCollection = new XPCollection <ETLBusinessObject>(criteria);
                etlBusinessObjectCollection.Sorting.Add(new SortProperty("BusinessObjectIssuedDateTimeStamp", SortingDirection.Descending));
                etlBusinessObject = etlBusinessObjectCollection.FirstOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            return(etlBusinessObject);
        }