Esempio n. 1
0
        public string GetCardDeviceById(string loginIdentifer, string cardDeviceID)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            obj2.Add("CardDevice", new JavaScriptObject());
            try
            {
                ResMsg msg = CommonUtil.CheckLoginState(loginIdentifer, true);
                if (!msg.Result)
                {
                    obj2["Message"] = msg.Message;
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                if ((cardDeviceID == null) || (cardDeviceID.Trim() == ""))
                {
                    obj2["Message"] = "设备卡ID不能为空";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                CardDevice cardDevice = CardDeviceModule.GetCardDeviceById(long.Parse(cardDeviceID));
                if (cardDevice == null)
                {
                    obj2["Message"] = "ID为" + cardDeviceID + "设备卡不存在";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                obj2["Result"]     = true;
                obj2["CardDevice"] = CardDeviceModule.CardDeviceToJson(cardDevice);
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
Esempio n. 2
0
        public string GetCardDeviceByIds(string loginIdentifer, string Ids)
        {
            JavaScriptObject obj2  = new JavaScriptObject();
            JavaScriptArray  array = new JavaScriptArray();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            obj2.Add("CardDevices", array);
            try
            {
                ResMsg msg = CommonUtil.CheckLoginState(loginIdentifer, true);
                if (!msg.Result)
                {
                    obj2["Message"] = msg.Message;
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                if ((Ids == null) || (Ids.Trim() == ""))
                {
                    obj2["Message"] = "设备卡ID不能为空";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                foreach (string str in Ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    CardDevice card = CardDeviceModule.GetCardDeviceById(long.Parse(str));
                    if (card == null)
                    {
                        obj2["Message"] = "ID为" + str + "的设备卡不存在";
                        return(JavaScriptConvert.SerializeObject(obj2));
                    }
                    array.Add(CardDeviceModule.CardDeviceToJson(card));
                }
                obj2["Result"] = true;
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }