コード例 #1
0
    public void SaveTower()
    {
        FileLoader fl = new FileLoader(Application.persistentDataPath, "Towers", towerFileName);
        //FileLoader fl = new FileLoader ("JSONData" + Path.DirectorySeparatorChar + "Towers",towerFileName);
        string json = "";

        json += "{\n";
        json += "\t\"towerName\":\"" + nameEntry.text + "\",\n";
        json += "\t\"decalFilename\":\"" + decalFilename + "\",\n";
        json += "\t\"towerType\":\"" + towerType + "\",\n";
        json += "\n";
        json += "\t\"pieces\":[\n";
        for (int i = 0; i < allPieces.Count; i++)
        {
            PieceRecord pr   = allPieces[i];
            string      line = "\t\t{";
            line += "\"anchorX\":" + pr.x + ", ";
            line += "\"anchorY\":" + pr.y + ", ";
            line += "\"rotation\":" + pr.pc.GetRotation() + ", ";
            line += "\"flipped\":" + (pr.pc.GetFlipped() ? "true" : "false") + ", ";
            line += "\"flipRotation\":" + pr.pc.GetFlipRotation() + ", ";
            line += "\"pieceFilename\":\"" + pr.pc.GetFilename() + "\"}";
            if (i != allPieces.Count - 1)
            {
                line += ",";
            }
            line += "\n";
            json += line;
        }
        json += "\t]\n";
        json += "}";
        Debug.Log(json);
        fl.Write(json);
    }
コード例 #2
0
        private PieceRecord GetPieceData(string url)
        {
            PieceRecord JMPiece    = new PieceRecord();
            WebRequest  apiRequest = WebRequest.Create(url);

            apiRequest.Proxy = null;
            HttpWebResponse apiResponse = (HttpWebResponse)apiRequest.GetResponse();

            if (apiResponse.StatusCode == HttpStatusCode.OK)
            {
                string xmlOutput;
                using (StreamReader sr = new StreamReader(apiResponse.GetResponseStream()))
                    xmlOutput = sr.ReadToEnd();
                if (xmlOutput == "\r\n")
                {
                    return(null);
                }
                XmlSerializer xmlSerialize = new XmlSerializer(typeof(PieceRecord));

                var xmlResult = (PieceRecord)xmlSerialize.Deserialize(new StringReader(xmlOutput));

                if (xmlResult != null)
                {
                    return((PieceRecord)xmlResult);
                }
                else
                {
                    return(default(PieceRecord));
                }
            }
            return(null);
        }
コード例 #3
0
    public void SaveTower()
    {
        FileLoader fl   = new FileLoader(Application.persistentDataPath, "Towers", "testSaveLocation");
        string     json = "";

        json += "{\n";
        json += "\t\"decalFilename\":\"" + decalFilename + "\",\n";
        json += "\t\"towerType\":\"" + towerType + "\",\n";
        json += "\n";
        json += "\t\"pieces\":[\n";
        for (int i = 0; i < allPieces.Count; i++)
        {
            PieceRecord pr   = allPieces[i];
            string      line = "\t\t{";
            line += "\"anchorX\":" + pr.x + ", ";
            line += "\"anchorY\":" + pr.y + ", ";
            line += "\"rotation\":" + pr.pc.GetRotation() + ", ";
            line += "\"pieceFilename\":\"" + pr.pc.GetFilename() + "\"}";
            if (i != allPieces.Count - 1)
            {
                line += ",";
            }
            line += "\n";
            json += line;
        }
        json += "\t]\n";
        json += "}";
        Debug.Log(json);
        fl.Write(json);
    }
コード例 #4
0
        private void btnGO_Click(object sender, EventArgs e)
        {
            tbType.Text        = "";
            tbName.Text        = "";
            tbPieces.Text      = "";
            tbWeight.Text      = "";
            tbUnits.Text       = "";
            tbArticleNo.Text   = "";
            tbArticleDesc.Text = "";
            tbWeightPiece.Text = "";
            tbLength.Text      = "";

            if (tbURL.Text.Contains("GetPiece?uid="))
            {
                // Single Piece Data
                tbType.Text = "JM-Piece ";
                PieceRecord JMPiece = GetPieceData(tbURL.Text);
                if (JMPiece != null)
                {
                    //
                    // write the JMPiece to your database server
                    //
                    tbType.Text        = "JM-Piece " + JMPiece.PieceNo.ToString();
                    tbArticleNo.Text   = JMPiece.ArticleNo;
                    tbArticleDesc.Text = JMPiece.ArticleDescription;
                    tbWeightPiece.Text = JMPiece.WeightBrut.ToString() + "/" + JMPiece.WeightNet.ToString() + " kg";
                    tbLength.Text      = JMPiece.Brut.ToString() + "/" + JMPiece.Net.ToString() + " m";
                }
            }
            else
            {
                // Packing List Data
                tbType.Text = "JM-Packing list";
                PLRecord JMPackingList = GetPackingListData(tbURL.Text);
                if (JMPackingList != null)
                {
                    //
                    // write the JMPackingList to your database server
                    //
                    tbType.Text   = "JM-Packing list No.:" + JMPackingList.PackinglistNo.ToString();
                    tbName.Text   = JMPackingList.CustomerName;
                    tbPieces.Text = JMPackingList.PieceCount.ToString() + " pieces";
                    tbWeight.Text = JMPackingList.TotalWeight.ToString() + " kg";
                    tbUnits.Text  = JMPackingList.ShippingUnitCount.ToString() + " shipping units";
                }
            }
        }