List <KeyValuePair <string, string> > EmparentarICS; //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 ICS de Oracle y CRM //Inicializa PFECore CrmGlobal.InicializarPFE(OracleGlobal); LeerICSFromCRM(); LeerICSFromOracle(); //2. Cargar iCS sin ics padre (son ICS padres) | //3. Cargar Resto de ICSs | Cargar todos y emparentar despues if (ICSOracle.Any()) { ComunGlobal.LogText("---- Iniciando sincronización ICS ------"); ComunGlobal.LogText("**** Registros a cotejar: " + ICSOracle.Count); #region PROCESA ICS bool ok; ICS auxICSCRM = new ICS(); Entity icsUpdate; foreach (var ics in ICSOracle) { ok = ICSCRM.TryGetValue(ics.Value.Aen_Codigo_Ics, out auxICSCRM); try { if (ok) // Existe, actualizamos { icsUpdate = new Entity(NombresCamposICS.EntityName); bool res = ics.Value.ICSIguales(auxICSCRM, ref icsUpdate); if (res) { //Emparentar en update (por si el padre del ICS se crea en este bloque también) //if (!ics.Value.Aen_Codigo_Ics_PadreSTR.Equals(string.Empty) && ics.Value.Aen_Codigo_Ics_Padre.Equals(Guid.Empty)) // EmparentarICS.Add(new KeyValuePair<string, string>(ics.Value.Aen_Codigo_Ics, ics.Value.Aen_Codigo_Ics_PadreSTR)); CrmGlobal.AnadirElementoEmr(new UpdateRequest { Target = icsUpdate }); } else { CrmGlobal.Iguales++; } } else //No existe, creamos { Entity newI = ics.Value.GetEntity(); //Emparentar post-creación if (!ics.Value.Aen_Codigo_Ics_PadreSTR.Equals(string.Empty) && ics.Value.Aen_Codigo_Ics_Padre.Equals(Guid.Empty)) { EmparentarICS.Add(new KeyValuePair <string, string>(ics.Value.Aen_Codigo_Ics, ics.Value.Aen_Codigo_Ics_PadreSTR)); } CrmGlobal.AnadirElementoEmr(new CreateRequest { Target = newI }); } } catch (Exception e) { ComunGlobal.LogText("ERROR con el ICS " + ics.Value.Aen_Codigo_Ics + " ::: " + e.ToString()); } } CrmGlobal.ProcesarUltimosEmr(); #endregion PROCESA ICS CrmGlobal.MostrarEstadisticas("ICS"); ComunGlobal.LogText("---- FIN sincronización ICS ------"); } else { ComunGlobal.LogText("No hay ICS en origen, terminamos"); } //4. Indexar Comités <códigoComite, Guid> CargaDiccionarioGuidsICS(); //5. Emparentar Comités EmparentacionDeICS(); LimpiezaDiccionarios(); return(MaestroICSCRM); } catch (Exception e) { ComunGlobal.LogText("ERROR en Lanzador de ICS ::: " + e.ToString()); if (OracleGlobal != null && OracleGlobal.OraConnParaLog.State == ConnectionState.Open) { OracleGlobal.OraConnParaLog.Dispose(); } return(null); } }
public void LimpiezaDiccionarios() { ICSOracle.Clear(); ICSCRM.Clear(); EmparentarICS.Clear(); }