Beispiel #1
0
 private void AddRelationshipProperties(object node, EditAreaDataActionLog item)
 {
     foreach (var relation in item.RelatedLog)
     {
         string caption = "رابطه با" + " " + relation.RelationshipInfo;
         var    relNode = DataTree.AddTreeNode(node, caption, true);
         AddTreeNodes(relation.RelatedActions, relNode);
     }
 }
Beispiel #2
0
        private EditAreaDataActionLog ToRemovedDataLog(DP_DataRepository originalData)
        {
            EditAreaDataActionLog log = new EditAreaDataActionLog();

            log.ActionType = LogAction.RemoveRelationship;
            log.EntityID   = originalData.TargetEntityID;
            //log.EntityName = item.;
            log.DataInfo      = originalData.ViewInfo;
            log.KeyProperties = originalData.KeyProperties;
            return(log);
        }
Beispiel #3
0
 private void AddLogProperties(object node, EditAreaDataActionLog item)
 {
     if (item.ActionType == LogAction.NewData || item.ActionType == LogAction.AddedToRelationshipNewData)
     {
         foreach (var property in item.LogProperties)
         {
             string caption = property.ColumnaName;
             caption += (string.IsNullOrEmpty(caption) ? "" : " : ") + property.NewValue;
             DataTree.AddTreeNode(node, caption, false, property.InfoColor);
         }
     }
     else
     {
         foreach (var property in item.LogProperties)
         {
             bool longValue = false;
             if ((property.NewValue != null && property.NewValue.Length > 50) ||
                 (property.OldValue != null && property.OldValue.Length > 50))
             {
                 longValue = true;
             }
             if (longValue)
             {
                 string caption     = property.ColumnaName;
                 var    properyNode = DataTree.AddTreeNode(node, caption, false, property.InfoColor);
                 string oldValue    = "مقدار قبلی" + ":";
                 oldValue += (string.IsNullOrEmpty(oldValue) ? "" : " ") + property.OldValue;
                 string newValue = "مقدار جدید" + ":";
                 newValue += (string.IsNullOrEmpty(newValue) ? "" : " ") + property.NewValue;
                 DataTree.AddTreeNode(properyNode, oldValue, false, property.InfoColor);
                 DataTree.AddTreeNode(properyNode, newValue, false, property.InfoColor);
             }
             else
             {
                 string caption = property.ColumnaName;
                 caption += "   " + "مقدار قبلی" + ":";
                 caption += " " + property.OldValue;
                 caption += "   " + "مقدار جدید" + ":";
                 caption += " " + property.NewValue;
                 DataTree.AddTreeNode(node, caption, false, property.InfoColor);
             }
         }
     }
 }
Beispiel #4
0
        private EditAreaDataActionLog ToDataLog(DP_DataRepository item)
        {
            EditAreaDataActionLog log = new EditAreaDataActionLog();

            if (item.ParantChildRelationshipInfo != null && item.ParantChildRelationshipInfo.DataItemIsAdded(item))
            {
                if (item.IsNewItem)
                {
                    log.ActionType = LogAction.AddedToRelationshipNewData;
                }
                else
                {
                    if (item.IsEdited)
                    {
                        log.ActionType = LogAction.AddedToRelationshipAndEdited;
                    }
                    else
                    {
                        log.ActionType = LogAction.AddedToRelationshipAndNotEdited;
                    }
                }
            }
            else
            {
                if (item.IsNewItem)
                {
                    log.ActionType = LogAction.NewData;
                }
                else
                {
                    if (item.IsEdited)
                    {
                        log.ActionType = LogAction.EditData;
                    }
                    else
                    {
                        log.ActionType = LogAction.EditDataNotEdited;
                    }
                }
            }
            log.EntityID = item.TargetEntityID;
            //log.EntityName = item.;
            log.DataInfo      = item.ViewInfo;
            log.KeyProperties = item.KeyProperties;

            List <EntityInstanceProperty> changedPropeties = null;

            if (item.IsNewItem)
            {
                changedPropeties = item.GetProperties();
            }
            else
            {
                changedPropeties = item.GetProperties().Where(x => x.ValueIsChanged).ToList();
            }
            foreach (var property in changedPropeties)
            {
                var actionLogProperty = new ActionLogProperty();
                actionLogProperty.ColumnaName = property.Column.Alias;
                actionLogProperty.ColumnID    = property.ColumnID;
                actionLogProperty.InfoColor   = InfoColor.Black;
                var stringvalue = property.Value == null ? "<Null>" : property.Value;
                if (property.FormulaID != 0)
                {
                    if (string.IsNullOrEmpty(property.FormulaException))
                    {
                        actionLogProperty.NewValue = stringvalue + " " + "محاسبه شده توسط فرمول" + " " + property.FormulaID;
                    }
                    else
                    {
                        actionLogProperty.NewValue  = stringvalue + " " + property.FormulaException;
                        actionLogProperty.InfoColor = InfoColor.Red;
                    }
                }
                else
                {
                    actionLogProperty.NewValue = stringvalue.ToString();
                }

                if (item.IsNewItem)
                {
                    if (property.Column.IsIdentity)
                    {
                        if (AgentHelper.ValueIsEmpty(property))
                        {
                            actionLogProperty.NewValue = "<identity>";
                        }
                    }
                }
                if (item.OriginalProperties.Any(x => x.ColumnID == property.ColumnID))
                {
                    var oldvalue = item.OriginalProperties.First(x => x.ColumnID == property.ColumnID).Value;
                    actionLogProperty.OldValue = oldvalue == null ? "<Null>" : oldvalue.ToString();
                }
                log.LogProperties.Add(actionLogProperty);
            }
            foreach (var child in item.ChildRelationshipInfos)
            {
                var relatedLog = new RelatedDataLog();
                relatedLog.RelationshipID   = child.Relationship.ID;
                relatedLog.RelationshipInfo = child.Relationship.Alias;

                foreach (var childData in child.RelatedData)
                {
                    relatedLog.RelatedActions.Add(ToDataLog(childData));
                }
                foreach (var childData in child.RemovedDataForUpdate)
                {
                    relatedLog.RelatedActions.Add(ToRemovedDataLog(childData));
                }
                log.RelatedLog.Add(relatedLog);
            }
            return(log);
        }