private void NotyfiInNewThread() { try { Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Guid blipFaceGuid = Guid.Empty; using (IsolatedStorageAccess isoAccess = new IsolatedStorageAccess(FileBlipFaceGuid)) { string[] credenctial = isoAccess.ReadAll(); if (credenctial != null && credenctial.Length > 0) { //odczytujemy Guid danej instancji aplikacji BlipFace var stringGuid = credenctial[0].Decrypt().ToInsecureString(); blipFaceGuid = new Guid(stringGuid); } } //gdy nie ma jeszcze ustawionego Guida aplikacji (np. gdy BlipFace jest uruchamiany poraz pierwszy if (blipFaceGuid == Guid.Empty) { blipFaceGuid = Guid.NewGuid(); SecureString secureGuid = blipFaceGuid.ToString().ToSecureString(); using (IsolatedStorageAccess isoAccess = new IsolatedStorageAccess(FileBlipFaceGuid)) { string[] credenctial = new[] {secureGuid.Encrypt()}; isoAccess.WriteStrings(credenctial); } } BlipFaceServicesCommunication communication = new BlipFaceServicesCommunication(); communication.NotifyUseBlipFace(blipFaceGuid, version.ToString()); }catch(Exception ex) { string mes = ex.Message; if(ex.InnerException!=null) { mes += Environment.NewLine + "Inner exp: " + ex.InnerException.Message; } System.Windows.Forms.MessageBox.Show(mes); } }
/// <summary> /// Metoda wywoływana gdy autorycajca zakończy się sukcesem /// </summary> /// <param name="remember"></param> public void SaveCredenctial(bool remember) { SecureString usr = _view.UserName.ToSecureString(); SecureString pas = _view.Password.ToSecureString(); using (IsolatedStorageAccess isoAccess = new IsolatedStorageAccess(FileWithUserPassword)) { if (remember) { string[] credenctial = new[] {usr.Encrypt(), pas.Encrypt()}; isoAccess.WriteStrings(credenctial); #region stara implementacja ////gdzie są przychowywane foldery można przeczytać ////http://msdn.microsoft.com/en-us/library/3ak841sy(VS.80).aspx ////u mnie na viście jest to folder ////C:\Users\ksirg\AppData\Local\VirtualStore\Program Files\BlipFace ////oraz C:\Users\ksirg\AppData\Local\IsolatedStorage\ plus dziwne nazwy folderów //IsolatedStorageFile isoStore = // IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null); ////towrzymy główny folder do przechowywania ////isoStore.CreateDirectory("blipFace"); ////tworzymy plik w którym bedzie przechowywane zaszyfrowane hasło i login //IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(FileWithUserPassword, // FileMode.Create, isoStore); ////zawsze tworzymy i nadpisujemy plik ////w pierwszej lini login a w drugiej hasło //using (StreamWriter sw = new StreamWriter(isoStream)) //{ // //zapisujem login // sw.Write(usr.Encrypt()); // //nowa linia // sw.Write(Environment.NewLine); // //zapisujemy hasło // sw.Write(pas.Encrypt()); // sw.Close(); //} #endregion } else { isoAccess.DeleteFile(); } } }