Esempio n. 1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (!base.Equals(obj))
            {
                return(false);
            }

            if (!(obj is EntryPosition))
            {
                return(false);
            }

            var other = (EntryPosition)obj;

            if (JournalName == null)
            {
                if (other.JournalName != null)
                {
                    return(false);
                }
            }
            else if (!JournalName.Equals(other.JournalName))
            {
                return(false);
            }

            if (Position == null)
            {
                if (other.Position != null)
                {
                    return(false);
                }
            }
            else if (!Position.Equals(other.Position))
            {
                return(false);
            }

            // 手写equals,自动生成时需注意
            if (Timestamp == null)
            {
                if (other.Timestamp != null)
                {
                    return(false);
                }
            }
            else if (!Timestamp.Equals(other.Timestamp))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public override int GetHashCode()
        {
            const int prime  = 31;
            var       result = base.GetHashCode();

            result = prime * result + ((JournalName == null) ? 0 : JournalName.GetHashCode());
            result = prime * result + ((Position == null) ? 0 : Position.GetHashCode());
            // 手写 equals,自动生成时需注意
            result = prime * result + ((Timestamp == null) ? 0 : Timestamp.GetHashCode());
            return(result);
        }
Esempio n. 3
0
        public void Save()
        {
            bool needSave = false;
            bool needPoc  = false;

            var o = MainObject.GetMain(MainId ?? 0) ?? new MainObject();

            if (o != null)
            {
                if (!o.MainId.HasValue)
                {
                    o.DocumentType = DocumentType;
                    needSave       = true;
                    needPoc        = true;
                }

                if (Title?.Trim() != o.Title)
                {
                    o.Title  = Title?.Trim();
                    needSave = true;
                }

                if (JournalName?.Trim() != o.JournalName)
                {
                    o.JournalName = JournalName?.Trim();
                    needSave      = true;
                }

                if (ContainsSciInfo != o.ContainsSciInfo)
                {
                    o.ContainsSciInfo = ContainsSciInfo;
                    needSave          = true;
                }

                if (ContainsTechData != o.ContainsTechData)
                {
                    o.ContainsTechData = ContainsTechData;
                    needSave           = true;
                }

                if (TechDataPublic != o.TechDataPublic)
                {
                    o.TechDataPublic = TechDataPublic;
                    needSave         = true;
                }

                if (Ouo3.HasValue && Ouo3.Value != o.Ouo3)
                {
                    o.Ouo3   = Ouo3.Value;
                    needSave = true;
                }

                if (Ouo3b != o.Ouo3b)
                {
                    o.Ouo3b  = Ouo3b;
                    needSave = true;
                }

                if (Ouo4 != o.Ouo4)
                {
                    o.Ouo4   = Ouo4;
                    needSave = true;
                }

                if (Ouo5 != o.Ouo5)
                {
                    o.Ouo5   = Ouo5;
                    needSave = true;
                }

                if (Ouo6 != o.Ouo6)
                {
                    o.Ouo6   = Ouo6;
                    needSave = true;
                }

                if (Ouo7 != o.Ouo7)
                {
                    o.Ouo7   = Ouo7;
                    needSave = true;
                }

                if (Ouo7EmployeeId != o.Ouo7EmployeeId)
                {
                    o.Ouo7EmployeeId = Ouo7EmployeeId;
                    needSave         = true;
                }

                if (DocumentType != o.DocumentType)
                {
                    o.DocumentType = DocumentType;
                    needSave       = true;
                }

                if (LimitedExp != o.LimitedExp)
                {
                    o.LimitedExp = LimitedExp;
                    needSave     = true;
                }

                if (needSave)
                {
                    o.Save();
                    MainId = o.MainId;
                }

                // Add owner as contact if this was the first time saving.
                if (needPoc && MainId.HasValue)
                {
                    ContactObject.Add(MainId.Value, Current.User.EmployeeId);
                }
            }
        }
Esempio n. 4
0
        public void Save()
        {
            bool needSave = false;

            if (SortMainId > 0)
            {
                var o = SortMainObject.GetSortMain(SortMainId);
                if (o != null)
                {
                    if (JournalType != o.JournalType)
                    {
                        o.JournalType = JournalType;
                        needSave      = true;
                    }

                    if (JournalName?.Trim() != o.JournalName)
                    {
                        o.JournalName = JournalName?.Trim();
                        needSave      = true;
                    }

                    if (JournalVolume?.Trim() != o.JournalVolume)
                    {
                        o.JournalVolume = JournalVolume?.Trim();
                        needSave        = true;
                    }

                    if (JournalIssue?.Trim() != o.JournalIssue)
                    {
                        o.JournalIssue = JournalIssue.Trim();
                        needSave       = true;
                    }

                    if (JournalSerial?.Trim() != o.JournalSerial)
                    {
                        o.JournalSerial = JournalSerial?.Trim();
                        needSave        = true;
                    }

                    if (JournalStartPage != o.JournalStartPage)
                    {
                        o.JournalStartPage = JournalStartPage;
                        needSave           = true;
                    }

                    if (JournalEndPage != o.JournalEndPage)
                    {
                        o.JournalEndPage = JournalEndPage;
                        needSave         = true;
                    }

                    if (JournalDoi?.Trim() != o.JournalDoi)
                    {
                        o.JournalDoi = JournalDoi?.Trim();
                        needSave     = true;
                    }

                    if (needSave)
                    {
                        o.Save();
                    }
                }
            }
        }