Пример #1
0
        //----< send message to host >------------------

        public void SendMessage()
        {
            //copy files
            string tReq = CreateTestrequest();

            CopyandSendFiles(TestRequests[tReq]);

            //set serverEndPoint
            CsEndPoint serverEndPoint = new CsEndPoint();

            serverEndPoint.machineAddress = "localhost";
            serverEndPoint.port           = 8090;

            //construct message for task
            CsMessage msg    = new CsMessage();
            string    tRname = Clientname.ToString() + TestRequests.Count().ToString();
            string    lFname = tRname + "_log.txt";

            msg.add("name", tRname);
            msg.add("testLogFile", lFname);
            msg.add("to", CsEndPoint.toString(serverEndPoint));
            msg.add("from", CsEndPoint.toString(endPoint_));
            msg.add("testRequest", tReq);
            msg.add("type", "client");
            msg.add("command", "ShowResult");
            msg.add("path", translater.getSavePath());
            translater.postMessage(msg);
        }
        public virtual List <TestRequests> GetAllTestRequest()
        {
            SqlConnection connection = new SqlConnection(Connection);

            string query = "SELECT *FROM TestRequestNo";

            connection.Open();

            SqlCommand          command         = new SqlCommand(query, connection);
            SqlDataReader       reader          = command.ExecuteReader();
            List <TestRequests> TestRequestList = new List <TestRequests>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    int          patientId   = (int)reader["PatientID"];
                    int          testID      = (int)reader["TestID"];
                    TestRequests TestRequest = new TestRequests(patientId, testID);

                    TestRequestList.Add(TestRequest);
                }
                reader.Close();
            }
            connection.Close();
            return(TestRequestList);
        }
Пример #3
0
        public async void TestRequest()
        {
            object result;

            try {
                result = await TestRequests.ExecuteTestRequest(Client,
                                                               _selectedTestRequestType,
                                                               _selectedExtendedOption,
                                                               !string.IsNullOrEmpty(TestId)?TestId : null,
                                                               !string.IsNullOrEmpty(TestUsername)?TestUsername : null,
                                                               AuthenticateIfOptional);
            } catch (Exception ex) {
                result = ex;
            }
            UpdateLastReturnValue(result);
        }
        public virtual int AddTestRequest(TestRequests testRequest)
        {
            SqlConnection connection = new SqlConnection(Connection);

            string query = "INSERT INTO TestRequestNo VALUES(@PatientID,@TestID)";

            connection.Open();

            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.AddWithValue("@PatientID", testRequest.patientID);
            command.Parameters.AddWithValue("@TestID", testRequest.TestID);

            int rowAffected = command.ExecuteNonQuery();

            return(rowAffected);
        }
Пример #5
0
        //----< createTestrequest >------------------

        private string CreateTestrequest()
        {
            string        dlls  = "";
            List <string> files = new List <string>();

            foreach (string path_dll in SelectedFiles)
            {
                files.Add(path_dll);
                string filename = System.IO.Path.GetFileName(path_dll);
                dlls += filename + ", ";
            }
            dlls = dlls.Substring(0, dlls.LastIndexOf(","));
            string time    = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz");
            string testreq = Clientname + ", " + Author + ", " + time + ", " + dlls;

            TestRequests.Add(testreq, files);
            TestReq.Items.Add(testreq);
            return(testreq);
        }
Пример #6
0
        static void Main(string[] args)
        {
            // validate parameters

            var appSettings = ConfigurationManager.AppSettings;

            ClientIdForUserAuthn = appSettings["ida:ClientId"];
            Tenant = appSettings["ida:Tenant"];

            if (!CheckConfiguration(args))
            {
                return;
            }

            HttpRequestMessage request = null;
            var authHelper             = new AuthenticationHelper(ClientIdForUserAuthn, Tenant);

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

            try
            {
                // Login as global admin of the Azure AD B2C tenant
                authHelper.LoginAsAdmin();

                // Graph client does not yet support trustFrameworkPolicy, so using HttpClient to make rest calls
                userMode = new UserMode(authHelper.TokenForUser);

                do
                {
                    //content is the the request body
                    string cont = string.Empty;
                    //last command is only meant to ensure that this is not the first time.
                    LastCommand = false;
                    //Get resource from console
                    resType = ProcessResourceInput();
                    //set resource for request to be constructed.
                    userMode.SetResouce(resType);
                    //Get Command from console
                    cmdType = ProcessCommandInput();
                    //initialize test request
                    testRequests = new TestRequests(userMode, resType, cmdType);
                    switch (cmdType)
                    {
                    case CommandType.LIST:

                        // List all polcies using "GET /trustFrameworkPolicies"
                        request = userMode.HttpGet();
                        ExecuteResponse(request);
                        break;

                    case CommandType.GET:
                        // Get a specific policy using "GET /trustFrameworkPolicies/{id}"
                        args = ProcessParametersInput();
                        testRequests.CheckAndGenerateTest(ref args[0], ref cont);

                        request = userMode.HttpGetID(args[0]);
                        ExecuteResponse(request);

                        break;

                    case CommandType.CREATE:
                        // Create a policy using "POST /trustFrameworkPolicies" with XML in the body
                        args = ProcessParametersInput();

                        if (!testRequests.CheckAndGenerateTest(ref args[0], ref cont))
                        {
                            cont    = System.IO.File.ReadAllText(args[0].Replace("\"", ""));
                            request = userMode.HttpPost(cont);
                            ExecuteResponse(request);
                        }


                        break;

                    case CommandType.UPDATE:
                        // Update using "PUT /trustFrameworkPolicies/{id}" with XML in the body
                        args = ProcessParametersInput();

                        if (!testRequests.CheckAndGenerateTest(ref args[0], ref cont))
                        {
                            cont = System.IO.File.ReadAllText(args[1].Replace("\"", ""));
                        }
                        request = userMode.HttpPutID(args[0], cont);
                        ExecuteResponse(request);
                        break;

                    case CommandType.DELETE:
                        // Delete using "DELETE /trustFrameworkPolicies/{id}"
                        args = ProcessParametersInput();

                        testRequests.CheckAndGenerateTest(ref args[0], ref cont);

                        request = userMode.HttpDeleteID(args[0]);
                        ExecuteResponse(request);
                        break;

                    case CommandType.BACKUPKEYSETS:
                    case CommandType.GETACTIVEKEY:
                        args = ProcessParametersInput();

                        request = userMode.HttpGetByCommandType(cmdType, args[0]);
                        ExecuteResponse(request);
                        break;

                    case CommandType.GENERATEKEY:
                    case CommandType.UPLOADCERTIFICATE:
                    case CommandType.UPLOADPKCS:
                    case CommandType.UPLOADSECRET:
                        args = ProcessParametersInput();


                        cont = args.Length == 1 ? string.Empty : args[1];
                        if (!testRequests.CheckAndGenerateTest(ref args[0], ref cont))
                        {
                            testRequests.GenerateKeySetID(ref args[0]);
                            cont = File.ReadAllText(args[1].Replace("\"", ""));
                        }
                        request = userMode.HttpPostByCommandType(cmdType, args[0], cont);
                        ExecuteResponse(request);
                        break;

                    case CommandType.EXIT:

                        CheckLastCommandAndExitApp();
                        break;
                    }
                } while (cmdType != CommandType.EXIT);
            }
            catch (Exception e)
            {
                Print(request);
                Console.WriteLine("\nError {0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }
        }