Пример #1
0
        public void CheckVersion(string version,string token,CheckVersionEndTaskHandler checkVersionEnd)
        {
            string URL = checkVersion;
            WebClient client = new WebClient();

            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 = 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 = String.Format(URL+"&t={1}",webVersion,token);
            }

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

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

                if (e.Cancelled){
                    if(checkVersionEnd!= null) checkVersionEnd(null,"Check version failed.","","");
                    return;
                }

                if (e.Error != null){
                    if(checkVersionEnd!= null) checkVersionEnd(null,"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,"New version is not found.","","");
                    return;
                }

            };
            client.OpenReadAsync(new Uri(URL));
        }
Пример #2
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));
		}
Пример #3
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));
        }
Пример #4
0
        const string getVersion   = "http://moscrif.com/ide/getVersion.ashx?v={0}";       //"http://localhost:1667/ide/getVersion.ashx?v={0}";

        public void CheckVersion(string version, string token, CheckVersionEndTaskHandler checkVersionEnd)
        {
            string    URL    = checkVersion;
            WebClient client = new WebClient();

            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 = 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 = String.Format(URL + "&t={1}", webVersion, token);
            }


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

            client.OpenReadCompleted += delegate(object sender, OpenReadCompletedEventArgs e) {            //UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) {
                if (e.Cancelled)
                {
                    if (checkVersionEnd != null)
                    {
                        checkVersionEnd(null, "Check version failed.", "", "");
                    }
                    return;
                }

                if (e.Error != null)
                {
                    if (checkVersionEnd != null)
                    {
                        checkVersionEnd(null, "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, "New version is not found.", "", "");
                    }
                    return;
                }
            };
            client.OpenReadAsync(new Uri(URL));
        }