List <KeyValuePair <string, string> > EmparentarComites; //Comite , Comite padre. #endregion PROPIEDADES #region METODOS public Dictionary <string, Guid> Iniciar(Oracle ora, Comun com, Crm crm) { try { OracleGlobal = ora; ComunGlobal = com; CrmGlobal = crm; //1. Leer Comités de Oracle y CRM //Inicializa PFECore CrmGlobal.InicializarPFE(OracleGlobal); LeerComitesFromCRM(); LeerComitesFromOracle(); //2. Cargar Comités sin comité padre (son comités padres) | //3. Cargar Resto de comités | Cargar todos y emparentar despues if (ComitesOracle.Any()) { ComunGlobal.LogText("---- Iniciando sincronización COMITES ------"); ComunGlobal.LogText("**** Registros a cotejar: " + ComitesOracle.Count); #region PROCESA COMITES bool ok; ComiteTecnico auxContCRM = new ComiteTecnico(); Entity comiteUpdate; foreach (var cmt in ComitesOracle) { ok = ComitesCRM.TryGetValue(cmt.Value.Aen_Codigo_Comite, out auxContCRM); try { if (ok) // Existe, actualizamos { comiteUpdate = new Entity(NombresCamposComiteTecnico.EntityName); bool res = cmt.Value.ComitesIguales(auxContCRM, ref comiteUpdate); if (res) { //Emparentar en update (por si el padre del comité se crea en este bloque también) //if (!cmt.Value.Aen_Codigo_PadreSTR.Equals(string.Empty) && cmt.Value.Aen_Codigo_Padre.Equals(Guid.Empty)) // EmparentarComites.Add(new KeyValuePair<string, string>(cmt.Value.Aen_Codigo_Comite, cmt.Value.Aen_Codigo_PadreSTR)); CrmGlobal.AnadirElementoEmr(new UpdateRequest { Target = comiteUpdate }); } else { CrmGlobal.Iguales++; } } else //No existe, creamos { Entity newCom = cmt.Value.GetEntity(); //Emparentar post-creación if (!cmt.Value.Aen_Codigo_PadreSTR.Equals(string.Empty) && cmt.Value.Aen_Codigo_Padre.Equals(Guid.Empty)) { EmparentarComites.Add(new KeyValuePair <string, string>(cmt.Value.Aen_Codigo_Comite, cmt.Value.Aen_Codigo_PadreSTR)); } CrmGlobal.AnadirElementoEmr(new CreateRequest { Target = newCom }); } } catch (Exception e) { ComunGlobal.LogText("ERROR con el comité " + cmt.Value.Aen_Codigo_Comite + " ::: " + e.ToString()); } } CrmGlobal.ProcesarUltimosEmr(); #endregion PROCESA COMITES CrmGlobal.MostrarEstadisticas("COMITES"); ComunGlobal.LogText("---- FIN sincronización COMITES ------"); } else { ComunGlobal.LogText("No hay Comités Técnicos en origen, terminamos"); } //4. Indexar Comités <códigoComite, Guid> CargaDiccionarioGuidsComites(); //5. Emparentar Comités EmparentacionDeComites(); LimpiezaDiccionarios(); return(MaestroComitesCRM); } catch (Exception e) { ComunGlobal.LogText("ERROR en Lanzador de COMITES ::: " + e.ToString()); if (OracleGlobal != null && OracleGlobal.OraConnParaLog.State == ConnectionState.Open) { OracleGlobal.OraConnParaLog.Dispose(); } return(null); } }
private void LimpiezaDiccionarios() { ComitesOracle.Clear(); ComitesCRM.Clear(); EmparentarComites.Clear(); }