public int Insert(InputContentInfo info) { int contentId; info.Taxis = GetMaxTaxis(info.InputId) + 1; info.BeforeExecuteNonQuery(); IDataParameter[] parms; var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(info.Attributes, TableName, out parms); using (var conn = GetConnection()) { conn.Open(); using (var trans = conn.BeginTransaction()) { try { contentId = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms); trans.Commit(); } catch { trans.Rollback(); throw; } } } return(contentId); }
private void ParseMouseWheelInfo(InputContentInfo inputLogInfo, out int?scrollDelta, out Point?position) { int parsedDelta; position = null; var strDelta = string.Empty; var strPositionGroup = string.Empty; var match = Regex.Match(inputLogInfo.Data, "delta:(-?[0-9]*), pos:(.*)"); if (match.Success) { strDelta = match.Groups[1].Value; strPositionGroup = match.Groups[2].Value; } else { // compat with previous log format strDelta = inputLogInfo.Data; } scrollDelta = null; if (int.TryParse(strDelta, out parsedDelta)) { scrollDelta = parsedDelta; } var strPositions = strPositionGroup.Split(';'); if (strPositions.Length == 2) { double x, y; if (double.TryParse(strPositions[0], out x) && double.TryParse(strPositions[1], out y)) { position = new Point(x, y); } } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID", "InputID", "ContentID"); var inputId = Body.GetQueryInt("InputID"); _contentId = Body.GetQueryInt("ContentID"); _relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, PublishmentSystemId, inputId); _inputInfo = DataProvider.InputDao.GetInputInfo(inputId); _contentInfo = DataProvider.InputContentDao.GetContentInfo(_contentId); if (!Page.IsPostBack) { var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, _relatedIdentities); rptContents.DataSource = styleInfoList; rptContents.ItemDataBound += rptContents_ItemDataBound; rptContents.DataBind(); breReply.Text = _contentInfo.Reply; } }
public void Update(InputContentInfo info) { info.BeforeExecuteNonQuery(); IDataParameter[] parms; var sqlUpdate = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(info.Attributes, TableName, out parms); ExecuteNonQuery(sqlUpdate, parms); }
private static AtomEntry GetAtomEntry(InputContentInfo contentInfo) { var entry = AtomUtility.GetEmptyEntry(); foreach (string attributeName in contentInfo.Attributes) { AtomUtility.AddDcElement(entry.AdditionalElements, attributeName, contentInfo.Attributes[attributeName]); } return(entry); }
private void Prepare(LogEntryVm logEntry, InputContentInfo inputLogInfo, IList <LogEntryVm> entries) { if (inputLogInfo.Type != "PreviewKeyDown" || inputLogInfo.Data != "V") { return; } var index = entries.IndexOf(logEntry); if (index <= 0) { return; } var previousEntry = entries[index - 1]; var previousInputContentInfo = previousEntry.ContentInfo as InputContentInfo; if (previousInputContentInfo == null) { return; } if (previousInputContentInfo.Data != "LeftCtrl" && previousInputContentInfo.Data != "RightCtrl") { return; } // its a copy paste, find the pasting info if (index > entries.Count - 2) { return; } var nextEntry = entries[index + 1]; var nextInputContentInfo = nextEntry.ContentInfo as InputContentInfo; if (nextInputContentInfo == null) { return; } if (nextInputContentInfo.Type != "Pasting") { return; } var pasteData = nextInputContentInfo.Data.Replace(@"\n", Environment.NewLine); Clipboard.SetText(pasteData); }
public InputContentInfo GetContentInfo(int contentId) { InputContentInfo info = null; string sqlWhere = $"WHERE ID = {contentId}"; var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TableName, SqlUtils.Asterisk, sqlWhere); using (var rdr = ExecuteReader(sqlSelect)) { if (rdr.Read()) { info = new InputContentInfo(); BaiRongDataProvider.DatabaseDao.ReadResultsToExtendedAttributes(rdr, info); } rdr.Close(); } info?.AfterExecuteReader(); return(info); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID", "InputID", "ContentID"); var inputId = Body.GetQueryInt("InputID"); _contentId = Body.GetQueryInt("ContentID"); _relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, PublishmentSystemId, inputId); _contentInfo = DataProvider.InputContentDao.GetContentInfo(_contentId); if (!string.IsNullOrEmpty(_contentInfo.UserName)) { //group_todo var showPopWinString = ModalUserView.GetOpenWindowString(_contentInfo.UserName); ltlAddUserName.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">{_contentInfo.UserName}</a>"; } else { ltlAddUserName.Text = "匿名"; } ltlIPAddress.Text = _contentInfo.IpAddress; ltlAddDate.Text = DateUtils.GetDateAndTimeString(_contentInfo.AddDate); ltlReply.Text = _contentInfo.Reply; var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, _relatedIdentities); rptContents.DataSource = styleInfoList; rptContents.ItemDataBound += rptContents_ItemDataBound; rptContents.DataBind(); }
public static List <InputContentInfo> GetInputContentsByCsvFile(string filePath, PublishmentSystemInfo publishmentSystemInfo, InputInfo inputInfo) { var contentInfoList = new List <InputContentInfo>(); List <string> head; List <List <string> > rows; CsvUtils.Import(filePath, out head, out rows); if (rows.Count > 0) { var relatedidentityes = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemInfo.PublishmentSystemId, inputInfo.InputID); var tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, relatedidentityes); var nameValueCollection = new NameValueCollection(); foreach (var styleInfo in tableStyleInfoList) { nameValueCollection[styleInfo.DisplayName] = styleInfo.AttributeName.ToLower(); } nameValueCollection["回复"] = InputContentAttribute.Reply.ToLower(); nameValueCollection["添加时间"] = InputContentAttribute.AddDate.ToLower(); var attributeNames = new List <string>(); foreach (var columnName in head) { if (!string.IsNullOrEmpty(nameValueCollection[columnName])) { attributeNames.Add(nameValueCollection[columnName]); } else { attributeNames.Add(columnName); } } foreach (var row in rows) { if (row.Count != attributeNames.Count) { continue; } var contentInfo = new InputContentInfo(0, inputInfo.InputID, 0, true, string.Empty, string.Empty, DateTime.Now, string.Empty); for (var i = 0; i < attributeNames.Count; i++) { var attributeName = attributeNames[i]; if (!string.IsNullOrEmpty(attributeName)) { var value = row[i]; contentInfo.SetExtendedAttribute(attributeName, value); } } contentInfoList.Add(contentInfo); } } return(contentInfoList); }
private async Task Play(Process process, LogEntryVm logEntry, InputContentInfo inputLogInfo) { var windowTitle = inputLogInfo.Window; var isForeground = NativeMethods.BringToFront(process, windowTitle); if (!isForeground) { Debug.WriteLine($"Cannot bring {process.ProcessName} to foreground"); return; } Microsoft.Test.Input.Key key; if (Enum.TryParse(inputLogInfo.Data, out key)) { switch (inputLogInfo.Type) { case "PreviewKeyDown": Microsoft.Test.Input.Keyboard.Press(key); break; case "PreviewKeyUp": Microsoft.Test.Input.Keyboard.Release(key); break; default: break; } } Point?position = null; var positions = inputLogInfo.Data.Split(';'); if (positions.Length == 2) { double x, y; if (double.TryParse(positions[0], out x) && double.TryParse(positions[1], out y)) { position = new Point(x, y); } } if (position.HasValue) { var pointOnScreen = GetPointToScreen(process, position, windowTitle); if (pointOnScreen.HasValue) { switch (inputLogInfo.Type) { case "PreviewMouseUp": Microsoft.Test.Input.Mouse.MoveTo(new System.Drawing.Point((int)pointOnScreen.Value.X, (int)pointOnScreen.Value.Y)); await Task.Delay(TimeSpan.FromMilliseconds(5)); Microsoft.Test.Input.Mouse.Up(Microsoft.Test.Input.MouseButton.Left); break; case "PreviewMouseMove": Microsoft.Test.Input.Mouse.MoveTo(new System.Drawing.Point((int)pointOnScreen.Value.X, (int)pointOnScreen.Value.Y)); break; case "PreviewMouseDown": Microsoft.Test.Input.Mouse.MoveTo(new System.Drawing.Point((int)pointOnScreen.Value.X, (int)pointOnScreen.Value.Y)); await Task.Delay(TimeSpan.FromMilliseconds(5)); Microsoft.Test.Input.Mouse.Down(Microsoft.Test.Input.MouseButton.Left); break; case "PreviewTouchUp": TouchUtils.TouchUp(pointOnScreen.Value); break; case "PreviewTouchMove": TouchUtils.TouchMove(pointOnScreen.Value); break; case "PreviewTouchDown": TouchUtils.TouchDown(pointOnScreen.Value); break; case "SizeChanged": NativeMethods.SetWindowSize(process, windowTitle, (int)position.Value.X, (int)position.Value.Y); break; default: break; } } } if (inputLogInfo.Type == "PreviewMouseWheel") { int?scrollDistance; ParseMouseWheelInfo(inputLogInfo, out scrollDistance, out position); var wheelPointOnScreen = GetPointToScreen(process, position, windowTitle); if (position.HasValue && wheelPointOnScreen.HasValue) { Microsoft.Test.Input.Mouse.MoveTo(new System.Drawing.Point((int)wheelPointOnScreen.Value.X, (int)wheelPointOnScreen.Value.Y)); } if (scrollDistance.HasValue) { Microsoft.Test.Input.Mouse.Scroll(scrollDistance.Value / 120); } } }
public void ImportInput(bool overwrite) { if (!DirectoryUtils.IsDirectoryExists(_directoryPath)) { return; } var filePaths = DirectoryUtils.GetFilePaths(_directoryPath); foreach (var filePath in filePaths) { var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath)); var inputInfo = new InputInfo { InputName = AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputName"), PublishmentSystemId = _publishmentSystemId, AddDate = DateTime.Now, IsChecked = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsChecked")), IsReply = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, "IsReply")), Taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "Taxis")), SettingsXml = AtomUtility.Decrypt(AtomUtility.GetDcElementContent(feed.AdditionalElements, "SettingsXML")) }; var srcInputInfo = DataProvider.InputDao.GetInputInfo(inputInfo.InputName, _publishmentSystemId); if (srcInputInfo != null) { if (overwrite) { DataProvider.InputDao.Delete(srcInputInfo.InputId); } else { inputInfo.InputName = DataProvider.InputDao.GetImportInputName(inputInfo.InputName, _publishmentSystemId); } } var inputId = DataProvider.InputDao.Insert(inputInfo); var styleDirectoryPath = PathUtils.Combine(_directoryPath, AtomUtility.GetDcElementContent(feed.AdditionalElements, "InputID")); TableStyleIe.SingleImportTableStyle(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, styleDirectoryPath, inputId); foreach (AtomEntry entry in feed.Entries) { var contentInfo = new InputContentInfo { InputId = inputId, IsChecked = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, InputContentAttribute.IsChecked)), UserName = AtomUtility.GetDcElementContent(entry.AdditionalElements, InputContentAttribute.UserName), AddDate = DateTime.Now, Reply = AtomUtility.GetDcElementContent(entry.AdditionalElements, InputContentAttribute.Reply) }; var attributes = AtomUtility.GetDcElementNameValueCollection(entry.AdditionalElements); foreach (string entryName in attributes.Keys) { if (!InputContentAttribute.AllAttributes.Contains(entryName.ToLower())) { contentInfo.SetExtendedAttribute(entryName, attributes[entryName]); } } DataProvider.InputContentDao.Insert(contentInfo); } } }
public override void Submit_OnClick(object sender, EventArgs e) { var isChanged = false; if (_contentId != 0) { try { var contentInfo = DataProvider.InputContentDao.GetContentInfo(_contentId); InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, PublishmentSystemInfo, _relatedIdentities, Page.Request.Form, contentInfo.Attributes); DataProvider.InputContentDao.Update(contentInfo); var builder = new StringBuilder(); var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, _relatedIdentities); foreach (var styleInfo in styleInfoList) { if (styleInfo.IsVisible == false) { continue; } var theValue = InputParserUtility.GetContentByTableStyle(contentInfo.GetExtendedAttribute(styleInfo.AttributeName), PublishmentSystemInfo, ETableStyle.InputContent, styleInfo); builder.Append($@"{styleInfo.DisplayName}:{theValue},"); } if (builder.Length > 0) { builder.Length = builder.Length - 1; } if (builder.Length > 60) { builder.Length = 60; } Body.AddSiteLog(PublishmentSystemId, "修改提交表单内容", $"提交表单:{_inputInfo.InputName},{builder}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "信息修改失败:" + ex.Message); } } else { try { var ipAddress = PageUtils.GetIpAddress(); var contentInfo = new InputContentInfo(0, _inputInfo.InputId, 0, true, string.Empty, ipAddress, DateTime.Now, string.Empty); InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, PublishmentSystemInfo, _relatedIdentities, Page.Request.Form, contentInfo.Attributes); DataProvider.InputContentDao.Insert(contentInfo); var builder = new StringBuilder(); var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, _relatedIdentities); foreach (var styleInfo in styleInfoList) { if (styleInfo.IsVisible == false) { continue; } var theValue = InputParserUtility.GetContentByTableStyle(contentInfo.GetExtendedAttribute(styleInfo.AttributeName), PublishmentSystemInfo, ETableStyle.InputContent, styleInfo); builder.Append($@"{styleInfo.DisplayName}:{theValue},"); } if (builder.Length > 0) { builder.Length = builder.Length - 1; } if (builder.Length > 60) { builder.Length = 60; } Body.AddSiteLog(PublishmentSystemId, "添加提交表单内容", $"提交表单:{_inputInfo.InputName},{builder}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "信息添加失败:" + ex.Message); } } if (isChanged) { PageUtils.CloseModalPageAndRedirect(Page, _returnUrl); } }
public void Main(int publishmentSystemId, int inputId) { var body = new RequestBody(); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); InputInfo inputInfo = null; if (inputId > 0) { inputInfo = DataProvider.InputDao.GetInputInfo(inputId); } if (inputInfo != null) { var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputInfo.InputId); var ipAddress = PageUtils.GetIpAddress(); var contentInfo = new InputContentInfo(0, inputInfo.InputId, 0, inputInfo.IsChecked, body.UserName, ipAddress, DateTime.Now, string.Empty); try { if (!inputInfo.Additional.IsAnomynous && !body.IsUserLoggin) { throw new Exception("请先登录系统!"); } InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, publishmentSystemInfo, relatedIdentities, HttpContext.Current.Request.Form, contentInfo.Attributes, false); if (HttpContext.Current.Request.Files.Count > 0) { foreach (var attributeName in HttpContext.Current.Request.Files.AllKeys) { var myFile = HttpContext.Current.Request.Files[attributeName]; if (myFile == null || "" == myFile.FileName) { continue; } var fileUrl = UploadFile(publishmentSystemInfo, myFile); contentInfo.SetExtendedAttribute(attributeName, fileUrl); } } contentInfo.Id = DataProvider.InputContentDao.Insert(contentInfo); if (inputInfo.Additional.IsAdministratorSmsNotify) { var keys = TranslateUtils.StringCollectionToStringList(inputInfo.Additional.AdministratorSmsNotifyKeys); if (keys.Count > 0) { var parameters = new NameValueCollection(); if (keys.Contains(InputContentAttribute.Id)) { parameters.Add(InputContentAttribute.Id, contentInfo.Id.ToString()); } if (keys.Contains(InputContentAttribute.AddDate)) { parameters.Add(InputContentAttribute.AddDate, DateUtils.GetDateAndTimeString(contentInfo.AddDate)); } var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, relatedIdentities); foreach (var styleInfo in styleInfoList) { if (keys.Contains(styleInfo.AttributeName)) { var value = contentInfo.GetExtendedAttribute(styleInfo.AttributeName); parameters.Add(styleInfo.AttributeName, value); } } string errorMessage; SmsManager.SendNotify(inputInfo.Additional.AdministratorSmsNotifyMobile, inputInfo.Additional.AdministratorSmsNotifyTplId, parameters, out errorMessage); } } HttpContext.Current.Response.Write(StlInput.GetPostMessageScript(inputId, true)); HttpContext.Current.Response.End(); } catch (Exception) { HttpContext.Current.Response.Write(StlInput.GetPostMessageScript(inputId, false)); HttpContext.Current.Response.End(); } } }
public void Main(int publishmentSystemId, int inputId) { var body = new RequestBody(); var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId); InputInfo inputInfo = null; if (inputId > 0) { inputInfo = DataProvider.InputDao.GetInputInfo(inputId); } if (inputInfo != null) { var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputInfo.InputId); var ipAddress = PageUtils.GetIpAddress(); var contentInfo = new InputContentInfo(0, inputInfo.InputId, 0, inputInfo.IsChecked, body.UserName, ipAddress, DateTime.Now, string.Empty); try { if (!inputInfo.Additional.IsAnomynous && !body.IsUserLoggin) { throw new Exception("请先登录系统!"); } InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, publishmentSystemInfo, relatedIdentities, HttpContext.Current.Request.Form, contentInfo.Attributes, false); if (HttpContext.Current.Request.Files.Count > 0) { foreach (var attributeName in HttpContext.Current.Request.Files.AllKeys) { var myFile = HttpContext.Current.Request.Files[attributeName]; if (myFile == null || "" == myFile.FileName) { continue; } var fileUrl = UploadFile(publishmentSystemInfo, myFile); contentInfo.SetExtendedAttribute(attributeName, fileUrl); } } DataProvider.InputContentDao.Insert(contentInfo); string message; if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["successTemplateString"])) { if (string.IsNullOrEmpty(inputInfo.Additional.MessageSuccess)) { message = "表单提交成功,正在审核。"; if (contentInfo.IsChecked) { message = "表单提交成功。"; } } else { message = inputInfo.Additional.MessageSuccess; } } else { message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["successTemplateString"]); } HttpContext.Current.Response.Write(InputTemplate.GetInputCallbackScript(publishmentSystemInfo, inputId, true, message)); HttpContext.Current.Response.End(); //if (contentInfo.IsChecked == EBoolean.True) //{ // FileSystemObject FSO = new FileSystemObject(base.PublishmentSystemID); // FSO.CreateImmediately(EChangedType.Add, ETemplateTypeUtils.GetEnumType(templateType), channelID, contentID, fileTemplateID); //} } catch (Exception ex) { string message; if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["failureTemplateString"])) { if (string.IsNullOrEmpty(inputInfo.Additional.MessageFailure)) { message = "表单提交失败," + ex.Message; } else { message = inputInfo.Additional.MessageFailure; } } else { message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["failureTemplateString"]); } HttpContext.Current.Response.Write(InputTemplate.GetInputCallbackScript(publishmentSystemInfo, inputId, false, message)); HttpContext.Current.Response.End(); } } }