Ejemplo n.º 1
0
        void Log(string Event, string Text)
        {
            string[] HashTags = HashExtractor.Matches(Text).Cast <Match>().Select(x => x.Groups[1].Value).ToArray();

            if (HashTags.Length < 1)
            {
                SayInChannel(CantDoThat);
                return;
            }

            if (string.IsNullOrWhiteSpace(Event))
            {
                SayInChannel(CantDoThat);
                return;
            }

            Event LogEvent = new Event();

            LogEvent.NoteData  = Event;
            LogEvent.Timestamp = DateTime.Now;
            EventsDB.Events.InsertOnSubmit(LogEvent);
            EventsDB.SubmitChanges();

            foreach (string Hash in HashTags)
            {
                EventsDB.EventHashtags.InsertOnSubmit(new Data.EventHashtag()
                {
                    EventId = LogEvent.Id, TagId = HashTag(Hash)
                });
            }

            EventsDB.SubmitChanges();
            SayInChannel(InfoSaved);
        }
Ejemplo n.º 2
0
    public int SaveChanges(bool IsNewRecord)
    {
        Events ObjTable;

        if (IsNewRecord)
        {
            ObjTable = new Events();
            dataContext.Events.InsertOnSubmit(ObjTable);
        }
        else
        {
            ObjTable = dataContext.Events.Single(p => p.Code.Equals(this.Code));
        }
        try
        {
            #region Save Controls
            string BaseID = this.ToString().Substring(3, this.ToString().Length - 3);
            Tools  tools  = new Tools();
            tools.AccessList = tools.GetAccessList(BaseID);
            foreach (WebControl wc in ObjectList)
            {
                string       Property     = wc.ID.Substring(3, wc.ID.Length - 3);
                PropertyInfo pi           = ObjTable.GetType().GetProperty(Property);
                string       FullPropName = BaseID + "." + Property;
                if (tools.HasAccess("Edit", BaseID + "." + Property))
                {
                    pi.SetValue(ObjTable, Tools.GetControlValue(wc), new object[] { });
                }
            }
            #endregion

            if (tools.HasAccess("Edit", "Events"))
            {
                dataContext.SubmitChanges();
            }
        }
        catch (Exception exp)
        {
            throw exp;
        }

        return(ObjTable.Code);
    }