Ejemplo n.º 1
0
 /// <summary>
 /// 実行中のアクティビティを中止します.このメソッドはデフォルトでUnloadedイベント発生時に実行されます.
 /// <para>
 /// もし何らかの理由でUnloadedイベント発生時にアクティビティを中止したくない場合は,このメソッドを
 /// イベントハンドラから削除してください.
 /// </para>
 /// </summary>
 /// <example>
 /// <code>
 /// // Unloadedイベント発生時にアクティビティを中止したくない場合は以下をコーディングします.
 /// Unloaded -= AbortRunningActivity;
 /// </code>
 /// </example>
 protected void AbortRunningActivity(object sender, EventArgs e)
 {
     Activities.Activity activity = new Activities.Activity(window.ParameterManager);
     activity.Abort();
 }
Ejemplo n.º 2
0
        public string sendToJSON(bool toMe)
        {
            Contact.Role roleTo = null;
            if (toMe)
            {
                roleTo = this.CurrentSession.User.Person.PrincipalRole;
            }
            else
            {
                switch (Type)
                {
                case PackType.Activity:
                    Activities.Activity activity = Activities.Activity.FetchById(PackParentId);
                    if (activity != null && activity.EndUser != null)
                    {
                        roleTo = activity.EndUser.PersonRole;
                    }
                    break;

                //case PackType.Batch:
                //    Consensus.Other.Batch batch = Consensus.Other.Batch.FetchById(PackParentId);
                //    roleTo = batch.?? // there isn't a role associated with a batch..
                //    break;
                case PackType.Booking:
                    Learning.Booking booking = Learning.Booking.FetchById(PackParentId);
                    if (booking != null)
                    {
                        roleTo = booking.BookerRole;
                    }
                    break;

                case PackType.Complaint:
                    Activities.Complaint complaint = Activities.Complaint.FetchById(PackParentId);
                    if (complaint != null)
                    {
                        roleTo = complaint.FromProleId;
                    }
                    break;

                case PackType.Event:
                    Learning.Event evnt = Learning.Event.FetchById(PackParentId);
                    if (evnt != null)
                    {
                        roleTo = evnt.CommissionedRole;
                    }
                    break;

                case PackType.GiftAidDeclaration:
                    Contact.Giftaid giftaid = Contact.Giftaid.FetchById(PackParentId.ConvertTo <int>());
                    if (giftaid != null)
                    {
                        roleTo = giftaid.PnId.PrincipalRole;
                    }
                    break;

                case PackType.InformationRequest:
                    Activities.Helpdesk helpdesc = Activities.Helpdesk.FetchById(PackParentId);
                    if (helpdesc != null)
                    {
                        roleTo = helpdesc.ProleId;
                    }
                    break;

                case PackType.Invoice:
                    Finance.Invoice invoice = Finance.Invoice.FetchById(PackParentId);
                    if (invoice != null)
                    {
                        roleTo = invoice.ProleId;
                    }
                    break;

                case PackType.Membership:
                    Membership.Membership membership = Membership.Membership.FetchById(PackParentId);
                    if (membership != null)
                    {
                        for (int i = 0; i < membership.MemberLocations.Count; i++)
                        {
                            if (membership.MemberLocations[i].RenewLoc == 1)
                            {
                                roleTo = membership.MemberLocations[i].Role;
                                break;
                            }
                        }
                    }
                    break;

                case PackType.Person:
                    Contact.Person person = Contact.Person.FetchById(PackParentId);
                    if (person != null)
                    {
                        roleTo = person.PrincipalRole;
                    }
                    break;
                }
            }

            if (roleTo == null)
            {
                return("null");
            }
            else
            {
                return(string.Format(@"
{{
    id: {0},
    name: {1}
}}",
                                     HttpUtility.JavaScriptStringEncode(roleTo.Id, true),
                                     HttpUtility.JavaScriptStringEncode(roleTo.PersonName, true)));
            }
        }
Ejemplo n.º 3
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            Controls.PopupField pField = Person;

            pField.Filters.Add(new Web.Controls.PopupFieldFilter()
            {
                Type          = Web.Controls.PopupFieldFilterTypes.Value,
                ParameterName = "personType",
                Value         = TimeLogFor == "Associate" ? "Associate" : "Volunteer"
            });

            if (this.DataSource != null)
            {
                if (!string.IsNullOrEmpty(this.DataSource.ActId) && this.DataSource.Type == "Activity")
                {
                    this.Activity.FieldValue = this.DataSource.ActId;
                    Activities.Activity activity = Activities.Activity.FetchById(this.DataSource.ActId);
                    if (activity != null)
                    {
                        this.Activity.FieldText = Activities.Activity.FetchById(this.DataSource.ActId).Name;
                    }
                }
                else if (!string.IsNullOrEmpty(this.DataSource.ActId) && this.DataSource.Type == "Session")
                {
                    var sessionObject = Learning.SessionXref.FetchAllBySessionId(this.DataSource.ActId);
                    if (sessionObject.Any())
                    {
                        var            eventId  = sessionObject.First().EventId;
                        Learning.Event eventobj = Learning.Event.FetchById(eventId);
                        if (eventobj != null)
                        {
                            this.Event.FieldText    = eventobj.Product.Name;
                            this.Event.FieldValue   = eventId;
                            this.EventId.FieldValue = this.DataSource.ActId;
                        }
                    }
                }
            }
            var sessionFields = new List <KeyValuePair <string, string> >();

            //Query to get all the sessions in the DB
            var sessionsList = Query.Create()
                               .Select("ACT_ID")
                               .Select("ACT_SESSION_NAME")
                               .Select("ACT_ACTION_DATE")
                               .Select("ACT_START_TIME")
                               .Select("SXREF_COURSE_ID")
                               .From(QuerySources.Sessions);

            //Fetch all sessions
            var allSessionsFromView = sessionsList.Run();

            foreach (var field in allSessionsFromView)
            {
                string startTime    = string.IsNullOrEmpty(field.Values.ToList()[3].ToString()) ? "00:00" : field.Values.ToList()[3].ToString();
                string courseId     = string.IsNullOrEmpty(field.Values.ToList()[4].ToString()) ? "" : "=" + field.Values.ToList()[4].ToString();
                string DisplayValue = string.Format(field.Values.ToList()[1] + " (" + field.Values.ToList()[2].ConvertTo <DateTime>().Date.ToString("dd/MMM/yyyy") + " - " + startTime + ")" + courseId);
                sessionFields.Add(new KeyValuePair <string, string>(field.Values.First().ToString(), DisplayValue));
            }

            this.ServerSessionList.DataSource = sessionFields;
        }