public HttpResponseMessage ProcessBloombergRequest(IRequestContract marshalContract) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, marshalContract); // TODO: Test for null marshal contract here //Create a bloomberg session to handle request also populates local config Session session = CreateBloombergSession(); ///////////////////////////////////////////////////////////////////////////// // Factory impl // get the processor for the Request supports expansion of new processors //IRequestProcessor rpRequestProcessor = MvcApplication.factory.FactoryToRequestProcessor(marshalContract); IRequestProcessor rpRequestProcessor = WebApiApplication.factory.FactoryToRequestProcessor(session, marshalContract); ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Concrete impl //IRequestProcessor rpRequestProcessor = new ORequestProcessor(); //////////////////////////////////////////////////////////////////////////// // polymorphic, let the object determine how to process itself based on concrete implementation of type rpRequestProcessor.ProcessRequest(session, marshalContract); // get the reponse from the object var json = rpRequestProcessor.GetResponse(); // if we get to this point return a status of success var responsemsg = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") }; return responsemsg; }
public override void ProcessRequest(Session s, IRequestContract requestContract) { // Example of having to alter request proior to processing //if (((ReferenceDataRequestContract)requestContract).ReturnEids) // request.GetElement("fields").AppendValue(""); base.ProcessRequest(s, requestContract); }
static void Main(string[] args) { WebBrowser web = new WebBrowser(); //ResponsePack_WebBrowser r = web.Request("https://www.baidu.com", null) as ResponsePack_WebBrowser; string json = File.ReadAllText(@"C:\Users\Guo\Desktop\zc-paimai.taobao.com.har"); HttpHar h = JsonConvert.DeserializeObject <HttpHar>(json); Cookie[] c = new Cookie[0]; var r = web.Request(h.log.entries[0].request, c); web.RefreshConfig(); RequestConfig req = new RequestConfig(); ChannelFactory <IRequestContract> channelFactory; using (channelFactory = new ChannelFactory <RequestContract.IRequestContract>("Request")) { IRequestContract ito = channelFactory.CreateChannel(); while (true) { // ResponsePack_WebBrowser res = ito.BrowserRequest(h.log.entries[0].request); var coo = new List <Cookie>(); string html = ito.Get(h.log.entries[0].request.url, coo); //Console.WriteLine(html); } // action?.Invoke(channelFactory.CreateChannel()); } }
public static List <User> GetAllUsers(Guid requestGuid) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); return(client.GetAllUsers(requestGuid)); } }
public static void SaveRequest(Request request) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); client.SaveRequest(request); } }
public static void AddUser(User user) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); client.AddUser(user); } }
public static User GetUserByGuid(Guid guid) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); return(client.GetUserByGuid(guid)); } }
public static User GetUserByLogin(string login) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); return(client.GetUserByLogin(login)); } }
public static void DeleteRequest(Request selectedRequest) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); client.DeleteRequest(selectedRequest); } }
public static bool UserExists(string login) { using (var myChannelFactory = new ChannelFactory <IRequestContract>("Server")) { IRequestContract client = myChannelFactory.CreateChannel(); return(client.UserExists(login)); } }
//// empty class for any possible preprocessing public ReferenceDataRequestProcessor(IRequestContract requestContract) : base(requestContract) { string s = ""; }
public ReferenceDataRequestProcessor(Session session, IRequestContract requestContract) : base(session, requestContract) { string s = ""; }
public HistoricalDataRequestProcessor(Session session, IRequestContract requestContract) : base(session, requestContract) { string s = ""; }
//// empty class for any possible preprocessing public HistoricalDataRequestProcessor(IRequestContract requestContract) : base(requestContract) { string s = ""; }
public virtual void ProcessRequest(Session s, IRequestContract requestContract) { // clone the original request so it can be reused by client and return with response response.OrigRequest = requestContract; //// get the configuration to process bloomberg request //BloombergApiSessionConfig config = new BloombergApiSessionConfig(); //// TODO MOVE THIS CODE TO THE CONSTRUCTOR FOR PREPOSTING ITEMS OT THE REQUEST FIELDS //// create the service //Service refDataSvc = s.GetService(config.BbService); //// get Request type //var requestName = Enum.GetName(typeof(BloombergRequestServiceTypes), requestContract.RequestType); //// create the request //request = refDataSvc.CreateRequest(requestName); // Loop through the list of identifiers and append them to the request foreach (var sec in requestContract.SecurityList) { string secfield = ""; // identifier security request if (sec.IdentifierType != IdentifierType.NONE) secfield = String.Format("/{0}/{1}",EnumLookup.IdentifierTypeName[sec.IdentifierType], sec.Identifier) ; //goldkey security request if (sec.GoldKey != GoldKey.NONE) secfield = String.Format("{0} {1}",sec.Identifier , EnumLookup.GoldKeyName[sec.GoldKey]); // Unique request error: if neither is filled for the security put in an error response // DO NOT SEND TO BLOOMBERG IF THIS HAPPENS if (sec.IdentifierType == IdentifierType.NONE && sec.GoldKey == GoldKey.NONE) { response.RequestError = new ErrorInfo() { Message = sec.Identifier + " not given a goldkey or indentifier type", Category = "none", Code = 0, Source = sec.Identifier, Subcategory = "" }; } else request.GetElement("securities").AppendValue(secfield); } // allow bloomberg to process bad request if user forgets fields list if (requestContract.FieldsList == null) request.GetElement("fields").AppendValue(""); else // Indicate which fields to retrieve for each identifier foreach(var field in requestContract.FieldsList) request.GetElement("fields").AppendValue(field); ProcessEvents(s,request); }
protected RequestProcessor(Session session,IRequestContract requestContract) { // get the configuration to process bloomberg request BloombergApiSessionConfig config = new BloombergApiSessionConfig(); // TODO MOVE THIS CODE TO THE CONSTRUCTOR FOR PREPOSTING ITEMS OT THE REQUEST FIELDS // create the service Service refDataSvc = session.GetService(config.BbService); // get Request type var requestName = Enum.GetName(typeof(BloombergRequestServiceTypes), requestContract.RequestType); // create the request request = refDataSvc.CreateRequest(requestName); }
protected RequestProcessor(IRequestContract requestContract) { string s = ""; }
//public IRequestProcessor FactoryToRequestProcessor(IRequestContract oContract) //{ // //functional switch to determine which processor to create // var type = oContract.GetType().Name.Replace("Contract", "Processor"); // var instance = _factories[type](oContract); // return instance; //} public IRequestProcessor FactoryToRequestProcessor(Session s, IRequestContract oContract) { //functional switch to determine which processor to create var type = oContract.GetType().Name.Replace("Contract", "Processor"); var instance = _factories[type](s, oContract); return instance; }
public SchedulerTask(IRequestContract request) { _RequestContract = request; }