Beispiel #1
0
    private void handleFacebookUser(string sessionKey, string userId)
    {
        log.Debug("Handling facebook user", userId);

        facebookApi = new FacebookAPI();

        facebookApi.IsDesktopApplication = false;
        facebookApi.ApplicationKey       = apikey;
        facebookApi.Secret = apisecret;

        facebookApi.SessionKey = sessionKey;
        facebookApi.UserId     = userId;

        facebookApi.ConnectToFacebook();

        FacebookId = facebookApi.GetLoggedInUser();
        Collection <Facebook.Entity.User> fb_users = facebookApi.GetUserInfo(facebook_id);

        log.Debug("Got Facebook users fb_users", fb_users);
        fb_user = fb_users[0];
        log.Debug("Facebook user fb_user", fb_user);

        IRecordList <DreamFolk> dreamFolk = DataProvider.LoadList <DreamFolk>(new FilterInfo("FacebookId", FacebookId));

        log.Debug("Got dreamFolk folk with FacebookId", FacebookId, dreamFolk);

        DreamFolk dreamPerson = null;

        if (dreamFolk.Count > 0)
        {
            dreamPerson = dreamFolk[0];
        }

        if (dreamPerson == null)
        {
            log.Warn("Creating new dreamPerson from Main.Current");
            dreamPerson = new DreamFolk(Main.Current.FbUser);
            dreamPerson.Save(true);
        }

        /*
         * else if ( dreamPerson.Birthday != Main.Current.FbUser.Birthday )
         * {
         *      log.Warn("Updating birthday dreamPerson from Main.Current");
         *      dreamPerson.Birthday = (DateTime)Main.Current.FbUser.Birthday;
         *      dreamPerson.Save(true);
         * }
         * else if ( !dreamPerson.Updated )
         */
        else
        {
            log.Warn("Updating dreamPerson");
            dreamPerson.update(fb_user);
            dreamPerson.Updated = true;
            dreamPerson.Save(true);
        }

        CurrentDreamFriend = dreamPerson;
        Now.Friends        = CurrentDreamFriend.Friends;
    }
Beispiel #2
0
        public static void InitDataBase()
        {
            IRecordList <Glyph> glyphs = DataProvider.LoadList <Glyph>();

            if (glyphs.Count == 0)
            {
                Glyph glyph;
                for (int i = 0; i <= 20; i++)
                {
                    glyph = new Glyph(i);
                    glyph.Save();
                }
            }
        }
Beispiel #3
0
        public static void InitDataBase()
        {
            IRecordList <Tone> tones = DataProvider.LoadList <Tone>();

            if (tones.Count == 0)
            {
                Tone tone;
                for (int i = 0; i <= 13; i++)
                {
                    tone = new Tone(i);
                    tone.Save();
                }
            }
        }
Beispiel #4
0
    public void Recalc(object state)
    {
        log.Warn("doing recalc2");
        log.Warn("doing recalc3");
        IRecordList <DreamFolk> dreamFriends = DataProvider.LoadList <DreamFolk>();

        log.Warn("loaded dreamFriends count: ", dreamFriends.Count);
        foreach (DreamFolk dreamFriend in dreamFriends)
        {
            dreamFriend.Birthday = dreamFriend.Birthday;
            dreamFriend.Save();
            log.Debug("recalced and saved " + dreamFriend.FacebookId);
        }
        log.Warn("birthdays recalculated: " + dreamFriends.Count);
    }
Beispiel #5
0
 public override Widget GetPropertyEditWidget(Widget parent, ColumnInfo column, IRecordList records)
 {
     switch (column.Name)
     {
         case "PayloadType":
             LabeledWidget<DropDown> dd = Context.Current.CreateWidget<LabeledWidget<DropDown>>();
             dd.LabelText = "Task Type";
             dd.Widget.Options = getTaskTypes();
             dd.Widget.OnChanged += new EventHandler<EmergeTk.ChangedEventArgs>(delegate(object sender, ChangedEventArgs ea )
             {
                 string opt = dd.Widget.SelectedOption;
                 this.payloadType = opt != "--SELECT--" ? opt : null;
             });
             dd.Widget.SelectedOption = this.payloadType;
             return dd;
         default:
             return base.GetPropertyEditWidget(parent, column, records);
     }
 }
Beispiel #6
0
    public override void Initialize()
    {
        base.Initialize ();

            log.Debug("**** Going to get new client of main ****",this.ClientId);
            string newClientId = RootContext.GetNewClientId(this);
            log.Debug("**** Going to set new client of main ****",this.ClientId,newClientId);
            this.ClientId = newClientId;
            log.Debug("**** Set new client of main ****",this.ClientId);

            log.Debug("**** INIT TIME ****",this.ClientId);
            log.Warn("**** WARN INIT TIME ****",this.ClientId);

            log.Debug("**** apikey:",apikey);
            log.Debug("**** apisecret:",apisecret);

            foreach (var item in HttpContext.Current.Request.Params) {
                    log.Debug("request item",item,HttpContext.Current.Request[(string)item]);
                }

            InitializeServices();

            if ( Glyphs == null )
                Glyphs = DataProvider.LoadList<Glyph>();
            if ( Tones == null )
                Tones = DataProvider.LoadList<Tone>();

            if ( Glyphs.Count == 0 )
            {
                Glyph.InitDataBase();
                Glyphs = DataProvider.LoadList<Glyph>();
            }
            if ( Tones.Count == 0 )
            {
                Tone.InitDataBase();
                Tones = DataProvider.LoadList<Tone>();
            }

            log.Debug("Tones",Tones);
            log.Debug("Glyphs",Glyphs);

            Now = new DreamFolk();
            Now.FacebookId = "Now";
            Now.Birthday = DateTime.Now;
            log.Warn("Now is " + Now.GetName(),Now,DateTime.Now,Now.Birthday);

            Label l = this.Find<Label>();
                if ( l == null ) l = this.CreateWidget<Label>();
            l.Text = DateTime.Now.ToShortDateString();

            // check to see if force records needs to be recalc
            if ( HttpContext.Current.Request["recalc"] == "1" )
            {
                log.Warn("RECALCULATING BIRTHDAYS!");
                //DataHelper helper = new DataHelper();
                //new Thread (new ThreadStart (helper.Recalc)).Start();
                ThreadPool.QueueUserWorkItem(new WaitCallback(Recalc));
            }
            else
                log.Warn("skppping recalc",HttpContext.Current.Request["recalc"]);

        //			DreamSpellUtil.Calc();
        //			log.Debug("Year Seal: " + DreamSpellUtil.CalcYearSeal());
        //			log.Debug("Year Tone: " + DreamSpellUtil.CalcYearTone());
        //			log.Debug("Distance From Day Out Of Time: " + DreamSpellUtil.CalcDistanceFromDayOutOfTime());
        //			log.Debug("Year Seal: " + DreamSpellUtil.CalcSeal());
        //			log.Debug("Year Tone: " + DreamSpellUtil.CalcTone());
        //			DreamSpellUtil.CalcOracle();
        //			log.Debug("Guide: " + DreamSpellUtil.Guide);
        //			log.Debug("Antiopde: " + DreamSpellUtil.Antipode);
        //			log.Debug("Analog: " + DreamSpellUtil.Analog);
        //			log.Debug("Occult: " + DreamSpellUtil.Occult);
        //			log.Debug("Kin: " + DreamSpellUtil.Kin);

            log.Debug("This HttpContext.Request",HttpContext.Current.Request);

            bool isAdded = HttpContext.Current.Request["fb_sig_added"] == "1";

            string owner_fb_id = HttpContext.Current.Request["owner_fb_id"];

            string sessionKey = HttpContext.Current.Request["fb_sig_session_key"];

            string userId = HttpContext.Current.Request["fb_sig_user"];

            log.Debug("isAdded",isAdded);
            log.Debug("owner_fb_id",owner_fb_id);
            log.Debug("sessionKey",sessionKey);
            log.Debug("userId",userId);

            if ( userId != "775949236")
            {
                log.Debug("User is not me", userId);
                //return;
            }
            else
            {
                log.Debug("User is me!");
            }
            //return;
            log.Debug("Checking for nullOrEmpty sessionKey",sessionKey);

            if( string.IsNullOrEmpty(sessionKey) )
            {
                log.Debug("No sessionKey");
                //this.HttpContext.Response.Redirect(@"http://www.facebook.com/login.php?api_key=" + apikey + @"&v=1.0");
                //return;
                log.Warn("No facebook session 1");

                StarSummary starSummary = Find<StarSummary>("StarHeader");
                if ( starSummary != null )
                {
                    starSummary.Visible = false;
                }

                Pane me = Find<Pane>("Me");
                //me.AppendClass("none");
                log.Warn("No facebook session 2");

                Pane friends = Find<Pane>("Friends");
                //friends.AppendClass("none");

                TabPane tabPane = Find<TabPane>();
                if ( tabPane != null )
                {
                    foreach (Pane pane in tabPane.tabsByLabels.Values)
                    {
                        log.Debug("looking at pane: " + pane.Id);
                        if ( pane.Id == "Me" || pane.Id == "Friends" )
                        {
                            log.Debug("found either Me or Friends, going apply None: " + pane.Id);
                            pane.AppendClass("none");

                            //HtmlElement li = pane.FindAncestor
                            //li.AppendClass("none");

                        }
                    }

                    /*
                    foreach (Object obj in tabPane.tabsByLabels.Keys)
                    {
                        if ( ! (obj is HtmlElement) )
                        {
                            log.Debug("obj is not an  htmlElement",obj);
                            continue;
                        }

                        HtmlElement li = (HtmlElement)obj;
                        log.Debug("looking at key: " + li.Id + " " + li.TagName + " " + li.ClassName);

                        if ( li.ClassName == "MeTab" || li.ClassName == "FriendsTab" )
                        {
                            li.AppendClass("none");

                            //HtmlElement li = pane.FindAncestor
                            //li.AppendClass("none");

                        }
                        else
                            li.AppendClass("no-top-margin");
                    }
                    */
                }

            }
            else
            {
                log.Debug( sessionKey, userId );

                IsFaceBookSession = true;

                if( sessionKey != null && userId != null )
                    handleFacebookUser(sessionKey, userId);
            }

            if ( CurrentDreamFriend == null )
            {
                log.Debug("Setting CurrentDreamFriend to Now");
                CurrentDreamFriend = Now;
            }
            log.Debug("Going to bind CurrentDreamFriend",CurrentDreamFriend);

        //			ConfirmButton button = this.RootContext.CreateWidget<ConfirmButton>(this);
        //			button.Label = "Recalc";
        //			button.OnClick += delegate { ThreadPool.QueueUserWorkItem(new WaitCallback(Recalc)); };

            //this.RootContext.CreateWidget<FriendList>(this);

            //this.Record = Now;
            this.Record = CurrentDreamFriend;
            this.DataBindWidget(this.Record);

            log.Debug("Binded CurrentDreamFriend");

            Pane todayPane = this.Find<Pane>("Today");
            Pane mePane = this.Find<Pane>("Me");
            Pane friendsPane = this.Find<Pane>("Friends");
            FriendList friendList = this.Find<FriendList>();

            if ( todayPane != null )
            {
                log.Debug("Binding todayPane");
                todayPane.DataBindWidget(Now);
            }

            if ( mePane != null )
            {
                log.Debug("Binding mePane");
                mePane.DataBindWidget(CurrentDreamFriend);
            }

            if ( friendsPane != null && friendList != null )
            {
                log.Debug("Binding friendsPane");
                friendsPane.DataBindWidget(CurrentDreamFriend);
                log.Debug("Binding friendList");
                friendList.DataBindWidget(CurrentDreamFriend);
            }

            log.Debug("Creating starHeaderNow");
            StarSummary starHeaderNow = this.Find<StarSummary>("StarHeaderNow");
            if ( starHeaderNow != null )
            {
                log.Debug("Binding starHeaderNow");
                starHeaderNow.Record = Now;
                starHeaderNow.DataBindWidget();
            }
    }
Beispiel #7
0
		public InMemoryLexEntryFinder(IRecordList<LexEntry> recordList)
		{
			_recordList = recordList;
		}
Beispiel #8
0
 public InMemoryLexEntryFinder(IRecordList <LexEntry> recordList)
 {
     _recordList = recordList;
 }
Beispiel #9
0
        public override void PostInitialize()
        {
            //UnDataBindWidget();
            //this.Record = Main.Current.CurrentDreamFriend;
            //this.DataBindWidget();

            FacebookAPI api = Main.Current.FacebookApi;

            if (api == null)
            {
                return;
            }
            Collection <string> friends = api.GetFriendIds();
//			IRecordList<RStuff.Model.Member> members = DataProvider.LoadList<RStuff.Model.Member>(
//              new FilterInfo( "FacebookId", friends, FilterOperation.In ) );
//            Repeater<RStuff.Model.Member> friendList = Find<Repeater<RStuff.Model.Member>>("friendList");
//            friendList.DataSource = members;
//            friendList.DataBind();

            IRecordList <DreamFolk> dreamFolk = DataProvider.LoadList <DreamFolk>(new FilterInfo("FacebookId", Main.Current.FacebookId));
            DreamFolk dreamPerson             = null;

            if (dreamFolk.Count > 0)
            {
                dreamPerson = dreamFolk[0];
            }

            if (dreamPerson == null)
            {
                log.Warn("Creating new dreamPerson");
                dreamPerson = new DreamFolk(Main.Current.FbUser);
                dreamPerson.Save(true);
            }
            else if (dreamPerson.Birthday != Main.Current.FbUser.Birthday)
            {
                log.Warn("Updating dreamPerson's birthday");
                dreamPerson.Birthday = (DateTime)Main.Current.FbUser.Birthday;
                dreamPerson.Save(true);
            }

            DreamFolk dreamFriend = null;
            Label     label;
            Collection <Facebook.Entity.User> fb_users;
            Pane pane, detailPane;
            bool dreamPersonChanged = false;
            int  count = 0;
            int  added = 0;

            foreach (string friend in friends)
            {
                //if ( count++ > 2 ) break;

                dreamFriend = dreamPerson.GetFriend(friend);
                if (dreamFriend == null)
                {
                    log.Warn("dreamFriend not found, going to create new one, friend is", friend);
                    fb_users = Main.Current.FacebookApi.GetUserInfo(friend);
                    Facebook.Entity.User fb_user = fb_users[0];
                    log.Debug(fb_user);

                    dreamFriend = new DreamFolk(fb_user);
                    dreamFriend.Save(true);

                    log.Warn("Created new dreamFriend");

                    dreamPerson.Friends.Add(dreamFriend);
                    //dreamPerson.Save();
                    dreamPersonChanged = true;

                    added++;
                }
                else if (!dreamFriend.Updated)
                {
                    log.Warn("Updating dreamFriend");

                    fb_users = Main.Current.FacebookApi.GetUserInfo(dreamFriend.FacebookId);
                    Facebook.Entity.User fb_user = fb_users[0];
                    log.Debug(fb_user);

                    //dreamFriend.Birthday = dreamFriend.Birthday;
                    dreamFriend.update(fb_user);

                    dreamFriend.Updated = true;
                    dreamFriend.Save(true);

                    count++;
                }
                //else
                //	log.Warn("DreamFriend is current and up todate",dreamFriend.FirstName);


                /*
                 * pane = this.RootContext.CreateWidget<Pane>(this);
                 * pane.AppendClass("dream-person");
                 *
                 * pane.OnClick += delegate( object sender, ClickEventArgs ea )
                 * {
                 *      DreamFolk dreamFolkFriend = (DreamFolk)ea.Source.Record;
                 *      this.RootContext.RawCmd("parent.location='http://www.facebook.com/profile.php?id=" + dreamFolkFriend.FacebookId + "';");
                 * };
                 * pane.Record = dreamFriend;
                 * pane.DataBindWidget();
                 *
                 * label = this.RootContext.CreateWidget<Label>(pane);
                 * label.Text = dreamFriend.FirstName;
                 * label.AppendClass("label-name");
                 *
                 * if ( dreamFriend.PictureSmallUrl != null )
                 * {
                 *      label = this.RootContext.CreateWidget<Label>(pane);
                 *      label.Text = "<img src=\"" + dreamFriend.PictureSmallUrl + "\" class=person>";
                 * }
                 * else if ( dreamFriend.PictureUrl != null )
                 * {
                 *      label = this.RootContext.CreateWidget<Label>(pane);
                 *      label.Text = "<img src=\"" + dreamFriend.PictureUrl + "\" class=person>";
                 * }
                 * else if ( dreamFriend.PictureBigUrl != null )
                 * {
                 *      label = this.RootContext.CreateWidget<Label>(pane);
                 *      label.Text = "<img src=\"" + dreamFriend.PictureBigUrl + "\" class=person>";
                 * }
                 *
                 * DateTime bday = dreamFriend.Birthday;
                 * //label.Text = date.ToString("d");
                 * if ( bday.Year == 1900 || bday.Year == DateTime.Now.Year )
                 * {
                 *      detailPane = this.RootContext.CreateWidget<Pane>(pane);
                 *      detailPane.AppendClass("dream-detail");
                 *
                 *      label = this.RootContext.CreateWidget<Label>(detailPane);
                 *      label.Text = "<img src=\"/Images/tone0.gif\" title=\"Unknown\" class=tone>";
                 *      label.AppendClass("label-tone");
                 *
                 *      label = this.RootContext.CreateWidget<Label>(detailPane);
                 *      label.Text = "<img src=\"/Images/glyph0.gif\" title=\"Unknown\" class=seal>";
                 *      label.AppendClass("label-glyph");
                 *
                 *      label = this.RootContext.CreateWidget<Label>(detailPane);
                 *      label.Text = "<a target=\"_parent\" href=\"http://apps.facebook.com/dreamspell/index.aspx?invite=1\" style=\"background-color:#3B5998;border-color:#D9DFEA #0E1F5B #0E1F5B #D9DFEA;border-style:solid;border-width:1px;color:white;margin-right:5px;padding:3px 15px;line-height:24px\">Invite!</a>";
                 * }
                 * else
                 * {
                 *      //DreamSpellUtil.Calc(bday);
                 *
                 *      detailPane = this.RootContext.CreateWidget<Pane>(pane);
                 *      detailPane.AppendClass("dream-detail");
                 *
                 *      label = this.RootContext.CreateWidget<Label>(detailPane);
                 *      label.Text = "<img src=\"/Images/tone" + dreamFriend.Tone + ".gif\" title=\""+ dreamFriend.Tone.Name +"\" class=tone>";
                 *      label.AppendClass("label-tone");
                 *
                 *      label = this.RootContext.CreateWidget<Label>(detailPane);
                 *      label.Text = "<img src=\"/Images/glyph" + dreamFriend.Seal + ".gif\" title=\""+ (dreamFriend.Seal == null ? "Unknown" : dreamFriend.Seal.Name) +"\" class=seal>";
                 *      label.AppendClass("label-glyph");
                 *
                 *      label = this.RootContext.CreateWidget<Label>(detailPane);
                 *      //label.Text = bday.ToString("d");
                 *      label.Text = dreamFriend.GetName();
                 *      label.AppendClass("label-dreamspell-name");
                 *
                 *      //break;
                 *
                 * }
                 */
            }

            if (dreamPersonChanged)
            {
                log.Debug("dreamPersonChanged, saving");
                dreamPerson.Save(true);
            }
            log.Debug("Added " + added + " new dream friends");
            log.Debug("Updated " + count + " dream friends");

            Repeater <DreamFolk> friendList = this.Find <Repeater <DreamFolk> >("Friends");

            //if ( friendList != null && Main.Current.CurrentDreamFriend != null && Main.Current.CurrentDreamFriend.Friends.Count > 0)
            if (friendList != null && Main.Current.CurrentDreamFriend.Friends.Count > 1)
            {
                log.Warn("Going to unbind and rebind friendList, friend count " + dreamFolk.Count);
                log.Warn("Going to unbind and rebind friendList, CurrentDreamFriend.friend count " + Main.Current.CurrentDreamFriend.Friends.Count);
                friendList.UnDataBindWidget();
                //friendList.DataSource = Main.Current.CurrentDreamFriend.Friends;
                friendList.DataSource = Main.Current.CurrentDreamFriend.Friends;
                friendList.DataBind();


                //foreach (DreamFolk d in Main.Current.CurrentDreamFriend.Friends)
                //	log.Debug(d.FirstName);
            }
            else
            {
                log.Error("Skipped unbind and rebind of frinedList");
            }
        }
Beispiel #10
0
 private void recurseBind(Widget parent, IRecordList children)
 {
     children.OnRecordAdded += new EventHandler<RecordEventArgs>(recordAdded);
        	children.OnRecordRemoved += new EventHandler<RecordEventArgs>(recordRemoved);
        	foreach (AbstractRecord r in children)
      	{
      		AddChildNode( parent, r );
        	}
 }