示例#1
0
        /// <summary>
        /// Gets the list.
        /// </summary>
        /// <param name="dt">The dt.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns>List&lt;OwnerInfo&gt;.</returns>
        private static List <OwnerInfo> GetList(DataTable dt, out string errOut)
        {
            List <OwnerInfo> lst = new List <OwnerInfo>();

            errOut = @"";
            try
            {
                foreach (DataRow d in dt.Rows)
                {
                    lst.Add(new OwnerInfo()
                    {
                        Id           = Convert.ToInt32(d["id"]),
                        Password     = d["pwd"] != DBNull.Value ? One.Decrypt(d["pwd"].ToString().Trim()) : "",
                        Name         = d["Name"] != DBNull.Value ? d["Name"].ToString().Trim() : "",
                        Address      = d["Address"] != DBNull.Value ? One.Decrypt(d["Address"].ToString().Trim()) : "",
                        City         = d["City"] != DBNull.Value ? d["City"].ToString().Trim() : "",
                        State        = d["State"] != DBNull.Value ? d["State"].ToString().Trim() : "",
                        ZipCode      = d["Zip"] != DBNull.Value ? d["Zip"].ToString().Trim() : "",
                        Phone        = d["Phone"] != DBNull.Value ? d["Phone"].ToString().Trim() : "",
                        Ccdwl        = d["Ccdwl"] != DBNull.Value ? One.Decrypt(d["Ccdwl"].ToString().Trim()) : "",
                        UsePassword  = Convert.ToInt32(d["UsePWD"]) == 1,
                        UserName     = d["uid"] != DBNull.Value ? One.Decrypt(d["uid"].ToString().Trim()) : "",
                        ForgotWord   = d["forgot_word"] != DBNull.Value ? One.Decrypt(d["forgot_word"].ToString().Trim()) : "",
                        ForgotPhrase = d["forgot_phrase"] != DBNull.Value ? One.Decrypt(d["forgot_phrase"].ToString().Trim()) : "",
                        LastSync     = d["sync_lastupdate"].ToString().Trim(),
                    });
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("GetList", e);
            }
            return(lst);
        }
示例#2
0
        /// <summary>
        /// Gets the owner identifier.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="ownerName">Name of the owner.</param>
        /// <param name="ownerLic">The owner lic.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns>System.Int64.</returns>
        /// <exception cref="System.Exception"></exception>
        public static long GetOwnerId(string databasePath, out string ownerName, out string ownerLic, out string errOut)
        {
            long lAns = 0;

            errOut    = "";
            ownerName = "";
            ownerLic  = "";
            try
            {
                DataTable dt = Database.GetDataFromTable(databasePath, "SELECT TOP 1 * from Owner_Info", out errOut);
                if (errOut.Length > 0)
                {
                    throw new Exception(errOut);
                }
                List <OwnerInfo> lst = GetList(dt, out errOut);

                foreach (OwnerInfo l in lst)
                {
                    lAns      = l.Id;
                    ownerName = l.Name;
                    ownerLic  = One.Decrypt(l.Ccdwl);
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("GetOwnerId", e);
            }
            return(lAns);
        }
示例#3
0
        /// <summary>
        /// Logins the enabled.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <param name="uid">The uid.</param>
        /// <param name="pwd">The password.</param>
        /// <param name="forgotWord">The forgot word.</param>
        /// <param name="forgotPhrase">The forgot phrase.</param>
        /// <param name="errOut">The error out.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="System.Exception"></exception>
        public static bool LoginEnabled(string databasePath, out string uid, out string pwd, out string forgotWord, out string forgotPhrase,
                                        out string errOut)
        {
            bool bAns = false;

            uid          = "admin";
            pwd          = "";
            forgotWord   = "burnsoft";
            forgotPhrase = "The Company that made this App";
            try
            {
                List <OwnerInfo> oi = GetOwnerInfo(databasePath, out errOut);
                if (errOut.Length > 0)
                {
                    throw new Exception(errOut);
                }
                foreach (OwnerInfo o in oi)
                {
                    bAns = o.UsePassword;
                    if (bAns)
                    {
                        uid = One.Decrypt(o.UserName);
                        pwd = One.Decrypt(o.Password);
                        if (o.ForgotPhrase.Length > 0)
                        {
                            forgotPhrase = One.Decrypt(o.ForgotPhrase);
                        }

                        if (o.ForgotWord.Length > 0)
                        {
                            forgotWord = One.Decrypt(o.ForgotWord);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                errOut = ErrorMessage("LoginEnabled", e);
            }
            return(bAns);
        }