コード例 #1
0
        /// <summary>
        /// 删除指定ID的销售模板
        /// </summary>
        /// <param name="desc">错误描述</param>
        /// <returns></returns>
        public int delTemp(ref string desc)
        {
            if (tempID == 0)
            {
                return(INVALIDTEMPID);
            }
            //拼接json数据
            StringBuilder jTemp = new StringBuilder();
            StringWriter  sw    = new StringWriter(jTemp);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("templateId");
                writer.WriteValue(tempID);
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    tempJsonInfo = jTemp.ToString();
            string    retJson      = ALG.senseCloudRequest(API.DeleteTemplate, tempJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            return(ret);
        }
コード例 #2
0
        //删除影子账户
        public int delUser(string userid, ref string desc)
        {
            if (Dev.Appid == "" || Dev.Secret == "")
            {
                return(NINITDEV);
            }
            if (userid == "")
            {
                return(NUSERID);
            }
            //拼接json数据
            StringBuilder jShadow = new StringBuilder();
            StringWriter  sw      = new StringWriter(jShadow);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("userId");
                writer.WriteValue(userid);
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    userJsonInfo = jShadow.ToString();
            string    retJson      = ALG.senseCloudRequest(API.DeleteUser, userJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            return(ret);
        }
コード例 #3
0
        /// <summary>
        /// 根据产品ID(许可ID)查找模板
        /// </summary>
        /// <param name="desc">错误描述</param>
        /// <returns></returns>
        public int findTempByProdID(ref string desc, ref string tempData)
        {
            if (licenseId == 0)
            {
                return(INVALIDLICID);
            }
            //拼接json数据
            StringBuilder jTemp = new StringBuilder();
            StringWriter  sw    = new StringWriter(jTemp);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("licenseId");
                writer.WriteValue(licenseId);
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    tempJsonInfo = jTemp.ToString();
            string    retJson      = ALG.senseCloudRequest(API.TemplateList, tempJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            if (ret == 0)
            {
                tempData = jobj["data"].ToString();
            }
            return(ret);
        }
コード例 #4
0
        public int findProductByName(ref string desc, ref string proData)
        {
            if (productName == "")
            {
                return(INVALIDLICNAME);
            }
            //拼接json数据
            StringBuilder jProduct = new StringBuilder();
            StringWriter  sw       = new StringWriter(jProduct);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("productName");
                writer.WriteValue(productName);
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG         = new algorithm();
            string    proJsonInfo = jProduct.ToString();
            string    retJson     = ALG.senseCloudRequest(API.ProductList, proJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            if (ret == 0)
            {
                proData = jobj["data"].ToString();
            }
            return(ret);
        }
コード例 #5
0
        //创建影子账户
        public int addShadowUser(ref string desc)
        {
            if (Dev.Appid == "" || Dev.Secret == "")
            {
                return(NINITDEV);
            }
            if (userAccount == "" || passwd == "")
            {
                return(NSETUSERINFO);
            }
            //拼接json数据
            StringBuilder jShadow = new StringBuilder();
            StringWriter  sw      = new StringWriter(jShadow);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("shadowAccount");
                writer.WriteValue(userAccount);
                writer.WritePropertyName("passwd");
                writer.WriteValue(passwd);
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    userJsonInfo = jShadow.ToString();
            string    retJson      = ALG.senseCloudRequest(API.AddShadowUser, userJsonInfo, Dev.Appid, Dev.Secret);
            //分析JSON数据
            JObject Jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(Jobj["code"].ToString());

            desc = Jobj["desc"].ToString();
            if (ret == 0)
            {
                shadowAccount = Jobj["data"]["userAccount"].ToString();
                userID        = Jobj["data"]["userId"].ToString();
            }

            return(0);
        }
コード例 #6
0
        /// <summary>
        /// 修改销售模板
        /// </summary>
        /// <param name="desc">错误描述</param>
        /// <returns></returns>
        public int modifyTemp(ref string desc)
        {
            if (tempID == 0)
            {
                return(INVALIDTEMPID);
            }
            //拼接json数据
            StringBuilder jTemp = new StringBuilder();
            StringWriter  sw    = new StringWriter(jTemp);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("templateId");
                writer.WriteValue(tempID);
                if (templateName != "")
                {
                    writer.WritePropertyName("templateName");
                    writer.WriteValue(templateName);
                }
                if (LicStartTimeType != "")
                {
                    writer.WritePropertyName("licStartTimeType");
                    writer.WriteValue(licStartTimeType);
                }
                if (canModify != "")
                {
                    writer.WritePropertyName("canModify");
                    writer.WriteValue(Convert.ToInt32(canModify));
                }
                //许可类型(云,软)
                writer.WritePropertyName("licenseForm");
                if (licenseForm == cloud)
                {
                    writer.WriteValue(cloud);
                }
                else if (licenseForm == slock)
                {
                    writer.WriteValue(slock);
                    if (offlineDays != 0)
                    {
                        writer.WritePropertyName("offlineDays");
                        writer.WriteValue(offlineDays);
                    }
                    if (LicBindLimit != 0)
                    {
                        writer.WritePropertyName("licBindLimit");
                        writer.WriteValue(licBindLimit);
                    }
                    if (licBindMaxLimit != 0)
                    {
                        writer.WritePropertyName("licBindMaxLimit");
                        writer.WriteValue(licBindMaxLimit);
                    }
                }
                if (moduleInfo.Count != 0)
                {
                    string module = module2Json();
                    writer.WritePropertyName("modules");
                    writer.WriteValue(module);
                }
                if (raw != "")
                {
                    writer.WritePropertyName("raw");
                    writer.WriteValue(raw);
                }
                if (pub != "")
                {
                    writer.WritePropertyName("pub");
                    writer.WriteValue(pub);
                }
                if (rom != "")
                {
                    writer.WritePropertyName("rom");
                    writer.WriteValue(rom);
                }
                if (startTime != 0)
                {
                    writer.WritePropertyName("startTime");
                    writer.WriteValue(startTime);
                }
                if (endTime != 0)
                {
                    writer.WritePropertyName("endTime");
                    writer.WriteValue(endTime);
                }
                if (spanTime != 0)
                {
                    writer.WritePropertyName("spanTime");
                    writer.WriteValue(spanTime);
                }
                if (licDuration != 0)
                {
                    writer.WritePropertyName("licDuration");
                    writer.WriteValue(licDuration);
                }
                if (version != 0)
                {
                    writer.WritePropertyName("version");
                    writer.WriteValue(version);
                }

                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    tempJsonInfo = jTemp.ToString();
            string    retJson      = ALG.senseCloudRequest(API.ModifyTemplate, tempJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            return(ret);
        }
コード例 #7
0
        //修改影子账户信息
        public int modifyUser(ref string desc)
        {
            if (Dev.Appid == "" || Dev.Secret == "")
            {
                return(NINITDEV);
            }
            if (userID == "")
            {
                return(NSETUSERINFO);
            }
            //拼接json数据
            StringBuilder jShadow = new StringBuilder();
            StringWriter  sw      = new StringWriter(jShadow);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("userId");
                writer.WriteValue(userID);
                if (nickname != "")
                {
                    writer.WritePropertyName("nickname");
                    writer.WriteValue(nickname);
                }
                if (cellphone != "")
                {
                    writer.WritePropertyName("cellphone");
                    writer.WriteValue(cellphone);
                }
                if (sex != "")
                {
                    writer.WritePropertyName("sex");
                    writer.WriteValue(sex);
                }
                if (tel != "")
                {
                    writer.WritePropertyName("tel");
                    writer.WriteValue(tel);
                }
                if (address != "")
                {
                    writer.WritePropertyName("address");
                    writer.WriteValue(address);
                }
                if (desc != "")
                {
                    writer.WritePropertyName("desc");
                    writer.WriteValue(this.desc);
                }
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    userJsonInfo = jShadow.ToString();
            string    retJson      = ALG.senseCloudRequest(API.ModifyUser, userJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            return(ret);
        }
コード例 #8
0
        //查找用户,需要设置至少emial,nickname,cellphone,currentPage,pagesize一项
        public int findUser(ref string desc, ref string usersData)
        {
            if (Dev.Appid == "" || Dev.Secret == "")
            {
                return(NINITDEV);
            }
            if (email == "" && nickname == "" && cellphone == "" && currentPage == 0 && pageSize == 0)
            {
                return(NSETUSERINFO);
            }
            //拼接json数据
            StringBuilder jShadow = new StringBuilder();
            StringWriter  sw      = new StringWriter(jShadow);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                if (email != "")
                {
                    writer.WritePropertyName("email");
                    writer.WriteValue(email);
                }
                if (nickname != "")
                {
                    writer.WritePropertyName("nickname");
                    writer.WriteValue(nickname);
                }
                if (cellphone != "")
                {
                    writer.WritePropertyName("cellphone");
                    writer.WriteValue(cellphone);
                }
                if (currentPage != 0)
                {
                    writer.WritePropertyName("currentPage");
                    writer.WriteValue(currentPage);
                }
                if (pageSize != 0)
                {
                    writer.WritePropertyName("pageSize");
                    writer.WriteValue(pageSize);
                }
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    userJsonInfo = jShadow.ToString();
            string    retJson      = ALG.senseCloudRequest(API.FindUsers, userJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            if (ret == 0)
            {
                usersData = jobj["data"].ToString();
            }
            return(ret);
        }
コード例 #9
0
        //创建用户
        public int addUser(ref string desc)
        {
            if (Dev.Appid == "" || Dev.Secret == "")
            {
                return(NINITDEV);
            }
            if (nickname == "" || userAccount == "" || passwd == "" || cellphone == "")
            {
                return(NSETUSERINFO);
            }
            //拼接JSON字符串
            StringBuilder jUser = new StringBuilder();
            StringWriter  sw    = new StringWriter(jUser);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("nickname");
                writer.WriteValue(nickname);
                writer.WritePropertyName("userAccount");
                writer.WriteValue(userAccount);
                writer.WritePropertyName("passwd");
                writer.WriteValue(passwd);
                writer.WritePropertyName("cellphone");
                writer.WriteValue(cellphone);
                if (sex != "")
                {
                    writer.WritePropertyName("sex");
                    writer.WriteValue(sex);
                }
                if (tel != "")
                {
                    writer.WritePropertyName("tel");
                    writer.WriteValue(tel);
                }
                if (address != "")
                {
                    writer.WritePropertyName("address");
                    writer.WriteValue(address);
                }
                if (desc != "")
                {
                    writer.WritePropertyName("desc");
                    writer.WriteValue(this.desc);
                }
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG          = new algorithm();
            string    userJsonInfo = jUser.ToString();
            string    retJsonInfo  = ALG.senseCloudRequest(API.AddUser, userJsonInfo, Dev.Appid, Dev.Secret);
            //分析JSON数据
            JObject jobj = JObject.Parse(retJsonInfo);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            if (ret == 0)
            {
                userID = jobj["data"]["userId"].ToString();
            }
            return(ret);
        }
コード例 #10
0
        public int modifyProduct(ref string desc)
        {
            if (licenseId == 0)
            {
                return(INVALIDLICID);
            }
            if (productName == "" || licenseForm == 0)
            {
                return(NSETPRODUCT);
            }

            //拼接json数据
            StringBuilder jProduct = new StringBuilder();
            StringWriter  sw       = new StringWriter(jProduct);

            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;

                writer.WriteStartObject();
                writer.WritePropertyName("licenseId");
                writer.WriteValue(licenseId);
                if (productName != "")
                {
                    writer.WritePropertyName("productName");
                    writer.WriteValue(productName);
                }
                writer.WritePropertyName("licenseForm");
                writer.WriteStartArray();
                if (licenseForm == cloud)
                {
                    writer.WriteValue(cloud);
                }
                else if (licenseForm == slock)
                {
                    writer.WriteValue(slock);
                }
                else if (licenseForm == cldAndSlk)
                {
                    writer.WriteValue(cloud);
                    writer.WriteValue(slock);
                }
                writer.WriteEnd();
                if (moduleInfo.Count != 0)
                {
                    string module = module2Json();
                    writer.WritePropertyName("modules");
                    writer.WriteValue(module);
                }
                if (raw != "")
                {
                    writer.WritePropertyName("raw");
                    writer.WriteValue(raw);
                }
                if (pub != "")
                {
                    writer.WritePropertyName("pub");
                    writer.WriteValue(pub);
                }
                if (rom != "")
                {
                    writer.WritePropertyName("rom");
                    writer.WriteValue(rom);
                }
                writer.WriteEndObject();
            }
            //调用公共算法类
            algorithm ALG         = new algorithm();
            string    proJsonInfo = jProduct.ToString();
            string    retJson     = ALG.senseCloudRequest(API.ModifyProduct, proJsonInfo, Dev.Appid, Dev.Secret);
            //解析JSON返回值
            JObject jobj = JObject.Parse(retJson);
            int     ret  = Convert.ToInt32(jobj["code"].ToString());

            desc = jobj["desc"].ToString();
            return(ret);
        }