/// <summary>
        /// Определяет был ли изменен объект
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool f_IsChanged(I_ELog obj)
        {
            bool isChanged = false;

            Cl_ELogClassAttribute classAtr = Cl_EntityLog.f_GetClassAttribute <Cl_ELogClassAttribute>(obj);

            if (classAtr == null)
            {
                return(true);
            }
            if (this.entityLogType != classAtr.p_EntityType)
            {
                return(true);
            }

            Dictionary <PropertyInfo, object> currentValues = f_GetValues(obj);

            foreach (KeyValuePair <PropertyInfo, object> item in currentValues)
            {
                if (!lastValues.ContainsKey(item.Key))
                {
                    continue;
                }
                if (Cl_EntityCompare.f_IsCompare(item.Key.PropertyType, lastValues[item.Key], item.Value) == false)
                {
                    isChanged = true;
                    break;
                }
            }

            return(isChanged);
        }
Esempio n. 2
0
        private static string f_GetRecordValue(Cl_RecordValue cur, Cl_RecordValue last)
        {
            StringBuilder sBuild      = new StringBuilder();
            Cl_Element    baseElement = cur.p_Element;

            if (baseElement.p_IsText)
            {
                if (baseElement.p_IsPartLocations)
                {
                    if (Cl_EntityCompare.f_IsCompare(typeof(Array), cur.p_PartLocations, last.p_PartLocations) == false)
                    {
                        sBuild.AppendLine("Локация \"" + baseElement.p_Name + "\". " + f_GetRecordParamsValue(cur.p_PartLocations, last.p_PartLocations));
                    }
                }

                if (baseElement.p_IsTextFromCatalog)
                {
                    if (Cl_EntityCompare.f_IsCompare(typeof(Array), cur.p_ValuesCatalog, last.p_ValuesCatalog) == false)
                    {
                        sBuild.AppendLine("Локация \"" + baseElement.p_Name + "\". " + f_GetRecordParamsValue(cur.p_ValuesCatalog, last.p_ValuesCatalog));
                    }

                    if (baseElement.p_Symmetrical && Cl_EntityCompare.f_IsCompare(typeof(Array), last.p_ValuesDopCatalog, cur.p_ValuesDopCatalog) == false)
                    {
                        sBuild.AppendLine("Локация \"" + baseElement.p_Name + "\". " + f_GetRecordParamsValue(cur.p_ValuesDopCatalog, last.p_ValuesDopCatalog));
                    }
                }
                else
                {
                    if (Cl_EntityCompare.f_IsCompare(typeof(String), last.p_ValueUser, cur.p_ValueUser) == false)
                    {
                        sBuild.AppendLine("Значение \"" + baseElement.p_Name + "\"" + (baseElement.p_Symmetrical ? " (" + baseElement.p_SymmetryParamLeft + ")" : "") + ". " + "Старое значение: \"" + last.p_ValueUser + "\". Новое значение: \"" + cur.p_ValueUser + "\"");
                    }

                    if (baseElement.p_Symmetrical && Cl_EntityCompare.f_IsCompare(typeof(String), last.p_ValueDopUser, cur.p_ValueDopUser) == false)
                    {
                        sBuild.AppendLine("Значение \"" + baseElement.p_Name + "\"" + (baseElement.p_Symmetrical ? " (" + baseElement.p_SymmetryParamRight + ")" : "") + ". " + "Старое значение: \"" + last.p_ValueDopUser + "\". Новое значение: \"" + cur.p_ValueDopUser + "\"");
                    }
                }
            }
            else if (baseElement.p_IsImage)
            {
                sBuild.Append("Картинка \"" + baseElement.p_Name + "\" изменилась");
            }
            else
            {
                throw new NotImplementedException();
            }

            return(sBuild.ToString().Trim());
        }
        /// <summary>
        /// Возвращает список измененных свойств объекта
        /// </summary>
        private Dictionary <PropertyInfo, object> f_GetChangedValues(I_ELog obj)
        {
            Dictionary <PropertyInfo, object> outValues     = new Dictionary <PropertyInfo, object>();
            Dictionary <PropertyInfo, object> currentValues = f_GetValues(obj);

            foreach (KeyValuePair <PropertyInfo, object> item in currentValues)
            {
                if (!lastValues.ContainsKey(item.Key))
                {
                    continue;
                }
                if (Cl_EntityCompare.f_IsCompare(item.Key.PropertyType, lastValues[item.Key], item.Value) == false)
                {
                    outValues.Add(item.Key, item.Value);
                }
            }

            return(outValues);
        }