Example #1
0
    public string ListUserPages(string userId, string ctrl)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();

        string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey"));

        if (ctrl != crlHash) return js.Serialize("");

        // first validation to garanty that user is graiter then zero
        int auxUserId = Convert.ToInt32(userId);
        if (auxUserId < 0) return js.Serialize("");

        db_config_users dcu = null;

        try
        {
            dcu = new db_config_users(auxUserId);
            dcu.Open();

            List<JsonUserPages> pages = (from p in dcu.GetPages()
                                         select new JsonUserPages { Id = p.ID, Title = p.Title }).ToList();

            return js.Serialize(pages);
        }
        catch (Exception ex)
        {
            loging.Error("BackOffice User Webservice", "User Pages", ex.Message, _logRecord);
        }
        finally
        {
            if (dcu != null) dcu.Close();
        }

        return js.Serialize("");
    }
Example #2
0
    public string ListAllUserPages(string userId, string ctrl)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();

        string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey"));

        //if (ctrl != crlHash) return js.Serialize("");

        db_config_page dcp = null;

        try
        {
            // first validation to guarantee that user is greater than zero
            int auxUserId = Convert.ToInt32(userId);
            if (auxUserId < 0) return js.Serialize("");

            dcp = new db_config_page();
            dcp.Open();

            db_config_users dcu = new db_config_users(dcp.Db, auxUserId);
            dcu.Open();

            // list user pages
            List<int> userPagesId = (from up in dcu.GetPages() select up.ID).ToList();

            if (userPagesId.Count > 0)
                dcp.SelectAuthenticatedObjectsFromDb(userPagesId); // list public pages and pages that user can have
            else
                dcp.SelectPublicObjectsFromDb();

            // --------------------------------
            // list pages that user dont have
            List<JsonUserPages> userPages = (from ap in dcp.AllPages
                                            select new JsonUserPages {Id = ap.ID, Title = ap.Title, Name = ap.Name}).ToList();

            return js.Serialize(userPages);
        }
        catch (Exception ex)
        {
            loging.Error("FrontOffice User Webservice", "List All User Pages ", ex.Message, _logRecord);
        }
        finally
        {
            if (dcp != null) dcp.Close();
        }

        return js.Serialize("");
    }
Example #3
0
    public string ListAvailablePagesToUser(string userId, string ctrl)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();

        string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey"));

        if (ctrl != crlHash) return js.Serialize("");

        db_config_page dcp = null;

        try
        {
            // first validation to guarantee that user is greater than zero
            int auxUserId = Convert.ToInt32(userId);
            if (auxUserId < 0) return js.Serialize("");

            dcp = new db_config_page();
            dcp.Open();

            db_config_users dcu = new db_config_users(dcp.Db, auxUserId);
            dcu.Open();

            // list user pages
            List<int> userPagesId = (from up in dcu.GetPages() select up.ID).ToList();

            // --------------------------------
            // list pages that user dont have
            List<JsonUserPages> noAvailableUserPages = userPagesId.Count == 0 ? (from ap in dcp.AllPages
                                                                                 select new JsonUserPages { Id = ap.ID, Title = ap.Title, Name = ap.Name }).ToList()
                                                                            : (from nup in dcp.AllPages
                                                                                where !userPagesId.Contains(nup.ID)
                                                                                select new JsonUserPages { Id = nup.ID, Title = nup.Title, Name = nup.Name }).ToList();

            return js.Serialize(noAvailableUserPages);
        }
        catch (Exception ex)
        {
            loging.Error("BackOffice User Webservice", "List All Pages ", ex.Message, _logRecord);
        }
        finally
        {
            if (dcp != null) dcp.Close();
        }

        return js.Serialize("");
    }