Example #1
0
        private void RecurseClusters(GroupClusterCollection clusters, string day)
        {
            foreach (GroupCluster cluster in clusters)
            {
                if (cluster.Active && cluster.ClusterType.AllowOccurrences)
                {
                    foreach (Group group in cluster.SmallGroups)
                    {
                        if (group.Active &&
                            day.StartsWith(group.MeetingDay.Value.Trim().ToLower()) &&
                            group.Leader != null &&
                            group.Leader.Emails.FirstActive != string.Empty)
                        {
                            Arena.Custom.CCV.Core.Communications.GroupAttendanceReminder reminder = new Arena.Custom.CCV.Core.Communications.GroupAttendanceReminder();
                            Dictionary <string, string> fields = new Dictionary <string, string>();
                            fields.Add("##RecipientFirstName##", group.Leader.NickName);
                            fields.Add("##RecipientLastName##", group.Leader.LastName);
                            fields.Add("##RecipientEmail##", group.Leader.Emails.FirstActive);
                            fields.Add("##RecipientID##", group.Leader.PersonID.ToString());
                            fields.Add("##RecipientGuid##", group.Leader.Guid.ToString());
                            fields.Add("##GroupID##", group.Leader.Emails.FirstActive);
                            fields.Add("##GroupGuid##", group.Guid.ToString());

                            reminder.Send(group.Leader.Emails.FirstActive, fields, group.Leader.PersonID);
                        }
                    }

                    RecurseClusters(cluster.ChildClusters, day);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Load a list of small group placemark objects from the given category ID. The
        /// list is constrained to the start and count parameters.
        /// </summary>
        /// <param name="categoryid">The Arena Category to generate a list of groups from, only active groups are returned.</param>
        /// <param name="start">The member index to start loading from.</param>
        /// <param name="count">The maximum number of groups to load, pass Int32.MaxValue for complete load.</param>
        /// <returns>A list of SmallGroupPlacemark objects.</returns>
        public List <SmallGroupPlacemark> SmallGroupPlacemarksInCategory(int categoryid, int start, int count)
        {
            GroupClusterCollection     gcc;
            List <SmallGroupPlacemark> groups = new List <SmallGroupPlacemark>();
            int i, g;


            gcc = new GroupClusterCollection(categoryid, ArenaContext.Current.Organization.OrganizationID);
            for (i = 0; i < gcc.Count && groups.Count < count; i++)
            {
                List <SmallGroupPlacemark> list = SmallGroupPlacemarksInCluster(gcc[i].GroupClusterID, 0, Int32.MaxValue);

                for (g = 0; g < list.Count && groups.Count < count; g++)
                {
                    if (start-- > 0)
                    {
                        continue;
                    }

                    groups.Add(list[g]);
                }
            }

            return(groups);
        }
Example #3
0
        /// <summary>
        /// Load a list of person placemark objects from the given category ID. The
        /// list is constrained to the start and count parameters.
        /// </summary>
        /// <param name="categoryid">The Arena Category to generate a list of people from, only active members are returned.</param>
        /// <param name="start">The member index to start loading from.</param>
        /// <param name="count">The maximum number of people to load, pass Int32.MaxValue for complete load.</param>
        /// <returns>A list of PersonPlacemark objects.</returns>
        public List <PersonPlacemark> PersonPlacemarksInCategory(int categoryid, int start, int count)
        {
            GroupClusterCollection gcc;
            List <PersonPlacemark> people = new List <PersonPlacemark>();
            int i, p;


            gcc = new GroupClusterCollection(categoryid, ArenaContext.Current.Organization.OrganizationID);
            for (i = 0; i < gcc.Count && people.Count < count; i++)
            {
                List <PersonPlacemark> list = PersonPlacemarksInCluster(gcc[i].GroupClusterID, 0, Int32.MaxValue);

                for (p = 0; p < list.Count && people.Count < count; p++)
                {
                    if (people.Contains(list[p]))
                    {
                        continue;
                    }

                    if (start-- > 0)
                    {
                        continue;
                    }

                    people.Add(list[p]);
                }
            }

            return(people);
        }
 private void DisplayClusters(GroupClusterCollection clusters, string prefix)
 {
     foreach (GroupCluster cluster in clusters)
     {
         ph1.Controls.Add(new LiteralControl(prefix + cluster.GroupClusterID.ToString() + ":" + cluster.Name + "<br/>"));
         DisplayClusters(cluster.ChildClusters, prefix + "--");
     }
 }
Example #5
0
		private void BuildGroupClusterTreeView( GroupClusterCollection clusters, TreeViewNode parentNode )
		{
			foreach ( GroupCluster cluster in clusters )
			{
				TreeViewNode node = new TreeViewNode();
				if ( cluster.Active && cluster.Allowed( OperationType.View, ArenaContext.Current.User, ArenaContext.Current.Person ) )
				{
					node.Text = cluster.Name;
					node.ShowCheckBox = true;
					node.Value = cluster.GroupClusterID.ToString();
					node.ID = cluster.GroupClusterID.ToString();
					node.ImageUrl = "~/images/smallgroup_cluster_level.gif";
					node.Visible = true;

					if ( parentNode == null )
					{
						tvGroups.Nodes.Add( node );
					}
					else
					{
						parentNode.Nodes.Add( node );
					}

					foreach ( Arena.SmallGroup.Group group in cluster.SmallGroups )
					{
						TreeViewNode node2;
						node2 = new TreeViewNode
						{
							Value = group.GroupID.ToString(),
							Text = ( group.Name != string.Empty ) ? group.Name : string.Format( "[Group:{0}]", group.GroupID.ToString() ),
							ShowCheckBox = false,
							ID = group.GroupClusterID.ToString(),
							ImageUrl = "~/include/componentArt/Images/small_groups.gif",
							Visible = true,
							ServerTemplateId = string.Empty
						};
						node.Nodes.Add( node2 );
						if ( node2.Visible )
						{
							ExpandParents( node2 );
						}
					}
					BuildGroupClusterTreeView( cluster.ChildClusters, node );
				}
				if ( parentNode == null )
				{
                    // TODO: do some testing to decide if this needs to be done.
					//RemoveClustersWithNoGroups( node );
					if ( node.Nodes.Count != 0 )
					{
						continue;
					}
					tvGroups.Nodes.Remove( node );
				}
			}
		}
Example #6
0
        /// <summary>
        /// Method to bind Small Groups to a TreeView control.
        /// </summary>
		private void BindGroups()
		{
			GroupClusterCollection cluster = new GroupClusterCollection();
			cluster.LoadRootClusters( _category, ArenaContext.Current.Organization.OrganizationID );
			BuildGroupClusterTreeView( cluster, null );

			if ( ( tvGroups.Nodes.Count == 0 ) || ( tvGroups.Nodes[ 0 ].Nodes.Count == 0 ) )
			{
				tvGroups.Visible = false;
			}
			else if ( tvGroups.Nodes.Count == 1 )
			{
				tvGroups.Nodes[ 0 ].Expanded = true;
			}
		}
Example #7
0
        private string RecurseClusters(GroupClusterCollection groupClusters)
        {
            StringBuilder sb = new StringBuilder();

            if (groupClusters != null && groupClusters.Count > 0)
                foreach (GroupCluster cluster in groupClusters)
                {
                    foreach (Group group in cluster.SmallGroups)
                        sb.Append(GroupShape(group));

                    sb.Append(RecurseClusters(cluster.ChildClusters));
                }

            return sb.ToString();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            DateTime startTime = DateTime.Now;

            GroupClusterCollection clusters = new GroupClusterCollection();

            clusters.LoadChildClusterHierarchy(-1, 1, 3);
            DisplayClusters(clusters, "");
            TimeSpan timeSpan = DateTime.Now.Subtract(startTime);

            ph1.Controls.Add(new LiteralControl(string.Format("[{0} milliseconds]", timeSpan.Milliseconds.ToString("N0"))));

            //startTime = DateTime.Now;
            //ProfileItems profileItems = new ProfileItems(-1, 3, Arena.Enums.ProfileType.Event, 109179);
            //DisplayProfileItems(profileItems, "");
            //timeSpan = DateTime.Now.Subtract(startTime);
            //ph2.Controls.Add(new LiteralControl(string.Format("[{0} milliseconds]", timeSpan.Milliseconds.ToString("N0"))));
        }
Example #9
0
        public Contracts.GenericListResult <Contracts.GenericReference> GetSmallGroupClusters(String categoryID, String clusterID, int start, int max)
        {
            GroupClusterCollection clusters;

            Contracts.GenericListResult <Contracts.GenericReference> list = new Contracts.GenericListResult <Contracts.GenericReference>();
            int i;


            if (categoryID != null)
            {
                clusters = new GroupClusterCollection(Convert.ToInt32(categoryID), Convert.ToInt32(ConfigurationManager.AppSettings["Organization"]));
            }
            else if (clusterID != null)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, Convert.ToInt32(clusterID), OperationType.View) == false)
                {
                    throw new Exception("Access denied.");
                }

                clusters = new GroupClusterCollection(Convert.ToInt32(clusterID));
            }
            else
            {
                throw new Exception("Required parameters not provided.");
            }

            list.Start = start;
            list.Max   = max;
            list.Total = clusters.Count;
            list.Items = new List <Contracts.GenericReference>();
            clusters.Sort(delegate(GroupCluster gc1, GroupCluster gc2) { return(gc1.Name.CompareTo(gc2.Name)); });
            for (i = start; i < clusters.Count && (max <= 0 || i < (start + max)); i++)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, clusters[i].GroupClusterID, OperationType.View) == true)
                {
                    list.Items.Add(new Contracts.GenericReference(clusters[i]));
                }
            }

            return(list);
        }
Example #10
0
        public WorkerResultStatus SendEmail(out string message, out int state)
        {
            WorkerResultStatus workerResultStatus = WorkerResultStatus.Ok;

            message = string.Empty;
            state   = STATE_OK;

            try
            {
                string day = DateTime.Today.DayOfWeek.ToString().ToLower();

                GroupClusterCollection clusters = new GroupClusterCollection();
                clusters.LoadChildClusterHierarchy(-1, _categoryId, _organizationId);
                RecurseClusters(clusters, day);
            }
            catch (Exception ex)
            {
                workerResultStatus = WorkerResultStatus.Exception;
                message            = "An error occured while processing ERA Loss Notifications.\n\nMessage\n------------------------\n" + ex.Message + "\n\nStack Trace\n------------------------\n" + ex.StackTrace;
            }

            return(workerResultStatus);
        }
Example #11
0
        private void BuildMap()
        {
            showGroupType = Boolean.Parse(ShowGroupTypeSetting);
            showMeetingDay = Boolean.Parse(ShowMeetingDaySetting) && category.MeetingDayCaption.Trim() != string.Empty;
            showMeetingTime = Boolean.Parse(ShowMeetingTimeSetting);
            showTopic = Boolean.Parse(ShowTopicSetting) && category.TopicCaption.Trim() != string.Empty;
            showMaritalPreference = Boolean.Parse(ShowMaritalPreferenceSetting) && category.MaritalPreferenceCaption.Trim() != string.Empty;
            showAgeGroup = Boolean.Parse(ShowAgeGroupSetting) && category.AgeGroupCaption.Trim() != string.Empty;
            showAverageAge = Boolean.Parse(ShowAverageAgeSetting);
            showCity = Boolean.Parse(ShowCitySetting);
            showDescription = Boolean.Parse(ShowDescriptionSetting) && category.DescriptionCaption.Trim() != string.Empty;
            showNotes = Boolean.Parse(ShowNotesSetting) && category.NotesCaption.Trim() != string.Empty;

            pnlMap.Controls.Clear();

            if (Request.Url.Port == 443)
                Page.ClientScript.RegisterStartupScript(typeof(string), "VirtualEarth", "<script src=\"https://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6&s=1\"></script>", false);
            else
                Page.ClientScript.RegisterStartupScript(typeof(string), "VirtualEarth", "<script src=\"http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6\"></script>", false);

            pnlMap.Style.Add("position", "relative");
            pnlMap.Style.Add("width", string.Format("{0}px", MapWidthSetting));
            pnlMap.Style.Add("height", string.Format("{0}px", MapHeightSetting));

            StringBuilder sbVEScript = new StringBuilder();

            sbVEScript.Append("var map = null;\n");
            sbVEScript.Append("var mapGroupLayer = null;\n");

            sbVEScript.Append("window.onload = function() {LoadMyMap();};\n");

            sbVEScript.Append("\nfunction LoadMyMap(){\n");
            sbVEScript.AppendFormat("\tmap = new VEMap('{0}');\n", pnlMap.ClientID);

            switch (MapDashboardSizeSetting)
            {
                case "Normal":
                    sbVEScript.Append("\tmap.SetDashboardSize(VEDashboardSize.Normal);\n");
                    break;
                case "Small":
                    sbVEScript.Append("\tmap.SetDashboardSize(VEDashboardSize.Small);\n");
                    break;
                case "Tiny":
                    sbVEScript.Append("\tmap.SetDashboardSize(VEDashboardSize.Tiny);\n");
                    break;
            }

            sbVEScript.Append("\tmap.LoadMap();\n\n");
            //sbVEScript.Append("\tmap.ClearInfoBoxStyles();\n\n");

            Address selectedAddress = null;
            if (Session["PersonAddress"] != null)
                selectedAddress = (Address)Session["PersonAddress"];

            if (selectedAddress == null && CurrentPerson != null)
                selectedAddress = CurrentPerson.PrimaryAddress;

            if (selectedAddress != null &&
                selectedAddress.Latitude != 0 &&
                selectedAddress.Longitude != 0)
            {
                sbVEScript.AppendFormat("\n\tshape = new VEShape(VEShapeType.Pushpin, new VELatLong({0}, {1}));\n",
                    selectedAddress.Latitude.ToString(),
                    selectedAddress.Longitude.ToString());
                sbVEScript.AppendFormat("\tshape.SetCustomIcon('{0}');\n", AddressIconSetting);
                sbVEScript.AppendFormat("\tshape.SetTitle(\"{0}\");\n", Utilities.replaceCRLF(selectedAddress.ToString()));
                sbVEScript.Append("\tmap.AddShape(shape);\n");
            }

            if (Area != null && Area.AreaID != -1)
            {
                sbVEScript.Append("\tvar points = new Array(\n");
                for (int i = 0; i < Area.Coordinates.Count; i++)
                {
                    AreaCoordinate coord = Area.Coordinates[i];
                    sbVEScript.AppendFormat("\t\tnew VELatLong({0}, {1})", coord.Latitude.ToString(), coord.Longitude.ToString());
                    if (i < Area.Coordinates.Count - 1)
                        sbVEScript.Append(",\n");
                }
                sbVEScript.Append("\n\t);\n");
                sbVEScript.Append("\tvar shape = new VEShape(VEShapeType.Polygon, points);\n");
                sbVEScript.Append("\tmap.SetMapView(points);\n");

                sbVEScript.AppendFormat("\tshape.SetLineColor(new VEColor({0}));\n", AreaBorderColorSetting);
                sbVEScript.AppendFormat("\tshape.SetLineWidth({0});\n", AreaBorderWidthSetting);
                sbVEScript.AppendFormat("\tshape.SetFillColor(new VEColor({0}));\n", AreaBackgroundColorSetting);
                sbVEScript.Append("\tshape.HideIcon();\n");
                sbVEScript.AppendFormat("\tshape.SetTitle('{0}');\n", Area.Name);
                sbVEScript.Append("\n\tmap.AddShape(shape);\n");

                sbVEScript.Append("\n\tmapGroupLayer = new VEShapeLayer();\n");
                sbVEScript.Append("\tmapGroupLayer.SetTitle('Groups');\n");
                sbVEScript.Append("\tmap.AddShapeLayer(mapGroupLayer);\n");

                mapGroupCount = 0;
                GroupCollection groups = new GroupCollection();
                groups.LoadByArea(Area.AreaID, category.CategoryID);
                foreach (Group group in groups)
                {
                    if (group.Active)
                    {
                        if (Boolean.Parse(ShowFullGroupsSetting) == false)
                        {
                            int groupCount = (group.LeaderID == -1 ? 0 : 1);
                            foreach (GroupMember member in group.Members)
                                if (member.Active)
                                    groupCount++;

                            if (groupCount < group.MaxMembers)
                                sbVEScript.Append(GroupShape(group));
                        }
                        else
                            sbVEScript.Append(GroupShape(group));
                    }
                }
            }
            else
            {
                GroupClusterCollection clusters = new GroupClusterCollection(category.CategoryID, CurrentOrganization.OrganizationID);
                sbVEScript.Append(RecurseClusters(clusters));

                if (selectedAddress != null &&
                    selectedAddress.Latitude != 0 &&
                    selectedAddress.Longitude != 0)
                {
                    sbVEScript.AppendFormat("\tmap.SetCenterAndZoom(new VELatLong({0}, {1}),12);\n", selectedAddress.Latitude, selectedAddress.Longitude);
                }
                else
                {
                    sbVEScript.Append("\tvar maxPoints = new Array(\n");
                    sbVEScript.AppendFormat("\t\tnew VELatLong({0}, {1}),\n", minLatitude.ToString(), minLongitude.ToString());
                    sbVEScript.AppendFormat("\t\tnew VELatLong({0}, {1}))\n", maxLatitude.ToString(), maxLongitude.ToString());
                    sbVEScript.Append("\tmap.SetMapView(maxPoints);\n");
                    //sbVEScript.Append("\tmap.ZoomIn();\n\n");
                }
            }

            sbVEScript.Append("}\n");

            sbVEScript.Append("\nfunction ShowGroup(shapeIndex){\n");
            sbVEScript.Append("\tvar shape = mapGroupLayer.GetShapeByIndex(shapeIndex);\n");
            sbVEScript.Append("\tvar latLong = shape.GetPoints();\n");
            sbVEScript.Append("\tmap.SetCenterAndZoom(latLong[0], 15);\n");
            sbVEScript.Append("\tsetTimeout(\"ShowInfoBox(\" + shapeIndex + \")\", 1000);\n");
            sbVEScript.Append("}\n");

            sbVEScript.Append("\nfunction ShowInfoBox(shapeIndex){\n");
            sbVEScript.Append("\tvar shape = mapGroupLayer.GetShapeByIndex(shapeIndex);\n");
            sbVEScript.Append("\tvar latLong = shape.GetPoints();\n");
            sbVEScript.Append("\tmap.ShowInfoBox(shape, latLong[0]);\n");
            sbVEScript.Append("}\n");

            // add Safari fix
            sbVEScript.Append("VEValidator.ValidateFloat = function(float) {");
            sbVEScript.Append("\treturn true;");
            sbVEScript.Append("}");

            Page.ClientScript.RegisterStartupScript(typeof(string), "LoadMap", sbVEScript.ToString(), true);
        }
        public Contracts.GenericListResult<Contracts.GenericReference> GetSmallGroupClusters(String categoryID, String clusterID, int start, int max)
        {
            GroupClusterCollection clusters;
            Contracts.GenericListResult<Contracts.GenericReference> list = new Contracts.GenericListResult<Contracts.GenericReference>();
            int i;

            if (categoryID != null)
            {
                clusters = new GroupClusterCollection(Convert.ToInt32(categoryID), Convert.ToInt32(ConfigurationManager.AppSettings["Organization"]));
            }
            else if (clusterID != null)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, Convert.ToInt32(clusterID), OperationType.View) == false)
                    throw new Exception("Access denied.");

                clusters = new GroupClusterCollection(Convert.ToInt32(clusterID));
            }
            else
                throw new Exception("Required parameters not provided.");

            list.Start = start;
            list.Max = max;
            list.Total = clusters.Count;
            list.Items = new List<Contracts.GenericReference>();
            clusters.Sort(delegate(GroupCluster gc1, GroupCluster gc2) { return gc1.Name.CompareTo(gc2.Name); });
            for (i = start; i < clusters.Count && (max <= 0 || i < (start + max)); i++)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, clusters[i].GroupClusterID, OperationType.View) == true)
                {
                    list.Items.Add(new Contracts.GenericReference(clusters[i]));
                }
            }

            return list;
        }