/// <summary> /// 安装字段 /// </summary> /// <param name="FieldName"></param> /// <param name="bpm"></param> public static Int32 InstallField(String FieldName, basePortalModule bpm) { DNNGo_PowerForms_Field fieldItem = new DNNGo_PowerForms_Field(); fieldItem.Name = fieldItem.Alias = fieldItem.ToolTip = FieldName; if (FieldName.IndexOf("Name", StringComparison.CurrentCultureIgnoreCase) >= 0) { fieldItem.FieldType = (Int32)EnumViewControlType.TextBox_DisplayName; fieldItem.Required = 1; } else if (FieldName.IndexOf("Email", StringComparison.CurrentCultureIgnoreCase) >= 0) { fieldItem.FieldType = (Int32)EnumViewControlType.TextBox_Email; fieldItem.Verification = (Int32)EnumVerification.email; fieldItem.Required = 1; } else if (FieldName.IndexOf("Messages", StringComparison.CurrentCultureIgnoreCase) >= 0) { fieldItem.FieldType = (Int32)EnumViewControlType.TextBox; fieldItem.Rows = 4; } QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, bpm.ModuleId, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, fieldItem.Name, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) == 0) { fieldItem.ModuleId = bpm.ModuleId; fieldItem.PortalId = bpm.PortalId; fieldItem.Sort = DNNGo_PowerForms_Field.FindCount(DNNGo_PowerForms_Field._.ModuleId, bpm.ModuleId) + 1; fieldItem.Status = 1; fieldItem.LastTime = xUserTime.UtcTime(); fieldItem.LastUser = bpm.UserId; fieldItem.LastIP = WebHelper.UserHost; return(fieldItem.Insert()); } return(0); }
/// <summary> /// 验证字段名是否重复 /// </summary> /// <returns></returns> private String ValidationCustomFieldName(string validateId, string validateValue, string validateError) { String validateJSON = "true"; Int32 ModuleID = WebHelper.GetIntParam(Request, "ModuleID", 0); QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, validateValue, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleID, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) > 0) { validateJSON = "false"; } return(validateJSON); }
protected void cmdExportAll_Click(object sender, EventArgs e) { try { QueryParam qp = new QueryParam(); qp.OrderType = 1; qp.Orderfld = DNNGo_PowerForms_Content._.ID; qp.PageSize = int.MaxValue; qp.Where = BindSearch(); Int32 RecordCount = 0; List <DNNGo_PowerForms_Content> DataList = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount); if (DataList != null && DataList.Count > 0) { try { String FullName = String.Empty; if (CsvHelper.SaveAsToFile(FieldList, DataList, out FullName, this)) { FileSystemUtils.DownloadFile(FullName, Path.GetFileName(FullName)); //Response.Write(FullName); } else { //导出记录失败 mTips.IsPostBack = true; mTips.LoadMessage("SaveExportRecordsError", EnumTips.Error, this, new String[] { FullName }); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// 验证字段名是否重复 /// </summary> /// <returns></returns> private String ValidationFieldName(string validateId, string validateValue, string validateError) { String validateJSON = String.Empty; Int32 ModuleID = WebHelper.GetIntParam(Request, "ModuleID", 0); QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, validateValue, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleID, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) > 0) { validateJSON = "{\"jsonValidateReturn\":[\"" + validateId + "\",\"" + validateError + "\",false]}";//验证不通过 } else { validateJSON = "{\"jsonValidateReturn\":[\"" + validateId + "\",\"" + validateError + "\",true]}";//验证通过 } return(validateJSON); }
/// <summary> /// 显示表单信息 /// </summary> /// <returns></returns> public Boolean DisplayForm() { Boolean _DisplayForm = true; Boolean LoginUserDisplay = ViewSettingT <Boolean>("PowerForms_LoginUserDisplay", false); if (LoginUserDisplay) { if (UserId > 0) { String FormVersion = ViewSettingT <String>("PowerForms_FormVersion", ""); if (!String.IsNullOrEmpty(FormVersion)) { //根据条件判断该用户是否提交过了。 QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.ModuleId, ModuleId, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.FormVersion, FormVersion, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.LastUser, UserId, SearchType.Equal)); if (DNNGo_PowerForms_Content.FindCount(qp) > 0) { _DisplayForm = false;//如果已经提交过表单,则不显示 } } } else { _DisplayForm = false;//需要登陆且没有登陆时不显示表单 } } //检查是否需要登陆用户可见 return(_DisplayForm); }
/// <summary> /// 绑定数据 /// </summary> private void BindDataToPage() { //tdControl.Visible = IsAdministrator; cmdDelete.Visible = IsAdministrator; cmdCleanup.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("CleanupConfirm", "") + "');"); QueryParam qp = new QueryParam(); qp.OrderType = OrderType; if (!String.IsNullOrEmpty(Orderfld)) { qp.Orderfld = Orderfld; } else { qp.Orderfld = DNNGo_PowerForms_Content._.ID; } #region "分页的一系列代码" int RecordCount = 0; int pagesize = qp.PageSize = Settings_PageSize; qp.PageIndex = PageIndex; #endregion //查询的方法 qp.Where = BindSearch(); List <DNNGo_PowerForms_Content> Articles = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount); qp.RecordCount = RecordCount; RecordPages = qp.Pages; repeaterContent.DataSource = Articles; repeaterContent.DataBind(); }
/// <summary> /// 验证隐藏域 /// </summary> /// <returns></returns> public Boolean VerificationHiddenfields(ref Boolean RepeatSubmitted) { Boolean HiddenfieldsVerify = true; String VerifyEncrypt = WebHelper.GetStringParam(Request, hfVerifyEncrypt.UniqueID, "", false); String VerifyString = WebHelper.GetStringParam(Request, hfVerifyString.UniqueID, "", false); if (!String.IsNullOrEmpty(VerifyEncrypt) && !String.IsNullOrEmpty(VerifyString)) { try { String DecryptString = CryptionHelper.DecryptString1(VerifyEncrypt, Settings_Hiddenfields_EncryptionKey);//CryptionHelper.DecryptString(VerifyEncrypt, Settings_Hiddenfields_EncryptionKey); if (!String.IsNullOrEmpty(DecryptString) && VerifyString == DecryptString) { //查询该信息是否为重复提交的 QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.VerifyString, VerifyString, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Content._.LastTime, xUserTime.UtcTime().AddMinutes(-Settings_Hiddenfields_VerifyIntervalTime), SearchType.GtEqual)); if (DNNGo_PowerForms_Content.FindCount(qp) > 0) { RepeatSubmitted = false; } } else { HiddenfieldsVerify = false; } } catch { HiddenfieldsVerify = false; } } else { HiddenfieldsVerify = false; } return(HiddenfieldsVerify); }
/// <summary> /// 绑定右边列表 /// </summary> private void BindDataList() { QueryParam qp = new QueryParam(); qp.PageSize = 10; qp.PageIndex = PageIndex; qp.Orderfld = Orderfld; qp.OrderType = OrderType; int RecordCount = 0; //查询的方法 qp.Where = BindSearch(); List <DNNGo_PowerForms_Group> lst = DNNGo_PowerForms_Group.FindAll(qp, out RecordCount); qp.RecordCount = RecordCount; RecordPages = qp.Pages; lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages")); gvArticleList.DataSource = lst; gvArticleList.DataBind(); }
/// <summary> /// 从XML导入数据 /// </summary> protected void cmdImportFormXml_Click(object sender, EventArgs e) { try { HttpPostedFile hpfile = fuImportFormXml.PostedFile; if (hpfile.ContentLength > 0) { if (Path.GetExtension(hpfile.FileName).IndexOf(".xml", StringComparison.CurrentCultureIgnoreCase) >= 0) { ImportExportHelper ieHelper = new ImportExportHelper(); ieHelper.ModuleID = ModuleId; ieHelper.UserId = UserId; //先清除原有的字段列表 QueryParam qp = new QueryParam(); Int32 RecordCount = 0; qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal)); List <DNNGo_PowerForms_Field> fieldList = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount); foreach (DNNGo_PowerForms_Field fieldItem in fieldList) { fieldItem.Delete(); } //构造需要上传的路径 String XmlFilePath = String.Format("{0}PowerForms\\Import\\{1}_{2}", PortalSettings.HomeDirectoryMapPath, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff"), fuImportFormXml.FileName); FileInfo XmlFile = new FileInfo(XmlFilePath); //判断文件夹是否存在 if (!XmlFile.Directory.Exists) { XmlFile.Directory.Create(); } //保存文件 fuImportFormXml.SaveAs(XmlFilePath); XmlFormat xf = new XmlFormat(XmlFilePath); List <FieldEntity> XmlFieldList = xf.ToList <FieldEntity>(); Int32 InsertResult = 0; foreach (FieldEntity XmlField in XmlFieldList) { DNNGo_PowerForms_Field FieldItem = ieHelper.XmlToEntity(XmlField); FieldItem.CreateUser = UserId; FieldItem.CreateTime = xUserTime.UtcTime(); FieldItem.ModuleId = ModuleId; FieldItem.PortalId = PortalId; FieldItem.LastIP = WebHelper.UserHost; FieldItem.LastTime = xUserTime.UtcTime(); FieldItem.LastUser = UserId; if (FieldItem.Insert() > 0) { InsertResult++; } } //提示 mTips.LoadMessage("ImportFieldSuccess", EnumTips.Success, this, new String[] { InsertResult.ToString() }); //跳转 Response.Redirect(xUrl("FieldList")); } else { //上传文件的后缀名错误 mTips.IsPostBack = true; mTips.LoadMessage("UploadFieldExtensionError", EnumTips.Warning, this, new String[] { "xml" }); } } else { //为上传任何数据 mTips.IsPostBack = true; mTips.LoadMessage("ImportFieldNullError", EnumTips.Success, this, new String[] { "" }); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
// Upload entire file private void UploadWholeFile(HttpContext context, List <Resource_FilesStatus> statuses) { for (int i = 0; i < context.Request.Files.Count; i++) { var file = context.Request.Files[i]; if (file != null && !String.IsNullOrEmpty(file.FileName) && file.ContentLength > 0) { //To verify that if the suffix name of the uploaded files meets the DNN HOST requirements Boolean retValue = FileSystemUtils.CheckValidFileName(file.FileName); if (retValue) { DNNGo_PowerForms_Files PhotoItem = new DNNGo_PowerForms_Files(); PhotoItem.ModuleId = WebHelper.GetIntParam(context.Request, "ModuleId", 0); PhotoItem.PortalId = WebHelper.GetIntParam(context.Request, "PortalId", 0); PhotoItem.FileName = file.FileName; PhotoItem.FileSize = file.ContentLength / 1024; PhotoItem.FileMate = FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", "")); PhotoItem.FileExtension = System.IO.Path.GetExtension(PhotoItem.FileName).Replace(".", ""); PhotoItem.Name = System.IO.Path.GetFileName(file.FileName).Replace(Path.GetExtension(PhotoItem.FileName), ""); PhotoItem.Status = (Int32)EnumFileStatus.Approved; try { if (("png,gif,jpg,jpeg,bmp").IndexOf(PhotoItem.FileExtension) >= 0) { //图片的流 Image image = Image.FromStream(file.InputStream); PhotoItem.ImageWidth = image.Width; PhotoItem.ImageHeight = image.Height; PhotoItem.Exif = Common.Serialize <EXIFMetaData.Metadata>(new EXIFMetaData().GetEXIFMetaData(image)); } } catch { } PhotoItem.LastTime = xUserTime.UtcTime(); PhotoItem.LastIP = WebHelper.UserHost; PhotoItem.LastUser = UserInfo.UserID; //将文件存储的路径整理好 String fileName = System.IO.Path.GetFileName(file.FileName).Replace("." + PhotoItem.FileExtension, ""); //文件名称 String WebPath = String.Format("PowerForms/uploads/{0}/{1}/{2}/", xUserTime.UtcTime().Year, xUserTime.UtcTime().Month, xUserTime.UtcTime().Day); //检测文件存储路径是否有相关的文件 FileInfo fInfo = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension))); //检测文件夹是否存在 if (!System.IO.Directory.Exists(fInfo.Directory.FullName)) { System.IO.Directory.CreateDirectory(fInfo.Directory.FullName); } else { Int32 j = 1; while (fInfo.Exists) { //文件已经存在了 fileName = String.Format("{0}_{1}", PhotoItem.Name, j); fInfo = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension))); j++; } } PhotoItem.FilePath = String.Format("{0}{1}.{2}", WebPath, fileName, PhotoItem.FileExtension); PhotoItem.FileName = String.Format("{0}.{1}", fileName, PhotoItem.FileExtension); try { if (!fInfo.Directory.Exists) { fInfo.Directory.Create(); // FileSystemUtils.AddFolder(PortalSettings, String.Format("{0}DNNGo_PhotoAlbums/{0}/{1}/"), String.Format("{0}DNNGo_PhotoAlbums/{0}/{1}/"), (int)DotNetNuke.Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem); } //构造指定存储路径 file.SaveAs(fInfo.FullName); //FileSystemUtils.AddFile(PhotoItem.FileName, PhotoItem.PortalId, String.Format("DNNGo_PhotoAlbums\\{0}\\{1}\\", PhotoItem.ModuleId, PhotoItem.AlbumID), PortalSettings.HomeDirectoryMapPath, PhotoItem.FileMeta); } catch (Exception ex) { } //给上传的相片设置初始的顺序 QueryParam qp = new QueryParam(); qp.ReturnFields = qp.Orderfld = DNNGo_PowerForms_Files._.Sort; qp.OrderType = 1; qp.Where.Add(new SearchParam(DNNGo_PowerForms_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal)); PhotoItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Files.FindScalar(qp)) + 2; Int32 PhotoId = PhotoItem.Insert(); statuses.Add(new Resource_FilesStatus(PhotoItem, PortalSettings, ModulePath)); } } } }
/// <summary> /// 设置方案项 /// </summary> private Int32 SetDataItem(Int32 ArticleStatus, out DNNGo_PowerForms_Field fieldItem) { fieldItem = FieldItem; //权限 fieldItem.Per_AllUsers = cbPermissionsAllUsers.Checked ? 0 : 1; String textStr, idStr = String.Empty; WebHelper.GetSelected(cblPermissionsRoles, out textStr, out idStr); fieldItem.Per_Roles = idStr; if (ddlControlType.Enabled) { fieldItem.FieldType = WebHelper.GetIntParam(Request, ddlControlType.UniqueID, (Int32)EnumViewControlType.TextBox); } fieldItem.ToolTip = txtToolTip.Text; fieldItem.Alias = txtAlias.Text; fieldItem.Description = txtDescription.Text; fieldItem.Required = cbRequired.Checked ? 1 : 0; fieldItem.Options = SetItemSettings(); if (divGroup.Visible) { SettingEntity GroupControl = new SettingEntity(); GroupControl.Name = "GroupControl"; Int32 GroupID = 0; if (int.TryParse(ControlHelper.GetWebFormValue(GroupControl, this), out GroupID)) { } fieldItem.GroupID = GroupID; } fieldItem.FiledList = txtFTListCollection.Text; if (fieldItem.FieldType == (Int32)EnumViewControlType.Html || fieldItem.FieldType == (Int32)EnumViewControlType.RichTextBox) { fieldItem.DefaultValue = txtTinymceDefaultValue.Text; } else { fieldItem.DefaultValue = txtFTDefaultValue.Text; } fieldItem.Rows = WebHelper.GetIntParam(Request, txtFTRows.UniqueID, 1); fieldItem.Verification = WebHelper.GetIntParam(Request, ddlVerification.UniqueID, 0); fieldItem.Direction = WebHelper.GetIntParam(Request, rblFTDirection.UniqueID, 0); fieldItem.ListColumn = WebHelper.GetIntParam(Request, txtFTListColumn.UniqueID, 1); fieldItem.Width = WebHelper.GetIntParam(Request, txtFTWidth.UniqueID, 100); fieldItem.WidthSuffix = WebHelper.GetIntParam(Request, ddlFTWidth.UniqueID, 0); fieldItem.EqualsControl = WebHelper.GetIntParam(Request, ddlFTEqualsControl.UniqueID, 0); fieldItem.AssociatedControl = WebHelper.GetIntParam(Request, ddlFTAssociatedControl.UniqueID, 0); fieldItem.InputLength = WebHelper.GetIntParam(Request, txtFTInputLength.UniqueID, 2000); fieldItem.LastTime = xUserTime.UtcTime(); fieldItem.LastUser = UserId; fieldItem.LastIP = WebHelper.UserHost; //发布状态和时间 DateTime oTime = xUserTime.LocalTime(); string[] expectedFormats = { "G", "g", "f", "F" }; string StartDate = WebHelper.GetStringParam(Request, txtStartDate.UniqueID, oTime.ToString("MM/dd/yyyy")); string StartTime = WebHelper.GetStringParam(Request, txtStartTime.UniqueID, oTime.ToString("hh:mm tt")); if (DateTime.TryParseExact(String.Format("{0} {1}", StartDate, StartTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime)) { fieldItem.StartTime = oTime; } //发布状态和时间 DateTime EndTime = xUserTime.LocalTime().AddYears(10); string DisableDate = WebHelper.GetStringParam(Request, txtDisableDate.UniqueID, EndTime.ToString("MM/dd/yyyy")); string DisableTime = WebHelper.GetStringParam(Request, txtDisableTime.UniqueID, EndTime.ToString("hh:mm tt")); if (DateTime.TryParseExact(String.Format("{0} {1}", DisableDate, DisableTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime)) { fieldItem.EndTime = EndTime; } if (ArticleStatus == -1)//如果没有指定状态就取控件的 { fieldItem.Status = cbStatus.Checked ? (Int32)EnumStatus.Activation : (Int32)EnumStatus.Hide; } else { fieldItem.Status = ArticleStatus; } Int32 SaveResult = 0; if (fieldItem.ID > 0) { SaveResult = fieldItem.Update(); } else { fieldItem.Name = txtName.Text; QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.Name, fieldItem.Name, SearchType.Equal)); if (DNNGo_PowerForms_Field.FindCount(qp) == 0) { fieldItem.ModuleId = ModuleId; fieldItem.PortalId = PortalId; QueryParam Sqp = new QueryParam(); Sqp.ReturnFields = Sqp.Orderfld = DNNGo_PowerForms_Field._.Sort; Sqp.OrderType = 1; Sqp.Where.Add(new SearchParam(DNNGo_PowerForms_Field._.ModuleId, ModuleId, SearchType.Equal)); fieldItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Field.FindScalar(Sqp)) + 2; //构造默认的验证方式 if (fieldItem.FieldType == (Int32)EnumViewControlType.DatePicker) { fieldItem.Verification = (Int32)EnumVerification.date; } else if (fieldItem.FieldType == (Int32)EnumViewControlType.FileUpload) { } else if (fieldItem.FieldType == (Int32)EnumViewControlType.TextBox_Email) { fieldItem.Verification = (Int32)EnumVerification.email; } SaveResult = fieldItem.Insert(); } else { SaveResult = -1; } } return(SaveResult); }
public Int32 SynchronizeAllFiles(FileInfo SynchronizeFile) { Int32 SynchronizeFileCount = 0; DNNGo_PowerForms_Files PhotoItem = new DNNGo_PowerForms_Files(); PhotoItem.ModuleId = ModuleId; PhotoItem.PortalId = PortalId; PhotoItem.FileName = SynchronizeFile.Name; PhotoItem.FileSize = Convert.ToInt32(SynchronizeFile.Length / 1024); PhotoItem.FileMate = FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", "")); PhotoItem.FileExtension = System.IO.Path.GetExtension(PhotoItem.FileName).Replace(".", ""); PhotoItem.Name = System.IO.Path.GetFileName(PhotoItem.FileName).Replace(Path.GetExtension(PhotoItem.FileName), ""); PhotoItem.Status = (Int32)EnumFileStatus.Approved; try { if (("png,gif,jpg,jpeg,bmp").IndexOf(PhotoItem.FileExtension) >= 0) { //图片的流 System.Drawing.Image image = System.Drawing.Image.FromFile(SynchronizeFile.FullName); PhotoItem.ImageWidth = image.Width; PhotoItem.ImageHeight = image.Height; PhotoItem.Exif = Common.Serialize <EXIFMetaData.Metadata>(new EXIFMetaData().GetEXIFMetaData(image)); } } catch { } PhotoItem.LastTime = xUserTime.UtcTime(); PhotoItem.LastIP = WebHelper.UserHost; PhotoItem.LastUser = UserInfo.UserID; //将文件存储的路径整理好 String fileName = PhotoItem.FileName; //文件名称 String WebPath = String.Format("PowerForms/uploads/{0}/{1}/{2}/", xUserTime.UtcTime().Year, xUserTime.UtcTime().Month, xUserTime.UtcTime().Day); //检测文件存储路径是否有相关的文件 FileInfo fInfo = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension))); //检测文件夹是否存在 if (!System.IO.Directory.Exists(fInfo.Directory.FullName)) { System.IO.Directory.CreateDirectory(fInfo.Directory.FullName); } else { Int32 j = 1; while (fInfo.Exists) { //文件已经存在了 fileName = String.Format("{0}_{1}", PhotoItem.Name, j); fInfo = new FileInfo(HttpContext.Current.Server.MapPath(String.Format("{0}{1}{2}.{3}", PortalSettings.HomeDirectory, WebPath, fileName, PhotoItem.FileExtension))); j++; } } PhotoItem.FilePath = String.Format("{0}{1}.{2}", WebPath, fileName, PhotoItem.FileExtension); PhotoItem.FileName = String.Format("{0}.{1}", fileName, PhotoItem.FileExtension); try { if (!fInfo.Directory.Exists) { fInfo.Directory.Create(); } //异步移动文件到文件夹中 List <String> SynchronizeFileQueue = new List <string>(); SynchronizeFileQueue.Add(SynchronizeFile.FullName); SynchronizeFileQueue.Add(fInfo.FullName); ManagedThreadPool.QueueUserWorkItem(new WaitCallback(ThreadMoveTo), SynchronizeFileQueue); } catch (Exception ex) { } //给上传的相片设置初始的顺序 QueryParam qp = new QueryParam(); qp.ReturnFields = qp.Orderfld = DNNGo_PowerForms_Files._.Sort; qp.OrderType = 1; qp.Where.Add(new SearchParam(DNNGo_PowerForms_Files._.PortalId, PhotoItem.PortalId, SearchType.Equal)); PhotoItem.Sort = Convert.ToInt32(DNNGo_PowerForms_Files.FindScalar(qp)) + 2; Int32 PhotoId = PhotoItem.Insert(); if (PhotoId > 0) { SynchronizeFileCount++; } return(SynchronizeFileCount); }