Beispiel #1
0
        public XElement DeleteActivity(int activityid)
        {
            XElement x = new XElement("activities");

            DBHelper db = new DBHelper(dbcstring);

            db.DeleteActivity(activityid);

            return x;
        }
Beispiel #2
0
        public XElement DeleteProject(int projectid)
        {
            XElement x = new XElement("projects");

            DBHelper db = new DBHelper(dbcstring);

            db.DeleteProject(projectid);

            return x;
        }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["user"] != null)
     {
         DBHelper db = new DBHelper(AgentUtileries.dbcstring);
         CurrentUser = (AUser)Session["user"];
         CurrentUser = db.GetUser(CurrentUser.ID);
         Session["user"] = CurrentUser;
         Projects = db.GetProjects(CurrentUser.ID);
         Page.Title = CurrentUser.Name;
     }
 }
Beispiel #4
0
        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.QueryString["id"];
            AImage image = new DBHelper(AgentUtileries.dbcstring).GetImage(int.Parse(id));

            char[] sep = { '.' };
            string[] splittedName = image.FileName.Split(sep);
            string type = splittedName[splittedName.Length - 1];
            context.Response.ContentType = "image/" + type;

            context.Response.OutputStream.Write(image.FileData, 0, image.FileData.Length);
        }
Beispiel #5
0
 protected void BLogin_Click(object sender, EventArgs e)
 {
     string email = TBEmail.Text,
         password = TBPassword.Text;
     DBHelper db = new DBHelper(AgentUtileries.dbcstring);
     int id = db.Authenticate(email, password);
     if (id > 0)
     {
         AUser user = db.GetUser(id);
         Session["user"] = user;
         Response.Redirect("~/Default.aspx");
     }
     else
     {
         Response.Redirect("~/User/Login.aspx");
     }
 }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                CurrentUser = (AUser)Session["user"];
                DBHelper db = new DBHelper(AgentUtileries.dbcstring);

                DateTime today = DateTime.Today,
                    end;
                string sdate = Request.QueryString["for"];
                switch (sdate)
                {
                    case "today":
                        end = today.AddDays(1);
                        TimeText = "hoy";
                        break;
                    case "week":
                        end = today.AddDays(7);
                        TimeText = "esta semana";
                        break;
                    case "month":
                        end = today.AddMonths(1);
                        TimeText = "este mes";
                        break;
                    case "year":
                        end = today.AddYears(1);
                        TimeText = "este año";
                        break;
                    default:
                        end = today.AddDays(7);
                        TimeText = "esta semana";
                        break;
                }

                List<AActivity> all = db.GetAllActivities(CurrentUser.ID);
                Projects = db.GetProjects(CurrentUser.ID);
                ActivityList = new List<AActivity>();
                foreach (AActivity activity in all)
                {
                    if (activity.Date.Value.Ticks > today.Ticks && activity.Date.Value.Ticks < end.Ticks)
                        ActivityList.Add(activity);
                }
                Title = "Actividades para " + TimeText;
            }
        }
Beispiel #7
0
        public XElement GetProject(int projectid)
        {
            XElement x = new XElement("projects");

            DBHelper db      = new Model.DBHelper(dbcstring);
            AProject project = db.GetProject(projectid);

            if (project != null)
            {
                XElement xproject = new XElement("project");
                xproject.Add(new XElement("id", project.ID.ToString()));
                xproject.Add(new XElement("title", project.Title.Trim()));
                int actCount = db.GetActivities(project.ID).Count;
                xproject.Add(new XElement("activitycount", actCount.ToString()));
                x.Add(xproject);
            }
            return(x);
        }
Beispiel #8
0
        public XElement GetProjects(int user)
        {
            XElement x = new XElement("projects");

            DBHelper        db       = new Model.DBHelper(dbcstring);
            List <AProject> projects = db.GetProjects(user);

            foreach (AProject project in projects)
            {
                XElement xproject = new XElement("project");
                xproject.Add(new XElement("id", project.ID.ToString()));
                xproject.Add(new XElement("title", project.Title.Trim()));
                int actCount = db.GetActivities(project.ID).Count;
                xproject.Add(new XElement("activitycount", actCount.ToString()));
                x.Add(xproject);
            }
            return(x);
        }
Beispiel #9
0
        public XElement Authenticate(string email, string password)
        {
            XElement x = new XElement("users");

            DBHelper db = new DBHelper(AgentUtileries.dbcstring);
            int result = db.Authenticate(email, password);
            if (result > 0)
            {
                AUser user = db.GetUser(result);
                XElement xuser = new XElement("user");
                xuser.Add(new XElement("ID", user.ID));
                xuser.Add(new XElement("Email", user.Email));
                xuser.Add(new XElement("Name", user.Name));
                x.Add(xuser);
            }

            return x;
        }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
            {
                CurrentUser = (AUser)Session["user"];
                DBHelper db = new DBHelper(AgentUtileries.dbcstring);

                Projects = db.GetProjects(CurrentUser.ID);

                string sid = Request.QueryString["view"];
                int id;
                int.TryParse(sid, out id);

                CurrentProject = db.GetProject(id);
                ActivityList = db.GetActivities(id);
                foreach(AActivity a in ActivityList) {
                    if (a.Completed) Completed++;
                }
                Title = CurrentProject.Title;
            }
        }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Comprobar que hay una sesión de usuario activa.
            if (Session["user"] != null)
            {
                CurrentUser = (AUser)Session["user"];
                DBHelper db = new DBHelper(AgentUtileries.dbcstring);
                Projects = db.GetProjects(CurrentUser.ID);

                Reminders = new List<AActivity>();
                List<AActivity> all = db.GetAllActivities(CurrentUser.ID);

                DateTime today = DateTime.Today,
                    tomorrow = today.AddDays(1);
                foreach (AActivity activity in all)
                {
                    if (activity.Reminder.Value.Ticks > today.Ticks && activity.Reminder.Value.Ticks < tomorrow.Ticks)
                        Reminders.Add(activity);
                }
            }
        }
Beispiel #12
0
        public XElement GetChildActivities(int activity)
        {
            XElement x = new XElement("activities");

            DBHelper         db         = new Model.DBHelper(dbcstring);
            List <AActivity> activities = db.GetChildActivities(activity);

            foreach (AActivity aactivity in activities)
            {
                XElement xproject = new XElement("activity");
                xproject.Add(new XElement("id", aactivity.ID.ToString()));
                xproject.Add(new XElement("title", aactivity.Title.Trim()));
                xproject.Add(new XElement("date", aactivity.Date));
                xproject.Add(new XElement("created", aactivity.Created));
                xproject.Add(new XElement("reminder", aactivity.Reminder));
                xproject.Add(new XElement("priority", aactivity.Priority));
                xproject.Add(new XElement("completed", aactivity.Completed));
                xproject.Add(new XElement("parent", aactivity.Parent));
                x.Add(xproject);
            }
            return(x);
        }
Beispiel #13
0
        public XElement RegisterActivity(int project, string title, int parentActivity, int priority,
            string due, string reminder, int completed)
        {
            XElement x = new XElement("activities");

            DBHelper db = new DBHelper(dbcstring);

            DateTime ddue = DateTime.Parse(due),
                dreminder = DateTime.Parse(reminder);
            bool bcompleted = (completed > 0);

            int registeredid = db.RegisterActivity(project, title, ddue, parentActivity,
                Convert.ToByte(priority), dreminder, bcompleted);
            AActivity activity = db.GetActivity(registeredid);

            if (activity != null)
            {
                XElement xproject = new XElement("activity");
                xproject.Add(new XElement("id", activity.ID.ToString()));
                xproject.Add(new XElement("title", activity.Title.Trim()));
                xproject.Add(new XElement("date", activity.Date));
                xproject.Add(new XElement("created", activity.Created));
                xproject.Add(new XElement("reminder", activity.Reminder));
                xproject.Add(new XElement("priority", activity.Priority));
                xproject.Add(new XElement("completed", activity.Completed));
                x.Add(xproject);
            }

            return x;
        }
Beispiel #14
0
        public XElement GetActivities(int project)
        {
            XElement x = new XElement("activities");

            DBHelper db = new Model.DBHelper(dbcstring);
            List<AActivity> activities = db.GetActivities(project);
            foreach (AActivity activity in activities)
            {
                XElement xproject = new XElement("activity");
                xproject.Add(new XElement("id", activity.ID.ToString()));
                xproject.Add(new XElement("title", activity.Title.Trim()));
                xproject.Add(new XElement("date", activity.Date));
                xproject.Add(new XElement("created", activity.Created));
                xproject.Add(new XElement("reminder", activity.Reminder));
                xproject.Add(new XElement("priority", activity.Priority));
                xproject.Add(new XElement("completed", activity.Completed));
                xproject.Add(new XElement("parent", activity.Parent));
                x.Add(xproject);
            }
            return x;
        }
Beispiel #15
0
        public XElement GetProject(int projectid)
        {
            XElement x = new XElement("projects");

            DBHelper db = new Model.DBHelper(dbcstring);
            AProject project = db.GetProject(projectid);
            if (project != null)
            {
                XElement xproject = new XElement("project");
                xproject.Add(new XElement("id", project.ID.ToString()));
                xproject.Add(new XElement("title", project.Title.Trim()));
                int actCount = db.GetActivities(project.ID).Count;
                xproject.Add(new XElement("activitycount", actCount.ToString()));
                x.Add(xproject);
            }
            return x;
        }
Beispiel #16
0
        public XElement UpdateUser(int userid, string name)
        {
            XElement x = new XElement("users");

            DBHelper db = new DBHelper(AgentUtileries.dbcstring);
            db.UpdateName(userid, name);

            AUser user = db.GetUser(userid);
            if (user != null)
            {
                XElement xuser = new XElement("user");
                xuser.Add(new XElement("ID", user.ID));
                xuser.Add(new XElement("Email", user.Email));
                xuser.Add(new XElement("Name", user.Name));
                x.Add(xuser);
            }

            return x;
        }
Beispiel #17
0
        public XElement UpdateReminder(int activity, string reminder)
        {
            XElement x = new XElement("activities");

            DBHelper db = new DBHelper(dbcstring);

            db.UpdateReminder(activity, DateTime.Parse(reminder));

            AActivity aactivity = db.GetActivity(activity);

            if (aactivity != null)
            {
                XElement xproject = new XElement("activity");
                xproject.Add(new XElement("id", aactivity.ID.ToString()));
                xproject.Add(new XElement("title", aactivity.Title.Trim()));
                xproject.Add(new XElement("date", aactivity.Date));
                xproject.Add(new XElement("created", aactivity.Created));
                xproject.Add(new XElement("reminder", aactivity.Reminder));
                xproject.Add(new XElement("priority", aactivity.Priority));
                xproject.Add(new XElement("completed", aactivity.Completed));
                x.Add(xproject);
            }

            return x;
        }
Beispiel #18
0
        public XElement UpdateProjectTitle(int projectid, string title)
        {
            XElement x = new XElement("projects");

            DBHelper db = new DBHelper(dbcstring);
            db.UpdateProjectTitle(projectid, title);

            AProject project = db.GetProject(projectid);
            if (project != null)
            {
                XElement xproject = new XElement("project");
                xproject.Add(new XElement("id", project.ID.ToString()));
                xproject.Add(new XElement("title", project.Title.Trim()));
                x.Add(xproject);
            }

            return x;
        }
Beispiel #19
0
        public XElement RegisterUser(string email, string password, string name)
        {
            XElement x = new XElement("users");

            DBHelper db = new DBHelper(AgentUtileries.dbcstring);
            db.RegisterUser(email, password, name);

            return x;
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] != null)
                CurrentUser = (AUser)Session["user"];
            if (!Page.IsPostBack)
            {
                string sid = Request.QueryString["view"];
                int id;
                int.TryParse(sid, out id);

                db = new DBHelper(AgentUtileries.dbcstring);
                Session["db"] = db;
                CurrentActivity = db.GetActivity(id);

                // Si hay una actividad actual, obtener sus otros datos.
                if (CurrentActivity != null)
                {
                    OwnerProject = db.GetProject(CurrentActivity.ProjectID);
                    ParentActivity = db.GetActivity(CurrentActivity.Parent);
                    ChildActivities = db.GetChildActivities(CurrentActivity.ID);
                    ActivityImages = db.GetImages(CurrentActivity.ID);
                    Session["activity"] = CurrentActivity;
                }
            }
            else
            {
                CurrentActivity = (AActivity)Session["activity"];
                db = (DBHelper)Session["db"];
                if (CurrentActivity != null)
                {
                    OwnerProject = db.GetProject(CurrentActivity.ProjectID);
                    ParentActivity = db.GetActivity(CurrentActivity.Parent);
                    ChildActivities = db.GetChildActivities(CurrentActivity.ID);
                    Title = CurrentActivity.Title;
                }
            }
        }
Beispiel #21
0
        public XElement RegisterProject(int user, string title)
        {
            XElement x = new XElement("projects");

            DBHelper db = new DBHelper(dbcstring);

            int registeredId = db.RegisterProject(user, title);
            AProject project = db.GetProject(registeredId);

            if (project != null)
            {
                XElement xproject = new XElement("project");
                xproject.Add(new XElement("id", project.ID.ToString()));
                xproject.Add(new XElement("title", project.Title.Trim()));
                x.Add(xproject);
            }

            return x;
        }
Beispiel #22
0
        public XElement GetProjects(int user)
        {
            XElement x = new XElement("projects");

            DBHelper db = new Model.DBHelper(dbcstring);
            List<AProject> projects = db.GetProjects(user);
            foreach (AProject project in projects)
            {
                XElement xproject = new XElement("project");
                xproject.Add(new XElement("id", project.ID.ToString()));
                xproject.Add(new XElement("title", project.Title.Trim()));
                int actCount = db.GetActivities(project.ID).Count;
                xproject.Add(new XElement("activitycount", actCount.ToString()));
                x.Add(xproject);
            }
            return x;
        }