Example #1
0
        public bool ActualizaDocumento(string User, string Password, int DocId, string No_Caso, string Institucion, string Fecha, string No_Correspondencia, string Remitente, string Destinatario, string tab, string Archivo, string OriginalName, string OriginalExtension, bool Imagen)
        {
            Interfaces.Collection Documento;
            int  idcejilla = 1;
            int  session   = 0;
            Ewsm ePower    = null;
            int  RefSize   = 0;
            int  lastRef   = 0;

            try
            {
                log = new Bitacorizador();
                log.LogInfo("UpdateDocument con los siguientes parámetros:");
                //Cargado de los parametros del config.
                //string epUser = Properties.Settings.Default.epowerUser;
                //string epPass = Properties.Settings.Default.epowerPassword;
                int appId   = Properties.Settings.Default.appId;
                int doctype = Properties.Settings.Default.doctype;
                int query   = Properties.Settings.Default.query;
                log.LogInfo("Usuario: " + User + "appId: " + appId + " Doctype: " + doctype + " Query: " + query);
                log.LogInfo("Con los siguientes Indices: ");
                log.LogInfo("DocId: " + DocId);
                BitacorizaIndices(log, No_Caso, Institucion, Fecha, No_Correspondencia, Remitente, Destinatario);
                log.LogInfo("Con el siguiente Contenido: ");
                log.LogInfo("Nombre Archivo: " + OriginalName);
                log.LogInfo("Extension: " + OriginalExtension);
                ePower = new Ewsm();
                log.LogInfo("Inicia Login hacia ePower");
                try
                {
                    session = ePower.doLogin(User, Password, "eAccess");
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al autenticarse con ePower: Imposible autenticarse con ePower, verifique sus credenciales y conexión a ePower. " + ex.Message);
                }
                log.LogInfo("Se inicia la actualización del documento, Recuperando documento");
                Documento = ePower.getFullDocument(session, appId, doctype, query, DocId);
                //Actualiza Indices
                //Rellena los indices del documento
                Documento.Fields[0].ValorDec    = int.Parse(No_Caso);
                Documento.Fields[1].ValorString = Institucion;
                Documento.Fields[2].ValorString = Fecha;
                Documento.Fields[3].ValorString = No_Correspondencia;
                Documento.Fields[4].ValorString = Remitente;
                Documento.Fields[5].ValorString = Destinatario;

                //localizacion de la cejilla
                if (Imagen)
                {
                    if (tab == "Correspondencia Recibida")
                    {
                        idcejilla = 4;
                    }
                    else if (tab == "Correspondencia Enviada")
                    {
                        idcejilla = 5;
                    }
                    else
                    {
                        idcejilla = 1;//Cejilla de imagenes
                    }
                }
                else
                {
                    idcejilla = 3;//Cejilla de Otros Documentos
                }
                /***Referencias a imagenes u otros documentos***/
                log.LogInfo("Actualizando Referencias ");
                RefSize = Documento.References.Length + 1;
                lastRef = Documento.References.Length;
                Comun.gsiStructRef[] referencias = new Comun.gsiStructRef[RefSize];
                for (int i = 0; i < Documento.References.Length; i++)
                {
                    referencias[i] = Documento.References[i];
                }
                gsiFile gsifile = new gsiFile();
                gsifile.extension = OriginalExtension;
                gsifile.Document  = System.Convert.FromBase64String(Archivo);
                Comun.gsiStructRef rf = Bridge.getInstance().saveRef(session, appId, gsifile);
                referencias[lastRef] = rf;
                referencias[lastRef].DisplayAlias      = OriginalName;
                referencias[lastRef].OriginalExtension = OriginalExtension;
                referencias[lastRef].ParentId          = idcejilla;
                log.LogInfo("Actualizando Documento");
                ePower.updateFullDocument(session, appId, doctype, query, Documento.DocId, Documento.Tabs, Documento.Fields, referencias, null, null);
                return(true);
            }
            catch (Exception ex)
            {
                log = new Bitacorizador();
                log.LogError("Error al ejecutar el método: UpdateDocument, Detalles " + "Mensaje: " + ex.Message + " StackTrace: " + ex.StackTrace);
                throw new Exception("Error al ejecutar el método: UpdateDocument, Detalles " + "Mensaje: " + ex.Message + " StackTrace: " + ex.StackTrace);
            }
            finally
            {
                ePower.doLogout(session);
            }
        }
Example #2
0
        public ResultadoAccion insertaDocumento(string User, string Password, int appId, int doctypeId, int queryId, Datos[] data, Contenido[] content)
        {
            ResultadoAccion resultado = new ResultadoAccion();

            resultado.Resultado = true;
            resultado.Mensaje   = "";

            Interfaces.Collection Documento;


            int  idcejilla = 1;
            int  session   = 0;
            Ewsm ePower    = null;

            try
            {
                log = new Bitacorizador();
                log.LogInfo("InsertDocument con los siguientes parámetros:");

                log.LogInfo("Con los siguientes Indices: ");

                ePower = new Ewsm();
                log.LogInfo("Inicia Login hacia ePower");
                try
                {
                    session = ePower.doLogin(User, Password, "eAccess");
                }
                catch (Exception ex)
                {
                    resultado.Resultado = false;
                    resultado.Mensaje   = "Error al autenticarse con ePower: Imposible autenticarse con ePower, verifique sus credenciales y conexión a ePower. " + ex.Message;
                }
                log.LogInfo("Se inicia la creación de un documento");
                Documento = ePower.getNewDocument(session, appId, doctypeId, queryId);
                if (!Documento.Equals(null))
                {
                    //Rellena los indices del documento
                    for (int i = 0; i < data.Length; i++)
                    {
                        if (Documento.Fields[i].Type == 1)
                        {
                            Documento.Fields[i].ValorString = data[i].ValorString.ToString();
                        }
                        else if (Documento.Fields[i].Type == 2)
                        {
                            Documento.Fields[i].ValorDec = double.Parse(data[i].ValorString.ToString());
                        }
                    }

                    //Cejillas

                    Comun.gsiStructTab[] tabsTemplete;
                    tabsTemplete = ePower.getTabTempleteStruct(session, appId, doctypeId);
                    Comun.gsiStructTab[] tabs = new Comun.gsiStructTab[tabsTemplete.Length + 2];

                    int tabId = 0;
                    int k     = 0;
                    for (int i = 0; i < tabsTemplete.Length; i++)
                    {
                        tabs[i]               = new Comun.gsiStructTab();
                        tabs[i].TabName       = tabsTemplete[i].TabName;
                        tabs[i].TabParentId   = tabsTemplete[i].TabParentId;
                        tabs[i].TabId         = tabsTemplete[i].TabId;
                        tabs[i].PreviousTabId = tabsTemplete[i].PreviousTabId;
                        tabId = tabsTemplete[i].TabId;
                        k     = i;
                    }

                    tabs[k + 1]               = new Comun.gsiStructTab();
                    tabs[k + 1].TabName       = "ERM";
                    tabs[k + 1].TabParentId   = 0;
                    tabs[k + 1].TabId         = tabId + 1;
                    tabs[k + 1].PreviousTabId = 1;

                    tabs[k + 2]               = new Comun.gsiStructTab();
                    tabs[k + 2].TabName       = "Otros Documentos";
                    tabs[k + 2].TabParentId   = 0;
                    tabs[k + 2].TabId         = tabId + 2;
                    tabs[k + 2].PreviousTabId = tabId + 1;

                    /***Referencias a imagenes u otros documentos***/
                    log.LogInfo("Insertando Referencias");

                    Comun.gsiStructRef[] referencias = new Comun.gsiStructRef[content.Length];

                    for (int i = 0; i < content.Length; i++)
                    {
                        idcejilla = 0;
                        for (int j = 0; j < tabs.Length; j++)
                        {
                            if (tabs[j].TabName.ToUpper() == content[i].TabName.ToUpper())
                            {
                                idcejilla = tabs[j].TabId;
                                break;
                            }
                            log.LogInfo("Imprimiendo " + tabs[j].TabName.ToUpper());
                        }
                        if (idcejilla == 0)
                        {
                            idcejilla = 1;
                        }

                        gsiFile gsifile = new gsiFile();
                        gsifile.extension = content[i].ExtensionBinario;
                        log.LogInfo("Informacion agregada al componente gsifile: extension " + gsifile.extension.ToString());
                        gsifile.Document = System.Convert.FromBase64String(content[i].BinarioBase64);
                        gsifile.parentId = idcejilla;
                        log.LogInfo("Informacion agregada al componente gsifile: parentID " + gsifile.parentId.ToString());
                        log.LogInfo("Inicia funcion saveRef EWSM");
                        log.LogInfo("Se envia el siguiente appID " + appId.ToString());
                        Comun.gsiStructRef rf1 = ePower.saveRef(session, appId, gsifile);

                        referencias[i] = rf1;
                        referencias[i].DisplayAlias      = content[i].NombreBinario;
                        referencias[i].OriginalExtension = content[i].ExtensionBinario;
                        referencias[i].ParentId          = idcejilla;// content[i].IdTab;
                    }

                    log.LogInfo("Salvando Documento");
                    log.LogInfo("Enviando " + session.ToString() + " " + appId.ToString() + " " + doctypeId.ToString() + " " + queryId.ToString() + " " + idcejilla.ToString());
                    ePower.saveFullDocument(session, appId, doctypeId, queryId, tabs, Documento.Fields, referencias, null, null);
                }
                return(resultado);
            }
            catch (Exception ex)
            {
                log = new Bitacorizador();
                log.LogError("Error al ejecutar el método: InsertaArchivo, Detalles " + "Mensaje: " + ex.Message + " StackTrace: " + ex.StackTrace);
                resultado.Resultado = false;
                resultado.Mensaje   = "Error al ejecutar el método: GuardarDocumento, Detalles " + "Mensaje: " + ex.Message + " StackTrace: " + ex.StackTrace;
                return(resultado);
            }
            finally
            {
                ePower.doLogout(session);
            }
        }
Example #3
0
 public gsiStructRef saveRef(int sessionId, int appId, gsiFile docFile)
 {
     return(epBridge.saveRef(sessionId, appId, docFile));
 }