예제 #1
0
        public bool GetLicenses()
        {
            string          URL    = licenceUrl;
            SystemWebClient client = new SystemWebClient();

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

                return(false);
            }
            return(true);
        }
예제 #2
0
        private static int GetStatusCode(SystemWebClient client, out string statusDescription)
        {
            FieldInfo responseField = client.GetType().GetField("m_WebRequest", BindingFlags.Instance | BindingFlags.NonPublic);

            if (responseField != null)
            {
                HttpWebResponse response = responseField.GetValue(client) as HttpWebResponse;

                if (response != null)
                {
                    statusDescription = response.StatusDescription;
                    return((int)response.StatusCode);
                }
            }
            statusDescription = null;
            return(0);
        }
예제 #3
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);
        }
예제 #4
0
		/*
		public string VersionConverter(string version){
			
			string[] versions = version.Split('.');
			string versionFile = System.IO.Path.Combine(paths.AppPath,"version.txt");
			string sFix = "";
			
			if(System.IO.File.Exists(versionFile)){
				try {
					using (StreamReader file = new StreamReader(versionFile)) {
						string text = file.ReadToEnd();
						sFix = text.Trim();
					}
				} catch {
				}						
			}
			

			string webVersion = String.Format("{0}q{1}{2}", versions[0], versions[1],sFix);
			return webVersion;			
		}
		*/
		
		public string CheckVersionSynch(string version,string token, out string newVersion){
			newVersion = String.Empty;
			string URL = getVersion;//"http://moscrif.com/ide/checkVersion.ashx?v={0}";
			SystemWebClient client = new SystemWebClient();
			
			string[] versions = version.Split('.');
			if (versions.Length != 4){
				return "Invalid Version.";
			}
			/*
			int iFix = 0;
			
			if(Int32.TryParse(versions[3],out iFix)){
				iFix = 0;
			}
			string sFix = "";
			if(iFix>0){
				sFix = ((char)(0-1+'a')).ToString();
			}*/
						
			string webVersion = MainClass.Tools.VersionConverter(version);//  String.Format("{0}q{1}{2}", versions[0], versions[1],sFix);
			
			if(String.IsNullOrEmpty(token)){
				URL = String.Format(URL,webVersion);
			} else {
				URL =MainClass.Settings.getVersionLog;
				URL = String.Format(URL+"&t={1}",webVersion,token);
			}
			
			URL = String.Format(URL,version,token);
			
			Stream strResult = client.OpenRead(new Uri(URL));

			StreamReader reader = new StreamReader( strResult );
			string result = reader.ReadToEnd();

			if(!String.IsNullOrEmpty(result) ){
				newVersion = result;
				return "New version is found.";
				
			} else {
				return "New version is not found.";
			}
					
		}		
예제 #5
0
파일: LoggUser.cs 프로젝트: moscrif/ide
        public void CheckLogin(string name, string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask)
        {
            string URL = loginUrl;
            SystemWebClient client = new SystemWebClient();

            string data = String.Format("{0}\n{1}",name,GetMd5Sum(password+SALT)); //\n{2}\n{3}",name,GetMd5Sum(password+SALT),Environment.MachineName,Environment.UserName);
            try{
                string result =  client.UploadString(new Uri(URL),data);
                string token = "";
                string licence = "";
                ParseResult(result, ref token,ref licence);

                if(String.IsNullOrEmpty(token)){
                    if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                    return;
                }

                Account ac = CreateAccount(token);

                if( ac!= null ){
                    ac.Login = name ;
                    Licenses lsl = Licenses.LoadLicenses(licence);
                    //ac.Licenses = lsl;
                    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,"Wrong username or password.");
                    return;
                }

            } catch (Exception ex){
                Logger.Error(ex.Message);

                //if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                if(loggNoTask!= null) loggNoTask(null,ex.Message);
                return;
            }
        }
예제 #6
0
        public bool SendFeedback(string xmlData, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask)
        {
            if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token)))
            {
                return(false);
            }
            string token = MainClass.Settings.Account.Token;

            string URL = feedbackUrl;

            SystemWebClient client = new SystemWebClient();

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

            //string data = "";
            try{
                string resp = client.UploadString(new Uri(URL), xmlData);
                Console.WriteLine(resp);
                if (loggYesTask != null)
                {
                    loggYesTask(null, null);
                }
            }catch (Exception ex) {
                string statusDesc = "";
                GetStatusCode(client, out statusDesc);
                Console.WriteLine(ex.Message);
                if (loggNoTask != null)
                {
                    loggNoTask(null, ex.Message);
                }

                return(false);
            }
            return(true);
        }
예제 #7
0
파일: LoggUser.cs 프로젝트: anthrax3/ide-1
        public bool Ping(string token)
        {
            string URL = pingUrl;
            string result;

            SystemWebClient client = new SystemWebClient();

            if (!string.IsNullOrEmpty(token))
            {
                URL = String.Format(URL + "?t={0}", token);
            }
            else
            {
                return(false);
            }
            try{
                result = client.DownloadString(new Uri(URL));

                if (!string.IsNullOrEmpty(result))
                {
                    Licenses lc = Licenses.LoadLicenses(result);
                    //MainClass.User.Licenses = lc;
                    if (lc != null && lc.Items.Count > 0)
                    {
                        MainClass.User.LicenseId = lc.Items[0].Typ;
                    }
                }
            }catch (Exception ex) {
                string statusDesc = "";
                GetStatusCode(client, out statusDesc);
                Console.WriteLine(ex.Message);
                Logger.Error(ex.Message);

                return(false);
            }
            return(true);
        }
예제 #8
0
파일: LoggingInfo.cs 프로젝트: moscrif/ide
        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;
        }
예제 #9
0
        public bool LoggWebString(ActionId action, string str, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask)
        {
            if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token)))
            {
                return(false);
            }
            string token = MainClass.Settings.Account.Token;

            string URL = loggUrl;

            SystemWebClient client = new SystemWebClient();

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

            //Console.WriteLine(URL);

            /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
             *
             *      if (e.Cancelled){
             *              Console.WriteLine("e.Cancelled->"+e.Cancelled);
             *              if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
             *              return;
             *      }
             *      if (e.Error != null){
             *              Console.WriteLine("e.Error->"+e.Error);
             *              if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
             *              return;
             *      }
             *      string result = e.Result;
             *      Console.WriteLine("e.Result->"+e.Result);
             * };*/

            string data = str;

            try{
                string resp = client.UploadString(new Uri(URL), data);
                Console.WriteLine(resp);
                if (loggYesTask != null)
                {
                    loggYesTask(null, null);
                }
            }catch (Exception ex) {
                string statusDesc = "";
                GetStatusCode(client, out statusDesc);
                Console.WriteLine(ex.Message);
                if (loggNoTask != null)
                {
                    loggNoTask(null, ex.Message);
                }

                return(false);
            }
            return(true);
        }
예제 #10
0
파일: LoggUser.cs 프로젝트: moscrif/ide
        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);
        }
예제 #11
0
        public bool GetBannerFromWeb()
        {
            string URL =bannerUrl;
            SystemWebClient client = new SystemWebClient();

            try{
                bannerFile = client.DownloadString(new Uri(URL));

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

                return false;
            }
            return true;
        }
예제 #12
0
        private static int GetStatusCode(SystemWebClient client, out string statusDescription)
        {
            FieldInfo responseField = client.GetType().GetField("m_WebRequest", BindingFlags.Instance | BindingFlags.NonPublic);

            if (responseField != null)
            {
                HttpWebResponse response = responseField.GetValue(client) as HttpWebResponse;

                if (response != null)
                {
                    statusDescription = response.StatusDescription;
                    return (int)response.StatusCode;
                }
            }
            statusDescription = null;
            return 0;
        }
예제 #13
0
파일: LoggUser.cs 프로젝트: anthrax3/ide-1
        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);
        }
예제 #14
0
파일: SignApp.cs 프로젝트: moscrif/ide
        public bool PostFile(string appFile,string token, out string signFile)
        {
            //string email,string login,string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask){

            string URL = signUrl;//"http://moscrif.com/ide/signApp.ashx?t={0}&a={1}";

            if( !string.IsNullOrEmpty(token)){
                    string app = System.IO.Path.GetFileNameWithoutExtension(appFile);
                    if (app.ToLower().EndsWith(".app"))
                        app = app.Substring(0, app.Length - 4);
                    URL = String.Format(URL,token,app);
                //URL = String.Format(URL+"?t={0}&a=" + "unsigned.app-hash",token);
            }else {
                signFile = "ERROR TOKEN";
                return false;
            }
            //Console.WriteLine("URL -> {0}", URL);

            SystemWebClient client = new SystemWebClient();

            string data ="";

            using (StreamReader file = new StreamReader(appFile)) {
                data = file.ReadToEnd();
                file.Close();
                file.Dispose();
            }
                //Console.WriteLine("data -> {0}", data);

            /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
                //Console.WriteLine(1);

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

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

                string result = e.Result;
                //Console.WriteLine(result);
                Account ac = CreateAccount(result);
                if(ac!= null ){
                    ac.Login = login;
                    if(loggYesTask!= null) loggYesTask(null,ac);

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

            };*/
            //client.UploadStringAsync(new Uri(URL),data);
            signFile =  client.UploadString(new Uri(URL),data);//(new Uri(URL),data);

            if(signFile.StartsWith("Error")){
                return false;
            }

            //byte[] respons = client.UploadFile(new Uri(URL),appFile);//UploadString(new Uri(URL),data);

            //Console.WriteLine("Respons is -> {0}",respons);
            return true;
        }
예제 #15
0
		string getVersion =MainClass.Settings.getVersion ;// "http://moscrif.com/ide/getVersion.ashx?v={0}";


		public void CheckVersion(string version,string token,CheckVersionEndTaskHandler checkVersionEnd,bool test){
			string URL = checkVersion;//"http://moscrif.com/ide/checkVersion.ashx?v={0}";
			SystemWebClient client = new SystemWebClient();
			
			string[] versions = version.Split('.');
			if (versions.Length != 4){
				if(checkVersionEnd!= null) checkVersionEnd(null,"Invalid Version.","","");
				return;
			}
			/*int iFix = 0;
			
			if(Int32.TryParse(versions[3],out iFix)){
				iFix = 0;
			}
			string sFix = "";
			if(iFix>0){
				sFix = ((char)(0-1+'a')).ToString();
			}*/
						
			string webVersion = MainClass.Tools.VersionConverter(version);//String.Format("{0}q{1}{2}", versions[0], versions[1],sFix);
			//Console.WriteLine("webVersion " + webVersion);
			
			if(String.IsNullOrEmpty(token)){
				URL = String.Format(URL,webVersion);
			} else {
				URL = MainClass.Settings.checkVersionLog;
				URL = String.Format(URL+"&t={1}",webVersion,token);
			}
			if(test){
				URL = URL+"&test=1";
			}

			//client.Do

			URL = String.Format(URL,version,token);
			
			client.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {//UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
							
				if (e.Cancelled){
					Logger.Error("Error check version Cancelled: {0}",e.Cancelled);
					if(checkVersionEnd!= null){
						checkVersionEnd(null,MainClass.Languages.Translate("check_version_failed"),"","");
					}
					return;
				}

				if (e.Error != null){
					Logger.Error("Error check version : {0}",e.Error.Message);
					if(checkVersionEnd!= null){
						checkVersionEnd(null,MainClass.Languages.Translate("check_version_failed"),"",e.Error.Message);
					}
					return;
				}


				StreamReader reader = new StreamReader( e.Result );
				string result = reader.ReadToEnd();

				if(!String.IsNullOrEmpty(result) ){
					if(checkVersionEnd!= null) checkVersionEnd(null,"New version is found.",result,"");

				} else {
					if(checkVersionEnd!= null) checkVersionEnd(null,MainClass.Languages.Translate("new_version_not_found"),"","");
					return;
				}

			};
			client.OpenReadAsync(new Uri(URL));
		}
예제 #16
0
        public void CheckVersion(string version,string token,CheckVersionEndTaskHandler checkVersionEnd,bool test)
        {
            string URL = checkVersion;//"http://moscrif.com/ide/checkVersion.ashx?v={0}";
            SystemWebClient client = new SystemWebClient();

            string[] versions = version.Split('.');
            if (versions.Length != 4){
                if(checkVersionEnd!= null) checkVersionEnd(null,"Invalid Version.","","");
                return;
            }
            /*int iFix = 0;

            if(Int32.TryParse(versions[3],out iFix)){
                iFix = 0;
            }
            string sFix = "";
            if(iFix>0){
                sFix = ((char)(0-1+'a')).ToString();
            }*/

            string webVersion = MainClass.Tools.VersionConverter(version);//String.Format("{0}q{1}{2}", versions[0], versions[1],sFix);
            //Console.WriteLine("webVersion " + webVersion);

            if(String.IsNullOrEmpty(token)){
                URL = String.Format(URL,webVersion);
            } else {
                URL = MainClass.Settings.checkVersionLog;
                URL = String.Format(URL+"&t={1}",webVersion,token);
            }
            if(test){
                URL = URL+"&test=1";
            }

            //client.Do

            URL = String.Format(URL,version,token);

            client.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {//UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {

                if (e.Cancelled){
                    Logger.Error("Error check version Cancelled: {0}",e.Cancelled);
                    if(checkVersionEnd!= null){
                        checkVersionEnd(null,MainClass.Languages.Translate("check_version_failed"),"","");
                    }
                    return;
                }

                if (e.Error != null){
                    Logger.Error("Error check version : {0}",e.Error.Message);
                    if(checkVersionEnd!= null){
                        checkVersionEnd(null,MainClass.Languages.Translate("check_version_failed"),"",e.Error.Message);
                    }
                    return;
                }

                StreamReader reader = new StreamReader( e.Result );
                string result = reader.ReadToEnd();

                if(!String.IsNullOrEmpty(result) ){
                    if(checkVersionEnd!= null) checkVersionEnd(null,"New version is found.",result,"");

                } else {
                    if(checkVersionEnd!= null) checkVersionEnd(null,MainClass.Languages.Translate("new_version_not_found"),"","");
                    return;
                }

            };
            client.OpenReadAsync(new Uri(URL));
        }
예제 #17
0
        /*
        public string VersionConverter(string version){

            string[] versions = version.Split('.');
            string versionFile = System.IO.Path.Combine(paths.AppPath,"version.txt");
            string sFix = "";

            if(System.IO.File.Exists(versionFile)){
                try {
                    using (StreamReader file = new StreamReader(versionFile)) {
                        string text = file.ReadToEnd();
                        sFix = text.Trim();
                    }
                } catch {
                }
            }

            string webVersion = String.Format("{0}q{1}{2}", versions[0], versions[1],sFix);
            return webVersion;
        }
        */
        public string CheckVersionSynch(string version,string token, out string newVersion)
        {
            newVersion = String.Empty;
            string URL = getVersion;//"http://moscrif.com/ide/checkVersion.ashx?v={0}";
            SystemWebClient client = new SystemWebClient();

            string[] versions = version.Split('.');
            if (versions.Length != 4){
                return "Invalid Version.";
            }
            /*
            int iFix = 0;

            if(Int32.TryParse(versions[3],out iFix)){
                iFix = 0;
            }
            string sFix = "";
            if(iFix>0){
                sFix = ((char)(0-1+'a')).ToString();
            }*/

            string webVersion = MainClass.Tools.VersionConverter(version);//  String.Format("{0}q{1}{2}", versions[0], versions[1],sFix);

            if(String.IsNullOrEmpty(token)){
                URL = String.Format(URL,webVersion);
            } else {
                URL =MainClass.Settings.getVersionLog;
                URL = String.Format(URL+"&t={1}",webVersion,token);
            }

            URL = String.Format(URL,version,token);

            Stream strResult = client.OpenRead(new Uri(URL));

            StreamReader reader = new StreamReader( strResult );
            string result = reader.ReadToEnd();

            if(!String.IsNullOrEmpty(result) ){
                newVersion = result;
                return "New version is found.";

            } else {
                return "New version is not found.";
            }
        }
예제 #18
0
파일: LoggingInfo.cs 프로젝트: moscrif/ide
        public bool SendFeedback(string xmlData,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask)
        {
            if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){
                return false;
            }
            string token =MainClass.Settings.Account.Token;

            string URL =feedbackUrl;

            SystemWebClient client = new SystemWebClient();

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

            //string data = "";
            try{

                string resp = client.UploadString(new Uri(URL),xmlData);
                Console.WriteLine(resp);
                if(loggYesTask!= null) loggYesTask(null,null);

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

                return false;
            }
            return true;
        }
예제 #19
0
파일: LoggingInfo.cs 프로젝트: moscrif/ide
        public bool LoggWebString(ActionId action,string str,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask)
        {
            if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){
                return false;
            }
            string token =MainClass.Settings.Account.Token;

            string URL =loggUrl;

            SystemWebClient client = new SystemWebClient();

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

            //Console.WriteLine(URL);

            /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {

                if (e.Cancelled){
                    Console.WriteLine("e.Cancelled->"+e.Cancelled);
                    if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                    return;
                }
                if (e.Error != null){
                    Console.WriteLine("e.Error->"+e.Error);
                    if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                    return;
                }
                string result = e.Result;
                Console.WriteLine("e.Result->"+e.Result);
            };*/

            string data = str;
            try{
                string resp = client.UploadString(new Uri(URL),data);
                Console.WriteLine(resp);
                if(loggYesTask!= null) loggYesTask(null,null);

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

                return false;
            }
            return true;
        }
예제 #20
0
파일: LoggUser.cs 프로젝트: moscrif/ide
        public bool Ping(string token)
        {
            string URL =pingUrl;
            string result;

            SystemWebClient client = new SystemWebClient();

            if( !string.IsNullOrEmpty(token))
                URL = String.Format(URL+"?t={0}",token);
            else {
                return false;
            }
            try{
                result = client.DownloadString(new Uri(URL));

                if(!string.IsNullOrEmpty(result)){
                    Licenses lc = Licenses.LoadLicenses(result);
                    //MainClass.User.Licenses = lc;
                    if(lc!= null && lc.Items.Count>0){
                        MainClass.User.LicenseId = lc.Items[0].Typ;
                    }
                }

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

                return false;
            }
            return true;
        }
예제 #21
0
파일: SignApp.cs 프로젝트: anthrax3/ide-1
        public bool PostFile(string appFile, string token, out string signFile) //string email,string login,string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask){
        {
            string URL = signUrl;                                               //"http://moscrif.com/ide/signApp.ashx?t={0}&a={1}";

            if (!string.IsNullOrEmpty(token))
            {
                string app = System.IO.Path.GetFileNameWithoutExtension(appFile);
                if (app.ToLower().EndsWith(".app"))
                {
                    app = app.Substring(0, app.Length - 4);
                }
                URL = String.Format(URL, token, app);
                //URL = String.Format(URL+"?t={0}&a=" + "unsigned.app-hash",token);
            }
            else
            {
                signFile = "ERROR TOKEN";
                return(false);
            }
            //Console.WriteLine("URL -> {0}", URL);

            SystemWebClient client = new SystemWebClient();

            string data = "";

            using (StreamReader file = new StreamReader(appFile)) {
                data = file.ReadToEnd();
                file.Close();
                file.Dispose();
            }
            //Console.WriteLine("data -> {0}", data);

            /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
             *      //Console.WriteLine(1);
             *
             *      if (e.Cancelled){
             *              if(loggNoTask!= null) loggNoTask(null,"Register to failed.");
             *              return;
             *      }
             *
             *      if (e.Error != null){
             *              if(loggNoTask!= null) loggNoTask(null,"Register to failed.");
             *              return;
             *      }
             *
             *      string result = e.Result;
             *      //Console.WriteLine(result);
             *      Account ac = CreateAccount(result);
             *      if(ac!= null ){
             *              ac.Login = login;
             *              if(loggYesTask!= null) loggYesTask(null,ac);
             *
             *      } else {
             *              if(loggNoTask!= null) loggNoTask(null,"Login to failed.");
             *              return;
             *      }
             *
             * };*/
            //client.UploadStringAsync(new Uri(URL),data);
            signFile = client.UploadString(new Uri(URL), data);            //(new Uri(URL),data);

            if (signFile.StartsWith("Error"))
            {
                return(false);
            }

            //byte[] respons = client.UploadFile(new Uri(URL),appFile);//UploadString(new Uri(URL),data);

            //Console.WriteLine("Respons is -> {0}",respons);
            return(true);
        }
예제 #22
0
파일: LoggUser.cs 프로젝트: anthrax3/ide-1
        public void CheckLogin(string name, string password, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask)
        {
            string          URL    = loginUrl;
            SystemWebClient client = new SystemWebClient();

            string data = String.Format("{0}\n{1}", name, GetMd5Sum(password + SALT));         //\n{2}\n{3}",name,GetMd5Sum(password+SALT),Environment.MachineName,Environment.UserName);

            try{
                string result  = client.UploadString(new Uri(URL), data);
                string token   = "";
                string licence = "";
                ParseResult(result, ref token, ref licence);

                if (String.IsNullOrEmpty(token))
                {
                    if (loggNoTask != null)
                    {
                        loggNoTask(null, "Wrong username or password.");
                    }
                    return;
                }

                Account ac = CreateAccount(token);

                if (ac != null)
                {
                    ac.Login = name;
                    Licenses lsl = Licenses.LoadLicenses(licence);
                    //ac.Licenses = lsl;
                    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, "Wrong username or password.");
                    }
                    return;
                }
            } catch (Exception ex) {
                Logger.Error(ex.Message);

                //if(loggNoTask!= null) loggNoTask(null,"Wrong username or password.");
                if (loggNoTask != null)
                {
                    loggNoTask(null, ex.Message);
                }
                return;
            }
        }