/// <summary>
 /// Get relation type for this relation
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="options"></param>
 /// <returns></returns>
 public RelationType GetRelationType(SingleGetOptions options)
 {
     return(Client.GetSingleton <RelationType>(
                GetFullLinks(),
                LinkRelations.RELATION_TYPE.Rel,
                options));
 }
示例#2
0
 /// <summary>
 /// Get the cabinet resource where this folder locates at
 /// </summary>
 /// <param name="options"></param>
 /// <returns>Returns Cabinet object</returns>
 public new Cabinet GetCabinet(SingleGetOptions options)
 {
     return(Client.GetSingleton <Cabinet>(
                GetFullLinks(),
                LinkRelations.CABINET.Rel,
                options));
 }
示例#3
0
 /// <summary>
 /// Get the parent folder of this folder
 /// </summary>
 /// <param name="options"></param>
 /// <returns>Returns Folder object</returns>
 public new Folder GetParentFolder(SingleGetOptions options)
 {
     return(Client.GetSingleton <Folder>(
                GetFullLinks(),
                LinkRelations.PARENT.Rel,
                options));
 }
示例#4
0
 /// <summary>
 /// Get current login user resource
 /// </summary>
 /// <param name="options"></param>
 /// <returns>Feed</returns>
 public User GetCurrentUser(SingleGetOptions options)
 {
     return(Client.GetSingleton <User>(
                this.Links,
                LinkRelations.CURRENT_USER.Rel,
                options));
 }
 public D2Configurations GetD2Configurations(SingleGetOptions options)
 {
     return(Client.GetSingleton <D2Configurations>(
                this.Links,
                LinkRelations.D2_CONFIGURATION.Rel,
                options));
 }
示例#6
0
 /// <summary>
 /// Get the predecessor version of this document
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public Document GetPredessorVersion(SingleGetOptions options)
 {
     return(Client.GetSingleton <Document>(
                GetFullLinks(),
                LinkRelations.PREDECESSOR_VERSION.Rel,
                options));
 }
示例#7
0
 /// <summary>
 /// Get current version of this document
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public Document GetCurrentVersion(SingleGetOptions options)
 {
     return(Client.GetSingleton <Document>(
                GetFullLinks(),
                LinkRelations.CURRENT_VERSION.Rel,
                options));
 }
示例#8
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Global.Repository     = null; // set back to null to validate the new credentials.
            Global.Docbase        = txtDocbase.Text;
            Global.UserName       = txtUserName.Text;
            Global.Password       = txtPassword.Text;
            Global.RestServiceURL = txtRestUrl.Text;
            Repository repository = Global.GetRepository();

            if (repository != null)
            {
                lblLoginBanner.Text = "";
                SingleGetOptions options     = new SingleGetOptions();
                User             currentUser = repository.GetCurrentUser(options);
                lblUserInfo.Visible     = true;
                lblUserInfo.ForeColor   = System.Drawing.Color.Green;
                lblUserInfo.Text        = "User " + currentUser.GetPropertyValue("user_name").ToString() + " successfully logged in!";
                lblLoginBanner.CssClass = "message-success";
                Response.Redirect("DQL.aspx");
            }
            else
            {
                lblUserInfo.Visible   = true;
                lblUserInfo.ForeColor = System.Drawing.Color.Red;
                lblUserInfo.Text      = "Login Failed, try again!";
            }
        }
示例#9
0
 /// <summary>
 /// Create a new group in this repository
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="options"></param>
 /// <returns>Group</returns>
 public T CreateGroup <T>(T newGroup, SingleGetOptions options) where T : Group
 {
     return(Client.Post <T>(
                this.Links,
                LinkRelations.GROUPS.Rel,
                newGroup,
                options));
 }
示例#10
0
 /// <summary>
 /// Create a new relation types in this repository
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="options"></param>
 /// <returns>Relation</returns>
 public T CreateRelation <T>(T newRelation, SingleGetOptions options) where T : Relation
 {
     return(Client.Post <T>(
                this.Links,
                LinkRelations.RELATIONS.Rel,
                newRelation,
                options));
 }
示例#11
0
 /// <summary>
 /// Create a new relation types in this repository
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="options"></param>
 /// <returns>Relation</returns>
 public T CreateRelation <T>(T newRelation, SingleGetOptions options) where T : Relation
 {
     return(Client.Post <T>(
                this.Links,
                Emc.Documentum.Rest.Http.Utility.LinkRelations.RELATIONS.Rel,
                newRelation,
                options));
 }
示例#12
0
 /// <summary>
 /// Get the primary content resource of this document
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public ContentMeta GetPrimaryContent(SingleGetOptions options)
 {
     SetMediaUrlPolicy(options);
     return(Client.GetSingleton <ContentMeta>(
                GetFullLinks(),
                LinkRelations.PRIMARY_CONTENT.Rel,
                options));
 }
示例#13
0
 /// <summary>
 /// Create a new user in this repository
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="options"></param>
 /// <returns>User</returns>
 public T CreateUser <T>(T newUser, SingleGetOptions options) where T : User
 {
     return(Client.Post <T>(
                this.Links,
                LinkRelations.USERS.Rel,
                newUser,
                options));
 }
示例#14
0
        /// <summary>
        /// Get sysobject by ID.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="objectId"></param>
        /// <returns></returns>
        public T GetSysObjectById <T>(string objectId) where T : PersistentObject
        {
            SingleGetOptions options = new SingleGetOptions {
                Links = true
            };

            return(GetSysObjectById <T>(objectId, options));
        }
示例#15
0
        /// <summary>
        /// Get rendition by Modifier and Format for RestDocument
        /// </summary>
        /// <param name="modifier"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        public ContentMeta GetRenditionByModifierAndFormat(string modifier, string format)
        {
            SingleGetOptions mediaOptions = new SingleGetOptions {
                View = ":all"
            };

            SetMediaUrlPolicy(mediaOptions);
            SetFormat(mediaOptions, format);
            SetModifier(mediaOptions, modifier);
            return(GetPrimaryContent(mediaOptions));
        }
 /// <summary>
 /// If a persistent object is a raw object, this method can be called to fetch the object again with its links
 /// </summary>
 /// <returns>Returns List</returns>
 protected List <Link> GetFullLinks()
 {
     if (this.Links.Count == 1 && this.Links[0].Title.Equals(LinkRelations.SELF.Rel))
     {
         SingleGetOptions options = new SingleGetOptions {
             Links = true
         };
         PersistentObject refreshed = Client.GetSingleton <PersistentObject>(this.Links, LinkRelations.SELF.Rel, options);
         this.Links = refreshed.Links;
     }
     return(this.Links);
 }
示例#17
0
        private static void GetDefaultFolder(User user, bool printResult)
        {
            Console.WriteLine("\n\tGets the home cabinet of user'" + user.GetPropertyString("user_name") + "'..");
            SingleGetOptions options = new SingleGetOptions();

            options.View  = ":default";
            options.Links = true;
            Folder defaultFolder = user.GetHomeCabinet(options);

            if (printResult)
            {
                Console.WriteLine(defaultFolder == null ? "NULL" : defaultFolder.ToString());
            }
        }
 /// <summary>
 /// Get parent type for this type
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public DmType GetParentType(SingleGetOptions options)
 {
     if (LinkRelations.FindLinkAsString(GetFullLinks(), LinkRelations.PARENT.Rel) == null)
     {
         return(null);
     }
     else
     {
         return(Client.GetSingleton <DmType>(
                    GetFullLinks(),
                    LinkRelations.PARENT.Rel,
                    options));
     }
 }
示例#19
0
        /// <summary>
        /// Get object by dql qualification
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dql"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public T GetObjectByQualification <T>(string dql, SingleGetOptions options)
        {
            dql = "select r_object_id from " + dql;
            Feed <PersistentObject> feed = ExecuteDQL <PersistentObject>(dql, new FeedGetOptions {
                Inline = false
            });

            if (feed.Entries == null || feed.Entries.Count == 0)
            {
                return(default(T));
            }
            if (feed.Entries.Count > 1)
            {
                throw new Exception("The qualification '" + dql + "' has more than one object in repository.");
            }
            return(Client.GetSingleton <T>(feed.Entries[0].Links, LinkRelations.EDIT.Rel, options));
        }
 /// <summary>
 /// Get relation type for this relation
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="options"></param>
 /// <returns></returns>
 public T GetChild <T>(SingleGetOptions options) where T : PersistentObject
 {
     // child link relation is not returned by feed for performance
     if (LinkRelations.FindLinkAsString(GetFullLinks(), LinkRelations.CHILD.Rel) == null)
     {
         this.Links = this.Fetch <Relation>().Links;
     }
     if (LinkRelations.FindLinkAsString(GetFullLinks(), LinkRelations.CHILD.Rel) == null)
     {
         return(null);
     }
     else
     {
         return(Client.GetSingleton <T>(
                    GetFullLinks(),
                    LinkRelations.CHILD.Rel,
                    options));
     }
 }
示例#21
0
 /// <summary>
 /// Get a document by a Dql qualification
 /// </summary>
 /// <param name="dql"></param>
 /// <param name="options"></param>
 /// <returns>RestDocument</returns>
 public Document GetDocumentByQualification(string dql, SingleGetOptions options)
 {
     return(GetObjectByQualification <Document>(dql, options));
 }
示例#22
0
        public static EmailPackage getFeedAsEmailPackage(Feed <Document> feed)
        {
            RestController client = feed.Client;

            if (client == null)
            {
                throw new Exception("CLIENTNULLEXCEPTION: the feed passed does not have its client set, no operations are possible without this.");
            }
            long             tStart  = DateTime.Now.Ticks;
            SingleGetOptions options = new SingleGetOptions {
                Links = true
            };
            EmailPackage             emailPkg   = null;;
            List <Entry <Document> > entries    = feed.Entries;
            Entry <Document>         emailEntry = (from k in entries where (k.Title != null && k.Title.Equals("EMAIL")) select k).FirstOrDefault();
            var attachmentEntry = (from a in entries where (a.Title != null && a.Title.Equals("ATTACHMENT")) select a.Content);

            if (emailEntry == null)
            {
                return(null);
            }

            string   objectId = emailEntry.Content.GetPropertyValue("r_object_id").ToString();
            Document document = null;

            //todo
            //client.getDocumentByQualification(
            //String.Format("dm_document where r_object_id = '{0}'", objectId),
            //new FeedGetOptions { Inline = true, Links = true });

            emailPkg = new EmailPackage(document, feed.Title.StartsWith("DUPLICATE"));
            if (emailPkg.IsDuplicate)
            {
                if (feed.Title.Equals("DUPLICATE"))
                {
                    feed.Client.Logger.WriteToLog(Rest.Utility.LogLevel.WARNING, "EmailImport", "API on the server is out of date"
                                                  + "and will not search for duplicates in the System, only Folder.", new Exception("SERVERAPIOUTDATED"));
                }
                // Determine Duplicate Type and fill it in
                if (feed.Title.Equals("DUPLICATE-FOLDER"))
                {
                    emailPkg.DuplicateType = DuplicateType.FOLDER;
                }
                else
                {
                    emailPkg.DuplicateType = DuplicateType.SYSTEM;
                }
            }

            //string extension = (from k in map where k.Value.Equals(format) select k.Key).FirstOrDefault();

            foreach (Document attachment in attachmentEntry)
            {
                string   attachmentId = attachment.GetPropertyValue("r_object_id").ToString();
                Document attDocument  = null;
                // todo
                // client.GetObjectById<Document>(attachmentId, options);
                emailPkg.Attachments.Add(attDocument);
            }
            client.Logger.WriteToLog(Rest.Utility.LogLevel.DEBUG, "EmailFeedToPackage",
                                     "Conversion took " + ((DateTime.Now.Ticks - tStart) / TimeSpan.TicksPerMillisecond) + "ms", "TIMING");
            return(emailPkg);
        }
示例#23
0
 /// <summary>
 /// Get sysobject by object ID
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="objectId"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public T GetSysObjectById <T>(string objectId, SingleGetOptions options) where T : PersistentObject
 {
     return(GetObjectByQualification <T>(String.Format("dm_sysobject where r_object_id='{0}'", objectId), options));
 }
示例#24
0
 /// <summary>
 /// Get the associated document resource of this content
 /// </summary>
 /// <param name="options"></param>
 /// <returns>Returns a RestDocument object </returns>
 public Document GetParentDocument(SingleGetOptions options)
 {
     return(Client.GetSingleton <Document>(this.Links, LinkRelations.PARENT.Rel, options));
 }
示例#25
0
 /// <summary>
 /// Get object by dql qualification
 /// </summary>
 /// <param name="dql"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public PersistentObject GetObjectByQualification(string dql, SingleGetOptions options)
 {
     return(GetObjectByQualification <PersistentObject>(dql, options));
 }
 /// <summary>
 /// Get the home cabinet (default folder) resource of the user
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public Cabinet GetHomeCabinet(SingleGetOptions options)
 {
     return(Client.GetSingleton <Cabinet>(GetFullLinks(), LinkRelations.DEFAULT_FOLDER.Rel, options));
 }
        /// <summary>
        /// Exports a file(s) to a zip file based on a qualifying DQL statement
        /// </summary>
        /// <param name="query"></param>
        /// <param name="folderName"></param>
        /// <param name="zipFileName"></param>
        /// <returns>FileInfo</returns>
        private FileInfo ExportToZip(string query, string folderName, string zipFileName)
        {
            try
            {
                Feed <PersistentObject> queryResult = ExecuteDQL <PersistentObject>(query, new FeedGetOptions()
                {
                    ItemsPerPage = 100, IncludeTotal = true
                });
                if (queryResult != null && queryResult.Total > 0)
                {
                    int    totalResults         = queryResult.Total;
                    double totalPages           = queryResult.PageCount;
                    int    docProcessed         = 0;
                    Dictionary <string, int> kp = new Dictionary <string, int>();

                    for (int i = 0; i < totalPages; i++)
                    {
                        List <PersistentObject> objs = ObjectUtil.getFeedAsList(queryResult, false);
                        foreach (PersistentObject obj in objs)
                        {
                            SingleGetOptions options = new SingleGetOptions();
                            options.SetQuery("media-url-policy", "local");
                            Document    doc = GetSysObjectById <Document>(obj.GetPropertyValue("r_object_id").ToString());// getDocumentByQualification("dm_document where r_object_id='" + obj.getAttributeValue("r_object_id") + "'", null);
                            ContentMeta primaryContentMeta    = doc.GetPrimaryContent(options);
                            FileInfo    downloadedContentFile = primaryContentMeta.DownloadContentMediaFile();
                            // string path = "c:/temp/case" + obj.getAttributeValue("r_folder_path").ToString();
                            string filename = downloadedContentFile.Name;

                            // If a file that is the same name is exported, give it a unique name
                            if (kp.Keys.Contains(filename))
                            {
                                int len = filename.LastIndexOf(".");
                                if (len < 0)
                                {
                                    len = filename.Length;
                                }
                                kp[filename] += 1;
                                string insertinto = "_" + kp[filename].ToString();
                                filename = filename.Insert(len, insertinto);
                                kp.Add(filename, 0);
                            }
                            else
                            {
                                kp.Add(filename, 0);
                            }


                            string zipPath = "";
                            if (folderName == null)
                            {
                                zipPath = Path.AltDirectorySeparatorChar + filename;
                                //zipPath = zipPath.Replace(@"/", @"\");
                            }
                            else
                            {
                                zipPath = obj.GetPropertyValue("r_folder_path").ToString();
                                zipPath = zipPath.Substring(zipPath.IndexOf(folderName));
                                if (zipPath.Length == 0)
                                {
                                    zipPath = zipPath + filename;
                                }
                                else
                                {
                                    zipPath = zipPath + Path.AltDirectorySeparatorChar + filename;
                                }
                                //zipPath = zipPath.Replace(@"/", @"\");
                                //pathinzip = pathinzip.Substring(pathinzip.IndexOf(@"\") + 1);
                            }
                            AddFileToZipArchive(downloadedContentFile, zipPath, new FileInfo(zipFileName));
                            docProcessed++;
                        }

                        if (totalResults != docProcessed)
                        {
                            queryResult = queryResult.NextPage();
                        }
                    }
                } // End if query result null
                else
                {
                    throw new Exception("NORESULTSTOZIP: Query returned no results - " + query);
                }
            }
            catch (Exception e)
            {
                Client.Logger.WriteToLog(Utility.LogLevel.DEBUG, "ZIPEXPORT", "ZIP EXPORT FAILED: ", e);
            }
            return(null);
        }