Example #1
0
        public bool LoggWeb(string token, ActionId action, string data, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask)
        {
            string URL = loggUrl;

            SystemWebClient client = new SystemWebClient();

            if (!string.IsNullOrEmpty(token))
            {
                URL = String.Format(URL + "?token={0}&action={1}&data={2}", token, (int)action, data);
            }
            else
            {
                return(false);
            }
            //Console.WriteLine(URL);

            client.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e) {
                if (e.Cancelled)
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Wrong username or password.");
                    }
                    return;
                }
                if (e.Error != null)
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Wrong username or password.");
                    }
                    return;
                }
            };

            try{
                client.DownloadStringAsync(new Uri(URL));
            }catch (Exception ex) {
                string statusDesc = "";
                GetStatusCode(client, out statusDesc);
                Console.WriteLine(ex.Message);

                return(false);
            }
            return(true);
        }
Example #2
0
        public bool LoggWeb(string token,ActionId action,string data,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask)
        {
            string URL =loggUrl;

            SystemWebClient client = new SystemWebClient();

            if( !string.IsNullOrEmpty(token))
                URL = String.Format(URL+"?token={0}&action={1}&data={2}",token,(int)action,data);
            else {
                return false;
            }
            //Console.WriteLine(URL);

            client.DownloadStringCompleted+= delegate(object sender, DownloadStringCompletedEventArgs e) {

                if (e.Cancelled){
                    if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                    return ;
                }
                if (e.Error != null){
                    if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                    return ;
                }
            };

            try{
                client.DownloadStringAsync(new Uri(URL));

            }catch(Exception ex){
                string statusDesc = "";
                GetStatusCode(client,out statusDesc);
                Console.WriteLine(ex.Message);

                return false;
            }
            return true;
        }