Exemple #1
0
        public void GetLiveStreamUrlAsyn(StreamingItem streaming)
        {
            streamingData = streaming;
            loginData = null;

            WebClient WebClient_GetUnixTime = new WebClient();
            WebClient_GetUnixTime.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WebClient_GetUnixTime_DownloadStringCompleted);
            WebClient_GetUnixTime.DownloadStringAsync(new Uri(URL_GET_UNIX_TIME, UriKind.Absolute));
        }
Exemple #2
0
 private void LoadLoginData()
 {
     if (IsolatedStorageSettings.ApplicationSettings.Contains("LoginData"))
     {
         LoginData = (LoginItem)IsolatedStorageSettings.ApplicationSettings["LoginData"];
     }
     else
     {
         LoginData = new LoginItem();
     }
 }
Exemple #3
0
 //Logout
 public void Logout()
 {
     LoginData = null;
     SaveLoginData();
 }
Exemple #4
0
        //Event
        void WebClient_LoginEmail_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            TruelifeEventArgs eventArg = new TruelifeEventArgs();
            eventArg.Code = 0;
            eventArg.Description = "error";
            try
            {
                if (e.Error != null)
                {
                    throw new Exception(e.Error.Message);
                }
                //----------
                XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
                if (xdoc.Root == null)
                {
                    throw new Exception("Root is null");
                }

                if (xdoc.Root.Element("header") == null)
                {
                    throw new Exception("header is null");
                }

                if (xdoc.Root.Element("header").Element("code") == null)
                {
                    throw new Exception("header/code is null");
                }

                if (xdoc.Root.Element("header").Element("description") == null)
                {
                    throw new Exception("header/description is null");
                }
                //----------
                var code = xdoc.Root.Element("header").Element("code");
                eventArg.Code = XmlValueParser.ParseInteger(code);

                var desc = xdoc.Root.Element("header").Element("description");
                eventArg.Description = XmlValueParser.ParseString(desc);

                if (eventArg.Code != 200)
                {
                    eventArg.ErrorMessageForUser = eventArg.Description;
                    eventArg.ErrorMessageForDeveloper = eventArg.Description;
                        eventArg.IsError = true;
                }
                else
                {
                    if (xdoc.Root.Element("profile") == null)
                    {
                        throw new Exception("profile is null");
                    }
                    
                    //----------
                    LoginItem tmp_item = new LoginItem();
                    
                    //parse
                    //tmp_item.blog_id = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("blog_id"));
                    tmp_item.sso_access_token = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("sso_access_token"));
                    tmp_item.sso_expires = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("sso_expires"));
                    //tmp_item.username = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("username"));
                    //tmp_item.password = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("password"));
                    tmp_item.email = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("email"));
                    tmp_item.name = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("name"));
                    tmp_item.birthday = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("birthday"));
                    tmp_item.gender = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("gender"));
                    tmp_item.role_id = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("role_id"));
                    tmp_item.employee_id = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("employee_id"));
                    tmp_item.sso_uid = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("sso_uid"));
                    tmp_item.verify_status = XmlValueParser.ParseString(xdoc.Root.Element("profile").Element("verify_status"));
                    
                    //----------
                    LoginData = tmp_item;
                    
                    LoginData.username = username;
                    //LoginData.password = password;
                    LoginData.password = "";//not need to save password
                    
                    eventArg.IsError = false;
                    SaveLoginData();
                }
            }
            catch (Exception ex)
            {
                eventArg.ErrorMessageForUser = "******";
                eventArg.ErrorMessageForDeveloper = "Error : Truelife - LoginWithEmail ; " + ex.Message;
                eventArg.IsError = true;
            }
            //-----
            //LoginWithEmailCompleted(eventArg);
            LoginAllCompleted(eventArg);
        }