Exemplo n.º 1
0
        public static bool NeedReload(this XPObjectSpace objectSpace, object currentObject)
        {
            XPMemberInfo optimisticLockFieldInfo;
            XPClassInfo  classInfo = GetClassInfo(objectSpace, currentObject, out optimisticLockFieldInfo);
            Boolean      isObjectChangedByAnotherUser = false;

            if (!objectSpace.IsDisposedObject(currentObject) && !objectSpace.IsNewObject(currentObject) && (optimisticLockFieldInfo != null))
            {
                Object keyPropertyValue = objectSpace.GetKeyValue(currentObject);
                Object lockFieldValue   = optimisticLockFieldInfo.GetValue(currentObject);

                if (lockFieldValue != null)
                {
                    if (objectSpace.Session.FindObject(currentObject.GetType(), new GroupOperator(
                                                           new BinaryOperator(objectSpace.GetKeyPropertyName(currentObject.GetType()), keyPropertyValue),
                                                           new BinaryOperator(classInfo.OptimisticLockFieldName, lockFieldValue)), true) == null)
                    {
                        isObjectChangedByAnotherUser = true;
                    }
                }
                else
                {
                    if (objectSpace.Session.FindObject(currentObject.GetType(), new GroupOperator(
                                                           new BinaryOperator(objectSpace.GetKeyPropertyName(currentObject.GetType()), keyPropertyValue),
                                                           new NullOperator(classInfo.OptimisticLockFieldName)), true) == null)
                    {
                        isObjectChangedByAnotherUser = true;
                    }
                }
            }
            return(isObjectChangedByAnotherUser);
        }
Exemplo n.º 2
0
        public FixCashFlowsAlgorithm(XPObjectSpace objSpace, CashFlowFixParam paramObj, CashFlowFixMapper mapper)
        {
            this.objSpace = objSpace;
            this.paramObj = paramObj;

            if (paramObj.Snapshot == null)
            {
                currentSnapshot = GetCurrentSnapshot(objSpace.Session);
            }
            else
            {
                currentSnapshot = paramObj.Snapshot;
            }

            if (paramObj.ApReclassActivity != null)
            {
                paramApReclassActivity = objSpace.GetObjectByKey <Activity>(objSpace.GetKeyValue(paramObj.ApReclassActivity));
            }

            defaultCounterparty = objSpace.FindObject <Counterparty>(
                CriteriaOperator.Parse("Name LIKE ?", CashDiscipline.Common.Constants.DefaultFixCounterparty));

            var query = new XPQuery <CashForecastFixTag>(objSpace.Session);

            reversalFixTag = query
                             .Where(x => x.Name == CashDiscipline.Common.Constants.ReversalFixTag).FirstOrDefault();

            revRecFixTag = query
                           .Where(x => x.Name == CashDiscipline.Common.Constants.RevRecFixTag).FirstOrDefault();

            resRevRecFixTag = query
                              .Where(x => x.Name == CashDiscipline.Common.Constants.ResRevRecFixTag).FirstOrDefault();

            payrollFixTag = query
                            .Where(x => x.Name == CashDiscipline.Common.Constants.PayrollFixTag).FirstOrDefault();

            autoFixTag = query
                         .Where(x => x.Name == CashDiscipline.Common.Constants.AutoFixTag).FirstOrDefault();

            setOfBooks  = SetOfBooks.GetInstance(objSpace);
            this.mapper = mapper;

            this.sqlDeclareClauses = CreateSqlDeclareClauses();
            var sqlStringUtil = new SqlStringUtil();

            this.parameterCommandText = sqlStringUtil.CreateCommandText(sqlDeclareClauses);
        }