2013-01-04 60 views
-1

我做了一個將用戶添加到存儲中的方法。下面是我得到的代碼和錯誤。嘗試保存在Windows Azure中時出錯表

public string addusr(string nome, string cidade, string cpf, string email, string telefone) 
    { 
     try 
     { 
      if (nome.Length == 0) 
       return "f:Preencha o campo nome."; 

      if (cidade.Length == 0) 
       return "f:Preencha o campo cidade."; 

      if (cpf.Length == 0) 
       return "f:Preencha o campo cpf."; 

      if (!Valida(cpf)) 
       return "f:CPF Invalido."; 

      if (email.Length == 0) 
       return "f:Preencha o campo email."; 

      Regex rg = new Regex(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$"); 
      if (!rg.IsMatch(email)) 
      { 
       return "f:Email Invalido"; 
      } 

      List<UserEntity> lst = new List<UserEntity>(); 
      var _account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn")); 
      var _context = new CRUDUserEntities(_account.TableEndpoint.ToString(), _account.Credentials); 
      if (_context.Select(cpf).Count() > 0) 
       return "dup"; 

      var account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("Conn")); 
      var context = new CRUDUserEntities(account.TableEndpoint.ToString(), account.Credentials); 
      UserClientEntity entity = new UserClientEntity() { nome = nome, cidade = cidade, cpf = cpf, email = email, telefone = telefone }; 
      context.ADDUSociate(entity); 
      return "k"; 
     } 
     catch (Exception exc) 
     { 
      string error = "f:" + exc.Message + "|" + exc.StackTrace; 
      // Trace.WriteLine("Erro no login: " + error , "Information"); 
      return error; 
     } 
    } 

當我嘗試添加用戶...我收到此錯誤:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"> 
     f:An error occurred while processing this request.| at   Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result() 
     at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait() 
     at Microsoft.WindowsAzure.StorageClient.CommonUtils.  <LazyEnumerateSegmented>d__0`1.MoveNext() 
     at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source) 
     at mobile.Service1.addusr(String nome, String cidade, String cpf, String email, String telefone) 
    </string> 

我不知道什麼是錯的..

+0

它在模擬器上工作嗎? –

+0

我沒有在模擬器中跑...在這裏模擬器不起作用。當我嘗試模擬「系統缺少執行服務的先決條件,請參閱輸出窗口以獲取更多信息」時,我收到此錯誤。 – Ladessa

+0

我建議你先讓模擬器工作在天藍色的存儲器上,然後在visual studio中進行調試。 –

回答

0

不知道什麼造成錯誤,但你錯過之後context.SaveChanges();

context.ADDUSociate(entity); 

「我建議你ST讓模擬器在天藍色存儲中工作並在Visual Studio中進行調試。「 我想你沒有安裝正確的Azure sdk。嘗試重新安裝它,模擬器應該工作。您可以按照本指南進行操作:http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/

+0

它不起作用 – Ladessa

相關問題