public void TestEnumLinqToLcsWithVariable()
        {
            // Arrange.
            var      testProvider = new TestLcsQueryProvider <FullTypesMainAgregator>();
            PoleEnum poleEnum     = PoleEnum.Attribute1;
            var      predicate1   = (Expression <Func <FullTypesMainAgregator, bool> >)(o => o.PoleEnum == poleEnum);

            new Query <FullTypesMainAgregator>(testProvider).Where(predicate1).ToArray();

            Expression queryExpression = testProvider.InnerExpression;
            var        expected        = new LoadingCustomizationStruct(null)
            {
                LimitFunction =
                    ldef.GetFunction(
                        ldef.funcEQ,
                        new VariableDef(ldef.StringType, Information.ExtractPropertyPath <FullTypesMainAgregator>(x => x.PoleEnum)),
                        EnumCaption.GetCaptionFor(PoleEnum.Attribute1))
            };

            // Act.
            LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, FullTypesMainAgregator.Views.FullView);

            // Assert.
            Assert.True(Equals(expected, actual));
        }
        public void TestEnumLinqToLcsWithoutVariable()
        {
            var exception = Xunit.Record.Exception(() =>
            {
                // Arrange.
                var testProvider = new TestLcsQueryProvider <FullTypesMainAgregator>();
                var predicate1   = (Expression <Func <FullTypesMainAgregator, bool> >)(o => o.PoleEnum == PoleEnum.Attribute1);
                new Query <FullTypesMainAgregator>(testProvider).Where(predicate1).ToArray();

                Expression queryExpression = testProvider.InnerExpression;
                var expected = new LoadingCustomizationStruct(null)
                {
                    LimitFunction =
                        ldef.GetFunction(
                            ldef.funcEQ,
                            new VariableDef(ldef.StringType, Information.ExtractPropertyPath <FullTypesMainAgregator>(x => x.PoleEnum)),
                            EnumCaption.GetCaptionFor(PoleEnum.Attribute1))
                };

                // Act.
                // При компиляции в VS2013 или VS2015 ServicePack 1 данная строка вызовет NotSupportedException.
                LoadingCustomizationStruct actual = LinqToLcs.GetLcs(queryExpression, FullTypesMainAgregator.Views.FullView);

                // Assert.
                Assert.True(Equals(expected, actual));
            });

            Assert.IsType(typeof(NotSupportedException), exception);
        }
        public override IzmenenieNaznachVypl Map(ChangeAppointmentPayment source, IzmenenieNaznachVypl dest)
        {
            if (dest.GetStatus() == ObjectStatus.Created)
            {
                dest.__PrimaryKey = source.Guid;
            }

            dest.DataNaznacheniia = (NullableDateTime)source.AppointmentDate;
            dest.DataOtmeny       = (NullableDateTime)source.CancellationDate;
            dest.TipVypl          = (tTipVyplaty)EnumCaption.GetValueFor(source.PaymentType.ToString(), typeof(tTipVyplaty));
            dest.PeriodPredost    =
                (tTipPerioda)EnumCaption.GetValueFor(EnumCaption.GetCaptionFor(source.Period), typeof(tTipPerioda));
            dest.Summa       = (NullableDecimal)source.Amount;
            dest.Primechanie = source.Note;
            dest.OrganSZ     = source.SocialProtectionAuthority == null
                ? null
                : PKHelper.CreateDataObject <OrganSZ>(source.SocialProtectionAuthority.Guid);
            dest.LgKatLeechnosti = source.BeneficiaryPreferentialCategory == null
                ? null
                : PKHelper.CreateDataObject <LgKatLeechnosti>(source.BeneficiaryPreferentialCategory.Guid);
            dest.Poluchatel = source.Recipient == null
                ? null
                : PKHelper.CreateDataObject <Leechnost>(source.Recipient.Guid);
            dest.Naznachenie = source.PaymentAppointment == null
                ? null
                : PKHelper.CreateDataObject <NaznachenieVyplaty>(source.PaymentAppointment.Guid);

            dest.CreateTime = source.CreateTime;
            dest.Creator    = source.Creator;
            dest.EditTime   = source.EditTime;
            dest.Editor     = source.Editor;

            return(dest);
        }
Пример #4
0
 public void BuildEqualsTest40()
 {
     Assert.Equal(
         LangDef.GetFunction(
             LangDef.funcEQ,
             StringVarDef,
             EnumCaption.GetCaptionFor(tDayOfWeek.Day0)),
         FunctionBuilder.BuildEquals(StringVarDef, tDayOfWeek.Day0));
 }
        /// <summary>
        /// Преобразовать значение.
        /// </summary>
        /// <param name="value">Значение для преобразования.</param>
        /// <param name="toType">Тип, в который надо преобразовать.</param>
        /// <returns>Преобразованное значение.</returns>
        public static object Convert(object value, Type toType)
        {
            lock (TypeToTypeMethods)
            {
                Type fromType = value.GetType();

                if (fromType == toType)
                {
                    return(value);
                }

                if (fromType == typeof(string) && toType.IsEnum)
                {
                    return(EnumCaption.GetValueFor((string)value, toType));
                }

                if (fromType.IsEnum && toType == typeof(string))
                {
                    return(EnumCaption.GetCaptionFor(value));
                }

                if (fromType == typeof(int) && toType.IsEnum)
                {
                    return(Enum.Parse(toType, Enum.GetName(toType, value)));
                }

                if (fromType.IsEnum && toType == typeof(int))
                {
                    return((int)value);
                }

                TypeTypePair key = new TypeTypePair(fromType, toType);
                if (!ParsedTypes.Contains(fromType))
                {
                    AddTypeOperator(fromType);
                }

                if (!ParsedTypes.Contains(toType))
                {
                    AddTypeOperator(toType);
                }

                if (TypeToTypeMethods.ContainsKey(key))
                {
                    MethodInfo mi = TypeToTypeMethods[key];
                    return(mi.Invoke(null, new[] { value }));
                }

                if (toType == typeof(string))
                {
                    return(value.ToString());
                }

                return(System.Convert.ChangeType(value, toType));
            }
        }
Пример #6
0
        public void EnumCaptionGetCaptionForTest()
        {
            // Arrange.

            // Act.
            string actual = EnumCaption.GetCaptionFor(NumberedYear.Year2012);

            // Assert.
            Assert.Equal("2012", actual);
        }
Пример #7
0
        public void EnumCaptionGetCaptionForEmptyStringTest()
        {
            // Arrange.

            // Act.
            string actual = EnumCaption.GetCaptionFor(NumberedYear.Year2014);

            // Assert.
            Assert.Equal(string.Empty, actual);
        }
Пример #8
0
        public void EnumCaptionGetCaptionForWithoutCaptionTest()
        {
            // Arrange.

            // Act.
            string actual = EnumCaption.GetCaptionFor(CaseSensitiveEnum.CASEINSENSITIVEVAL);

            // Assert.
            Assert.Equal("CASEINSENSITIVEVAL", actual);
        }
Пример #9
0
        /// <summary>
        ///     Проверить и преобразовать аргумент в соответствии с типом.
        /// </summary>
        /// <param name="type">Тип.</param>
        /// <param name="value">Значение.</param>
        /// <exception cref="ArgumentException">Аргумент не содержит ключевой структуры.</exception>
        /// <exception cref="InvalidCastException">Не совпадают тип свойства и тип переданного параметра.</exception>
        /// <exception cref="FormatException"><seealso cref="M:Convert.ChangeType(object, Type)"/></exception>
        /// <returns>Преобразованный аргумент.</returns>
        internal static object ConvertValue(Type type, object value)
        {
            ValidateValue(value);

            var nctType = GetObjectType(type).NetCompatibilityType;
            var res     = value;

            if (res.GetType().IsEnum)
            {
                if (nctType == typeof(string))
                {
                    res = EnumCaption.GetCaptionFor(res);
                }
                else if (nctType == typeof(decimal))
                {
                    res = Convert.ChangeType(res, nctType);
                }
            }

            if (IsKeyType(nctType))
            {
                res = PKHelper.GetKeyByObject(res);
                if (res == null)
                {
                    throw new ArgumentException(nameof(value));
                }
            }

            ValidateValue(res);

            // Когда свойство строкового типа, а значение - не строка.
            if (nctType == typeof(string) && GetObjectType(res.GetType()).NetCompatibilityType != typeof(string))
            {
                res = Convert.ToString(res);
            }

            if (GetObjectType(res.GetType()).NetCompatibilityType != nctType)
            {
                if (res.GetType().GetInterfaces().Any(x => x == typeof(IConvertible)))
                {
                    // Попробуем преобразовать в нужный тип.
                    res = Convert.ChangeType(res, type);
                }
                else
                {
                    throw new InvalidCastException(nameof(value));
                }
            }

            return(res);
        }
Пример #10
0
        public void EnumCaptionGetCaptionForNullTest()
        {
            var exception = Xunit.Record.Exception(() =>
            {
                // Arrange.

                // Act.
                EnumCaption.GetCaptionFor(null);

                // Assert.
                // Ожидаем исключения.
            });

            Assert.IsType(typeof(ArgumentNullException), exception);
        }
Пример #11
0
        public void EnumCaptionGetCaptionForNotEnumTest()
        {
            var exception = Xunit.Record.Exception(() =>
            {
                // Arrange.
                SimpleDataObject simpleDataObject = new SimpleDataObject();

                // Act.
                EnumCaption.GetCaptionFor(simpleDataObject);

                // Assert.
                // Ожидаем исключения.
            });

            Assert.IsType(typeof(NotEnumTypeException), exception);
        }
Пример #12
0
        /// <summary>
        /// Возвращает количество взятий в прокат велосипедов выбранного типа.
        /// </summary>
        public static int GetRentsCount(BicycleType type)
        {
            var lcs  = LoadingCustomizationStruct.GetSimpleStruct(typeof(RentSession), RentSession.Views.RentSessionE);
            var ld   = SQLWhereLanguageDef.LanguageDef;
            var func = ld.GetFunction(
                ld.funcEQ,
                new VariableDef(
                    ld.StringType,
                    Information.ExtractPropertyPath <RentSession>(item => item.Bicycle.Type)
                    ),
                EnumCaption.GetCaptionFor(type)
                );

            lcs.LimitFunction = func;
            var ds = (SQLDataService)DataServiceProvider.DataService;

            return(ds.LoadObjects(lcs).Length);

            //return ds.Query<RentSession>(RentSession.Views.RentSessionE.Name)
            //    .Count(item => item.Bicycle.Type.Equals(type));
        }
        public override FaktLgot Map(FactBenefits source, FaktLgot dest)
        {
            if (dest.GetStatus() == ObjectStatus.Created)
            {
                dest.__PrimaryKey = source.Guid;
            }

            dest.DataNachisleniia = (NullableDateTime)source.AccrualDate;
            dest.DataPolucheniia  = (NullableDateTime)source.ReceiveDate;
            dest.Summa            = (NullableDecimal)source.Amount;
            dest.SummaSotcPaketa  = (NullableDecimal)source.AmountSocialPackage;
            dest.Kommentarii      = source.Comments;
            dest.SposobOplaty     = (tSposobOplaty)EnumCaption.GetValueFor(EnumCaption.GetCaptionFor(source.PaymentMethod),
                                                                           typeof(tSposobOplaty));
            dest.DataPereplS  = (NullableDateTime)source.OverpaymentDateFrom;
            dest.DataPereplPo = (NullableDateTime)source.OverpaymentDateTo;
            dest.NositelLgoty = source.MediumBenefit == null
                ? null
                : PKHelper.CreateDataObject <LgKatLeechnosti>(source.MediumBenefit.Guid);
            dest.Izhdivenetc = source.Dependent == null
                ? null
                : PKHelper.CreateDataObject <Leechnost>(source.Dependent.Guid);
            dest.Poluchatel = source.Recipient == null
                ? null
                : PKHelper.CreateDataObject <Leechnost>(source.Recipient.Guid);
            dest.Lgota   = source.Benefit == null ? null : PKHelper.CreateDataObject <Lgota>(source.Benefit.Guid);
            dest.OrganSZ = source.SocialProtectionAuthority == null
                ? null
                : PKHelper.CreateDataObject <OrganSZ>(source.SocialProtectionAuthority.Guid);
            dest.Period = source.Period == null ? null : PKHelper.CreateDataObject <Period>(source.Period.Guid);

            dest.CreateTime = source.CreateTime;
            dest.Creator    = source.Creator;
            dest.EditTime   = source.EditTime;
            dest.Editor     = source.Editor;

            return(dest);
        }
Пример #14
0
        public override Stroenie Map(Structure source, Stroenie dest)
        {
            if (dest.GetStatus() == ObjectStatus.Created)
            {
                dest.__PrimaryKey = source.Guid;
            }

            dest.KodFIAS       = source.FIAS;
            dest.VidStroeniia  = (tVidStroeniia)EnumCaption.GetValueFor(EnumCaption.GetCaptionFor(source.TypeStructure), typeof(tVidStroeniia));
            dest.Nomer         = source.Number == null ? 0 : (uint)source.Number;
            dest.PochtIndeks   = source.PostIndex;
            dest.DopStroenie   = source.Additional;
            dest.KodPodtverzhd = source.VerificationCode == null ? 0 : (uint)source.VerificationCode;
            dest.Raion         = source.Area == null ? null : PKHelper.CreateDataObject <Territoriia>(source.Area.Guid);
            dest.Ulitca        = source.Street == null ? null : PKHelper.CreateDataObject <Ulitca>(source.Street.Guid);

            dest.CreateTime = source.CreateTime;
            dest.Creator    = source.Creator;
            dest.EditTime   = source.EditTime;
            dest.Editor     = source.Editor;

            return(dest);
        }
Пример #15
0
 /// <summary>
 /// Метод для получения CSS-класса тэга "body" на основе текущего типа разметки.
 /// </summary>
 /// <returns>CSS-класс тэга "body".</returns>
 protected string GetBodyClass()
 {
     return(EnumCaption.GetCaptionFor(_layout));
 }
Пример #16
0
        /// <summary>
        /// Здесь лучше всего писать бизнес-логику, оперируя только объектом данных.
        /// </summary>
        protected override void PreApplyToControls()
        {
            SQLWhereLanguageDef langdef = SQLWhereLanguageDef.LanguageDef;

            Function lf = langdef.GetFunction(langdef.funcEQ,
                                              new VariableDef(langdef.StringType, Information.ExtractPropertyName <Сотрудник>(x => x.Должность)), EnumCaption.GetCaptionFor(Должность.Менеджер));

            ctrlСотрудник.LimitFunction = lf;
        }
Пример #17
0
 public void BuildBetweenTest342()
 {
     Assert.Equal(
         LangDef.GetFunction(LangDef.funcBETWEEN, StringVarDef, String1, EnumCaption.GetCaptionFor(Enum1)),
         FunctionBuilder.BuildBetween(StringVarDef.Caption, String1, Enum1));
 }
        public override FaktLgot Map(FactBenefits source, FaktLgot dest, List <string> attrs)
        {
            if (dest.GetStatus() == ObjectStatus.Created || attrs == null)
            {
                return(Map(source, dest));
            }

            if (attrs.Contains(FactBenefits.ConstAccrualDate))
            {
                dest.DataNachisleniia = (NullableDateTime)source.AccrualDate;
            }

            if (attrs.Contains(FactBenefits.ConstReceiveDate))
            {
                dest.DataPolucheniia = (NullableDateTime)source.ReceiveDate;
            }

            if (attrs.Contains(FactBenefits.ConstAmount))
            {
                dest.Summa = (NullableDecimal)source.Amount;
            }

            if (attrs.Contains(FactBenefits.ConstAmountSocialPackage))
            {
                dest.SummaSotcPaketa = (NullableDecimal)source.AmountSocialPackage;
            }

            if (attrs.Contains(FactBenefits.ConstComments))
            {
                dest.Kommentarii = source.Comments;
            }

            if (attrs.Contains(FactBenefits.ConstPaymentMethod))
            {
                dest.SposobOplaty =
                    (tSposobOplaty)EnumCaption.GetValueFor(EnumCaption.GetCaptionFor(source.PaymentMethod),
                                                           typeof(tSposobOplaty));
            }

            if (attrs.Contains(FactBenefits.ConstOverpaymentDateFrom))
            {
                dest.DataPereplS = (NullableDateTime)source.OverpaymentDateFrom;
            }

            if (attrs.Contains(FactBenefits.ConstOverpaymentDateTo))
            {
                dest.DataPereplPo = (NullableDateTime)source.OverpaymentDateTo;
            }

            if (attrs.Contains(FactBenefits.ConstMediumBenefit))
            {
                dest.NositelLgoty = source.MediumBenefit == null
                    ? null
                    : PKHelper.CreateDataObject <LgKatLeechnosti>(source.MediumBenefit.Guid);
            }

            if (attrs.Contains(FactBenefits.ConstDependent))
            {
                dest.Izhdivenetc = source.Dependent == null
                    ? null
                    : PKHelper.CreateDataObject <Leechnost>(source.Dependent.Guid);
            }

            if (attrs.Contains(FactBenefits.ConstRecipient))
            {
                dest.Poluchatel = source.Recipient == null
                    ? null
                    : PKHelper.CreateDataObject <Leechnost>(source.Recipient.Guid);
            }

            if (attrs.Contains(FactBenefits.ConstBenefit))
            {
                dest.Lgota = source.Benefit == null ? null : PKHelper.CreateDataObject <Lgota>(source.Benefit.Guid);
            }

            if (attrs.Contains(FactBenefits.ConstSocialProtectionAuthority))
            {
                dest.OrganSZ = source.SocialProtectionAuthority == null
                    ? null
                    : PKHelper.CreateDataObject <OrganSZ>(source.SocialProtectionAuthority.Guid);
            }

            if (attrs.Contains(FactBenefits.ConstPeriod))
            {
                dest.Period = source.Period == null ? null : PKHelper.CreateDataObject <Period>(source.Period.Guid);
            }

            if (attrs.Contains(SyncXMLDataObject.ConstCreateTime))
            {
                dest.CreateTime = source.CreateTime;
            }

            if (attrs.Contains(SyncXMLDataObject.ConstCreator))
            {
                dest.Creator = source.Creator;
            }

            if (attrs.Contains(SyncXMLDataObject.ConstEditTime))
            {
                dest.EditTime = source.EditTime;
            }

            if (attrs.Contains(SyncXMLDataObject.ConstEditor))
            {
                dest.Editor = source.Editor;
            }

            return(dest);
        }
Пример #19
0
        public override Stroenie Map(Structure source, Stroenie dest, List <string> attrs)
        {
            if (dest.GetStatus() == ObjectStatus.Created || attrs == null)
            {
                return(Map(source, dest));
            }
            else
            {
                if (attrs.Contains(Structure.ConstFIAS))
                {
                    dest.KodFIAS = source.FIAS;
                }
                if (attrs.Contains(Structure.ConstType))
                {
                    dest.VidStroeniia = (tVidStroeniia)EnumCaption.GetValueFor(EnumCaption.GetCaptionFor(source.TypeStructure), typeof(tVidStroeniia));
                }
                if (attrs.Contains(Structure.ConstNumber))
                {
                    dest.Nomer = (uint)source.Number;
                }
                if (attrs.Contains(Structure.ConstPostIndex))
                {
                    dest.PochtIndeks = source.PostIndex;
                }
                if (attrs.Contains(Structure.ConstAdditional))
                {
                    dest.DopStroenie = source.Additional;
                }
                if (attrs.Contains(Structure.ConstVerificationCode))
                {
                    dest.KodPodtverzhd = source.VerificationCode == null ? 0 : (uint)source.VerificationCode;
                }
                if (attrs.Contains(Structure.ConstArea))
                {
                    dest.Raion = source.Area == null ? null : PKHelper.CreateDataObject <Territoriia>(source.Area.Guid);
                }
                if (attrs.Contains(Structure.ConstStreet))
                {
                    dest.Ulitca = source.Street == null ? null : PKHelper.CreateDataObject <Ulitca>(source.Street.Guid);
                }

                if (attrs.Contains(SyncXMLDataObject.ConstCreateTime))
                {
                    dest.CreateTime = source.CreateTime;
                }
                if (attrs.Contains(SyncXMLDataObject.ConstCreator))
                {
                    dest.Creator = source.Creator;
                }
                if (attrs.Contains(SyncXMLDataObject.ConstEditTime))
                {
                    dest.EditTime = source.EditTime;
                }
                if (attrs.Contains(SyncXMLDataObject.ConstEditor))
                {
                    dest.Editor = source.Editor;
                }

                return(dest);
            }
        }
Пример #20
0
 /// <summary>
 /// Метод для получения CSS-класса тэга "body" на основе текущего типа разметки.
 /// </summary>
 /// <returns>CSS-класс тэга "body".</returns>
 protected string GetBodyClass()
 {
     return(string.Concat(EnumCaption.GetCaptionFor(_layout), _openAsModalDialog ? " modal" : string.Empty));
 }
Пример #21
0
        public string GetBodyID()
        {
            string bodyId = EnumCaption.GetCaptionFor(BodyID);

            return(bodyId);
        }
 public void BuildTest202()
 {
     Assert.Equal(
         LangDef.GetFunction(LangDef.funcEQ, StringVarDef, EnumCaption.GetCaptionFor(TestDayOfWeek1)),
         FunctionBuilder.Build(LangDef.funcIN, StringVarDef, TestDayOfWeek1, TestDayOfWeek1));
 }
 public void BuildTest204()
 {
     Assert.Equal(
         LangDef.GetFunction(LangDef.funcEQ, StringVarDef, EnumCaption.GetCaptionFor(TestDayOfWeek1)),
         FunctionBuilder.Build(LangDef.funcIN, StringVarDef, RepeatedEnumList.ToArray()));
 }
 public void BuildTest209()
 {
     Assert.Equal(
         LangDef.GetFunction(LangDef.funcIN, StringVarDef, EnumCaption.GetCaptionFor(TestDayOfWeek1), EnumCaption.GetCaptionFor(TestDayOfWeek2)),
         FunctionBuilder.Build(LangDef.funcIN, StringVarDef, EnumList.Where(x => true)));
 }
Пример #25
0
        /// <summary>
        /// Вызывается самым первым в Page_Load.
        /// </summary>
        protected override void Preload()
        {
            ExternalLangDef langdef = ExternalLangDef.LanguageDef;

            WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                   langdef.GetFunction(
                                                                       langdef.funcNEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.Выполнено)),
                                                                   langdef.GetFunction(
                                                                       langdef.funcNEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.Отложено)));
        }
        public override IzmenenieNaznachVypl Map(ChangeAppointmentPayment source, IzmenenieNaznachVypl dest,
                                                 List <string> attrs)
        {
            if (dest.GetStatus() == ObjectStatus.Created || attrs == null)
            {
                return(Map(source, dest));
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstAppointmentDate))
            {
                dest.DataNaznacheniia = (NullableDateTime)source.AppointmentDate;
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstCancellationDate))
            {
                dest.DataOtmeny = (NullableDateTime)source.CancellationDate;
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstPaymentType))
            {
                dest.TipVypl =
                    (tTipVyplaty)EnumCaption.GetValueFor(source.PaymentType.ToString(), typeof(tTipVyplaty));
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstPeriod))
            {
                dest.PeriodPredost =
                    (tTipPerioda)EnumCaption.GetValueFor(EnumCaption.GetCaptionFor(source.Period),
                                                         typeof(tTipPerioda));
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstAmount))
            {
                dest.Summa = (NullableDecimal)source.Amount;
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstNote))
            {
                dest.Primechanie = source.Note;
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstSocialProtectionAuthority))
            {
                dest.OrganSZ = source.SocialProtectionAuthority == null
                    ? null
                    : PKHelper.CreateDataObject <OrganSZ>(source.SocialProtectionAuthority.Guid);
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstBeneficiaryPreferentialCategory))
            {
                dest.LgKatLeechnosti = source.BeneficiaryPreferentialCategory == null
                    ? null
                    : PKHelper.CreateDataObject <LgKatLeechnosti>(source.BeneficiaryPreferentialCategory.Guid);
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstRecipient))
            {
                dest.Poluchatel = source.Recipient == null
                    ? null
                    : PKHelper.CreateDataObject <Leechnost>(source.Recipient.Guid);
            }

            if (attrs.Contains(ChangeAppointmentPayment.ConstPaymentAppointment))
            {
                dest.Naznachenie = source.PaymentAppointment == null
                    ? null
                    : PKHelper.CreateDataObject <NaznachenieVyplaty>(source.PaymentAppointment.Guid);
            }

            if (attrs.Contains(SyncXMLDataObject.ConstCreateTime))
            {
                dest.CreateTime = source.CreateTime;
            }

            if (attrs.Contains(SyncXMLDataObject.ConstCreator))
            {
                dest.Creator = source.Creator;
            }

            if (attrs.Contains(SyncXMLDataObject.ConstEditTime))
            {
                dest.EditTime = source.EditTime;
            }

            if (attrs.Contains(SyncXMLDataObject.ConstEditor))
            {
                dest.Editor = source.Editor;
            }

            return(dest);
        }
        /// <summary>
        /// Вызывается самым первым в Page_Load.
        /// </summary>
        protected override void Preload()
        {
            ExternalLangDef langdef = ExternalLangDef.LanguageDef;

            WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcEQ,
                                                                   new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true);

            string a = Request.QueryString["status"];

            switch (a)
            {
            case "done":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.Выполнено)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;

            case "test":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.Проверка)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;

            case "process":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.ВПроцессеОбсуждения)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;

            case "wait":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.ЖдутУточнения)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;

            case "otl":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.Отложено)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;

            case "forum":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.Форум)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;

            case "vforum":
                WebObjectListView1.LimitFunction = langdef.GetFunction(langdef.funcAND,
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.StringType, Information.ExtractPropertyName <Задача>(x => x.Статус)), EnumCaption.GetCaptionFor(СтатусЗадачи.ВнешнийФорум)),
                                                                       langdef.GetFunction(
                                                                           langdef.funcEQ, new VariableDef(langdef.BoolType, Information.ExtractPropertyName <Задача>(x => x.Поддержка)), true));
                break;
            }
        }
Пример #28
0
        /// <summary>
        /// Здесь лучше всего писать бизнес-логику, оперируя только объектом данных.
        /// </summary>
        protected override void PreApplyToControls()
        {
            ExternalLangDef ld = ExternalLangDef.LanguageDef;

            if (Context.User.IsInRole("Продавец"))
            {
                if (this.DataObject == null)
                {
                    // Определяем текущего пользователя
                    var          currentUser = Context.User.Identity.Name;
                    IDataService ds          = DataServiceProvider.DataService;
                    var          lcs         = LoadingCustomizationStruct.GetSimpleStruct(typeof(Продавец), "ПродавецL");
                    lcs.LimitFunction = ld.GetFunction(ld.funcEQ,
                                                       new VariableDef(ld.StringType, Information.ExtractPropertyPath <Продавец>(x => x.Логин)), currentUser);
                    var manager = ds.LoadObjects(lcs)[0] as Продавец;

                    // Устанавливаем текущего продавца в поле заказа
                    NewPlatform.Flexberry.Orm.KeyGen.SystemGuidGenerator generator = new NewPlatform.Flexberry.Orm.KeyGen.SystemGuidGenerator();
                    this.DataObject = new Чек()
                    {
                        //__PrimaryKey = generator.Generate(typeof(Чек)),
                        Продавец      = manager,
                        ТорговаяТочка = manager.ТорговаяТочка
                    };

                    // Фильтруем список индивидуальных заказов в соотв. с торговой точкой, на которой работает текущий продавец
                    ctrlИндивидуальныйЗаказ.MasterViewName = ИндивидуальныйЗаказ.Views.ИндивидуальныйЗаказE.Name;
                    ctrlИндивидуальныйЗаказ.LimitFunction  = ld.GetFunction(ld.funcAND,
                                                                            ld.GetFunction(ld.funcEQ,
                                                                                           new VariableDef(ld.GuidType, Information.ExtractPropertyPath <ИндивидуальныйЗаказ>(order => order.ТорговаяТочка)),
                                                                                           manager.ТорговаяТочка.__PrimaryKey),
                                                                            ld.GetFunction(ld.funcEQ,
                                                                                           new VariableDef(ld.StringType, Information.ExtractPropertyPath <ИндивидуальныйЗаказ>(order => order.Состояние)),
                                                                                           EnumCaption.GetCaptionFor(СостояниеЗаказа.Выполненный)));
                }
                // отображаем в возможных позициях в чеке только те продукты, которые есть в продаже на этой торговой точке
                ctrlПозицияВЧеке.AddLookUpSettings(Information.ExtractPropertyPath <ПозицияВЧеке>(r => r.Продукт), new LookUpSetting()
                {
                    LimitFunction = ld.GetFunction(ld.funcExist,
                                                   new DetailVariableDef(ld.GetObjectType("Details"), "ПродуктНаПродажу", ПродуктНаПродажу.Views.ПродуктНаПродажуE, "Продукт", null),
                                                   ld.GetFunction(ld.funcEQ,
                                                                  new VariableDef(ld.StringType, Information.ExtractPropertyPath <ПродуктНаПродажу>(r => r.ТорговаяТочка)),
                                                                  this.DataObject.ТорговаяТочка.__PrimaryKey)),
                    ColumnsSort = new ColumnsSortDef[] { new ColumnsSortDef("Код", SortOrder.Asc) }
                });
                ctrlПродавец.Enabled            = false;
                ctrlТорговаяТочка.Enabled       = false;
                ctrlИндивидуальныйЗаказ.Enabled = false;
                if (this.DataObject.GetStatus() == ObjectStatus.Created)
                {
                    ctrlИндивидуальныйЗаказ.Enabled = true;
                }
                if (DataObject.Состояние == СостояниеЧека.Закрытый)
                {
                    ctrlСостояние.Enabled = false;
                }
            }
        }