Exemple #1
0
        public async Task <Guid> CreateClientLocation(SmartAgentClient newClient)
        {
            var clientLocationKey = await FindClientLocation(newClient.ClientLocationName);

            if (clientLocationKey == new Guid("00000000-0000-0000-0000-000000000000"))
            {
                var term = "%" + newClient.ClientLocationName + "%";

                var query = @"INSERT INTO [dsa_clientLocations]([dateAdded],[dateChanged],[lastUserID],[deviceID],[clientKey],[clientLocationKey]
                             ,[clientLocationName], clientId, tpid, facilityId)
		                      VALUES(GETDATE() ,GETDATE(),'kris.lindsey',@deviceId, @clientKey ,@clientLocationKey,@clientLocationName, @clientId, @tpid, @facilityId)
                              SELECT clientLocationKey FROM dbo.dsa_clientLocations WHERE (clientLocationName LIKE @term)";

                var p = new DynamicParameters();

                p.Add("@clientId", newClient.ClientId);
                p.Add("@tpid", newClient.TpId);
                p.Add("@facilityId", newClient.FacilityId);
                p.Add("@term", newClient.ClientLocationName);
                p.Add("@deviceId", newClient.DeviceId);
                p.Add("@clientKey", newClient.ClientKey);
                p.Add("@clientLocationName", newClient.ClientLocationName);
                p.Add("@clientLocationKey", newClient.ClientLocationKey);


                var key = await _db.QueryAsync <Guid>(query, p);

                return(key.SingleOrDefault());
            }
            throw new Exception("Client location already exsits");
        }
Exemple #2
0
        public async Task <Guid> CreateFacilityMasterRecord(SmartAgentClient client)
        {
            if (client.ClientLocationName != "")
            {
                var query = @"INSERT INTO [dbo].[dsa_facilityMaster]([FacilityKey],[FacilityName],[OrderMap],[ClientKey],[ClientLocationKey],[AutoRunUserID])
			                  VALUES(@facilityKey,@clientLocationName ,@OrderMap, CAST(@clientKey as varchar(50)),@clientLocationKey,NULL)"            ;
                var p     = new DynamicParameters();

                p.Add("@OrderMap", client.OrderMap);
                p.Add("@clientKey", client.ClientKey);
                p.Add("@clientLocationName", client.ClientLocationName);
                p.Add("@clientLocationKey", client.ClientLocationKey);
                p.Add("@facilityKey", client.FacilityKey);

                try
                {
                    var key = await _db.QueryAsync <Guid>(query, p);

                    return(key.SingleOrDefault());
                }
                catch (SqlException)
                {
                    throw;
                }
            }
            throw new ArgumentNullException("Need facility key");
        }
Exemple #3
0
        public async Task Create_Client_Test()
        {
            var db = new SqlConnection(ConfigurationManager.ConnectionStrings[_devSmartAgent].ConnectionString);

            var container = new UnityContainer();

            container.RegisterType <ICreatSmartAgentClient, CreateSmartAgentUserRepo>(new InjectionConstructor(db));
            container.RegisterType <IDbConnection, SqlConnection>();
            var repo = container.Resolve <ICreatSmartAgentClient>();

            var newClient = new SmartAgentClient();

            newClient.ClientLocationName = "Good Samaritan Hospital Lebanon";
            newClient.ClientKey          = new Guid("3bc45110-cad0-4f2a-bd2d-efccda2732d4");
            newClient.ClientLocationKey  = new Guid("cb097cc3-2f93-4f3a-867c-192b0fd1c3db");
            newClient.DeviceId           = "Samaritan";
            newClient.ClientId           = "120838";
            newClient.TpId        = "196387";
            newClient.FacilityId  = "1";
            newClient.OrderMap    = "0150700001507000";
            newClient.FacilityKey = Guid.NewGuid();
            try
            {
                await repo.CreateSmartAgentClient(newClient);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        public async Task CreateSmartAgentClient(SmartAgentClient newClient)
        {
            var clientLocationKey = await CreateClientLocation(newClient);

            var clientkey = await CreateClientMasterRecord(newClient);

            await CreateClientAppsRecord(clientLocationKey, newClient.DeviceId);
            await CreateFacilityMasterRecord(newClient);
        }
Exemple #5
0
        private async Task <Guid> CreateClientMasterRecord(SmartAgentClient client)
        {
            if (client.ClientName != null)
            {
                var query = @"INSERT INTO [dbo].[dsa_clientMaster]([dateAdded],[dateChanged],[lastUserID],[deviceID],[clientKey],[clientName],[imageDelay],[HowToDeliver])
                              VALUES(GETDATE(), GETDATE(),'kris.lindsey', @DeviceId, @ClientKey, @ClientName, 0,@HowToDeliver)
                               SELECT clientKey FROM dbo.dsa_clientMaster WHERE clientName =@ClientName";

                var p = new DynamicParameters();
                p.Add("@DeviceId", client.DeviceId);
                p.Add("@ClientKey", client.ClientKey);
                p.Add("@ClientName", client.ClientName);
                p.Add("@HowToDeliver", client.HowToDeilver);

                using (_db)
                {
                    var key = await _db.QueryAsync <Guid>(query, p);

                    return(key.SingleOrDefault());
                }
            }
            throw new ArgumentNullException("Please provide data for entry");
        }
Exemple #6
0
        public async Task Create_ClientLocation_Test()
        {
            IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings[_devSmartAgent].ConnectionString);

            var container = new UnityContainer();

            container.RegisterType <ICreatSmartAgentClient, CreateSmartAgentUserRepo>(new InjectionConstructor(db));
            container.RegisterType <IDbConnection, SqlConnection>();
            var repo = container.Resolve <ICreatSmartAgentClient>();

            SmartAgentClient newClient = new SmartAgentClient();

            newClient.ClientLocationName = "Norton Kosair Children Hospital";
            newClient.ClientKey          = new Guid("F3ED1F27-4023-4C31-A1EC-75498BAD2DA9");
            newClient.ClientLocationKey  = new Guid("79F149F3-716D-4A44-B67B-CE72FA56725A");
            newClient.DeviceId           = "Norton";
            newClient.ClientId           = "102765";
            newClient.TpId       = "178916";
            newClient.FacilityId = "NHSG-KCH";

            var key = await repo.CreateClientLocation(newClient);

            Console.WriteLine(key);
        }