Esempio n. 1
0
        public ActionResult OperateSite()
        {
            //NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
            InvokeResult result = new InvokeResult();

            var siteName = PageReq.GetForm("siteName");
            var opType   = PageReq.GetForm("opType");
            var path     = PageReq.GetForm("path");

            var serverId = PageReq.GetFormInt("serverId");
            var server   = dataOp.FindOneByQuery("ServerInfo", Query.EQ("serverId", serverId.ToString()));

            MZ.BusinessLogicLayer.WebService.RemoteIISSites client = new BusinessLogicLayer.WebService.RemoteIISSites(server.String("serverAddress"));
            var isSuccess = client.OperateWebSite(siteName, opType);

            if (isSuccess)
            {
                result.Status = Status.Successful;
            }
            else
            {
                result.Status = Status.Failed;
            }
            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Esempio n. 2
0
        public string SaveTZCADDWGFile(FormCollection saveForm)
        {
            DataOperation dataOp = new DataOperation();

            Session["userId"] = PageReq.GetFormInt("userId");
            string oldGuid2d   = PageReq.GetForm("oldguid2d");
            bool   isPreDefine = saveForm["isPreDefine"] != null?bool.Parse(saveForm["isPreDefine"]) : false;

            BsonDocument oldfileDoc = dataOp.FindOneByKeyVal("FileLibrary", "guid2d", oldGuid2d);

            #region 判断是否是新建地块
            int isNewProj = PageReq.GetFormInt("isNewProj");

            if (isNewProj == 1)
            {
                InvokeResult newProjRet = new InvokeResult();

                int    nodePid   = PageReq.GetFormInt("nodePid");
                string name      = PageReq.GetForm("name");
                int    typeObjId = 9;

                if (nodePid > 0)
                {
                    newProjRet = dataOp.Insert("ProjectNode", new BsonDocument().Add("name", name).Add("nodePid", nodePid.ToString()).Add("typeObjId", typeObjId.ToString()));
                }

                saveForm["keyValue"] = newProjRet.BsonInfo.String("nodeId");
            }
            #endregion

            if (saveForm["fileObjId"].ToString() == "57")   //如果文档类型是变更单,则直接进入保存
            {
                return(this.SaveMultipleUploadFiles(saveForm));
            }

            if (oldfileDoc == null)
            {
                return(this.SaveMultipleUploadFiles(saveForm));
            }
            else
            {
                return(this.SaveDWGNewVersion(saveForm, oldfileDoc, dataOp));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 上传多个文件
        /// </summary>
        /// <param name="saveForm"></param>
        /// <returns></returns>
        public string SaveMultipleUploadFiles(FormCollection saveForm)
        {
            DataOperation dataOp = new DataOperation();

            string tableName    = PageReq.GetForm("tableName");
            string keyName      = PageReq.GetForm("keyName");
            string keyValue     = saveForm["keyValue"].ToString();
            string localPath    = PageReq.GetForm("uploadFileList");
            string fileSaveType = saveForm["fileSaveType"] != null ? saveForm["fileSaveType"] : "multiply";
            int    fileTypeId   = PageReq.GetFormInt("fileTypeId");
            int    fileObjId    = PageReq.GetFormInt("fileObjId");
            int    uploadType   = PageReq.GetFormInt("uploadType");
            string subMapParam  = PageReq.GetForm("subMapParam");
            string guid2d       = PageReq.GetForm("guid2d");
            string oldGuid2d    = PageReq.GetForm("oldguid2d");
            bool   isPreDefine  = saveForm["isPreDefine"] != null?bool.Parse(saveForm["isPreDefine"]) : false;

            Dictionary <string, string> propDic  = new Dictionary <string, string>();
            FileOperationHelper         opHelper = new FileOperationHelper();
            List <InvokeResult <FileUploadSaveResult> > result = new List <InvokeResult <FileUploadSaveResult> >();

            localPath = localPath.Replace("\\\\", "\\");

            #region 如果保存类型为单个single 则删除旧的所有关联文件
            if (!string.IsNullOrEmpty(fileSaveType))
            {
                if (fileSaveType == "single")
                {
                    opHelper.DeleteFile(tableName, keyName, keyValue);
                }
            }
            #endregion

            #region 通过关联读取对象属性
            if (!string.IsNullOrEmpty(localPath.Trim()))
            {
                string[] fileStr = Regex.Split(localPath, @"\|H\|", RegexOptions.IgnoreCase);
                Dictionary <string, string> filePath = new Dictionary <string, string>();
                foreach (string file in fileStr)
                {
                    string[] filePaths = Regex.Split(file, @"\|Y\|", RegexOptions.IgnoreCase);

                    if (filePaths.Length > 0)
                    {
                        string[] subfile = Regex.Split(filePaths[0], @"\|Z\|", RegexOptions.IgnoreCase);
                        if (subfile.Length > 0)
                        {
                            if (!filePath.Keys.Contains(subfile[0]))
                            {
                                if (filePaths.Length >= 2)
                                {
                                    filePath.Add(subfile[0], filePaths[1]);
                                }
                                else
                                {
                                    filePath.Add(subfile[0], "");
                                }
                            }
                        }
                    }
                }

                if (fileObjId != 0)
                {
                    List <BsonDocument> docs = new List <BsonDocument>();
                    docs = dataOp.FindAllByKeyVal("FileObjPropertyRelation", "fileObjId", fileObjId.ToString()).ToList();

                    List <string> strList = new List <string>();
                    strList = docs.Select(t => t.Text("filePropId")).Distinct().ToList();
                    var doccList = dataOp.FindAllByKeyValList("FileProperty", "filePropId", strList);
                    foreach (var item in doccList)
                    {
                        var formValue = saveForm[item.Text("dataKey")];
                        if (formValue != null)
                        {
                            propDic.Add(item.Text("dataKey"), formValue.ToString());
                        }
                    }
                }

                List <FileUploadObject> singleList = new List <FileUploadObject>(); //纯文档上传
                List <FileUploadObject> objList    = new List <FileUploadObject>(); //当前传入类型文件上传
                foreach (var str in filePath)
                {
                    FileUploadObject obj = new FileUploadObject();
                    obj.fileTypeId   = fileTypeId;
                    obj.fileObjId    = fileObjId;
                    obj.localPath    = str.Key;
                    obj.tableName    = tableName;
                    obj.keyName      = keyName;
                    obj.keyValue     = keyValue;
                    obj.uploadType   = uploadType;
                    obj.isPreDefine  = isPreDefine;
                    obj.isCover      = false;
                    obj.propvalueDic = propDic;
                    obj.rootDir      = str.Value;
                    obj.subMapParam  = subMapParam;
                    obj.guid2d       = guid2d;
                    if (uploadType != 0 && (obj.rootDir == "null" || obj.rootDir.Trim() == ""))
                    {
                        singleList.Add(obj);
                    }
                    else
                    {
                        objList.Add(obj);
                    }
                }

                result = opHelper.UploadMultipleFiles(objList, (UploadType)uploadType);//(UploadType)uploadType
                if (singleList.Count > 0)
                {
                    result = opHelper.UploadMultipleFiles(singleList, (UploadType)0);
                }
            }
            else
            {
                PageJson jsonone = new PageJson();
                jsonone.Success = false;
                return(jsonone.ToString() + "|");
            }
            #endregion

            PageJson json = new PageJson();
            var      ret  = opHelper.ResultConver(result);

            #region 如果有关联的文件Id列表,则保存关联记录
            string     fileVerIds    = PageReq.GetForm("fileVerIds");
            List <int> fileVerIdList = fileVerIds.SplitToIntList(",");

            if (ret.Status == Status.Successful && fileVerIdList.Count > 0)
            {
                List <StorageData> saveList = new List <StorageData>();
                foreach (var tempVerId in fileVerIdList)
                {
                    StorageData tempData = new StorageData();

                    tempData.Name     = "FileAlterRelation";
                    tempData.Type     = StorageType.Insert;
                    tempData.Document = new BsonDocument().Add("alterFileId", result.FirstOrDefault().Value.fileId.ToString())
                                        .Add("fileVerId", tempVerId);

                    saveList.Add(tempData);
                }

                dataOp.BatchSaveStorageData(saveList);
            }
            #endregion

            json.Success = ret.Status == Status.Successful ? true : false;
            var strResult = json.ToString() + "|" + ret.Value + "|" + keyValue;
            return(strResult);
        }