public Boolean RemoveCSEvent(CSEvent evnt) { InitDB(); try { CSEvent deleteEvent = new CSEvent(); deleteEvent.Query.Where( deleteEvent.Query.Eventstart.Equal(evnt.Eventstart) && deleteEvent.Query.Eventend.Equal(evnt.Eventend) && deleteEvent.Query.Title.Equal(evnt.Title) && deleteEvent.Query.Screenlocation.Equal(evnt.Screenlocation) && deleteEvent.Query.Description.Equal(evnt.Description) ); if (deleteEvent.Query.Load()) { deleteEvent.MarkAsDeleted(); deleteEvent.Save(); } Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Event deleted ok"); } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Error deleting event"); return false; } return true; }
public long InsertUpdateCSEvent(CSEvent csEvent) { InitDB(); CSEvent newEvent = new CSEvent(); newEvent.Query.Where(newEvent.Query.Id.Equal(csEvent.Id)); long functionResult = 0; try { if (newEvent.Query.Load()) //Do update { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Updating event"); newEvent.Screenlocation = csEvent.Screenlocation; newEvent.Customticker = csEvent.Customticker; newEvent.Datetimecreated = csEvent.Datetimecreated; try { newEvent.Eventstart = (DateTime)csEvent.Eventstart; newEvent.Eventend = (DateTime)csEvent.Eventend; } catch (Exception) { } newEvent.Description = csEvent.Description; newEvent.Eventbackground = csEvent.Eventbackground; try { newEvent.Eventlogoblob = csEvent.Eventlogoblob; } catch (Exception) { newEvent.Eventlogoblob = null; } newEvent.Eventlogofile = csEvent.Eventlogofile; newEvent.Template = csEvent.Template; newEvent.Title = csEvent.Title; newEvent.Save(); functionResult = (long)newEvent.Id; } else //Do insert { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Inserting event"); newEvent = new CSEvent(); try { newEvent.Screenlocation = csEvent.Screenlocation; newEvent.Customticker = csEvent.Customticker; try { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"END:"+csEvent.Eventend.ToString()); Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"START:" + csEvent.Eventstart.ToString()); newEvent.Eventend = (DateTime)csEvent.Eventend; newEvent.Eventstart = (DateTime)csEvent.Eventstart; } catch (Exception) { } newEvent.Datetimecreated = csEvent.Datetimecreated; newEvent.Description = csEvent.Description; newEvent.Eventbackground = csEvent.Eventbackground; try { newEvent.Eventlogoblob = csEvent.Eventlogoblob; } catch (Exception) { newEvent.Eventlogoblob = null; } newEvent.Eventlogofile = csEvent.Eventlogofile; newEvent.Template = csEvent.Template; newEvent.Title = csEvent.Title; } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Err:"+ex.Message); } Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Saving Event"); newEvent.Save(); Console.WriteLine(DateTime.Now.ToShortTimeString()+" "+"Saved Event"); functionResult = (long)newEvent.Id; } } catch (Exception) { functionResult = 0; } return functionResult; }