Exemple #1
0
    public string AddUserFavoritePage(string userId, string pageName, string ctrl)
    {
        string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey"));

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

        db_config_users dcu = null;

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

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

            Users u = dcu.Get(auxUserId);

            if (u == null) return string.Empty; // if user does not exists will leave width no return message

            OptionItems oi = new OptionItems(u.UserOptions);

            List<string> favoriteList = oi.GetList("favorites");

            if (favoriteList.IndexOf(pageName) < 0)
            {
                favoriteList.Add(pageName);
                oi.UpdateOptions("favorites", favoriteList);
                u.UserOptions = oi.GetOptionsString();
                dcu.Commit();

                return "page added to favorites";
            }
            else
                return "page already added to favorite.";

        }
        catch (Exception ex)
        {
            loging.Error("FrontOffice User Webservice", "Add User Favorite Page", ex.Message, _logRecord);
        }
        finally
        {
            if (dcu != null) dcu.Close();
        }

        return "failed to add page";
    }
Exemple #2
0
    public string ChangeUserPassword(string userId, string newPass, string ctrl)
    {
        JavaScriptSerializer js = new JavaScriptSerializer();

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

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

        db_config_users dcu = null;

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

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

            Users u = dcu.Get(auxUserId);

            if (u == null) return string.Empty; // if user does not exists it will leave with no return messsage

            u.Pass = newPass;
            dcu.Commit();

            return "password changed";
        }
        catch (Exception ex)
        {
            loging.Error("FrontOffice User Webservice", "User Change Password", ex.Message, _logRecord);
        }
        finally
        {
            if (dcu != null) dcu.Close();
        }

        return "password not changed";
    }
Exemple #3
0
    public string SetUserDefaultFrontOfficePage(string userId, string pageName, string ctrl)
    {
        string crlHash = Generic.GetHash(Generic.GetWebConfigValue("WebServiceKey"));

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

        db_config_users dcu = null;

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

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

            Users u = dcu.Get(auxUserId);

            if (u == null) return string.Empty; // if user does not exists it will leave with no return messsage

            OptionItems oi = new OptionItems(u.UserOptions);
            oi.UpdateOptions("default_frontoffice_page", new List<string> { pageName });

            u.UserOptions = oi.GetOptionsString();

            dcu.Commit();

            return pageName != ""
                                ? "Page " + pageName + " is set as default frontoffice page"
                                : "Default frontoffice page is clean";
        }
        catch (Exception ex)
        {
            loging.Error("FrontOffice User Webservice", "Add User Favorite Page", ex.Message, _logRecord);
        }
        finally
        {
            if (dcu != null) dcu.Close();
        }

        return "failed to set page";
    }
Exemple #4
0
    /************************ Configurations ************************/
    /// <summary>
    /// updating existing user data
    /// </summary>
    private static void SaveUser(string uId, string name, string pass, int admin, string desc, string uOptions, string aOptions)
    {
        try
        {
            int id = Convert.ToInt32(uId);

            db_config_users dcu = new db_config_users(id);
            dcu.Open(); // open connection

            Users user = dcu.Get(id);

            if (user.ID != id) return; // if id is diferent probabaly because user pressed save with no user selected

            user.Name = name;
            user.Pass = pass;
            user.AdMIn = admin;
            user.Description = desc;
            user.UserOptions = uOptions;
            user.AdMInOptions = aOptions;

            dcu.Commit();

            dcu.Close(); // close connection

            Generic.JavaScriptInjector("alert('User Saved'); window.location.reload();");
        }
        catch (Exception ex)
        {
            Generic.JavaScriptInjector("alert('" + ex.Message + "');");
        }
    }