public static void SerializeWSToponimias(string username, string password, string timestamp, string filename) { var dipWS = new Controllers.DocInPortoWS(); var diags = dipWS.GetDocumentosEnviadosParaArquivoGeral(DateTime.MinValue, int.MaxValue); //Pre_ToponimiaWS.ToponimiaWS tp = new Pre_ToponimiaWS.ToponimiaWS(); ToponimiaWS tp = new ToponimiaWS(); tp.Credentials = new NetworkCredential(username, password); var moradas = new Dictionary <string, MoradaRecord>(); foreach (var d in diags) { if (d.CODMORADA == null) { continue; } var top = tp.SeleccionaToponimia(d.CODMORADA); moradas[d.CODMORADA] = new MoradaRecord() { CodigoMorada = top.Tables[0].Rows[0]["CODMORADA"].ToString(), Nome = top.Tables[0].Rows[0]["MORADA"].ToString() }; } Stream stream = File.Open(filename, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, moradas.Values.ToArray()); stream.Close(); }
public static void SerializeWSToponimias(string username, string password, string timestamp, string filename) { var dipWS = new Controllers.DocInPortoWS(); var diags = dipWS.GetDocumentosEnviadosParaArquivoGeral(DateTime.MinValue, int.MaxValue); //Pre_ToponimiaWS.ToponimiaWS tp = new Pre_ToponimiaWS.ToponimiaWS(); ToponimiaWS tp = new ToponimiaWS(); tp.Credentials = new NetworkCredential(username, password); var moradas = new Dictionary<string, MoradaRecord>(); foreach (var d in diags) { if (d.CODMORADA == null) continue; var top = tp.SeleccionaToponimia(d.CODMORADA); moradas[d.CODMORADA] = new MoradaRecord() {CodigoMorada = top.Tables[0].Rows[0]["CODMORADA"].ToString(), Nome = top.Tables[0].Rows[0]["MORADA"].ToString()}; } Stream stream = File.Open(filename, FileMode.Create); BinaryFormatter bFormatter = new BinaryFormatter(); bFormatter.Serialize(stream, moradas.Values.ToArray()); stream.Close(); }