示例#1
0
        public void GetMesh(XElement ele, string outputFile, bool bUseAPILib)
        {
            string    TempFileName = "";
            APIStatus sts;

            if (!bUseAPILib)
            {
                string url     = "http://www.meshola.com/API/APIAlpha";
                string command = "getmesh";
                string xmldata = ele.ToString();

                // Post to the API url and get back a file
                using (WebClient client = new WebClient())
                {
                    var reqparm = new System.Collections.Specialized.NameValueCollection();
                    reqparm.Add("uk", "");
                    reqparm.Add("command", command);
                    reqparm.Add("xmldata", xmldata);
                    reqparm.Add("outputfile", "HelloStairs.fbx");
                    Console.WriteLine("before API call");
                    byte[]       responsebytes = client.UploadValues(url, "POST", reqparm);
                    MemoryStream ms            = new MemoryStream(responsebytes);
                    Console.WriteLine("after API call");
                    TempFileName = Path.GetTempFileName();
                    File.WriteAllBytes(TempFileName, responsebytes);
                }
            }
            else
            {
                API oAPI = new API();
                sts = oAPI.APIEntry(eAPICommand.GetMesh, ele);
                if (sts.Success == false)
                {
                    throw new Exception("Failed to get mesh from API");
                }
                TempFileName = sts.OutputFile;
            }

            File.Delete(outputFile);
            File.Copy(TempFileName, outputFile);
        }