Example #1
0
        ///XML///
        public List <Request> GetXmlData(HttpPostedFileBase xmlFile)
        {
            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(RequestCollection));
                StreamReader  sr            = new StreamReader(Server.MapPath("~/XmlFiles/" + Path.GetFileName(xmlFile.FileName)));
                reqCollection = (RequestCollection)xmlSerializer.Deserialize(sr);

                foreach (Request r in reqCollection.Requests)
                {
                    reqList.Add(r);
                    if (r.ClientId == null || r.Name == null)
                    {
                        reqList.Clear();
                        throw new InvalidOperationException();
                    }
                }
                ViewBag.Success = "Success";
                sr.Close();
            }
            catch (InvalidOperationException ex)
            {
                ViewBag.ex = "Plik zawiera nie prawidłowe dane: " + ex.Message;
            }
            return(reqList);
        }
        public DataSet Execute(RequestCollection requests)
        {
            this.LastError = "";
            var ds = DataService.Execute(requests);

            var table = ds.FirstTable();

            if (table != null)
            {
                if (table.TableName == "Error")
                {
                    var row = table.FirstRow();

                    var message    = row["Message"].ToString();
                    var source     = row["Source"].ToString();
                    var stackTrace = row["StackTrace"].ToString();
                    var helpLink   = row["HelpLink"].ToString();

                    this.LastError = message;
                    ds             = null;
                }
            }

            return(ds);
        }
Example #3
0
        ///JSON///
        public List <Request> GetJsonData(HttpPostedFileBase jsonFile)
        {
            try
            {
                StreamReader sr       = new StreamReader(Server.MapPath("~/JsonFiles/" + Path.GetFileName(jsonFile.FileName)));
                string       jsonData = sr.ReadToEnd();
                reqCollection = JsonConvert.DeserializeObject <RequestCollection>(jsonData);

                foreach (Request r in reqCollection.Requests)
                {
                    reqList.Add(r);
                    if (r.ClientId == null || r.Name == null)
                    {
                        reqList.Clear();
                        throw new JsonSerializationException();
                    }
                }
                ViewBag.Success = "Success";

                sr.Close();
            }
            catch (JsonSerializationException ex)
            {
                ViewBag.ex = "Plik zawiera nie prawidłowe dane: " + ex.Message;
            }

            return(reqList);
        }
Example #4
0
 public void Then_Quotes_Are_Returned()
 {
     Assert.Multiple(() =>
     {
         Assert.That(QuotesReturnedByProviderAdapter, Is.Not.Null);
         Assert.That(QuotesReturnedByProviderAdapter.Quotes.First().AnnualSpend, Is.EqualTo(640M));
         Assert.That(QuotesReturnedByProviderAdapter.Quotes.Count(), Is.EqualTo(70));
         Assert.That(QuotesReturnedByProviderAdapter.Quotes.First().SupplierName, Is.EqualTo("EDF Energy"));
         Assert.That(QuotesReturnedByProviderAdapter.Quotes.First().ResultId, Is.EqualTo("tariffSelectionG592694_E592596"));
         AttachmentPersistorMock.Verify(x => x.Save(It.IsAny <Attachment>()), Times.Never());
         Assert.That(RequestCollection.Count, Is.EqualTo(11));
         Assert.That(RequestCollection.First().Path.Value, Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/current-supply"));
         Assert.That(RequestCollection[1].Path.Value, Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/current-supply"));
         Assert.That(RequestCollection.First().Method, Is.EqualTo("GET"));
         Assert.That(RequestCollection[1].Method, Is.EqualTo("POST"));
         Assert.That(RequestCollection[2].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/usage"));
         Assert.That(RequestCollection[3].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/usage"));
         Assert.That(RequestCollection[4].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9"));
         Assert.That(RequestCollection[5].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/proratapreference"));
         Assert.That(RequestCollection[6].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/proratapreference"));
         Assert.That(RequestCollection[7].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/preferences"));
         Assert.That(RequestCollection[8].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/preferences"));
         Assert.That(RequestCollection[9].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/future-supply"));
         Assert.That(RequestCollection[10].Path.Value,
                     Is.EqualTo("/domestic/energy/switches/e1b208db-54ab-4cb6-b592-a17f008f6dc9/future-supplies"));
     });
 }
Example #5
0
        public PostmanCollectionTests(ApiFixture fixture, ITestOutputHelper output)
        {
            sut = fixture.PostmanCollection(output);
            api = fixture.Api;

            variables = new MutableVariableContext(new {
                baseUrl = api.BaseAddress?.ToString().Trim('/') ?? "http://localhost:5042"
            });
        }
        public DataSet Execute(RequestCollection requests)
        {
            //var xml = requests.ToXml();
            //var text = DependencyService.Get<IHttpPost>().HttpPost(xml, this);
            //var bytes = Convert.FromBase64String(text);
            //var ds = DependencyService.Get<ISerializer>().Decompress<DataSet>(bytes);

            var ds = DependencyService.Get <IDataProvider>().Excute(requests);

            return(ds);
        }
Example #7
0
        public DataSet Execute(RequestCollection requests)
        {
            //var xml = requests.ToXml();
            //var text = HttpPost(xml);
            //var bytes = Convert.FromBase64String(text);
            //var ds = Serializer.Decompress<DataSet>(bytes);
            ////var ds = Serializer.FromBinary<DataSet>(bytes);
            //return ds;

            return(DataProvider.Excute(requests));
        }
Example #8
0
 public TestServer(int expectedNumberOfRequests)
 {
     _port     = PortAllocations.Instance.NextFreePort();
     _requests = new RequestCollection <string>(expectedNumberOfRequests);
     _webHost  = new WebHostBuilder()
                 .ConfigureServices(services => services.AddSingleton(typeof(RequestCollection <string>), _requests))
                 .UseStartup <Startup>()
                 .UseKestrel(options => {
         options.Listen(IPAddress.Loopback, _port);
     })
                 .Build();
 }
Example #9
0
        public async Task <bool> Update(RequestCollection collection)
        {
            ReplaceOneResult updateResult =
                await _db
                .Requests
                .ReplaceOneAsync(
                    filter : g => g.Id == collection.Id,
                    replacement : collection);

            return(updateResult.IsAcknowledged &&
                   updateResult.ModifiedCount > 0);
        }
Example #10
0
 public void RemoveFromCollection(Request r)
 {
     if (r != null && r.Collection != null)
     {
         int            index           = Collections.IndexOf(r.Collection);
         List <Request> updatedRequests = Collections[index].Requests;
         updatedRequests.Remove(r);
         Collections[index] = new RequestCollection(Collections[index].Name, updatedRequests);
         NotifyOfPropertyChange(() => Collections);
         SaveCollections();
     }
 }
Example #11
0
        public void AddToSelectedCollection()
        {
            int index = Collections.IndexOf(SelectedCollection);

            if (index >= 0 && SelectedHistory != null)
            {
                List <Request> updatedRequests = Collections[index].Requests;
                updatedRequests.Add(SelectedHistory);
                Collections[index] = new RequestCollection(Collections[index].Name, updatedRequests);
                NotifyOfPropertyChange(() => Collections);
                SaveCollections();
            }
        }
Example #12
0
        public IntegrationTests(ApiFixture fixture, ITestOutputHelper output)
        {
            sut    = fixture.PostmanCollection(output);
            api    = fixture.Api;
            client = fixture.ApiClient;

            variables = new ImmutableVariableContext(new
            {
                baseUrl = api.BaseAddress?.ToString().Trim('/') ?? "http://localhost:5042"
            });

            folder = sut.FindFolder("Tests");
        }
Example #13
0
        /// <summary>
        /// Load all approved prayer requests for the given organization.
        /// </summary>
        /// <param name="requests"></param>
        /// <param name="organizationID"></param>
        /// <returns></returns>
        public static RequestCollection LoadApprovedRequestsByOrg(this RequestCollection requests, int organizationID)
        {
            SqlDataReader approvedRequests = new RequestData().GetApprovedRequests(organizationID);

            while (approvedRequests.Read())
            {
                Request request = new Request((int)approvedRequests["request_id"]);
                requests.Add(request);
            }
            approvedRequests.Close();

            return(requests);
        }
Example #14
0
        public async Task InvokeAsync(HttpContext httpContext)
        {
            try
            {
                RequestCollection requestCollection = new RequestCollection(new ModelContext());
                Request           request           = new Request();
                request.Creation_Date = DateTime.Now;
                request.Path          = httpContext.Request.Path.Value;
                requestCollection.AddOrUpdateRequest(request);
            }
            catch (Exception ex)
            {
                Log.Error($"Error in analytics helper. {ex.Message}");
            }

            await _RequestDelegate(httpContext);
        }
Example #15
0
        public async Task <RequestCollection> FindPullRequests(string location, bool useCache, IEnumerable <CommitInfo> commits)
        {
            var allIssues = await IssueCache.GetIssues(this.Client, location, useCache);

            var requests = new RequestCollection(allIssues);

            foreach (var commit in commits)
            {
                string prMatch = TryExpression(SquashExpression, commit);

                if (prMatch == null)
                {
                    prMatch = TryExpression(MergeExpression, commit);
                }

                if (prMatch != null && Int32.TryParse(prMatch, out int id))
                {
                    var matchPR = allIssues.FirstOrDefault(x => x.Number == id);

                    if (matchPR != null)
                    {
                        var labels = matchPR.Labels;
                        if (labels.Count == 0)
                        {
                            var backport = TryBodyExpression(BackportExpression, matchPR.Body);
                            if (backport != null && Int32.TryParse(backport, out int backportID))
                            {
                                var matchBackport = allIssues.FirstOrDefault(x => x.Number == backportID);
                                if (matchBackport != null)
                                {
                                    labels = matchBackport.Labels;
                                }
                            }
                        }
                        if (!labels.Any(x => x == "not-notes-worthy"))
                        {
                            requests.Add(new RequestInfo(matchPR.Number, string.Format("{0:MM/dd/yyyy}", matchPR.ClosedAt), commit.Title,
                                                         commit.Description, matchPR.Title, matchPR.Body, commit.Hash, commit.Author, matchPR.Url,
                                                         labels.Where(x => IsInterestingLabel(x)).ToList()));
                        }
                    }
                }
            }
            return(requests);
        }
        public void Execute()
        {
            RequestCollection requestCollection = new RequestCollection(_ModelContext);
            BookCollection    bookCollection    = new BookCollection(_ModelContext);
            PostCollection    postCollection    = new PostCollection(_ModelContext);
            TagCollection     tagCollection     = new TagCollection(_ModelContext);

            requestCollection.DeleteAllRequests();
            bookCollection.DeleteAllBooks();
            postCollection.DeleteAllPosts();
            tagCollection.DeleteAllTags();

            List <string> seedList = GetSeedList();

            foreach (string seed in seedList)
            {
                _ModelContext.Database.ExecuteSqlRaw(seed);
            }
        }
        /// <summary>
        /// new
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="socketBufferSize"></param>
        /// <param name="messageBufferSize"></param>
        /// <param name="millisecondsSendTimeout"></param>
        /// <param name="millisecondsReceiveTimeout"></param>
        /// <exception cref="ArgumentNullException">protocol is null</exception>
        public BaseSocketClient(Protocol.IProtocol <TResponse> protocol,
                                int socketBufferSize,
                                int messageBufferSize,
                                int millisecondsSendTimeout,
                                int millisecondsReceiveTimeout)
            : base(socketBufferSize, messageBufferSize)
        {
            if (protocol == null)
            {
                throw new ArgumentNullException("protocol");
            }
            this._protocol = protocol;

            this._millisecondsSendTimeout    = millisecondsSendTimeout;
            this._millisecondsReceiveTimeout = millisecondsReceiveTimeout;

            this._pendingQueue      = new PendingSendQueue(this, millisecondsSendTimeout);
            this._requestCollection = new RequestCollection(this, millisecondsReceiveTimeout);
        }
Example #18
0
        public static void saveError(IClientServices Services, string spName, string paramQuery)
        {
            RequestCollection _query = DataQuery.Create("FW", "ws_Error_Save", new
            {
                ID               = "0",
                Error            = Services.LastError,
                LocalIP          = LocalIPAddress(),
                sPName           = spName,
                spParameterQuery = paramQuery,
                StackTrade       = "",
                StackMessage     = "",
                StackSource      = ""
            });
            DataSet _ds = Services.Execute(_query);

            if (_ds == null)
            {
                UI.ShowError(Services.LastError);
            }
        }
Example #19
0
        public static void saveError(IClientServices Services, Exception exception, string FormName)
        {
            UI.ShowError(exception.Message);
            RequestCollection _query = DataQuery.Create("FW", "ws_Error_Save", new
            {
                ID               = "0",
                Error            = Services.LastError + "(" + FormName + ")",
                LocalIP          = LocalIPAddress(),
                sPName           = "",
                spParameterQuery = "",
                exception.StackTrace,
                exception.Message,
                exception.Source
            }); DataSet _ds = Services.Execute(_query);

            if (_ds == null)
            {
                UI.ShowError(Services.LastError);
            }
        }
Example #20
0
        public static string TableCellValue(IClientServices Services, string TableName, string ColumnNameShow, string ColumnNameExpression, string Expression)
        {
            string            value  = "";
            RequestCollection _query = DataQuery.Create("QAHosGenericDB", "ws_GetFieldlValueOfTable", new
            {
                TableName           = TableName,
                FieldNameShow       = ColumnNameShow,
                FieldNameExpression = ColumnNameExpression,
                Expression          = Expression
            });
            DataSet _ds = Services.Execute(_query);

            if (_ds == null)
            {
                UI.ShowError(Services.LastError);
            }

            value = _ds.FirstValue();

            return(value);
        }
Example #21
0
 public ConsolePrinter(RequestCollection requests, string location)
 {
     Printer  = new ConsolePRPrinter(location);
     Requests = requests;
 }
Example #22
0
 public MultiRequest()
 {
     Requests = new RequestCollection();
 }
Example #23
0
 public RequestCollection PostmanCollection(ITestOutputHelper output) => RequestCollection.Load("postomate.postman_collection.json", message => output.WriteLine(message));
Example #24
0
 public async Task Create(RequestCollection collection)
 {
     await _db.Requests.InsertOneAsync(collection);
 }
Example #25
0
 public Startup(RequestCollection <string> requests)
 {
     _requests = requests;
 }
Example #26
0
        public static DataSet ProcessRequest(string connstr, RequestCollection requests)
        {
            string connectionString = "";

            if (String.IsNullOrEmpty(connstr))
            {
                connectionString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
            }
            else
            {
                connectionString = connstr;
            }

            var response = new DataSet();

            SqlTransaction transaction = null;
            string         error       = "";

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    transaction = connection.BeginTransaction(); try
                    {
                        foreach (var request in requests)
                        {
                            var category   = request["Attributes"]["Category"].Value;
                            var command    = request["Attributes"]["Command"].Value;
                            var parameters = request["Parameters"];

                            /*1.0.1.1*/
                            string param = "";
                            foreach (var parameter in parameters)
                            {
                                var name  = parameter.Name;
                                var value = parameter.Value;

                                name = Misc.SafeSqlName(name);

                                param += "@" + name + "='" + value + "',";

                                if (parameter.IsNull)
                                {
                                    value = null;
                                }
                            }

                            error += command + " " + param;


                            /*1.0.1.1*/

                            if (command.StartsWith("ws_") || command.StartsWith("rep_"))
                            {
                                if (ProcessNative(category, command, parameters, response) == false)
                                {
                                    ProcessSql(connection, transaction, category, command, parameters, response);
                                }
                            }
                        }

                        transaction.Commit();
                    }
                    catch (SqlException eSql)
                    {
                        if (eSql.Number == -2)
                        {
                            var table = new DataTable("Error");
                            table.Columns.Add("Message");
                            table.Columns.Add("MessageDev"); //1.0.1.1
                            table.Columns.Add("Source");
                            table.Columns.Add("StackTrace");
                            table.Columns.Add("HelpLink");

                            var row = table.NewRow();
                            row["Message"]    = "Đường truyền bị gián đoạn. Vui lòng khởi động lại phần mềm. Và chờ trong giây lát.";
                            row["MessageDev"] = error;// error; //1.0.1.1
                            row["Source"]     = eSql.Source;
                            row["StackTrace"] = eSql.StackTrace;
                            row["HelpLink"]   = eSql.HelpLink;

                            table.Rows.Add(row);

                            response = new DataSet();
                            response.Tables.Add(table);
                        }
                        else
                        {
                            throw eSql;
                        }
                    }
                    catch (Exception e)
                    {
                        transaction.Rollback();
                        throw e;
                    }
                }
            }
            catch (Exception e)
            {
                var table = new DataTable("Error");
                table.Columns.Add("Message");
                table.Columns.Add("MessageDev"); //1.0.1.1
                table.Columns.Add("Source");
                table.Columns.Add("StackTrace");
                table.Columns.Add("HelpLink");

                //var resultError = "";
                //if (error.Length > 0)
                //{
                //    int indexSubstring = error.LastIndexOf(",ws_");
                //    resultError = error.Substring(indexSubstring, error.Length - indexSubstring);
                //}
                var row = table.NewRow();
                row["Message"]    = e.Message;
                row["MessageDev"] = error;// error; //1.0.1.1
                row["Source"]     = e.Source;
                row["StackTrace"] = e.StackTrace;
                row["HelpLink"]   = e.HelpLink;

                table.Rows.Add(row);

                response = new DataSet();
                response.Tables.Add(table);
            }


            return(response);
        }