private void LoadField() { var fieldNode = FieldSetsHelper.FindField(_fieldSetsXml, lbDataSet.Text, _fieldName); if (fieldNode != null) { var config = new PFModelConfig(fieldNode, lbDataSet.Text); tbName.Text = config.FieldName; tbText.Text = config.FieldText; if (config.FieldType != null) { cbType.SelectedItem = PFDataHelper.GetStringByType(config.FieldType); } cbVisible.Checked = config.Visible; if (config.FieldSqlLength != null) { nudSqlLength.Value = config.FieldSqlLength.Value; nudSqlLength.ReadOnly = !(cbHaveSqlLength.Checked = true); } else { nudSqlLength.ReadOnly = !(cbHaveSqlLength.Checked = false); } if (config.FieldWidth != null) { nudWidth.Value = decimal.Parse(config.FieldWidth.Replace("px", "")); nudWidth.ReadOnly = !(cbHaveWidth.Checked = true); } else { nudWidth.ReadOnly = !(cbHaveWidth.Checked = false); } //_pfModelConfig = config; } }
public PFGridColumn(StoreColumn c) { this.DataIndex = c.data; this.Text = c.title ?? c.data; this.Width = c.width; this.Visible = c.visible; if (!this.Visible) { SetClassName("col-h"); } if (!string.IsNullOrWhiteSpace(c.dataType)) { var dataType = PFDataHelper.GetTypeByString(c.dataType); SetStyleByDataType(this, dataType); //bool isPercent = dataType == typeof(PFPercent); //if (dataType == typeof(decimal) || dataType == typeof(int) || isPercent) //{ // SetStyle("text-align:right;padding-right: 9px"); // Render = (cc, r, v) => // { // var rr = PFDataHelper.Thousandth(v); // if (isPercent) // { // rr += " %"; // } // return rr; // }; // SetClassName("col-r"); //} } }
public override void SetPropertyFor <TModel, TProperty>(HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression) { base.SetPropertyFor(htmlHelper, expression); //var t = typeof(TProperty); var t = PFDataHelper.GetNonnullType(typeof(TProperty)); var v = PFMVCHelper.ExpressionValueFor(htmlHelper, expression); if (v != null) { if (t.IsEnum) { _selectedValue = ((int)v).ToString(); } else { _selectedValue = v.ToString(); } } if (t.IsEnum) { SetSelectList(PFDataHelper.EnumToKVList(t)); } //_selectedValue = (PFMVCHelper.ExpressionValueFor(htmlHelper,expression)??"").ToString(); //_selectedText = (PFMVCHelper.ExpressionValueFor(htmlHelper, expression) ?? "").ToString();//这里用text,是因为即便是enum,ToString后肯定是需要显示的值 }
public void TestPFEmailMq() { var resMsg = ""; var p = new PagingParameters(); p["backupDatabase"] = "bonus"; TestPFEmailMqConsumer tmpObj = new TestPFEmailMqConsumer(); PFMqHelper.BuildConsumer(tmpObj); Thread.Sleep(2000);//不延迟的话,后面太快了,前面还没开始监听 var st = DateTime.Now; var message = JsonConvert.SerializeObject(p); var t = PFMqHelper.BuildProducer(message, new TestPFEmailMqProducer()); t.Wait(); var et = DateTime.Now; resMsg = t.Result.Body; var usedTime = PFDataHelper.GetTimeSpan(et - st);//平均6秒 Assert.IsTrue(resMsg == JsonConvert.SerializeObject("接收到信息:" + message)); //Assert.IsTrue(true); }
/// <summary> /// 便于controller中把前端的值提交过来 /// </summary> /// <param name="year">2014</param> /// <param name="smon">1</param> /// <param name="emon">2</param> public static void GetCMonthRange(string year, string smon, string emon, out string sCMonth, out string eCMonth) { int yearInt = PFDataHelper.ObjectToInt(year) ?? 0; sCMonth = PFDataHelper.DateToCMonth(new DateTime(yearInt, PFDataHelper.ObjectToInt(smon) ?? 0, 1)); eCMonth = PFDataHelper.DateToCMonth(new DateTime(yearInt, PFDataHelper.ObjectToInt(emon) ?? 0, 1)); }
private async Task TestAsync() { await Task.Run(() => { var t = PFDataHelper.CountTime(() => { Thread.Sleep(5000); }); AppendResult(string.Format("task finish {0}", PFDataHelper.GetTimeSpan(t))); }); }
public void TestSendEmail() { PFDataHelper.SendEmail(UserEmailUserName, UserEmailPwd, UserEmailHostName, new string[] { PFDataHelper.SysEmailUserName }, "aaa", "aaaaa"); return; string emailTitle = "test_PFEmailMq_producer_会员资料表";//中文有问题--benjamin todo //string emailBody = "会员资料表"; //string emailBody = "hyzlTable_aabb_中国人"; string emailBody = @" <p>2019.01月结数据备份情况:<p> <ol> <li>aaa</li> <li>bbb</li> </ol> "; //string producerEmailTitle = "PFEmailMq_producer_" + "hyzl"; //消费方(使用系统邮箱) PFEmail result = null; bool success = false; var consumerTask = new PFListenEmailTask("TestForceUpdateHyzl", new PFEmailManager(PFDataHelper.SysEmailHostName, PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd), email => { result = email; success = true; }, (email//, task ) => { return(email.Subject == emailTitle); }); consumerTask.Start(); //生产方(使用User邮箱,也可以用系统邮箱吧) var rt = new Task(() => { PFDataHelper.SendEmail(UserEmailUserName, UserEmailPwd, UserEmailHostName, new string[] { PFDataHelper.SysEmailUserName }, emailTitle, emailBody); }); rt.Start(); rt.Wait(); while (!success) { Thread.Sleep(2000); } Assert.IsTrue(emailTitle == result.Subject); }
private Task TestTask() { var rt = new Task(() => { var t = PFDataHelper.CountTime(() => { Thread.Sleep(5000); }); AppendResult(string.Format("task finish {0}", PFDataHelper.GetTimeSpan(t))); }); rt.Start(); return(rt); }
private async Task <bool> IsTestAsync() { var b = false; await Task.Run(() => { var t = PFDataHelper.CountTime(() => { Thread.Sleep(5000); }); AppendResult(string.Format("task finish {0}", PFDataHelper.GetTimeSpan(t))); b = true; }); return(b); }
public override MvcHtmlString Html(HtmlHelper htmlHelper, string name, object value) { var htmlAttributes = GetHtmlAttributes(); var result = ""; if (!Readonly) { if (htmlHelper.ViewData["hasDataBoxJs"] == null) { var configMapper = PFDataHelper.GetConfigMapper(); var pathConfig = configMapper.GetPathConfig(); result = string.Format("<script language='javascript' type='text/javascript' src='/{0}'></script>", pathConfig.DataBoxJsPath); htmlHelper.ViewData["hasDataBoxJs"] = true; } } return(new MvcHtmlString(result + htmlHelper.TextBox(name, PFDataHelper.ObjectToDateString(value, _format), htmlAttributes).ToString())); }
static void Main() { PFDataHelper.SetConfigMapper(new PFConfigMapper()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var win = new MainTabForm(); win.WindowState = System.Windows.Forms.FormWindowState.Maximized; //Application.Run(new Form1()); //Application.Run(new FuncForm()); Application.Run(win); //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); ////Application.Run(new Form1()); //Application.Run(new MainTabForm()); }
public static void SetStyleByDataType(PFGridColumn c, Type dataType) { bool isPercent = dataType == typeof(PFPercent); if (dataType == typeof(decimal) || dataType == typeof(int) || isPercent) { c.SetStyle("text-align:right;padding-right: 9px"); c.Render = (cc, r, v) => { var rr = PFDataHelper.Thousandth(v); if (isPercent) { rr += " %"; } return(rr); }; c.SetClassName("col-r"); } }
public virtual void ColumnsForAll(string modelConfigName) { var cs = new PFGridColumnCollection { Grid = this }; if (!string.IsNullOrWhiteSpace(modelConfigName)) { cs.SetModelConfig(modelConfigName); } if (_model != null && _model.Count > 0) { if (_model[0] is TreeListItem) { PFDataHelper.EachObjectProperty((_model[0] as TreeListItem).Data, (i, name, value) => { ////旧版只有一句?待验证--benjamin todo 20191014 //cs.Add(name); var c = cs.Add(name); if (value != null) { PFGridColumn.SetStyleByDataType(c, value.GetType()); } }); } else if (_model[0] is Dictionary <string, object> )//新版才有这段代码?待验证--benjamin todo 20191014 { var dict = (_model[0] as Dictionary <string, object>); foreach (var key in dict.Keys) { var c = cs.Add(key); var value = dict[key]; if (value != null) { PFGridColumn.SetStyleByDataType(c, value.GetType()); } } } } cs.ForEach(_columns.Add); }
public List <CompareCnt> GetAllMonthDataSrcList(string backupDatabase) { string sql = string.Format(@" declare @sql nvarchar(max) create table #m001(SrcTbName varchar(max),idd int identity(1,1),Flag bit,Total int,TotalMonth varchar(7),TotalDate DateTime,SrcCnt int,DstCnt int) set @sql=N'insert into #m001(SrcTbName) select name from {0}.dbo.sysobjects where xtype=''u'' and name<>''t_zxbmonth'' '; exec (@sql) select * from #m001 ", backupDatabase); var proc = SrcSqlExec; var dt = proc.GetQueryTable(sql); var list = new List <CompareCnt>(); if (dt != null && dt.Rows.Count > 0) { list = PFDataHelper.DataTableToList <CompareCnt>(dt).OrderBy(a => a.SrcTbName).ToList(); } return(list); }
private void startConvertBtn_Click(object sender, EventArgs e) { if (fileDGView.Rows.Count < 1) { MessageBox.Show("无待转换文件"); return; } foreach (DataGridViewRow row in fileDGView.Rows) { if (!row.IsNewRow) { var path = row.Cells["FileName"].Value.ToString(); //Encoding encode = TxtFileEncoder.GetEncoding(i); Encoding encode = TxtFileEncoder.GetEncoding((Stream) new FileStream(path, FileMode.Open)); string s = PFDataHelper.ReadFileToString(path, encode); PFDataHelper.SaveStringToFile(s, Path.Combine(PFDataHelper.BaseDirectory, "OutFile", Path.GetFileName(path))); } } System.Diagnostics.Process.Start(Path.Combine(PFDataHelper.BaseDirectory, "OutFile")); }
private void packZipBtn_Click(object sender, EventArgs e) { PFWinFormHelper.GetGridSelectedRows(pathDGView, rows => { //var targetPath = "D:\\wxj\\pf_project"; var targetPath = ConfigurationManager.AppSettings["ZipTargetPath"]; PFDataHelper.CreateDirectory(targetPath); PFWinFormHelper.MultiFuncLoadingFlag = true; //flag 为false时候,退出执行耗时操作 MultiFuncLoading loadingfrm = new MultiFuncLoading(this); // 将Loaing窗口,注入到 SplashScreenManager 来管理 SplashScreenManager loading = new SplashScreenManager(loadingfrm); loading.ShowLoading(); // 设置loadingfrm操作必须在调用ShowLoading之后执行 loadingfrm.SetTxt("多功能Loaidng界面", "拼命加载中...客官耐心等待", "Please Waitting..."); // try catch 包起来,防止出错 try { int i = 0; int total = rows.Count; foreach (var row in rows) { i++; ZipUtility zip = new ZipUtility(); var path = row.Cells["FolderPath"].Value.ToString(); var fileName = row.Cells["FolderName"].Value.ToString(); var excludeFolderArr = row.Cells["excludeFolder"].Value == null ? null : row.Cells["excludeFolder"].Value.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); loadingfrm.SetJD("当前:正在打包", "当前进度:" + fileName + "(" + i + "/" + total + ")"); zip.ZipFileFromDirectory(path, Path.Combine(targetPath, fileName + "_" + DateTime.Now.ToString("yyyyMMdd") + "_" + ConfigurationManager.AppSettings["FromWhere"] + ".zip"), 4, excludeFolderArr); } } catch (Exception) { /*可选处理异常*/ } finally { loading.CloseWaitForm(); } System.Diagnostics.Process.Start(targetPath); //如果是本地访问就直接打开文件夹 }); }
protected PFModelConfig GetModelPropertyConfig <TModel, TProperty>(HtmlHelper htmlHelper, Expression <Func <TModel, TProperty> > expression) { var modelType = typeof(TModel); //var modelConfig = PFDataHelper.GetModelConfig(modelType.Name, modelType.FullName); //if (modelConfig == null) //{ // modelConfig = htmlHelper.ViewData["modelConfig"] as PFModelConfigCollection; //} var modelConfig = PFDataHelper.MergeModelConfig( PFDataHelper.GetModelConfig(modelType.Name, modelType.FullName), htmlHelper.ViewData["modelConfig"] as PFModelConfigCollection ); if (modelConfig == null) { return(null); } var propertyName = ExpressionHelper.GetExpressionText(expression); var config = modelConfig[propertyName]; return(config); }
public void Init(object data) { var type = PFDataHelper.GetGenericType(data); var tableName = PFDataHelper.IsDynamicType(type) ? string.Empty : type.Name; table = new DataTable(tableName); PFDataHelper.EachListHeader(data, (rowIndex, name, cellType) => { string typeName = cellType.ToString(); if (cellType.IsGenericType) { typeName = cellType.GetGenericArguments()[0].ToString(); } Type newType = Type.GetType(typeName, false); if (newType != null) { table.Columns.Add(name, newType); } }); table.BeginLoadData(); title = new List <string>(); }
//[TestMethod] //public void TestSendEmailAsync() { // string producerEmailTitle = "PFEmailMq_producer_"+ "会员资料表";//中文有问题--benjamin todo // //string producerEmailTitle = "PFEmailMq_producer_" + "hyzl"; // //消费方(使用系统邮箱) // string result = ""; // bool success = false; // var consumerTask = new PFListenEmailTask("TestForceUpdateHyzl", // new PFEmailManager(PFDataHelper.SysEmailHostName, PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd), // email => // { // result = "{success:true}"; // //消费方回复邮件 // PFDataHelper.SendEmail(PFDataHelper.SysEmailUserName, PFDataHelper.SysEmailPwd, PFDataHelper.SysEmailHostName, // new string[] { UserEmailUserName }, "PFEmailMq_consumer_" + email.Subject, // result); // }, // (email//, task // ) => // { // //消费方监听生产方邮件 // //return email.Subject != null && email.Subject.IndexOf("TestForceUpdateHyzl_") == 0;//这里不要用>-1,否则可能把自动回复的邮件也当作是了 // return email.Subject== producerEmailTitle; // }); // consumerTask.Start(); // //生产方(使用User邮箱,也可以用系统邮箱吧) // var rt=PFDataHelper.SendEmailAsync(UserEmailUserName, UserEmailPwd, UserEmailHostName, // new string[] { PFDataHelper.SysEmailUserName }, // producerEmailTitle, "会员资料表"); // rt.Wait(); // var resultTitle = rt.Result.Subject; // Assert.IsTrue(resultTitle== "PFEmailMq_consumer_" + producerEmailTitle); //} private String GetDateString() { return(PFDataHelper.ObjectToDateString(DateTime.Now, PFDataHelper.DateFormat)); }
public void SetModelConfig(string name, string fullName) { _modelConfig = PFDataHelper.GetModelConfig(name, fullName); }
public void TestEncode() { //=?utf-8?B?UEZFbWFpbE1xX3Byb2R1Y2VyX+S8muWRmOi1hOaWmeihqA==?= string s1 = "UEZFbWFpbE1xX3Byb2R1Y2VyX+S8muWRmOi1hOaWmeihqA=="; var v1 = PFDataHelper.Decode(s1, PFEncodeType.Base64, PFEncodeType.UTF8); Assert.IsTrue(v1 == "PFEmailMq_producer_会员资料表"); var r1 = PFDataHelper.Encode(v1, PFEncodeType.Base64, PFEncodeType.UTF8); Assert.IsTrue(r1 == s1); //=?gb18030?B?UEZFbWFpbE1xX3Byb2R1Y2VyX2Zyb21RUU1haWxf?= string s2 = "UEZFbWFpbE1xX3Byb2R1Y2VyX2Zyb21RUU1haWxf"; var v2 = PFDataHelper.Decode(s2, PFEncodeType.Bit8, PFEncodeType.GB18030); Assert.IsTrue(v2 == "PFEmailMq_producer_fromQQMail_"); var r2 = PFDataHelper.Encode(v2, PFEncodeType.Bit8, PFEncodeType.GB18030); Assert.IsTrue(r2 == s2); //qqmail body string s3 = "MjAxOS4wMdTCveHK/b7dsbi33cfpv/Y6DQoNCiANCiANCmFhYQ0KIA0KYmJi"; var v3 = PFDataHelper.Decode(s3, PFEncodeType.Bit8, PFEncodeType.GB18030); Assert.IsTrue(v2 == "PFEmailMq_producer_fromQQMail_"); //var r2 = PFDataHelper.Encode(v2, PFEncodeType.Bit8, PFEncodeType.GB18030); //Assert.IsTrue(r2 == s2); //126mail Subject: =?GBK?Q?PFEmailMq=5Fproducer?= //=?GBK?Q?=5Ffrom126Mail=5F=BB=E1=D4=B1=D7=CA=C1=CF=B1=ED?= var s4 = "PFEmailMq=5Fproducer"; var v4 = PFDataHelper.Decode(s4, PFEncodeType.QuotedPrintable, PFEncodeType.GBK); Assert.IsTrue(v4 == "PFEmailMq_producer"); var s5 = "=5Ffrom126Mail=5F=BB=E1=D4=B1=D7=CA=C1=CF=B1=ED"; var v5 = PFDataHelper.Decode(s5, PFEncodeType.QuotedPrintable, PFEncodeType.GBK); Assert.IsTrue(v5 == "_from126Mail_会员资料表"); //aliyunEmail //PGRpdiBjbGFzcz0iX19hbGl5dW5fZW1haWxfYm9keV9ibG9jayI+PGRpdiAgc3R5bGU9ImxpbmUt var s6 = "PGRpdiBjbGFzcz0iX19hbGl5dW5fZW1haWxfYm9keV9ibG9jayI+PGRpdiAgc3R5bGU9ImxpbmUt"; var v6 = PFDataHelper.Decode(s6, PFEncodeType.Base64, PFEncodeType.UTF8); Assert.IsTrue(v6 == "<div class=\"__aliyun_email_body_block\"><div style=\"line-"); var s7 = "<html xmlns:v=3D\"urn:schemas-microsoft-com:vml\" ";//只要没最后的等号就不报错 var v7 = PFDataHelper.Decode(s7, PFEncodeType.QuotedPrintable, PFEncodeType.GB2312); //正确是 <html xmlns:v="urn:schemas-microsoft-com:vml" % //参考http://web.chacuo.net/charsetquotedprintable/ //=?GB2312?B?16q3ojogRnc6IMfryr4=?= string s8 = "16q3ojogRnc6IMfryr4="; var v8 = PFDataHelper.Decode(s8, PFEncodeType.Bit8, PFEncodeType.GB2312); Assert.IsTrue(v8 == "转发: Fw: 请示"); var r8 = PFDataHelper.Encode(v8, PFEncodeType.Bit8, PFEncodeType.GB2312); Assert.IsTrue(r8 == s8); }
/// <summary> /// if(@dstTbExist=1)是为了,如果30中加了新表,那之前的月份的dst库中可能不存在该表 /// </summary> /// <param name="backupDatabase">不包含月份</param> /// <param name="needRowCount">不需要行数时不查(提高效率)</param> /// <param name="notInTableNames">排除某些表(提高效率),为空时默认查全部表</param> /// <returns></returns> public List <CompareCnt> GetCompareCntList(string backupDatabase, bool needRowCount, string[] notInTableNames = null) { var proc = SrcSqlExec; var sql = string.Format(@" declare @sql nvarchar(max),@cmonth varchar(7),@ym varchar(6),@now datetime,@b bit,@c int,@dbname varchar(max),@dbpath varchar(max),@src varchar(max),@dst varchar(max),@commited bit,@dstTbExist bit; set @src='192.168.0.30' set @dst='192.168.0.33' set @cmonth='{0}' set @ym=left(@cmonth,4)+RIGHT(@cmonth,2) create table #m001(SrcTbName varchar(max),idd int identity(1,1),Flag bit,Total int,TotalMonth varchar(7),TotalDate DateTime,SrcCnt int,DstCnt int) set @sql=N'insert into #m001(SrcTbName) select name from {1}.dbo.sysobjects where xtype=''u'' and name<>''t_zxbmonth'' {3} '; exec (@sql) Declare @idx int=1,@max int,@tname varchar(max); select @max=MAX(idd) from #m001 While(@idx<=@max) Begin select top 1 @tname=SrcTbName from #m001 where idd=@idx SELECT @sql= N' if exists (select * from ['+@dst+'].{1}'+@ym+'.dbo.sysobjects where xtype=''u'' and name='''+@tname+''') begin set @a=1 end else begin set @a=0 end ' EXEC sp_executesql @sql,N'@a bit output',@dstTbExist OUTPUT if(@dstTbExist=1 and 1={2}) begin set @sql=N' update #m001 set SrcCnt=( select count(*) from {1}.dbo.'+@tname+' ), DstCnt=( select count(*) from ['+@dst+'].{1}'+@ym+'.dbo.'+@tname+' ) where SrcTbName='''+@tname+''' ' exec (@sql) end update #m001 set Flag=aa.Flag,Total=aa.qty,TotalMonth=aa.cmonth,TotalDate=aa.cdate from (select Flag,qty,cmonth,cdate from {1}.dbo.t_zxbmonth where tbname=@tname) aa where SrcTbName=@tname set @idx=@idx+1 End --统计表单独 set @sql=N'insert into #m001(SrcTbName,SrcCnt,DstCnt) select ''t_zxbmonth'', (select count(*) from {1}.dbo.t_zxbmonth), (select count(*) from ['+@dst+'].{1}'+@ym+'.dbo.t_zxbmonth) '; exec (@sql) select * from #m001 drop table #m001 ", Cmonth, backupDatabase, needRowCount ? 1 : 0, (notInTableNames != null && notInTableNames.Any()) ? string.Format(" and name not in (''{0}'') ", string.Join("'',''", notInTableNames)) : ""); var dt = proc.GetQueryTable(sql); var list = new List <CompareCnt>(); if (dt != null && dt.Rows.Count > 0) { list = PFDataHelper.DataTableToList <CompareCnt>(dt).OrderBy(a => a.SrcTbName).ToList(); } return(list); }
private void UpdateFieldNodeByForm(ref XmlNode fieldNode) { UpdateFieldNodeProperty(ref fieldNode, "FieldText", tbText.Text, () => true); UpdateFieldNodeProperty(ref fieldNode, "FieldType", cbType.SelectedItem as string, () => !PFDataHelper.StringIsNullOrWhiteSpace(cbType.SelectedItem as string)); UpdateFieldNodeProperty(ref fieldNode, "FieldSqlLength", nudSqlLength.Value.ToString(), () => cbHaveSqlLength.Checked); UpdateFieldNodeProperty(ref fieldNode, "FieldWidth", nudWidth.Value.ToString(), () => cbHaveWidth.Checked); UpdateFieldNodeProperty(ref fieldNode, "Visible", cbVisible.Checked?"true": "false", () => !cbVisible.Checked);//其实,true时没有保存节点 #region old //var n = fieldNode.SelectSingleNode("FieldText"); //if (n != null) { n.InnerText = tbText.Text; } //var t = fieldNode.SelectSingleNode("FieldType"); //if (t != null) { t.InnerText = cbType.SelectedItem.ToString(); } //var l = fieldNode.SelectSingleNode("FieldSqlLength"); //if (l != null) //{ // if (cbHaveSqlLength.Checked) { l.InnerText = nudSqlLength.Value.ToString(); } else { fieldNode.RemoveChild(l); } //} //else //{ // if (cbHaveSqlLength.Checked) // { // XmlNode sqlLengthNode = _fieldSetsXml.CreateNode("element", "FieldSqlLength", ""); // sqlLengthNode.InnerText = nudSqlLength.Value.ToString(); // fieldNode.AppendChild(sqlLengthNode); // } //} //var w = fieldNode.SelectSingleNode("FieldWidth"); //if (w != null) //{ // if (cbHaveWidth.Checked) { w.InnerText = nudWidth.Value.ToString(); } else { fieldNode.RemoveChild(w); } //} //else //{ // if (cbHaveWidth.Checked) // { // XmlNode widthNode = _fieldSetsXml.CreateNode("element", "FieldWidth", ""); // widthNode.InnerText = nudWidth.Value.ToString(); // fieldNode.AppendChild(widthNode); // } //} //var v = fieldNode.SelectSingleNode("Visible"); //if (v != null) //{ // if (cbVisible.Checked) { fieldNode.RemoveChild(v); } //} //else //{ // if (!cbVisible.Checked) // { // XmlNode visibleNode = _fieldSetsXml.CreateNode("element", "Visible", ""); // visibleNode.InnerText = "false"; // fieldNode.AppendChild(visibleNode); // } //} #endregion }
public void TestEmail() { PFEmail email = null; string subject = null; string body = null; //var message = JsonConvert.DeserializeObject<List<string>>(PFDataHelper.ReadLocalTxt("mailFujianJson.txt")); //email = new PFEmail(message); //body = email.Body; ////return; //Assert.IsTrue(body == "各们领导、同事:\r\n\r\n 附件为油葱架构文档V1.5版,请查收,谢谢\r\n\r\n \r\n\r\n \r\n\r\n陈辉\r\n\r\n"); List <KeyValuePair <string, KeyValuePair <string, string> > > fileNames = new List <KeyValuePair <string, KeyValuePair <string, string> > > { new KeyValuePair <string, KeyValuePair <string, string> >( "126Email.txt", new KeyValuePair <string, string>( "PFEmailMq_producer_from126Mail_会员资料表", "2019.01月结数据备份情况:\n\naaa\nbbb\n\n")), new KeyValuePair <string, KeyValuePair <string, string> >( "aliyunEmail.txt", new KeyValuePair <string, string>( "[SPAM]PFEmailMq_producer_fromSellGirl_会员资料表", "\n<p>2019.01月结数据备份情况:<p>\n<ol>\n<li>aaa</li>\n<li>bbb</li>\n</ol>")), new KeyValuePair <string, KeyValuePair <string, string> >( "perfect99Email.txt", new KeyValuePair <string, string>( "PFEmailMq_producer_会员资料表", "\r\n<p>2019.01月结数据备份情况:<p>\r\n<ol>\r\n<li>aaa</li>\r\n<li>bbb</li>\r\n</ol>\r\n")), new KeyValuePair <string, KeyValuePair <string, string> >( "perfect99Email_含附件.txt", new KeyValuePair <string, string>( "油葱架构文档V1.5版", "各们领导、同事:\r\n\r\n 附件为油葱架构文档V1.5版,请查收,谢谢\r\n\r\n \r\n\r\n \r\n\r\n陈辉\r\n\r\n")), #region qqEmail new KeyValuePair <string, KeyValuePair <string, string> >( "qqEmail.txt", new KeyValuePair <string, string>( "PFEmailMq_producer_fromQQMail_会员资料表", "2019.01月结数据备份情况:\r\n\r\n \r\n \r\naaa\r\n \r\nbbb")), #endregion qqEmail #region perfect99Email2 new KeyValuePair <string, KeyValuePair <string, string> >( "perfect99Email2.txt", new KeyValuePair <string, string>( "转发: Fw: 请示", @" [email protected] 发件人: 完美(中国)有限公司 信息中心 发送时间: 2020-04-13 16:15 收件人: 王现伟 抄送: 余凤瑜 主题: Fw: 请示 王现伟,您好! = = = = = = 下面是转发邮件 = = = = = = = 原邮件发件人名字:胡文祥 原邮件发件人地址:[email protected] 原邮件收件人名字:王天庆总监; 李观棉 原邮件收件人地址:[email protected]; [email protected] 原邮件抄送人名字: 原邮件抄送人地址: 信息中心,您好! 我部2020年2月19日已取消购买宜悦空气净化器优惠购(AP60025)获得800元奖励的活动。后因服务中心库存较多,经过请示领导特将服务中心后台报单时间调整至3月31日。请继续提取空机(AP60025)2月及3月的实际销售名单给到财务以发放相应补贴: 请同步发一份销售名单给到此邮箱号([email protected])谢谢! 附:补报返现补贴的请示 胡文祥(推广专员) 市场中心 -策划部 TEL:0760-88701828-88225/13924995602 E-Mail :[email protected] 完美(中国)有限公司 Perfect (China) Co., Ltd. 地址:广东省中山市石岐区东明北路(民营科技园),邮编:528402 Add :Dongming North Road, Shiqi District, Zhongshan City, Guangdong Province, PRC (528400 = = = = = = = = = = = = = = = = = = = = 致 礼! 完美(中国)有限公司 信息中心 [email protected] 2020-04-13 ")), #endregion perfect99Email2 #region perfect99Email3 new KeyValuePair <string, KeyValuePair <string, string> >( "perfect99Email3.txt", new KeyValuePair <string, string>( "Fw: 关联关系申报与处理规定签订事宜Message-ID: <*****@*****.**>Organization: =?gb2312?B?zerDwKOo1tC5+qOp09DP3rmry74=?=X-mailer: Foxmail 6, 15, 201, 20 [cn]", @"陈超,您好! = = = = = = 下面是转发邮件 = = = = = = = 原邮件发件人名字:人力资源中心 原邮件发件人地址:[email protected] 原邮件收件人名字:财务中心; 采购中心; 法务外事中心; 供应商改造项目组; 基建办; 集团战略法务部; 监察中心; 健康公司工作小组; 企业门户项目组; 人力资源中心; 市场中心; 完美大学; 信息中心; 研发中心; 业务中心; 制造中心; 总裁办; 董事长助理徐奕新高级经理; 董事长秘书陈嘉丽; 许生秘书许丽萍; 董事会办公室江晓君; 董事长助理秘书-柯冬燕; 董事长秘书张子卉; 副董事长办-赖丽霞; 副董事长秘书-黄学军; 常务副总裁秘书黄绮柔; 总裁办黄思苑; 分子机构管理室; 扬州人力资源部 原邮件收件人地址:[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected] 原邮件抄送人名字: 原邮件抄送人地址: 各中心/部门: 您好! 为了进一步完善个人信息申报体系,有效管控公司与个人的利益冲突,公司制定了《关联关系申报与处理规定》及相应申报表,现请各位员工按以下要求完成相关申报: 一、申报对象:文员级及以上级别员工(名单单独发各中心秘书)。 二、提交要求: A、总部、完美广东员工需在4月16日下午16:00前,将《关联关系申报与处理规定》、《关联关系申报表》签字版原件以中心为单位提交至人力资源中心王成 瑶处(IP:88390)。 B、分公司员工需在4月16日下午16:00前将签字版原件寄至人力资源中心黄燕婵收(请勿与其他资料混在一起)。 C、扬州完美人员由扬州完美人力资源部负责收集汇总与存档,其中经理级及以上员工的《关联关系申报与处理规定》、《关联关系申报表》扫描件,由扬州人力资源部扫描后发至:[email protected]。 三、填写要求: A、申报内容可以打印,必须按“申报要求”将相关内容填写完整。 B、规定签名处及申报表的签名处必须亲笔签名,且正楷字清晰签署。 C、规定与申报表可双面打印,两面均需按要求签名。 以上请知悉配合,如有疑问,请与谭富豪(88389)/王成瑶(88390)联系。谢谢! 2020-04-13 祝工作顺利! 致 礼! 人力资源中心 HR CENTER Tel:88701828-88392 方玉英 Fax:88701828-88370 = = = = = = = = = = = = = = = = = = = = 致 礼! 完美(中国)有限公司 信息中心 [email protected] 2020-04-13 ")), #endregion perfect99Email3 #region perfect99Email4 new KeyValuePair <string, KeyValuePair <string, string> >( "perfect99Email4.txt", new KeyValuePair <string, string>( "新电子商务系统权限申请_0603015", @"<p>新电子商务系统权限申请</p> <p>申请人工号:0603015</p> ")) //, #endregion perfect99Email4 }; //fileNames = fileNames.Where(a => a.Key == "perfect99Email4.txt").ToList(); foreach (var i in fileNames) { //email = new PFEmail(PFDataHelper.ReadLocalTxt(i).Split(new char[] { '\r', '\n' })); try { email = new PFEmail(PFDataHelper.ReadLocalTxt(i.Key).Split(new string[] { "\r\n" }, StringSplitOptions.None)); subject = email.Subject; //PFDataHelper.WriteLog(subject); body = email.Body; } catch (Exception e) { throw new Exception(i.Key + e.ToString()); } if (subject != i.Value.Key || body != i.Value.Value) { throw new Exception(i.Key); } //Assert.IsTrue(body == i.Value); } var aa = "aa"; }
public void SetModelConfig(string names) { _modelConfig = PFDataHelper.GetMultiModelConfig(names); }
public PFGridColumn Add(string dataIndex) { var col = new PFGridColumn { DataIndex = dataIndex, Text = dataIndex }; if (_modelConfig != null) { var config = _modelConfig[col.DataIndex]; if (config != null)//为了页面可以修改列宽,所以应该像现在这样Add就加上配置 { col.Text = config.FieldText; if (!string.IsNullOrWhiteSpace(config.FieldWidth)) { col.Width = config.FieldWidth; } if (!config.Visible) { col.Visible = false; } PFGridColumn.SetStyleByDataType(col, config.FieldType); //bool isPercent = config.FieldType == typeof(PFPercent); //if (config.FieldType == typeof(decimal) || config.FieldType == typeof(int) || isPercent) //{ // col.SetStyle("text-align:right;padding-right: 9px"); // col.Render = (c, r,v) => // { // var rr = PFDataHelper.Thousandth(v); // if (isPercent) // { // rr += " %"; // } // return rr; // }; // col.SetClassName("col-r"); //} } } if ( //setWidthByHeaderWord && string.IsNullOrWhiteSpace(col.Width)) //设置为中文后进入这里才有意义 { //var w = PFDataHelper.GetWordsWidth(col.Text,null,null,36); var w = PFDataHelper.GetWordsWidth(col.Text); if (w != null) { col.Width = w; } } //if (!string.IsNullOrWhiteSpace(col.Width)) //{ // col.Width = (decimal.Parse(col.Width.Replace("px", "")) + 36) + "px";//36是padding左右的值 //} //if (Count < 1) //{ // col.IsFirstColumn=true; //} this.Add(col); return(col); }
/// <summary> /// 注意:Model为DataTable时没必要写自动生成列的方法,因为在PFGrid.ColumnsFor方法里循环Table生成也是很简单的 /// </summary> /// <param name="htmlHelper"></param> /// <returns></returns> public MvcHtmlString Html(HtmlHelper htmlHelper) { var sb = new StringBuilder(); ////特性 var htmlAttributes = GetHtmlAttributes(); var sAttributes = ""; foreach (var a in htmlAttributes) { sAttributes += string.Format(" {0}='{1}' ", a.Key, a.Value); } var configMapper = PFDataHelper.GetConfigMapper(); var pathConfig = configMapper.GetPathConfig(); if (htmlHelper.ViewData["hasPFGridCss"] == null) { sb.AppendFormat("<link href=\"/{0}/PFGrid.css\" rel=\"stylesheet\" />", pathConfig.CssPath); htmlHelper.ViewData["hasPFGridCss"] = true; } #region 标题 // if (!string.IsNullOrWhiteSpace(_title)) // { //// sb.AppendFormat(@" //// <tr> //// <td style='' class='txt_86433c_12 pf-grid-head-td' align='left'> //// <strong>◎ {0}</strong> //// </td> //// </tr> ////", _title); // } #endregion 标题 #region 主体table sb.AppendFormat(@"<table {0}>", sAttributes); bool hasData = _model != null && _model.Count > 0; #region 表头 if (hasData) { if (_header != null) { sb.Append(_header.Html(this)); } else { sb.AppendFormat("<thead><tr class='{0}'>", _headClass); _columns.ForEach(c => { var style = c.GetStyle(false); if (!string.IsNullOrWhiteSpace(c.Width)) { style += ";min-width:" + c.Width; } if (!string.IsNullOrWhiteSpace(style)) { style = string.Format("style='{0} '", style); } sb.AppendFormat("<th {1} field-name='{2}' >{0}</th>", c.Text, style, c.DataIndex); //var style = ""; //if (!c.Visible) { style += "display:none;"; } //if (c.Width != null) { style += "width:" + c.Width + ";"; } //if (!string.IsNullOrWhiteSpace(style)) { style = string.Format("style='{0}'", style); } //sb.AppendFormat("<th {1} >{0}</th>", c.Text, style); }); sb.Append("</tr></thead>"); } } #endregion 表头 sb.Append(@"<tbody>"); if (hasData) { #region 行内容 int i = 0; bool isTree = false; foreach (var row in _model) { if (row is TreeListItem) { isTree = true; if (_columns.Any()) { var style = "text-align:left;padding-left:5px;padding-right:5px;white-space:nowrap;"; if (_header != null) { _columns.First(c => c.Text == _header.FirstLeaf(a => a.Visible).Text).SetStyle(style); } else { _columns.First(a => a.Visible).SetStyle(style); } } break; } } if (isTree) { var matrix = new TreeMatrix(_model); foreach (var row in _model) { var tRow = row as TreeListItem; sb.Append(TreeRowToHtml(tRow, i, 1, matrix)); i++; tRow.EachChild((a, b) => { //sb.Append(TreeRowToHtml(tRow, i, b, matrix)); sb.Append(TreeRowToHtml(a, i, b, matrix)); i++; }); } } else { foreach (var row in _model) { sb.Append(RowToHtml(row)); } } #endregion 行内容 } else { sb.AppendFormat("<tr><td>{0}</td></tr>", "无相关数据"); //sb.AppendFormat("<table style='width: 100%;'><tr class='{0}'><td style='text-align:center;color:red'>无相关数据</td></tr></table>", _itemClass); } sb.Append(@"</tbody>"); sb.Append(@"</table>"); #endregion 主体table return(MvcHtmlString.Create(sb.ToString())); }