示例#1
0
    }//end of InitializePagingVars()
		
	protected void Page_PreRender(object sender, EventArgs e)
    {
		try
		{
			//code will load and initialize the JavaScript SDK with all standard options
			if (!Page.ClientScript.IsClientScriptBlockRegistered("facebook_api"))
               	Page.ClientScript.RegisterClientScriptInclude("facebook_api", String.Format("http://connect.facebook.net/{0}/all.js", "en_US"));
 
           	if (!Page.ClientScript.IsStartupScriptRegistered("facebook_api_init"))
				Page.ClientScript.RegisterStartupScript(typeof(string), "facebook_api_init", String.Format("FB.init({{appId: '{0}', status: true, cookie: true, xfbml: true, oauth: true }});", "574005609290762"), true);
 
           	if (!Page.ClientScript.IsStartupScriptRegistered("facebook_login"))
           	{
               	string facebookLogin = String.Format("function fblogin() {{ FB.login(function(response) {{ if (response.authResponse) {{ {0} }} else {{ {1} }}}}, {{ scope: '{2}' }});}}", this.Page.ClientScript.GetPostBackEventReference(this.Page, "FacebookLogin", false), this.Page.ClientScript.GetPostBackEventReference(this.Page, "FacebookLogout", false), "publish_stream,email");
				
               	Page.ClientScript.RegisterStartupScript(typeof(string), "facebook_login", facebookLogin, true);
           	}//end of if
 
           	if (!Page.ClientScript.IsStartupScriptRegistered("facebook_logout"))
           	{
               	string facebookLogout = String.Format("function fblogout() {{ FB.logout(function(response) {{ {0} }}); }}", this.Page.ClientScript.GetPostBackEventReference(this.Page, "FacebookLogout", false));
               	Page.ClientScript.RegisterStartupScript(typeof(string), "facebook_logout",
                  facebookLogout, true);
           	}//end of if
			
			FacebookApp facebookApp = new FacebookApp();//holds an object of the FB
				
			//checks if the user is connected to the session
			if (facebookApp.Session != null && facebookApp.AccessToken != null)
			{
				var facebookUser = facebookApp.Api("me") as JsonObject;//holds the object of the user
	
				//checks if the the user has submited a condolence		
				if(panCondoloncesThankYou.Visible == false)
					//displays the Condolace section
					panLeaveCondolence.Style.Add("display", "block");
				else
					//closes the Leave Condolence section
					panLeaveCondolence.Style.Add("display", "none");
					
				//removes the socail and user text boxes as the user is now already sign in
				//and turns on the label of the user and displays the logout button
				panCondolenceSocialOption.Visible = false;
				panConEnterNameEmail.Visible = false;
				panConNameEmail.Visible = true;
				panLogOutFB.Visible = true;
				
				//checks if there is a user name 
				if (facebookUser.ContainsKey("username") && facebookUser["username"] != null)
					lblConnectedUser.Text = facebookUser["username"].ToString();

				//checks if there is a name from FB	
				if (facebookUser.ContainsKey("name") && facebookUser["name"] != null)		
					//displays the name from FB
					lblConnectedName.Text = facebookUser["name"].ToString();
				
				//checks if there is a email from FB
				if (facebookUser.ContainsKey("email") && facebookUser["email"] != null)
					//displays the email from FB
					lblConnectedEmail.Text = facebookUser["email"].ToString();
					
				//sets the which social network the user is usiing
				hfObituaryCondolenceSocialNetwork.Value = "1";
			}//end of if
			else
			{
				//adds the Social Options and allow the user to enter their own email
				//and removes the FB Logout and email
				panCondolenceSocialOption.Visible = true;
				panConEnterNameEmail.Visible = true;
				panConNameEmail.Visible = false;
				panLogOutFB.Visible = false;
		
				//resets all of the social fields
				lblConnectedUser.Text = "";
				lblConnectedName.Text = "";
				lblConnectedEmail.Text = "";
				hfObituaryCondolenceSocialNetwork.Value = "0";
			}//end of else
			
			//checks if the user is logged into twitter
			if (Request["oauth_token"] != null)
			{
				Session["TwitterRequestToken"] = Request["oauth_token"].ToString();
                Session["TwitterPin"] = Request["oauth_verifier"].ToString();
 
                var tokens = OAuthUtility.GetAccessToken(
                    ConfigurationManager.AppSettings["consumerKey"],
                    ConfigurationManager.AppSettings["consumerSecret"],
                    Session["TwitterRequestToken"].ToString(),
                    Session["TwitterPin"].ToString());
 
                OAuthTokens oatAccess = new OAuthTokens()
					{
						AccessToken = tokens.Token,
						AccessTokenSecret = tokens.TokenSecret,
						ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
						ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"]
					};
 
 				TwitterResponse<TwitterUser> twitterResponse = TwitterAccount.VerifyCredentials(oatAccess);//holds the response that has come from twitter with if this is a good token
 
                if (twitterResponse.Result == RequestResult.Success)
				{
                   //We now have the credentials, so make a call to the Twitter API.
					HtmlMeta hmTwitter = new HtmlMeta();//holds the meta takes that will go into the header
			    	HtmlHead head = (HtmlHead)Page.Header;//holds the reference of the Header
										
					//removes the socail and user text boxes as the user is now already sign in
					//and turns on the label of the user
					panCondolenceSocialOption.Visible = false;
					panConEnterNameEmail.Visible = false;
					panConNameEmail.Visible = true;
					
					//sets the which social network the user is usiing
					hfObituaryCondolenceSocialNetwork.Value = "2";
													
					//sets the username and actully name
					lblConnectedUser.Text = twitterResponse.ResponseObject.ScreenName;
					lblConnectedName.Text = twitterResponse.ResponseObject.Name;

					//define an HTML meta twitter:creator in the header 
					hmTwitter.Name = "twitter:creator";
					hmTwitter.Content = lblConnectedUser.Text;
					hmTwitter.Controls.Add(hmTwitter);
					
					//because twitter does not allow access to the email address this should not be display
					panConnectedEmail.Visible = false;
				}//end of if
			}//end of if
				

                DataTable dtObituaryDetails = null;
                if (panSidebarLinks.Visible)
                    dtObituaryDetails = DAL.getRow("", "WHERE  = '" + General.ObituaryStatus.Published.ToString() + "' AND  = " + hfObituaryID.Value);//holds the Obituary details
                else
                    dtObituaryDetails = DAL.getRow("", "WHERE  = " + hfObituaryID.Value);//holds the Obituary details
								
				//checks if there is any details for this obituary
				if (dtObituaryDetails != null && dtObituaryDetails.Rows.Count > 0)
				{
					int intIndexServiceID = 0;//holds the unquie id of the row
					string strLastFHID = "";//holds what is the last FHID
					string strShareDescription = "";//holds the description that will share to the world
					DataTable dtImage = DAL.getRow("","Where  = " + hfObituaryID.Value + " Order by ");//holds the Images for this Obituary
					DataTable dtObitService = DAL.getRow("", "WHERE  = " + hfObituaryID.Value + " Order by , , ");//gets all services for this obituary
					DataTable dtObitFlowers = DAL.getRow("", "WHERE  = " + hfObituaryID.Value + " AND  = 1 Order by , ");//holds the Flower Recipient
					DataTable dtObitCards = DAL.queryDbTable("SELECT , ,  + ' ' +   FROM  WHERE  = " + hfObituaryID.Value + " AND  = 1");

					//checks if there is any images to display
					if(dtImage.Rows.Count > 0)
						//sets an iframe to display the image slider as the image slider uses a advance jquery
						//the DNN does not run
						litImageSlider.Text = "<iframe id='iframeImageSlider' src='/ImageSlider.aspx?=" + hfObituaryID.Value + "' scrolling='no'></iframe>";

                    //checks if this is PrePla or Memorial n if so then change the text for Leave Condolence
                    if (dtObituaryDetails.Rows[0][""].ToString() == ((int)General.ObituaryType.PrePlan).ToString() || dtObituaryDetails.Rows[0][""].ToString() == ((int)General.ObituaryType.Memorial).ToString())
                    {
                        hlLeaveCondolence.Text = "Leave a Condolence or Message";
                        lblNoOfCondolences.Text = " Condolences or Messages";
						panLeaveCondolenceTitleLeft.CssClass += " divLeaveCondolenceMmemoralTitleLeft";
                    }//end of if
					
					//checks if this user is logged in and they have not logged into a soical network
					//get there there details instead of typing it in
					if(Session[""] != null && panConNameEmail.Visible == false)
					{
						DataTable dtUserDetails = DAL.getRow("", "WHERE  = " + Session[""].ToString());//holds the this user detail that is logged in
						
						//sets the users name and email to tell the user that this is what is going to be displayed
						lblConnectedName.Text = dtUserDetails.Rows[0][""].ToString() + " " + dtUserDetails.Rows[0][""].ToString();
						lblConnectedEmail.Text = dtUserDetails.Rows[0][""].ToString();
						lblReminderEmail.Text = dtUserDetails.Rows[0][""].ToString();
																		
						//displays the user name and email to tell the user who the are login in as
						panConNameEmail.Visible = true;
						//lblReminderEmail.Visible = true;
						panConEnterNameEmail.Visible = false;
						panCondolenceSocialOption.Visible = false;                        
					}//end of if

					//sets the condolences, the number of them for this Obituary and paging
			        BindDesignsPanel();
					
					//sets the on Click for the link Leave Condolence to turn it off and on
					hlLeaveCondolence.Attributes.Add("onClick", "javascript:toggleLayer('" + panLeaveCondolence.ClientID + "', '', '');");
                    hlSectionCondolence.Attributes.Add("onClick", "javascript:toggleLayer('" + panLeaveCondolence.ClientID + "', '', '');" + panLeaveCondolence.ClientID + ".scrollIntoView(true);");
					
					//sets the basis settings
					lblName.Text = dtObituaryDetails.Rows[0][""].ToString() + ", "  + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString();
					lblPrintName.Text = dtObituaryDetails.Rows[0][""].ToString() + ", "  + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString();
					
					//sets the sidebar name of the user
                    lblShareForName.Text = dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString();
					lblReminderForName.Text = dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString();
					lblReminderForName2.Text = dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString();
					
					//sets the title of the page
					Page.Title = "The Obituaries - Details for " + dtObituaryDetails.Rows[0][""].ToString() + " " + dtObituaryDetails.Rows[0][""].ToString();
					
					//sets the flower FH sidebar
					panFlowersFH.Visible = Convert.ToBoolean(dtObituaryDetails.Rows[0][""].ToString());
					
					//checks if there is a FHID
                    if (Convert.ToInt32(dtObituaryDetails.Rows[0][""].ToString()) > 0)
                    {
                        //sets the FHID for this flower request
                        hlFlowerFH.NavigateUrl += dtObituaryDetails.Rows[0][""].ToString() + "&oid=" + hfObituaryID.Value;
                        chkFuneralHome.Text = " All announcements from <strong>" + DAL.queryDbScalar("SELECT  FROM  WHERE  = '" + dtObituaryDetails.Rows[0][""].ToString() + "'") + "</strong>";
                    }//end of if
                    else
                        //removes the Flowers FH is there is no FHID to use
                        panFlowersFH.Visible = chkFuneralHome.Visible = false;
					
					//sets the Anotehr Address URL for flowers and cards	
					hlSendCardsAnotherAddress.NavigateUrl = "/Obituaries/sympathycards.aspx?ObituariesID=" + hfObituaryID.Value;
					hlSendFlowersAnotherAddress.NavigateUrl = "/Obituaries/flower.aspx?person=2&FHPID=0&oid=" + hfObituaryID.Value;
					
					//checks if there is any flowsers 
					if(dtObitFlowers.Rows.Count > 0)
					{
						//sets the flowers recipient in the sidebar
						dlFlowerRecipient.DataSource = dtObitFlowers;
						dlFlowerRecipient.DataBind();
					}//end of if
					else
						//removes the 'or' flowers from view
                        panFlowersOr.Visible = false;
											
					//checks if there is any cards 
					if (dtObitCards != null && dtObitCards.Rows.Count > 0)
					{
						//sets the card recipient in the sidebar
						rpCardReceiver.DataSource = dtObitCards;
						rpCardReceiver.DataBind();
					}//end of if
					else
						//removes the 'or' card from view
						panCardOr.Visible = false;
						
					//resets lblBirthDateAndPassingDate
					lblBirthDateAndPassingDate.Text = "";
		
					//checks if there is a birth date
					if(!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()))
						lblBirthDateAndPassingDate.Text += Convert.ToDateTime(dtObituaryDetails.Rows[0][""].ToString()).ToString("MMMM dd, yyyy");
						
					//checks that there must be both a birth\death date for - to display
					if(!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()) && !string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString())) 
						lblBirthDateAndPassingDate.Text += " - ";
						
					//checks if there is a death date or a is this a pre-plan obituarie
					if(!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()))
						//sets the death year
						lblBirthDateAndPassingDate.Text += Convert.ToDateTime(dtObituaryDetails.Rows[0][""].ToString()).ToString("MMMM dd, yyyy");
						
					//checks if there is any text in the lblBirthDateAndPassingDate
					//in order to add it to the print version
					if(!string.IsNullOrEmpty(lblBirthDateAndPassingDate.Text))
						lblPrintBirthDateAndPassingDate.Text = lblBirthDateAndPassingDate.Text;
						
					//sets the twitter sharing for this obituery
					hlShareTwiiter.NavigateUrl = "https://twitter.com/share?url=" + Server.UrlEncode("http://theobituaries.ca/Obituaries.aspx?ObituariesID=" + hfObituaryID.Value) + "&text=Obituary for " + lblName.Text;
					
					//sets the linkin sharing for this obituery
					ltlLinkin.Text = "<script type='IN/Share' data-url='" + Server.UrlEncode("http://theobituaries.ca/Obituaries.aspx?ObituariesID=" + hfObituaryID.Value) + "'></script>";
					
					//checks if strShareDescription has any content
					if(string.IsNullOrEmpty(strShareDescription))
						//uses a default text as to not have DNN text display on the user's condolences
						strShareDescription = "A condolence for " + dtObituaryDetails.Rows[0][""].ToString() + " "  + dtObituaryDetails.Rows[0][""].ToString();
					
					//sets the Facebook sharing for this obituery
					litFB.Text = "<iframe src='http://www.facebook.com/plugins/like.php?href=http%3A%2F%2F" + Request.Url.Host + "%2FObituaries.aspx%3FObituariesID%3D" + hfObituaryID.Value + "&amp;send=false&amp;layout=button_count&amp;width=60&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21&amp;appId=574005609290762' scrolling='no' frameborder='0' style='overflow:hidden;height:21px;' allowTransparency='true'></iframe>";
								  
					HtmlMeta hmFB = new HtmlMeta();//holds the meta takes that will go into the header
				    HtmlHead head = (HtmlHead)Page.Header;//holds the reference of the Header
					
                    lnkSendCardToFuneralHome.Visible = false;

                    if (dtObituaryDetails.Rows[0][""].ToString() == "True" && !string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()) && dtObituaryDetails.Rows[0][""].ToString() != "0")
                    {
                        lnkSendCardToFuneralHome.NavigateUrl = "/Obituaries/sympathycards.aspx?ObituariesID=" + hfObituaryID.Value + "&FuneralHomeID=" + dtObituaryDetails.Rows[0][""].ToString();
                        lnkSendCardToFuneralHome.Visible = true;
                    }//end of if

                    if (!string.IsNullOrEmpty(dtObituaryDetails.Rows[0][""].ToString()))
                        hfObituaryCreatorEmail.Value = DAL.queryDbScalar("SELECT  FROM  WHERE  = '" + dtObituaryDetails.Rows[0][""].ToString() + "'");
						
					//resets litObituaryServices
					litObituaryServices.Text = "";
							
					//checks if there is any sevices
					if(dtObitService.Rows.Count > 0)
					{
						//goes around adding the services of the Obituary
						foreach (DataRow drObitService in dtObitService.Rows)
						{
							//checks if there is a FHID or or  is the different
							//this is different from the next one as this will skip the whole row
							if(Convert.ToInt32(drObitService[""].ToString()) != 0 || Convert.ToInt32(drObitService[""].ToString()) == 0 && strLastFHID != drObitService[""].ToString())
							{ 
								//checks if the last FHID or  is the different
								if(strLastFHID != drObitService[""].ToString() || Convert.ToInt32(drObitService[""].ToString()) == 0 && strLastFHID != drObitService[""].ToString())
								{
									DataTable dtFHDetails = DAL.getRow("", "WHERE  = " + Convert.ToInt32(drObitService[""].ToString()));//holds the Funeral Home details
						
									//checks if this is a the first service
									//as there is not last service yet
									if(!string.IsNullOrEmpty(strLastFHID))			
										//create a ends the last serivce 
										litObituaryServices.Text += "</div>";
									
									//starts a new one
									litObituaryServices.Text += "<div class='customContainer divObiturayDetailsServiceContainer'>" + 
										"<div class='customLeft divObiturayDetailsServiceLeft'>";
										
											//checks if this FH is in the database and if it is a partner
											if (dtFHDetails != null && dtFHDetails.Rows.Count > 0)
											{
												string strSearchItemMap = "";//holds the map of the search itme
												
												//checks if there is a address to search for the google map
												if(!string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString()) && !string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString()) && !string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString()))
												{
													//checks if there is a already a location that the user wants to use
													if(dtFHDetails.Rows[0][""] == null || string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString().Trim()))					
														//adds the funcation that will activate the google map hidden
														strSearchItemMap = "getLocationHiddenGeo(&quot;" + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "," + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "," + dtFHDetails.Rows[0][""] + "&quot;,&quot;" + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "&quot;,43.64100156269233,-79.38599562435303);";
													else
														//adds funcation that will activate the google map hidden what the user want to display
														strSearchItemMap = "getLocationHiddenGeo(&quot;" + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "," + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "," + dtFHDetails.Rows[0][""] + "&quot;,&quot;" + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "&quot;," + dtFHDetails.Rows[0][""] + ");";
												}//end of if
																								
												//loads the ability to display the map
                                                if (panSidebarLinks.Visible)
                                                    litObituaryServices.Text += "<a href='javascript:void(0);' onClick='" + strSearchItemMap + "toggleLayer(&quot;divHiddenHeaderMap&quot;,&quot;divGrayBG&quot;,&quot;&quot;);getDocID(&quot;lblHiddenMapName&quot;).innerHTML=&quot;Location for " + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + " - " + dtFHDetails.Rows[0][""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + ", " + dtFHDetails.Rows[0][""].ToString() + "&quot;;'><img alt='Map' src='/Portals/_default/skins/Obit/Images/obits-map.jpg' /></a>";
                                                else
                                                    litObituaryServices.Text += "<img alt='Map' src='/Portals/_default/skins/Obit/Images/obits-map.jpg' />";
											}//end of if
											//displays a custom FH that the user has create
											else
												litObituaryServices.Text += "<a href='javascript:void(0);' onClick='getLocationHiddenGeo(&quot;" + drObitService[""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "," + drObitService[""].ToString().Replace("'", "&lsquo;").Replace("\"", "&quot;") + "," + drObitService[""] + "&quot;,&quot;" + drObitService[""].ToString().Replace("'","&lsquo;").Replace("\"","&quot;") + "&quot;,43.64100156269233,-79.38599562435303);toggleLayer(&quot;divHiddenHeaderMap&quot;,&quot;divGrayBG&quot;,&quot;&quot;);getDocID(&quot;lblHiddenMapName&quot;).innerHTML=&quot;Location for " + drObitService[""].ToString().Replace("'","&lsquo;").Replace("\"","&quot;") + " - " + drObitService[""].ToString().Replace("'","&lsquo;").Replace("\"","&quot;") + ", " + drObitService[""].ToString() + "&quot;;'><img alt='Map' src='/Portals/_default/skins/Obit/Images/obits-map.jpg' /></a>";
												
										litObituaryServices.Text += "</div>" + 
										"<div class='customRight divObiturayDetailsServiceRight'>";
											
												//checks if this FH is in the database and if it is a partner
												if (dtFHDetails != null && dtFHDetails.Rows.Count > 0)
												{
													//checks if this is a Publish FH or non
                                                    if (dtFHDetails.Rows[0][""].ToString() == "1" && panSidebarLinks.Visible)
														litObituaryServices.Text += "<a href='/FuneralHome.aspx?FuneralHomeId=" + dtFHDetails.Rows[0][""].ToString() + "'>" + 
															dtFHDetails.Rows[0][""].ToString() + 
														"</a>";
													else
														litObituaryServices.Text += "<label class='lblObituaryFHServiceName'>" +
															dtFHDetails.Rows[0][""].ToString() + 
														"</label>";
													
													litObituaryServices.Text += "<div class='divObiturayServiceLocation'>" +
														dtFHDetails.Rows[0][""].ToString() + ", " + dtFHDetails.Rows[0][""].ToString() + ", " + dtFHDetails.Rows[0][""].ToString() + ", " + dtFHDetails.Rows[0][""].ToString() + 
													"</div>";
												}//end of if
												//displays a custom FH that the user has create
												else
												{
													//checks if there is a custom name for this custom FH
													if(!string.IsNullOrEmpty(drObitService[""].ToString()))
														litObituaryServices.Text += "<label class='lblObituaryFHServiceName'>" +
															drObitService[""].ToString() + 
														"</label>" +
														"<div class='divObiturayServiceLocation'>";
													else
														//beacuse divObiturayServiceLocation has a padding this will move
														//make the address not appeaeal with the map icon this wll fix it
														litObituaryServices.Text += "<div class='divObiturayServiceNoCustomLocationName'>";
														
													litObituaryServices.Text += drObitService[""].ToString() + ", " + drObitService[""].ToString() + ", " + drObitService[""].ToString() + ", " + drObitService[""].ToString() + 
													"</div>";
												}//end of else
												 
											//sets the link to open the location and start the service detail div
											litObituaryServices.Text += "<a href='#service-location-" + intIndexServiceID + "' class='toggle-location scroll-show'>Open Location</a>" + 
										"</div>" + 
										"<div class='customFooter divObiturayDetailsServiceFooter'></div>";
									
									//checks if this row is a FH or a custom address
									//and then updates the strLastFHID
									if(Convert.ToInt32(drObitService[""].ToString()) == 0)
										strLastFHID = drObitService[""].ToString();
									else
										strLastFHID = drObitService[""].ToString();
								}//end of if
								
								//displays the details of the service
								litObituaryServices.Text += "<div class='divObiturayServiceDateTime'>" + 
									"<div class='divObiturayServiceDate'>" + 
										"<label>" + Convert.ToDateTime(drObitService[""].ToString()).ToString("dddd, MMMM d, yyyy") + "</label>" + 
									"</div>" + 
									"<div class='divObiturayServiceTime'>" + 
										"<label><strong>"; 
				
									//checks which Obituary Service Type is this and displays it
									switch(Convert.ToInt32(drObitService[""].ToString()))
									{
										case 0:
											litObituaryServices.Text += "Visitation";
										break;
										case 1:
											litObituaryServices.Text += "Funeral Service";
										break;
										case 2:
											litObituaryServices.Text += "Graveside Service";
										break;
										case 3:
											litObituaryServices.Text += "Memorial Service";
										break;
										case 4:
											litObituaryServices.Text += "Non Commemorative Funeral";
										break;
										case 6:
											litObituaryServices.Text += "Celebration of Life";
										break;
										default:
											litObituaryServices.Text += drObitService[""].ToString();
										break;										
									}//end of switch
										
									//displays the service start time
									litObituaryServices.Text += " - " + Convert.ToDateTime(drObitService[""].ToString()).ToString("h:mm tt");
									
									//checks if there is a service end time
									if(!string.IsNullOrEmpty(drObitService[""].ToString()) && drObitService[""].ToString() != "00:00:00")
										//displays the service end time
										litObituaryServices.Text += " - " + Convert.ToDateTime(drObitService[""].ToString()).ToString("h:mm tt");
									
								//end the details of the service
								litObituaryServices.Text += "</strong></label>" + 
									"</div>" + 
								"</div>";
								
								intIndexServiceID++;
							}//end of if
						}//end of foreach
						
						//closes the last service
						litObituaryServices.Text += "</div>";
					}//end of if
					else
						//remvoes the service section from display	
						panObituaryServices.Visible = false;
				}//end of if
			//}//end of if				
		}//end of try
        catch (Exception ex)
        {
            lblMainError.Text = ex.Message;// + " " + ex.StackTrace;
            lblMainError.Visible = true;
        }//end of catch
    }//end of Page_PreRender()
示例#2
0
        private void btnAreFriends_Click(object sender, EventArgs e)
        {
            // calculate total calls to Facebook for this
            int totalCalls = 0;

            // ((n) + (n-1) + (n-2) + ... 1) - n = number of combinations
            for (int i = Friends.Keys.Count; i > 0; i--)
            {
                totalCalls += i;
            }
            totalCalls -= Friends.Keys.Count;

            if (MessageBox.Show(
                    string.Format("Warning: checking for friend relationships can take a long time! \n(Generates {0} calls to Facebook to check friend combinations).  \n\nDo you want to continue?", totalCalls),
                    "Warning: Long operation", MessageBoxButtons.YesNo)
                == System.Windows.Forms.DialogResult.Yes)
            {
                // init array of friend IDs
                FriendIds = new string[Friends.Keys.Count];
                Friends.Keys.CopyTo(FriendIds, 0);

                for (int i = 0; i < FriendIds.Length; i++)
                {
                    for (int j = i + 1; j < FriendIds.Length; j++)
                    {
                        try
                        {
                            tsStatusMessage.Text = string.Format("Checking {0} and {1}", Friends[FriendIds[i]].Name, Friends[FriendIds[j]].Name);
                            Application.DoEvents();

                            Dictionary <string, object> parms = new Dictionary <string, object>();
                            parms.Add("method", "friends.areFriends");
                            parms.Add("uids1", FriendIds[i]);
                            parms.Add("uids2", FriendIds[j]);
                            parms.Add("format", "json");
                            object             obj  = app.Api(parms);
                            Facebook.JsonArray resp = (Facebook.JsonArray)obj;
                            if ((bool)((Facebook.JsonObject)resp[0])["are_friends"] == true)
                            {
                                string friendId1   = ((Facebook.JsonObject)resp[0])["uid1"].ToString();
                                string friendId2   = ((Facebook.JsonObject)resp[0])["uid2"].ToString();
                                string friendName1 = Friends.ContainsKey(friendId1) ?
                                                     Friends[friendId1].Name : "";
                                string friendName2 = Friends.ContainsKey(friendId2) ?
                                                     Friends[friendId2].Name : "";

                                FriendPairs.Add(string.Format("{0},{1},{2},{3}",
                                                              friendId1, friendId2, friendName1, friendName2));
                                FriendPairs.Add(string.Format("{0},{1},{2},{3}",
                                                              friendId2, friendId1, friendName2, friendName1));
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                lblStep5.Visible     = true;
                tsStatusMessage.Text = "Check for who is friends with who: complete!";
            }
        }
        private List <Result> UpdateAchievements()
        {
            IEnumerable <User> users;

            using (IAchievementManager manager = new AchievementManager())
            {
                // get users configured for auto update
                users = manager.GetAutoUpdateUsers();
            }

            List <Result> results = new List <Result>();

            using (SteamCommunityManager manager = new SteamCommunityManager())
                using (IAchievementService service = new AchievementService())
                {
                    foreach (User user in users)
                    {
                        Log("User: "******" ( " + user.FacebookUserId + ")");

                        if (String.IsNullOrEmpty(user.AccessToken))
                        {
                            Log("Empty AccessToken");

                            // if there is no access token, the user hasn't given the app offline_access
                            continue;
                        }

                        // update the user's achievements
                        int updated = service.UpdateAchievements(user.SteamUserId);

                        if (updated == 0)
                        {
                            Log("No updated achievements");

                            continue;
                        }

                        // get the user's unpublished achievements
                        IEnumerable <SimpleAchievement> achievements = service.GetNewAchievements(user.SteamUserId);

                        if (!achievements.Any())
                        {
                            Log("No unpublished achievements");

                            continue;
                        }

                        FacebookApp app          = new FacebookApp(user.AccessToken);
                        string      userFeedPath = String.Format("/{0}/feed/", user.FacebookUserId);

                        List <int> publishedAchievements = new List <int>();

                        // post the first 5 new achievements
                        foreach (SimpleAchievement achievement in achievements.Take(5))
                        {
                            string message = String.Format("{0} earned an achievement in {1}",
                                                           user.SteamUserId, achievement.Game.Name);
                            dynamic parameters = new ExpandoObject();
                            parameters.link        = achievement.Game.StatsUrl;
                            parameters.message     = message;
                            parameters.name        = achievement.Name;
                            parameters.description = achievement.Description;
                            parameters.picture     = achievement.ImageUrl;

                            Log(message);

                            Result result = new Result
                            {
                                SteamUserId = user.SteamUserId,
                                GameName    = achievement.Game.Name,
                                Description = achievement.Name
                            };

                            try
                            {
                                dynamic response = app.Api(userFeedPath, parameters, HttpMethod.Post);

                                publishedAchievements.Add(achievement.Id);
                            }
                            catch (FacebookApiException ex)
                            {
                                // log Facebook errors and continue
                                result.ExceptionMessage += Environment.NewLine + "Exception: " + ex.Message;
                                if (ex.InnerException != null)
                                {
                                    result.ExceptionMessage += Environment.NewLine + ", Inner Exception: " + ex.InnerException.Message;
                                }

                                Log(result.ExceptionMessage);
                            }

                            results.Add(result);
                        }

                        // update the published flag
                        service.PublishAchievements(user.SteamUserId, publishedAchievements);

                        Log("User achievements published");
                    }
                }

            return(results);
        }