示例#1
0
        private Comun.gsiStructTab[] creaCejillas()
        {
            Comun.gsiStructTab[] tabs = new Comun.gsiStructTab[5];
            tabs[0]             = new Comun.gsiStructTab();
            tabs[0].TabName     = "Imagenes";
            tabs[0].TabParentId = 0;
            tabs[0].TabId       = 1;

            tabs[1]             = new Comun.gsiStructTab();
            tabs[1].TabName     = "ERM";
            tabs[1].TabParentId = 0;
            tabs[1].TabId       = 2;

            tabs[2]             = new Comun.gsiStructTab();
            tabs[2].TabName     = "Otros Documentos";
            tabs[2].TabParentId = 0;
            tabs[2].TabId       = 3;

            tabs[3]             = new Comun.gsiStructTab();
            tabs[3].TabName     = "Correspondencia Recibida";
            tabs[3].TabParentId = 1;
            tabs[3].TabId       = 4;

            tabs[4]             = new Comun.gsiStructTab();
            tabs[4].TabName     = "Correspondencia Enviada";
            tabs[4].TabParentId = 1;
            tabs[4].TabId       = 5;

            return(tabs);
        }
示例#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);
            }
        }