public ActionResult Checkout(Library.Model.Checkout Checkout) { object response = null; try { string endpointName = GlobalCache.GetResolvedString("LibraryServiceEndpoint"); if (endpointName == null) { throw new ApplicationException("Could not find 'LibraryServiceEndpoint' in configuration settings."); } Debug.WriteLine(string.Format("LibraryServiceEndpoint='{0}'", endpointName)); DateTime?checkedout = null; using (LibraryServiceClient proxy = new LibraryServiceClient(endpointName)) { if (proxy.Checkout(Checkout, true, out checkedout)) { Checkout.DateOut = checkedout.Value; var parameters = new KeyedDataStore(Request.Form); parameters["DateOut"] = checkedout.Value; sendEmailConfirmation(parameters); response = new { code = 200, message = string.Format("{0: MM/dd/yyyy HH:mm:ss} - A confirmation email has been sent.", checkedout), ISBN = Checkout.ISBN }; } else { response = new { code = 409, message = string.Format("{0: MM/dd/yyyy HH:mm:ss} - As of this date, your selection was already checked out.", checkedout), ISBN = "" }; Response.StatusCode = 409; } } } catch (Exception exp) { Trace.WriteLine(string.Format("Exception CheckoutBook::ProcessRequest\n{0}", exp.Message)); Request.PostError(exp); } Response.ContentType = "application/json"; return(Json(response, JsonRequestBehavior.AllowGet)); }
public void SetUp() { this.stream = new MemoryStream(); this.streamManager = new RecyclableMemoryStreamManager(1 << 17, 2, 1 << 24); this.dimensions = new DimensionSet(new HashSet<Dimension>(new[] {new Dimension(AnyDimension)})); this.data = new KeyedDataStore<InternalHitCount>(this.dimensions, this.streamManager); var hitCount = new InternalHitCount(); hitCount.AddValue(AnyDataValue); this.data.AddValue(new DimensionSpecification {{AnyDimension, AnyDimensionValue}}, AnyDataValue); this.data.Merge(); }
public EchoClient() { try { var config = new KeyedDataStore(new AppConfigProvider()); endPointName = config["EchoServiceEndpoint"] as string; Trace.WriteLine(string.Format("+ EchoClient : EndPointName '{0}'", endPointName ?? "*null*")); } catch (Exception exp) { Trace.WriteLine(string.Format("*EchoClient Exception* {0}", exp.Message)); } }
public void TearDown() { if (this.data != null) { this.data.Dispose(); this.data = null; } if (this.stream != null) { this.stream.Dispose(); this.stream = null; } }
public void SetUp() { this.stream = new MemoryStream(); this.streamManager = new RecyclableMemoryStreamManager(1 << 17, 2, 1 << 24); this.dimensions = new DimensionSet(new HashSet <Dimension>(new[] { new Dimension(AnyDimension) })); this.data = new KeyedDataStore <InternalHitCount>(this.dimensions, this.streamManager); var hitCount = new InternalHitCount(); hitCount.AddValue(AnyDataValue); this.data.AddValue(new DimensionSpecification { { AnyDimension, AnyDimensionValue } }, AnyDataValue); this.data.Merge(); }
static void Main(string[] args) { AppTraceListener tracer = null; Trace.Listeners.Add(new ConsoleTraceListener()); try { tracer = new AppTraceListener(@"C:\Logs\HelloIndigoConsoleHost"); var parameters = new KeyedDataStore(System.Environment.CommandLine.CommandLineParser(new Dictionary <string, object>(), StringFunction.DictionaryNotFoundOptions.AddKey)); bool debugFlag = false; parameters.get("debug", ref debugFlag); if (debugFlag) { Debugger.Break(); } string typeName = parameters["Service"] as string; var serviceType = TypeHandler.GetReferencedTypeByName(typeName, "HelloIndigo", "HelloIndigoService"); if (serviceType == null) { throw new Exception(string.Format("Type [{0}] not available", typeName)); } using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(serviceType)) { host.Open(); int i = 0; i = 0; Trace.WriteLine(string.Format("+ BaseAddresses +")); foreach (Uri baseAddress in host.BaseAddresses) { Trace.WriteLine(string.Format(" [{0}] = {1}", i++, baseAddress.AbsoluteUri)); } Trace.WriteLine(string.Format("- BaseAddresses -")); i = 0; Trace.WriteLine(string.Format("Service : {0}", host.Description.ConfigurationName)); Trace.WriteLine(string.Format("+ EndPoints +")); foreach (var ep in host.Description.Endpoints) { Trace.WriteLine(string.Format(" [{0}] = {1} {2} {3}", i++, ep.Address.Uri, ep.Binding.Name, ep.Contract.Name)); } Trace.WriteLine(string.Format("- EndPoints -")); Console.WriteLine(string.Format("Press ENTER to terminate '{0}'", host.Description.ConfigurationName)); Console.ReadLine(); } } catch (Exception exp) { Trace.WriteLine(exp.ToString()); } finally { if (tracer != null) { tracer.Close(); } } }