Example #1
0
        public static string CriaDocContainerAssocia(string IDCATEGORY, string Retornocriar, string RetornCreateFolder)
        {
            try
            {
                string IDPASTA             = "";
                string StructID            = "";
                var    digitosparaStructID = "";

                #region DadosXML

                XDocument doc   = XDocument.Load((CaminhoDadosXML(caminho) + @"System.net.cnfg.xml"));
                var       prods = from p in doc.Descendants("Config")
                                  select new
                {
                    IDCategoriaPasta = p.Element("IDCategoriaPasta").Value,
                    StructPendenteID = p.Element("StructPendenteID").Value,
                    DigitosStructID  = p.Element("DigitosStructID").Value,
                };

                foreach (var p in prods)
                {
                    IDPASTA             = p.IDCategoriaPasta;
                    StructID            = p.StructPendenteID;
                    digitosparaStructID = p.DigitosStructID;
                }
                #endregion

                if (StructID == "")
                {
                    string strID = IDCATEGORY.Substring(0, Convert.ToInt32(digitosparaStructID));
                    StructID = strID;
                }


                SEClient newDocContainerAss = Conection.GetConnection();
                string   resultContainerAss = newDocContainerAss.newDocumentContainerAssociation(IDPASTA, RetornCreateFolder, "", StructID, IDCATEGORY, Retornocriar, out long codeAssociation, out string detailAssociation);
                if (resultContainerAss.ToString().Substring(0, 2).Contains("0:"))
                {
                    File.AppendAllText(logCriarPastaFuncionario + @"\" + "log_erro_CriarPastaFuncionario.txt", "\r\n" + DateTime.Now + @" | VINCULADO DOCUMENTO: " + Retornocriar + @" A PASTA " + RetornCreateFolder + @" COM " + resultContainerAss + @";");
                }
                else
                {
                    File.AppendAllText(logCriarPastaFuncionario + @"\" + "log_CriarPastaFuncionario.txt", "\r\n" + DateTime.Now + @" | VINCULADO DOCUMENTO: " + Retornocriar + @" A PASTA " + RetornCreateFolder + @" COM " + resultContainerAss + @";");
                }
                IDAssoc = 1;
                return(resultContainerAss);
            }
            catch (Exception ex)
            {
                while (IDAssoc <= 2)
                {
                    IDAssoc++;
                    File.AppendAllText(logCriarPastaFuncionario + @"\" + "log_erro_CriarPastaFuncionario.txt", "\r\n" + DateTime.Now + @" | CriarPastaDoc | " + ex.Message.ToString() + @";");
                    Thread.Sleep(Convert.ToInt32(5000));
                    return(CriaDocContainerAssocia(IDCATEGORY, Retornocriar, RetornCreateFolder));
                }
                return("false");
            }
        }
Example #2
0
        //#region BuscaMatricula
        //public static string ValidMatricExistt(string CategDoc, string VlAtribut, string CategPast)
        //{

        //    try
        //    {
        //        SEClient SeachDoc1 = Conection.GetConnection();

        //        searchDocumentReturn searchDocumentReturnT1 = new searchDocumentReturn();
        //        searchDocumentFilter searchDocumentFilterT1 = new searchDocumentFilter { IDCATEGORY = CategDoc };
        //        searchDocumentReturnT1 = SeachDoc1.searchDocument(searchDocumentFilterT1, "", null);

        //        if (searchDocumentReturnT1.RESULTS.Count() > 0)
        //        {
        //            foreach (var item in (searchDocumentReturnT1.RESULTS))
        //            {

        //                documentDataReturn documentDataReturn = new documentDataReturn();
        //                SEClient SeachDoc = Conection.GetConnection();
        //                documentDataReturn = SeachDoc.viewDocumentData(item.IDDOCUMENT, "", "", "");

        //                foreach (var item1 in (documentDataReturn.ATTRIBUTTES.Where(p => p.ATTRIBUTTENAME == VlAtribut)))
        //                {

        //                    var AtribuValue = item1.ATTRIBUTTEVALUE[0];

        //                    if (AtribuValue != null && AtribuValue != "")
        //                    {
        //                        var IDPasta = CategPast + "-" + AtribuValue;
        //                        AssociarDOCxPASTA(CategPast, IDPasta, CategDoc, item.IDDOCUMENT);
        //                    }
        //                    else
        //                    {
        //                        File.AppendAllText(logpath + @"\" + "log_Associação_erro.txt", "\r\n" + DateTime.Now + @" | ASSOCIAR DOCUMENTO: " + item.IDDOCUMENT + @" DOCUMENTO SEM VALOR NO ATRIBUTO: " + VlAtribut);
        //                    }

        //                }

        //            }
        //        }

        //        //Pesq2 = 1;

        //        //if (searchDocumentReturnT1.RESULTS.Count() > 0)
        //        //{
        //        //    return ("yes");
        //        //}
        //        //else
        //        //{
        //        return ("NoExist");
        //        //}

        //    }
        //    catch (Exception ex)
        //    {
        //        //while (Pesq2 <= 2)
        //        //{
        //        //    Pesq2++;
        //        //    File.AppendAllText(logpath + @"\" + "log_erro.txt", "\r\n" + DateTime.Now + @" | ValidMatricExistt | " + @" Valida Matricula: " + IdentificadorDOC + @" - " + ex.Message.ToString() + @";");
        //        //    Thread.Sleep(Convert.ToInt32());
        //        //    return ValidMatricExistt(IdentificadorDOC);
        //        //}
        //        ////File.AppendAllText(logpath + @"\" + "log_erro.txt", "\r\n" + DateTime.Now + @" | SeachDoc " + ex.Message.ToString() + @";");
        //        return ("NoConect");
        //    }

        //}
        //#endregion


        #region CREATEDOCCONTAINER
        public static string AssociarDOCxPASTA(string CategPast, string IDPasta, string CategDoc, string IDDocument)
        {
            try
            {
                var fileNameArray = Path.GetFileName(CategDoc).ToString().Split(new char[] { Convert.ToChar("-") });

                string StructID = fileNameArray[0];

                SEClient newDocContainerAss = Conection.GetConnection();
                string   resultadoAssocDoc  = newDocContainerAss.newDocumentContainerAssociation(CategPast, IDPasta, "", StructID, CategDoc, IDDocument, out long codeAssociation, out string detailAssociation);

                string RespAssoc = resultadoAssocDoc + "-" + detailAssociation;

                if (resultadoAssocDoc == "SUCCESS")
                {
                    File.AppendAllText(logAssociaçaoDocumento + @"\" + "log_Associação.txt", "\r\n" + DateTime.Now + @" | ASSOCIAR DOCUMENTO: " + IDDocument + @" A PASTA " + IDPasta + @" - " + RespAssoc + @";");
                }
                else if (RespAssoc.Contains("Documento já associado"))
                {
                    File.AppendAllText(logAssociaçaoDocumento + @"\" + "log_Documento já associado.txt", "\r\n" + DateTime.Now + @" | ASSOCIAR DOCUMENTO: " + IDDocument + @" A PASTA " + IDPasta + @" - " + detailAssociation + @";");
                }
                else if (RespAssoc.Contains("FAILURE"))
                {
                    File.AppendAllText(logAssociaçaoDocumento + @"\" + "log_Associação_erro.txt", "\r\n" + DateTime.Now + @" | ASSOCIAR DOCUMENTO: " + IDDocument + @" A PASTA " + IDPasta + @" - " + RespAssoc + @";");
                }
                IDAssoc = 1;

                return("");
            }
            catch (Exception ex)
            {
                while (IDAssoc <= 2)
                {
                    IDAssoc++;
                    File.AppendAllText(logAssociaçaoDocumento + @"\" + "log_Associação_erro.txt", "\r\n" + DateTime.Now + @" | AssociaDOC | " + ex.Message.ToString() + @";");
                    Thread.Sleep(5000);
                    return(AssociarDOCxPASTA(CategPast, IDPasta, CategDoc, IDDocument));
                }
                return("");
            }
        }
Example #3
0
            public static string CriaDocContainerAssocia(string IDCATEGORY, string Retornocriar, string MatriculaPasta)
            {
                try
                {
                    string UpperLevelCategoryID = ConfigurationManager.AppSettings["CATEGORIADEASSOCIACAO"];
                    string StructID             = ConfigurationManager.AppSettings["CONTAINER"];

                    SEClient newDocContainerAss = Conection.GetConnection();
                    string   resultadoNewDoc    = newDocContainerAss.newDocumentContainerAssociation(UpperLevelCategoryID, MatriculaPasta, "", StructID, IDCATEGORY, Retornocriar, out long codeAssociation, out string detailAssociation);

                    if (resultadoNewDoc.Contains("SUCCESS"))
                    {
                        File.AppendAllText(logpath + @"\" + "log.txt", "\r\n" + DateTime.Now + @" | Vinculado: " + Retornocriar + @" ao " + MatriculaPasta + @" " + resultadoNewDoc.ToString() + @";");
                    }
                    else
                    {
                        File.AppendAllText(logpath + @"\" + "log_erro.txt", "\r\n" + DateTime.Now + @" | Vinculado: " + Retornocriar + @" ao " + MatriculaPasta + @" " + resultadoNewDoc.ToString() + @";");
                    }
                    iAssoc = 1;
                    return("");
                }
                catch (Exception ex)
                {
                    while (iAssoc <= 2)
                    {
                        iAssoc++;
                        File.AppendAllText(logpath + @"\" + "log_erro.txt", "\r\n" + DateTime.Now + @" | AssociacaoDoc " + @" | " + Retornocriar + @" ao " + MatriculaPasta + @" " + ex.Message.ToString() + @";");
                        Thread.Sleep(Convert.ToInt32(IntervalReturn));
                        return(CriaDocContainerAssocia(IDCATEGORY, Retornocriar, MatriculaPasta));
                    }
                    EnviaEmail(ex.Message.ToString(), "Erro na Associação");
                    //File.AppendAllText(logpath + @"\" + "log_erro.txt", "\r\n" + DateTime.Now + @" | AssociacaoDoc " + ex.Message.ToString() + @";");
                    iAssoc = 1;
                    return("");
                }
            }