예제 #1
0
        public virtual ITisDataLayerTreeNode Clone(EntityCloneSpec enEntityCloneSpec, Func <IEntityBase, string> nameingFun)
        {
            bool bCloneData           = (enEntityCloneSpec & EntityCloneSpec.Data) > 0;
            bool bCloneOwnedChildren  = (enEntityCloneSpec & EntityCloneSpec.OwnedChildren) > 0;
            bool bCloneLinkedChildren = (enEntityCloneSpec & EntityCloneSpec.LinkedChildren) > 0;


            // Performs clone, returns empty object
            ITisDataLayerTreeNode oCloned = this.CloneObject(nameingFun);

            // Clone parameters if requested
            if (bCloneData)
            {
                CloneDataTo(oCloned);
            }

            // Clone owned children if requested
            if (bCloneOwnedChildren)
            {
                CloneOwnedChildrenTo(oCloned, enEntityCloneSpec);
            }

            // Clone linked children if requested
            if (bCloneLinkedChildren)
            {
                CloneLinkedChildrenTo(oCloned, enEntityCloneSpec);
            }

            return(oCloned);
        }
예제 #2
0
        /// <summary>
        /// Set namedUserTags too the eFlow object.
        /// </summary>
        /// <param name="eflowObject">The eFlow object to set its NamedUserTags.</param>
        /// <param name="setNamedTags">The dictionary of NamedUserTags to set.</param>
        /// <returns>true when successfull.</returns>
        public static bool SetNamedUserTags(ITisDataLayerTreeNode eflowObject, Dictionary <String, String> setNamedTags)
        {
            try
            {
                if (eflowObject == null || setNamedTags == null || setNamedTags.Count <= 0)
                {
                    return(false);
                }

                foreach (KeyValuePair <String, String> kv in setNamedTags)
                {
                    if (eflowObject.UserTagsMap.Contains(kv.Key))
                    {
                        eflowObject.UserTagsMap[kv.Key] = kv.Value;
                    }
                    else
                    {
                        eflowObject.UserTagsMap.Add(kv.Key, kv.Value);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(false);
        }
 public DLTNodesCopySession(
     ITisDataLayerTreeNode oSrcRoot,
     ITisDataLayerTreeNode oDstRoot,
     Func <IEntityBase, string> nameingFun = null)
     : base((EntityBase)oSrcRoot, (EntityBase)oDstRoot)
 {
     m_nameingFun = nameingFun;
 }
예제 #4
0
 private void CloneLinkedChildrenTo(
     ITisDataLayerTreeNode oTargetObj,
     EntityCloneSpec enEntityCloneSpec)
 {
     CloneChildrenTo(
         oTargetObj,
         this.TypeInfo.LinkedChildren,
         enEntityCloneSpec);
 }
예제 #5
0
        public void CopyUserTagsTo(ITisDataLayerTreeNode oTarget)
        {
            ((TisDataLayerTreeNode)oTarget).UserTagsMap.Clear();

            foreach (DictionaryEntry oEntry in this.UserTagsMap)
            {
                ((TisDataLayerTreeNode)oTarget).UserTagsMap.Add(oEntry.Key, oEntry.Value);
            }
        }
예제 #6
0
        public CCEflowBaseObject FromEflowObject(CCreator creator, ITisDataLayerTreeNode eflowObject)
#endif
        {
            try
            {
                if (eflowObject is ITisFieldData)
                {
                    return(new CCCollection.CCField(creator, eflowObject as ITisFieldData));
                }
                else if (eflowObject is ITisFieldParams)
                {
                    return(new CCCollection.CCField(creator, eflowObject as ITisFieldParams));
                }
                else if (eflowObject is ITisFieldGroupData)
                {
                    return(new CCCollection.CCGroup(creator, eflowObject as ITisFieldGroupData));
                }
                else if (eflowObject is ITisFieldGroupParams)
                {
                    return(new CCCollection.CCGroup(creator, eflowObject as ITisFieldGroupParams));
                }
                else if (eflowObject is ITisFieldTableData)
                {
                    return(new CCCollection.CCTable(creator, eflowObject as ITisFieldTableData));
                }
                else if (eflowObject is ITisFieldTableParams)
                {
                    return(new CCCollection.CCTable(creator, eflowObject as ITisFieldTableParams));
                }
                else if (eflowObject is ITisFieldArrayData)
                {
                    return(new CCCollection.CCFieldArray(creator, eflowObject as ITisFieldArrayData));
                }
                else if (eflowObject is ITisPageData)
                {
                    return(new CCCollection.CCPage(creator, eflowObject as ITisPageData));
                }
                else if (eflowObject is ITisPageParams)
                {
                    ITisPageParams pg = eflowObject as ITisPageParams;
                    return(new CCCollection.CCPage(creator, pg, pg.NumberOfLinkedEFIs == 1 ? pg.get_LinkedEFIByIndex(0).Name : pg.ParentForm.ParentFlow.Process.DefaultEFI ?? String.Empty));
                }
                else if (eflowObject is ITisFormData)
                {
                    return(new CCCollection.CCForm(creator, eflowObject as ITisFormData));
                }
                else if (eflowObject is ITisFormParams)
                {
                    return(new CCCollection.CCForm(creator, eflowObject as ITisFormParams));
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(null);
        }
예제 #7
0
        public void ImportNode(
            ITisDataLayerTreeNode oNodeToImport,
            IImportObjectExistsNotify oObjectExistsNotifier,
            ITisDataLayerTreeNode[] OptionalLinks)
        {
            try
            {
                Rare.ObjectExistsNotifier = oObjectExistsNotifier;

                ITisDataLayerTreeNode oImportedRootOwner =
                    (ITisDataLayerTreeNode)((EntityBase)oNodeToImport).RootOwner;

                DLTNodesCopySession oMergeSession = new DLTNodesCopySession(
                    oImportedRootOwner,
                    (ITisDataLayerTreeNode)this.RootOwner
                    );

                oMergeSession.AddCopyRoot(oNodeToImport);

                oMergeSession.OnObjectExists += new ImportObjectExistsDelegate(
                    this.oCopySession_OnObjectExists);

                oMergeSession.PerformCopy(false);

                Rare.ObjectExistsNotifier = null;

                ICollection oSrcObjects = oMergeSession.GetAllSourceObjects();

                // Copy attachments
                foreach (EntityBase oSrcObj in oSrcObjects)
                {
                    ITisDataLayerTreeNode oSrcNode   = oSrcObj as ITisDataLayerTreeNode;
                    ITisDataLayerTreeNode oCopiedObj =
                        oMergeSession.GetClonedObject(oSrcObj) as ITisDataLayerTreeNode;

                    if (oSrcNode != null && oCopiedObj != null)
                    {
                        CopyNodeAttachments(
                            oSrcNode,
                            oCopiedObj);
                    }
                }
            }
            catch (Exception oExc)
            {
                Log.Write(
                    Log.Severity.ERROR,
                    System.Reflection.MethodInfo.GetCurrentMethod(),
                    "Failed", oExc);

                Log.WriteException(oExc);

                throw;
            }
        }
예제 #8
0
        // May be overriden of object contains a complex data, not just parameters
        protected virtual void CloneDataTo(object oTargetObj)
        {
            // Clone all parameters
            CloneParametersTo(oTargetObj);

            // Copy UserTags

            ITisDataLayerTreeNode oTargetDLTNode =
                oTargetObj as ITisDataLayerTreeNode;

            if (oTargetDLTNode != null)
            {
                CopyUserTagsTo(oTargetDLTNode);
            }
        }
예제 #9
0
        /// <summary>
        /// Get the namedUserTags of the specified eflow object.
        /// </summary>
        /// <param name="eflowObject">The eFlow object to get its NamedUserTags.</param>
        /// <param name="skipEmpty">Skip empty NamedUserTags (value)</param>
        /// <returns>A dictionary of Key values when successfull.</returns>
        public static Dictionary <String, String> GetNamedUserTags(ITisDataLayerTreeNode eflowObject, bool skipEmpty)
        {
            Dictionary <String, String> result = new Dictionary <String, String>();

            try
            {
                System.Collections.IDictionaryEnumerator enm = eflowObject.UserTagsMap.GetEnumerator();
                while (enm.MoveNext())
                {
                    if (skipEmpty && String.IsNullOrEmpty(enm.Value as String))
                    {
                        continue;
                    }
                    result.Add(enm.Key as String, enm.Value as String);
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(result);
        }
예제 #10
0
 /// <summary>
 /// Set specified UserTags to the eFlow object.
 /// </summary>
 /// <param name="eflowObject">The eFlow object to set its UserTags.</param>
 /// <param name="setTags">The dictionary of UserTags to set.</param>
 /// <returns>true whne successfull.</returns>
 public static bool SetUserTags(ITisDataLayerTreeNode eflowObject, Dictionary <String, String> setTags)
 {
     try
     {
         if (eflowObject == null || setTags == null || setTags.Count <= 0)
         {
             return(false);
         }
         int count = 0;
         foreach (KeyValuePair <String, String> kv in setTags)
         {
             eflowObject.set_UserTags((short)count, kv.Value);
             count++;
         }
         return(true);
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
     return(false);
 }
예제 #11
0
        private void CloneChildrenTo(
            ITisDataLayerTreeNode oTargetObj,
            ICollection <ITisEntityChildInfo> ChildrenInfoCollection,
            EntityCloneSpec enEntityCloneSpec)
        {
            foreach (ITisEntityChildInfo oChildInfo in ChildrenInfoCollection)
            {
                // Get source list
                INamedObjectList oSrcList = oChildInfo.GetChildList(this);

                // Get destination list
                INamedObjectList oDstList = oChildInfo.GetChildList(oTargetObj);

                // Add cloned objects to destination list

                TisDataLayerTreeNode oChildNode;

                for (int i = 0; i < oSrcList.Count; i++)
                {
                    if (oSrcList is INamedObjectOrder)
                    {
                        oChildNode =
                            ((oSrcList as INamedObjectOrder).GetByOrder(i)) as TisDataLayerTreeNode;
                    }
                    else
                    {
                        oChildNode =
                            (oSrcList[oSrcList.NameByIndex(i)]) as TisDataLayerTreeNode;
                    }

                    // Clone
                    ITisDataLayerTreeNode oClonedChildNode =
                        oChildNode.Clone(enEntityCloneSpec);

                    // Add to list
                    oDstList.Add(oClonedChildNode);
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Get the UserTags of the specified eflow object.
        /// </summary>
        /// <param name="eflowObject">the eFlow object to get it's UserTags</param>
        /// <param name="skipEmpty">Skip empty UserTags</param>
        /// <returns>A dictionary of Key (number) values when successfull.</returns>
        public static Dictionary <String, String> GetUserTags(ITisDataLayerTreeNode eflowObject, bool skipEmpty)
        {
            Dictionary <String, String> result = new Dictionary <String, String>();

            try
            {
                int sc = 0;
                for (int i = 0; i < eflowObject.NumberOfUserTags; i++)
                {
                    if (skipEmpty && String.IsNullOrEmpty(eflowObject.get_UserTags((short)i)))
                    {
                        continue;
                    }

                    sc++;
                    result.Add(sc.ToString("000"), eflowObject.get_UserTags((short)i));
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(result);
        }
예제 #13
0
        //
        //	Private
        //

        #region Import support

        private void CopyNodeAttachments(
            ITisDataLayerTreeNode oSrcTreeNode,
            ITisDataLayerTreeNode oDstTreeNode)
        {
            ISupportsAttachments oSrc = oSrcTreeNode as ISupportsAttachments;
            ISupportsAttachments oDst = oDstTreeNode as ISupportsAttachments;

            EntityBase oSrcEntity = oSrcTreeNode as EntityBase;
            EntityBase oDstEntity = oDstTreeNode as EntityBase;

            if (oSrc == null || oDst == null || oSrcEntity == null || oDstEntity == null)
            {
                return;
            }

            IList <string> oLocalAttachments = oSrc.LocalAttachments;

            ITisAttachedFileManager oSrcAttachedFileManager = (ITisAttachedFileManager)oSrcEntity.GetContextService(
                TisServicesSchema.SetupAttachmentsFileManager.ServiceName);

            ITisAttachedFileManager oDstAttachedFileManager = (ITisAttachedFileManager)oDstEntity.GetContextService(
                TisServicesSchema.SetupAttachmentsFileManager.ServiceName);

            foreach (string sAttachment in oLocalAttachments)
            {
                string sAttType    = AttachmentsUtil.GetAttachmentType(sAttachment);
                string sDstAttName = oDst.GetAttachmentFileName(sAttType) ?? oDst.GetAttachmentNameByFileName(sAttachment);

                try
                {
                    if (!StringUtil.CompareIgnoreCase(sAttachment, sDstAttName))
                    {
                        if (!File.Exists(sAttachment))
                        {
                            oSrcAttachedFileManager.GetAttachment(sAttachment);
                        }

                        if (StringUtil.CompareIgnoreCase(sAttType, "EFI"))
                        {
                            // Special handling for EFIs
                            int nRetVal = FoLearn.CopyToNewEfi(
                                sAttachment,
                                sDstAttName);

                            if (nRetVal != 0)
                            {
                                throw new TisException("FoLearn.CopyToNewEfi failed, Code={0}", nRetVal);
                            }
                        }
                        else
                        {
                            // Copy local (cached)
                            File.Copy(
                                sAttachment,
                                sDstAttName,
                                true // Overwrite
                                );
                        }
                    }
                }
                catch (Exception oExc)
                {
                    Log.WriteException(oExc);

                    throw;
                }

                // Save to server
                oDstAttachedFileManager.SaveAttachment(
                    sDstAttName,
                    TIS_ATTACHMENT_EXISTS_ACTION.TIS_EXISTING_OVERRIDE);
            }
        }
예제 #14
0
 public void CloneDataTo(ITisDataLayerTreeNode oNode)
 {
     this.CloneDataTo((object)oNode);
 }
예제 #15
0
 public void CopyParametersTo(ITisDataLayerTreeNode oTarget)
 {
     CloneParametersTo(oTarget);
 }
예제 #16
0
        /// <summary>
        /// Get a CCEflowBaseObject  (that can be casted to the appropriate return type) from an eFlow dynamic or setup object (form, page, group, filed, table, field-array).
        /// </summary>
        /// <param name="creator">The CCreator to link to the objects ((optional)</param>
        /// <param name="eflowObject">The eFlow object to create a </param>
        /// <returns>a CCEflowBaseObject when successfull, null when not.</returns>
#if INTERNAL
        internal CCEflowBaseObject FromEflowObject(CCreator creator, ITisDataLayerTreeNode eflowObject)