Ejemplo n.º 1
0
        public bool Upload()
        {
            OA_DocumentService api = MossObject.GetMOSSAPI();

            string[] saveUrl = api.Upload(GetUploadFileInfo_new(), StreamToBytes(UploadFilesStream), this.DocumentEntry, false); //service上传
            UploadFullName = saveUrl[0];                                                                                         //全路径
            UploadURL      = saveUrl[1];                                                                                         //文件夹+文件名

            return(true);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 将附件下载为 字节流
 /// </summary>
 /// <param name="UCProcessType"></param>
 /// <param name="URL"></param>
 /// <returns></returns>
 public static Byte[] DownLoad(string UCProcessType, string URL)
 {
     Byte[] fileByte = null;
     if (OAConfig.GetConfig("MOSS认证", "是否启用DLL") == "1")
     {
         fileByte = DocumentManager.Download(MossObject.GetDownLoadFileInfo(UCProcessType, URL));
     }
     else
     {
         fileByte = MossObject.GetMOSSAPI().Download(MossObject.GetDownLoadFileInfo(UCProcessType, URL));
     }
     return(fileByte);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// MOSS附件大小
        /// </summary>
        /// <param name="UCProcessType"></param>
        /// <param name="URL"></param>
        /// <returns></returns>
        public static long FileLength(string UCProcessType, string URL)
        {
            long fileLength;

            if (OAConfig.GetConfig("MOSS认证", "是否启用DLL") == "1")
            {
                fileLength = DocumentManager.FileLength(MossObject.GetDownLoadFileInfo(UCProcessType, URL));
            }
            else
            {
                fileLength = MossObject.GetMOSSAPI().FileLength(MossObject.GetDownLoadFileInfo(UCProcessType, URL));
            }
            return(fileLength);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 将附件下载 写入文件
        /// </summary>
        /// <param name="UCProcessType"></param>
        /// <param name="URL"></param>
        /// <returns></returns>
        public static string DownLoad_New(string UCProcessType, string URL)
        {
            string filePath = null;

            string strTempFileName = "Download_OA_" + Current.UserName + "_";

            if (OAConfig.GetConfig("MOSS认证", "是否启用DLL") == "1")
            {
                filePath = DocumentManager.Download_New(MossObject.GetDownLoadFileInfo(UCProcessType, URL), strTempFileName);
            }
            else
            {
                filePath = MossObject.GetMOSSAPI().Download_New(MossObject.GetDownLoadFileInfo(UCProcessType, URL), strTempFileName);
            }
            return(filePath);
        }
Ejemplo n.º 5
0
        public static CFuJian Upload(UploadedFile file, string UCProcessType, string UCProcessID, string UCWorkItemID)
        {
            CFuJian cFuJian = new CFuJian();

            OA_DocumentService api = MossObject.GetMOSSAPI();

            string[] fileInfo = GetUploadFileInfo(UCProcessType, file.FileName);

            cFuJian.Type = System.IO.Path.GetExtension(file.FileName); //文件类型 扩展名
            if (cFuJian.Type.IndexOf('.') > -1)
            {
                cFuJian.Type = cFuJian.Type.Substring(1);
            }
            cFuJian.Alias = file.FileName.Substring(0, file.FileName.Length - cFuJian.Type.Length - 1); //别名
            //ff.Title = ff.Alias + "." + ff.Type;
            cFuJian.Title = fileInfo[3];
            if (cFuJian.Type.Length == 0)//没有扩展名
            {
                cFuJian.Alias = file.FileName;
            }
            cFuJian.Alias = cFuJian.Alias.Replace(" ", "");

            cFuJian.FolderName = fileInfo[2];

            cFuJian.FileName = fileInfo[3];

            cFuJian.Size        = MossObject.ToFileSize(file.ContentLength); //文件大小
            cFuJian.ProcessType = UCProcessType;
            cFuJian.WorkItemID  = UCWorkItemID;

            string[] saveUrl;

            #region DLL
            if (OAConfig.GetConfig("MOSS认证", "是否启用DLL") == "1")
            {
                #region 更新栏位
                List <System.Collections.DictionaryEntry> lst = new List <System.Collections.DictionaryEntry>();
                System.Collections.DictionaryEntry        de  = new System.Collections.DictionaryEntry();
                de.Key   = "流程实例";
                de.Value = UCProcessID;
                lst.Add(de);

                de       = new System.Collections.DictionaryEntry();
                de.Key   = "别名";
                de.Value = cFuJian.Alias;
                lst.Add(de);

                de       = new System.Collections.DictionaryEntry();
                de.Key   = "上次修改者";
                de.Value = CurrentUserInfo.DisplayName;
                lst.Add(de);
                #endregion

                System.Collections.DictionaryEntry[] result = DocumentManager.ConvertToDE(lst.ToArray());

                if (file.ContentLength <= MossObject.middleFileSize * 1024 * 1024)
                {
                    saveUrl = DocumentManager.Upload(fileInfo, MossObject.StreamToBytes(file.InputStream), result, false);
                }
                else
                {
                    string strFileTemp = "D:\\FileTemp\\";

                    if (System.IO.Directory.Exists(strFileTemp) == false)
                    {
                        System.IO.Directory.CreateDirectory(strFileTemp);
                    }

                    string fileTemp = strFileTemp + "OA" + Current.UserName + Path.GetFileNameWithoutExtension(file.TmpFile.Name);

                    string filePath = fileTemp + file.FileName;

p1:
                    if (System.IO.File.Exists(filePath))
                    {
                        filePath = fileTemp + new Random(1).Next(100).ToString() + file.FileName;
                        goto p1;
                    }
                    else
                    {
                        file.TmpFile.MoveTo(filePath);
                    }

                    saveUrl = DocumentManager.Upload(fileInfo, filePath, result, false);

                    File.Delete(filePath);
                }

                ////int ret = api.CopyTo(fileInfo, "322.doc", true);
                //file.TmpFile.Delete(); //删除临时文件
                //cFuJian.fullURL = saveUrl[0]; //全路径
                //cFuJian.URL = saveUrl[1];//文件夹+/文件名
                //cFuJian.Encode = "";//文件编码
                //return cFuJian;
            }
            #endregion

            #region webservice
            else
            {
                #region 更新栏位
                List <DictionaryEntry> lst = new List <DictionaryEntry>();
                DictionaryEntry        de  = new DictionaryEntry();
                de.Key   = "流程实例";
                de.Value = UCProcessID;
                lst.Add(de);

                de       = new DictionaryEntry();
                de.Key   = "别名";
                de.Value = cFuJian.Alias;
                lst.Add(de);

                de       = new DictionaryEntry();
                de.Key   = "上次修改者";
                de.Value = CurrentUserInfo.DisplayName;
                lst.Add(de);
                #endregion

                DictionaryEntry[] result = api.ConvertToDE(lst.ToArray());

                if (file.ContentLength <= MossObject.middleFileSize * 1024 * 1024)
                {
                    //上传到文档库
                    saveUrl = api.Upload(fileInfo, MossObject.StreamToBytes(file.InputStream), result, false);
                }
                else
                {
                    string strFileTemp = "D:\\FileTemp\\";

                    if (System.IO.Directory.Exists(strFileTemp) == false)
                    {
                        System.IO.Directory.CreateDirectory(strFileTemp);
                    }

                    string fileTemp = strFileTemp + "OA" + Current.UserName + Path.GetFileNameWithoutExtension(file.TmpFile.Name);

                    string filePath = fileTemp + file.FileName;

p1:
                    if (System.IO.File.Exists(filePath))
                    {
                        filePath = fileTemp + new Random(1).Next(100).ToString() + file.FileName;
                        goto p1;
                    }
                    else
                    {
                        file.TmpFile.MoveTo(filePath);
                    }

                    saveUrl = api.Upload_New(fileInfo, filePath, result, false);

                    File.Delete(filePath);
                }
            }

            #endregion

            file.TmpFile.Delete();        //删除临时文件

            cFuJian.fullURL = saveUrl[0]; //全路径
            cFuJian.URL     = saveUrl[1]; //文件夹+/文件名
            cFuJian.Encode  = "";         //文件编码
            return(cFuJian);
        }
Ejemplo n.º 6
0
        public DictionaryEntry[] ConvertToDE(DictionaryEntry[] entrys)
        {
            OA_DocumentService api = MossObject.GetMOSSAPI();

            return(api.ConvertToDE(entrys));
        }