Exemplo n.º 1
0
        public void ARProxy_CreateEntry_datatype_Enum()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                DateTime dt      = DateTime.Now;
                string   entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status         = NRemedy_Test_Regular_Form.Status_Enum.Fixed
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);

                model.Status = NRemedy_Test_Regular_Form.Status_Enum.Rejected;
                proxy.SetEntry(model);

                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Rejected, model.Status);

                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 2
0
        public void ARProxy_CreateEntry_datatype_int()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    IntegerField   = 256
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(256, model.IntegerField);

                model.IntegerField = 512;
                proxy.SetEntry(model);

                Assert.AreEqual(512, model.IntegerField);
                Assert.AreEqual("should not changed", model.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 3
0
        public static void SetEntry <TModel>(
            this ARProxy <TModel> proxy, TModel model, params Expression <Func <TModel, object> >[] propertiesTobeUp)
            where TModel : ARBaseForm
        {
            if (propertiesTobeUp == null || propertiesTobeUp.Length == 0)
            {
                return;
            }
            ITypeMetaProvider <TModel> metaProvider = new ExpressionTypeMetaProvider <TModel>(propertiesTobeUp);

            ModelMeteData <TModel> MetaData = new ModelMeteData <TModel>();

            MetaData.FormName = metaProvider.GetFormNameFromModelType();
            var entryIdProp = metaProvider.GetEntryIdPropertyInfo();

            if (entryIdProp == null)
            {
                throw new CustomAttributeFormatException("Can not find EntryId's PropertyInfo.");
            }
            MetaData.EntryId = (string)entryIdProp.GetValue(model);
            MetaData.Model   = model;
            var props = metaProvider.GetPropertyInfoes(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null);

            MetaData.Properties = new List <PropertyAndField <TModel> >();

            foreach (var p in props)
            {
                if ((p.AccessLevel & ModelBinderAccessLevel.OnlyUnBind) == ModelBinderAccessLevel.OnlyUnBind)
                {
                    MetaData.Properties.Add(p);
                }
            }

            proxy.SetEntry(MetaData);
        }
Exemplo n.º 4
0
        public void ARProxy_SetEntry_By_Properties_Ids()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                DateTime dt      = DateTime.Now;
                string   entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField     = "should not changed",
                    Status             = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField       = 10
                }
                                                     );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                //Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                model.CharacterField     = "don not want changed";
                model.Status             = NRemedy_Test_Regular_Form.Status_Enum.New;
                model.DecimalNumberField = 3.14m;
                model.IntegerField       = 11;

                List <ARFieldValue> up_fvs = new List <ARFieldValue>();

                up_fvs.Add(new ARFieldValue(TestDecimalFieldId, 3.14m, ARDataType.DATA_TYPE_DECIMAL));
                up_fvs.Add(new ARFieldValue(7u, NRemedy_Test_Regular_Form.Status_Enum.New, ARDataType.DATA_TYPE_ENUM));
                up_fvs.Add(new ARFieldValue(TestIntFieldId, 11, ARDataType.DATA_TYPE_INTEGER));

                //set
                proxy.SetEntry(entryId, up_fvs);

                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.New, model2.Status);
                Assert.AreEqual(3.14m, model2.DecimalNumberField);
                Assert.AreEqual(11, model2.IntegerField);
                Assert.AreEqual("should not changed", model2.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 5
0
        public void ARProxy_Transacation_Simple_Rollback()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                context.TransactionBegin();
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status         = NRemedy_Test_Regular_Form.Status_Enum.Fixed
                });
                Assert.AreEqual(string.Empty, entryId);
                //second call will failed
                List <ARFieldValue> up_fvs = new List <ARFieldValue>();
                up_fvs.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR));
                proxy.SetEntry("11111111111", up_fvs);

                var result = context.TransactionCommit();

                Assert.IsFalse(result.Success);
                Assert.AreEqual(2, result.ResultList.Count);

                Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[0].CallType);
                var entryid1 = result.ResultList[0].EntryId;
                //!!@@important
                //when create entry is not in trasaction, it will not cause warning 52 when the RequestID is in the fieldValueList
                //but in trasacation, this will cause warning 52.
                //this because trasaction actually means group the operations and send to AR when commit.AR may block the operaion,
                //even this is caused by warning
                Assert.IsNull(result.ResultList[0].Status);

                Assert.AreEqual(EntryCallType.BULK_ENTRY_SET, result.ResultList[1].CallType);
                Assert.IsNotNull(result.ResultList[1].Status);
                //item do not exist in the db
                Assert.AreEqual(302, result.ResultList[1].Status.MessageNumber);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 6
0
        public void ARProxy_SetEntry_By_Properties_Str()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                DateTime dt      = DateTime.Now;
                string   entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField     = "should not changed",
                    Status             = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField       = 10
                }
                                                     );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                //Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                model.CharacterField     = "don not want changed";
                model.Status             = NRemedy_Test_Regular_Form.Status_Enum.New;
                model.DecimalNumberField = 3.14m;
                model.IntegerField       = 11;

                //set
                proxy.SetEntry(model, new string[] {
                    "Status",
                    "DecimalNumberField",
                    "IntegerField"
                });

                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.New, model2.Status);
                Assert.AreEqual(3.14m, model2.DecimalNumberField);
                Assert.AreEqual(11, model2.IntegerField);
                Assert.AreEqual("should not changed", model2.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 7
0
        public void ARProxy_CreateEntry_datatype_datetime()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                DateTime dt      = DateTime.Now;
                string   entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    DateTimeField  = dt
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);

                Assert.AreEqual(dt.Year, ((DateTime)model.DateTimeField).Year);
                Assert.AreEqual(dt.Month, ((DateTime)model.DateTimeField).Month);
                Assert.AreEqual(dt.Day, ((DateTime)model.DateTimeField).Day);
                Assert.AreEqual(dt.Hour, ((DateTime)model.DateTimeField).Hour);
                Assert.AreEqual(dt.Minute, ((DateTime)model.DateTimeField).Minute);
                Assert.AreEqual(dt.Second, ((DateTime)model.DateTimeField).Second);

                model.DateTimeField = dt + new TimeSpan(1, 1, 1);
                proxy.SetEntry(model);

                Assert.AreEqual(dt.Year, ((DateTime)model.DateTimeField).Year);
                Assert.AreEqual(dt.Month, ((DateTime)model.DateTimeField).Month);
                Assert.AreEqual(dt.Day, ((DateTime)model.DateTimeField).Day);
                Assert.AreEqual(dt.Hour + 1, ((DateTime)model.DateTimeField).Hour);
                Assert.AreEqual(dt.Minute + 1, ((DateTime)model.DateTimeField).Minute);
                //the second may error in some case
                Assert.AreEqual(dt.Second + 1, ((DateTime)model.DateTimeField).Second);

                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 8
0
        public void ARProxy_CreateEntry_datatype_character_chinese_with_set()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);

            try
            {
                ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = TestCharacterFieldValueChinese,
                    IntegerField   = 3
                });
                Assert.AreNotEqual(null, entryId);

                //GetEntry
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(TestCharacterFieldValueChinese, model.CharacterField);
                model.CharacterField = TestCharacterFieldValueChinese + "Set Something";

                //SetEntry
                proxy.SetEntry(model);
                model = null;

                //GetAgain
                model = proxy.GetEntry(entryId);
                Assert.IsNotNull(model);
                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", model.CharacterField);
                Assert.AreEqual(3, model.IntegerField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 9
0
        public static void SetEntryList <TModel>(
            this ARProxy <TModel> proxy, string qualification, TModel model, params Expression <Func <TModel, object> >[] propertiesTobeUp)
            where TModel : ARBaseForm
        {
            if (propertiesTobeUp == null || propertiesTobeUp.Length == 0)
            {
                return;
            }
            ITypeMetaProvider <TModel> metaProvider = new ExpressionTypeMetaProvider <TModel>(propertiesTobeUp);

            ModelMeteData <TModel> MetaData = new ModelMeteData <TModel>();

            MetaData.FormName = metaProvider.GetFormNameFromModelType();

            MetaData.Model = model;
            var props = metaProvider.GetPropertyInfoes(BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance, null);

            MetaData.Properties = new List <PropertyAndField <TModel> >();

            foreach (var p in props)
            {
                if ((p.AccessLevel & ModelBinderAccessLevel.OnlyUnBind) == ModelBinderAccessLevel.OnlyUnBind)
                {
                    MetaData.Properties.Add(p);
                }
            }

            int            total   = -1;
            List <AREntry> entries = proxy.GetARServer().GetEntryList(MetaData.FormName, qualification, null, 0, null, ref total, null);

            foreach (var entry in entries)
            {
                string entryid = string.Join("|", entry.EntryIds.ToArray());
                MetaData.EntryId = entryid;
                proxy.SetEntry(MetaData);
            }
        }
Exemplo n.º 10
0
        public void ARProxy_CreateEntry_datatype_datetime()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    DateTimeField = dt
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);

                Assert.AreEqual(dt.Year, ((DateTime)model.DateTimeField).Year);
                Assert.AreEqual(dt.Month, ((DateTime)model.DateTimeField).Month);
                Assert.AreEqual(dt.Day, ((DateTime)model.DateTimeField).Day);
                Assert.AreEqual(dt.Hour, ((DateTime)model.DateTimeField).Hour);
                Assert.AreEqual(dt.Minute, ((DateTime)model.DateTimeField).Minute);
                Assert.AreEqual(dt.Second, ((DateTime)model.DateTimeField).Second);

                model.DateTimeField = dt + new TimeSpan(1, 1, 1);
                proxy.SetEntry(model);

                Assert.AreEqual(dt.Year, ((DateTime)model.DateTimeField).Year);
                Assert.AreEqual(dt.Month, ((DateTime)model.DateTimeField).Month);
                Assert.AreEqual(dt.Day, ((DateTime)model.DateTimeField).Day);
                Assert.AreEqual(dt.Hour + 1, ((DateTime)model.DateTimeField).Hour);
                Assert.AreEqual(dt.Minute + 1, ((DateTime)model.DateTimeField).Minute);
                //the second may error in some case
                Assert.AreEqual(dt.Second + 1, ((DateTime)model.DateTimeField).Second);

                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 11
0
        public void ARProxy_CreateEntry_datatype_int()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    IntegerField = 256
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(256, model.IntegerField);

                model.IntegerField = 512;
                proxy.SetEntry(model);

                Assert.AreEqual(512, model.IntegerField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 12
0
        public void ARProxy_CreateEntry_datatype_Real()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    RealNumberField = 3.14
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(3.14, model.RealNumberField);

                model.RealNumberField = 0.62;
                proxy.SetEntry(model);

                Assert.AreEqual(0.62, model.RealNumberField);

                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 13
0
        public void ARProxy_SetEntry_By_Properties_Ids()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                //Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                model.CharacterField = "don not want changed";
                model.Status = NRemedy_Test_Regular_Form.Status_Enum.New;
                model.DecimalNumberField = 3.14m;
                model.IntegerField = 11;

                List<ARFieldValue> up_fvs = new List<ARFieldValue>();

                up_fvs.Add(new ARFieldValue(TestDecimalFieldId, 3.14m, ARDataType.DATA_TYPE_DECIMAL));
                up_fvs.Add(new ARFieldValue(7u, NRemedy_Test_Regular_Form.Status_Enum.New, ARDataType.DATA_TYPE_ENUM));
                up_fvs.Add(new ARFieldValue(TestIntFieldId, 11, ARDataType.DATA_TYPE_INTEGER));

                //set
                proxy.SetEntry(entryId, up_fvs);

                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.New, model2.Status);
                Assert.AreEqual(3.14m, model2.DecimalNumberField);
                Assert.AreEqual(11, model2.IntegerField);
                Assert.AreEqual("should not changed", model2.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 14
0
        public void ARProxy_CreateEntry_datatype_Enum_NULL()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    Radio_Button_Field = null//
                });
                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                Assert.AreEqual(null, model.RealNumberField);//

                model.Status = NRemedy_Test_Regular_Form.Status_Enum.Rejected;
                model.Radio_Button_Field = NRemedy_Test_Regular_Form.Radio_Button_Field_Enum.First;//
                proxy.SetEntry(model);

                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Rejected, model.Status);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Radio_Button_Field_Enum.First, model.Radio_Button_Field);//
                //Assert.AreEqual(dt + new TimeSpan(1, 1, 1), model.DateTimeField);
                Assert.AreEqual("should not changed", model.CharacterField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 15
0
        public void ARProxy_CreateEntry_datatype_character_chinese_with_set()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {

                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = TestCharacterFieldValueChinese,
                    IntegerField = 3
                });
                Assert.AreNotEqual(null, entryId);

                //GetEntry
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                Assert.AreEqual(TestCharacterFieldValueChinese, model.CharacterField);
                model.CharacterField = TestCharacterFieldValueChinese + "Set Something";

                //SetEntry
                proxy.SetEntry(model);
                model = null;

                //GetAgain
                model = proxy.GetEntry(entryId);
                Assert.IsNotNull(model);
                Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", model.CharacterField);
                Assert.AreEqual(3, model.IntegerField);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);

            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 16
0
        public void ARProxy_Transacation_Simple_Rollback()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                context.TransactionBegin();
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed
                });
                Assert.AreEqual(string.Empty, entryId);
                //second call will failed
                List<ARFieldValue> up_fvs = new List<ARFieldValue>();
                up_fvs.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR));
                proxy.SetEntry("11111111111", up_fvs);

                var result = context.TransactionCommit();

                Assert.IsFalse(result.Success);
                Assert.AreEqual(2, result.ResultList.Count);

                Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[0].CallType);
                var entryid1 = result.ResultList[0].EntryId;
                //!!@@important
                //when create entry is not in trasaction, it will not cause warning 52 when the RequestID is in the fieldValueList
                //but in trasacation, this will cause warning 52.
                //this because trasaction actually means group the operations and send to AR when commit.AR may block the operaion,
                //even this is caused by warning
                Assert.IsNull(result.ResultList[0].Status);

                Assert.AreEqual(EntryCallType.BULK_ENTRY_SET, result.ResultList[1].CallType);
                Assert.IsNotNull(result.ResultList[1].Status);
                //item do not exist in the db
                Assert.AreEqual(302, result.ResultList[1].Status.MessageNumber);

            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }
Exemplo n.º 17
0
        public void ARProxy_SetEntry_By_Properties_Str()
        {
            ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd);
            try
            {
                ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context);
                DateTime dt = DateTime.Now;
                string entryId = proxy.CreateEntry(new NRemedy_Test_Regular_Form
                {
                    CharacterField = "should not changed",
                    Status = NRemedy_Test_Regular_Form.Status_Enum.Fixed,
                    DecimalNumberField = 3.13m,
                    IntegerField = 10
                }
                );

                Assert.AreNotEqual(null, entryId);
                NRemedy_Test_Regular_Form model = proxy.GetEntry(entryId);
                //Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.Fixed, model.Status);
                model.CharacterField = "don not want changed";
                model.Status = NRemedy_Test_Regular_Form.Status_Enum.New;
                model.DecimalNumberField = 3.14m;
                model.IntegerField = 11;

                //set
                proxy.SetEntry(model, new string[] {
                    "Status",
                    "DecimalNumberField",
                    "IntegerField"
                });

                NRemedy_Test_Regular_Form model2 = proxy.GetEntry(entryId);
                Assert.AreEqual(NRemedy_Test_Regular_Form.Status_Enum.New, model2.Status);
                Assert.AreEqual(3.14m, model2.DecimalNumberField);
                Assert.AreEqual(11, model2.IntegerField);
                Assert.AreEqual("should not changed", model2.CharacterField);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(null, ex);
            }
            finally
            {
                context.Dispose();
            }
        }