예제 #1
0
        /// <summary>
        /// 事件注销
        /// </summary>
        public void UnRegisterEvent(EventID id, object listener)
        {
            if (!_eventDic.TryGetValue(id, out var lst))
            {
                Log.Warnning("EventMgr.UnRegisterEvent--->dose not contain id:" + id.ToString());
                return;
            }

            if (listener is null)
            {
                Log.Warnning("EventMgr.UnRegisterEvent--->listener is null,id:" + id.ToString());
                return;
            }

            EventArgs arg = null;
            var       cnt = lst.Count;

            for (int i = 0; i < cnt; i++)
            {
                arg = lst[i];
                if (!ReferenceEquals(listener, arg.Listener))
                {
                    continue;
                }

                //todo待优化:避免遍历找到对应的listener
                lst.Remove(arg);
                ReSortEventDic(id);
                break;
            }
        }
예제 #2
0
        internal DB_SubCalendarEventFly(EventID EventIDData, string Name, DateTimeOffset StartData, DateTimeOffset EndData, int PriorityData, Location_Elements LocationData, DateTimeOffset OriginalStartData, TimeSpan EventPrepTimeData, TimeSpan Event_PreDeadlineData, bool EventRigidFlagData, EventDisplay UiData, MiscData NoteData, bool CompletionFlagData, Procrastination ProcrastinationData, NowProfile NowProfileData, TimeLine CalendarEventRangeData, bool FromRepeatFlagData, bool ElapsedFlagData, bool EnabledFlagData, List <string> UserIDData, long Sequence)
        {
            this.BusyFrame          = new BusyTimeLine(EventIDData.ToString(), StartData, EndData);
            this.CalendarEventRange = CalendarEventRangeData;
            this.FromRepeatEvent    = FromRepeatFlagData;
            this.EventName          = Name;
            this.EventDuration      = BusyFrame.BusyTimeSpan;
            this.Complete           = CompletionFlagData;
            this.ConflictingEvents  = new ConflictProfile();
            this.DataBlob           = NoteData;
            this.DeadlineElapsed    = ElapsedFlagData;
            this.Enabled            = EnabledFlagData;
            this.StartDateTime      = StartData;
            this.EndDateTime        = EndData;
            this.EventPreDeadline   = Event_PreDeadlineData;
            this.RepetitionSequence = Sequence;
            this.LocationInfo       = LocationData;
            //this.OldPreferredIndex = mySubCalEvent.OldUniversalIndex;
            //this.otherPartyID = mySubCalEvent.ThirdPartyID;
            //this.preferredDayIndex = mySubCalEvent.UniversalDayIndex;
            this.PrepTime                 = EventPrepTimeData;
            this.Priority                 = PriorityData;
            this.ProfileOfNow             = NowProfileData;
            this.ProfileOfProcrastination = ProcrastinationData;
            //this.RepetitionFlag = mySubCalEvent.FromRepeat;
            this.RigidSchedule = EventRigidFlagData;

            this.UiParams = UiData;
            this.UniqueID = EventIDData;

            this.UserIDs       = UserIDData;
            this.OriginalStart = OriginalStartData;
        }
예제 #3
0
    /// <summary>
    /// Get callback result
    /// </summary>
    public string GetCallbackResult()
    {
        string whereCondition = (SiteID > 0) ? SqlHelper.AddWhereCondition(gridEvents.WhereClause, GenerateWhereCondition()) : gridEvents.WhereClause;

        mParameters            = new Hashtable();
        mParameters["where"]   = whereCondition;
        mParameters["orderby"] = gridEvents.SortDirect;

        // Get the dialog identifier
        Guid dialogIdentifier = GetDialogIdentifier();

        // Store the dialog identifier with appropriate data in the session
        WindowHelper.Add(dialogIdentifier.ToString(), mParameters);

        string queryString = "?params=" + dialogIdentifier;

        if (SiteID > 0)
        {
            queryString = URLHelper.AddParameterToUrl(queryString, "siteid", SiteID.ToString());
        }
        queryString = URLHelper.AddParameterToUrl(queryString, "hash", QueryHelper.GetHash(queryString));
        queryString = URLHelper.AddParameterToUrl(queryString, "eventid", EventID.ToString());

        return(queryString);
    }
        public async void Upload_Picture_Clicked(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            try
            {
                file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium
                });

                if (file == null)
                {
                    return;
                }
                imgChosen.Source = ImageSource.FromStream(() =>
                {
                    var imageStram = file.GetStream();
                    return(imageStram);
                });
                string id    = EventID.ToString();
                string photo = await fb.UploadEventPhoto(file.GetStream(), id);

                EventImage = imgChosen;
            }
            catch (Exception ex)
            {
                await DisplayAlert("Upload Failed", ex.Message, "OK");
            }
        }
예제 #5
0
 /// <summary>
 /// Use the logger to output the JSON size, the event ID and the JSON
 /// </summary>
 public void Print()
 {
     logger.Trace("RCON_Event.Print() starts.");
     logger.Debug("Printing the event info of an event.");
     logger.Info("JSON size: " + JsonSize.ToString());
     logger.Info("Event ID: " + EventID.ToString());
     logger.Info("JSON: " + JsonAsString);
     logger.Trace("RCON_Event.Print() finishes.");
 }
예제 #6
0
        public string[] ToStringArray()
        {
            List <string> result = new List <string>();

            result.Add(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff"));
            result.Add(EventID.ToString());
            result.Add(Provider);
            result.Add(Data);
            return(result.ToArray());
        }
예제 #7
0
 public IDictionary <string, string> ToDictionary()
 {
     return(new Dictionary <string, string>()
     {
         { nameof(EventID), EventID.ToString() },
         { nameof(EventType), EventType },
         { nameof(UserID), UserID },
         { nameof(SourceIPAddress), SourceIPAddress },
         { nameof(DataTimeStamp), DataTimeStamp.ToString() }
     });
 }
예제 #8
0
 public void removeListener(EventID eventID, EventHandler handler)
 {
     if (registeredListener.ContainsKey(eventID))
     {
         registeredListener.Remove(eventID);
         EventDispatcher.Instance.RemoveListener(eventID, ID, handler);
     }
     else
     {
         ZLog.warn(eventID.ToString() + " does not register handler:" + handler.ToString());
     }
 }
예제 #9
0
        /// <summary>
        /// 触发事件
        /// </summary>
        public void FireEvent(EventID id, object[] args = null)
        {
            if (!_eventDic.TryGetValue(id, out var lst))
            {
                Log.Warnning("EventMgr.FireEvent--->dose not contain id:" + id.ToString());
                return;
            }

            foreach (var arg in lst)
            {
                arg.CallBack?.Invoke(args);
            }
        }
예제 #10
0
 public static void TriggerEvent(EventID id)
 {
     if (!eventDic.ContainsKey(id))
     {
         Debug.Log("触发事件失败,该事件未被注册 - " + id.ToString());
         return;
     }
     Delegate[] ds = eventDic[id].GetInvocationList();
     foreach (var d in ds)
     {
         Action a = d as Action;
         a();
     }
 }
예제 #11
0
    private static void OnListenerAdding(EventID e, Delegate d)
    {
        if (!mEvents.ContainsKey(e))
        {
            mEvents.Add(e, null);
        }

        Delegate ed = mEvents[e];

        if (ed != null && d.GetType() != ed.GetType())
        {
            Debug.LogError(string.Format("添加事件监听错误,EventID:{0},添加的事件{1},已存在的事件{2}", e.ToString(), d.GetType().Name, ed.GetType().Name));
        }
    }
예제 #12
0
 public static void TriggerEvent<T, U, V, W>(EventID id, T arg1, U arg2, V arg3, W arg4)
 {
     if (!eventDic.ContainsKey(id))
     {
         Debug.Log("触发事件失败,该事件未被注册 - " + id.ToString());
         return;
     }
     Delegate[] ds = eventDic[id].GetInvocationList();
     foreach (var d in ds)
     {
         Action<T, U, V, W> a = d as Action<T, U, V, W>;
         a(arg1, arg2, arg3, arg4);
     }
 }
		/// <summary>
		/// Removes the listener. Use to Unregister listener
		/// </summary>
		/// <param name="eventID">EventID.</param>
		/// <param name="callback">Callback.</param>
		public void RemoveListener (EventID eventID, Action<object> callback)
		{
			// checking params
			Common.Assert(callback != null, "RemoveListener, event {0}, callback = null !!", eventID.ToString());
			Common.Assert(eventID != EventID.None, "AddListener, event = None !!");

			if (_listeners.ContainsKey(eventID))
			{
				_listeners[eventID] -= callback;
			}
			else
			{
				Common.Warning(false, "RemoveListener, not found key : " + eventID);
			}
		}
예제 #14
0
        /// <summary>
        /// Removes the listener. Use to Unregister listener
        /// </summary>
        /// <param name="eventID">EventID.</param>
        /// <param name="callback">Callback.</param>
        public void RemoveListener(EventID eventID, Action <object> callback)
        {
            // checking params
            Debug.Assert(callback != null, "RemoveListener, event " + eventID.ToString() + "callback = null !!");
            Debug.Assert(eventID != EventID.None, "AddListener, event = None !!");

            if (_listeners.ContainsKey(eventID))
            {
                _listeners[eventID] -= callback;
            }
            else
            {
                Debug.Log("RemoveListener, not found key : " + eventID);
            }
        }
예제 #15
0
 /// <summary>
 /// Converts the value of the current WeatherEvent instance
 /// to its equivalent string representation.
 /// </summary>
 /// <returns>A string representation of a WeatherEvent.</returns>
 public override string ToString()
 {
     return(EventID.ToString() + ToStringSeparator +
            Type.ToString() + ToStringSeparator +
            Severity.ToString() + ToStringSeparator +
            StartTime.ToString() + ToStringSeparator +
            EndTime.ToString() + ToStringSeparator +
            TimeZone.ToString() + ToStringSeparator +
            AirportCode.ToString() + ToStringSeparator +
            LocationLatitude.ToString() + ToStringSeparator +
            LocationLongitude.ToString() + ToStringSeparator +
            City.ToString() + ToStringSeparator +
            County.ToString() + ToStringSeparator +
            State.ToString() + ToStringSeparator +
            ZipCode.ToString());
 }
예제 #16
0
        private bool CheckType(EventID eventID, Delegate del)
        {
            Delegate d = events[(int)eventID];

            if (d != null && d.GetType() != del.GetType())
            {
                Log.Error(
                    String.Format("Event type doesnot match : {0}", eventID.ToString())
                    );
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #17
0
        /// <summary>
        /// Register to listen for eventID
        /// </summary>
        /// <param name="eventID">EventID that object want to listen</param>
        /// <param name="callback">Callback will be invoked when this eventID be raised</para	m>
        public void RegisterListener(EventID eventID, Action <object> callback)
        {
            // checking params
            Debug.Assert(callback != null, "AddListener, event " + eventID.ToString() + "callback = null !!");
            Debug.Assert(eventID != EventID.None, "RegisterListener, event = None !!");

            // check if listener exist in distionary
            if (_listeners.ContainsKey(eventID))
            {
                // add callback to our collection
                _listeners[eventID] += callback;
            }
            else
            {
                // add new key-value pair
                _listeners.Add(eventID, null);
                _listeners[eventID] += callback;
            }
        }
예제 #18
0
        public static SubCalEvent ToRepeatInstance(this Event googleEvent, EventID CalendarID, uint CurrentCount)
        {
            SubCalEvent retValue = new SubCalEvent();

            retValue.ThirdPartyEventID = googleEvent.Id;
            retValue.ThirdPartyType    = ThirdPartyControl.CalendarTool.google.ToString();
            retValue.ThirdPartyUserID  = googleEvent.Organizer.Email;
            EventID SubEVentID = EventID.generateRepeatGoogleSubCalendarEventID(CalendarID, CurrentCount);

            retValue.ID         = SubEVentID.ToString();
            retValue.CalendarID = SubEVentID.getRepeatCalendarEventID();


            retValue.SubCalStartDate = (long)(new DateTimeOffset(googleEvent.Start.DateTime.Value) - TilerElementExtension.JSStartTime).TotalMilliseconds;
            retValue.SubCalEndDate   = (long)(new DateTimeOffset(googleEvent.End.DateTime.Value) - TilerElementExtension.JSStartTime).TotalMilliseconds;

            retValue.SubCalTotalDuration      = (googleEvent.End.DateTime.Value - googleEvent.Start.DateTime.Value);
            retValue.SubCalRigid              = true;
            retValue.SubCalAddressDescription = googleEvent.Location;// SubCalendarEventEntry.Location.Description;
            retValue.SubCalAddress            = googleEvent.Location;
            retValue.SubCalCalendarName       = googleEvent.Summary;

            retValue.SubCalCalEventStart = retValue.SubCalStartDate;
            retValue.SubCalCalEventEnd   = retValue.SubCalEndDate;
            retValue.isThirdParty        = true;
            retValue.isReadOnly          = false;
            if (googleEvent.ExtendedProperties != null && googleEvent.ExtendedProperties.Private__ != null && googleEvent.ExtendedProperties.Private__.ContainsKey(GoogleTilerEventControl.tilerReadonlyKey))
            {
                retValue.isReadOnly = Convert.ToBoolean(googleEvent.ExtendedProperties.Private__[GoogleTilerEventControl.tilerReadonlyKey]);
            }



            retValue.isComplete = false;
            retValue.isEnabled  = true;
            retValue.Duration   = (long)retValue.SubCalTotalDuration.TotalMilliseconds;
            //retValue.EventPreDeadline = (long)SubCalendarEventEntry.PreDeadline.TotalMilliseconds;
            retValue.Priority = 0;
            //retValue.Conflict = String.Join(",", SubCalendarEventEntry.Conflicts.getConflictingEventIDs());
            retValue.ColorSelection = 0;
            return(retValue);
        }
예제 #19
0
        public void Trigger <T, U, V>(EventID eventID, T t, U u, V v)
        {
            Delegate targetAction;

            if (events.TryGetValue((int)eventID, out targetAction))
            {
                Assert.IsNotNull(targetAction);
                Delegate[] list = targetAction.GetInvocationList();
                for (int i = 0; i < list.Length; i++)
                {
                    if (list[i].GetType() != typeof(Action <T, U, V>))
                    {
                        Log.Warn(String.Format("Unexpected event type : {0}", eventID.ToString()));
                        continue;
                    }
                    Action <T, U, V> action = (Action <T, U, V>)list[i];
                    action(t, u, v);
                }
            }
        }
예제 #20
0
    /// <summary>
    /// Get callback result
    /// </summary>
    public string GetCallbackResult()
    {
        string whereCondition = (SiteID > 0) ? SqlHelper.AddWhereCondition(gridEvents.WhereClause, GenerateWhereCondition()) : gridEvents.WhereClause;

        mParameters            = new Hashtable();
        mParameters["where"]   = whereCondition;
        mParameters["orderby"] = gridEvents.SortDirect;

        WindowHelper.Add(Identifier, mParameters);

        string queryString = "?params=" + Identifier;

        if (SiteID > 0)
        {
            queryString = URLHelper.AddParameterToUrl(queryString, "siteid", SiteID.ToString());
        }
        queryString = URLHelper.AddParameterToUrl(queryString, "hash", QueryHelper.GetHash(queryString));
        queryString = URLHelper.AddParameterToUrl(queryString, "eventid", EventID.ToString());

        return(queryString);
    }
예제 #21
0
    public void PostEvent(EventID eventID, object param = null)
    {
        if (!_listeners.ContainsKey(eventID))
        {
            Debug.Log(eventID.ToString() + ": NO LISTENER");
            //no listerner
            return;
        }

        var callbacks = _listeners[eventID];

        // if there's no listener remain, then remove
        if (callbacks != null)
        {
            callbacks(param);
        }
        else
        {
            _listeners.Remove(eventID);
        }
    }
예제 #22
0
        static void OnListenerAdding(EventID e, Delegate d)
        {
            List <Delegate> list = null;

            mEvent.TryGetValue(e, out list);
            if (null == list)
            {
                list = new List <Delegate>();
                mEvent.Add(e, list);
            }

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] == d)
                {
                    string error = string.Format("添加事件监听错误, EventID:{0}, 添加的事件{1}", e.ToString(), d.GetType().Name);
                    UnityEngine.Debug.LogError(error);
                    return;
                }
            }
            list.Add(d);
        }
예제 #23
0
    public static void FireEvent(EventID e)
    {
        Delegate d;

        for (int i = 0; i < strlist.Count; i++)
        {
            if (e.ToString() == strlist[i])
            {
                return;
            }
        }

        if (mEvents.TryGetValue(e, out d))
        {
            Callback callback = d as Callback;

            if (callback != null)
            {
                callback();
            }
        }
    }
예제 #24
0
        /// <summary>
        /// 根据回调顺序重新排序
        /// </summary>
        private void ReSortEventDic(EventID id)
        {
            if (!_eventDic.TryGetValue(id, out var lst))
            {
                Log.Warnning("EventMgr.ReSortEventDic--->dost not contains id:" + id.ToString());
                return;
            }

            lst.Sort((x, y) =>
            {
                if (x.Order > y.Order)
                {
                    return(1);
                }

                if (x.Order < y.Order)
                {
                    return(-1);
                }

                return(0);
            });
        }
예제 #25
0
        /// <summary>
        /// Saves an Event. If the record status == Delete, then the record is deleted.
        /// </summary>
        /// <param name="sUserUpdating">User name of who is doing it.</param>
        /// <returns></returns>
        public int Save(string sUserUpdating)
        {
            if (RecStatus == RecordStatuses.Delete)
            {
                SortedList Params = new SortedList();
                Params.Add("@UserID", "1");
                Params.Add("@RecordID", EventID.ToString());

                cUtilities.PerformNonQuery("uspDelCMEvents", Params, "LARPortal", sUserUpdating);
            }
            else
            {
                SortedList Params = new SortedList();
                Params.Add("@UserID", "1");
                Params.Add("@EventID", EventID.ToString());
                Params.Add("@CampaignID", CampaignID.ToString());
                if (EventName != null)
                {
                    Params.Add("@EventName", EventName);
                }
                if (IGEventLocation != null)
                {
                    Params.Add("@IGEventLocation", IGEventLocation);
                }
                if (DecisionByDate.HasValue)
                {
                    Params.Add("@DecisionByDate", DecisionByDate.ToString());
                }
                if (NotificationDate.HasValue)
                {
                    Params.Add("@NotificationDate", NotificationDate.Value.ToShortDateString());
                }
                if (SharePlanningInfo.HasValue)
                {
                    Params.Add("@SharePlanningInfo", SharePlanningInfo.ToString());
                }
                if (StatusID.HasValue)
                {
                    Params.Add("@StatusID", StatusID.ToString());
                }
                if (EventDescription != null)
                {
                    Params.Add("@EventDescription", EventDescription);
                }
                if (StartDateTime.HasValue)
                {
                    Params.Add("@StartDate", StartDateTime.Value.ToShortDateString());
                    Params.Add("@StartTime", StartDateTime.Value.ToShortTimeString());
                }
                if (EndDateTime.HasValue)
                {
                    Params.Add("@EndDate", EndDateTime.Value.ToShortDateString());
                    Params.Add("@EndTime", EndDateTime.Value.ToShortTimeString());
                }
                Params.Add("@SiteID", SiteID.ToString());
                if (MaximumPCCount.HasValue)
                {
                    Params.Add("@MaximumPCCount", MaximumPCCount.ToString());
                }
                if (BaseNPCCount.HasValue)
                {
                    Params.Add("@BaseNPCCount", BaseNPCCount.ToString());
                }
                if (NPCOverrideRatio.HasValue)
                {
                    Params.Add("@NPCOverrideRatio", NPCOverrideRatio.ToString());
                }
                if (CapThresholdNotification.HasValue)
                {
                    Params.Add("@CapThresholdNotification", CapThresholdNotification.ToString());
                }
                if (CapMetNotification.HasValue)
                {
                    Params.Add("@CapMetNotification", CapMetNotification.ToString());
                }
                if (MaximumPCCount.HasValue)
                {
                    Params.Add("@MaximumNPCCount", MaximumNPCCount.ToString());
                }
                if (AutoApproveWaitListOpenings.HasValue)
                {
                    Params.Add("@AutoApproveWaitListOpenings", AutoApproveWaitListOpenings.ToString());
                }
                if (RegistrationOpenDateTime.HasValue)
                {
                    Params.Add("@RegistrationOpenDate", RegistrationOpenDateTime.Value.ToShortDateString());
                    Params.Add("@RegistrationOpenTime", RegistrationOpenDateTime.Value.ToShortTimeString());
                }
                if (PreregistrationDeadline.HasValue)
                {
                    Params.Add("@PreregistrationDeadline", PreregistrationDeadline.Value.ToShortDateString());
                }
                if (PreregistrationPrice.HasValue)
                {
                    Params.Add("@PreregistrationPrice", PreregistrationPrice.ToString());
                }
                if (LateRegistrationPrice.HasValue)
                {
                    Params.Add("@LateRegistrationPrice", LateRegistrationPrice.ToString());
                }
                if (CheckinPrice.HasValue)
                {
                    Params.Add("@CheckinPrice", CheckinPrice.ToString());
                }
                if (DaysToAutoCancelOtherPlayerRegistration.HasValue)
                {
                    Params.Add("@DaysToAutoCancelOtherPlayerRegistration", DaysToAutoCancelOtherPlayerRegistration.ToString());
                }
                if (PCFoodService.HasValue)
                {
                    Params.Add("@PCFoodService", PCFoodService.ToString());
                }
                if (NPCFoodService.HasValue)
                {
                    Params.Add("@NPCFoodService", NPCFoodService.ToString());
                }
                if (CookingFacilitiesAvailable.HasValue)
                {
                    Params.Add("@CookingFacilitiesAvailable", CookingFacilitiesAvailable.ToString());
                }
                if (RefrigeratorAvailable.HasValue)
                {
                    Params.Add("@RefrigeratorAvailable", RefrigeratorAvailable.ToString());
                }
                if (PELDeadlineDate.HasValue)
                {
                    Params.Add("@PELDeadlineDate", PELDeadlineDate.Value.ToShortDateString());
                }
                if (InfoSkillDeadlineDate.HasValue)
                {
                    Params.Add("@InfoSkillDeadlineDate", InfoSkillDeadlineDate.Value.ToShortDateString());
                }
                if (Comments != null)
                {
                    Params.Add("@Comments", Comments);
                }

                DataTable UpdateResults = cUtilities.LoadDataTable("uspInsUpdCMEvents", Params, "LARPortal", sUserUpdating, "cEvent.Save");
                if (UpdateResults.Rows.Count > 0)
                {
                    int iEventID;
                    if (int.TryParse(UpdateResults.Rows[0]["EventID"].ToString(), out iEventID))
                    {
                        EventID = iEventID;
                    }
                }
            }

            return(0);
        }
예제 #26
0
 private bool CheckRemove(EventID eventID, Delegate del)
 {
     if (!events.ContainsKey((int)eventID))
     {
         Log.Warn(String.Format("Fialed to remove event listener {0}:Target listener is non-existent.", eventID.ToString()));
         return(false);
     }
     return(CheckType(eventID, del));
 }
예제 #27
0
        protected void lvCMNEvent_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 EventID;

            Int64.TryParse(e.CommandArgument.ToString(), out EventID);

            if (EventID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _EventID = EventID;

                    PrepareEditView();
                }

                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(CMNEventEntity.FLD_NAME_EventID, EventID.ToString(), SQLMatchType.Equal);

                        CMNEventEntity cMNEventEntity = new CMNEventEntity();


                        result = FCCCMNEvent.GetFacadeCreate().Delete(cMNEventEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _EventID        = 0;
                            _CMNEventEntity = new CMNEventEntity();
                            PrepareInitialView();
                            BindCMNEventList();

                            MiscUtil.ShowMessage(lblMessage, "Event has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Event.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
예제 #28
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check if current event exist
        if (!CheckIfEventExists())
        {
            return;
        }

        // Check 'Modify' permission
        if (!CheckPermissions("cms.eventmanager", "Modify"))
        {
            return;
        }

        txtEmail.Text = txtEmail.Text.Trim();

        // Validate fields
        string errorMessage = new Validator()
                              .NotEmpty(txtEmail.Text, rfvEmail.Text)
                              .MatchesCondition(txtEmail, input => input.IsValid(), GetString("Event_Attendee_Edit.IncorectEmailFormat"))
                              .Result;

        if (!String.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
            return;
        }

        // Indicates new attendee
        bool isNew = false;

        if (AttendeeID <= 0)
        {
            eai.AttendeeEventNodeID = EventID;
            isNew = true;
        }
        else
        {
            eai = EventAttendeeInfoProvider.GetEventAttendeeInfo(AttendeeID);
        }

        if (eai != null)
        {
            eai.AttendeeFirstName = txtFirstName.Text;
            eai.AttendeeLastName  = txtLastName.Text;
            eai.AttendeeEmail     = txtEmail.Text;
            eai.AttendeePhone     = txtPhone.Text;
            EventAttendeeInfoProvider.SetEventAttendeeInfo(eai);

            // If new item store new attendeeID .. used in post back situations
            if (isNew)
            {
                NewItemID = eai.AttendeeID;
                if (RedirectAfterInsert)
                {
                    string redirectTo = "~/CMSModules/EventManager/Tools/Events_Attendee_Edit.aspx";
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "eventId", EventID.ToString());
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "attendeeId", NewItemID.ToString());
                    redirectTo = URLHelper.AddParameterToUrl(redirectTo, "saved", "1");
                    URLHelper.Redirect(redirectTo);
                }
                else
                {
                    RefreshBreadCrumbs();
                    ShowChangesSaved();
                }
            }
            else
            {
                RefreshBreadCrumbs();
                ShowChangesSaved();
            }
        }
        else
        {
            ShowError(GetString("general.invalidid"));
        }
    }
예제 #29
0
        public string GetFormattedSyntax()
        {
            string name = Info == null?EventID.ToString("X8") : Info._compressedName;

            string n = Environment.NewLine;

            #region Special Events
            //This region contains code that displays certain events in a neat format.
            switch (_nameSpace)
            {
            case 0:     //Execution Flow
                switch (_id)
                {
                case 0x04:         //Set Loop
                    return(String.Format("loop ({0})", Loop(Data(0))) + n + "{");

                case 0x05:         //Execute Loop
                    return("}");

                case 0x0A:         //If
                case 0x0D:         //Else If
                    string        val   = (_id == 0xD) ? ("}" + n + "else if (") : ("if (");
                    Event         ev    = this;
                    List <string> args  = new List <string>();
                    List <string> comps = new List <string>();
Top:
                    string thisArg = "";

                    //Requirement arguments use all the following parameters it requires
                    //A better way to handle them would be to store syntax for every requirement
                    //But this works for now

                    switch (ev.Count)
                    {
                    case 1:
                        thisArg += ev.Arg(0);
                        break;

                    case 2:
                        thisArg += String.Format("{0}({1})", ev.Arg(0), ev.Arg(1));
                        break;

                    case 3:
                        thisArg += String.Format("{0}({1}), {2}", ev.Arg(0), ev.Arg(1), ev.Arg(2));
                        break;

                    case 4:
                        //thisArg += String.Format("{0}({1} {2} {3})", ev.Arg(0), ev.Arg(1), Comp(ev.Data(2)), ev.Arg(3));
                        thisArg += String.Format("{0} {1} {2}", ev.Arg(1), Comp(ev.Data(2)), ev.Arg(3));
                        break;
                    }

                    args.Add(thisArg);

                    //Check for following AND or OR 'if' events
                    if (ev.Next != null)
                    {
                        ev = ev.Next;
                        if (ev._nameSpace == 0)
                        {
                            if (ev._id == 0xB)
                            {
                                comps.Add(" && ");
                                goto Top;
                            }
                            else if (ev._id == 0xC)
                            {
                                comps.Add(" || ");
                                goto Top;
                            }
                        }
                    }
                    bool first = true;
                    int  t     = 0;
                    bool c     = args.Count > 1;
                    foreach (string a in args)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            val += n + comps[t++];
                        }

                        if (c)
                        {
                            val += "(";
                        }
                        val += a;
                        if (c)
                        {
                            val += ")";
                        }
                    }

                    val += ")" + n + "{";
                    return(val);

                case 0x0B:         //And
                case 0x0C:         //Or
                    return(null);  //This is handled by the parent 'If' event above

                case 0x0E:         //Else
                    return("}" + n + "else" + n + "{");

                case 0x0F:         //End If
                    return("}");

                case 0x10:         //Switch
                    return(String.Format("switch ({0}, {1})", Arg(1), Arg(0)) + n + "{");

                case 0x11:         //Case
                case 0x12:         //Default case

                    string start = "";
                    string mid   = "";
                    string end   = "";

                    if (Prev != null && Prev.EventID != 0x00100200 && Prev.EventID != 0x00110100)
                    {
                        start = "}" + n;
                    }

                    if (_id == 0x12)
                    {
                        mid = "default:";
                    }
                    else
                    {
                        mid = String.Format("case {0}:", Arg(0));
                    }

                    if (Next != null && Next.EventID != 0x00110100)
                    {
                        end = n + "{";
                    }

                    return(start + mid + end);

                case 0x13:         //End switch

                    string va2 = "";

                    if (Prev != null && Prev.EventID != 0x00100200)
                    {
                        va2 += "    }" + n;         //Forced tab
                    }
                    return(va2 + "}");

                case 0x18:         //break
                    return("break;");
                }
                break;

            case 0x12:     //Variables
                switch (_id)
                {
                case 0x00:
                case 0x06:
                    return(String.Format("{0} = {1};", Arg(1), Arg(0)));

                case 0x01:
                case 0x07:
                    return(String.Format("{0} += {1};", Arg(1), Arg(0)));

                case 0x02:
                case 0x08:
                    return(String.Format("{0} -= {1};", Arg(1), Arg(0)));

                case 0x03:
                    return(String.Format("{0}++;", Arg(0)));

                case 0x04:
                    return(String.Format("{0}--;", Arg(0)));

                case 0x0A:
                    return(String.Format("{0} = true;", Arg(0)));

                case 0x0B:
                    return(String.Format("{0} = false;", Arg(0)));

                case 0x0F:
                    return(String.Format("{0} *= {1};", Arg(1), Arg(0)));

                case 0x10:
                    return(String.Format("{0} /= {1};", Arg(1), Arg(0)));

                case 0x12:
                    return(String.Format("{0} ?= {1};", Arg(1), Arg(0)));
                }
                break;
            }
            #endregion

            string s = name + "(";
            int    z = 0;
            foreach (Parameter p in this)
            {
                s += p.GetArg();
                if (++z != Count)
                {
                    s += ", ";
                }
            }
            s += ");";
            return(s);
        }
예제 #30
0
        /*
         * /// <summary>
         * /// Writes the specified message to the event log as an information event
         * /// with the specified event ID.
         * /// </summary>
         * /// <param name="message">
         * /// The message to be written to the log.
         * /// </param>
         * /// <param name="id">
         * /// The event ID to use for the event being written.
         * /// </param>
         * public static void WriteInformationEvent(string message, EventID id)
         * {
         *  log.WriteEntry(message, System.Diagnostics.EventLogEntryType.Information, (int)id);
         *  //System.Diagnostics.EventLogEntryType.
         *
         *  int j = 0;
         *  Task[] tasks = new Task[Settings.SyslogServers.Count];
         *
         *  foreach (SyslogServerInfo serverInfo in Settings.SyslogServers)
         *  {
         *      if (serverInfo.IsValid)
         *      {
         *          Syslog syslog = new Syslog(serverInfo.Hostname, serverInfo.Port, serverInfo.Protocol, serverInfo.RFC);
         *          tasks[j] = Task.Factory.StartNew(() => syslog.SendMessage(message, id.ToString(), SyslogNet.Client.Severity.Informational));
         *      }
         *      j++;
         *  }
         * }
         *
         * /// <summary>
         * /// Writes the specified message to the event log as an error event with the
         * /// specified event ID.
         * /// </summary>
         * /// <param name="message">
         * /// The message to be written to the log.
         * /// </param>
         * /// <param name="id">
         * /// The event ID to use for the event being written.
         * /// </param>
         * public static void WriteErrorEvent(string message, EventID id)
         * {
         *  log.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error, (int)id);
         *
         *  int j = 0;
         *  Task[] tasks = new Task[Settings.SyslogServers.Count];
         *
         *  foreach (SyslogServerInfo serverInfo in Settings.SyslogServers)
         *  {
         *      if (serverInfo.IsValid)
         *      {
         *          Syslog syslog = new Syslog(serverInfo.Hostname, serverInfo.Port, serverInfo.Protocol, serverInfo.RFC);
         *          tasks[j] = Task.Factory.StartNew(() => syslog.SendMessage(message, id.ToString(), SyslogNet.Client.Severity.Error));
         *      }
         *      j++;
         *  }
         * }
         *
         * /// <summary>
         * /// Writes the specified message to the event log as a warning event with the
         * /// specified event ID.
         * /// </summary>
         * /// <param name="message">
         * /// The message to be written to the log.
         * /// </param>
         * /// <param name="id">
         * /// The event ID to use for the event being written.
         * /// </param>
         * public static void WriteWarningEvent(string message, EventID id)
         * {
         *  log.WriteEntry(message, System.Diagnostics.EventLogEntryType.Warning, (int)id);
         *
         *  int j = 0;
         *  Task[] tasks = new Task[Settings.SyslogServers.Count];
         *
         *  foreach (SyslogServerInfo serverInfo in Settings.SyslogServers)
         *  {
         *      if (serverInfo.IsValid)
         *      {
         *          Syslog syslog = new Syslog(serverInfo.Hostname, serverInfo.Port, serverInfo.Protocol, serverInfo.RFC);
         *          tasks[j] = Task.Factory.StartNew(() => syslog.SendMessage(message, id.ToString(), SyslogNet.Client.Severity.Warning));
         *      }
         *      j++;
         *  }
         * }
         */

        /// <summary>
        /// Writes an event to the log.
        /// </summary>
        /// <param name="message">
        /// The message to write to the log.
        /// </param>
        /// <param name="id">
        /// An ID for the type of event being logged.
        /// </param>
        /// <param name="entryType">
        /// The severity of the message being logged (information, warning, etc.).
        /// </param>
        public static void WriteEvent(string message, EventID id, System.Diagnostics.EventLogEntryType entryType)
        {
            log.WriteEntry(message, entryType, (int)id);

            int j = 0;

            Task[] tasks = new Task[Settings.SyslogServers.Count];

            // Determine the syslog severity for this event, based on the event log entry type.
            SyslogNet.Client.Severity severity = SyslogNet.Client.Severity.Informational;
            switch (entryType)
            {
            case System.Diagnostics.EventLogEntryType.Error:
                severity = SyslogNet.Client.Severity.Error;
                break;

            case System.Diagnostics.EventLogEntryType.Warning:
                severity = SyslogNet.Client.Severity.Warning;
                break;

            case System.Diagnostics.EventLogEntryType.FailureAudit:
                severity = SyslogNet.Client.Severity.Alert;
                break;

            case System.Diagnostics.EventLogEntryType.SuccessAudit:
                severity = SyslogNet.Client.Severity.Notice;
                break;

            default:
                break;
            }

            foreach (SyslogServerInfo serverInfo in Settings.SyslogServers)
            {
                if (serverInfo.IsValid)
                {
                    Syslog syslog = new Syslog(serverInfo.Hostname, serverInfo.Port, serverInfo.Protocol, serverInfo.RFC);
                    tasks[j] = Task.Factory.StartNew(() => syslog.SendMessage(message, id.ToString(), severity));
                }
                j++;
            }
        }