Example #1
0
        }// fi

        public bool GetCoincidencia(int id, string denominacion, C_TipoSociedades tipoSociedad)
        {
            bool exito = false;

            string[] palabras = denominacion.Split(' ');

            if (palabras.Count() > 7)
            {
                string end = String.Join(" ", palabras, palabras.Count() - 7, 7);

                double porcentaje = 0;
                StringUtilities.LevenshteinDistance(end, tipoSociedad.SubtipoStr, out porcentaje);

                if (porcentaje < 0.1)
                {
                    BasicEntityInfo info = new BasicEntityInfo()
                    {
                        Id       = id,
                        Sociedad = denominacion
                    };

                    this.UpdateOrden(info, tipoSociedad);
                    exito = true;
                }
            }

            return(exito);
        }
Example #2
0
        /// <summary>
        /// Verifica si la información que esta después de la última "," coincide con las siglas de los tipos de denominaciones
        /// </summary>
        private bool AfterComaProces(int id, string denominacion, ObservableCollection <C_TipoSociedades> tiposCatalogo)
        {
            BasicEntityInfo info = new BasicEntityInfo();

            info.Id = id;
            int idCurrent = info.Id;

            info.Sociedad = denominacion;

            if (!String.IsNullOrEmpty(info.Sociedad) && !info.Sociedad.EndsWith(","))
            {
                int index = info.Sociedad.LastIndexOf(',');
                if (index + 1 > info.Sociedad.Length)
                {
                }
                else
                {
                    if (index > -1)
                    {
                        info.AfterComa    = info.Sociedad.Substring(index + 1);
                        info.AfterComaStr = StringUtilities.PrepareToAlphabeticalOrder(info.AfterComa);

                        C_TipoSociedades socCorrecta = tiposCatalogo.FirstOrDefault(x => x.SiglasStr.Equals(info.AfterComaStr));

                        if (socCorrecta != null)
                        {
                            this.UpdateOrden(info, socCorrecta);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #3
0
        /// <summary>
        /// Elimina los espacios de la denominación y busca si es que dicha denominación culmina con
        /// alguna de las siglas del catálogo de tipo de denominaciones
        /// </summary>
        private bool NoSpacesProces(int id, string denominacion, ObservableCollection <C_TipoSociedades> tiposCatalogo)
        {
            int idCurrent = 0;
            int totalReview = 0, totalupdates = 0;

            bool exito = false;

            try
            {
                BasicEntityInfo info = new BasicEntityInfo();
                info.Id = id;

                idCurrent     = info.Id;
                info.Sociedad = denominacion;

                if (!string.IsNullOrEmpty(info.Sociedad))
                {
                    info.SociedadStr = StringUtilities.PrepareToAlphabeticalOrder(this.CleanDenominacion(info.Sociedad)).Replace(" ", "");
                    Console.WriteLine(info.Id);
                    totalReview++;

                    bool find = false;
                    foreach (C_TipoSociedades tipo in tiposCatalogo)
                    {
                        if (info.SociedadStr.EndsWith(tipo.SiglasStr))
                        {
                            this.UpdateOrden(info, tipo);
                            totalupdates++;
                            exito = true;
                        }
                        else if (info.SociedadStr.EndsWith(tipo.SubtipoStrWoSpaces))
                        {
                            this.UpdateOrden(info, tipo);
                            totalupdates++;
                            exito = true;
                        }

                        if (exito)
                        {
                            break;
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                return(false);
                //string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                //ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,PadronModel" + idCurrent, "PadronApi");
            }
            catch (Exception ex)
            {
                return(false);
                //string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                //ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,PadronModel" + idCurrent, "PadronApi");
            }

            return(exito);
        }
        private IBoardPostEntity LoadPostLight(IEsentSession session, PostsTable table, bool getPostCount, PostStoreEntityType?entityType)
        {
            BasicEntityInfo         bi = default(BasicEntityInfo);
            PostModelStorePostLight r  = IsOriginalPageSequence(entityType) ? new PostModelStorePostLightWithSequence() : new PostModelStorePostLight();

            SetPostLightData(session, table, getPostCount, r, ref bi);
            return(r);
        }
        private IBoardPostEntity LoadPost(IEsentSession session, ref LoadPostDataContext loadContext, bool getPostCount, PostStoreEntityType?entityType)
        {
            BasicEntityInfo    bi = default(BasicEntityInfo);
            PostModelStorePost r  = IsOriginalPageSequence(entityType) ? new PostModelStorePostWithSequence() : new PostModelStorePost();

            SetPostData(session, ref loadContext, getPostCount, r, ref bi);
            return(r);
        }
        private IBoardPostEntity LoadThreadCollection(PostsTable table)
        {
            BasicEntityInfo bi = default(BasicEntityInfo);
            var             r  = new PostModelStoreThreadCollection();

            SetThreadCollectionData(table, r, ref bi);
            return(r);
        }
        private IBoardPostEntity LoadBareEntity(PostsTable table, PostStoreEntityType?entityType)
        {
            PostModelStoreBareEntity r  = IsOriginalPageSequence(entityType) ? new PostModelStoreBareEntityWithSequence() : new PostModelStoreBareEntity();
            BasicEntityInfo          bi = default(BasicEntityInfo);

            SetBareEntityData(table, r, ref bi);
            return(r);
        }
        private IBoardPostEntity LoadLinkOnly(PostsTable table)
        {
            BasicEntityInfo bi = default(BasicEntityInfo);

            LoadBasicInfo(table, ref bi);
            return(new PostModelStoreBareEntityLink()
            {
                EntityType = bi.entityType,
                Link = bi.link,
                ParentLink = bi.parentLink,
                StoreId = bi.entityId,
                StoreParentId = bi.parentEntityId
            });
        }
 private void LoadBasicInfo(PostsTable.ViewValues.BasicLoadInfoView v, ref BasicEntityInfo bi)
 {
     bi.entityType    = (PostStoreEntityType)v.EntityType;
     bi.genEntityType = ToGenericEntityType(bi.entityType);
     (bi.link, bi.parentLink, bi.sequenceId, bi.boardId, bi.parentSequenceId) = LoadEntityLinks(v, bi.genEntityType);
     bi.entityId = new PostStoreEntityId()
     {
         Id = v.Id
     };
     bi.parentEntityId = v.DirectParentId != null ? (PostStoreEntityId?)(new PostStoreEntityId()
     {
         Id = v.DirectParentId.Value
     }) : null;
 }
Example #10
0
        public void GetSociedadesTocompare()
        {
            List <BasicEntityInfo> listaSociedades = new List <BasicEntityInfo>();

            SqlConnection connection = new SqlConnection(sqlConnectionString);
            SqlCommand    cmd;
            SqlDataReader reader;

            try
            {
                connection.Open();

                cmd    = new SqlCommand("SELECT Id, dsdensocial FROM Sociedades where CLAVE_FORMA in ('M4','M47')", connection);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    BasicEntityInfo sociedad = new BasicEntityInfo();
                    sociedad.Id       = Convert.ToInt32(reader["Id"]);
                    sociedad.Sociedad = reader["dsdensocial"].ToString();

                    listaSociedades.Add(sociedad);
                }


                reader.Close();
                cmd.Dispose();

                this.LookForSimilar(listaSociedades);
            }
            catch (OleDbException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,ValidaSocioModel", "DGNMTools");
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,ValidaSocioModel", "DGNMTools");
            }
            finally
            {
                connection.Close();
            }
        }
        private List <IPostMedia> LoadPostMedia(MediaFilesTable mediaTable, ref BasicEntityInfo bi, bool setIndex)
        {
            var r     = new List <IPostMedia>();
            var index = mediaTable.Indexes.SequencesIndex;

            if (setIndex)
            {
                index.SetAsCurrentIndex();
            }
            foreach (var md in index.EnumerateAsMediaDataView(index.CreateKey(bi.entityId.Id)))
            {
                var m = ObjectSerializationService.Deserialize(md.MediaData) as IPostMedia;
                if (m != null)
                {
                    r.Add(m);
                }
            }
            return(r);
        }
Example #12
0
        /// <summary>
        /// Actualiza el tipo de sociedad, ya sea que este en blanco o que tenga un tipo incorrecto
        /// </summary>
        /// <param name="info"></param>
        /// <param name="socCorrecta"></param>
        /// <returns></returns>
        public bool UpdateOrden(BasicEntityInfo info, C_TipoSociedades socCorrecta)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            bool updateCompleted = false;

            try
            {
                connection.Open();

                SqlCommand cmd = new SqlCommand("UPDATE CaratulasJulio2018 SET IdTipoSociedadSugerido = @Tipo, TipoSociedadSugerido = @TipoSociedadSugerido, SubTipoSociedadSugerido = @SubTipoSociedadSugerido WHERE Id = @Id", connection);
                cmd.Parameters.AddWithValue("@Tipo", socCorrecta.Id);
                cmd.Parameters.AddWithValue("@TipoSociedadSugerido", socCorrecta.TipoSociedad);
                cmd.Parameters.AddWithValue("@SubTipoSociedadSugerido", socCorrecta.Subtipo);
                cmd.Parameters.AddWithValue("@Id", info.Id);

                cmd.ExecuteNonQuery();

                cmd.Dispose();
                updateCompleted = true;
            }
            catch (SqlException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,ObraModel", "PadronApi");
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,ObraModel", "PadronApi");
            }
            finally
            {
                connection.Close();
            }

            return(updateCompleted);
        }
        private void SetPostLightData(IEsentSession session, PostsTable.ViewValues.PostLightLoadView v, bool getPostCount, PostModelStorePostLight data, ref BasicEntityInfo bi)
        {
            SetBareEntityData(v, data, ref bi);
            data.BoardSpecificDate = v.BoardSpecificDate;
            data.Counter           = getPostCount && bi.parentEntityId != null?GetPostCounterNumber(session, bi.parentEntityId.Value, bi.sequenceId) ?? 0 : 0;

            data.Date    = FromUtcToOffset(v.Date) ?? DateTimeOffset.MinValue;
            data.Flags   = v.Flags.Where(g => g?.Value != null).Select(g => g.Value.Value).Distinct().ToList();
            data.TagsSet = v.ThreadTags
                           .Where(t => !string.IsNullOrEmpty(t?.Value))
                           .Select(t => t.Value)
                           .Distinct()
                           .OrderBy(t => t, StringComparer.CurrentCulture)
                           .ToArray();
            data.LLikes    = v.Likes;
            data.LDislikes = v.Dislikes;
        }
        private List <ILink> LoadQuotesForPost(PostsTable quotesTable, bool setIndex, ref BasicEntityInfo bi)
        {
            var r = new HashSet <ILink>(BoardLinkEqualityComparer.Instance);

            if (bi.parentEntityId != null && bi.parentSequenceId != null)
            {
                var index = quotesTable.Indexes.QuotedPostsIndex;
                if (setIndex)
                {
                    index.SetAsCurrentIndex();
                }
                foreach (var seqId in index.EnumerateAsSequenceNumberView(index.CreateKey(bi.parentEntityId.Value.Id, bi.sequenceId)))
                {
                    r.Add(new PostLink()
                    {
                        Engine    = EngineId,
                        Board     = bi.boardId,
                        OpPostNum = bi.parentSequenceId.Value,
                        PostNum   = seqId.SequenceNumber
                    });
                }
            }
            return(r.OrderBy(l => l, BoardLinkComparer.Instance).ToList());
        }
 private void SetThreadCollectionData(PostsTable table, PostModelStoreThreadCollection data, ref BasicEntityInfo bi)
 {
     SetThreadCollectionData(table.Views.PostCollectionLoadInfoView.Fetch(), data, ref bi);
 }
 private void SetThreadCollectionData(PostsTable.ViewValues.PostCollectionLoadInfoView v, PostModelStoreThreadCollection data, ref BasicEntityInfo bi)
 {
     SetBareEntityData(v, data, ref bi);
     data.Etag  = v.Etag;
     data.Info  = ObjectSerializationService.Deserialize(v.OtherDataBinary) as IBoardPostCollectionInfoSet;
     data.Stage = v.ChildrenLoadStage;
 }
 private void SetThreadPreviewData(PostsTable table, PostModelStoreThreadPreview data, ref BasicEntityInfo bi)
 {
     SetThreadPreviewData(table.Views.ThreadPreviewLoadInfoView.Fetch(), data, ref bi);
 }
        private void SetThreadPreviewData(PostsTable.ViewValues.ThreadPreviewLoadInfoView v, PostModelStoreThreadPreview data, ref BasicEntityInfo bi)
        {
            SetPostCollectionData(v, data, ref bi);
            var counts = ReadThreadPreviewCounts(v.PreviewCounts);

            data.ImageCount     = counts.imageCount;
            data.Omit           = counts.omit;
            data.OmitImages     = counts.omitImages;
            data.ReplyCount     = counts.replyCount;
            data.OnPageSequence = v.ThreadPreviewSequence ?? int.MaxValue;
        }
Example #19
0
        public void GetInfoDenominacionForChanges()
        {
            ObservableCollection <BasicEntityInfo> sociedades = new ObservableCollection <BasicEntityInfo>();

            //const string SqlCadena = "SELECT Id,dsdensocial FROM CaratulasJulio2018 WHERE (TipoSociedadSugerido is null and (CLAVE_FORMA = 'M9' )) ORDER BY Id desc";
            const string SqlCadena = "SELECT * FROM InfoMovtos";

            int totalReview = 0, totalupdates = 0;

            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    cmd        = null;
            SqlDataReader reader     = null;
            int           idCurrent  = 0;

            try
            {
                connection.Open();

                cmd    = new SqlCommand(SqlCadena, connection);
                reader = cmd.ExecuteReader();
                //int totalReview = 0, totalupdates = 0;

                bool exitoNoSpace = false;

                while (reader.Read())
                {
                    //idCurrent = Convert.ToInt32(reader["Id"]);
                    BasicEntityInfo sociedad = new BasicEntityInfo();
                    sociedad.Sociedad        = reader["dsdensocial"].ToString();
                    sociedad.DenomDatoCadena = reader["dsdatocadena"].ToString();

                    string tempString = reader["dsxmldocumento"].ToString();

                    sociedad.BoletaInscripcion = this.extractSocNameFromXml(tempString);

                    if (sociedad.Sociedad.Equals(sociedad.DenomDatoCadena) && sociedad.Sociedad.Equals(sociedad.BoletaInscripcion) && sociedad.DenomDatoCadena.Equals(sociedad.BoletaInscripcion))
                    {
                        sociedad.IsSameName = true;
                    }
                }

                cmd.Dispose();
                reader.Close();

                MessageBox.Show(String.Format("Total revisados: {0}", totalReview));
                MessageBox.Show(String.Format("Total actualizados: {0}", totalupdates));
            }
            catch (SqlException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, String.Format("{0} Exception,BasicEntityModel{1}", methodName, idCurrent), "PadronApi");
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, String.Format("{0} Exception,BasicEntityModel{1}", methodName, idCurrent), "PadronApi");
            }
            finally
            {
                connection.Close();
            }
        }
 private void SetPostData(IEsentSession session, ref LoadPostDataContext loadContext, bool getPostCount, PostModelStorePost data, ref BasicEntityInfo bi)
 {
     SetPostData(session, ref loadContext, loadContext.table.Views.PostFullLoadView.Fetch(), getPostCount, data, ref bi);
 }
        private void SetPostData(IEsentSession session, ref LoadPostDataContext loadContext, PostsTable.ViewValues.PostFullLoadView v, bool getPostCount, PostModelStorePost data, ref BasicEntityInfo bi)
        {
            SetPostLightData(session, v, getPostCount, data, ref bi);
            var posterName = v.PosterName;
            var otherData  = DeserializeDataContract <PostOtherData>(v.OtherDataBinary);

            otherData?.FillPostData(data, LinkSerialization, posterName);
            data.Comment    = ObjectSerializationService.Deserialize(v.Document) as IPostDocument;
            data.LoadedTime = FromUtcToOffset(v.LoadedTime) ?? DateTimeOffset.MinValue;
            data.MediaFiles = LoadPostMedia(loadContext.mediaTable ?? throw new InvalidOperationException("Таблица медиафайлов не открыта"), ref bi, false);
            data.Quotes     = LoadQuotesForPost(loadContext.quotesTable ?? throw new InvalidOperationException("Таблица цитат не открыта"), false, ref bi);
        }
 private void SetBareEntityData(PostsTable table, PostModelStoreBareEntity data, ref BasicEntityInfo bi)
 {
     SetBareEntityData(table.Views.BareEntityLoadInfoView.Fetch(), data, ref bi);
 }
 private void SetPostLightData(IEsentSession session, PostsTable table, bool getPostCount, PostModelStorePostLight data, ref BasicEntityInfo bi)
 {
     SetPostLightData(session, table.Views.PostLightLoadView.Fetch(), getPostCount, data, ref bi);
 }
 private void SetBareEntityData(PostsTable.ViewValues.BareEntityLoadInfoView v, PostModelStoreBareEntity data, ref BasicEntityInfo bi)
 {
     LoadBasicInfo(v, ref bi);
     data.EntityType    = bi.entityType;
     data.Link          = bi.link;
     data.ParentLink    = bi.parentLink;
     data.Thumbnail     = ObjectSerializationService.Deserialize(v.Thumbnail) as IPostMediaWithSize;
     data.Subject       = v.Subject;
     data.StoreId       = bi.entityId;
     data.StoreParentId = bi.parentEntityId;
     if (data is IBoardPostEntityWithSequence2 s)
     {
         s.SetOnPageSequence(v.ThreadPreviewSequence ?? int.MaxValue);
     }
 }