Ejemplo n.º 1
0
 public void TestConversion()
 {
     TestContext.WriteLine("StrHelper.TrueStrings = {0}", StrHelper.TrueStrings);
     Assert.AreEqual(StrHelper.ToBoolean("y"), true);
     Assert.AreEqual(StrHelper.ToBoolean("Yes"), true);
     Assert.AreEqual(StrHelper.ToBoolean("true"), true);
     Assert.AreEqual(StrHelper.ToBoolean("1"), true);
     Assert.AreEqual(StrHelper.ToBoolean("enabled"), true);
     Assert.AreEqual(StrHelper.ToBoolean("N"), false);
     Assert.AreEqual(StrHelper.ToBoolean("qoo"), false);
 }
Ejemplo n.º 2
0
 public DataTable SelByIDS(string ids)
 {
     ids = StrHelper.PureIDSForDB(ids);
     if (!string.IsNullOrEmpty(ids))
     {
         SafeSC.CheckIDSEx(ids);
         ids = ids.TrimEnd(new char[] { ',' });
         string sql = "Select * From " + strTableName + " Where SpecID IN (" + ids + ")";
         return(SqlHelper.ExecuteTable(CommandType.Text, sql));
     }
     return(new DataTable());
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取广告绑定了哪些版位
        /// </summary>
        public string Zone_GetIDS(int adid)
        {
            DataTable dt = DBCenter.Sel(BindTbName, "ADID=" + adid);

            if (dt.Rows.Count < 1)
            {
                return("");
            }
            string zoneIds = StrHelper.GetIDSFromDT(dt, "ZoneID");

            return(zoneIds);
        }
Ejemplo n.º 4
0
        public void AuthApply_Submit()
        {
            M_APP_Auth authMod = new M_APP_Auth();

            authMod.SiteUrl = StrHelper.UrlDeal(Request.Form["siteurl"]);
            authMod.Contact = Request.Form["contact"];
            authMod.MPhone  = Request.Form["mphone"];
            authMod.Email   = Request.Form["email"];
            authMod.QQCode  = Request.Form["qqcode"];
            authBll.Insert(authMod);
            function.WriteSuccessMsg("授权申请提交成功,请等待管理员审核", "AuthApply");
        }
Ejemplo n.º 5
0
        public void FullShapeSpaceToSpaceTest()
        {
            string input = "a b";

            string expected = "a b";
            string actual;

            actual = StrHelper.FullShapeSpaceToSpace(input);

            Assert.AreEqual(expected, actual, "global::Huanlin.Text.StrHelper.FullShapeSpaceToSpace did not return the expected value" +
                            ".");
        }
Ejemplo n.º 6
0
        protected bool GetArr <TItem>(string key, string sprartor, out TItem[] value, Func <string, TItem> parse)
        {
            string strValue;

            if (!GetString(key, out strValue))
            {
                value = default(TItem[]);
                return(false);
            }

            return(StrHelper.GetArr(strValue, sprartor, out value, parse));
        }
Ejemplo n.º 7
0
        public void RemoveSpacesTest()
        {
            string input           = "a b c";
            bool   fullShapeSpaces = true;

            string expected = "abc";
            string actual;

            actual = StrHelper.RemoveSpaces(input, fullShapeSpaces);

            Assert.AreEqual(expected, actual, "global::Huanlin.Text.StrHelper.RemoveSpaces did not return the expected value.");
        }
Ejemplo n.º 8
0
 private static int GetIsEnableImgDeal()
 {
     try
     {
         return(StrHelper.ToInt32(ConfigurationManager.AppSettings["IsEnableImgDeal"].ToString()));
     }
     catch (Exception e)
     {
         Log.Error(e.Message + e.StackTrace);
         return(0);
     }
 }
Ejemplo n.º 9
0
 private static int GetProxyPoolSize()
 {
     try
     {
         return(StrHelper.ToInt32(ConfigurationManager.AppSettings["ProxyPoolSize"].ToString()));
     }
     catch (Exception e)
     {
         Log.Error(e.Message + e.StackTrace);
         return(10);
     }
 }
Ejemplo n.º 10
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // 只需設定一次,且必須最早進行的初始化動作:建立點字轉換器物件,並指定點字對應表物件。
            string filePath = StrHelper.AppendSlash(Application.StartupPath);

            ChineseWordConverter chtCvt = new ChineseWordConverter(filePath + "ChineseBrailleTable.xml");
            EnglishWordConverter engCvt = new EnglishWordConverter(filePath + "EnglishBrailleTable.xml");

            m_Processer = new BrailleProcessor();
            m_Processer.AddWordConverter(chtCvt);
            m_Processer.AddWordConverter(engCvt);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 16进制字符串转换为Byte
        /// </summary>
        /// <param name="hexString">16进制源字符串</param>
        /// <returns>Byte类型数组</returns>
        public static byte HexToByte(this string hexString)
        {
            string strTemp = hexString;
            int    len     = hexString.Length;

            if (len % 2 != 0)
            {
                strTemp = "0" + hexString;
            }

            return(StrHelper.HexStringToByte(strTemp)[0]);
        }
Ejemplo n.º 12
0
        protected bool GetU16(string key, out UInt16 value)
        {
            string strValue;

            if (!GetString(key, out strValue))
            {
                value = 0;
                return(false);
            }

            return(StrHelper.GetU16(strValue, out value, m_logger));
        }
Ejemplo n.º 13
0
        public override string[] GetInsertFieldNamesOf(Type type)
        {
            string[] fieldNames;

            fieldNames = GetPersistentFieldNamesOf(type);

            if (GetIdMethodFor(type) != IdMethod.UserSubmitted)
            {
                fieldNames = StrHelper.Remove("Id", fieldNames);
            }

            return(fieldNames);
        }
Ejemplo n.º 14
0
        //批量删除用户
        protected void BtnDelAll_Click(object sender, EventArgs e)
        {
            string ids = Request.Form["idchk"];

            string[] uid = ids.Split(',');
            for (int i = 0; i < uid.Length; i++)
            {
                M_UserInfo info = buser.SeachByID(DataConverter.CLng(uid[i]));
                info.UserRole = StrHelper.RemoveToIDS(info.UserRole, Mid.ToString());
                buser.UpDateUser(info);
            }
            MyBind();
        }
        private string GetFilePathToInclude(string commandParamAndVars)
        {
            var fileInFilePathList = StrHelper.GetWhiteSpaceSplittedStrArr(commandParamAndVars);

            if (fileInFilePathList.Count >= 1)
            {
                var fileInFilePathFirst = fileInFilePathList[0];

                return(Path.Combine(OperationPath, fileInFilePathFirst));
            }

            return(null);
        }
Ejemplo n.º 16
0
        public override string[] GetUpdateFieldNamesOf(Type type)
        {
            string[] fieldNames;
            string   optimisticLockField = null;

            fieldNames = GetPersistentFieldNamesOf(type);
            fieldNames = StrHelper.Remove("Id", fieldNames);

            optimisticLockField = GetOptimisticLockField(type);
            fieldNames          = StrHelper.Remove(optimisticLockField, fieldNames);

            return(fieldNames);
        }
Ejemplo n.º 17
0
    protected void Save_Btn_Click(object sender, EventArgs e)
    {
        int    Mid     = DataConvert.CLng(Mid_Hid.Value);
        string content = Content_Hid.Value;

        //-------------------

        desMod             = desBll.SelReturnModel(Mid);
        desMod.LogoContent = StrHelper.CompressString(Content_Hid.Value);
        desMod.ZStatus     = 99;
        desBll.UpdateByID(desMod);
        Response.Redirect(Request.RawUrl);
    }
Ejemplo n.º 18
0
        /// <summary>
        /// 根据IDS获取试题,如果传入PaperID,则使用其中的临时值,对部分变量初始化
        /// </summary>
        /// <param name="ids">Qids</param>
        /// <param name="paperid">试卷ID</param>
        /// <returns>试题列表</returns>
        public DataTable SelByIDSForExam(string ids, int paperid = 0)
        {
            ids = StrHelper.PureIDSForDB(ids);
            if (string.IsNullOrEmpty(ids))
            {
                return(null);
            }
            SafeSC.CheckIDSEx(ids);
            string    sql     = "SELECT *,IsRight=0,Remark='',pid=0,[order]=0 FROM " + strTableName + " WHERE p_id IN(" + ids + ") ORDER BY p_type";
            DataTable questDT = SqlHelper.ExecuteTable(CommandType.Text, sql);

            //检测有无大题,有大题的话,将大题下的小题也抽出,并设置pid,
            DataRow[] bigdrs = questDT.Select("p_type=10");
            foreach (DataRow dr in bigdrs)
            {
                string    qids = StrHelper.PureIDSForDB(dr["p_content"].ToString());
                int       pid  = DataConvert.CLng(dr["p_id"]);
                DataTable dt   = SelByIDS(qids, pid);//大题不支持嵌套,即大题不能再选大题
                //为其加载在大题中配置好的排序
                DataTable childDT = JsonConvert.DeserializeObject <DataTable>(dr["QInfo"].ToString());
                foreach (DataRow child in childDT.Rows)
                {
                    DataRow[] childDR = dt.Select("p_id=" + child["p_id"]);
                    if (childDR.Length > 0)
                    {
                        childDR[0]["order"] = DataConvert.CLng(child["orderid"]);
                    }
                }
                questDT.Merge(dt);
            }
            //附加临时状态,用于自定义分数,试卷对题目的排序
            if (paperid > 0)
            {
                M_Exam_Sys_Papers paperMod = new B_Exam_Sys_Papers().SelReturnModel(paperid);
                if (paperMod != null && !string.IsNullOrEmpty(paperMod.QuestList))
                {
                    List <M_Exam_TempQuest> list = JsonConvert.DeserializeObject <List <M_Exam_TempQuest> >(paperMod.QuestList);
                    foreach (M_Exam_TempQuest model in list)
                    {
                        DataRow[] drs = questDT.Select("p_id=" + model.id);
                        if (drs.Length < 1)
                        {
                            continue;
                        }
                        drs[0]["p_defaultscores"] = model.score;
                        drs[0]["order"]           = model.order;
                    }
                }
            }//paper end;
            return(questDT);
        }
Ejemplo n.º 19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         M_UserInfo mu    = buser.GetLogin();
         DataTable  nowDT = ExOrder.SelPage(1, int.MaxValue, new F_Order()
         {
             uid     = mu.UserID,
             s_order = "99"
         }).dt;
         DataTable hisDT = ExOrder.SelPage(1, int.MaxValue, new F_Order()
         {
             uid     = mu.UserID,
             s_order = "100"
         }).dt;
         {
             string uids = StrHelper.GetIDSFromDT(nowDT, "spfbrid");
             if (string.IsNullOrEmpty(uids))
             {
                 uids = "-1";
             }
             DataTable dt = teaBll.SelPage(new F_Teacher()
             {
                 uids = uids
             });
             RPT.DataSource = dt;
             RPT.DataBind();
             if (dt.Rows.Count < 1)
             {
                 function.Script(this, "$('#empty1').show();");
             }
         }
         {
             string uids = StrHelper.GetIDSFromDT(hisDT, "spfbrid");
             if (string.IsNullOrEmpty(uids))
             {
                 uids = "-1";
             }
             DataTable dt = teaBll.SelPage(new F_Teacher()
             {
                 uids = uids
             });
             RPT2.DataSource = dt;
             RPT2.DataBind();
             if (dt.Rows.Count < 1)
             {
                 function.Script(this, "$('#empty2').show();");
             }
         }
     }
 }
Ejemplo n.º 20
0
        public IActionResult WelPage_Submit(M_WXImgItem itemMod)
        {
            M_WxImgMsg msgMod = new M_WxImgMsg();

            itemMod.PicUrl = StrHelper.UrlDeal(itemMod.PicUrl);
            itemMod.Url    = StrHelper.UrlDeal(itemMod.Url);
            msgMod.Articles.Add(itemMod);
            M_WX_APPID appmod = appBll.SelReturnModel(AppId);

            appmod.WelStr = JsonConvert.SerializeObject(msgMod);
            appBll.UpdateByID(appmod);
            WxAPI.Code_Get(appmod).AppId.WelStr = appmod.WelStr;
            return(WriteOK("操作成功", ""));
        }
Ejemplo n.º 21
0
        public bool CheckNodeDir(M_Node nodeMod)
        {
            if (StrHelper.StrNullCheck(nodeMod.NodeDir))
            {
                return(false);
            }
            List <SqlParameter> sp = new List <SqlParameter>()
            {
                new SqlParameter("NodeName", nodeMod.NodeName), new SqlParameter("NodeDir", nodeMod.NodeDir)
            };

            string where = "NodeID!=" + nodeMod.NodeID + " AND ParentID=" + nodeMod.ParentID + " AND NodeDir=@NodeDir";
            return(DBCenter.Count(TbName, where, sp) == 0);
        }
Ejemplo n.º 22
0
        public static string GetSnapUrl(object uid, object orderNo, object proid)
        {
            if (StrHelper.StrNullCheck(uid.ToString(), orderNo.ToString(), proid.ToString()))
            {
                return("");
            }
            string url = "/UploadFiles/SnapDir/" + uid + "/" + orderNo + "/" + proid + ".html";

            if (File.Exists(function.VToP(url)))
            {
                return("<a href='" + url + "' target='_blank'>[交易快照]</a>");
            }
            return("");
        }
Ejemplo n.º 23
0
        public void TestIsPrefixedByOneOfPrefixes()
        {
            var good0 = "%s%foo";
            var good1 = "%d%foo";
            var bad0  = "%sfoo";
            var bad1  = "%%dfoo";
            var bad2  = "foo";

            Assert.True(StrHelper.IsPrefixedByOneOfPrefixes(good0, JsMrgHtmlVarRunner.HtmlVarPrefixes));
            Assert.True(StrHelper.IsPrefixedByOneOfPrefixes(good1, JsMrgHtmlVarRunner.HtmlVarPrefixes));
            Assert.False(StrHelper.IsPrefixedByOneOfPrefixes(bad0, JsMrgHtmlVarRunner.HtmlVarPrefixes));
            Assert.False(StrHelper.IsPrefixedByOneOfPrefixes(bad1, JsMrgHtmlVarRunner.HtmlVarPrefixes));
            Assert.False(StrHelper.IsPrefixedByOneOfPrefixes(bad2, JsMrgHtmlVarRunner.HtmlVarPrefixes));
        }
Ejemplo n.º 24
0
    protected void Comp_Click(object sender, EventArgs e)
    {
        DataTable dt = SqlHelper.ExecuteTable("SELECT ID,MsgContent FROM ZL_Guest_Bar");

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow dr = dt.Rows[i];
            dr["MsgContent"] = StrHelper.CompressString(dr["MsgContent"].ToString());
            SqlParameter[] sp  = new SqlParameter[] { new SqlParameter("msg", dr["MsgContent"].ToString()) };
            string         sql = "UPDATE ZL_Guest_Bar SET MsgContent=@msg WHERE ID=" + dr["ID"];
            SqlHelper.ExecuteSql(sql, sp);
        }
        function.WriteErrMsg("操作完成");
    }
Ejemplo n.º 25
0
        public ActionResult AddProduct()
        {
            VM_Product vm = new VM_Product();

            if (Mid < 1)
            {
                if (ModelID < 1)
                {
                    function.WriteErrMsg("没有指定要添加内容的模型ID!"); return(null);
                }
                if (NodeID < 1)
                {
                    function.WriteErrMsg("没有指定要添加内容的栏目节点ID!"); return(null);
                }
                vm.proMod = new M_Product()
                {
                    Stock = 10, Rateset = 1, Dengji = 3
                };
                vm.NodeID         = NodeID;
                vm.ModelID        = ModelID;
                vm.proMod.ProCode = B_Product.GetProCode();
            }
            else
            {
                vm.proMod  = proBll.GetproductByid(Mid);
                vm.NodeID  = vm.proMod.Nodeid;
                vm.ModelID = vm.proMod.ModelID;
                vm.ValueDT = proBll.GetContent(vm.proMod.TableName, vm.proMod.ItemID);
                if (!string.IsNullOrEmpty(vm.proMod.BindIDS))//捆绑商品
                {
                    DataTable dt = proBll.SelByIDS(vm.proMod.BindIDS, "id,Thumbnails,Proname,LinPrice");
                    vm.bindList = JsonConvert.SerializeObject(dt);
                }
                #region 特选商品
                {
                    string where = string.Format("(ProIDS LIKE '%,{0},%' OR ProIDS LIKE '{0},%' OR ProIDS LIKE '%,{0}')", vm.proMod.ID.ToString());
                    DataTable dt   = DBCenter.SelWithField("ZL_User_BindPro", "UserID", where);
                    string    uids = StrHelper.GetIDSFromDT(dt, "UserID");
                    ViewBag.prouids = uids;
                }
                #endregion
            }
            //------------------------------------------------------------------------------------------------
            vm.nodeMod = nodeBll.SelReturnModel(vm.NodeID);
            if (vm.nodeMod.IsNull)
            {
                function.WriteErrMsg("节点[" + NodeID + "]不存在"); return(null);
            }
            return(View(vm));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 把指定的點字字串(16進位)轉成 BrailleCell 物件,並加入點字串列中。
        /// </summary>
        /// <param name="brCode">欲加入串列的點字碼 16 進位字串。</param>
        public void AddCell(string brCode)
        {
            if (String.IsNullOrEmpty(brCode))
            {
                return;
            }

            for (int i = 0; i < brCode.Length; i += 2)
            {
                string      s     = brCode.Substring(i, 2);
                byte        aByte = StrHelper.HexStrToByte(s);
                BrailleCell cell  = BrailleCell.GetInstance(aByte);
                m_CellList.Add(cell);
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 截断字符串
 /// </summary>
 /// <param name="s">源字符串</param>
 /// <param name="length">需要截断的长度</param>
 /// <param name="isend">是否添加...标记</param>
 /// <returns></returns>
 public static string GetSubString(string s, int length, bool isend)
 {
     if (!string.IsNullOrEmpty(s) && length > 0)
     {
         if (isend)
         {
             return(StrHelper.GetUnicodeSubString(s, length, "..."));
         }
         else
         {
             return(StrHelper.GetUnicodeSubString(s, length, ""));
         }
     }
     return(s);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// DES加密字符串
        /// </summary>
        /// <param name="encryptString">待加密的字符串</param>
        /// <param name="encryptKey">加密密钥,要求为8位</param>
        /// <returns>加密成功返回加密后的字符串,失败返回源串</returns>
        public static string DESEncode(string encryptString, string encryptKey)
        {
            encryptKey = StrHelper.GetSubString(encryptKey, 8, "");
            encryptKey = encryptKey.PadRight(8, ' ');
            byte[] rgbKey                    = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
            byte[] rgbIV                     = Keys;
            byte[] inputByteArray            = Encoding.UTF8.GetBytes(encryptString);
            DESCryptoServiceProvider dCSP    = new DESCryptoServiceProvider();
            MemoryStream             mStream = new MemoryStream();
            CryptoStream             cStream = new CryptoStream(mStream, dCSP.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);

            cStream.Write(inputByteArray, 0, inputByteArray.Length);
            cStream.FlushFinalBlock();
            return(Convert.ToBase64String(mStream.ToArray()));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 將十六進位的點字碼字串轉成對應的點字物件,並加入點字串列。
        /// </summary>
        /// <param name="brCodes">十六進位的點字碼字串。此字串的長度應為 2 的倍數。</param>
        /// <returns></returns>
        public void Add(string brCodes)
        {
            if (String.IsNullOrEmpty(brCodes))
            {
                return; // 忽略空的點字碼(因為呼叫端可能常常會傳入空的點字碼)
            }

            for (int i = 0; i < brCodes.Length; i += 2)
            {
                string      s     = brCodes.Substring(i, 2);
                byte        aByte = StrHelper.HexStrToByte(s);
                BrailleCell cell  = BrailleCell.GetInstance(aByte);
                m_Cells.Add(cell);
            }
        }
Ejemplo n.º 30
0
        public IActionResult ASCXLoad(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(Content(""));
            }
            C_Model model = new C_Model();

            model.mode  = StrHelper.GetValFromUrl(name, "mode");
            model.value = StrHelper.GetValFromUrl(name, "value");
            string cshtmlName = name.Split('?')[0].Replace(".ascx", "");

            //检测当前页面是否有缓存,无则重新加载
            return(PartialView("~/Areas/Admin/Views/Shared/" + cshtmlName + ".cshtml", model));
        }