/// <summary> /// Uninitialize and clean up AR Foundation components. /// </summary> private void UninitializeARFoundation() { if (!isInitialized) { return; } if (!preExistingArSessionOriginObject && (arSessionOriginObject != null)) { UnityObjectExtensions.DestroyObject(trackedPoseDriver); trackedPoseDriver = null; UnityObjectExtensions.DestroyObject(arCameraBackground); arCameraBackground = null; UnityObjectExtensions.DestroyObject(arCameraManager); arCameraManager = null; UnityObjectExtensions.DestroyObject(arSessionOrigin); arSessionOrigin = null; } if (!preExistingArSessionObject && (arSessionObject != null)) { UnityObjectExtensions.DestroyObject(arInputManager); arInputManager = null; UnityObjectExtensions.DestroyObject(arSession); arSession = null; UnityObjectExtensions.DestroyObject(arSessionObject); arSessionObject = null; } isInitialized = false; }
IEnumerator Install() { SetInstallButtonActive(false); if (ARSession.state == ARSessionState.NeedsInstall) { Log("Attempting install..."); yield return(ARSession.Install()); if (ARSession.state == ARSessionState.NeedsInstall) { Log("The software update failed, or you declined the update."); SetInstallButtonActive(true); } else if (ARSession.state == ARSessionState.Ready) { // Log("Success! Starting AR session..."); m_Session.enabled = true; } } else { Log("Error: ARSession does not require install."); } }
public override void InterruptionEnded(ARSession session) { if (arkit.TryGetTarget(out var ap) && ap.Application.IsActive) { Urho.Application.InvokeOnMain(() => ap.OnInterruptionEnded()); } }
public override void DidRemoveAnchors(ARSession session, ARAnchor[] anchors) { if (arkit.TryGetTarget(out var ap) && ap.Application.IsActive) { Urho.Application.InvokeOnMain(() => ap.OnDidRemoveAnchors(anchors)); } }
private void Awake() { session = FindObjectOfType <ARSession>(); mapWorker = FindObjectOfType <SparseSpatialMapWorkerFrameFilter>(); videoCamera = session.GetComponentInChildren <VideoCameraDevice>(); #if UNITY_EDITOR GameObject.Find("EasyAR_SparseSpatialMapWorker").SetActive(false); #endif PropDragger.CreateObject += (gameObj) => { if (gameObj) { gameObj.transform.parent = mapData.Controller.transform; mapData.Props.Add(gameObj); } }; PropDragger.DeleteObject += (gameObj) => { if (gameObj) { mapData.Props.Remove(gameObj); } }; }
public override void DidFail(ARSession session, Foundation.NSError error) { if (arkit.TryGetTarget(out var ap) && ap.Application.IsActive) { Urho.Application.InvokeOnMain(() => ap.OnDidFail(error)); } }
public override void DidUpdateAnchors(ARSession session, ARAnchor[] anchors) { if (arkitApp.TryGetTarget(out var ap)) { Urho.Application.InvokeOnMain(() => ap.DidUpdateAnchors(anchors)); } }
private IEnumerator Check() { if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { UnsupportTip.SetActive(true); UnsupportTipBg.SetActive(true); CloseArBtn.SetActive(false); } else { if (CheckPosAvailable()) { arSession.enabled = true; PlaneManager.Instance.IsStartScan = true; } else { NotLocateTip.SetActive(true); UnsupportTipBg.SetActive(true); CloseArBtn.SetActive(false); } } }
public void Update() { _AppQuitOnEscape(); AsyncTask.Update(); //This function must be called before other Components' Update to ensure the accuracy of AREngine ARSession.Update(); }
private static bool ConfiguredForARF(WorldLockingContext context) { #if WLT_ARFOUNDATION_PRESENT ARSession session = GameObject.FindObjectOfType <ARSession>(); ARSessionOrigin sessionOrigin = GameObject.FindObjectOfType <ARSessionOrigin>(); if (session != null && sessionOrigin == null) { Debug.LogError($"Found ARSession on {session.name}, but no ARSessionOrigin. Check ARFoundation configuration."); } if (session == null && sessionOrigin != null) { Debug.LogError($"Found ARSessionOrigin on {sessionOrigin.name}, but no ARSession. Check ARFoundation configuration."); } if (session != null && sessionOrigin != null) { var sharedSettings = context.SharedSettings; sharedSettings.anchorSettings.anchorSubsystem = AnchorSettings.AnchorSubsystem.ARFoundation; sharedSettings.anchorSettings.ARSessionSource = session.gameObject; sharedSettings.anchorSettings.ARSessionOriginSource = sessionOrigin.gameObject; return(true); } #endif // WLT_ARFOUNDATION_PRESENT return(false); }
private void CameraDidChangeTrackingState(ARSession session, ARCamera camera) { var message = string.Empty; // Inform the user of their camera tracking state. switch (camera.TrackingState) { case ARTrackingState.NotAvailable: message = "Tracking unavailable"; break; case ARTrackingState.Limited: switch (camera.TrackingStateReason) { case ARTrackingStateReason.ExcessiveMotion: message = "Tracking limited - Too much camera movement"; break; case ARTrackingStateReason.InsufficientFeatures: message = "Tracking limited - Not enough surface detail"; break; case ARTrackingStateReason.Initializing: message = "Initializing AR Session"; break; } break; case ARTrackingState.Normal: message = "Tracking normal"; break; } this.sessionInfoLabel.Text = message; }
public void OnApplicationPause(bool isPaused) { if (isPaused) { ARSession.Pause(); } else { if (!isSessionCreated) { Init(); } if (isErrorHappendWhenInit) { return; } try { ARSession.Resume(); } catch (ARCameraPermissionDeniedException e) { ARDebug.LogError("camera permission is denied"); errorMessage = "This app require camera permission"; Log(); Invoke("_DoQuit", 0.5f); } } }
public void GetEntryListStatictisc_count_noqulifier_group_success() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<UInt32> groupIds = new List<UInt32>(); groupIds.Add(TestCharacterFieldId); var retlist = session.GetListEntryStatictisc( TestRegularFormName, null, ARStatictisc.STAT_OP_COUNT, null, groupIds.ToArray() ); Assert.AreEqual(3, retlist.Count); Dictionary<String, int> assertTable = new Dictionary<string, int>(); assertTable.Add("Hello Remedy", 7); assertTable.Add("你好 RemedySet Something", 2); assertTable.Add("你好 Remedy", 9); Assert.AreEqual(assertTable[retlist[0].GroupByValues[0].ToString()], Convert.ToInt32(retlist[0].Statictisc)); Assert.AreEqual(assertTable[retlist[1].GroupByValues[0].ToString()], Convert.ToInt32(retlist[1].Statictisc)); Assert.AreEqual(assertTable[retlist[2].GroupByValues[0].ToString()], Convert.ToInt32(retlist[2].Statictisc)); } catch (Exception ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public static void Cleanup() { //cleanup the user which has been created in Initialize ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List <uint> fieldIds = new List <uint>(); fieldIds.Add(1u); int total = -1; var entry = session.GetEntryList("User", "'101'=\"周平\"", fieldIds.ToArray(), null, null, ref total, null); if (entry != null || entry.Count != 0) { foreach (var e in entry) { session.DeleteEntry("User", e.EntryIds.ToArray()); } } } finally { session.LogOut(); } }
public static void Initialize(TestContext context) { ARSession session = new ARSession(); try { session.Login(TestServer,TestAdmin,TestAdminPwd); int totalCount = -1; List<AREntry> allentries = session.GetEntryList( TestRegularFormName, null, null, null, null, ref totalCount, null); foreach (AREntry entry in allentries) { session.DeleteEntry(TestRegularFormName,entry.EntryIds.ToArray()); } } catch (ARException ex) { } finally { session.LogOut(); } }
public void Run(bool runEngineFramesInArkitCallbacks = true) { if (Camera == null) { throw new InvalidOperationException("Camera was not set."); } if (runEngineFramesInArkitCallbacks && !Application.Options.DelayedStart) { throw new InvalidOperationException("ApplicationOptions.DelayedStart should be true if runEngineFramesInArkitCallbacks flag is set"); } arSessionDelegate = new UrhoARSessionDelegate(this, runEngineFramesInArkitCallbacks); ARSession = new ARSession { Delegate = arSessionDelegate }; ARConfiguration = ARConfiguration ?? new ARWorldTrackingConfiguration(); ARConfiguration.LightEstimationEnabled = true; ARSession.Run(ARConfiguration, ARSessionRunOptions.RemoveExistingAnchors); if ((Orientation == UIInterfaceOrientation.LandscapeRight || Orientation == UIInterfaceOrientation.LandscapeLeft) && ARConfiguration is ARFaceTrackingConfiguration) { throw new Exception("ARFaceTrackingConfiguration in landscape is not supported"); } }
IEnumerator Start() { arSession.enabled = false; if (ARSession.state == ARSessionState.None || ARSession.state == ARSessionState.CheckingAvailability) { yield return(ARSession.CheckAvailability()); } else if (ARSession.state == ARSessionState.Unsupported) { this.OnFailARSession?.Invoke(); yield break; } if (ARSession.state == ARSessionState.NeedsInstall) { this.OnRequestARLibInstall?.Invoke(); yield return(ARSession.Install()); } if (ARSession.state == ARSessionState.Ready) { this.OnReadyAR?.Invoke(); arSession.enabled = true; } yield return(null); }
internal void SessionDelegate_InterruptionEnded(ARSession session) { UserFeedback.UnblurBackground(); Session.Run(StandardConfiguration(), ARSessionRunOptions.ResetTracking | ARSessionRunOptions.RemoveExistingAnchors); RestartExperience(this); UserFeedback.ShowMessage("RESETTING SESSION"); }
public void DidUpdateAnchors(ARSession session, ARAnchor[] anchors) { if (anchors.First() is ARFaceAnchor faceAnchor) { //currentFaceAnchor = faceAnchor; //System.Console.WriteLine(""); //System.Console.WriteLine("New matrix"); //System.Console.WriteLine("{0}.{0}.{0}.{0}", faceAnchor.Transform.M11, // faceAnchor.Transform.M12, // faceAnchor.Transform.M13, // faceAnchor.Transform.M14); //System.Console.WriteLine("{0}.{0}.{0}.{0}", faceAnchor.Transform.M21, // faceAnchor.Transform.M22, // faceAnchor.Transform.M23, // faceAnchor.Transform.M24); //System.Console.WriteLine("{0}.{0}.{0}.{0}", faceAnchor.Transform.M31, // faceAnchor.Transform.M32, // faceAnchor.Transform.M33, // faceAnchor.Transform.M34); //System.Console.WriteLine("{0}.{0}.{0}.{0}", faceAnchor.Transform.M41, //faceAnchor.Transform.M42, //faceAnchor.Transform.M43, //faceAnchor.Transform.M44); System.Console.WriteLine("Updated anchor"); } //System.Console.WriteLine("Updated Anchors"); }
void AttachRefrences() { if (m_ARSession == null) { m_ARSession = FindObjectOfType <ARSession>(); } if (m_SessionOrigin == null) { m_SessionOrigin = FindObjectOfType <ARSessionOrigin>(); } if (m_AnchorManager == null) { m_AnchorManager = FindObjectOfType <ARAnchorManager>(); if (m_AnchorManager == null && m_SessionOrigin != null) { m_AnchorManager = m_SessionOrigin.gameObject.AddComponent <ARAnchorManager>(); } } if (m_MarkerController == null) { m_MarkerController = FindObjectOfType <MarkerController>(); m_MarkerController.MarkerAnchorer = this; } }
public override void CameraDidChangeTrackingState(ARSession session, ARCamera camera) { if (arkit.TryGetTarget(out var ap) && ap.Application.IsActive) { Urho.Application.InvokeOnMain(() => ap.OnCameraDidChangeTrackingState(camera)); } }
public override void DidUpdateFrame(ARSession session, ARFrame frame) { if (arkitApp.TryGetTarget(out var ap)) { Urho.Application.InvokeOnMain(() => ap.ProcessARFrame(session, frame)); } }
public override void DidOutputAudioSampleBuffer(ARSession session, CMSampleBuffer audioSampleBuffer) { if (arkit.TryGetTarget(out var ap) && ap.Application.IsActive) { Urho.Application.InvokeOnMain(() => ap.OnDidOutputAudioSampleBuffer(audioSampleBuffer)); } }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); //ARWorldTrackingSessionConfiguration config;// = new A //ARWorldTrackingSessionConfiguration ARWorldTrackingConfiguration config = new ARWorldTrackingConfiguration(); //ARWorldTrackingSessionConfiguration config = new ARWorldTrackingSessionConfiguration{ //}; config.PlaneDetection = ARPlaneDetection.Horizontal; arSessionConfig = config; arSessionConfig.LightEstimationEnabled = true; arSession = new ARSession(); arSCNView = new ARSCNView(); arSCNView.Frame = View.Bounds; arSCNView.Session = arSession; arSCNView.AutomaticallyUpdatesLighting = true; View.AddSubview(this.arSCNView); arSession.Run(this.arSessionConfig, ARSessionRunOptions.RemoveExistingAnchors); var scene = SCNScene.FromFile("Models.scnassets/chair/chair.scn"); SCNNode node = scene.RootNode.ChildNodes[0]; node.Position = new SCNVector3(0, -1, -1); arSCNView.Scene.RootNode.AddNodes(node); }
IEnumerator Start() { if (!renderStreaming.runOnAwake) { renderStreaming.Run( hardwareEncoder: RenderStreamingSettings.EnableHWCodec, signaling: RenderStreamingSettings.Signaling); } if ((ARSession.state == ARSessionState.None) || (ARSession.state == ARSessionState.CheckingAvailability)) { yield return(ARSession.CheckAvailability()); } if (ARSession.state == ARSessionState.Unsupported) { // Start some fallback experience for unsupported devices Debug.LogError("AR foundation is not supported on this device."); } else { // Start the AR session session.enabled = true; } }
private void Awake() { _arSession = GetComponentInChildren <ARSession>(true); _arTrackedImageManager = GetComponentInChildren <ARTrackedImageManager>(true); _camera = GetComponentInChildren <Camera>(true); Origin = _camera.transform.parent; }
public void DidRemoveAnchors(ARSession session, ARAnchor[] anchors) { if (anchors.First() is ARFaceAnchor faceAnchor) { currentFaceAnchor = null; System.Console.WriteLine("Anchor removed"); } }
public NetworkManageriOS(ARSession arSession) { // todo: clean these up UnityMCSessionNativeInterface.GetMcSessionNativeInterface().DataReceivedEvent += OnDataReceivedEvent; UnityMCSessionNativeInterface.GetMcSessionNativeInterface().StateChangedEvent += OnStateChangedEvent; _arSession = arSession; }
// Start is called before the first frame update void Start() { mainCamera = Camera.main; arCameraManager = FindObjectOfType <ARCameraManager>(); arSession = FindObjectOfType <ARSession>(); // arAnchorManager = FindObjectOfType<ARAnchorManager>(); aRReferencePointManager = FindObjectOfType <ARReferencePointManager>(); }
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 override void DidUpdateFrame(ARSession session, ARFrame frame) { if (arkitApp.TryGetTarget(out var ap)) { ap.ProcessARFrame(session, frame); //we use ApplicationOptions.DelayedStart=true: ap.Engine.RunFrame(); } }
public void UpdateARSession(ARSession session) { if (session == null) { ResetARCoreSession(); } m_ARKitSession = session; }
public static void Initialize(TestContext context) { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); int totalCount = -1; List<AREntry> allentries = session.GetEntryList( TestRegularFormName, null, null, null, null, ref totalCount, null); foreach (AREntry entry in allentries) { session.DeleteEntry(TestRegularFormName, entry.EntryIds.ToArray()); } //add test data List<ARFieldValue> fv1 = new List<ARFieldValue>(); fv1.Add(new ARFieldValue(TestCharacterFieldId,(object)TestCharacterFieldValue,ARDataType.DATA_TYPE_CHAR)); fv1.Add(new ARFieldValue(TestIntFieldId,1,ARDataType.DATA_TYPE_INTEGER)); List<ARFieldValue> fv2 = new List<ARFieldValue>(); fv2.Add(new ARFieldValue(TestCharacterFieldId,(object)TestCharacterFieldValueChinese,ARDataType.DATA_TYPE_CHAR)); fv2.Add(new ARFieldValue(TestIntFieldId,1,ARDataType.DATA_TYPE_INTEGER)); List<ARFieldValue> fv3 = new List<ARFieldValue>(); fv3.Add(new ARFieldValue(TestCharacterFieldId,(object)(TestCharacterFieldValueChinese + "Set Something"),ARDataType.DATA_TYPE_CHAR)); fv3.Add(new ARFieldValue(TestIntFieldId,1,ARDataType.DATA_TYPE_INTEGER)); for (int i = 0; i < 7; i++) session.CreateEntry(TestRegularFormName, fv1.ToArray()); for (int i = 0; i < 9; i++) session.CreateEntry(TestRegularFormName, fv2.ToArray()); for (int i = 0; i < 2; i++) session.CreateEntry(TestRegularFormName, fv3.ToArray()); } catch (ARException ex) { } finally { 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 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 Login_with_admin_failed_and_try_a_success_again() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd + "something"); } catch (ARException ex) { Assert.AreEqual(623, ex.MessageNumber); //183977-ErrorMsgs-7604.pdf page 72 try { session.Login(TestServer, TestAdmin, TestAdminPwd); } catch { Assert.AreEqual(null, ex); } } session.LogOut(); }
public static void Cleanup() { //cleanup the user which has been created in Initialize ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<uint> fieldIds = new List<uint>(); fieldIds.Add(1u); int total = -1; var entry = session.GetEntryList("User", "'101'=\"周平\"", fieldIds.ToArray(), null, null, ref total, null); if (entry != null || entry.Count != 0){ foreach (var e in entry) session.DeleteEntry("User", e.EntryIds.ToArray()); } } finally { session.LogOut(); } }
public void ARSession_ServerInfo_Get_SERVER_INFO_MAX_ENTRIES() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<uint> tar = new List<uint>(); tar.Add((uint)ServerInfoType.SERVER_INFO_MAX_ENTRIES); var result = session.GetServerInfo(tar.ToArray()); Assert.AreEqual(1,result.Count); Assert.AreEqual(ServerInfoType.SERVER_INFO_MAX_ENTRIES, result[0].Type); } catch (Exception ex) { Assert.AreEqual(null, ex); } finally { session.LogOut(); } }
public static void Initialize(TestContext context) { //clean first Cleanup(); //create a user which has login name with unicode character ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<ARFieldValue> valuelist = new List<ARFieldValue>(); valuelist.Add(new ARFieldValue(101u, "周平", ARDataType.DATA_TYPE_CHAR)); valuelist.Add(new ARFieldValue(8u, "周平", ARDataType.DATA_TYPE_CHAR)); valuelist.Add(new ARFieldValue(102u, "123", ARDataType.DATA_TYPE_CHAR)); session.CreateEntry("User", valuelist.ToArray()); TestChineseUser = "******"; TestChineseUserPwd = "123"; } finally { session.LogOut(); } }
public void CreateEntry_form_not_found_303() { 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.CreateEntry(TestRegularFormName + "Y(HGYU", valuelist.ToArray()); } catch (ARException ex) { Assert.AreEqual(303, ex.MessageNumber); //183977-ErrorMsgs-7604.pdf page 49 } 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_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 GetEntryList_qulifier_fieldIds_nopage_hascount_hasorder_success() { ARSession session = new ARSession(); try { int total = 0; session.Login(TestServer, TestAdmin, TestAdminPwd); List<UInt32> fieldIds = new List<UInt32>(); fieldIds.Add(TestCharacterFieldId); fieldIds.Add(TestIntFieldId); List<ARSortInfo> sortInfo = new List<ARSortInfo>(); sortInfo.Add(new ARSortInfo { FieldId = TestCharacterFieldId, Order = SortOrder.SORT_DESCENDING }); var retlist = session.GetEntryList( TestRegularFormName, "'Character Field' LIKE \"%你好%\"", fieldIds.ToArray(), null, null, ref total, sortInfo.ToArray() ); Assert.AreEqual(11, retlist.Count); Assert.AreEqual(11, total); foreach (var entry in retlist) { //Assert.AreEqual(entry.EntryIds.First(), entry.FieldValues.First(f => f.FieldId == 1).Value.ToString()); Assert.IsTrue(entry.FieldValues.First(f => f.FieldId == TestCharacterFieldId).Value.ToString().Contains("你好")); } string maxentrylist = retlist.Max(e => e.EntryIds.First()); string minentrylist = retlist.Min(e => e.EntryIds.First()); Assert.AreEqual(10, Convert.ToInt32(maxentrylist) - Convert.ToInt32(minentrylist)); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[0].FieldValues[0].Value); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[1].FieldValues[0].Value); } catch (Exception ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void ARSession_Transcation_Create_Set_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()); List<string> entryid = new List<string>() { "111111111111" };//entryid do not exist List<ARFieldValue> up_fvs = new List<ARFieldValue>(); up_fvs.Add(new ARFieldValue(TestCharacterFieldId, (object)TestCharacterFieldValueChinese, ARDataType.DATA_TYPE_CHAR)); //let the second call failed session.SetEntry(TestRegularFormName, entryid.ToArray(), up_fvs.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_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 (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_Transcation_Create_Set_Cancel() { 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(2); Assert.IsTrue(result.Success); } catch (ARException ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void GetEntryList_qulifier_fieldIds_nopage_nocount_noorder_success() { ARSession session = new ARSession(); try { int total = -1; session.Login(TestServer, TestAdmin, TestAdminPwd); List<UInt32> fieldIds = new List<UInt32>(); fieldIds.Add(TestCharacterFieldId); fieldIds.Add(TestIntFieldId); //fieldIds.Add(1); var retlist = session.GetEntryList( TestRegularFormName, "'Character Field' LIKE \"%你好%\"", fieldIds.ToArray(), null, null, ref total, null ); Assert.AreEqual(11, retlist.Count); Assert.AreEqual(-1, total); foreach (var entry in retlist) { //Assert.AreEqual(entry.EntryIds.First(), entry.FieldValues.First(f => f.FieldId == 1).Value.ToString()); Assert.IsTrue(entry.FieldValues.First(f => f.FieldId == TestCharacterFieldId).Value.ToString().Contains("你好")); } } catch (Exception ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void Login_with_chinese_admin_success() { ARSession session = new ARSession(); try { session.Login(TestServer, TestChineseUser, TestChineseUserPwd); } 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 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 Login(string server, string user, string password, string authentication) { if (SessionInstance == null) SessionInstance = new ARSession(); //has been login if (SessionInstance.HasSession()) return; //has not been login SessionInstance.Login(server, user, password); }
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_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 GetEntryListStatictisc_count_qulifier_nogroup_success() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd); List<UInt32> groupIds = new List<UInt32>(); groupIds.Add(TestCharacterFieldId); var retlist = session.GetListEntryStatictisc( TestRegularFormName, "'Character Field' = \"Hello Remedy\"", ARStatictisc.STAT_OP_COUNT, null, null ); Assert.AreEqual(1, retlist.Count); Assert.AreEqual(7, Convert.ToInt32(retlist[0].Statictisc)); Assert.AreEqual(null, retlist[0].GroupByValues); } catch (Exception ex) { Assert.AreEqual(null, ex); } session.LogOut(); }
public void Login_with_admin_failed_cause_bad_pwd() { ARSession session = new ARSession(); try { session.Login(TestServer, TestAdmin, TestAdminPwd + "something"); } catch (ARException ex) { Assert.AreEqual(623, ex.MessageNumber); //183977-ErrorMsgs-7604.pdf page 72 } session.LogOut(); }