Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id = "";
            Resume theresume=new Resume();
            var Couchbase = new CouchbaseClient();

            if (Request.QueryString["id"] as string != null)
            {
                id = Request.QueryString["id"];
            }
            if(Page.RouteData.Values["id"] as string != null){
                id = Page.RouteData.Values["id"] as string;
            }

            if(id!= ""){

                theresume = Resume.ParseJSON(Couchbase.Get<String>(id));
                initalobject.InnerHtml = String.Format("<script>var resume = {0};</script>", theresume.toJSON());

                if(theresume.EditPassword == null ||theresume.EditPassword == EditPassword.Value){
                    //Check for password

                }else{
                ;//Prompt for password.
                }

            }

            if(Request.HttpMethod =="POST" && json.Value.Length>0 && (theresume.EditPassword == null || theresume.EditPassword == EditPassword.Value)){
                bool okay =false;
                string reason ="";
                Resume newResume = Resume.ParseJSON(json.Value);

                if(newResume.Id == null || newResume.Id ==""){
                 newResume.Id= Guid.NewGuid().ToString();
                 okay = Couchbase.Store(Enyim.Caching.Memcached.StoreMode.Add, newResume.Id, newResume.toJSON(false));

                 if(!okay){
                    reason = " Could not save resume, likley due to a server failure, ";
                 }
                }
                else{
                    if (theresume.EditPassword == newResume.EditPassword){
                        okay = Couchbase.Store(Enyim.Caching.Memcached.StoreMode.Replace, newResume.Id, newResume.toJSON(false));
                        if (!okay)
                        {
                            reason = " Could not save resume, likley due to a server failure, ";
                        }
                    }
                    else{
                        reason = "Incorrect Edit Password";
                    }

                }
                Response.Clear();
                Response.ContentType = @"application\json";
                if(okay){
                    Response.Write(String.Format("{{\"Response\":\"okay\",\"id\":\"{0}\"}}", newResume.Id));
                }
                else{
                    Response.Write(String.Format("{{\"Response\":\"error\",\"id\":\"{0}\",\"reason\":\"{1}\"}}", newResume.Id, reason));
                }
            }

            //TODO Populate forms fields
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Couchbase.CouchbaseClient cb = new Couchbase.CouchbaseClient();

            Classes.Resume temp = new Classes.Resume();

            temp.Name ="Smuggo Smuggins";
            temp.Statement =" Since Failheap has an eve dieded thread, EveO could do with a failheap dieded thread.So, is it down for anyone else? Where is it? When's it back? What am I going to do with myself all afternoon?/nervous breakdown";
            temp.PhotoUrl = "http://image.eveonline.com/Character/1343751208_256.jpg";

            for(int i = rando.Next(1,3); i > 0; i--){
                Classes.Achievement a = new Classes.Achievement();
                a.Info = getranod() + " " + getranod();
                temp.Achievements.Add(a);
            }

            for (int i = rando.Next(1, 3); i > 0; i--)
            {
                string a =getranod();
                temp.Address.Add(new Address(a));
            }
            for (int i = rando.Next(1, 5); i > 0; i--)
            {
                Classes.Certification c = new Classes.Certification();
                c.Institution = getranod();
                c.Name = getranod();
                c.Url = "http://"+getranod();
                c.Year = rando.Next(1990,DateTime.Now.Year);
                temp.Certifications.Add(c);
            }

            for (int i = rando.Next(1, 5); i > 0; i--)
            {

                Classes.Education c = new Classes.Education();
                c.Institution = getranod();
                c.Degree = getranod();
                c.Url = "http://" + getranod();
                c.Year = rando.Next(1940, DateTime.Now.Year);
                temp.Education.Add(c);
            }
            for (int i = rando.Next(1, 3); i > 0; i--)
            {
                string a =getranod()+"@"+getranod()+"."+getranod();
                temp.Emails.Add(new Email(a));
            }
            for (int i = rando.Next(1, 3); i > 0; i--)
            {
                PhoneNumber p = new PhoneNumber();
                p.Number = rando.Next(0,9999999).ToString();
                p.Type = getranod();

                temp.Phones.Add(p);
            }
            for (int i = rando.Next(1, 5); i > 0; i--)
            {

                Classes.Praise c = new Classes.Praise();
                c.Statement = getranod()+ " "+ getranod()+ " "+ getranod();
                c.Name = getranod();
                c.Url = "http://" + getranod();

                temp.Praise.Add(c);
            }
            for (int i = rando.Next(1, 5); i > 0; i--)
            {

                Classes.Skill c = new Classes.Skill();

                c.Name = getranod();
                c.Url = "http://" + getranod();

                temp.Skills.Add(c);
            }
            for (int i = rando.Next(1, 5); i > 0; i--)
            {

                Classes.SocialMedia c = new Classes.SocialMedia();
                c.Service = getranod();
                c.Username = getranod();
                c.Url = "http://" + getranod();
                temp.SocialMedia.Add(c);
            }
            for (int i = rando.Next(1, 5); i > 0; i--)
            {

                Classes.Experience c = new Classes.Experience();
                c.Title = getranod() + " of "+ getranod();
                c.Start = new DateTime( rando.Next(1980,2012),rando.Next(1,12), rando.Next(1,28));
                c.End = new DateTime( rando.Next(1980,2012),rando.Next(1,12), rando.Next(1,28));
                    string detail = "";
                    for (int k = rando.Next(5, 20); k > 0; k--)
                    {
                        detail += getranod() + " ";
                    }

                c.Company = getranod();
                c.Url = "http://" + getranod();
                temp.WorkExperience.Add(c);
            }

            bool okay = cb.Store(Enyim.Caching.Memcached.StoreMode.Set, temp.Id, temp.toJSON());

            var test  = cb.Get(temp.Id);

            form1.InnerHtml = test.ToString();
        }