当前位置: 首页>>代码示例>>C#>>正文


C# Common.ReuploadDoc方法代码示例

本文整理汇总了C#中Common.ReuploadDoc方法的典型用法代码示例。如果您正苦于以下问题:C# Common.ReuploadDoc方法的具体用法?C# Common.ReuploadDoc怎么用?C# Common.ReuploadDoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Common的用法示例。


在下文中一共展示了Common.ReuploadDoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DocumentReuploaded

        /// <summary>
        /// Reupload document, upload updated document to the original document server location
        /// </summary>
        /// <param name="logonId"></param>
        /// <param name="docSearchItem"></param>
        /// <returns></returns>
        private DocumentReturnValue DocumentReuploaded(DocumentSearchItem docSearchItem)
        {
            DocumentReturnValue returnValue = new DocumentReturnValue();
            string errorMessage = string.Empty;

            try
            {

                SrvDocument srvDoc = new SrvDocument();
                srvDoc.Id = docSearchItem.Id;

                if (docSearchItem.ProjectId != Guid.Empty)
                {
                    srvDoc.DocumentModuleId = docSearchItem.ProjectId;
                    srvDoc.Type = DmEnums.DmPMSDocType.Project;
                }
                else if (docSearchItem.MemberId != Guid.Empty)
                {
                    srvDoc.DocumentModuleId = docSearchItem.MemberId;
                    srvDoc.Type = DmEnums.DmPMSDocType.Member;
                }
                else if (docSearchItem.OrganisationId != Guid.Empty)
                {
                    srvDoc.DocumentModuleId = docSearchItem.OrganisationId;
                    srvDoc.Type = DmEnums.DmPMSDocType.Org;
                }

                // If document details is edited then Load default values in SrvDocument
                srvDoc.Load(docSearchItem.Id);

                // Don't set it while Editing Document
                srvDoc.VolumeId = 0;

                // Hardcoded
                srvDoc.ApplicationId = (int)DataConstants.Application.PMS;
                srvDoc.FolderName = "Documents";

                if (!srvDoc.IsUsedVersioning)
                    throw new Exception("Unable to reupload document as versioning is disabled. You may rename your document and retry.");

                srvDoc.Notes = docSearchItem.Notes;

                if (returnValue.Success)
                {
                    //FileStreamCreator fileStreamCreator = new FileStreamCreator();
                    if (!File.Exists(docSearchItem.FileName))
                    {
                        throw new Exception("Document is not uploaded.");
                    }
                    Common dmCommon = new Common();

                    try
                    {
                        string collection = dmCommon.GetOriginalDocFilePath(docSearchItem.Id);
                        string originalFilePath = GetValueOnIndexFromArray(collection, 0);
                        bool isEncrypted = Convert.ToBoolean(GetValueOnIndexFromArray(collection, 1));
                        bool local = Convert.ToBoolean(GetValueOnIndexFromArray(collection, 2));

                        if (!string.IsNullOrEmpty(originalFilePath))
                        {
                            // Reupload Document
                            // If existing document is in encrypted form, then the upadted doc will also be saved in encrypted format
                            if (dmCommon.ReuploadDoc(docSearchItem.Id, docSearchItem.FileName, isEncrypted, local))
                            {
                                FileInfo file = new FileInfo(docSearchItem.FileName);
                                if (File.Exists(originalFilePath))
                                {
                                    // Attempt to copy the file.
                                    file.CopyTo(originalFilePath, true);
                                }
                                // Save Document Details
                                returnValue.Success = srvDoc.Save(out errorMessage);
                            }
                            else
                            {
                                returnValue.Success = false;
                                returnValue.Message = "Reupload failed.";
                            }
                        }
                        else
                        {
                            returnValue.Success = false;
                            returnValue.Message = "System cannot able to find original file path location to reupload.";
                        }
                    }
                    catch (Exception ex)
                    {
                        returnValue.Success = false;
                        returnValue.Message = ex.Message;
                    }
                }
            }
            finally
            {
//.........这里部分代码省略.........
开发者ID:advanced-joelloyd,项目名称:UghWebforms,代码行数:101,代码来源:DocumentService.svc.cs


注:本文中的Common.ReuploadDoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。