protected override void OnActivated()
        {
            base.OnActivated();

            subjectAreaCollection = ObjectSpace.CreateObject<XPCollection<SubjectArea>>();
            subjectAreaCollection.Load();

            PopulateSubjectAreaList();
        }
Example #2
0
        protected virtual void FindAndDeletePFRegisterRecords(Guid token)    //(crmDealWithoutStageVersion scVersion) {
        {
            CriteriaOperator criteria = new BinaryOperator("Token", token, BinaryOperatorType.Equal);

            XPCollection <crmPlaneFactRegister> RegColl = new XPCollection <crmPlaneFactRegister>(this.Session, criteria, null);

            if (!RegColl.IsLoaded)
            {
                RegColl.Load();
            }
            RegColl.DeleteObjectOnRemove = true;

            // Удаление старого
            while (RegColl.Count > 0)
            {
                RegColl.Remove(RegColl[0]);
            }
        }
Example #3
0
        /// <summary>
        /// Определение пользователя типа AppUser по его UserName
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static AppUser PopulateUserByUserName(string userID, Session ssn)
        {
            XPCollection <AppUser> appUsers = new XPCollection <AppUser>(ssn);

            if (!appUsers.IsLoaded)
            {
                appUsers.Load();
            }
            var lau = (from appuser in appUsers where appuser.UserName == userID.Trim() select appuser);

            IEnumerator enumlau = lau.GetEnumerator();

            while (enumlau.MoveNext())
            {
                return((AppUser)enumlau.Current);
            }

            return(null);
        }
Example #4
0
        static void Main(string[] args)
        {
            XpoDefault.ConnectionString = MSSqlConnectionProvider.GetConnectionString(".", "sa", "123", "testdb");

            Session
                sessionI = new Session(),
                sessionII;

            UnitOfWork
                unitOfWorkI;

            XPMemberInfo
                memberInfo;

            XPCollection
                xpCollectionI,
                xpCollectionII;

            XPCollection <Staff>
            xpCollectionStaff;

            CriteriaOperator
                criteria;

            TestMaster
                tmpTestMaster,
                tmpTestMasterII;

            TestDetail
                tmpTestDetail,
                tmpTestDetailII;

            TestDE
                tmpTestDE   = null,
                tmpTestDEII = null;

            int
                tmpInt;

            string
                tmpString;

            XPClassInfo
                testMasterClassInfo = sessionI.GetClassInfo <TestMaster>(),
                testDetailClassInfo = sessionI.GetClassInfo <TestDetail>(),
                staffClassInfo      = sessionI.GetClassInfo <Staff>();

            Victim
                tmpVictim;

            #if TEST_PREFETCH_COLLECTION
            if ((tmpTestMaster = sessionI.GetObjectByKey <TestMaster>(2L)) != null)
            {
                foreach (var detail in tmpTestMaster.Details)
                {
                    Debug.WriteLine($"Id: {detail.Id}");
                }
            }

            if ((tmpTestMaster = sessionI.GetObjectByKey <TestMaster>(1L)) != null && (memberInfo = testMasterClassInfo.GetMember(nameof(TestMaster.Details))).MemberType.IsSubclassOf(typeof(XPBaseCollection)))
            {
                if (memberInfo.GetValue(tmpTestMaster) is XPCollection <TestDetail> xpCollectionTestDetails)
                {
                    if (((IXPPrefetchableAssociationList)xpCollectionTestDetails).NeedPrefetch())
                    {
                        criteria = new BinaryOperator(new OperandProperty(nameof(TestDetail.Master)), new OperandValue(tmpTestMaster.Id), BinaryOperatorType.Equal);
                        var details = sessionI.GetObjects(testDetailClassInfo, criteria, null, 0, true, false);
                        ((IXPPrefetchableAssociationList)xpCollectionTestDetails).FinishPrefetch(details);
                        if (!xpCollectionTestDetails.IsLoaded)
                        {
                            xpCollectionTestDetails.Load();
                        }
                    }
                }

                foreach (var detail in tmpTestMaster.Details)
                {
                    Debug.WriteLine($"Id: {detail.Id}");
                }
            }
            #endif

            #if TEST_GENERICS
            xpCollectionI = new XPCollection(sessionI, typeof(Staff));
            //xpCollectionStaff = xpCollectionI as XPCollection<Staff>; // Error CS0039 Cannot convert type 'DevExpress.Xpo.XPCollection' to 'DevExpress.Xpo.XPCollection<TestCollection.Db.Staff>' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion


            Type genericXPCollectionStaff = typeof(XPCollection <>).MakeGenericType(staffClassInfo.ClassType);
            xpCollectionStaff = Activator.CreateInstance(genericXPCollectionStaff, sessionI) as XPCollection <Staff>;
            xpCollectionStaff = new XPCollection <Staff>(sessionI);

            genericXPCollectionStaff = xpCollectionStaff.GetType();
            if (genericXPCollectionStaff.IsGenericType)
            {
                var genericTypeDefinition = genericXPCollectionStaff.GetGenericTypeDefinition();
                if (genericTypeDefinition == typeof(XPCollection <>))
                {
                    Type type = genericXPCollectionStaff.GetGenericArguments()[0];
                    //type = genericXPCollectionStaff.GetProperty("Item").PropertyType;
                    type = genericXPCollectionStaff.GetTypeInfo().GenericTypeArguments[0];
                }

                var xpBaseCollection = (XPBaseCollection)xpCollectionStaff;
            }

            var customCollectionStaff = new CustomCollection <Staff>(sessionI);
            var customCollection      = (XPBaseCollection)customCollectionStaff;

            Type type1       = xpCollectionI.GetType();
            Type elementType = typeof(object);
            Type type2       = typeof(IEnumerable <>).MakeGenericType(elementType);
            Type type3       = typeof(IQueryable <>).MakeGenericType(elementType);
            bool flag        = type2.IsAssignableFrom(type1); // IEnumerable<> false
            flag = type3.IsAssignableFrom(type1);             // IQueryable<> false
            MethodInfo          method1             = (flag ? queryableDistinctInfo : enumerableDistinctInfo).MakeGenericMethod(elementType);
            MethodInfo          method2             = (flag ? queryableOfTypeInfo : enumerableOfTypeInfo).MakeGenericMethod(elementType);
            ParameterExpression parameterExpression = Expression.Parameter(typeof(object), "dataSource");
            UnaryExpression     unaryExpression     = Expression.Convert((Expression)parameterExpression, flag ? type3 : type2);
            var expr = Expression.Lambda <Func <object, object> >((Expression)(true ? Expression.Call(method1, (Expression)unaryExpression) : Expression.Call(method1, (Expression)Expression.Call(method2, (Expression)unaryExpression))), new ParameterExpression[1]
            {
                parameterExpression
            });
            var func = expr.Compile();
            //var result = func(xpCollectionI);

            type1 = xpCollectionStaff.GetType();
            flag  = type2.IsAssignableFrom(type1);    // IEnumerable<> true
            flag  = type3.IsAssignableFrom(type1);    // IQueryable<> false
            var result = func(xpCollectionStaff);
            #endif

            #if TEST_SORTING
            xpCollectionI = new XPCollection(sessionI, typeof(Staff), null, new SortProperty("Dep", SortingDirection.Ascending), new SortProperty("Name", SortingDirection.Ascending));
            foreach (var item in xpCollectionI.OfType <Staff>())
            {
                Debug.WriteLine($"{{Dep:{item.Dep}, Name:\"{item.Name}\"}}");
            }

            xpCollectionII         = new XPCollection(sessionI, typeof(Staff));
            xpCollectionII.Sorting = new SortingCollection {
                new SortProperty("Dep", SortingDirection.Ascending), new SortProperty("Name", SortingDirection.Ascending)
            };
            foreach (var item in xpCollectionII.OfType <Staff>())
            {
                Debug.WriteLine($"{{Dep:{item.Dep}, Name:\"{item.Name}\"}}");
            }
            #endif

            #if TEST_COLLECTION_FROM_COLLECTION
            var baseCollection = new XPCollection <Victim>(sessionI);
            foreach (var item in baseCollection)
            {
                Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
            }

            var falseCollection = new XPCollection(baseCollection, new BinaryOperator(new OperandProperty("FBit"), new OperandValue(false), BinaryOperatorType.Equal));
            foreach (Victim item in falseCollection)
            {
                Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
            }

            var trueCollection = new XPCollection(baseCollection, new BinaryOperator(new OperandProperty("FBit"), new OperandValue(true), BinaryOperatorType.Equal));
            foreach (Victim item in trueCollection)
            {
                Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
            }

            if ((tmpVictim = ((IBindingList)falseCollection).AddNew() as Victim) != null)
            {
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in falseCollection)
                {
                    Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.FBit = false;
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in falseCollection)
                {
                    Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.Save();
                baseCollection.Reload();
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in falseCollection)
                {
                    Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
            }
            if ((tmpVictim = ((IBindingList)falseCollection).AddNew() as Victim) != null)
            {
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in falseCollection)
                {
                    Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.FBit = true;
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in falseCollection)
                {
                    Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.Save();
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in falseCollection)
                {
                    Debug.WriteLine($"falseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
            }

            if ((tmpVictim = ((IBindingList)trueCollection).AddNew() as Victim) != null)
            {
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in trueCollection)
                {
                    Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.FBit = true;
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in trueCollection)
                {
                    Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.Save();
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in trueCollection)
                {
                    Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
            }
            if ((tmpVictim = ((IBindingList)trueCollection).AddNew() as Victim) != null)
            {
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in trueCollection)
                {
                    Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.FBit = false;
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in trueCollection)
                {
                    Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                tmpVictim.Save();
                foreach (var item in baseCollection)
                {
                    Debug.WriteLine($"baseCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
                foreach (Victim item in trueCollection)
                {
                    Debug.WriteLine($"trueCollection id:{item.Id} f_int:{item.FInt} f_bit:{item.FBit}");
                }
            }
            #endif

            #if TEST_LIFECYCLE
            using (unitOfWorkI = new UnitOfWork())
            {
                xpCollectionI = new XPCollection(typeof(TestMaster));
                AddEventsListeners(xpCollectionI);

                if ((tmpTestMaster = ((IBindingList)xpCollectionI).AddNew() as TestMaster) != null)
                {
                    tmpTestMaster.Name = "Name";
                    tmpTestMaster.Save();
                }

                foreach (TestMaster item in xpCollectionI)
                {
                    System.Diagnostics.Debug.WriteLine(item.Id);
                }
                RemoveEventsListeners(xpCollectionI);
            }
            #endif

            #if TEST_ADD
            using (unitOfWorkI = new UnitOfWork())
            {
                xpCollectionI = new XPCollection(unitOfWorkI, typeof(TestDE));

                    #if TEST_LIFECYCLE
                AddEventsListeners(xpCollectionI);
                    #endif

                if ((tmpTestDE = ((IBindingList)xpCollectionI).AddNew() as TestDE) != null)
                {
                    tmpTestDE.f1 = 1;
                }

                    #if TEST_LIFECYCLE
                RemoveEventsListeners(xpCollectionI);
                    #endif

                tmpTestMaster = new TestMaster(unitOfWorkI);
                    #if TEST_LIFECYCLE
                AddEventsListeners(tmpTestMaster);
                AddEventsListeners(tmpTestMaster.Details);
                    #endif

                if ((tmpTestDetail = ((IBindingList)tmpTestMaster.Details).AddNew() as TestDetail) != null)
                {
                    tmpTestDetail.Name = "blah-blah-blah";
                }

                    #if TEST_LIFECYCLE
                RemoveEventsListeners(tmpTestMaster.Details);
                RemoveEventsListeners(tmpTestMaster);
                    #endif
            }
            #endif

            #if TEST_MODIFY
            using (unitOfWorkI = new UnitOfWork())
            {
                xpCollectionI  = new XPCollection(unitOfWorkI, typeof(TestDE));
                xpCollectionII = new XPCollection(unitOfWorkI, typeof(TestDE));

                criteria = new BinaryOperator(new OperandProperty("id"), new OperandValue(1L), BinaryOperatorType.Equal);

                xpCollectionI.Filter  = criteria;
                xpCollectionII.Filter = criteria;

                if (xpCollectionI.Count != 0)
                {
                    tmpTestDE = xpCollectionI[0] as TestDE;
                }
                if (xpCollectionII.Count != 0)
                {
                    tmpTestDEII = xpCollectionI[0] as TestDE;
                }

                if (tmpTestDE != null)
                {
                    tmpTestDE.f1 = tmpTestDE.f1.HasValue ? tmpTestDE.f1.Value + 1 : 1;
                    tmpTestDE.Save();
                }

                if (tmpTestDEII != null)
                {
                    tmpTestDEII.f1 = tmpTestDEII.f1.HasValue ? tmpTestDEII.f1.Value + 1 : 1;
                    tmpTestDEII.Save();
                }

                unitOfWorkI.CommitChanges();
            }
            #endif

            #if TEST_LOAD
            xpCollectionI = new XPCollection(sessionI, testMasterClassInfo);
            xpCollectionI.Load();
            xpCollectionI.Reload();

            var listOfTestMaster = sessionI.GetObjects(testMasterClassInfo, new BinaryOperator("Name", "TEST An item with the same key has already been added 1:1", BinaryOperatorType.Equal), null, 0, 0, true, true).OfType <TestMaster>().ToList();

            if (listOfTestMaster.Count > 0)
            {
                tmpTestMaster = listOfTestMaster[0];

                if (tmpTestMaster.Details.Count > 0)
                {
                    tmpString = tmpTestMaster.Details[0].Val;
                }
            }
            #endif

            #if TEST_An_item_with_the_same_key_has_already_been_added
            var listOfTestMaster = sessionI.GetObjects(testMasterClassInfo, new BinaryOperator("Name", "TEST An item with the same key has already been added 1:N", BinaryOperatorType.Equal), null, 0, 0, true, true).OfType <TestMaster>().ToList();

            if (listOfTestMaster.Count > 0)
            {
                tmpTestMaster = listOfTestMaster[0];
                tmpString     = tmpTestMaster.DetailVal;
            }
            #endif

            #if TEST_CREATE
            if ((tmpTestMaster = testMasterClassInfo.CreateNewObject(sessionI) as TestMaster) != null)
            {
                tmpTestMaster.Name = DateTime.Now.Ticks.ToString();

                tmpTestMaster.Details.AddRange(new[]
                {
                    testDetailClassInfo.CreateNewObject(sessionI) as TestDetail,
                    testDetailClassInfo.CreateNewObject(sessionI) as TestDetail,
                    testDetailClassInfo.CreateNewObject(sessionI) as TestDetail
                });

                tmpTestMaster.Details.ToList().ForEach(item => item.Name = DateTime.Now.Ticks.ToString());

                sessionI.Save(tmpTestMaster);
            }
            #endif

            #if TEST_SET
            tmpTestMaster = sessionI.GetObjectByKey <TestMaster>(1L);
            tmpInt        = tmpTestMaster.Details.Count;

            sessionII              = new Session();
            tmpTestMasterII        = sessionII.GetObjectByKey <TestMaster>(2L);
            tmpTestDetailII        = sessionII.GetObjectByKey <TestDetail>(2L);
            tmpTestDetailII.Master = tmpTestMasterII;
            sessionII.Save(tmpTestDetailII);

            tmpInt = tmpTestMaster.Details.Count;
            #endif

            #if TEST_REMOVE
            tmpTestMaster = sessionI.GetObjectByKey <TestMaster>(1L);
            tmpInt        = tmpTestMaster.Details.Count;

            sessionII       = new Session();
            tmpTestMasterII = sessionII.GetObjectByKey <TestMaster>(1L);
            tmpTestDetailII = sessionII.GetObjectByKey <TestDetail>(2L);
            tmpTestMasterII.Details.Remove(tmpTestDetailII);
            sessionII.Save(new XPCustomObject[] { tmpTestMasterII, tmpTestDetailII });

            tmpInt = tmpTestMaster.Details.Count;
            #endif
        }
Example #5
0
 private TargetPerson[] LoadPersonOfInterests()
 {
     using (var session = new Session())
     {
         var xpc = new XPCollection<TargetPerson>();
         xpc.Load();
         return xpc.ToArray();
     }
 }
Example #6
0
        private void FindAndDeleteDCDRegisterRecords(crmDealLongServiceVersion scVersion)
        {
            // Находим в регистрах crmDebtorCreditorDebtRegister и crmCashFlowRegister запись с теми же параметрами, что и scVersion, и удаляем её

            //Сторона основная
            //Тема
            //Заказ
            //Сторона контрагент
            //Договор
            //Простой договор
            //Финансовая сделка
            //Статья затрат (ДДС)
            //План/Факт

            CriteriaOperator criteria = null;

            criteria = new GroupOperator();
            ((GroupOperator)criteria).OperatorType = GroupOperatorType.And;

            //CriteriaOperator criteriaDocNumberYear = new BinaryOperator("DocNumberYear", DocNumberYear, BinaryOperatorType.Equal);
            //((GroupOperator)criteria).Operands.Add(criteriaDocNumberYear);

            //CriteriaOperator criteriaDocNumberDepartment = null;
            //if (!string.IsNullOrEmpty(DocNumberDepartment)) {
            //    criteriaDocNumberDepartment = new BinaryOperator("DocNumberDepartment", DocNumberDepartment, BinaryOperatorType.Equal);
            //    ((GroupOperator)criteria).Operands.Add(criteriaDocNumberDepartment);
            //}


            OperandProperty  propPrimaryParty = new OperandProperty("PrimaryParty");
            CriteriaOperator opPrimaryParty   = propPrimaryParty == scVersion.Customer;

            ((GroupOperator)criteria).Operands.Add(opPrimaryParty);

            OperandProperty  propContragentParty = new OperandProperty("ContragentParty");
            CriteriaOperator opContragentParty   = propContragentParty == scVersion.Supplier;

            ((GroupOperator)criteria).Operands.Add(opContragentParty);

            OperandProperty  propOrder = new OperandProperty("fmOrder");
            CriteriaOperator opOrder   = propOrder == scVersion.Order;

            ((GroupOperator)criteria).Operands.Add(opOrder);

            OperandProperty  propContract = new OperandProperty("Contract");
            CriteriaOperator opContract   = propContract == scVersion.ContractDeal.Contract;

            ((GroupOperator)criteria).Operands.Add(opContract);

            OperandProperty  propContracDeal = new OperandProperty("ContracDeal");
            CriteriaOperator opContracDeal   = propContracDeal == scVersion.ContractDeal;

            ((GroupOperator)criteria).Operands.Add(opContracDeal);

            //OperandProperty propFinancialDeal = new OperandProperty("FinancialDeal");
            //CriteriaOperator opFinancialDeal = propFinancialDeal == scVersion.FinancialDeal.FinancialDeal;
            //((GroupOperator)criteria).Operands.Add(opFinancialDeal);

            OperandProperty  propCostItem = new OperandProperty("CostItem");
            CriteriaOperator opCostItem   = propCostItem == scVersion.CostItem;

            ((GroupOperator)criteria).Operands.Add(opCostItem);

            //OperandProperty propNomenclature = new OperandProperty("Nomenclature");
            //CriteriaOperator opNomenclature = propNomenclature == this.Current.ContractDeal.Nomenclature;

            OperandProperty  propPlaneFact = new OperandProperty("PlaneFact");
            CriteriaOperator opPlaneFact   = propPlaneFact == 1; // PlaneFact.PLAN;

            ((GroupOperator)criteria).Operands.Add(opPlaneFact);

            OperandProperty  propValuta = new OperandProperty("Valuta");
            CriteriaOperator opValuta   = propValuta == scVersion.Valuta;

            ((GroupOperator)criteria).Operands.Add(opValuta);

            XPCollection <crmDebtorCreditorDebtRegister> dcdRegColl = new XPCollection <crmDebtorCreditorDebtRegister>(this.Session, criteria, null);

            if (!dcdRegColl.IsLoaded)
            {
                dcdRegColl.Load();
            }
            dcdRegColl.DeleteObjectOnRemove = true;

            // Удаление старого
            while (dcdRegColl.Count > 0)
            {
                dcdRegColl.Remove(dcdRegColl[0]);
            }


            XPCollection <crmCashFlowRegister> cfRegColl = new XPCollection <crmCashFlowRegister>(this.Session, criteria, null);

            if (!cfRegColl.IsLoaded)
            {
                cfRegColl.Load();
            }
            cfRegColl.DeleteObjectOnRemove = true;

            // Удаление старого
            while (cfRegColl.Count > 0)
            {
                cfRegColl.Remove(cfRegColl[0]);
            }
        }
Example #7
0
        private void FindAndDeletePFRegisterRecords(crmDealLongServiceVersion scVersion)
        {
            // Находим в регистре crmPlaneFactRegister запись с теми же параметрами, что и scVersion, и удаляем её

            //Сторона Кредитор Creditor
            //Сторона Дебитор  Debitor
            //Тема
            //Заказ   fmOrder
            //Договор  Contract
            //Простой договор (Ведомость) ContracDeal
            //Этап
            //Финансовая сделка   FinancialDeal
            //Статья затрат (ДДС)   CostItem
            //Номенклатура обязательств   Nomenclature
            //План/Факт   PlaneFact = PLANE

            CriteriaOperator criteria = null;

            criteria = new GroupOperator();
            ((GroupOperator)criteria).OperatorType = GroupOperatorType.And;

            //CriteriaOperator criteriaDocNumberYear = new BinaryOperator("DocNumberYear", DocNumberYear, BinaryOperatorType.Equal);
            //((GroupOperator)criteria).Operands.Add(criteriaDocNumberYear);

            //CriteriaOperator criteriaDocNumberDepartment = null;
            //if (!string.IsNullOrEmpty(DocNumberDepartment)) {
            //    criteriaDocNumberDepartment = new BinaryOperator("DocNumberDepartment", DocNumberDepartment, BinaryOperatorType.Equal);
            //    ((GroupOperator)criteria).Operands.Add(criteriaDocNumberDepartment);
            //}


            OperandProperty  propCreditor = new OperandProperty("Creditor");
            CriteriaOperator opCreditor   = propCreditor == scVersion.Customer;

            ((GroupOperator)criteria).Operands.Add(opCreditor);

            OperandProperty  propDebitor = new OperandProperty("Debitor");
            CriteriaOperator opDebitor   = propDebitor == scVersion.Supplier;

            ((GroupOperator)criteria).Operands.Add(opDebitor);

            OperandProperty  propOrder = new OperandProperty("fmOrder");
            CriteriaOperator opOrder   = propOrder == scVersion.Order;

            ((GroupOperator)criteria).Operands.Add(opOrder);

            OperandProperty  propContract = new OperandProperty("Contract");
            CriteriaOperator opContract   = propContract == scVersion.ContractDeal.Contract;

            ((GroupOperator)criteria).Operands.Add(opContract);

            OperandProperty  propContracDeal = new OperandProperty("ContracDeal");
            CriteriaOperator opContracDeal   = propContracDeal == scVersion.ContractDeal;

            ((GroupOperator)criteria).Operands.Add(opContracDeal);

            OperandProperty  propCostItem = new OperandProperty("CostItem");
            CriteriaOperator opCostItem   = propCostItem == scVersion.CostItem;

            ((GroupOperator)criteria).Operands.Add(opCostItem);

            //OperandProperty propNomenclature = new OperandProperty("Nomenclature");
            //CriteriaOperator opNomenclature = propNomenclature == this.Current.ContractDeal.Nomenclature;

            OperandProperty  propPlaneFact = new OperandProperty("PlaneFact");
            CriteriaOperator opPlaneFact   = propPlaneFact == 1; // PlaneFact.PLAN;

            ((GroupOperator)criteria).Operands.Add(opPlaneFact);

            OperandProperty  propValuta = new OperandProperty("Valuta");
            CriteriaOperator opValuta   = propValuta == scVersion.Valuta;

            ((GroupOperator)criteria).Operands.Add(opValuta);

            XPCollection <crmPlaneFactRegister> RegColl = new XPCollection <crmPlaneFactRegister>(this.Session, criteria, null);

            if (!RegColl.IsLoaded)
            {
                RegColl.Load();
            }
            RegColl.DeleteObjectOnRemove = true;

            // Удаление старого
            while (RegColl.Count > 0)
            {
                RegColl.Remove(RegColl[0]);
            }
        }
        private void DoSearch()
        {
            var videos =
            new FileSystemStorage(
                Properties.Settings.Default.OutputPath).
                VideoFilesBetween(_selectedCamera.Id,
                                  _currentRange.From, _currentRange.To).ToList();

            var watch = System.Diagnostics.Stopwatch.StartNew();
            var range = new DateTimeRange(_currentRange.From, _currentRange.To.AddMinutes(1));

            watch.Stop();
            System.Diagnostics.Debug.WriteLine("frames search took " + watch.Elapsed);

            watch.Start();

            _portraits = new XPCollection<Portrait>();
            var cretia = CriteriaOperator.Parse("CaptureTime >= ? and CaptureTime < ?",
                                                            range.From, range.To);
            _portraits.Criteria = cretia;
            _portraits.Load();

            var gq = from  item in _portraits
                     group item by item.CaptureTime.Date.AddHours(item.CaptureTime.Hour).AddMinutes(item.CaptureTime.Minute) into g
                     orderby g.Key ascending
                     select g;

            watch.Stop();
            System.Diagnostics.Debug.WriteLine("portraits search took " + watch.Elapsed);

            this._screen.ClearAll();

            foreach (var v in videos)
            {
                if (v.CapturedAt.Ticks < _currentRange.From.Ticks || v.CapturedAt.Ticks > _currentRange.To.Ticks)
                {
                    continue;
                }

                v.HasFaceCaptured = gq.Where(g => g.Key == v.CapturedAt).Count() != 0;

                if ((_scope & SearchScope.FaceCapturedVideo)
                    == SearchScope.FaceCapturedVideo)
                {
                    if (v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((_scope & SearchScope.MotionWithoutFaceVideo)
                    == SearchScope.MotionWithoutFaceVideo)
                {
                    if (v.HasMotionDetected && !v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((_scope & SearchScope.MotionLessVideo)
                    == SearchScope.MotionLessVideo)
                {
                    if (!v.HasFaceCaptured &&
                        !v.HasMotionDetected)
                    {
                        _screen.AddVideo(v);
                    }
                }

            }
        }
        private void UpdateFaceStatus()
        {
            if (_videos.Count > 0)
            {
                var min = _videos.Min(v => v.CapturedAt);
                var max = _videos.Max(v => v.CapturedAt);

                _portraits = new XPCollection<Portrait>();
                var cretia = CriteriaOperator.Parse("CaptureTime >= ? and CaptureTime < ?",
                                                    min, max);
                _portraits.Criteria = cretia;
                _portraits.Load();

                var gq = from Portrait item in _portraits
                         group item by item.CaptureTime.Date.AddHours(item.CaptureTime.Hour).AddMinutes(item.CaptureTime.Minute)
                             into g
                             orderby g.Key ascending
                             select g;

                foreach (var v in _videos)
                {
                    var video = v;
                    _cts.Token.ThrowIfCancellationRequested();
                    var hasFace = gq.Where(g => g.Key == video.CapturedAt).Count() != 0;
                    Action ac = () => video.HasFaceCaptured = hasFace;
                    this.BeginInvoke(ac);
                }
            }
        }
Example #10
0
        private void DoSearch()
        {
            var videos =
                new FileSystemStorage(
                    Properties.Settings.Default.OutputPath).
                VideoFilesBetween(_selectedCamera.Id,
                                  _currentRange.From, _currentRange.To).ToList();

            var watch = System.Diagnostics.Stopwatch.StartNew();
            var range = new DateTimeRange(_currentRange.From, _currentRange.To.AddMinutes(1));

            watch.Stop();
            System.Diagnostics.Debug.WriteLine("frames search took " + watch.Elapsed);

            watch.Start();

            _portraits = new XPCollection <Portrait>();
            var cretia = CriteriaOperator.Parse("CaptureTime >= ? and CaptureTime < ?",
                                                range.From, range.To);

            _portraits.Criteria = cretia;
            _portraits.Load();

            var gq = from item in _portraits
                     group item by item.CaptureTime.Date.AddHours(item.CaptureTime.Hour).AddMinutes(item.CaptureTime.Minute) into g
                     orderby g.Key ascending
                     select g;

            watch.Stop();
            System.Diagnostics.Debug.WriteLine("portraits search took " + watch.Elapsed);

            this._screen.ClearAll();

            foreach (var v in videos)
            {
                if (v.CapturedAt.Ticks < _currentRange.From.Ticks || v.CapturedAt.Ticks > _currentRange.To.Ticks)
                {
                    continue;
                }

                v.HasFaceCaptured = gq.Where(g => g.Key == v.CapturedAt).Count() != 0;

                if ((_scope & SearchScope.FaceCapturedVideo)
                    == SearchScope.FaceCapturedVideo)
                {
                    if (v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((_scope & SearchScope.MotionWithoutFaceVideo)
                    == SearchScope.MotionWithoutFaceVideo)
                {
                    if (v.HasMotionDetected && !v.HasFaceCaptured)
                    {
                        _screen.AddVideo(v);
                    }
                }

                if ((_scope & SearchScope.MotionLessVideo)
                    == SearchScope.MotionLessVideo)
                {
                    if (!v.HasFaceCaptured &&
                        !v.HasMotionDetected)
                    {
                        _screen.AddVideo(v);
                    }
                }
            }
        }
Example #11
0
        public override List <BaseReportHelper> CreateReportListSource(Session ssn, CriteriaOperator criteria)
        {
            XPClassInfo classInfo = ssn.GetClassInfo(this.GetType());

            XPCollection <crmDebtorCreditorDebtRegister> dbRegister = new XPCollection <crmDebtorCreditorDebtRegister>(ssn, criteria, null);

            dbRegister.Criteria = criteria;
            dbRegister.Reload();
            if (!dbRegister.IsLoaded)
            {
                dbRegister.Load();
            }

            // Linq по коллекции
            var registerGroups = from registerRow in dbRegister
                                 group registerRow by
                                 new {
                registerRow.PrimaryParty,
                registerRow.ContragentParty,
                registerRow.Contract,
                registerRow.ContractDeal,
                registerRow.ObligationUnit,
                registerRow.Stage
            }
            into registerGroup
                select new {
                RegGroup = registerGroup,

                PrimaryPartyOid     = registerGroup.Key.PrimaryParty.Oid,
                PrimaryPartyName    = registerGroup.Key.PrimaryParty.Person.NameFull,
                ContragentPartyOid  = registerGroup.Key.ContragentParty.Oid,
                ContragentPartyName = registerGroup.Key.ContragentParty.Person.NameFull,
                ContractOid         = registerGroup.Key.Contract.Oid,
                //!!!Паша нужно подставит ьправильное значение
                //ContractName = registerGroup.Key.Contract.Delo,
                ContractName     = " ",
                ContractDealOid  = registerGroup.Key.ContractDeal.Oid,
                ContractDealName = registerGroup.Key.ContractDeal.Name,
                StageOid         = registerGroup.Key.Stage.Oid,
                StageName        = registerGroup.Key.Stage.Code,

                ValutaName = registerGroup.Key.ObligationUnit.Valuta.Code,

                ObligationUnitOid      = registerGroup.Key.ObligationUnit.Oid,
                ObligationUnitDateTime = registerGroup.Key.ObligationUnit.DatePlane,                          // Уточнить!
                ObligationUnitCode     = registerGroup.Key.ObligationUnit.Code,


                DeliveryCostPlan =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.PLAN
                     & (regRow.ObligationUnit as crmDeliveryUnit) != null
                     select regRow.CreditCostInRUR).Sum()
                ,
                PaymentCostPlan =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.PLAN
                     & (regRow.ObligationUnit as crmPaymentUnit) != null
                     select regRow.CreditCostInRUR).Sum()
                ,
                DeliveryCostFact =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.FACT
                     & (regRow.ObligationUnit as crmDeliveryUnit) != null
                     select regRow.DebitCostInRUR).Sum()
                ,
                PaymentCostFact =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.FACT
                     & (regRow.ObligationUnit as crmPaymentUnit) != null
                     select regRow.DebitCostInRUR).Sum()
                ,



                DeliveryCostCumulativePlan =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     //& regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.PLAN
                     & (regRow.ObligationUnit as crmDeliveryUnit) != null
                     & regRow.ObligationUnitDateTime <= registerGroup.Key.ObligationUnit.DatePlane
                     select regRow.CreditCostInRUR).Sum()
                ,
                PaymentCostCumulativePlan =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     //& regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.PLAN
                     & (regRow.ObligationUnit as crmPaymentUnit) != null
                     & regRow.ObligationUnitDateTime <= registerGroup.Key.ObligationUnit.DatePlane
                     select regRow.CreditCostInRUR).Sum()
                ,
                DeliveryCostCumulativeFact =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     //& regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.FACT
                     & (regRow.ObligationUnit as crmDeliveryUnit) != null
                     & regRow.ObligationUnitDateTime <= registerGroup.Key.ObligationUnit.DatePlane
                     select regRow.DebitCostInRUR).Sum()
                ,
                PaymentCostCumulativeFact =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     //& regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit == registerGroup.Key.ObligationUnit
                     & regRow.PlaneFact == PlaneFact.FACT
                     & (regRow.ObligationUnit as crmPaymentUnit) != null
                     & regRow.ObligationUnitDateTime <= registerGroup.Key.ObligationUnit.DatePlane
                     select regRow.DebitCostInRUR).Sum()
            };

            //XPCollection xpColSpravka0103 = new XPCollection(ssn, typeof(Spravka0103));
            List <BaseReportHelper> xpColSpravka0103 = new List <BaseReportHelper>();


            // Для каждой группы формируем запись
            foreach (var grp in registerGroups)
            {
                foreach (var item in grp.RegGroup)
                {
                    Spravka0103 sprObj = new Spravka0103(ssn);

                    //sprObj.Oid = item.Oid;

                    sprObj.PrimaryPartyOid    = grp.PrimaryPartyOid;
                    sprObj.ContragentPartyOid = grp.ContragentPartyOid;
                    sprObj.ContractOid        = grp.ContractOid;
                    sprObj.ContractDealOid    = grp.ContractDealOid;
                    sprObj.ObligationUnitOid  = grp.ObligationUnitOid;
                    sprObj.StageOid           = grp.StageOid;

                    sprObj.ObligationUnitDateTime = grp.ObligationUnitDateTime;
                    sprObj.ObligationUnitCode     = grp.ObligationUnitCode;

                    sprObj.PrimaryPartyName    = grp.PrimaryPartyName;    //item.PrimaryParty.PartyName;
                    sprObj.ContragentPartyName = grp.ContragentPartyName; //item.ContragentParty.PartyName;
                    sprObj.ContractName        = grp.ContractName;
                    sprObj.ContractDealName    = grp.ContractDealName;    // item.ContractDeal.ContractDocument.FullName;
                    sprObj.StageName           = grp.StageName;

                    sprObj.ValutaName = grp.ValutaName;

                    // Вычислить 4-е величины
                    sprObj.DeliveryCostPlan = grp.DeliveryCostPlan;
                    sprObj.PaymentCostPlan  = grp.PaymentCostPlan;
                    sprObj.DeliveryCostFact = grp.DeliveryCostFact;
                    sprObj.PaymentCostFact  = grp.PaymentCostFact;

                    // Вычислить 4-е накопительные величины
                    sprObj.DeliveryCostCumulativePlan = grp.DeliveryCostCumulativePlan;
                    sprObj.PaymentCostCumulativePlan  = grp.PaymentCostCumulativePlan;
                    sprObj.DeliveryCostCumulativeFact = grp.DeliveryCostCumulativeFact;
                    sprObj.PaymentCostCumulativeFact  = grp.PaymentCostCumulativeFact;


                    //sprObj.DeliveryCostPlanFact = Convert.ToDecimal(sprObj.DeliveryCostPlan) - Convert.ToDecimal(sprObj.DeliveryCostFact);
                    //sprObj.PaymentCostPlanFact = Convert.ToDecimal(sprObj.PaymentCostPlan) - Convert.ToDecimal(sprObj.PaymentCostFact);
                    //sprObj.ResultPlanFact = Convert.ToDecimal(sprObj.DeliveryCostPlanFact) - Convert.ToDecimal(sprObj.PaymentCostPlanFact);

                    //obj["PrimaryPartyOid"] = grp.PrimaryPartyOid;
                    //obj["ContragentPartyOid"] = grp.ContragentPartyOid;
                    //obj["ContractOid"] = grp.ContractOid;
                    //obj["ContractDealOid"] = grp.ContractDealOid;
                    //obj["ObligationUnitOid"] = grp.ObligationUnitOid;
                    //obj["StageOid"] = grp.StageOid;

                    //obj["ObligationUnitDateTime"] = grp.ObligationUnitDateTime;
                    //obj["ObligationUnitCode"] = grp.ObligationUnitCode;

                    //obj["PrimaryPartyName"] = grp.PrimaryPartyName;    //item.PrimaryParty.PartyName;
                    //obj["ContragentPartyName"] = grp.ContragentPartyName;    //item.ContragentParty.PartyName;
                    //obj["ContractName"] = grp.ContractName;
                    //obj["ContractDealName"] = grp.ContractDealName;   // item.ContractDeal.ContractDocument.FullName;
                    //obj["StageName"] = grp.StageName;

                    //obj["ValutaName"] = grp.ValutaName;

                    //// Вычислить 4-е величины
                    //obj["DeliveryCostPlan"] = grp.DeliveryCostPlan;
                    //obj["PaymentCostPlan"] = grp.PaymentCostPlan;
                    //obj["DeliveryCostFact"] = grp.DeliveryCostFact;
                    //obj["PaymentCostFact"] = grp.PaymentCostFact;

                    //// Вычислить 4-е накопительные величины
                    //obj["DeliveryCostCumulativePlan"] = grp.DeliveryCostCumulativePlan;
                    //obj["PaymentCostCumulativePlan"] = grp.PaymentCostCumulativePlan;
                    //obj["DeliveryCostCumulativeFact"] = grp.DeliveryCostCumulativeFact;
                    //obj["PaymentCostCumulativeFact"] = grp.PaymentCostCumulativeFact;

                    xpColSpravka0103.Add(sprObj);
                }
            }

            return(xpColSpravka0103);
        }
Example #12
0
 private PortraitCapturer.DAL.DTO.TargetPerson[] LoadPersonOfInterests()
 {
     using (var session = new Session())
     {
         var xpc = new XPCollection<PortraitCapturer.DAL.DTO.TargetPerson>();
         xpc.Load();
         return xpc.ToArray();
     }
 }
Example #13
0
        // Формирование коллекции для отчёта
        public static XPCollection <crmGroupByStageAndObligationReportHelper> CreateReportDataSource(Session ssn, crmPartyRu prmContragentParty)
        {
            XPCollection <crmGroupByStageAndObligationReportHelper> Res = new XPCollection <crmGroupByStageAndObligationReportHelper>(ssn);

            CriteriaOperator op = null;

            if (prmContragentParty != null)
            {
                OperandProperty prop = new OperandProperty("PrimaryParty");
                op = prop == prmContragentParty;
            }

            XPCollection <crmDebtorCreditorDebtRegister> dbRegister = new XPCollection <crmDebtorCreditorDebtRegister>(ssn, op, null);

            dbRegister.Criteria = op;
            dbRegister.Reload();
            if (!dbRegister.IsLoaded)
            {
                dbRegister.Load();
            }

            // Справка устроена таким образом. На каждое обязательство имеется совокупность троек (дата, план, факт). В каждой
            // такой тройке дата всегда заполнена, а из план или факт заполнен только один из них
            // Это означает, что идёт цикл по всем обязательствам и для каждого из них формируются записи с указанными тройками внутри

            IList <Guid> obligationGuidList = new List <Guid>();

            foreach (crmDebtorCreditorDebtRegister item in dbRegister)
            {
                if (item.ObligationUnit != null && !obligationGuidList.Contains(item.ObligationUnit.Oid))
                {
                    obligationGuidList.Add(item.ObligationUnit.Oid);
                }
            }

            // Из-за малого объёма коллекции dbRegister оптимизация не нужна

            foreach (Guid obligationGuid in obligationGuidList)
            {
                foreach (crmDebtorCreditorDebtRegister item in dbRegister)
                {
                    if (item.ObligationUnit.Oid == obligationGuid)
                    {
                        crmGroupByStageAndObligationReportHelper obj = new crmGroupByStageAndObligationReportHelper(ssn);

                        obj.ObligationUnitOid      = item.ObligationUnit.Oid;
                        obj.ObligationUnitDateTime = item.ObligationUnitDateTime;
                        obj.ObligationUnitCode     = item.ObligationUnit.Code;
                        obj.PrimaryPartyName       = item.PrimaryParty.PartyName;
                        obj.ContragentPartyName    = item.ContragentParty.PartyName;
                        obj.ContractName           = item.Contract.Delo;
                        obj.ContractDealName       = item.ContractDeal.Name; // item.ContractDeal.ContractDocument.FullName;
                        obj.StageOid  = item.Stage.Oid;
                        obj.StageName = item.Stage.Code;

                        if (item.PlaneFact == PlaneFact.PLAN)
                        {
                            obj.DebetPlan             = item.DebitCost;
                            obj.DebetInRURPlan        = item.DebitCostInRUR;
                            obj.CreditPlan            = item.CreditCost;
                            obj.CreditInRURPlan       = item.CreditCostInRUR;
                            obj.DebitCreditValutaName = item.CreditValuta.Code;

                            obj.DebetFact       = 0;
                            obj.CreditFact      = 0;
                            obj.DebetInRURFact  = 0;
                            obj.CreditInRURFact = 0;
                        }
                        else if (item.PlaneFact == PlaneFact.FACT)
                        {
                            obj.DebetFact             = item.DebitCost;
                            obj.CreditFact            = item.CreditCost;
                            obj.DebetInRURFact        = item.DebitCostInRUR;
                            obj.CreditInRURFact       = item.CreditCostInRUR;
                            obj.DebitCreditValutaName = item.CreditValuta.Code;

                            obj.DebetPlan       = 0;
                            obj.CreditPlan      = 0;
                            obj.DebetInRURPlan  = 0;
                            obj.CreditInRURPlan = 0;
                        }

                        Res.Add(obj);
                    }
                }
            }


            /*
             * foreach (crmDebtorCreditorDebtRegister item in dbRegister) {
             *
             *  // Здесь надо вести поиски. Нельзя брать только План или только Факт, т.к. они могут не быть попарными
             *  // Если в текущей записи План, то ищем соответствующий Факт и наоборот
             *  // Поиск ведётся в пределах той же коллекции dbRegister. Ключом для поиска является
             *  // совокупность полей: item.Stage.Oid, item.ObligationUnit
             *
             *  if (item.PlaneFact == PlaneFact.PLAN) {
             *
             *      crmGroupByStageAndObligationReportHelper obj = new crmGroupByStageAndObligationReportHelper(ssn);
             *
             *      obj.ObligationUnitOid = item.ObligationUnit.Oid;
             *      obj.ObligationUnitDateTime = item.ObligationUnitDateTime;
             *      obj.ObligationUnitCode = item.ObligationUnit.Code;
             *      obj.PrimaryPartyName = item.PrimaryParty.PartyName;
             *      obj.ContragentPartyName = item.ContragentParty.PartyName;
             *      obj.ContractName = item.Contract.Delo;
             *      obj.ContractDealName = item.ContractDeal.ContractDocument.FullName;
             *      obj.StageOid = item.Stage.Oid;
             *      obj.StageName = item.Stage.Code;
             *
             *      obj.DebetPlan = item.DebitCost;
             *      obj.DebetInRURPlan = item.DebitCostInRUR;
             *      obj.CreditPlan = item.CreditCost;
             *      obj.CreditInRURPlan = item.CreditCostInRUR;
             *      obj.DebitCreditValutaName = item.CreditValuta.Code;
             *
             *      // Обойдёмся без LINQ
             *      foreach (crmDebtorCreditorDebtRegister itemDual in dbRegister) {
             *          if (itemDual.PlaneFact == PlaneFact.FACT
             *              && item.ObligationUnit.Oid == itemDual.ObligationUnit.Oid
             *              && item.Stage.Oid == itemDual.Stage.Oid) {
             *
             *              obj.DebetFact = itemDual.DebitCost;
             *              obj.CreditFact = itemDual.CreditCost;
             *              obj.DebetInRURFact = itemDual.DebitCostInRUR;
             *              obj.CreditInRURFact = itemDual.CreditCostInRUR;
             *
             *              break;
             *          }
             *      }
             *      Res.Add(obj);
             *
             *  } else if (item.PlaneFact == PlaneFact.FACT) {
             *
             *      crmGroupByStageAndObligationReportHelper obj = new crmGroupByStageAndObligationReportHelper(ssn);
             *
             *      obj.ObligationUnitOid = item.ObligationUnit.Oid;
             *      obj.ObligationUnitDateTime = item.ObligationUnitDateTime;
             *      obj.ObligationUnitCode = item.ObligationUnit.Code;
             *      obj.PrimaryPartyName = item.PrimaryParty.PartyName;
             *      obj.ContragentPartyName = item.ContragentParty.PartyName;
             *      obj.ContractName = item.Contract.Delo;
             *      obj.ContractDealName = item.ContractDeal.ContractDocument.FullName;
             *      obj.StageOid = item.Stage.Oid;
             *      obj.StageName = item.Stage.Code;
             *
             *      obj.DebetFact = item.DebitCost;
             *      obj.CreditFact = item.CreditCost;
             *      obj.DebetInRURFact = item.DebitCostInRUR;
             *      obj.CreditInRURFact = item.CreditCostInRUR;
             *      obj.DebitCreditValutaName = item.CreditValuta.Code;
             *
             *      // Обойдёмся без LINQ
             *      foreach (crmDebtorCreditorDebtRegister itemDual in dbRegister) {
             *          if (itemDual.PlaneFact == PlaneFact.PLAN
             *              && item.ObligationUnit.Oid == itemDual.ObligationUnit.Oid
             *              && item.Stage.Oid == itemDual.Stage.Oid) {
             *
             *              obj.DebetPlan = itemDual.DebitCost;
             *              obj.CreditPlan = itemDual.CreditCost;
             *              obj.DebetInRURPlan = itemDual.DebitCostInRUR;
             *              obj.CreditInRURPlan = itemDual.CreditCostInRUR;
             *
             *              break;
             *          }
             *      }
             *      Res.Add(obj);
             *
             *  }
             *
             * }
             */

            return(Res);
        }
        void actionAdminCreateTask_Executed(object sender, ActionBaseEventArgs e)
        {
            // Загружаем новый Task

            DealWithoutStageTaskInstanceDefinitionAdmin currentObject = (DealWithoutStageTaskInstanceDefinitionAdmin)View.CurrentObject;

            currentObject.Save();
            currentObject.Session.FlushChanges();

            // Находим новую задачу (она должна быть одна для админской (singleton)) по ссылке в задаче на админскую
            XPCollection <BaseUserTask> tasks = new XPCollection <BaseUserTask>(currentObject.Session);

            if (!tasks.IsLoaded)
            {
                tasks.Load();
            }

            var ltasks = (from task in tasks where task.TaskAdminGuid.Equals(currentObject.Oid) select task);
            //if (((XPCollection<BaseUserTask>)ltasks).Count == 0) return;

            BaseUserTask but = null;

            // Выполнение пункта меню
            //string viewId = "BaseUserTask";
            //ChoiceActionItem item = FindNavigationItemByViewId(viewId);
            //if (item != null && item.Enabled.ResultValue) {
            //    Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction.DoExecute(item);
            //} else {
            //    throw new Exception(String.Format("Unable to open {0} at startup", viewId));
            //}
            //return;

            //ChoiceActionItem item = FindNavigationItemByViewId("TaskInvoiceInstanceDefinition_ListView");



            IEnumerator enumltasks = ltasks.GetEnumerator();

            while (enumltasks.MoveNext())
            {
                but = (BaseUserTask)enumltasks.Current;
                break;
            }
            if (but == null)
            {
                return;
            }


            //string detailViewId = "TaskInvoiceInstanceDefinition_DetailView";
            string       detailViewId = "BaseUserTask_DetailView";
            IObjectSpace objectSpace  = Frame.Application.CreateObjectSpace();
            //IObjectSpace objectSpace = View.ObjectSpace.CreateNestedObjectSpace();
            BaseUserTask objCurrent = objectSpace.GetObject <BaseUserTask>(but);

            //TaskInvoiceInstanceDefinitionAdmin objTaskInvoiceInstanceDefinitionAdmin = objectSpace.CreateObject<TaskInvoiceInstanceDefinitionAdmin>();
            DetailView dv = Frame.Application.CreateDetailView(objectSpace, detailViewId, true, objCurrent);

            //ListView dv = Frame.Application.CreateListView(objectSpace, typeof(TaskInvoiceInstanceDefinitionAdmin), true);
            dv.AllowEdit.SetItemValue("BaseUserTaskReadOnly", true);

            ShowViewParameters svp = new ShowViewParameters();

            svp.CreatedView = dv;
            //Specify various display settings.
            svp.TargetWindow         = TargetWindow.Current;
            svp.Context              = TemplateContext.View;
            svp.CreateAllControllers = true;
            // Here we show our detail view.
            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(Frame, null));
        }
Example #15
0
        //private string _ValutaName;
        ///// <summary>
        ///// ValutaName
        ///// Валюта договора
        ///// </summary>
        //public string ValutaName {
        //    get { return _ValutaName; }
        //    set {
        //        SetPropertyValue<string>("ValutaName", ref _ValutaName, value);
        //    }
        //}

        #endregion


        #region МЕТОДЫ

        public override List <BaseReportHelper> CreateReportListSource(Session ssn, CriteriaOperator criteria)
        {
            XPClassInfo classInfo = ssn.GetClassInfo(this.GetType());

            XPCollection <crmDebtorCreditorDebtRegister> dbRegister = new XPCollection <crmDebtorCreditorDebtRegister>(ssn, criteria, null);

            dbRegister.Criteria = criteria;
            dbRegister.Reload();
            if (!dbRegister.IsLoaded)
            {
                dbRegister.Load();
            }

            // Linq по коллекции
            var registerGroups = from registerRow in dbRegister
                                 group registerRow by
                                 new {
                registerRow.PrimaryParty,
                registerRow.Subject,
                registerRow.fmOrder,
                registerRow.ContragentParty,
                registerRow.Contract,
                registerRow.ContractDeal,
                registerRow.Stage,
                registerRow.ObligationUnitMonth
            }
            into registerGroup
                select new {
                RegGroup = registerGroup,

                PrimaryPartyOid  = registerGroup.Key.PrimaryParty.Oid,
                PrimaryPartyName = registerGroup.Key.PrimaryParty.Person.NameFull,

                SubjectOid  = registerGroup.Key.Subject.Oid,
                SubjectName = registerGroup.Key.Subject.Code,

                OrderOid  = registerGroup.Key.fmOrder.Oid,
                OrderName = registerGroup.Key.fmOrder.Subject.Code,

                ContragentPartyOid  = registerGroup.Key.ContragentParty.Oid,
                ContragentPartyName = registerGroup.Key.ContragentParty.Person.NameFull,

                ContractOid = registerGroup.Key.Contract.Oid,
                //!!!Паша нужно подставит ьправильное значение
                //ContractName = registerGroup.Key.Contract.Delo,
                ContractName = " ",

                ContractDealOid  = registerGroup.Key.ContractDeal.Oid,
                ContractDealName = registerGroup.Key.ContractDeal.Name,

                StageOid  = registerGroup.Key.Stage.Oid,
                StageName = registerGroup.Key.Stage.Code,

                //ValutaName = registerGroup.Key.ObligationUnit.Valuta.Code,

                ObligationUnitMonth     = registerGroup.Key.ObligationUnitMonth,
                ObligationUnitMonthName = registerGroup.Key.ObligationUnitMonth,

                DeliveryCostPlan =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit.DatePlane.Month == registerGroup.Key.ObligationUnitMonth
                     & regRow.fmOrder == registerGroup.Key.fmOrder
                     & regRow.PlaneFact == PlaneFact.PLAN
                     & (regRow.ObligationUnit as crmDeliveryUnit) != null
                     select regRow.CreditCostInRUR).Sum()
                ,
                PaymentCostPlan =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit.DatePlane.Month == registerGroup.Key.ObligationUnitMonth
                     & regRow.fmOrder == registerGroup.Key.fmOrder
                     & regRow.PlaneFact == PlaneFact.PLAN
                     & (regRow.ObligationUnit as crmPaymentUnit) != null
                     select regRow.CreditCostInRUR).Sum()
                ,
                DeliveryCostFact =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit.DatePlane.Month == registerGroup.Key.ObligationUnitMonth
                     & regRow.fmOrder == registerGroup.Key.fmOrder
                     & regRow.PlaneFact == PlaneFact.FACT
                     & (regRow.ObligationUnit as crmDeliveryUnit) != null
                     select regRow.DebitCostInRUR).Sum()
                ,
                PaymentCostFact =
                    (from regRow in dbRegister
                     where
                     regRow.PrimaryParty == registerGroup.Key.PrimaryParty
                     & regRow.ContragentParty == registerGroup.Key.ContragentParty
                     & regRow.Contract == registerGroup.Key.Contract
                     & regRow.ContractDeal == registerGroup.Key.ContractDeal
                     & regRow.Stage == registerGroup.Key.Stage
                     & regRow.ObligationUnit.DatePlane.Month == registerGroup.Key.ObligationUnitMonth
                     & regRow.fmOrder == registerGroup.Key.fmOrder
                     & regRow.PlaneFact == PlaneFact.FACT
                     & (regRow.ObligationUnit as crmPaymentUnit) != null
                     select regRow.DebitCostInRUR).Sum()
            };

            //XPCollection xpColSpravka0105 = new XPCollection(ssn, typeof(Spravka0105));
            List <BaseReportHelper> xpColSpravka0105 = new List <BaseReportHelper>();


            // Для каждой группы формируем запись
            foreach (var grp in registerGroups)
            {
                foreach (var item in grp.RegGroup)
                {
                    Spravka0105 sprObj = new Spravka0105(ssn);

                    //sprObj.Oid = item.Oid;

                    sprObj.PrimaryPartyOid    = grp.PrimaryPartyOid;
                    sprObj.ContragentPartyOid = grp.ContragentPartyOid;
                    sprObj.ContractOid        = grp.ContractOid;
                    sprObj.ContractDealOid    = grp.ContractDealOid;

                    sprObj.ObligationUnitMonth     = grp.ObligationUnitMonth;
                    sprObj.ObligationUnitMonthName = GetMonthNameByNumber(grp.ObligationUnitMonth).ToString();

                    sprObj.StageOid = grp.StageOid;

                    sprObj.SubjectOid  = grp.SubjectOid;
                    sprObj.SubjectName = grp.SubjectName;
                    sprObj.OrderOid    = grp.OrderOid;
                    sprObj.OrderName   = grp.OrderName;


                    //sprObj.ObligationUnitDateTime = grp.ObligationUnitDateTime;
                    //sprObj.ObligationUnitCode = grp.ObligationUnitCode;

                    sprObj.PrimaryPartyName    = grp.PrimaryPartyName;    //item.PrimaryParty.PartyName;
                    sprObj.ContragentPartyName = grp.ContragentPartyName; //item.ContragentParty.PartyName;
                    sprObj.ContractName        = grp.ContractName;
                    sprObj.ContractDealName    = grp.ContractDealName;    // item.ContractDeal.ContractDocument.FullName;
                    sprObj.StageName           = grp.StageName;

                    //sprObj.ValutaName = grp.ValutaName;

                    // Вычислить 4-е величины
                    sprObj.DeliveryCostPlan = grp.DeliveryCostPlan;
                    sprObj.PaymentCostPlan  = grp.PaymentCostPlan;
                    sprObj.DeliveryCostFact = grp.DeliveryCostFact;
                    sprObj.PaymentCostFact  = grp.PaymentCostFact;

                    xpColSpravka0105.Add(sprObj);
                }
            }

            return(xpColSpravka0105);
        }
Example #16
0
        /// <summary>
        /// Список платёжных документов по жёсткому критерию
        /// </summary>
        /// <returns></returns>
        public IEnumerable GetPaymentDocsByHardCriteria <typeDoc>() where typeDoc : fmCDocRCB
        {
            //XPQuery<T> paymentDocs = new XPQuery<T>(this.Session);
            //var queryPaymentDocs = from paymentDoc in paymentDocs
            //                       where !(from statementDoc in paymentDocs
            //                       //    select statementDoc.PaymentDocument).Contains(paymentDoc)
            //                       select paymentDoc;

            //foreach (var doc in queryPaymentDocs) {
            //    // Отбираем только те, сумма которых не покрыта полностью
            //    XPQuery<T> paymentDocs1 = new XPQuery<T>(this.Session);

            /*
             * XPQuery<typeDoc> paymentDocs = new XPQuery<typeDoc>(this.Session);
             * XPQuery<fmCStatementAccountDoc> accDocs = new XPQuery<fmCStatementAccountDoc>(this.Session);
             * var queryPaymentDocs = from paymentDoc in paymentDocs
             *                     join accDoc in accDocs on paymentDoc equals accDoc.PaymentDocument
             *                     where accDoc == null
             *                     //where !(from statementDoc in accDocs
             *                     //     select statementDoc.PaymentDocument).Contains(paymentDoc)
             *                     select paymentDoc;
             */


            //CriteriaOperator criteriaAND = new GroupOperator();
            //((GroupOperator)criteriaAND).OperatorType = GroupOperatorType.And;

            //CriteriaOperator criteria1 = new BinaryOperator(new OperandProperty("INN"), new ConstantValue(pr.INN), BinaryOperatorType.Equal);
            //CriteriaOperator criteria2 = new BinaryOperator(new OperandProperty("KPP"), new ConstantValue(pr.KPP), BinaryOperatorType.Equal);
            //CriteriaOperator criteria3 = CriteriaOperator.Parse("'" + pr.KPP + "' != ''");

            //((GroupOperator)criteriaAND).Operands.Add(criteria1);
            //((GroupOperator)criteriaAND).Operands.Add(criteria2);
            //((GroupOperator)criteriaAND).Operands.Add(criteria3);

            //crmCParty party = null;
            //crmCLegalPerson lp = null;
            //crmCLegalPersonUnit lpu = null;

            //bool lpResult = true;

            //party = this.Session.FindObject<crmCParty>(criteriaAND);
            //if (party == null) {

            //OperandProperty prop = new OperandProperty("LegalPerson");
            //CriteriaOperator op = prop == lPerson;
            //CriteriaOperator criteriaPersonUnit = new BinaryOperator(new OperandProperty("KPP"), new ConstantValue(rKPP), BinaryOperatorType.Equal);

            //CriteriaOperator criteriaAND = new GroupOperator();
            //((GroupOperator)criteriaAND).OperatorType = GroupOperatorType.And;

            //((GroupOperator)criteriaAND).Operands.Add(op);
            //((GroupOperator)criteriaAND).Operands.Add(criteriaPersonUnit);

            //InOperator inOp = new InOperator(

            /*
             * foreach (var doc in queryPaymentDocs) {
             *  XPQuery<fmCStatementAccountDoc> statementDocs = new XPQuery<fmCStatementAccountDoc>(this.Session);
             *  var queryPaymentDocs1 = from statementDoc in statementDocs
             *                          where statementDoc.PaymentDocument == doc
             *                          select statementDoc;
             *  int count = queryPaymentDocs1.Count();
             *  if (count == 0)
             *      yield return doc;
             * }
             */

            XPCollection <typeDoc> docCol = new XPCollection <typeDoc>(Session);

            if (!docCol.IsLoaded)
            {
                docCol.Load();
            }
            foreach (typeDoc doc in docCol)
            {
                XPQuery <fmCSAStatementAccountDoc> statementDocs = new XPQuery <fmCSAStatementAccountDoc>(this.Session);
                var queryPaymentDocs1 = from statementDoc in statementDocs
                                        where statementDoc.PaymentDocument == doc
                                        select statementDoc;
                int count = queryPaymentDocs1.Count();
                if (count == 0)
                {
                    yield return(doc);
                }
            }
        }
Example #17
0
        /// <summary>
        /// Получение очередного номера для сортировки Пока алгоритм не отличается от алгоритма получения ISN
        /// </summary>
        public int getDocNumber()
        {
            // Вариант 2 (с XPCollection)

            Session ssn = this.Session;   // new Session(this.Session.Dictionary);

            XPCollection <RegistrationLogDocNumberCounter> xpCounterCol = new XPCollection <RegistrationLogDocNumberCounter>(ssn);

            // Условия
            CriteriaOperator criteria = null;

            criteria = new GroupOperator();
            ((GroupOperator)criteria).OperatorType = GroupOperatorType.And;

            CriteriaOperator criteriaYear = new BinaryOperator("Year", DocNumberYear, BinaryOperatorType.Equal);

            ((GroupOperator)criteria).Operands.Add(criteriaYear);

            CriteriaOperator criteriaDepartment = null;

            if (DepartmentRegistrator != null)
            {
                criteriaDepartment = new BinaryOperator("Department", DepartmentRegistrator, BinaryOperatorType.Equal);
                ((GroupOperator)criteria).Operands.Add(criteriaDepartment);
            }

            xpCounterCol.Criteria = criteria;

            if (!xpCounterCol.IsLoaded)
            {
                xpCounterCol.Load();
            }


            if (xpCounterCol.Count == 0)
            {
                // SHU 2011-11-03 ПЕРЕДЕЛАТЬ НА Session!
                // Другой работающий вариант. Здесь плохо с Connection (надо явно прописывать).
                // ssn.BeginNestedUnitOfWork не даёт желаемого результата
                using (UnitOfWork uow = new UnitOfWork(this.Session.Dictionary)) {
                    uow.Connection = ssn.Connection;
                    //if (uow.Connection.State == System.Data.ConnectionState.Closed) uow.Connect();
                    RegistrationLogDocNumberCounter newCounter = new RegistrationLogDocNumberCounter(uow);
                    newCounter.Year = this.DocNumberYear;

                    hrmDepartment dep = uow.GetObjectByKey(this.DepartmentRegistrator.GetType(), this.DepartmentRegistrator.ClassInfo.GetId(this.DepartmentRegistrator)) as hrmDepartment;

                    newCounter.Department = dep;   // this.DepartmentRegistrator;
                    newCounter.Save();
                    uow.FlushChanges();
                    //if (uow.Connection.State == System.Data.ConnectionState.Open) uow.Connection.Close();
                    xpCounterCol.Reload();
                    if (!xpCounterCol.IsLoaded)
                    {
                        xpCounterCol.Load();
                    }
                }
            }

            // Номер документа
            return(xpCounterCol[0].ReserveDocNumber());
        }