public void ARSession_Transcation_Create_Set_Success() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValue, ARDataType.DATA_TYPE_CHAR)); var entrytobeset = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //begin Transaction session.BeginBulkEntryTransaction(); //create session.CreateEntry(TestRegularFormName, valuelist.ToArray()); List <string> entryid = new List <string>() { entrytobeset }; List <ARFieldValue> up_fvs = new List <ARFieldValue>(); up_fvs.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR)); //let the second call success too session.SetEntry(TestRegularFormName, entryid.ToArray(), up_fvs.ToArray()); //commit var result = session.EndBulkEntryTransaction(1); Assert.IsTrue(result.Success); Assert.AreEqual(2, result.ResultList.Count); Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[0].CallType); var entryid1 = result.ResultList[0].EntryId; Assert.IsNull(result.ResultList[0].Status); Assert.AreEqual(EntryCallType.BULK_ENTRY_SET, result.ResultList[1].CallType); Assert.IsNull(result.ResultList[1].Status); List <string> entryIds = new List <string>(); entryIds.Add(entryid1); List <uint> fieldIds = new List <uint>(); fieldIds.Add((uint)TestCharacterFieldId); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(TestCharacterFieldValue, Entry.First(f => f.FieldId == TestCharacterFieldId).Value.ToString()); List <ARFieldValue> Entry2UP = session.GetEntry(TestRegularFormName, entryid.ToArray(), fieldIds.ToArray()); Assert.AreEqual(TestCharacterFieldValueChinese, Entry2UP.First(f => f.FieldId == TestCharacterFieldId).Value.ToString()); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_Enum_Status_NULL() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(TestRadioFieldId, null, ARDataType.DATA_TYPE_ENUM));//set null for the status character string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List <string> entryIds = new List <string>(); entryIds.Add(entryid); List <uint> fieldIds = new List <uint>(); fieldIds.Add(TestRadioFieldId); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_NULL, Entry[0].DataType); Assert.AreEqual(TestRadioFieldId, Entry[0].FieldId); Assert.AreEqual(null, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_DateTime() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List <ARFieldValue> valuelist = new List <ARFieldValue>(); //convert datetime to second from 1970-1-1 TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1); int secondtoNow = (int)ts.TotalSeconds; valuelist.Add(new ARFieldValue(TestDateTimeFieldId, secondtoNow, ARDataType.DATA_TYPE_TIME)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List <string> entryIds = new List <string>(); entryIds.Add(entryid); List <uint> fieldIds = new List <uint>(); fieldIds.Add((uint)TestDateTimeFieldId); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME, Entry[0].DataType); Assert.AreEqual(TestDateTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestDateTimeFieldId, secondtoNow + 100, ARDataType.DATA_TYPE_TIME)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME, Entry[0].DataType); Assert.AreEqual(TestDateTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow + 100, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_Time() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List <ARFieldValue> valuelist = new List <ARFieldValue>(); DateTime dt = DateTime.Now; int secondtoNow = dt.Hour * 3600 + dt.Minute * 60 + dt.Second; valuelist.Add(new ARFieldValue(TestTimeFieldId, secondtoNow, ARDataType.DATA_TYPE_TIME_OF_DAY)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List <string> entryIds = new List <string>(); entryIds.Add(entryid); List <uint> fieldIds = new List <uint>(); fieldIds.Add((uint)TestTimeFieldId); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME_OF_DAY, Entry[0].DataType); Assert.AreEqual(TestTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestTimeFieldId, secondtoNow + 100, ARDataType.DATA_TYPE_TIME_OF_DAY)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME_OF_DAY, Entry[0].DataType); Assert.AreEqual(TestTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow + 100, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_character_chinese_with_set() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR)); string entryId = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); Assert.AreNotEqual(null, entryId); //GetEntry List <string> IdList = new List <string>(); IdList.Add(entryId); List <uint> FIdList = new List <uint>(); FIdList.Add((uint)TestCharacterFieldId); List <ARFieldValue> fieldsReturns = session.GetEntry(TestRegularFormName, IdList.ToArray(), FIdList.ToArray()); Assert.AreEqual(1, fieldsReturns.Count); Assert.AreEqual(ARDataType.DATA_TYPE_CHAR, fieldsReturns[0].DataType); Assert.AreEqual(TestCharacterFieldId, fieldsReturns[0].FieldId); Assert.AreEqual(TestCharacterFieldValueChinese, fieldsReturns[0].Value.ToString()); //SetEntry fieldsReturns.Clear(); fieldsReturns.Add(new ARFieldValue(TestCharacterFieldId, (object)(TestCharacterFieldValueChinese + "Set Something"), ARDataType.DATA_TYPE_CHAR)); session.SetEntry(TestRegularFormName, IdList.ToArray(), fieldsReturns.ToArray()); //GetAgain fieldsReturns.Clear(); fieldsReturns = session.GetEntry(TestRegularFormName, IdList.ToArray(), FIdList.ToArray()); Assert.AreEqual(1, fieldsReturns.Count); Assert.AreEqual(ARDataType.DATA_TYPE_CHAR, fieldsReturns[0].DataType); Assert.AreEqual(TestCharacterFieldId, fieldsReturns[0].FieldId); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", fieldsReturns[0].Value.ToString()); } catch (Exception ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_character_chinese_with_delete() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR)); string entryId = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); Assert.AreNotEqual(null, entryId); //GetEntry List<string> IdList = new List<string>(); IdList.Add(entryId); List<uint> FIdList = new List<uint>(); FIdList.Add((uint)TestCharacterFieldId); List<ARFieldValue> fieldsReturns = session.GetEntry(TestRegularFormName, IdList.ToArray(), FIdList.ToArray()); Assert.AreEqual(1, fieldsReturns.Count); Assert.AreEqual(ARDataType.DATA_TYPE_CHAR, fieldsReturns[0].DataType); Assert.AreEqual(TestCharacterFieldId, fieldsReturns[0].FieldId); Assert.AreEqual(TestCharacterFieldValueChinese, fieldsReturns[0].Value.ToString()); //DeleteEntry session.DeleteEntry(TestRegularFormName, IdList.ToArray()); //GetAgain fieldsReturns.Clear(); fieldsReturns = session.GetEntry(TestRegularFormName, IdList.ToArray(), FIdList.ToArray()); Assert.IsNull(fieldsReturns); //DeleteAgain session.DeleteEntry(TestRegularFormName, IdList.ToArray()); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_Decimal() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(TestDecimalFieldId, 3.14, ARDataType.DATA_TYPE_DECIMAL)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List <string> entryIds = new List <string>(); entryIds.Add(entryid); List <uint> fieldIds = new List <uint>(); fieldIds.Add((uint)TestDecimalFieldId); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_DECIMAL, Entry[0].DataType); Assert.AreEqual(TestDecimalFieldId, Entry[0].FieldId); Assert.AreEqual(3.14, Convert.ToDouble(Entry[0].Value)); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestDecimalFieldId, 0.61, ARDataType.DATA_TYPE_DECIMAL)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_DECIMAL, Entry[0].DataType); Assert.AreEqual(TestDecimalFieldId, Entry[0].FieldId); Assert.AreEqual(0.61, Convert.ToDouble(Entry[0].Value)); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_Enum_Status() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(7, 1, ARDataType.DATA_TYPE_ENUM)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List <string> entryIds = new List <string>(); entryIds.Add(entryid); List <uint> fieldIds = new List <uint>(); fieldIds.Add(7); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_ENUM, Entry[0].DataType); Assert.AreEqual(7, (int)Entry[0].FieldId); Assert.AreEqual((UInt32)1, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(7, 2, ARDataType.DATA_TYPE_ENUM)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_ENUM, Entry[0].DataType); Assert.AreEqual(7, (int)Entry[0].FieldId); Assert.AreEqual((UInt32)2, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void ARSession_Transcation_Create_Create_Failed() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValue, ARDataType.DATA_TYPE_CHAR)); //begin Transaction session.BeginBulkEntryTransaction(); //create session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //let the second call failed valuelist.Add(new ARFieldValue(7u, null, ARDataType.DATA_TYPE_NULL)); session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //commit var result = session.EndBulkEntryTransaction(1); 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; Assert.IsNull(result.ResultList[0].Status); Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[1].CallType); Assert.AreEqual(null, result.ResultList[1].EntryId); Assert.IsNotNull(result.ResultList[1].Status); Assert.AreEqual(326, result.ResultList[1].Status.MessageNumber); List <string> entryIds = new List <string>(); entryIds.Add(entryid1); List <uint> fieldIds = new List <uint>(); fieldIds.Add((uint)TestCharacterFieldId); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.IsNull(Entry); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void ARSession_Transcation_Create_Create_Failed() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValue, ARDataType.DATA_TYPE_CHAR)); //begin Transaction session.BeginBulkEntryTransaction(); //create session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //let the second call failed valuelist.Add(new ARFieldValue(7u, null, ARDataType.DATA_TYPE_NULL)); session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //commit var result = session.EndBulkEntryTransaction(1); 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; Assert.IsNull(result.ResultList[0].Status); Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[1].CallType); Assert.AreEqual(null, result.ResultList[1].EntryId); Assert.IsNotNull(result.ResultList[1].Status); Assert.AreEqual(326, result.ResultList[1].Status.MessageNumber); List<string> entryIds = new List<string>(); entryIds.Add(entryid1); List<uint> fieldIds = new List<uint>(); fieldIds.Add((uint)TestCharacterFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.IsNull(Entry); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void Impersonat_Create_Test() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List <ARFieldValue> valuelist = new List <ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValue, ARDataType.DATA_TYPE_CHAR)); session.SetImpersonatedUser(ImpersonatedChineseUser); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); List <string> entryIds = new List <string>(); entryIds.Add(entryid); List <uint> fieldIds = new List <uint>(); fieldIds.Add((uint)TestCharacterFieldId); fieldIds.Add(2); fieldIds.Add(5); session.SetImpersonatedUser(null); List <ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(TestCharacterFieldValue, Entry.First(f => f.FieldId == TestCharacterFieldId).Value.ToString()); Assert.AreEqual(ImpersonatedChineseUser, Entry.First(f => f.FieldId == 2).Value.ToString()); Assert.AreEqual(ImpersonatedChineseUser, Entry.First(f => f.FieldId == 5).Value.ToString()); } catch (ARException ex) { Assert.AreEqual(null, ex); } finally { session.LogOut(); } }
public void SetEntry_datatype_Enum_Status_NULL() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(TestRadioFieldId, 1, ARDataType.DATA_TYPE_ENUM)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List<string> entryIds = new List<string>(); entryIds.Add(entryid); List<uint> fieldIds = new List<uint>(); fieldIds.Add(TestRadioFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_ENUM, Entry[0].DataType); Assert.AreEqual(TestRadioFieldId, Entry[0].FieldId); Assert.AreEqual((UInt32)1, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestRadioFieldId, null, ARDataType.DATA_TYPE_ENUM)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_NULL, Entry[0].DataType); Assert.AreEqual(TestRadioFieldId, Entry[0].FieldId); Assert.AreEqual(null, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void ARSession_Transcation_Create_Set_Success() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValue, ARDataType.DATA_TYPE_CHAR)); var entrytobeset = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //begin Transaction session.BeginBulkEntryTransaction(); //create session.CreateEntry(TestRegularFormName, valuelist.ToArray()); List<string> entryid = new List<string>() { entrytobeset }; List<ARFieldValue> up_fvs = new List<ARFieldValue>(); up_fvs.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR)); //let the second call success too session.SetEntry(TestRegularFormName, entryid.ToArray(), up_fvs.ToArray()); //commit var result = session.EndBulkEntryTransaction(1); Assert.IsTrue(result.Success); Assert.AreEqual(2, result.ResultList.Count); Assert.AreEqual(EntryCallType.BULK_ENTRY_CREATE, result.ResultList[0].CallType); var entryid1 = result.ResultList[0].EntryId; Assert.IsNull(result.ResultList[0].Status); Assert.AreEqual(EntryCallType.BULK_ENTRY_SET, result.ResultList[1].CallType); Assert.IsNull(result.ResultList[1].Status); List<string> entryIds = new List<string>(); entryIds.Add(entryid1); List<uint> fieldIds = new List<uint>(); fieldIds.Add((uint)TestCharacterFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(TestCharacterFieldValue, Entry.First(f => f.FieldId == TestCharacterFieldId).Value.ToString()); List<ARFieldValue> Entry2UP = session.GetEntry(TestRegularFormName, entryid.ToArray(), fieldIds.ToArray()); Assert.AreEqual(TestCharacterFieldValueChinese, Entry2UP.First(f => f.FieldId == TestCharacterFieldId).Value.ToString()); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_Real() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(TestRealFieldId, 3.1415926, ARDataType.DATA_TYPE_REAL)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List<string> entryIds = new List<string>(); entryIds.Add(entryid); List<uint> fieldIds = new List<uint>(); fieldIds.Add((uint)TestRealFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_REAL, Entry[0].DataType); Assert.AreEqual(TestRealFieldId, Entry[0].FieldId); Assert.AreEqual(3.1415926, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestRealFieldId, 0.618, ARDataType.DATA_TYPE_REAL)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_REAL, Entry[0].DataType); Assert.AreEqual(TestRealFieldId, Entry[0].FieldId); Assert.AreEqual(0.618, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_datatype_DateTime() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List<ARFieldValue> valuelist = new List<ARFieldValue>(); //convert datetime to second from 1970-1-1 TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1); int secondtoNow = (int)ts.TotalSeconds; valuelist.Add(new ARFieldValue(TestDateTimeFieldId, secondtoNow, ARDataType.DATA_TYPE_TIME)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List<string> entryIds = new List<string>(); entryIds.Add(entryid); List<uint> fieldIds = new List<uint>(); fieldIds.Add((uint)TestDateTimeFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME, Entry[0].DataType); Assert.AreEqual(TestDateTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestDateTimeFieldId, secondtoNow+100, ARDataType.DATA_TYPE_TIME)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME, Entry[0].DataType); Assert.AreEqual(TestDateTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow + 100, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public List <ARFieldValue> GetEntry(string form, string entryId, List <uint> FieldIdList) { CheckSessionNull(); return(SessionInstance.GetEntry(form, entryId.Split('|'), FieldIdList.ToArray())); }
public void CreateEntry_datatype_Time() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); //Create List<ARFieldValue> valuelist = new List<ARFieldValue>(); DateTime dt = DateTime.Now; int secondtoNow = dt.Hour*3600 + dt.Minute*60 + dt.Second; valuelist.Add(new ARFieldValue(TestTimeFieldId, secondtoNow, ARDataType.DATA_TYPE_TIME_OF_DAY)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); //Get for Assert List<string> entryIds = new List<string>(); entryIds.Add(entryid); List<uint> fieldIds = new List<uint>(); fieldIds.Add((uint)TestTimeFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME_OF_DAY, Entry[0].DataType); Assert.AreEqual(TestTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow, Entry[0].Value); //Set valuelist.Clear(); valuelist.Add(new ARFieldValue(TestTimeFieldId, secondtoNow + 100, ARDataType.DATA_TYPE_TIME_OF_DAY)); session.SetEntry(TestRegularFormName, entryIds.ToArray(), valuelist.ToArray()); //Get for Assert Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, Entry.Count); Assert.AreEqual(ARDataType.DATA_TYPE_TIME_OF_DAY, Entry[0].DataType); Assert.AreEqual(TestTimeFieldId, Entry[0].FieldId); Assert.AreEqual(secondtoNow + 100, Entry[0].Value); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void CreateEntry_simple_success() { ARSession session = new ARSession(); try{ session.Login(TestServer, TestAdmin, TestAdminPwd); List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(TestCharacterFieldId,(object)TestCharacterFieldValue,ARDataType.DATA_TYPE_CHAR)); string entryid = session.CreateEntry(TestRegularFormName, valuelist.ToArray()); List<string> entryIds = new List<string>(); entryIds.Add(entryid); List<uint> fieldIds = new List<uint>(); fieldIds.Add((uint)TestCharacterFieldId); List<ARFieldValue> Entry = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(TestCharacterFieldValue, Entry.First(f => f.FieldId == TestCharacterFieldId).Value.ToString()); } catch(ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void ARSession_Create_Entry_with_Att_01() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); /* create entry with att and get it for assert */ string testStr = "先假设这就是附件内容"; byte[] buff = Encoding.UTF8.GetBytes(testStr); List <ARFieldValue> fvl = new List <ARFieldValue>(); fvl.Add(new ARFieldValue { FieldId = attchFId, DataType = ARDataType.DATA_TYPE_ATTACH, Value = new ARAttachment { AttchmentName = "附件.txt", Buff = buff } }); fvl.Add(new ARFieldValue(TestCharacterFieldId, "Attachment Flag", ARDataType.DATA_TYPE_CHAR)); string entryId = session.CreateEntry(TestRegularFormName, fvl.ToArray()); Assert.IsNotNull(entryId); List <uint> fieldIds = new List <uint>(); fieldIds.Add(attchFId); List <string> entryIds = new List <string>(); entryIds.Add(entryId); List <ARFieldValue> arfvl = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, arfvl.Count); Assert.IsTrue(arfvl[0].Value is ARAttachment); ARAttachment att = (ARAttachment)arfvl[0].Value; String rStr = Encoding.UTF8.GetString(att.Buff); Assert.AreEqual( testStr, rStr); byte[] setByte = Encoding.UTF8.GetBytes(testStr + " after set."); List <ARFieldValue> set_arfvl = new List <ARFieldValue>(); set_arfvl.Add(new ARFieldValue { DataType = ARDataType.DATA_TYPE_ATTACH, FieldId = attchFId, Value = new ARAttachment { AttchmentName = "ARSession_Create_Entry_with_Att_01.txt", Buff = setByte } }); session.SetEntry(TestRegularFormName, entryIds.ToArray(), set_arfvl.ToArray()); /* Get blob from the entry */ byte[] buffer = session.GetBLOB(TestRegularFormName, entryIds.ToArray(), attchFId); String rStr2 = Encoding.UTF8.GetString(buffer); Assert.AreEqual( testStr + " after set.", rStr2); /* Get entry list */ int total = -1; var listEntry = session.GetEntryList(TestRegularFormName, "'Character Field' = \"Attachment Flag\"" , fieldIds.ToArray(), null, null, ref total, null); foreach (var l in listEntry) { Assert.IsTrue(l.FieldValues[0].Value is ARAttachment); ARAttachment att2 = (ARAttachment)l.FieldValues[0].Value; String rStr3 = Encoding.UTF8.GetString(att2.Buff); Assert.AreEqual( testStr + " after set.", rStr3); } } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void ARSession_Create_Entry_with_Att_01() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); /* create entry with att and get it for assert */ string testStr = "先假设这就是附件内容"; byte[] buff = Encoding.UTF8.GetBytes(testStr); List<ARFieldValue> fvl = new List<ARFieldValue>(); fvl.Add(new ARFieldValue { FieldId = attchFId, DataType = ARDataType.DATA_TYPE_ATTACH, Value = new ARAttachment { AttchmentName = "附件.txt", Buff = buff } }); fvl.Add(new ARFieldValue(TestCharacterFieldId, "Attachment Flag", ARDataType.DATA_TYPE_CHAR)); string entryId = session.CreateEntry(TestRegularFormName, fvl.ToArray()); Assert.IsNotNull(entryId); List<uint> fieldIds = new List<uint>(); fieldIds.Add(attchFId); List<string> entryIds = new List<string>(); entryIds.Add(entryId); List<ARFieldValue> arfvl = session.GetEntry(TestRegularFormName, entryIds.ToArray(), fieldIds.ToArray()); Assert.AreEqual(1, arfvl.Count); Assert.IsTrue(arfvl[0].Value is ARAttachment); ARAttachment att = (ARAttachment)arfvl[0].Value; String rStr = Encoding.UTF8.GetString(att.Buff); Assert.AreEqual( testStr, rStr); byte[] setByte = Encoding.UTF8.GetBytes(testStr + " after set."); List<ARFieldValue> set_arfvl = new List<ARFieldValue>(); set_arfvl.Add(new ARFieldValue{ DataType = ARDataType.DATA_TYPE_ATTACH, FieldId = attchFId, Value = new ARAttachment { AttchmentName = "ARSession_Create_Entry_with_Att_01.txt", Buff = setByte } }); session.SetEntry(TestRegularFormName, entryIds.ToArray(), set_arfvl.ToArray()); /* Get blob from the entry */ byte[] buffer = session.GetBLOB(TestRegularFormName, entryIds.ToArray(), attchFId); String rStr2 = Encoding.UTF8.GetString(buffer); Assert.AreEqual( testStr + " after set.", rStr2); /* Get entry list */ int total = -1; var listEntry = session.GetEntryList(TestRegularFormName, "'Character Field' = \"Attachment Flag\"" , fieldIds.ToArray(), null, null, ref total, null); foreach (var l in listEntry) { Assert.IsTrue(l.FieldValues[0].Value is ARAttachment); ARAttachment att2 = (ARAttachment)l.FieldValues[0].Value; String rStr3 = Encoding.UTF8.GetString(att2.Buff); Assert.AreEqual( testStr + " after set.", rStr3); } } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }