internal void method_28() { if ((this.m_bodyItems != null) && (this.m_bodyItems.Count > 0)) { BodyRegion region = null; for (int i = 0; i < this.m_bodyItems.Count; i++) { region = this.m_bodyItems[i]; region.Close(); region = null; } this.m_bodyItems.Clear(); this.m_bodyItems = null; } if (this.paragraphCollection_0 != null) { this.paragraphCollection_0.Clear(); this.paragraphCollection_0 = null; } if (this.tableCollection_0 != null) { this.tableCollection_0.Clear(); this.tableCollection_0 = null; } if (this.formFieldCollection_0 != null) { this.formFieldCollection_0.InnerList.Clear(); this.formFieldCollection_0 = null; } }
/// <summary> /// 解析单个表达式 /// </summary> /// <param name="wherelist"></param> /// <param name="datas"></param> /// <returns></returns> private string GetConditionSql_ParserSingleExpression(string where, FormFieldCollection datas) { string[] tjlist = where.Split(new String[] { "'", "`" }, StringSplitOptions.None); if (tjlist[1].Substring(0, 1) == "@") { tjlist[1] = tjlist[1].Substring(1); tjlist[1] = this.GetConditionSql_GetCurFormVar(tjlist[1], datas); } else if (tjlist[1].Substring(0, 1) == "[") { tjlist[1] = tjlist[1].Substring(1, tjlist[1].Length - 2); tjlist[1] = this.GetConditionSql_GetSysVariable(tjlist[1]); } if (tjlist[3].Substring(0, 1) == "@") { tjlist[3] = tjlist[3].Substring(1); tjlist[1] = this.GetConditionSql_GetCurFormVar(tjlist[1], datas); } else if (tjlist[3].Substring(0, 1) == "[") { tjlist[3] = tjlist[3].Substring(1, tjlist[3].Length - 2); tjlist[3] = this.GetConditionSql_GetSysVariable(tjlist[3]); } return("'" + tjlist[1] + "'" + tjlist[2] + "'" + tjlist[3] + "'"); }
///<summary> /// ///</summary> ///<param name="fo"></param> ///<param name="returnMessage"></param> ///<param name="returnTitle"></param> ///<param name="returnSubject"></param> ///<param name="returnFieldColl"></param> ///<returns></returns> public static bool Validate(Form fo, out string returnMessage, out string returnTitle, out string returnSubject, out FormFieldCollection returnFieldColl) { //login to VisualVault using API values stored in web.config file string serverUrl = WebConfigurationManager.AppSettings["vVServerURL"]; string userId = WebConfigurationManager.AppSettings["vVUserID"]; string password = WebConfigurationManager.AppSettings["vVPassword"]; returnSubject = ""; bool response; returnFieldColl = new FormFieldCollection(); _vault = VVRuntime.VisualVaultLogin.Login(serverUrl, userId, password, Constants.DeveloperKey, Constants.DeveloperSecret, Constants.ProductId); if (_vault != null) { //check required fields response = CheckRequiredFields(fo.FormFields, out returnMessage, out returnTitle, out returnSubject, out returnFieldColl); //response = UpdateFormFields(fo.FormFields, out returnMessage, out returnTitle, out returnSubject, out returnFieldColl); } else { //unable to login to VisualVault response = false; returnTitle = "Error"; returnMessage = "Unable to login to VisualVault."; } return(response); }
public void FormFieldsGetFormFieldsCollection() { //ExStart:FormFieldsGetFormFieldsCollection Document doc = new Document(MyDir + "Form fields.docx"); FormFieldCollection formFields = doc.Range.FormFields; //ExEnd:FormFieldsGetFormFieldsCollection }
public static void ObtainingFormFieldsFeature() { //Shows how to get a collection of form fields. Document doc = new Document(MyDir + "Obtaining form fields.docx"); FormFieldCollection formFields = doc.Range.FormFields; FormField formField1 = formFields[3]; FormField formField2 = formFields["CustomerName"]; }
public void FormFieldsGetFormFieldsCollection() { //ExStart //ExFor:Range.FormFields //ExFor:FormFieldCollection //ExSummary:Shows how to get a collection of form fields. Document doc = new Document(MyDir + "FormFields.doc"); FormFieldCollection formFields = doc.Range.FormFields; //ExEnd }
/// <summary> /// 从表单项列表与Request.Forms生成字段数据 /// 1.主要是用户在工作过程中流转使用 /// </summary> /// <returns></returns> public FormFieldCollection GetPostedDatas() { FormFieldCollection ffc = this.Items_FormFieldCollection; foreach (FormField ff in ffc) { ff.Value = HttpContext.Current.Request.Form[ff.Id] == null ? "" : HttpContext.Current.Request.Form[ff.Id]; //ff.Value = HttpContext.Current.Request.Form[ff.Id]; } //需要开发 return(ffc); }
public void FormFieldsGetByName() { //ExStart //ExFor:FormField //ExSummary:Shows how to access form fields. Document doc = new Document(MyDir + "FormFields.doc"); FormFieldCollection documentFormFields = doc.Range.FormFields; FormField formField1 = documentFormFields[3]; FormField formField2 = documentFormFields["CustomerName"]; //ExEnd }
public static void Run() { // ExStart:FormFieldsGetFormFieldsCollection // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithFields(); Document doc = new Document(dataDir + "FormFields.doc"); FormFieldCollection formFields = doc.Range.FormFields; // ExEnd:FormFieldsGetFormFieldsCollection Console.WriteLine("\nDocument have " + formFields.Count.ToString() + " form fields."); }
/// <summary> /// Serializes form data /// </summary> /// <param name="fields">Form data to serialize</param> /// <param name="serializationType">Serialization method to use</param> public string Serialize(FormFieldCollection fields, FormFieldSerializationType serializationType) { switch (serializationType) { case FormFieldSerializationType.UrlEncoded: return UrlEncodedSerialize(fields); case FormFieldSerializationType.PlainText: case FormFieldSerializationType.Multipart: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException("serializationType"); } }
/// <summary> /// 生成当前工作N步中表单Html /// </summary> /// <param name="step"></param> /// <returns></returns> public String GenerateHtmls(int id) { WX.Flow.Model.Run.MODEL runmodel = WX.Flow.Model.Run.NewDataModel(id); FormFieldCollection datas = this.GetDatas_FormFieldCollection(); this.MyFlow.LoadProcessList(false); Process.MODEL process = this.MyFlow.ProcessList.Find(delegate(Process.MODEL prcs_dele) { return(prcs_dele.StepNo.ToInt32() == runmodel.StepNo.ToInt32()); }); if (process == null) { return(null); } return(this.MyForm.GenerateHtmls(datas, process.Editable_FormFieldCollection, process.Hidden_FormFieldCollection, runmodel.BeginUser.ToString())); }
internal static bool UpdateFormFields(FormFieldCollection formFieldCollection, out string errorMessage, out string messageTitle, out string messageSubject, out FormFieldCollection returnFieldColl) { var result = true; errorMessage = ""; messageTitle = ""; messageSubject = ""; returnFieldColl = new FormFieldCollection(); try { //This method is a simple example of updating form field values //(1) Get the form template name. In this case we are storing the template name in the web.config file var formTemplateName = WebConfigurationManager.AppSettings["TestFormTemplate"]; //(2) Instantiate a form template object by name var formTemplate = _vault.Forms.GetFormTemplate(formTemplateName); //(3) Fill in a new form. This will be the first revision of a new form instance var formInstance = formTemplate.GetNewFormDataInstance(); //(4) Populate field values for the new form instance. foreach (FormField formField in formInstance.FormFields) { if (formField.FieldType == FormFieldTypes.UserIDStamp) { //UserIDStamp form field type is referred to as a SignatureStamp in the user interface. //This field type requires special handling; in order to set the value pass in a string value of "True" //which will sign a signature using the user credentials of the authentication user (the user you used to instantiate the Vault object) formField.FieldValue = "True"; } } //(5) Save the new form instance formInstance.SaveForm(); //(6) Create a new revision of the form instance //formInstance = formInstance.GetNewDataInstanceRevision(); //(7) Update form field values and Save to create a new revision of a form instance } catch (Exception ex) { result = false; } return(result); }
public static void Run() { // ExStart:FormFieldsGetByName // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WorkingWithFields(); Document doc = new Document(dataDir + "FormFields.doc"); FormFieldCollection documentFormFields = doc.Range.FormFields; FormField formField1 = documentFormFields[3]; FormField formField2 = documentFormFields["Text2"]; // ExEnd:FormFieldsGetByName Console.WriteLine("\n" + formField2.Name + " field have following text " + formField2.GetText() + "."); }
static void Main(string[] args) { string MyDir = @"E:\Aspose\Aspose Vs OpenXML\Missing Features of OpenXML Words Provided by Aspose.Words v1.1\Sample Files\"; //Shows how to get a collection of form fields. Document doc = new Document(MyDir + "FormFields.doc"); FormFieldCollection formFields = doc.Range.FormFields; //Shows how to access form fields. Document myDoc = new Document(MyDir + "FormFields.doc"); FormFieldCollection documentFormFields = myDoc.Range.FormFields; FormField formField1 = documentFormFields[3]; FormField formField2 = documentFormFields["CustomerName"]; }
static void Main(string[] args) { string FilePath = @"..\..\..\Sample Files\"; string FileName = FilePath + "Obtaining Form Fields.docx"; //Shows how to get a collection of form fields. Document doc = new Document(FileName); FormFieldCollection formFields = doc.Range.FormFields; //Shows how to access form fields. Document myDoc = new Document(FileName); FormFieldCollection documentFormFields = myDoc.Range.FormFields; FormField formField1 = documentFormFields[3]; FormField formField2 = documentFormFields["CustomerName"]; }
public void FormFieldsGetByName() { //ExStart:FormFieldsFontFormatting //ExStart:FormFieldsGetByName Document doc = new Document(MyDir + "Form fields.docx"); FormFieldCollection documentFormFields = doc.Range.FormFields; FormField formField1 = documentFormFields[3]; FormField formField2 = documentFormFields["Text2"]; //ExEnd:FormFieldsGetByName formField1.Font.Size = 20; formField2.Font.Color = Color.Red; //ExEnd:FormFieldsFontFormatting }
/// <summary> /// 获取单个表单变量 /// </summary> /// <param name="Vname"></param> /// <returns></returns> private string GetConditionSql_GetCurFormVar(string Vname, FormFieldCollection datas) { if (datas == null) { return(String.Empty); } FormField ff = datas.FindItemByTitle(Vname); if (ff != null) { return(ff.Value); } else { return(String.Empty); } }
public void TestUrlEncodedSerialize() { // Arrange var fields = new FormFieldCollection { new FormField("test1", "test1Value"), new FormField("Test2", "test2Value"), new FormField("Test3", "test \n=&?/+") }; var serializer = new FormFieldSerializer(); // Act var serialized = serializer.Serialize(fields); // Assert Assert.AreEqual("test1=test1Value&Test2=test2Value&Test3=test+%0a%3d%26%3f%2f%2b", serialized); }
/// <summary> /// 从表单模板生成表单字段 /// 1.保存表单模板数据前调用! /// </summary> /// <returns></returns> public FormFieldCollection FetchItems() { //需要开发 FormFieldCollection ffc = new FormFieldCollection(); string resolvestr = this.Module.ToString(); string[] regstr = new string[] { "<input(.*?)title=\"(.*?)\"(.*?)name=\"(.*?)\"(.*?)/>", //input表单 "<input(.*?)name=\"(.*?)\"(.*?)title=\"(.*?)\"(.*?)/>", //input表单 "<textarea(.*?)title=\"(.*?)\"(.*?)name=\"(.*?)\"(.*?)>([\\s\\S]*?)</textarea>", //多行文本框 "<textarea(.*?)name=\"(.*?)\"(.*?)title=\"(.*?)\"(.*?)>([\\s\\S]*?)</textarea>", //多行文本框 "<select(.*?)title=\"(.*?)\"(.*?)name=\"(.*?)\"([\\s\\S]*?)</select>", //下拉列表 "<select(.*?)name=\"(.*?)\"(.*?)title=\"(.*?)\"([\\s\\S]*?)</select>", //下拉列表 "<img(.*?)title=\"(.*?)\"(.*?)name=\"(.*?)\"(.*?)/>", //图片 "<img(.*?)name=\"(.*?)\"(.*?)title=\"(.*?)\"(.*?)/>", //图片 "<button(.*?)title=\"(.*?)\"(.*?)name=\"(.*?)\"([\\s\\S]*?)</button>", //按钮 "<button(.*?)name=\"(.*?)\"(.*?)title=\"(.*?)\"([\\s\\S]*?)</button>" //按钮 }; for (int i = 0; i < regstr.Length; i++) { MatchCollection mc = Regex.Matches(resolvestr, regstr[i]); for (int j = 0; j < mc.Count; j++) { FormField ff = new FormField(); if (i % 2 == 0) { ff.Id = mc[j].Result("$4"); ff.Text = mc[j].Result("$2"); } else { ff.Id = mc[j].Result("$2"); ff.Text = mc[j].Result("$4"); } if (mc[j].Result("$3").IndexOf("datafld") > -1) { ff.Type = Regex.Match(mc[j].Result("$3"), "datafld=\"(.*?)\"").Result("$1"); } ffc.Add(ff); } } return(ffc); }
private void button1_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); //Open a Word document Document document = new Document(@"..\..\..\..\..\..\Data\FillFormField.doc"); //Get the first section Section section = document.Sections[0]; FormFieldCollection formFields = section.Body.FormFields; sb.Append("The first section has " + formFields.Count + " form fields."); File.WriteAllText("result.txt", sb.ToString()); //Launch result file WordDocViewer("result.txt"); }
//ExEnd private void TestFormField(Document doc) { doc = DocumentHelper.SaveOpen(doc); FieldCollection fields = doc.Range.Fields; Assert.AreEqual(3, fields.Count); TestUtil.VerifyField(FieldType.FieldFormDropDown, " FORMDROPDOWN \u0001", string.Empty, doc.Range.Fields[0]); TestUtil.VerifyField(FieldType.FieldFormCheckBox, " FORMCHECKBOX \u0001", string.Empty, doc.Range.Fields[1]); TestUtil.VerifyField(FieldType.FieldFormTextInput, " FORMTEXT \u0001", "New placeholder text", doc.Range.Fields[2]); FormFieldCollection formFields = doc.Range.FormFields; Assert.AreEqual(3, formFields.Count); Assert.AreEqual(FieldType.FieldFormDropDown, formFields[0].Type); Assert.AreEqual(new[] { "One", "Two", "Three" }, formFields[0].DropDownItems); Assert.True(formFields[0].CalculateOnExit); Assert.AreEqual(0, formFields[0].DropDownSelectedIndex); Assert.True(formFields[0].Enabled); Assert.AreEqual("One", formFields[0].Result); Assert.AreEqual(FieldType.FieldFormCheckBox, formFields[1].Type); Assert.True(formFields[1].IsCheckBoxExactSize); Assert.AreEqual("Right click to check this box", formFields[1].HelpText); Assert.True(formFields[1].OwnHelp); Assert.AreEqual("Checkbox status text", formFields[1].StatusText); Assert.True(formFields[1].OwnStatus); Assert.AreEqual(50.0d, formFields[1].CheckBoxSize); Assert.False(formFields[1].Checked); Assert.False(formFields[1].Default); Assert.AreEqual("0", formFields[1].Result); Assert.AreEqual(FieldType.FieldFormTextInput, formFields[2].Type); Assert.AreEqual("EntryMacro", formFields[2].EntryMacro); Assert.AreEqual("ExitMacro", formFields[2].ExitMacro); Assert.AreEqual("Regular", formFields[2].TextInputDefault); Assert.AreEqual("FIRST CAPITAL", formFields[2].TextInputFormat); Assert.AreEqual(TextFormFieldType.Regular, formFields[2].TextInputType); Assert.AreEqual(50, formFields[2].MaxLength); Assert.AreEqual("New placeholder text", formFields[2].Result); }
/// <summary> /// 获取条件形成的Sql语句 /// </summary> /// <param name="inStr">条件字段字符串</param> /// <param name="curRun">当前工作</param> /// <returns></returns> private String GetConditionSql(string inStr, Run.MODEL curRun) { if (String.IsNullOrEmpty(inStr)) { return("1=1"); } //Get FieldValues of FieldItemCollection FormFieldCollection datas = null; if (curRun != null) { datas = curRun.GetDatas_FormFieldCollection(); } string prcsin = inStr; //获取单个表达式集合,并逐个解析它 string[] prcslist = prcsin.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries); if (prcslist.Length != 3) { return("1=1"); } string[] wherelist = prcslist[0].Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < wherelist.Length; i++) { wherelist[i] = GetConditionSql_ParserSingleExpression(wherelist[i], datas); } //获取整体表达式字符串 string sqlstr = prcslist[1]; //生成整体表达式 for (int i = 0; i < wherelist.Length; i++) { sqlstr = sqlstr.Replace("[" + (i + 1) + "]", wherelist[i]); } return(sqlstr); }
/// <summary> /// Call a phone number using a forwarding phone number /// </summary> /// <param name="outgoingNumber">Phone number to call</param> /// <param name="forwardingNumber">Forwarding number to call</param> /// <param name="phoneType">Phone Type Enumerator</param> public void ConnectCall(string outgoingNumber, string forwardingNumber, PHONETYPES phoneType) { if (!_isLoggedIn) throw new InvalidOperationException("Not logged in"); if (_isDisposed) throw new ObjectDisposedException(GetType().Name); var formData = new FormFieldCollection { new FormField(OUTGOINGNUMBER_FIELD, outgoingNumber), new FormField(FORWARDINGNUMBER_FIELD, forwardingNumber), new FormField(PHONETYPE_FIELD,((int)phoneType).ToString()), new FormField(RNR_SE_FIELD, _rnrSe) }; var response = _webManager.PerformPost(ConnectCallUri, formData, FormFieldSerializationType.UrlEncoded); using (var streamReader = new StreamReader(response.Response)) { var result = JsonConvert.DeserializeObject<Result>(streamReader.ReadToEnd()); if (!result.Ok) throw new GVoiceException(result.Data.Code); } }
private string _Convert(string srcPath, string destFileExtension, Boolean srcIsZip, int pageIndex = -1, int imgQuality = 0, string htmlEncoding = "gb2312", int fontZoomPercent = 100, Boolean combineImages = false) { //判断许可 //if (!CheckLicense()) //{ // return new InternalBufferOverflowException().ToString(); //} //清理旧文件 if (this.AutoDelOldFile) { Utils.ClearupDir(this._tempPath, SaveDirMaxFileCount); } //文件名唯一标识 var fileGUID = Utils.GetMd5Str(srcPath); try { this._combineImages = combineImages; string fileExtension = Path.GetExtension(srcPath).ToLower(); string fileName = fileGUID + fileExtension; string tempFilePath = this._tempPath + fileName; //判断目录是否存在(如果存在则说明转换过),如果是则不在下载,而doc每次都更新 //var dirInfo = new DirectoryInfo(this._tempPath + fileGUID); //if (!dirInfo.Exists || dirInfo.GetFiles().Length == 0 || fileExtension == ".doc") { //如果是HTTP链接,则通过HTTP下载 if (srcPath.Contains("http://")) { var downloadTempFile = tempFilePath + ".tmp"; Utils.DownloadToFile(srcPath, downloadTempFile, _cookie); //如果是压缩文件,则解压 if (srcIsZip) { Utils.UnZipFile(downloadTempFile, tempFilePath); } else { File.Copy(downloadTempFile, tempFilePath); } FileInfo fi = new FileInfo(downloadTempFile); fi.Delete(); } //如果是局域网,则直接获取 else if (!string.IsNullOrEmpty(this._fileServer) && srcPath.StartsWith(@"\\")) { using (IdentityScope identity = new IdentityScope(this._serverUser, this._fileServer, this._serverPwd)) { //如果是压缩文件,则解压 if (srcIsZip) { Utils.UnZipFile(srcPath, tempFilePath); } else { tempFilePath = srcPath; } } } else { //如果是压缩文件,则解压 if (srcIsZip) { Utils.UnZipFile(srcPath, tempFilePath); } else { tempFilePath = srcPath; } } ////如果是压缩文件,则解压 //if (srcIsZip) //{ // try // { // //如果是局域网的,则先登录认证 // if (!string.IsNullOrEmpty(this._fileServer) && srcPath.StartsWith(@"\\")) // { // using (IdentityScope identity = new IdentityScope(this._serverUser, this._fileServer, this._serverPwd)) // { // Utils.UnZipFile(srcPath, tempFilePath); // } // } // else // { // Utils.UnZipFile(srcPath, tempFilePath); // } // } // catch (Exception) // { // return "文件解压失败,请确认源文件是压缩文件."; // } //} } //如果路径为空,则直接返回 if (string.IsNullOrEmpty(tempFilePath)) { return(""); } string destFileName = fileGUID + destFileExtension; string destDir = this._tempPath + fileGUID + "\\"; string destFilePath = destDir + destFileName; string resultData = string.Empty; if (fileExtension == ".doc" || fileExtension == ".docx") { if (!Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } //转换成HTML if (destFileExtension.Equals(".html")) { Document doc = new Document(tempFilePath); //不显示文本边框 doc.SaveOptions.HtmlExportTextInputFormFieldAsText = true; doc.SaveOptions.HtmlExportAllowNegativeLeftIndent = true; doc.SaveOptions.HtmlExportDocumentProperties = false; doc.AcceptAllRevisions(); FormFieldCollection formFields = doc.Range.FormFields; for (int i = formFields.Count - 1; i >= 0; i--) { var ff = formFields[i]; if (ff.Type == FieldType.FieldNone) { ff.Remove(); } } doc.Save(destFilePath); StreamReader sr = new StreamReader(destFilePath); var htmlData = Utils.ReplaceMatch("<meta name=\"generator\" content=\".*?\" />", RegexOptions.None, sr.ReadToEnd(), ""); htmlData = Utils.ReplaceMatch(@"<html>[\s\S]*?<body>", RegexOptions.None, htmlData, ""); htmlData = Utils.ReplaceMatch(@"</body>[\s\S]*?</html>", RegexOptions.None, htmlData, ""); byte a = 0xc2; byte b = 0xa0; htmlData = htmlData.Replace((char)a, ' '); htmlData = htmlData.Replace((char)b, ' '); htmlData = Utils.ReplaceMatch("<img src=\"(.*?)\"", RegexOptions.IgnoreCase, htmlData, "<img src=\"" + this._relativeTempPath + fileGUID + "/$1\""); string pageData = "<span style=\"font-family:'宋体'; font-size:[1-9]+?pt\">-</span><span[^>].*?>[1-9]+?</span><span style=\"font-family:'宋体'; font-size:[1-9]+?pt\">-</span>"; htmlData = Utils.ReplaceMatch(pageData, RegexOptions.IgnoreCase, htmlData, ""); var utils = new Utils(); htmlData = utils.UpdateTableWidthMatch("<table cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse[^>]*?>", htmlData, "100%"); htmlData = htmlData.Replace("442.35pt", "100%"); sr.Close(); if (htmlEncoding.ToLower().Equals("gb2312")) { //StreamWriter sw = new StreamWriter(destFilePath, false, Encoding.GetEncoding("gb2312")); //sw.Write(htmlData); //sw.Flush(); //sw.Close(); resultData = Utils.UTF82GB2312(htmlData); } else { //StreamWriter sw = new StreamWriter(destFilePath); //sw.Write(htmlData); //sw.Flush(); //sw.Close(); resultData = htmlData; } //删除临时文件 Utils.SigleFileDel(destFilePath); //如果文件夹为空,则删除文件夹 var dir = new DirectoryInfo(destDir); if (dir.Exists && dir.GetFiles().Length == 0) { Utils.RemoteDelDir(destDir); } } //转换成图片的 else if (destFileExtension.Equals(".jpg")) { resultData = new DocEngine().Convert(tempFilePath, this._tempPath, fileGUID, combineImages, pageIndex, imgQuality); } } else if (fileExtension == ".pdf") { resultData = new PDFEngine().Convert(tempFilePath, this._tempPath, fileGUID, combineImages, pageIndex, imgQuality); } else if (fileExtension == ".ceb") { if (string.IsNullOrEmpty(CebImageSavePath)) { resultData = new CebEngine().Convert(tempFilePath, this._tempPath, fileGUID, this._tempPath, combineImages, imgQuality); } else { resultData = new CebEngine().Convert(tempFilePath, this._tempPath, fileGUID, CebImageSavePath, combineImages, imgQuality); }; } //删除临时文件 Utils.SigleFileDel(tempFilePath); return(resultData); } catch (Exception) { return("未能找到文件。"); } }
/// <summary> /// /// </summary> /// <param name="formFieldCollection"></param> /// <param name="errorMessage"></param> /// <param name="messageTitle"></param> /// <param name="messageSubject"></param> /// <param name="returnFieldColl"></param> /// <returns></returns> internal static bool CheckRequiredFields(FormFieldCollection formFieldCollection, out string errorMessage, out string messageTitle, out string messageSubject, out FormFieldCollection returnFieldColl) { //list form fields you want to validate here var requiredFields = "First Name,DOB,Place of Birth,Gender".Split(','); var result = true; errorMessage = ""; messageTitle = ""; messageSubject = ""; returnFieldColl = new FormFieldCollection(); foreach (string fieldName in requiredFields) { foreach (FormField formField in formFieldCollection) { if (fieldName.ToLower() == formField.FieldName.ToLower()) { bool found; //If the form field has no value we assume validation failed //If the form field has a value and the value = select item or --select-- we assume //a drop down list where no value has been selected by the user switch (formField.FieldValue.ToLower()) { case "select item": case "--select--": case "": found = false; break; default: found = true; break; } //Always set the RenderValidationError property to true|false if (!found) { if (errorMessage.Length > 0) { errorMessage += ","; } //turn on the validation error icon formField.RenderValidationError = true; returnFieldColl.Add(formField); errorMessage += fieldName; } else { //turn off the validation error icon formField.RenderValidationError = false; returnFieldColl.Add(formField); } } } } if (errorMessage.Length > 0) { errorMessage = errorMessage.Insert(0, "These fields have missing values: "); messageTitle = "Field validation error"; messageSubject = "Missing required fields"; result = false; } return(result); }
/// <summary> /// Serializes form data with the default serialization method. /// </summary> /// <param name="fields">Form data to serialize</param> public string Serialize(FormFieldCollection fields) { return Serialize(fields, FormFieldSerializationType.UrlEncoded); }
public static FormFieldCollection GetFormFieldsOfDocument(this Document document) { FormFieldCollection formFields = document.Range.FormFields; return(formFields); }
[Test] //ExSkip public void Visitor() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to insert a combo box. builder.Write("Choose a value from this combo box: "); FormField comboBox = builder.InsertComboBox("MyComboBox", new[] { "One", "Two", "Three" }, 0); comboBox.CalculateOnExit = true; Assert.AreEqual(3, comboBox.DropDownItems.Count); Assert.AreEqual(0, comboBox.DropDownSelectedIndex); Assert.True(comboBox.Enabled); builder.InsertBreak(BreakType.ParagraphBreak); // Use a document builder to insert a check box. builder.Write("Click this check box to tick/untick it: "); FormField checkBox = builder.InsertCheckBox("MyCheckBox", false, 50); checkBox.IsCheckBoxExactSize = true; checkBox.HelpText = "Right click to check this box"; checkBox.OwnHelp = true; checkBox.StatusText = "Checkbox status text"; checkBox.OwnStatus = true; Assert.AreEqual(50.0d, checkBox.CheckBoxSize); Assert.False(checkBox.Checked); Assert.False(checkBox.Default); builder.InsertBreak(BreakType.ParagraphBreak); // Use a document builder to insert text input form field. builder.Write("Enter text here: "); FormField textInput = builder.InsertTextInput("MyTextInput", TextFormFieldType.Regular, "", "Placeholder text", 50); textInput.EntryMacro = "EntryMacro"; textInput.ExitMacro = "ExitMacro"; textInput.TextInputDefault = "Regular"; textInput.TextInputFormat = "FIRST CAPITAL"; textInput.SetTextInputValue("New placeholder text"); Assert.AreEqual(TextFormFieldType.Regular, textInput.TextInputType); Assert.AreEqual(50, textInput.MaxLength); // This collection contains all of our form fields. FormFieldCollection formFields = doc.Range.FormFields; Assert.AreEqual(3, formFields.Count); // Fields display our form fields. We can see their field codes by opening this document // in Microsoft and pressing Alt + F9. These fields have no switches, // and members of the FormField object fully govern their form fields' content. Assert.AreEqual(3, doc.Range.Fields.Count); Assert.AreEqual(" FORMDROPDOWN \u0001", doc.Range.Fields[0].GetFieldCode()); Assert.AreEqual(" FORMCHECKBOX \u0001", doc.Range.Fields[1].GetFieldCode()); Assert.AreEqual(" FORMTEXT \u0001", doc.Range.Fields[2].GetFieldCode()); // Allow each form field to accept a document visitor. FormFieldVisitor formFieldVisitor = new FormFieldVisitor(); using (IEnumerator <FormField> fieldEnumerator = formFields.GetEnumerator()) while (fieldEnumerator.MoveNext()) { fieldEnumerator.Current.Accept(formFieldVisitor); } Console.WriteLine(formFieldVisitor.GetText()); doc.UpdateFields(); doc.Save(ArtifactsDir + "FormFields.Visitor.html"); TestFormField(doc); //ExSkip }
public String GenerateHtmls(FormFieldCollection datas, FormFieldCollection editableFlds, FormFieldCollection hiddenFlds, string BeginuserID) { String htmls = null; String module = this.Module.ToString(); //需要开发 htmls = module; HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); document.LoadHtml(module); htmls = this.Module_Short.ToString(); HtmlNode rootNode = document.DocumentNode; string newnode = ""; HtmlNodeCollection hnc = rootNode.SelectNodes("//input");//单行文本框 if (hnc != null) { foreach (HtmlNode hn in hnc) { newnode = ""; if (hn.OuterHtml.Trim() != "") { if (editableFlds.Contains(hn.Attributes["name"].Value)) { hn.Attributes.Add("readonly", "readonly"); } if (hiddenFlds.Contains(hn.Attributes["name"].Value)) { if (hn.Attributes["style"] != null) { hn.Attributes["style"].Value = hn.Attributes["style"].Value + ";display:none;"; } else { hn.Attributes.Add("style", "display:none;"); } } if (hn.Attributes["value"] != null) { hn.Attributes["value"].Value = datas[hn.Attributes["name"].Value].Value; } else { hn.Attributes.Add("value", datas[hn.Attributes["name"].Value].Value); } if (hn.Attributes["class"] != null && hn.Attributes["class"].Value == "AUTO") { switch (hn.Attributes["datafld"].Value) { case "SYS_DATE": hn.Attributes["value"].Value = DateTime.Now.ToString("yyyy-MM-dd"); break; case "SYS_DATE_CN": hn.Attributes["value"].Value = DateTime.Now.ToString("yyyy年M月d日"); break; case "SYS_DATE_CN_SHORT3": hn.Attributes["value"].Value = DateTime.Now.ToString("yyyy年"); break; case "SYS_DATE_CN_SHORT4": hn.Attributes["value"].Value = DateTime.Now.ToString("yyyy"); break; case "SYS_DATE_CN_SHORT1": hn.Attributes["value"].Value = DateTime.Now.ToString("yyyy年M月"); break; case "SYS_DATE_CN_SHORT2": hn.Attributes["value"].Value = DateTime.Now.ToString("M月d日"); break; case "SYS_TIME": hn.Attributes["value"].Value = DateTime.Now.ToString("H:m:s"); break; case "SYS_DATETIM": hn.Attributes["value"].Value = DateTime.Now.ToString("yyyy-MM-dd H:m:s"); break; case "SYS_WEEK": hn.Attributes["value"].Value = DateTime.Now.DayOfWeek.ToString(); break; case "SYS_USERID": hn.Attributes["value"].Value = WX.Authentication.GetUserID(); break; case "SYS_USERNAME": { if (BeginuserID == "") { WX.Public.CurUser.LoadUserModel(false); hn.Attributes["value"].Value = WX.Public.CurUser.UserModel.RealName.ToString(); } else { hn.Attributes["value"].Value = WX.WXUser.GetRealNameByUserID(BeginuserID); } } break; case "SYS_DEPTNAME": { if (BeginuserID == "") { WX.Public.CurUser.LoadEmployeeUser(); WX.Public.CurUser.LoadMyDepartment(); hn.Attributes["value"].Value = WX.Public.CurUser.MyDepartMent.Name.ToString(); } else { hn.Attributes["value"].Value = WX.WXUser.GetDeptNameByUserID(BeginuserID); } } break; case "SYS_USERPRIV": { WX.Public.CurUser.LoadEmployeeUser(); WX.Public.CurUser.LoadDutyUser(); hn.Attributes["value"].Value = WX.Public.CurUser.DutyUser.Name.ToString(); } break; case "SYS_USERPRIVOTHER": { WX.Public.CurUser.LoadEmployeeUser(); WX.Public.CurUser.LoadDutyUser(); hn.Attributes["value"].Value = WX.Public.CurUser.DutyUser.Name.ToString(); } break; case "SYS_USERNAME_DATE": { WX.Public.CurUser.LoadUserModel(false); hn.Attributes["value"].Value = WX.Public.CurUser.UserModel.RealName.ToString() + " " + DateTime.Now.ToString("yyyy-MM-dd"); } break; case "SYS_USERNAME_DATETIME": { WX.Public.CurUser.LoadUserModel(false); hn.Attributes["value"].Value = WX.Public.CurUser.UserModel.RealName.ToString() + " " + DateTime.Now.ToString("yyyy-MM-dd H:m:s"); } break; case "SYS_FORMNAME": { hn.Attributes["value"].Value = "表单名称"; } break; case "SYS_RUNDATE": hn.Attributes["value"].Value = ""; break; case "SYS_RUNDATETIME": hn.Attributes["value"].Value = ""; break; case "SYS_RUNID": hn.Attributes["value"].Value = ""; break; case "SYS_AUTONUM": hn.Attributes["value"].Value = ""; break; case "SYS_IP": hn.Attributes["value"].Value = "-SYS_IP-"; break; //getIp(); case "SYS_MANAGER1": { WX.Public.CurUser.LoadUserModel(false); WX.Model.User.MODEL zgmodel = WX.Model.User.Caches.Find(delegate(WX.Model.User.MODEL dele) { return(dele.DepartmentID.ToInt32() == WX.Public.CurUser.UserModel.DepartmentID.ToInt32() && dele.DutyId.ToInt32() == 500); }); //WX.Model.Employee.GetModel("select top 1 * from [TU_Employees] where DepartmentID='" + WX.Main.CurUser.EmployeeUser.DepartmentID.ToString() + "' and DutyID=500"); hn.Attributes["value"].Value = (zgmodel != null ? zgmodel.RealName.value.ToString() : ""); } break; case "SYS_MANAGER2": { WX.Public.CurUser.LoadUserModel(false); WX.Public.CurUser.LoadMyDepartment(); //WX.Model.Department.MODEL model = WX.Model.Department.GetModel("select * from TE_Departments where ParentID='" + usermodel.EmployeeUser.DepartmentID.value.ToString() + "'"); //WX.Model.Employee.MODEL zgmodel = WX.Model.Employee.GetModel("select top 1 * from [TU_Employees] where DepartmentID='" + WX.Main.CurUser.EmployeeUser.DepartmentID.ToString() + "' and DutyID=500"); WX.Model.User.MODEL zgmodel = WX.Model.User.Caches.Find(delegate(WX.Model.User.MODEL dele) { return(dele.DepartmentID.ToInt32() == WX.Public.CurUser.UserModel.DepartmentID.ToInt32() && dele.DutyId.ToInt32() == 500); }); hn.Attributes["value"].Value = (zgmodel != null ? zgmodel.RealName.value.ToString() : ""); } break; case "SYS_SQL": { hn.Attributes["value"].Value = ULCode.QDA.XSql.GetValue(hn.Attributes["datasrc"].Value.ToString()).ToString(); } break; default: break; } if (hn.Attributes["hidden"] != null) { hn.Attributes["type"].Value = "hidden"; hn.Attributes["hidden"].Remove(); } if (datas[hn.Attributes["name"].Value].Value != null) { hn.Attributes["value"].Value = datas[hn.Attributes["name"].Value].Value; } htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } else if (hn.Attributes["class"] != null && hn.Attributes["class"].Value == "CALC") { newnode = "<script>function calc_" + hn.Attributes["name"].Value.Split('_')[1] + "(){var myvalue=eval(\"" + (hn.Attributes["value"].Value.IndexOf('(') > -1 ? "calc_" : "") + hn.Attributes["value"].Value.ToLower() + "\");if(myvalue==Infinity) document.form1." + hn.Attributes["name"].Value + ".value=\"无效结果\";else if(!isNaN(myvalue)) {var prec=document.form1." + hn.Attributes["name"].Value + ".getAttribute('prec');var vPrec;if(!prec) vPrec=10000;else vPrec=Math.pow(10,prec);var result = new Number(parseFloat(Math.round(myvalue*vPrec)/vPrec));document.form1." + hn.Attributes["name"].Value + ".value=result.toFixed(prec);}else document.form1." + hn.Attributes["name"].Value + ".value=myvalue;setTimeout(calc_" + hn.Attributes["name"].Value.Split('_')[1] + ",1000);}setTimeout(calc_" + hn.Attributes["name"].Value.Split('_')[1] + ",3000);</script>"; htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml + newnode); } else if (hn.Attributes["type"].Value == "text") { if (hn.Attributes["hidden"] != null) { hn.Attributes["type"].Value = "hidden"; hn.Attributes["hidden"].Remove(); } htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } else if (hn.Attributes["type"].Value == "checkbox") { hn.Attributes["value"].Value = hn.Attributes["name"].Value; if (datas[hn.Attributes["name"].Value].Value == hn.Attributes["name"].Value) { if (hn.Attributes["checked"] != null) { hn.Attributes["checked"].Value = "checked"; } else { hn.Attributes.Add("checked", "checked"); } } else if (datas[hn.Attributes["name"].Value].Value != null) { try { hn.Attributes.Remove("checked"); } catch { } } htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } else { htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } } } } hnc = rootNode.SelectNodes("//select");//下拉 if (hnc != null) { string child = ""; foreach (HtmlNode hn in hnc) { if (editableFlds.Contains(hn.Attributes["name"].Value)) { hn.Attributes.Add("readonly", "readonly"); } if (hiddenFlds.Contains(hn.Attributes["name"].Value)) { if (hn.Attributes["style"] != null) { hn.Attributes["style"].Value = hn.Attributes["style"].Value + ";display:none;"; } else { hn.Attributes.Add("style", "display:none;"); } } newnode = ""; if (hn.Attributes["class"] != null && hn.Attributes["class"].Value == "AUTO") { switch (hn.Attributes["datafld"].Value) { case "SYS_LIST_DEPT": { newnode = ""; string sSql = "exec [dbo].[sp_get_tree_multi_table] 'TE_Departments','ID','Name','ParentID','Sort',0,0,5"; DataTable dt = ULCode.QDA.XSql.GetDataTable(sSql); foreach (DataRow dr in dt.Rows) { newnode += "<option value=\"" + dr["id"].ToString() + "\" " + (datas[hn.Attributes["name"].Value].Value == dr["id"].ToString() ? " selected=\"selected\"" : "") + ">" + dr["node_name"].ToString() + "</option>"; } if (hn.Attributes["child"] != null) { child = hn.Attributes["child"].Value + "|DepartmentID"; } hn.InnerHtml = newnode; } break; case "SYS_LIST_USER": { newnode = ""; DataTable dt = ULCode.QDA.XSql.GetDataTable("SELECT * FROM vw_employees"); foreach (DataRow dr in dt.Rows) { newnode += "<option value=\"" + (child != "" && child.Split('|')[0] == hn.Attributes["id"].Value ? dr["RealName"].ToString() + "|" + dr[child.Split('|')[1]] + "|" : "") + dr["UserID"].ToString() + "\" " + (datas[hn.Attributes["name"].Value].Value == (child != "" && child.Split('|')[0] == hn.Attributes["id"].Value ? dr["RealName"].ToString() + "|" + dr[child.Split('|')[1]] + "|" : "") + dr["UserID"].ToString() ? " selected=\"selected\"" : "") + ">" + dr["RealName"].ToString() + "</option>"; } hn.InnerHtml = newnode; } break; case "SYS_LIST_PRIV": { newnode = ""; DataTable dt = ULCode.QDA.XSql.GetDataTable("select * from TE_Duties"); foreach (DataRow dr in dt.Rows) { newnode += "<option value=\"" + dr["ID"].ToString() + "\" " + (datas[hn.Attributes["name"].Value].Value == dr["ID"].ToString() ? " selected=\"selected\"" : "") + ">" + dr["Name"].ToString() + "</option>"; } if (hn.Attributes["child"] != null) { child = hn.Attributes["child"].Value + "|DutyID"; } hn.InnerHtml = newnode; } break; case "SYS_LIST_SQL": { newnode = ""; DataTable dt = ULCode.QDA.XSql.GetDataTable(hn.Attributes["datasrc"].Value.ToString()); foreach (DataRow dr in dt.Rows) { newnode += "<option value=\"" + dr["ID"].ToString() + "\" " + (datas[hn.Attributes["name"].Value].Value == dr["ID"].ToString() ? " selected=\"selected\"" : "") + ">" + (dr["Name"] == null || dr["Name"].ToString() == "" ? dr["ID"].ToString() : dr["Name"].ToString()) + "</option>"; } hn.InnerHtml = newnode; } break; default: break; } htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } else { if (datas[hn.Attributes["name"].Value].Value != null && datas[hn.Attributes["name"].Value].Value != "") { hn.InnerHtml = hn.InnerHtml.Replace(" selected=\"selected\"", "").Replace(datas[hn.Attributes["name"].Value].Value + "\">", datas[hn.Attributes["name"].Value].Value + "\" selected=\"selected\">"); } if (hn.OuterHtml.Trim() != "") { htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } } } } hnc = rootNode.SelectNodes("//textarea");//单行文本框 if (hnc != null) { foreach (HtmlNode hn in hnc) { if (editableFlds.Contains(hn.Attributes["name"].Value)) { hn.Attributes.Add("readonly", "readonly"); } if (hiddenFlds.Contains(hn.Attributes["name"].Value)) { if (hn.Attributes["style"] != null) { hn.Attributes["style"].Value = hn.Attributes["style"].Value + ";display:none;"; } else { hn.Attributes.Add("style", "display:none;"); } } if (datas[hn.Attributes["name"].Value].Value != null) { hn.InnerHtml = datas[hn.Attributes["name"].Value].Value;; } newnode = ""; if (hn.OuterHtml.Trim() != "") { if (hn.Attributes["rich"] != null && hn.Attributes["rich"].Value == "1") { newnode = "<div><input type=\"hidden\" id=\"" + hn.Attributes["name"].Value + "\" name=\"" + hn.Attributes["name"].Value + "\" value=\"" + hn.InnerHtml + "\" /><input type=\"hidden\" id=\"" + hn.Attributes["name"].Value + "___Config\" value=\"HtmlEncodeOutput=true\" /><iframe " + (hn.Attributes["style"] != null ? " style=\"" + hn.Attributes["style"].Value + "\"" : "") + (hn.Attributes["readonly"] != null ? " readonly=\"" + hn.Attributes["readonly"].Value + "\"" : "") + " id=\"" + hn.Attributes["name"].Value + "___Frame\" src=\"/fckeditor/editor/fckeditor.html?InstanceName=" + hn.Attributes["name"].Value + "&Toolbar=\"Defaul\" width=\"" + (hn.Attributes["rich_width"] != null ? hn.Attributes["rich_width"].Value : "100%") + "\" height=\"" + (hn.Attributes["rich_width"] != null ? hn.Attributes["rich_height"].Value : "300px") + "\" frameborder=\"no\" scrolling=\"no\"></iframe></div>"; htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", newnode); } else { htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", hn.OuterHtml); } } } } hnc = rootNode.SelectNodes("//img");//单选按钮 if (hnc != null) { foreach (HtmlNode hn in hnc) { newnode = ""; if (hn.OuterHtml.Trim() != "") { string oldnode = hn.OuterHtml; switch (hn.Attributes["class"].Value) { case "RADIO": { string[] items = hn.Attributes["radio_field"].Value.Split('`'); string checkstr = ""; for (int j = 0; j < items.Length; j++) { checkstr = ""; if (items[j] != "") { if (datas[hn.Attributes["name"].Value].Value == "" && hn.Attributes["radio_check"] != null && hn.Attributes["radio_check"].Value == items[j]) { checkstr = "checked"; } else if (datas[hn.Attributes["name"].Value].Value == items[j]) { checkstr = "checked"; } newnode += "<input name=\"" + hn.Attributes["name"].Value + "\" type=\"radio\" title=\"" + hn.Attributes["title"].Value + "\" " + checkstr + " " + (editableFlds.Contains(hn.Attributes["name"].Value) ? "readonly=\"readonly\"" : "") + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? " style='display:none;'" : "") + " value=\"" + items[j] + "\" />" + items[j] + " "; } } htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", newnode); } break; case "DATE": { newnode = "<input name=\"" + hn.Attributes["name"].Value + "\" class=\"" + (hn.Attributes["date_format"].Value == "yyyy-MM-dd" ? "easyui-datebox" : "easyui-datetimebox") + "\" value=\"" + (datas[hn.Attributes["name"].Value].Value == "" ? DateTime.Now.ToString(hn.Attributes["date_format"].Value) : datas[hn.Attributes["name"].Value].Value) + "\" type=\"text\" style=\"" + (hn.Attributes["tsize"] != null ? "width:" + hn.Attributes["tsize"].Value.ToString() + "px;" : "") + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? "display:none;" : "") + "\" " + (editableFlds.Contains(hn.Attributes["name"].Value) ? " readonly=\"readonly\"" : "") + " title=\"" + hn.Attributes["title"].Value + "\" />"; htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", newnode); } break; case "LIST_VIEW": { string[] titles = hn.Attributes["lv_title"].Value.Split('`'); newnode = "<TABLE id='LV_" + hn.Attributes["name"].Value.Split('_')[1] + "' lv_sum=\"" + hn.Attributes["lv_sum"].Value + "\" lv_cal=\"" + hn.Attributes["lv_cal"].Value + "\" lv_coltype=\"" + hn.Attributes["lv_coltype"].Value + "\" lv_colvalue=\"" + hn.Attributes["lv_colvalue"].Value + "\" data_table=\"\" data_field=\"\" data_query=\"\" data_fld_name=\"\" class='LIST_VIEW' style='border-collapse:collapse;" + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? "display:none;" : "") + "' border=1 cellspacing=0 cellpadding=2 FormData='" + hn.Attributes["lv_size"].Value + "'><TR style='font-weight:bold;font-size:14px;' class='LIST_VIEW_HEADER'>\n"; newnode += "<TD nowrap>序号</TD>\n"; for (int i = 0; i < titles.Length - 1; i++) { newnode += "<TD nowrap>" + titles[i] + "</TD>\n"; } newnode += "<TD>操作</TD></TR></TABLE>\n"; newnode += "<input type=button value=新增 " + (editableFlds.Contains(hn.Attributes["name"].Value) ? " readonly=\"readonly\"" : "") + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? "style=\"display:none;\"" : "") + " onclick=\"tb_addnew('LV_" + hn.Attributes["name"].Value.Split('_')[1] + "','0','" + hn.Attributes["lv_colvalue"].Value + "','1')\">\n"; newnode += "<input type=button value=计算 " + (editableFlds.Contains(hn.Attributes["name"].Value) ? " readonly=\"readonly\"" : "") + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? "style=\"display:none;\"" : "") + " onclick=\"tb_cal('LV_" + hn.Attributes["name"].Value.Split('_')[1] + "','" + hn.Attributes["lv_cal"].Value + "')\">\n"; newnode += "<input type=hidden class=\"LIST_VIEW\" name=" + hn.Attributes["name"].Value + ">\n"; newnode += "<br />\n"; newnode += "<br />\n"; htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", newnode); } break; case "SIGN": { string[] types = hn.Attributes["sign_type"].Value.Split(','); if (types[0] == "1") { newnode = "<input id=\"Button1\" type=\"button\" value=\" 盖 章 \" onclick=\"addseal()\" " + (editableFlds.Contains(hn.Attributes["name"].Value) ? "readonly=\"readonly\"" : "") + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? " style='display:none;'" : "") + " />"; } if (types[1] == "1") { newnode += "<input id=\"Button2\" type=\"button\" value=\" 手 写 \" onclick=\"handwrite()\" " + (editableFlds.Contains(hn.Attributes["name"].Value) ? "readonly=\"readonly\"" : "") + (hiddenFlds.Contains(hn.Attributes["name"].Value) ? " style='display:none;'" : "") + " />"; } if (newnode != "") { newnode += "<input type=\"hidden\" name=\"" + hn.Attributes["name"].Value + "\" value=\"" + datas[hn.Attributes["name"].Value].Value + "\" id=\"txtSealData\" />"; } htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", newnode); } break; case "USER": { newnode = "<input type=\"hidden\" name=\"" + hn.Attributes["name"].Value + "\" value=\"" + datas[hn.Attributes["name"].Value].Value + "\" id=\"" + hn.Attributes["name"].Value + "\" />"; string txtvalue = ""; try { if (datas[hn.Attributes["name"].Value].Value.Trim() != "") { DataTable dduname = ULCode.QDA.XSql.GetDataTable("select RealName from TU_Users where UserID='" + datas[hn.Attributes["name"].Value].Value + "'"); if (dduname.Rows.Count > 0) { txtvalue = dduname.Rows[0][0].ToString(); } } } catch { } newnode += "<input type=\"text\" name=\"txt" + hn.Attributes["name"].Value + "\" value=\"" + txtvalue + "\" size=\"12\" readonly=\"readonly\" id=\"txt" + hn.Attributes["name"].Value + "\"/>"; newnode += " ╋<a href=\"javascript:void(0)\" onclick=\"PopupIFrame('/App_Ctrl/SelectPeople.aspx?CompanyId=11','选择人员','" + hn.Attributes["name"].Value + "','txt" + hn.Attributes["name"].Value + "',468,395);\">选择</a>"; htmls = htmls.Replace("{" + hn.Attributes["name"].Value + "}", newnode); } break; default: break; } } } } return(htmls); //return htmls; }
/// <summary> /// 保存 /// </summary> /// <param name="step">第几步</param> /// <param name="fldDatas">字段信息与数据</param> /// <param name="attacheIdList">附件id列表</param> /// <param name="attacheNameList">附件Name列表</param> /// <param name="signText"></param> /// <param name="signData"></param> /// <param name="flag">状态</param> /// <returns></returns> public int Save(int step, FormFieldCollection fldDatas, string attacheIdList, string attacheNameList, string signText, string signData, int flag) { //1.保存fldDatas到FL_RunDatas_{N}中 this.LoadMyForm(false); String sSql = String.Format("select * from sysobjects where xtype='u' and name='FL_RunDatas_{0}'", this.MyForm.Id); if (!ULCode.QDA.XSql.IsHasRow(sSql)) { sSql = String.Format("Select * into FL_RunDatas_{0} from FL_RunDatas", this.MyForm.Id); ULCode.QDA.XSql.Execute(sSql); } sSql = String.Format("Select * from FL_RunDatas_{0} where RunId={1}", this.MyForm.Id, this.Id); if (ULCode.QDA.XSql.IsHasRow(sSql)) { sSql = String.Format("Update FL_RunDatas_{0} set Datas='{2}' where RunId={0}", this.MyForm.Id, this.Id, fldDatas.GetSavedDatas(FormFieldDataType.Data)); } else { sSql = String.Format("insert into FL_RunDatas_{0}(Name,FormId,RunId,BeginUserId,BeginTime,Datas) Values('{2}','{0}','{1}','{3}','{4}','{5}')" , this.MyForm.Id , this.Id , this.Name , this.BeginUser.ToString() , this.BeginTime , fldDatas.GetSavedDatas(FormFieldDataType.Data)); } int iR0 = ULCode.QDA.XSql.Execute(sSql); //2.保存attacheIdList, attacheNameList到当前步骤 if (!String.IsNullOrEmpty(attacheIdList)) { if (this.Attach_IdList.isEmpty) { this.Attach_IdList.set_String_Append(attacheIdList); } else { this.Attach_IdList.set_String_Append("," + attacheIdList); } } if (!String.IsNullOrEmpty(attacheNameList)) { if (this.Attach_NameList.isEmpty) { this.Attach_NameList.set_String_Append("," + attacheNameList); } else { this.Attach_NameList.set_String_Append("," + attacheNameList); } } //this.Attach_IdList.set_String_AppendFormat(",{0}", attacheIdList); //this.Attach_NameList.set_String_AppendFormat(",{0}", attacheNameList); int iR1 = this.Update(); //3.保存SignText与SignData sSql = String.Format("if exists(select * from FL_RunFeedBack where RunId={0} and StepNo={1} and UserId='{4}' and FeedFlag=0)" + " Update FL_RunFeedBack set Content='{2}',SignData='{3}',FeedFlag={7},EditTime=GetDate(),CheckUserID='" + WX.Public.CurUser.UserID + "' where RunId={0} and StepNo={1} and UserId='{4}' and FeedFlag=0;" + " else " + " Insert into FL_RunFeedBack(RunId,StepNo,UserId,Content,Attach_IdList,Attach_NameList,EditTime,FeedFlag,SignData,ReplyId,CheckUserID)" + " values({0},{1},'{4}','{2}','{5}','{6}',GetDate(),{7},'{3}',0,'{8}');" , this.Id, step, signText, signData, this.BeginUser.ToString(), null, null, flag, WX.Public.CurUser.UserID); int iR2 = ULCode.QDA.XSql.Execute(sSql); WX.Flow.Model.Process.MODEL proc = WX.Flow.Model.Process.GetModel("select * from FL_Process where FlowID=" + this.FlowId.ToString() + " and StepNo=" + step); if (proc != null && proc.UpdateTable.ToString() != "") { sSql = String.Format("if exists(select * from {0} where UserID='{2}') update {0} set {1} where UserID='{2}'; else begin Insert into {0} (UserID) values('{2}');update {0} set {1} where UserID='{2}';end", proc.UpdateTable.ToString(), proc.UpdateKeyValue, this.BeginUser.ToString()); ULCode.QDA.XSql.Execute(sSql); } if (iR0 * iR1 * iR2 > 0) { //Succeess; } else { //Faild } return(iR2); }
/// <param name="action">Form action</param> /// <param name="html">Html of the form</param> /// <param name="fields">Form fields</param> public Form(Uri action, string html, FormFieldCollection fields) { Fields = fields; Html = html; Action = action; }
/// <summary> /// Send an SMS to a specified phone number /// </summary> /// <param name="phoneNumber">Phone number to send the sms to</param> /// <param name="message">SMS Message</param> public void SendSms(string phoneNumber, string message) { if (!_isLoggedIn) throw new InvalidOperationException("Not logged in"); if (_isDisposed) throw new ObjectDisposedException(GetType().Name); var formData = new FormFieldCollection { new FormField(PHONENUMBER_FIELD, phoneNumber), new FormField(TEXT_FIELD, message), new FormField(RNR_SE_FIELD, _rnrSe) }; var response = _webManager.PerformPost(SendSmsUri, formData, FormFieldSerializationType.UrlEncoded); using (var streamReader = new StreamReader(response.Response)) { var result = JsonConvert.DeserializeObject<Result>(streamReader.ReadToEnd()); if (!result.Ok) throw new GVoiceException(result.Data.Code); } }
public static void SetValueFieldsInDocument(this Document document, List <FieldProperties> listValues, FormFieldCollection formFields) { int count = 0; foreach (var field in formFields) { var value = listValues.Where(l => l.Name == field.Name).FirstOrDefault(); if (value != null) { field.Result = value.Result; } else { count++; } } NumberFieldsWithoutValue = count; }
[Test] //ExSkip public void FormField() { Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a document builder to insert a combo box FormField comboBox = builder.InsertComboBox("MyComboBox", new[] { "One", "Two", "Three" }, 0); comboBox.CalculateOnExit = true; Assert.AreEqual(3, comboBox.DropDownItems.Count); Assert.AreEqual(0, comboBox.DropDownSelectedIndex); Assert.True(comboBox.Enabled); // Use a document builder to insert a check box FormField checkBox = builder.InsertCheckBox("MyCheckBox", false, 50); checkBox.IsCheckBoxExactSize = true; checkBox.HelpText = "Right click to check this box"; checkBox.OwnHelp = true; checkBox.StatusText = "Checkbox status text"; checkBox.OwnStatus = true; Assert.AreEqual(50.0d, checkBox.CheckBoxSize); Assert.False(checkBox.Checked); Assert.False(checkBox.Default); builder.Writeln(); // Use a document builder to insert text input form field FormField textInput = builder.InsertTextInput("MyTextInput", TextFormFieldType.Regular, "", "Your text goes here", 50); textInput.EntryMacro = "EntryMacro"; textInput.ExitMacro = "ExitMacro"; textInput.TextInputDefault = "Regular"; textInput.TextInputFormat = "FIRST CAPITAL"; textInput.SetTextInputValue("This value overrides the one we set during initialization"); Assert.AreEqual(TextFormFieldType.Regular, textInput.TextInputType); Assert.AreEqual(50, textInput.MaxLength); // Get the collection of form fields that has accumulated in our document FormFieldCollection formFields = doc.Range.FormFields; Assert.AreEqual(3, formFields.Count); // Our form fields are represented as fields, with field codes FORMDROPDOWN, FORMCHECKBOX and FORMTEXT respectively, // made visible by pressing Alt + F9 in Microsoft Word // These fields have no switches and the content of their form fields is fully governed by members of the FormField object Assert.AreEqual(3, doc.Range.Fields.Count); // Iterate over the collection with an enumerator, accepting a visitor with each form field FormFieldVisitor formFieldVisitor = new FormFieldVisitor(); using (IEnumerator <FormField> fieldEnumerator = formFields.GetEnumerator()) while (fieldEnumerator.MoveNext()) { fieldEnumerator.Current.Accept(formFieldVisitor); } Console.WriteLine(formFieldVisitor.GetText()); doc.UpdateFields(); doc.Save(ArtifactsDir + "Field.FormField.docx"); TestFormField(doc); //ExSkip }