public void Initialize() { // TODO: Uncomment these lines to choose a database storage strategy. // string correspondenceConnectionString = ConfigurationManager.ConnectionStrings["Correspondence"].ConnectionString; // var storage = new SQLStorageStrategy(correspondenceConnectionString).UpgradeDatabase(); string path = HostingEnvironment.MapPath("~/App_Data/Correspondence"); var storage = new FileStreamStorageStrategy(path); var http = new HTTPConfigurationProvider(); var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http); _community = new Community(storage); _community.AddAsynchronousCommunicationStrategy(communication); _community.Register<CorrespondenceModel>(); _community.Subscribe(() => Domain); _community.ClientApp = false; LoadDomain(); // Synchronize whenever the user has something to send. _community.FactAdded += delegate { _community.BeginSending(); }; // Resume in 5 minutes if there is an error. Timer synchronizeTimer = new Timer(); synchronizeTimer.Elapsed += delegate { _community.BeginSending(); _community.BeginReceiving(); }; synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0; synchronizeTimer.Start(); }
public void Initialize() { // TODO: Uncomment these lines to choose a database storage strategy. // string correspondenceConnectionString = ConfigurationManager.ConnectionStrings["Correspondence"].ConnectionString; // var storage = new SQLStorageStrategy(correspondenceConnectionString).UpgradeDatabase(); string path = HostingEnvironment.MapPath("~/App_Data/Correspondence"); var storage = new FileStreamStorageStrategy(path); var http = new HTTPConfigurationProvider(); var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http); _community = new Community(storage); _community.AddAsynchronousCommunicationStrategy(communication); _community.Register <CorrespondenceModel>(); _community.Subscribe(() => Domain); _community.ClientApp = false; LoadDomain(); // Synchronize whenever the user has something to send. _community.FactAdded += delegate { _community.BeginSending(); }; // Resume in 5 minutes if there is an error. Timer synchronizeTimer = new Timer(); synchronizeTimer.Elapsed += delegate { _community.BeginSending(); _community.BeginReceiving(); }; synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0; synchronizeTimer.Start(); }