public void WordProtocol_Create_Test()
        {
            bool result = true;

            try
            {
                ProtocolRequest request = new ProtocolRequest();
                SponsorContact  contact = new SponsorContact();
                contact.SponsorName = "ABC";
                contact.Address     = "123 Street";
                contact.City        = "XYZ";
                contact.State       = "Alpha";
                contact.ZipCode     = "12345";
                string protocolNumber = "P15-1000-00A";
                request.SetContact(contact);

                string sourceFile      = @"C:\Users\BMcCulley\Documents\TestResources\ProtocolsManager\
                                      ASTM-Hemolysis Complete.docx";
                string destinationFile = @"C:\Users\BMcCulley\Documents\TestResources\ProtocolsManager\Dest\
                                         ASTM-Hemolysis Complete.docx";

                WordProtocol protocol = new WordProtocol(request, protocolNumber);
                protocol.Create(sourceFile, destinationFile);
            }
            catch (Exception ex)
            {
                result = false;
                Debug.WriteLine(ex.ToString());
            }

            Assert.AreEqual <bool>(true, result);
        }
示例#2
0
        public void ProcessMessage_BulkQueryMultipleReturn_Success()
        {
            IProcessMessageStrategy strategy = CreateMySqlProcessStrategyWithMocks(new Mocks.MockDBConnection(new MockMySqlSuccessBehaviour()));

            ProtocolRequest request = new ProtocolRequest
            {
                Action      = "SampleCall",
                Destination = "MYSQL",
                IsBulkQuery = true,
                IPAddress   = "127.0.0.1",
                Type        = Newtonsoft.Json.Linq.JTokenType.Object,
                Data        = "[{'Param1':1},{'Param2':2}]"
            };

            ProtocolResponse response = strategy.Process(request);

            Assert.That(response.Result == true);
            Assert.That(response.Error == "");
            Assert.That(response.Action == "SampleCall");

            Assert.That(response.Data.Count == 2, "BulkQuery should return multiple rows of data", null);
            Assert.That((int)response.Data[0][0] == 1);
            Assert.That((bool)response.Data[0][1] == true);
            Assert.That((string)response.Data[0][2] == "string1");
            Assert.That((double)response.Data[0][3] == 12.25);
            Assert.That((int)response.Data[1][0] == 1);
        }
        public static void UpdateItem(ProtocolRequest request, string userName)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pr_update_request", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@ProtocolRequestID", SqlDbType.Int).Value = request.ID;
                        command.Parameters.Add("@ContactCode", SqlDbType.NVarChar).Value  =
                            request.Contact.ContactCode;
                        command.Parameters.Add("@Guidelines", SqlDbType.NVarChar).Value   = request.Guidelines;
                        command.Parameters.Add("@Compliance", SqlDbType.NVarChar).Value   = request.Compliance;
                        command.Parameters.Add("@ProtocolType", SqlDbType.NVarChar).Value = request.ProtocolType;
                        command.Parameters.Add("@DueDate", SqlDbType.NVarChar).Value      = request.DueDate;
                        command.Parameters.Add("@SendVia", SqlDbType.NVarChar).Value      = request.SendVia;
                        command.Parameters.Add("@BillTo", SqlDbType.NVarChar).Value       = request.BillTo;
                        command.Parameters.Add("@Cost", SqlDbType.NVarChar).Value         = request.Cost;
                        command.Parameters.Add("@PO", SqlDbType.NVarChar).Value           = request.PO;
                        command.Parameters.Add("@AssignedTo", SqlDbType.NVarChar).Value   = request.AssignedTo.UserName;
                        command.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar).Value    = userName;

                        int result = command.ExecuteNonQuery();
                    }
                }
            }
            catch (SqlException e)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "Update", e);
            }
        }
        public static IList SelectClosedRequests(string requestedBy, string assignedTo)
        {
            IList results = new ArrayList();

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pr_select_closed_requests", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@RequestedBy", SqlDbType.NVarChar).Value = requestedBy;
                        command.Parameters.Add("@AssignedTo", SqlDbType.NVarChar).Value  = assignedTo;

                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            ProtocolRequest request = CreateNewProtocolRequest(reader);
                            results.Add(request);
                        }
                    }
                }
            }
            catch (SqlException e)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "SelectClosedRequests", e);
            }
            return(results);
        }
        public static ProtocolRequest CreateNewProtocolRequest(SqlDataReader reader)
        {
            ProtocolRequest request = new ProtocolRequest();

            request.ID = Convert.ToInt32(reader[0].ToString());
            request.SetContact(reader[17].ToString().Trim());
            request.Guidelines          = reader[2].ToString();
            request.Compliance          = reader[3].ToString();
            request.ProtocolType        = reader[4].ToString();
            request.DueDate             = Convert.ToDateTime(reader[5].ToString());
            request.SendVia             = reader[6].ToString();
            request.BillTo              = reader[7].ToString();
            request.Cost                = reader[8].ToString().Trim();
            request.Comments            = reader[9].ToString();
            request.PO                  = reader[10].ToString().Trim();
            request.AssignedTo.FullName = reader[11].ToString();
            request.RequestStatus       = reader[12].ToString();
            request.RequestedBy         = reader[13].ToString();
            request.RequestedDate       = Convert.ToDateTime(reader[14].ToString());
            request.AssignedTo.UserName = reader[18].ToString();
            if (reader.FieldCount > 20)
            {
                request.TemplateCount   = Convert.ToInt32(reader[19].ToString());
                request.AssignedPNCount = Convert.ToInt32(reader[20].ToString());
            }
            return(request);
        }
示例#6
0
        private void LoadProtocolRequestDetailByRoleID(ProtocolRequest request)
        {
            switch (loginInfo.Role.RoleID)
            {
            case UserRoles.IT:
                LoadProtocolRequestEditView(request);
                break;

            case UserRoles.CSR:
                LoadRequestDetail_CSRView(request);
                break;

            case UserRoles.DocControl:
                LoadProtocolRequestEditView(request);
                break;

            case UserRoles.Manager:
                LoadRequestDetail_ManagerView(request);
                break;

            case UserRoles.DepartmentDirector:
                LoadRequestDetail_DirectorView(request);
                break;

            default:
                LoadProtocolRequestReadOnlyView(request);
                break;
            }
        }
        //This is where I need to modify things so that the loaded protocols are accurate, using sponsor AND contact codes
        public static IList SelectAllNewRequests()
        {
            IList results = new ArrayList();

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pr_admin_select_new_requests", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            ProtocolRequest request = CreateNewProtocolRequest(reader);
                            results.Add(request);
                        }
                    }
                }
            }
            catch (SqlException e)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "SelectAllNewRequests", e);
            }
            return(results);
        }
        public static void InsertItem(ProtocolRequest request, IList templates, string userName)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pa_insert_activity", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        foreach (Template item in templates)
                        {
                            command.Parameters.Clear();
                            command.Parameters.Add("@RequestID", SqlDbType.Int).Value      = request.ID;
                            command.Parameters.Add("@TemplateID", SqlDbType.Int).Value     = item.ID;
                            command.Parameters.Add("@EventID", SqlDbType.Int).Value        = 1;
                            command.Parameters.Add("@CreatedBy", SqlDbType.NVarChar).Value = userName;

                            int result = command.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "InsertFromProtocolRequest", ex);
            }
        }
 public void LoadView(ProtocolRequest protocolRequest)
 {
     this.request = protocolRequest;
     this.contact = protocolRequest.Contact;
     this.requestFormController.LoadView(this.request);
     this.RefreshTemplateListView();
 }
示例#10
0
        public void AddItemToListView(ProtocolRequest request)
        {
            ListViewItem item = this.RequestListView.Items.Add(request.RequestedDate.ToString("MM/dd/yyyy"));

            item.SubItems.Add(request.RequestedBy);
            item.SubItems.Add(request.AssignedTo.FullName);
        }
示例#11
0
 public WordProtocol()
 {
     this.TemplateName    = "";
     this.SourceFile      = "";
     this.DestinationFile = "";
     request = new ProtocolRequest();
 }
示例#12
0
        public void InternalRequest <TId, TInputType>(ProtocolRequest <TId, TInputType> request)
            where TId : IProtocolIdentifier
        {
            if (_terminated)
            {
                Logger.LogTrace($"Era {_era} is already finished, skipping InternalRequest");
                return;
            }

            if (request.From != null)
            {
                if (_callback.TryGetValue(request.To, out var existingCallback))
                {
                    throw new InvalidOperationException(
                              $"Cannot have two requests from different protocols ({request.From}, " +
                              $"{existingCallback}) to one protocol {request.To}"
                              );
                }

                _callback[request.To] = request.From;
            }

            Logger.LogTrace($"Protocol {request.From} requested result from protocol {request.To}");
            EnsureProtocol(request.To);

            if (_registry.TryGetValue(request.To, out var protocol))
            {
                protocol?.ReceiveMessage(new MessageEnvelope(request, GetMyId()));
            }
        }
        public static IList SelectItemsByStatus(string status)
        {
            IList results = new ArrayList();

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand("pr_select_requests_by_status", connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.Add("@RequestStatus", SqlDbType.NVarChar).Value = status;
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            ProtocolRequest request = CreateNewProtocolRequest(reader);
                            results.Add(request);
                        }
                    }
                }
            }
            catch (SqlException e)
            {
                ErrorHandler.CreateLogFile(ErrorFormName, "GetProtocolRequestsByStatus", e);
            }
            return(results);
        }
示例#14
0
        public HttpRequestMessage CreateHttpRequest(ProtocolRequest protocolRequest)
        {
            Uri requestUri = protocolRequest.Url.BuildUri();
            var httpRequest = new HttpRequestMessage(HttpMethod.Post, requestUri);
            AddHttpRequestContent(protocolRequest, httpRequest);

            return httpRequest;
        }
示例#15
0
        private void LoadRequestDetail_CSRView(ProtocolRequest request)
        {
            ProtocolRequestCSRView  subView           = new ProtocolRequestCSRView();
            RequestDetailController subViewController = new RequestDetailController(subView);

            subViewController.LoadView(request);
            view.AddControlToMainPanel(subView);
        }
 public void RequestListView_SelectedIndexChanged(int selectedIndex)
 {
     if (selectedIndex > -1 && selectedIndex < this.requestList.Count)
     {
         this.selectedRequest = (ProtocolRequest)this.requestList[selectedIndex];
         this.requestViewController.LoadView(this.selectedRequest, RequestFormTypes.ReadOnly);
     }
 }
示例#17
0
        private void HandleInputMessage(ProtocolRequest <HoneyBadgerId, IRawShare> request)
        {
            _rawShare  = request.Input;
            _requested = ResultStatus.Requested;

            CheckEncryption();
            CheckResult();
        }
 public RequestFormController(IRequestForm view)
 {
     this.view = view;
     this.view.SetController(this);
     this.request    = new ProtocolRequest();
     loginInfo       = LoginInfo.GetInstance();
     this.auditItems = new List <AuditItem>();
 }
示例#19
0
        public void Process_MessageIsNewConnection_HoldsClient()
        {
            var req = new ProtocolRequest {
                ClientId = "client1", Message = "join"
            };
            var response = _sut.Process(req);

            Assert.That(response.Action, Is.EqualTo(Action.Hold));
        }
示例#20
0
        public void LoadProtocolRequestEditView(ProtocolRequest request)
        {
            ProtocolRequestEditView2 subView           = new ProtocolRequestEditView2();
            RequestDetailController  subViewController = new RequestDetailController(subView);

            subViewController.LoadView(request);

            view.AddControlToMainPanel(subView);
        }
示例#21
0
        public void RequestDataGridViewCellDoubleClicked(int requestID)
        {
            //This is where I should be saving the state of the column header to be loaded back later!!! If at all possible
            ProtocolRequest request = this.protocolRequests.Cast <ProtocolRequest>().
                                      SingleOrDefault(x => x.ID == requestID);
            MainView mainView = (MainView)this.view.ParentControl;

            mainView.Invoke(mainView.LoadProtocolRequestViewDelegate, new object[] { request });
        }
        public HttpRequestMessage CreateHttpRequest(ProtocolRequest protocolRequest)
        {
            Uri requestUri  = protocolRequest.Url.BuildUri();
            var httpRequest = new HttpRequestMessage(HttpMethod.Post, requestUri);

            AddHttpRequestContent(protocolRequest, httpRequest);

            return(httpRequest);
        }
示例#23
0
 public void AddProtocolRequestToView(ProtocolRequest request)
 {
     int rowIndex = this.RequestDataGridView.Rows.Add(
         request.ID,
         request.RequestedDate.ToString("MM/dd/yyyy"),
         request.RequestedBy,
         request.AssignedTo.FullName,
         request.Contact.SponsorName,
         request.AssignedPNCount.ToString() + "/" + request.TemplateCount.ToString());
 }
        protected virtual ProtocolRequest CreateProtocolRequest(UrlParts requestUrl, Dictionary <string, string> parameters)
        {
            var oauthRequest = new ProtocolRequest()
            {
                Url            = requestUrl,
                BodyParameters = parameters
            };

            return(oauthRequest);
        }
示例#25
0
 public ProtocolRequestReport(ProtocolRequest request)
 {
     this.protocolRequest = request;
     this.templates       = new ArrayList();
     this.templates       = QProtocolRequestTemplates.SelectItems(request.ID);
     this.filePath        = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                            "\\TPM-ToxikonProtocolManager\\";
     this.fileName = protocolRequest.Contact.SponsorName + '-' + protocolRequest.RequestedBy + '-' +
                     protocolRequest.RequestedDate.ToString("yyyyMMdd");
 }
示例#26
0
        protected virtual ProtocolRequest CreateProtocolRequest(Dictionary <string, string> parameters)
        {
            var oauthRequest = new ProtocolRequest()
            {
                BodyParameters = parameters,
                Url            = new UrlParts(TokenRequestEndpoint)
            };

            return(oauthRequest);
        }
示例#27
0
 public ProtocolRequestAddController(IProtocolRequestAddView view)
 {
     this.view = view;
     this.view.SetController(this);
     this.sponsorContacts       = new ArrayList();
     this.request               = new ProtocolRequest();
     this.requestFormController = new RequestFormController(this.view.GetRequestForm);
     this.loginInfo             = LoginInfo.GetInstance();
     this.selectedTemplates     = new ArrayList();
 }
示例#28
0
 public void LoadProtocolRequestDetailView(ProtocolRequest request)
 {
     if (request.RequestStatus != RequestStatuses.Closed)
     {
         LoadProtocolRequestDetailByRoleID(request);
     }
     else
     {
         LoadProtocolRequestReadOnlyView(request);
     }
 }
示例#29
0
        public void ProcessMessage_GetServerInvalidVersion_Success()
        {
            IProcessMessageStrategy strategy = CreateMySqlProcessStrategyWithMocks(new Mocks.MockDBConnection());
            ProtocolRequest         request  = CreateMockProtocolRequest("GetOrAddServer", "{ 'ServerName':'Dev Kaukasus Insurgency Server','Version':'INVALID'}");
            ProtocolResponse        response = strategy.Process(request);

            Assert.That(response.Result == false);
            Assert.That(response.Error == "Version mismatch - you are running an older version of KI - the latest version is [0.90] - Please update to the latest version");
            Assert.That(response.Action == "GetOrAddServer");
            Assert.That(response.Data.Count == 0);
        }
示例#30
0
        public ProtocolResponse SendRequest(ProtocolRequest protocolRequest)
        {
            HttpRequestMessage httpRequest = _requestAdapter.CreateHttpRequest(protocolRequest);

            var httpClient = new HttpClient();
            HttpResponseMessage httpResponse = httpClient.SendAsync(httpRequest).Result;

            ProtocolResponse oauthResponse = _responseAdapter.CreateProtocolResponse(httpResponse);

            return(oauthResponse);
        }
示例#31
0
        ProtocolResponse IProcessMessageStrategy.Process(ProtocolRequest request)
        {
            ProtocolResponse response = new ProtocolResponse
            {
                Action = request.Action,
                Error  = "Invalid Destination specified - must be either 'REDIS' or 'MYSQL'",
                Data   = null,
                Result = false
            };

            return(response);
        }
 protected override void AddHttpRequestContent(ProtocolRequest protocolRequest, HttpRequestMessage httpRequest)
 {
     httpRequest.Content = new FormUrlEncodedContent(protocolRequest.BodyParameters);
 }
示例#33
0
 protected abstract void AddHttpRequestContent(ProtocolRequest protocolRequest, HttpRequestMessage httpRequest);