コード例 #1
0
        public BindingIP GetBinding(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }
            DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "ID=" + id));
            BindingIP b  = new BindingIP();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    try {
                        b = new BindingIP()
                        {
                            ID          = dr["ID"].ToSafeInteger(),
                            IPAddress   = SimpleEncryption.Decrypt(dr["IPAddress"].ToSafeString()),
                            Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()),
                            Path        = SimpleEncryption.Decrypt(dr["Path"].ToSafeString()),
                            AutoBind    = dr["AutoBind"].ToSafeInteger(),
                            Code        = dr["Code"].ToSafeString()
                        };
                    } catch { /*@Ignore exception*/ }
                }
            }
            return(b);
        }
コード例 #2
0
        public List <BindingIP> GetBindings(bool autoBinded = false)
        {
            DataTable dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_DESC, defaultTable, "ID"));

            if (autoBinded)
            {
                dt = sqlite.Select(string.Format(Queries.SELECT_TABLE_WHERE, defaultTable, "AutoBind = 1"));
            }
            List <BindingIP> pwds = new List <BindingIP>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    BindingIP cmd = new BindingIP()
                    {
                        ID          = dr["ID"].ToSafeInteger(),
                        IPAddress   = SimpleEncryption.Decrypt(dr["IPAddress"].ToSafeString()),
                        Description = SimpleEncryption.Decrypt(dr["Description"].ToSafeString()),
                        Path        = SimpleEncryption.Decrypt(dr["Path"].ToSafeString()),
                        AutoBind    = dr["AutoBind"].ToSafeInteger(),
                        Code        = dr["Code"].ToSafeString()
                    };
                    pwds.Add(cmd);
                }
            }
            return(pwds);
        }
コード例 #3
0
        public string GetIPAddress(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }
            BindingIP bind = GetBinding(id);

            if (bind != null)
            {
                if (!string.IsNullOrEmpty(bind.IPAddress))
                {
                    return(bind.IPAddress);
                }
            }
            return(string.Empty);
        }
コード例 #4
0
        public void Add(BindingIP c)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();
            string code = (c.Path + c.Description).RemoveNonAlphaNumeric().ToLower();

            data.Add("Description", SimpleEncryption.Encrypt(c.Description));
            data.Add("IPAddress", SimpleEncryption.Encrypt(c.IPAddress));
            data.Add("Path", SimpleEncryption.Encrypt(c.Path));
            data.Add("AutoBind", c.AutoBind);
            data.Add("Code", code);
            if (sqlite.IsExist(defaultTable, "Code", code.ToStringType()))
            {
                sqlite.Update(defaultTable, data, "Code", code);
            }
            else
            {
                sqlite.Insert(defaultTable, data);
            }
        }