public override ContentItem GetById(ValidUrl url_, ContentViewType viewType_) { //ContentItem item = _db.GetCollection<ContentItem>(COLLNAME).AsQueryable<ContentItem>().Where(x => x.Url.Id == url_.Id && x.ContentView.ViewType == viewType_).FirstOrDefault<ContentItem>(); ContentItem item = _db.GetCollection <ContentItem>(COLLNAME).Find(Query.And(Query.EQ("Url.Id", url_.Id), Query.EQ("ViewType", Convert.ToInt32(viewType_)))).FirstOrDefault <ContentItem>(); if (item == null) { DependencyManager.Logger.Log(new LogEventInfo(LogLevel.Debug, ECMSSettings.DEFAULT_LOGGER, "Specific content not found now going to search for default content.")); item = _db.GetCollection <ContentItem>(COLLNAME).Find(Query.And(Query.EQ("ContentView.SiteId", url_.SiteId), Query.EQ("ContentView.ViewName", url_.View), Query.EQ("ContentView.ViewType", Convert.ToInt32(viewType_)))).FirstOrDefault <ContentItem>(); } //TODO : Optimize this if (item != null) { using (StringReader streamReader = new StringReader(item.Body[0].ToString())) { using (var csv = new CsvHelper.CsvReader(streamReader)) { //csv.Configuration.IgnoreQuotes = true; csv.Read(); item.Body = JObject.FromObject(csv.GetRecord(typeof(object))); } } } return(item); }
static void Main(string[] args) { //Create our service PushService push = new PushService(); //Wire up the events push.Events.OnDeviceSubscriptionExpired += new PushSharp.Common.ChannelEvents.DeviceSubscriptionExpired(Events_OnDeviceSubscriptionExpired); push.Events.OnDeviceSubscriptionIdChanged += new PushSharp.Common.ChannelEvents.DeviceSubscriptionIdChanged(Events_OnDeviceSubscriptionIdChanged); push.Events.OnChannelException += new PushSharp.Common.ChannelEvents.ChannelExceptionDelegate(Events_OnChannelException); push.Events.OnNotificationSendFailure += new PushSharp.Common.ChannelEvents.NotificationSendFailureDelegate(Events_OnNotificationSendFailure); push.Events.OnNotificationSent += new PushSharp.Common.ChannelEvents.NotificationSentDelegate(Events_OnNotificationSent); push.Events.OnChannelCreated += new PushSharp.Common.ChannelEvents.ChannelCreatedDelegate(Events_OnChannelCreated); push.Events.OnChannelDestroyed += new PushSharp.Common.ChannelEvents.ChannelDestroyedDelegate(Events_OnChannelDestroyed); //Configure and start Apple APNS // IMPORTANT: Make sure you use the right Push certificate. Apple allows you to generate one for connecting to Sandbox, // and one for connecting to Production. You must use the right one, to match the provisioning profile you build your // app with! var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Resources/myMood-prod-push-cert.p12")); //IMPORTANT: If you are using a Development provisioning Profile, you must use the Sandbox push notification server // (so you would leave the first arg in the ctor of ApplePushChannelSettings as 'false') // If you are using an AdHoc or AppStore provisioning profile, you must use the Production push notification server // (so you would change the first arg in the ctor of ApplePushChannelSettings to 'true') push.StartApplePushService(new ApplePushChannelSettings(appleCert, "d1scov3r!")); //push.QueueNotification(NotificationFactory.Apple() // .ForDeviceToken("14e9c79db41cf4aa205cb72e7d60cede573cfa1867f1427ddd7372ef19c29b3a") // .WithAlert("Remember to send yourself a myMood report before handing back the iPad") // .WithSound("default") // ); using (var csv = new CsvHelper.CsvReader(new StreamReader(typeof(Device).Assembly.GetManifestResourceStream(typeof(Device).Assembly.GetName().Name + ".devices.csv")))) { while (csv.Read()) { var device = csv.GetRecord <Device>(); //Fluent construction of an iOS notification //IMPORTANT: For iOS you MUST MUST MUST use your own DeviceToken here that gets generated within your iOS app itself when the Application Delegate // for registered for remote notifications is called, and the device token is passed back to you push.QueueNotification(NotificationFactory.Apple() .ForDeviceToken(device.DeviceId) .WithAlert("Remember to send yourself a myMood report before handing back the iPad!") //.WithSound("default") ); } } //Stop and wait for the queues to drains push.StopAllServices(true); Console.WriteLine("Queue Finished, press return to exit..."); Console.ReadLine(); }
public override ContentItem GetById(ValidUrl url_, ContentViewType viewType_) { //ContentItem item = _db.GetCollection<ContentItem>(COLLNAME).AsQueryable<ContentItem>().Where(x => x.Url.Id == url_.Id && x.ContentView.ViewType == viewType_).FirstOrDefault<ContentItem>(); ContentItem item = _db.GetCollection<ContentItem>(COLLNAME).Find(Query.And(Query.EQ("Url.Id", url_.Id), Query.EQ("ViewType", Convert.ToInt32(viewType_)))).FirstOrDefault<ContentItem>(); if (item == null) { DependencyManager.Logger.Log(new LogEventInfo(LogLevel.Debug, ECMSSettings.DEFAULT_LOGGER, "Specific content not found now going to search for default content.")); item = _db.GetCollection<ContentItem>(COLLNAME).Find(Query.And(Query.EQ("ContentView.SiteId", url_.SiteId), Query.EQ("ContentView.ViewName", url_.View), Query.EQ("ContentView.ViewType", Convert.ToInt32(viewType_)))).FirstOrDefault<ContentItem>(); } //TODO : Optimize this if (item != null) { using (StringReader streamReader = new StringReader(item.Body[0].ToString())) { using (var csv = new CsvHelper.CsvReader(streamReader)) { //csv.Configuration.IgnoreQuotes = true; csv.Read(); item.Body = JObject.FromObject(csv.GetRecord(typeof(object))); } } } return item; }