public void UploadToS3Completed_Test()
        {
            // this test inserts a new file into the database and updates its status
            // by completing it
            string         fileName = "testfile.jpg";
            AppFileService target   = (AppFileService)AppFileEN.GetService("");
            var            appFile  = target.InsertNewFile(fileName, (int)EntityEnums.AppEntityFileTypeEnum.Test_Picture_Upload, TestEnums.User.constPatientUserID);

            Assert.AreEqual(appFile.AppFileUploadStatusID, (short)EntityEnums.AppEntityFileUploadStatus.Incomplete);
            string fileKey = "systemtest/testfile.jpg";

            target.DeleteFromS3(fileKey); // clearning test

            byte[] bytes = { 0, 1, 2, 3, 4 };
            target.UploadFileToS3(fileKey, bytes, "image/jpg", Guid.NewGuid());
            target.UploadToS3Completed(new AppFileUploadToS3CompletedSP()
            {
                AppFileID = appFile.AppFileID
            });

            var   actualfile = target.GetByIDT(appFile.AppFileID);
            short newStatus  = actualfile.AppFileUploadStatusID;

            try // Cleaning test data
            {
                target.DeleteFromS3(fileKey);
                target.Delete(actualfile);
            }
            catch (Exception)
            {
            }
            Assert.AreEqual(newStatus, (short)EntityEnums.AppEntityFileUploadStatus.Completed);
        }
        public void AmazonUploadRequestTest()
        {
            TestUtils.Security.SetCurrentUser(TestEnums.User.constPatientUserID);

            var target = AppFileEN.GetService("");
            AppFileAmazonUploadRequestSP p = new AppFileAmazonUploadRequestSP()
            {
                FileName = "images.jpg"
                , AppEntityRecordIDValue = (long)TestEnums.User.constPatientUserID
                , AppFileTypeID          = (int)EntityEnums.AppEntityFileTypeEnum.Test_Picture_Upload
            };
            var result = target.AmazonUploadRequest(p);

            string expectedKey = "systemtest/testfile.jpg";

            //string expectedPolicyString = ""; (it can variate and has time added by 10 hours so, it's hard to have an exact policy)

            Assert.IsTrue(result.AppFileID > 0);
            Assert.AreEqual(result.Key, expectedKey);
            //Assert.AreEqual(System.Text.UTF8Encoding.UTF8.GetString(Convert.FromBase64String(result.PolicyBase64)), expectedPolicyString);
            string actualPolicyText = System.Text.UTF8Encoding.UTF8.GetString(Convert.FromBase64String(result.PolicyBase64));

            Assert.IsTrue(string.IsNullOrEmpty(actualPolicyText) == false, "policy text base 64 can't be null or empty.");
            Assert.IsTrue(FWUtils.EntityUtils.JsonIsValidThenDeserialize(actualPolicyText) != null, "policy string should be a valid json object");
            Assert.IsTrue(string.IsNullOrEmpty(System.Text.UTF8Encoding.UTF8.GetString(Convert.FromBase64String(result.SignatureBase64))) == false, "signature base 64 can't be null or empty.");
        }
        public void UploadFileToS3_GetS3SignedUrl_Delete_IntegrationTest()
        {
            // https://console.aws.amazon.com/s3/home?region=us-west-2#

            AppFileService target = (AppFileService)AppFileEN.GetService("");
            string         key    = "systemtest/testintegrationfile2.jpg";

            // test deleting existing file
            try
            {
                target.DeleteFromS3(key);
            }
            catch (Exception)
            {
            }

            byte[] testbytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            target.UploadFileToS3(key, testbytes, "image/jpg", Guid.NewGuid());

            var url = target.GetS3SignedUrlAccess(key, 5);

            using (System.Net.WebClient w = new System.Net.WebClient())
            {
                byte[] data = w.DownloadData(url);
                Assert.IsTrue(data.Length > 0);
            }

            target.DeleteFromS3(key);
        }
        public void FileExistsS3_Test2()
        {
            AppFileService target   = (AppFileService)AppFileEN.GetService("");
            string         key      = "systemtest/randomfilename123123123.jpg";
            bool           expected = false;
            bool           actual   = target.FileExistsS3(key);

            Assert.AreEqual(expected, actual, "file " + key + "should not exists on Amazon S3 bucket.");
        }
Exemplo n.º 5
0
 protected override void onAfterGetByFilter(System.Collections.IList list, GetByFilterParameters parameters)
 {
     foreach (EntityObjectBase entityObj in list)
     {
         long doctorId = (long)entityObj.GetPrimaryKeyValue();
         var  doctorProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)doctorId);
         FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "DoctorProfilePicUrl", entityObj, doctorProfileImageUrl);
     }
 }
        public void FileExistsS3_Test()
        {
            AppFileService target   = (AppFileService)AppFileEN.GetService("");
            string         key      = "systemtest/testwebprivatedownload.jpg";
            bool           expected = true;
            bool           actual   = target.FileExistsS3(key);

            Assert.AreEqual(expected, actual, "file " + key + "should exist on Amazon S3 bucket.");
        }
        public void InsertTest()
        {
            TestUtils.Security.SetCurrentUser(TestEnums.User.constDoctorID);

            var AppFile = AppFileServiceTest.CreateNewAppFile();
            var target  = AppFileEN.GetService("");

            target.Insert(AppFile, new InsertParameters());
            // Happy scenario without exception
        }
        public void GetFileKey2Test()
        {
            AppFileService target              = (AppFileService)AppFileEN.GetService("");
            string         recordId            = "123123";
            string         virtualPathTemplate = "userfiles/u{userid}/visitattach/{recordid}/image.jpg";
            string         selectedfileName    = "filename.jpg";
            long           userId              = 100000001;
            string         expected            = "userfiles/u100000001/visitattach/123123/image.jpg";
            string         actual              = target.GetFileKeyByPathTemplate(virtualPathTemplate, selectedfileName, userId, recordId);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 9
0
        protected override void onAfterGetByID(object entityObj, object typedKeyObject, GetByIDParameters parameters)
        {
            if (entityObj != null)
            {
                long senderId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vCallLog.ColumnNames.SenderUserID);
                var  senderProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)senderId);
                FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "SenderProfilePicUrl", entityObj, senderProfileImageUrl);

                long receiverId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vCallLog.ColumnNames.ReceiverUserID);
                var  receiverProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)receiverId);
                FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "ReceiverProfilePicUrl", entityObj, receiverProfileImageUrl);
            }
        }
Exemplo n.º 10
0
        public void GetFileKeyTest()
        {
            var            AppFile             = AppFileServiceTest.CreateNewAppFile();
            AppFileService target              = (AppFileService)AppFileEN.GetService("");
            string         recordId            = "123123";
            string         virtualPathTemplate = "userfiles/u{userid}/visitattach/{recordid}/{filename}";
            string         selectedfileName    = "myfile.zip";
            long           userId              = 100000001;
            string         expected            = "userfiles/u100000001/visitattach/123123/myfile.zip";
            string         actual              = target.GetFileKeyByPathTemplate(virtualPathTemplate, selectedfileName, userId, recordId);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 11
0
        protected override void onAfterGetByFilter(System.Collections.IList list, GetByFilterParameters parameters)
        {
            foreach (EntityObjectBase entityObj in list)
            {
                long senderId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vCallLog.ColumnNames.SenderUserID);
                var  senderProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)senderId);
                FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "SenderProfilePicUrl", entityObj, senderProfileImageUrl);

                long receiverId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vCallLog.ColumnNames.ReceiverUserID);
                var  receiverProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)receiverId);
                FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "ReceiverProfilePicUrl", entityObj, receiverProfileImageUrl);
            }
        }
Exemplo n.º 12
0
        protected override void onAfterGetByID(object entityObj, object typedKeyObject, GetByIDParameters parameters)
        {
            if (this.AdditionalDataKey == CallLogEN.AdditionalData_PhoneRing ||
                this.AdditionalDataKey == CallLogEN.AdditionalData_VisitCallPatient)
            {
                long doctorId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vCallLog.ColumnNames.SenderUserID);
                var  doctorProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)doctorId);
                FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "SenderProfilePicUrl", entityObj, doctorProfileImageUrl);

                long patientId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vCallLog.ColumnNames.ReceiverUserID);
                var  patientProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)patientId);
                FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "ReceiverProfilePicUrl", entityObj, patientProfileImageUrl);
            }
        }
Exemplo n.º 13
0
        public void GetS3SignedUrlAccessTest()
        {
            // https://console.aws.amazon.com/s3/home?region=us-west-2#

            // test generates a url for downloading a file from S3
            // it downloads the file and checks the length to be more than 0
            AppFileService target = (AppFileService)AppFileEN.GetService("");
            string         key    = "systemtest/testwebprivatedownload.jpg";
            var            url    = target.GetS3SignedUrlAccess(key, 5);

            using (System.Net.WebClient w = new System.Net.WebClient())
            {
                byte[] data = w.DownloadData(url);
                Assert.IsTrue(data.Length > 0);
            }
        }
Exemplo n.º 14
0
        protected override void onAfterGetByFilter(System.Collections.IList list, GetByFilterParameters parameters)
        {
            foreach (EntityObjectBase entityObj in list)
            {
                // filling doctor profile picture data
                if (this.AdditionalDataKey == VisitEN.AdditionalData_MyVisitsDoctor ||
                    this.AdditionalDataKey == VisitEN.AdditionalData_GridForPatient)
                {
                    long doctorId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vDoctor_Patient.ColumnNames.DoctorID);
                    var  doctorProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)doctorId);
                    FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "DoctorProfilePicUrl", entityObj, doctorProfileImageUrl);
                }

                // filing patient profile picture url
                if (this.AdditionalDataKey == VisitEN.AdditionalData_MyVisitsPatient ||
                    this.AdditionalDataKey == VisitEN.AdditionalData_TodaysAppointments ||
                    this.AdditionalDataKey == VisitEN.AdditionalData_GridForDoctor)
                {
                    long patientId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entityObj, vDoctor_Patient.ColumnNames.PatientUserID);
                    var  patientProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)patientId);
                    FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "PatientProfilePicUrl", entityObj, patientProfileImageUrl);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Sends call notification for the patient based on the visit information
        /// </summary>s
        /// <param name="p">parameters</param>
        public CallLogCallPatientResponseSP VisitCallPatient(CallLogVisitCallPatientSP p)
        {
            long   visitID = p.VisitID;
            vVisit v       = VisitEN.GetService().GetByIDV(visitID, new GetByIDParameters());

            if (v == null)
            {
                throw new BRException(BusinessErrorStrings.Visit.Visit_Deleted);
            }
            OwnerDoctorSecurity.Check("call a patient", v, vVisit.ColumnNames.DoctorID);

            // inserting call log to the database
            var callLogService = CallLogEN.GetService();
            var callLog        = CallLogEN.GetEntityObjectT();

            callLog.StartDate       = DateTime.UtcNow;
            callLog.SenderUserID    = v.DoctorID;
            callLog.ReceiverUserID  = v.PatientUserID;
            callLog.DurationSeconds = 0;
            callLog.EntityRecordID  = v.VisitID;
            callLog.AppEntityID     = (short)EntityEnums.AppEntityEnum.Visit;
            callLogService.Insert(callLog, null);


            var mobilePushService = MobilePushNotificationEN.GetService();
            var mobilePush        = MobilePushNotificationEN.GetEntityObjectT();

            mobilePush.MobilePushTemplateID = (byte)EntityEnums.MobilePushTemplateType.Call_PhoneRing;
            mobilePush.ParamsJSON           = FWUtils.EntityUtils.JsonSerializeObject(new PhoneRingParameters()
            {
                CallLogID = callLog.CallLogID, SenderFullName = v.DoctorFullName
            });
            mobilePush.TemplateParamsJSON             = new TemplateParams("caller", v.DoctorFullName).SerializeToString();
            mobilePush.ReceiverUserID                 = callLog.ReceiverUserID;
            mobilePush.MobilePushNotificationStatusID = (byte)EntityEnums.NotificationStatusEnum.Pending;
            mobilePush.InsertDate   = DateTime.UtcNow;
            mobilePush.SenderUserID = v.DoctorID;
            mobilePushService.Insert(mobilePush, null);


            CallLogCallPatientResponseSP response = new CallLogCallPatientResponseSP();

            response.CallLogID             = callLog.CallLogID;
            response.ReceiverUserID        = v.PatientUserID;
            response.ReceiverFullName      = v.PatientFullName;
            response.ReceiverProfilePicUrl = AppFileEN.GetService().GetUserProfileImageUrl(v.PatientUserID);
            return(response);

            //var userDeviceSettingsService = UserDeviceSettingEN.GetService("");

            ////string messageBody = "Doctor " + v.DoctorFirstName + " " + v.DoctorLastName + " is calling.";
            ////string sound = "RingPhone.caf";
            ////int? timeToLiveSeconds = 0;
            ////string collapseKeyIfAny = null;
            ////bool? delayWhileIdle = null;
            ////userDeviceSettingsService.PushNotification(v.PatientUserID, messageBody, sound, timeToLiveSeconds, collapseKeyIfAny, delayWhileIdle);

            //UTD.Tricorder.Common.NotificationSystem.MobileNotificationMessage msg
            //    = new UTD.Tricorder.Common.NotificationSystem.MobileNotificationMessage();
            //msg.Type = UTD.Tricorder.Common.NotificationSystem.MobileNotificationTypeSEnum.PhoneRing;
            //msg.Title = "Visit Call"; // No title
            //msg.Alert = "Doctor " + v.DoctorFirstName + " " + v.DoctorLastName + " is calling you.";
            ////msg.ParamsJSON = "{visitId: '" + visitID.ToString() + "', patientId:'" + v.PatientUserID.ToString() + "'}"; // we may need to do authentication before answering calls
            //msg.ParamsJSON = FWUtils.EntityUtils.JsonSerializeObject(new PhoneRingParameters(visitID.ToString()));
            ////msg.TimeToLiveSeconds = 0;
            //msg.IsOneSufficient = false;
            //msg.Sound = "Rington2.mp3";
            //msg.DelayWhileIdle = false;

            //FWUtils.ExpLogUtils.Logger.WriteLog(new AppLog() { AppLogTypeID = (short)EntityEnums.AppLogType.Visit_CallPatient, UserID = v.PatientUserID, ExtraBigInt = visitID });

            //int devicesCount = userDeviceSettingsService.PushNotification(v.PatientUserID, msg);
            //if (devicesCount == 0)
            //{
            //    throw new BRException(BusinessErrorStrings.Visit.CallPatient_NoDeviceAttachedToThisUser);
            //}
        }
Exemplo n.º 16
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private IAppFileService CreateService()
        {
            return(AppFileEN.GetService(""));
        }
Exemplo n.º 17
0
        protected override void onAfterGetByID(object entityObj, object typedKeyObject, GetByIDParameters parameters)
        {
            var doctorProfileImageUrl = AppFileEN.GetService().GetUserProfileImageUrl((long)typedKeyObject);

            FWUtils.EntityUtils.SetEntityFieldValue(this.Entity, "DoctorProfilePicUrl", entityObj, doctorProfileImageUrl);
        }