Example #1
0
        public void Register(string email, string login, string password, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask)
        {
            string          URL    = redgisterUrl;
            SystemWebClient client = new SystemWebClient();

            string data = String.Format("{0}\n{1}\n{2}", email, login, GetMd5Sum(password + SALT));

            client.UploadStringCompleted += delegate(object sender, UploadStringCompletedEventArgs e) {
                if (e.Cancelled)
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Register failed.");
                    }
                    return;
                }

                if (e.Error != null)
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Register failed.");
                    }
                    return;
                }
                string result = e.Result;

                string token   = "";
                string licence = "";
                ParseResult(result, ref token, ref licence);

                if (String.IsNullOrEmpty(token))
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Register failed.");
                    }
                    return;
                }

                Account ac = CreateAccount(token);

                if (ac != null)
                {
                    ac.Login = login;
                    Licenses lsl = Licenses.LoadLicenses(licence);

                    if (lsl != null && lsl.Items.Count > 0)
                    {
                        ac.LicenseId = lsl.Items[0].Typ;
                    }
                    else
                    {
                        ac.LicenseId = "-100";
                    }

                    if (loggYesTask != null)
                    {
                        loggYesTask(null, ac);
                    }
                }
                else
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Register failed.");
                    }
                    return;
                }

                /*Account ac = CreateAccount(result);
                 * if(ac!= null ){
                 *      ac.Login = login;
                 *      if(loggYesTask!= null) loggYesTask(null,ac);
                 *
                 * } else {
                 *      if(loggNoTask!= null) loggNoTask(null,"Login failed.");
                 *      return;
                 * }*/
            };
            client.UploadStringAsync(new Uri(URL), data);
        }
Example #2
0
        public void Register(string email,string login,string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask)
        {
            string URL = redgisterUrl;
            SystemWebClient client = new SystemWebClient();

            string data = String.Format("{0}\n{1}\n{2}",email,login,GetMd5Sum(password+SALT));
            client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {

                if (e.Cancelled){
                    if(loggNoTask!= null) loggNoTask(null,"Register failed.");
                    return;
                }

                if (e.Error != null){
                    if(loggNoTask!= null) loggNoTask(null,"Register failed.");
                    return;
                }
                string result = e.Result;

                string token = "";
                string licence = "";
                ParseResult(result, ref token,ref licence);

                if(String.IsNullOrEmpty(token)){
                    if(loggNoTask!= null) loggNoTask(null,"Register failed.");
                    return;
                }

                Account ac = CreateAccount(token);

                if( ac!= null ){
                    ac.Login = login ;
                    Licenses lsl = Licenses.LoadLicenses(licence);

                    if(lsl!= null && lsl.Items.Count>0){
                        ac.LicenseId = lsl.Items[0].Typ;
                    }else {
                        ac.LicenseId = "-100";
                    }

                    if(loggYesTask!= null) loggYesTask(null,ac);
                } else {
                    if(loggNoTask!= null) loggNoTask(null,"Register failed.");
                    return;
                }

                /*Account ac = CreateAccount(result);
                if(ac!= null ){
                    ac.Login = login;
                    if(loggYesTask!= null) loggYesTask(null,ac);

                } else {
                    if(loggNoTask!= null) loggNoTask(null,"Login failed.");
                    return;
                }*/

            };
            client.UploadStringAsync(new Uri(URL),data);
        }