Example #1
0
    IEnumerator start1()
    {
        //Resources.UnloadUnusedAssets();

        post_value = Panel.transform.GetComponent <ToggleScene> ();
        post_type  = post_value.post_type;
        Debug.Log("文章類型:" + post_type);
        Debug.Log("submit");


        UIPopupList cityselect = GameObject.Find("CitySelect").GetComponent <UIPopupList> ();

        city = cityselect.value;
        if (city == "台北")
        {
            city = "Taipei";
        }
        else if (city == "台中")
        {
            city = "Taichung";
        }
        else if (city == "台南")
        {
            city = "Tainan";
        }
        else if (city == "新北")
        {
            city = "NewTaipei";
        }
        else if (city == "桃園")
        {
            city = "Taoyuan";
        }
        else if (city == "高雄")
        {
            city = "Kaohsiung";
        }
        //進經濟地理資料庫部分
        UIPopupList lbs      = GameObject.Find("place_pop").GetComponent <UIPopupList>();
        string      lbs_name = lbs.value;

        if (lbs_name != "")
        {
            //StartCoroutine(xml(lbs_name));
            string url = "http://egis.moea.gov.tw/innoserve/toolLoc/GetFastLocData.aspx?cmd=searchLayer2&group=0&db=ALL&param=" + lbs_name + "&coor=84";
            WWW    www = new WWW(url);
            yield return(www);

            if (www.error == null)
            {
                Debug.Log("Loaded following XML " + www.data);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(www.data);

                XmlNode provinces = xmlDoc.SelectSingleNode("result");
                Debug.Log("readxml");

                foreach (XmlNode province in provinces)
                {
                    XmlElement _province = (XmlElement)province;

                    geo_x = _province.GetAttribute("Cx");
                    geo_y = _province.GetAttribute("Cy");
                    Debug.Log(geo_x);
                    Debug.Log(geo_y);
                    //yield return geo_x;
                    //yield return geo_y;
                }
            }
        }


        UserTag_1 = UserTagInput[0].value;
        UserTag_2 = UserTagInput[1].value;
        UserTag_3 = UserTagInput[2].value;

        string userpost = userpostLabel.value;

        /*
         * ParseObject POST = new ParseObject("POST");
         * POST ["postfield"] = userpost;
         * POST ["Location"] = city;
         * POST ["foo"] = post_type;
         * POST.SaveAsync();*/

        ParseObject POST = new ParseObject("POST");

        /*Loom.QueueOnMainThread (() => {
         *      if (img == null) {
         *              byte[] data = img1.EncodeToJPG ();
         *              ParseFile file = new ParseFile ("none.jpg", data);
         *              file.SaveAsync ().ContinueWith (t =>
         *              {
         *                      Debug.Log (file.Name);
         *              });
         *              POST ["file"] = file;
         *      } else {
         *              byte[] data = img.EncodeToJPG ();
         *              ParseFile file = new ParseFile ("photo.jpg", data);
         *              file.SaveAsync ().ContinueWith (t =>
         *              {
         *                      Debug.Log (file.Name);
         *              });
         *              POST ["file"] = file;
         *      }
         * });*/
        if (lbs_name != "")
        {
            double result  = Convert.ToDouble(geo_x);
            double result2 = Convert.ToDouble(geo_y);
            var    point   = new ParseGeoPoint(result2, result);
            POST ["Post_Geo"]  = point;
            POST ["geo_place"] = lbs_name;
        }
        POST ["postfield"] = userpost;
        POST ["Location"]  = city;
        POST ["foo"]       = post_type;
        POST ["Like"]      = InitialAmount;
        POST ["DisLike"]   = InitialAmount;
        POST ["Tag1"]      = UserTag_1;
        POST ["Tag2"]      = UserTag_2;
        POST ["Tag3"]      = UserTag_3;
        POST ["Sum"]       = 0;
        POST ["User"]      = ParseUser.CurrentUser.Username;
        Debug.Log(post_type);
        Debug.Log(city);
        //POST.SaveAsync();
        //Debug.Log ("文章內容:" + userpost);
        POST.SaveAsync().ContinueWith(t =>
        {
            Debug.Log("文章內容:" + userpost);
        });


        FindorSave(UserTag_1, 0);
        FindorSave(UserTag_2, 1);
        FindorSave(UserTag_3, 2);

        cityselect.value = "城市";

        userpostLabel.value = "";
        lbs_name            = null;
        Debug.Log(lbs_name);
    }
Example #2
0
    IEnumerator OnClick()
    {
        post_value = Panel.transform.GetComponent <ToggleScene> ();
        post_type  = post_value.post_type;
        Debug.Log("文章類型:" + post_type);
        Debug.Log("submit");

        UIPopupList cityselect = GameObject.Find("CitySelect").GetComponent <UIPopupList> ();
        string      city       = cityselect.value;

        if (city == "台北")
        {
            city = "Taipei";
        }
        else if (city == "台中")
        {
            city = "Taichung";
        }
        else if (city == "台南")
        {
            city = "Tainan";
        }
        else if (city == "新北")
        {
            city = "NewTaipei";
        }
        else if (city == "桃園")
        {
            city = "Taoyuan";
        }
        else if (city == "高雄")
        {
            city = "Kaohsiung";
        }
        //進經濟地理資料庫部分
        UIPopupList lbs      = GameObject.Find("place_pop").GetComponent <UIPopupList>();
        string      lbs_name = lbs.value;

        if (lbs_name != null)
        {
            //StartCoroutine(xml(lbs_name));
            string url = "http://egis.moea.gov.tw/innoserve/toolLoc/GetFastLocData.aspx?cmd=searchLayer2&group=0&db=ALL&param=" + lbs_name + "&coor=84";
            WWW    www = new WWW(url);
            yield return(www);

            if (www.error == null)
            {
                Debug.Log("Loaded following XML " + www.data);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(www.data);

                XmlNode provinces = xmlDoc.SelectSingleNode("result");
                Debug.Log("readxml");

                foreach (XmlNode province in provinces)
                {
                    XmlElement _province = (XmlElement)province;

                    geo_x = _province.GetAttribute("Cx");
                    geo_y = _province.GetAttribute("Cy");
                    Debug.Log(geo_x);
                    Debug.Log(geo_y);
                    //yield return geo_x;
                    //yield return geo_y;
                }
            }
        }


        UserTag_1 = UserTagInput[0].value;
        UserTag_2 = UserTagInput[1].value;
        UserTag_3 = UserTagInput[2].value;

        string userpost = userpostLabel.value;

        ParseObject POST = new ParseObject("POST");


        if (img != null)
        {
            byte[] data = img.EncodeToJPG();
            //byte[] files = System.Text.Encoding.UTF8.GetBytes(data);
            ParseFile file = new ParseFile("resume.jpg", data);

            file.SaveAsync().ContinueWith(t =>
            {
                Debug.Log(file.Name);
            });
            POST ["file"] = file;
        }

        if (lbs_name != null)
        {
            double result  = Convert.ToDouble(geo_x);
            double result2 = Convert.ToDouble(geo_y);
            var    point   = new ParseGeoPoint(result2, result);
            POST ["Post_Geo"]  = point;
            POST ["geo_place"] = lbs_name;
        }
        POST ["postfield"] = userpost;
        POST ["Location"]  = city;
        POST ["foo"]       = post_type;
        POST ["User"]      = ParseUser.CurrentUser.Username;
        string str = POST.ObjectId;

        POST.SaveAsync().ContinueWith(t =>
        {
            Debug.Log("文章內容:" + userpost);
        });
        cityselect.value    = "城市";
        lbs.value           = "確認→";
        userpostLabel.value = "";

        FindorSave(UserTag_1, 0);
        FindorSave(UserTag_2, 1);
        FindorSave(UserTag_3, 2);

        ParseObject JUDGE = new ParseObject("JUDGE");

        JUDGE ["Post_Id"] = str;
        JUDGE ["Like"]    = InitialAmount;
        JUDGE ["DisLike"] = InitialAmount;
        JUDGE.SaveAsync();
        Debug.Log("save");
    }
Example #3
0
    void UpdateOldUser(ParseFile file)
    {
        Loom.QueueOnMainThread(() => {
            post_value = Panel.transform.GetComponent <ToggleScene> ();
            post_type  = post_value.post_type;
            Debug.Log("文章類型:" + post_type);
            Debug.Log("submit");

            UIPopupList cityselect = GameObject.Find("CitySelect").GetComponent <UIPopupList> ();
            city = cityselect.value;
            if (city == "台北")
            {
                city = "Taipei";
            }
            else if (city == "台中")
            {
                city = "Taichung";
            }
            else if (city == "台南")
            {
                city = "Tainan";
            }
            else if (city == "新北")
            {
                city = "NewTaipei";
            }
            else if (city == "桃園")
            {
                city = "Taoyuan";
            }
            else if (city == "高雄")
            {
                city = "Kaohsiung";
            }

            ParseObject low = new ParseObject("POST");
            low["file"]     = file;
            if (lbs_name != "")
            {
                double result     = Convert.ToDouble(geo_x);
                double result2    = Convert.ToDouble(geo_y);
                var point         = new ParseGeoPoint(result2, result);
                low ["Post_Geo"]  = point;
                low ["geo_place"] = lbs_name;
            }
            low ["User"]      = ParseUser.CurrentUser.Username;
            low ["Location"]  = city;
            low ["foo"]       = post_type;
            low ["Like"]      = InitialAmount;
            low ["DisLike"]   = InitialAmount;
            low ["Tag1"]      = UserTag_1;
            low ["Tag2"]      = UserTag_2;
            low ["Tag3"]      = UserTag_3;
            low ["Sum"]       = 0;
            string userpost   = userpostLabel.value;
            low ["postfield"] = userpost;
            //
            low.SaveAsync().ContinueWith(task => {
            });

            FindorSave(UserTag_1, 0);
            FindorSave(UserTag_2, 1);
            FindorSave(UserTag_3, 2);
            //cityselect.value = "城市";
            userpostLabel.value = "";
            lbs_name            = "";
            Image picture       = GameObject.Find("CirQle_slide/Canvas/Image").GetComponent <Image>();
            picture.sprite      = null;
            img = null;
            //lbs.value = "確認→";
        });
    }