Example #1
0
    public static JsonDAO Create(Dictionary <string, object> d)
    {
        JsonDAO jdao = new JsonDAO();

        jdao.Dict = d;
        return(jdao);
    }
Example #2
0
 private void MainApp_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (shouldSave)
     {
         JsonDAO.SaveCourses(user);
     }
 }
Example #3
0
    public static JsonDAO Parse(string json)
    {
        // Debug.LogError("PARSE:" +json);
        JsonDAO jdao = new JsonDAO();

        jdao.Dict = MiniJSON.Json.Deserialize(json) as Dictionary <string, object>;
        return(jdao);
    }
Example #4
0
        private void logout_Click(object sender, System.EventArgs e)
        {
            JsonDAO.Delete();
            shouldSave = false;

            Hide();
            SignIn s = new SignIn();

            s.ShowDialog();
            Close();
        }
Example #5
0
    public static BannerData Create(JsonDAO jdao, ListItemModel listItemModel)
    {
        BannerData d = new BannerData(listItemModel);

        d.banner   = String.Format("{0}/{1}", GlobalDefine.GetBaseBannerUrl(), jdao.GetStr("banner"));
        d.priority = jdao.GetInt("priority");
        d.link     = jdao.GetStr("link");

#if BUILD_TYPE_DEBUG
        Debug.Log("CALL BatchData#Create banner:" + d.banner + " priority:" + d.priority);
#endif
        return(d);
    }
Example #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            User user = JsonDAO.Load();

            if (user == null)
            {
                Application.Run(new SignIn());
            }
            else
            {
                browser.SignIn(ref user);
                Application.Run(new MainApp(user));
            }
        }
Example #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            user = new User(unameTextBox.Text, passTextBox.Text);

            if (Program.browser.SignIn(ref user))
            {
                Program.browser.GetCourses(user);
                JsonDAO.SaveUser(user);
                JsonDAO.SaveCourses(user);

                Hide();
                MainApp m = new MainApp(user);
                m.ShowDialog();
                Close();
            }
            else
            {
                MessageBox.Show("Ωχ!", "Λάθος όνομα χρήστη ή κωδικός", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
    public List <JsonDAO> GetJsonDAOList(string key)
    {
        List <JsonDAO> list = new List <JsonDAO>();
        string         str  = GetStr(key);

        if (str.IsNullOrEmpty())
        {
            return(list);
        }

#if BUILD_TYPE_DEBUG
        Debug.Log("KEY:" + key + " STR:" + str);
#endif
        foreach (object obj in MiniJSON.Json.Deserialize(str) as List <object> )
        {
            JsonDAO jdao = JsonDAO.Create(obj);
            list.Add(jdao);
        }

        return(list);
    }
Example #9
0
 public void SetJsonDAO(string key, JsonDAO jdao)
 {
     SetStr(key, jdao.ToJson());
 }
Example #10
0
 public static JsonDAO ToJsonDAO(this string json)
 {
     return(JsonDAO.Create(json));
 }
Example #11
0
    IEnumerator _LoadAndShow(Type _type, System.Action setupFinish)
    {
        string url = null;

        System.Action errorAction = null;

        switch (_type)
        {
        case Type.Title:
            url         = GlobalDefine.GetTapBannerListUrl();
            errorAction = errorBannerTitle;
            break;

        case Type.Menu:
        case Type.Quest:
            url         = GlobalDefine.GetMainMenuBannerListUrl();
            errorAction = errorBannerMenu;
            break;

        default:
            errorAction = errorBannerMenu;
            break;
        }

        if (url == null)
        {
            if (errorAction != null)
            {
                errorAction();
            }

            yield break;
        }

        WWW www = new WWW(url);

        yield return(www);

#if BUILD_TYPE_DEBUG
        Debug.Log("url:" + url);
        Debug.Log("JSON:" + www.text);
#endif


        if (www.error.IsNOTNullOrEmpty())
        {
            if (errorAction != null)
            {
                errorAction();
            }
            yield break;
        }

        if (www.text.IsNullOrEmpty())
        {
            if (errorAction != null)
            {
                errorAction();
            }
            yield break;
        }

        List <BannerData> list    = new List <BannerData>();
        List <object>     objList = MiniJSON.Json.Deserialize(www.text) as List <object>;
        if (objList.Count == 0)
        {
            if (errorAction != null)
            {
                errorAction();
            }
            yield break;
        }

        int count    = 0;
        int objCount = 0;

#if UNITY_IPHONE
        Platform bannerPlatform = Platform.IOS;
#elif UNITY_ANDROID
        Platform bannerPlatform = Platform.ANDROID;
#elif UNITY_WINDOWS
        Platform bannerPlatform = Platform.WINDOWS;
#else
        Platform bannerPlatform = Platform.NONE;
#endif

        object[] banners = objList.ToArray();
        for (int bannercount = 0; bannercount < banners.Length; bannercount++)
        {
            JsonDAO jdao         = JsonDAO.Create(banners[bannercount]);
            var     timing_start = jdao.GetInt("timing_start");
            var     timing_end   = jdao.GetInt("timing_end");
            var     platform     = (Platform)jdao.GetInt("platform", (int)Platform.NONE);
            var     location     = jdao.GetList("location");

            if (platform != bannerPlatform &&
                platform != Platform.ALL)
            {
                continue;
            }

            if (timing_start != 0 &&
                timing_end != 0)
            {
                if (TimeManager.Instance.CheckWithinTime((uint)timing_start, (uint)timing_end) == false)
                {
                    continue;
                }
            }

            bool bCheckScreen = true;
            if (location.Count != 0)
            {
                bCheckScreen = false;
                for (int i = 0; i < location.Count; ++i)
                {
                    switch ((Location)System.Convert.ToInt32(location[i]))
                    {
                    case Location.HOME:
                        if (_type == Type.Menu)
                        {
                            bCheckScreen = true;
                        }
                        break;

                    case Location.QUEST:
                        if (_type == Type.Quest)
                        {
                            bCheckScreen = true;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }

            if (bCheckScreen == false)
            {
                continue;
            }

            var        model = new ListItemModel((uint)objCount);
            BannerData d     = BannerData.Create(jdao, model);
            m_banners.Add(model);
            objCount++;

            d.LoadTexture(() =>
            {
                count++;

                if (d.Texture != null)
                {
                    list.Add(d);
                }
                if (count == objCount)
                {
                    if (list.Count == 0)
                    {
                        if (errorAction != null)
                        {
                            errorAction();
                        }
                    }
                    else
                    {
                        carouselRotator.ResetWaitTimer();

                        list.Sort((a, b) =>
                        {
                            int ret = a.priority - b.priority;
                            return(ret != 0 ? ret : (int)a.model.index - (int)b.model.index);
                        });

                        Collection = list;

                        if (setupFinish != null)
                        {
                            setupFinish();
                        }
                    }
                }
            });
        }
    }