Beispiel #1
0
        /// <summary>
        /// 获取接口列表
        /// </summary>
        public void Get_InterfaceTestList()
        {
            InterfaceModelList list = Get_InterFaceList();

            if (list != null)
            {
                CommonMethod.ResponseJsonResult(list.inlist);
            }
            else
            {
                CommonMethod.ResponseJsonResult(new List <InterfaceModel>());
            }
        }
Beispiel #2
0
        /// <summary>
        /// 判断原来是否存在这个xml文档
        /// </summary>
        public void Comfird_FileExist()
        {
            string             InterfaceName = Request["InterfaceName"];
            string             filepath      = AppsettingConfig.xmlpath.Replace("{InterfaceKey}", InterfaceName);
            InterfaceModelList list          = Get_InterFaceList();

            if (list != null)
            {
                List <InterfaceModel> inlist = list.inlist;
                bool isexist = inlist.Exists(x => x.InterfaceName == InterfaceName);
                CommonMethod.ResponseJsonResult(new { success = true, isexist = isexist });
            }
            else
            {
                CommonMethod.ResponseJsonResult(new { success = true, isexist = false });
            }
        }
Beispiel #3
0
        /// <summary>
        /// 获取接口的链接与key值
        /// </summary>
        public void Get_InterfaceDataModel()
        {
            string InterfaceName = Request["InterfaceName"];

            if (String.IsNullOrEmpty(InterfaceName))
            {
                CommonMethod.ResponseJsonResult(new { success = false, msg = "请选择所需要接口!" });
            }
            else
            {
                InterfaceModelList list = Get_InterFaceList();
                if (list != null)
                {
                    List <InterfaceModel> inlist = list.inlist;
                    InterfaceModel        model  = inlist.First(x => x.InterfaceName == InterfaceName);
                    CommonMethod.ResponseJsonResult(new { success = true, datamodel = model });
                }
                else
                {
                    CommonMethod.ResponseJsonResult(new { success = false, msg = "不存在接口列表" });
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 保存接口data
        /// </summary>
        public void Save_InterfaceData()
        {
            string InterfaceName  = Request["InterfaceName"];
            string InterfaceUrl   = Request["InterfaceUrl"];
            string xml_base64     = Request["xml_base64"];
            string chName         = Request["chName"];
            string InterfaceDes   = Request["InterfaceDes"];
            string InterfaceReDes = Request["InterfaceReDes"];
            string msgout         = string.Empty;
            bool   isupload       = UploadXmlFile(xml_base64, InterfaceName, out msgout);

            if (isupload)
            {
                InterfaceModelList savelist = new InterfaceModelList();
                InterfaceModelList list     = Get_InterFaceList();
                if (list != null)
                {
                    List <InterfaceModel> inlist = list.inlist;
                    // inlist.Remove(new InterfaceModel { InterfaceName = InterfaceName });
                    inlist.RemoveAll(x => x.InterfaceName == InterfaceName);//按Key删除
                    inlist.Add(new InterfaceModel {
                        InterfaceReDes = InterfaceReDes, InterfaceName = InterfaceName, InterfaceUrl = InterfaceUrl, selecName = string.Format("{0}({1})", chName, InterfaceUrl), chName = chName, InterfaceDes = InterfaceDes
                    });
                    savelist.inlist = inlist;
                    string path = HttpContext.Server.MapPath(AppsettingConfig.interlistpath);
                    CreateconfigFile(path);
                    FileStream   fs = new FileStream(path, FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    //开始写入
                    sw.Write(Newtonsoft.Json.JsonConvert.SerializeObject(savelist));//写入文件,替换原文件
                    //清空缓冲区
                    sw.Flush();
                    //关闭流
                    sw.Close();
                    fs.Close();
                    CommonMethod.ResponseJsonResult(new { success = true, msg = "保存测试接口成功." });
                }
                else
                {
                    List <InterfaceModel> inlist = new List <InterfaceModel>();
                    inlist.Add(new InterfaceModel {
                        InterfaceReDes = InterfaceReDes, InterfaceName = InterfaceName, InterfaceUrl = InterfaceUrl, selecName = string.Format("{0}({1})", chName, InterfaceUrl), chName = chName, InterfaceDes = InterfaceDes
                    });
                    savelist.inlist = inlist;
                    string path = HttpContext.Server.MapPath(AppsettingConfig.interlistpath);
                    CreateconfigFile(path);
                    FileStream   fs = new FileStream(path, FileMode.Create);
                    StreamWriter sw = new StreamWriter(fs);
                    //开始写入
                    sw.Write(Newtonsoft.Json.JsonConvert.SerializeObject(savelist));//写入文件,替换原文件
                    //清空缓冲区
                    sw.Flush();
                    //关闭流
                    sw.Close();
                    fs.Close();
                    CommonMethod.ResponseJsonResult(new { success = true, msg = "保存测试接口成功." });
                }
            }
            else
            {
                msgout = msgout == "" ? "上传文件出错,请确定文件是否正确" : msgout;
                CommonMethod.ResponseJsonResult(new { success = false, msg = msgout });
            }
        }