public override bool DoFillWork(object state) { FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 2) { return(false); } FillValue3C value = new FillValue3C(); char[] separators = fillValue.Separators; value.Separators = separators; StringBuilder text = new StringBuilder(); foreach (var item in fillValue.OriginString.Split(separators[1])) { value.SetValue(item); text.Append(string.Format("{0}{1}{2}", value.Value, separators[0], value.Note)); text.Append(separators[1]); } if (text.Length != 0) { text.Remove(text.Length - 1, 1); } value.SetValue(text.ToString()); return(base.DoFillWork(value)); }
/// <summary> /// 从指定的CCC填报参数复制信息。 /// </summary> /// <param name="other"></param> public void CopyFrom(FillValue3C other) { this.Key = other.Key; this.DoubleClick = other.DoubleClick; this.PublicAttachFile = other.publicAttachFile; this.OriginString = other.OriginString; this.DoubleClick = other.DoubleClick; this.Separators = other.Separators; }
public override bool DoFillWork(object fileName) { FillValue3C value = fileName as FillValue3C; if (value == null || value.Value == null || _editHandle == IntPtr.Zero || _okButtonHandle == IntPtr.Zero) { return(false); } ApiSetter.SetText(_editHandle, value.Value); return(ApiSetter.ClickButton(_okButtonHandle, base.HWnd, null, null)); }
private void StartFillSelectFirm(object state) { FillValue3C value = state as FillValue3C; if (value != null) { uint processId; NativeApi.GetWindowThreadProcessId(base.HWnd, out processId); FillDialog_3C fill = FillDialog_3C.GetFillDialog(CCCWindowType.FirmWindow, processId); fill.DoFillWork(value.Value); } }
public override bool DoFillWork(object fillValue) { bool result = false; FillValue3C value = fillValue as FillValue3C; if (value != null) { result = ApiSetter.SetComboBoxSelected(base.HWnd, _comboBoxHandle, value.Value, true); } ApiSetter.ClickButton(_okBtnHandle, base.HWnd, StartFillSelectFirm, this.FillValue); return(result); }
public unsafe override bool DoFillWork(object state) { NativeApi.SendMessage(_listBox, WMMSG.WM_SETFOCUS, 0, 0); uint msg = WMMSG.LB_SETCURSEL; long style = NativeApi.GetWindowLong(_listBox, -16); if ((style & ListBoxStyles.LBS_MULTIPLESEL) == ListBoxStyles.LBS_MULTIPLESEL) { msg = WMMSG.LB_SETSEL; } FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 1) { return(false); } string[] values = fillValue.Value.Split(fillValue.Separators[0]); if (values == null) { return(false); } int count = NativeApi.SendMessage(_listBox, WMMSG.LB_GETCOUNT, 0, 0).ToInt32(); StringBuilder text = new StringBuilder(256); for (int i = 0; i < count; i++) { RECT rect; IntPtr result = NativeApi.SendMessage(_listBox, WMMSG.LB_GETTEXT, i, text); if (values.Contains(text.ToString())) { IntPtr checkedIndex = NativeApi.SendMessage(_listBox, msg, i, 0); if (checkedIndex.ToInt32() == -1) { continue; } //NativeApi.SendMessage(base.HWnd, WMMSG.WM_COMMAND, (_listBox.ToInt32() & 0xFFFF | 0x10000), _listBox.ToInt32()); NativeApi.SendMessage(_listBox, WMMSG.LB_GETITEMRECT, i, ((IntPtr)(&rect)).ToInt32()); if (fillValue.DoubleClick) { NativeApi.SendMessage(_listBox, WMMSG.WM_LBUTTONDOWN, MouseVirtualKeys.None, (rect.Top << 16) | (rect.Left & 0xFFFF)); NativeApi.SendMessage(_listBox, WMMSG.WM_LBUTTONUP, MouseVirtualKeys.None, (rect.Top << 16) | (rect.Left & 0xFFFF)); } NativeApi.SendMessage(_listBox, WMMSG.WM_LBUTTONDOWN, MouseVirtualKeys.None, (rect.Top << 16) | (rect.Left & 0xFFFF)); NativeApi.SendMessage(_listBox, WMMSG.WM_LBUTTONUP, MouseVirtualKeys.None, (rect.Top << 16) | (rect.Left & 0xFFFF)); } } ApiSetter.ClickButton(_finishButton, base.HWnd, null, null); return(true); }
private bool FillCheckBox(FillParameter3C fillParameter, IntPtr container) { FillValue3C value = _pageData[fillParameter.Key] as FillValue3C; if (value == null || string.IsNullOrEmpty(value.Value)) { return(false); } string[] values = value.Value.Split(fillParameter.Separators[0]); List <string> valueList = new List <string>(); foreach (var item in values) { valueList.AddRange(item.Split('|')); } return(ApiSetter.CheckCheckBox(container, this, value.Note, valueList)); }
public override bool DoFillWork(object state) { bool result = true; FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 1) { return(false); } string[] values = fillValue.Value.Split(fillValue.Separators[0]); if (values != null) { for (int i = 0; i < radionPanels.Count && values.Length > i; i++) { result = result && ApiSetter.CheckRadioButton(radionPanels[i], values[i]); } } return(result && ApiSetter.ClickButton(okButton, base.HWnd, null, null)); }
public override bool DoFillWork(object state) { FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.AttachFile == null || fillValue.Separators == null || fillValue.Separators.Length < 1) { return(false); } string[] fileNames = fillValue.AttachFile.Split(fillValue.Separators[0]); //bool flag = fillValue.AttachFile == fillValue.PublicAttachFile; foreach (string fileName in fileNames) { //string fullName = (base.Owner == null || string.IsNullOrEmpty(base.Owner.DataFilePath)) ? // fileName : string.Format("{0}\\{1}", base.Owner.DataFilePath, fileName); //List<string> files = CheckFile(fileName, base.Owner.DataFilePath, fillValue.PublicAttachFile, flag); //if (files != null) //{ // foreach (var file in files) // { string file = fileName; if (Path.GetFileName(fileName) == fileName) { file = string.Format("{0}\\{1}", base.Owner.DataFilePath, fileName); } if (File.Exists(file)) { ApiSetter.ClickButton(addButton, base.HWnd, FillOpenFileDialog, file); // 点击添加按钮 } else { this.Owner.Records.Add(new FillRecord(ElementType.Unknown, RecordType.Failed, string.Format("文件 {0} 不存在", file), null)); } // } //} //else // this.Owner.Records.Add(new FillRecord(ElementType.Unknown, RecordType.Failed, string.Format("文件 {0} 不存在", fullName), null)); } ApiSetter.ClickButton(saveButton, base.HWnd, null, null); // 点击保存按钮 return(true); }
public unsafe override bool DoFillWork(object state) { FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 1) { return(false); } string[] values = fillValue.Value.Split(fillValue.Separators[0]); if (values == null || values.Length == 0) { return(false); } ApiSetter.SetComboBoxSelected(base.HWnd, comboBox, values[0]); if (values.Length > 1) { uint msg = WMMSG.LB_SETCURSEL; long style = NativeApi.GetWindowLong(listBox, -16); if ((style & ListBoxStyles.LBS_MULTIPLESEL) == ListBoxStyles.LBS_MULTIPLESEL) { msg = WMMSG.LB_SETSEL; } int count = NativeApi.SendMessage(listBox, WMMSG.LB_GETCOUNT, 0, 0).ToInt32(); StringBuilder text = new StringBuilder(256); for (int i = 0; i < count; i++) { RECT rect; IntPtr result = NativeApi.SendMessage(listBox, WMMSG.LB_GETTEXT, i, text); if (values.Contains(text.ToString())) { NativeApi.SendMessage(listBox, msg, i, 0); NativeApi.SendMessage(listBox, WMMSG.LB_GETITEMRECT, i, ((IntPtr)(&rect)).ToInt32()); NativeApi.SendMessage(listBox, WMMSG.WM_LBUTTONDOWN, MouseVirtualKeys.MK_CONTROL, (rect.Top << 16) | (rect.Left & 0xFFFF)); NativeApi.SendMessage(listBox, WMMSG.WM_LBUTTONUP, MouseVirtualKeys.MK_CONTROL, (rect.Top << 16) | (rect.Left & 0xFFFF)); } } ApiSetter.ClickButton(multiInstall, base.HWnd, null, null); } return(ApiSetter.ClickButton(finish, base.HWnd, null, null)); }
public override bool DoFillWork(object state) { FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 1) { return(false); } string[] values = fillValue.Value.Split(fillValue.Separators[0]); if (values == null || values.Length == 0) { return(true); } List <IntPtr> list = ControlSorter.SortContainer(_container); if (list == null) { return(false); } StringBuilder className = new StringBuilder(256); for (int i = 0; i < values.Length && i < list.Count; i++) { className.Clear(); NativeApi.GetClassName(list[i], className, 255); string classNameStr = className.ToString(); if (classNameStr.StartsWith(CCCFillManager.EditClassName)) { ApiSetter.SetText(list[i], values[i]); } else if (classNameStr.StartsWith(CCCFillManager.ComboBoxClassName)) { ApiSetter.SetComboBoxSelected(base.HWnd, list[i], values[i]); } } ApiSetter.ClickButton(_finishButton, base.HWnd, null, null); return(true); }
private bool FillValue(string className, ref int index, IntPtr handle, FillValue3C value) { _asyncHandle.Wait(); string parameterValue = null; if (value == null) { return(false); } FillParameter3C parameter = _fillParameters[value.Key] as FillParameter3C; if (index == -1) { parameterValue = value.Value; } else { string[] values = value.Value == null ? null : value.Value.Split(parameter.Separators[0]); parameterValue = (values == null || values.Length <= index) ? (string.IsNullOrEmpty(value.Note) ? "" : value.Note) : values[index]; } StringBuilder text = null; switch (className) { case CCCFillManager.EditClassName: if (ApiSetter.IsEditable(handle, _handle) == false) { index--; break; } ApiSetter.SetText(handle, parameterValue); break; case CCCFillManager.ComboBoxClassName: if (ApiSetter.IsEditable(handle, _handle) == false) { index--; break; } ApiSetter.SetComboBoxSelected(_handle, handle, parameterValue, parameter.IsComboBoxPreciseMatch); break; case CCCFillManager.ButtonClassName: value.Separators = parameter.Separators; text = new StringBuilder(256); NativeApi.GetWindowText(handle, text, 255); if (text.ToString() == "附件" && value != null && string.IsNullOrEmpty(value.AttachFile) == false) { return(ApiSetter.ClickButton(handle, _handle, ListenAttachWindow, value)); } else if (text.ToString() == "编辑") { if (string.IsNullOrEmpty(value.OriginString)) { return(false); } if (string.IsNullOrEmpty(parameter.EditType)) { parameter.EditType = "add"; } switch (parameter.EditType.ToLower()) { case "add": return(ApiSetter.ClickButton(handle, _handle, ListenAddWindow, value)); case "radio": return(ApiSetter.ClickButton(handle, _handle, ListenRadioWindow, value)); case "select": return(ApiSetter.ClickButton(handle, _handle, ListenListBoxWindow, value)); case "multiselect": value.DoubleClick = true; return(ApiSetter.ClickButton(handle, _handle, ListenListBoxWindow, value)); case "text": return(ApiSetter.ClickButton(handle, _handle, ListenTextWindow, value)); case "column": return(ApiSetter.ClickButton(handle, _handle, ListenColumnWindow, value)); case "multinote": return(ApiSetter.ClickButton(handle, _handle, ListenMultiValueAndNoteWindow, value)); default: return(false); } } else { } break; } return(true); }
private bool FillValue(string className, IntPtr handle, FillValue3C value) { int index = -1; return(FillValue(className, ref index, handle, value)); }
/// <summary> /// 根据参数键值及控件句柄填写参数。 /// </summary> /// <param name="key"></param> /// <param name="fillControl"></param> /// <returns></returns> private bool FillValue(string key, object fillControl) { IntPtr current = IntPtr.Zero; List <IntPtr> list = fillControl as List <IntPtr>; if (list != null && list.Count == 0) { return(true); } if (string.IsNullOrEmpty(key)) { return(true); } FillParameter3C fillParameter = _fillParameters[key] as FillParameter3C; if (fillParameter == null) { fillParameter = new FillParameter3C() { Key = key, Separators = FillParameter3C.DefaultSeparators }; _fillParameters.Add(key, fillParameter); } FillValue3C fillValue = _pageData[key] as FillValue3C; if (fillValue == null) { Records.Add(new FillRecord(ElementType.Unknown, RecordType.Failed, "数据文件中未定义此参数", key)); return(true); } StringBuilder className = new StringBuilder(256); string name = ""; if (list != null) { current = list[0]; className = new StringBuilder(256); NativeApi.GetClassName(current, className, 255); name = className.ToString(); // 勾选是否适用复选框 if (name.StartsWith(CCCFillManager.ButtonClassName)) { if (fillValue.Value == "N/A") { if (ApiSetter.IsDisabled(current) == false) { ApiSetter.SetCheck(current, this.Hwnd); //ApiSetter.ClickButton(current, this.Hwnd, null, null); return(true); } } current = list.Count > 1 ? list[list.Count - 1] : current; } } else { current = (IntPtr)fillControl; } if (fillParameter.Type == "5" || fillParameter.Type == "7") { return(FillCheckBox(fillParameter, current)); } className.Clear(); NativeApi.GetClassName(current, className, 255); name = className.ToString(); if (name.StartsWith(CCCFillManager.StaticClassName)) { return(true); } else if (name.StartsWith(CCCFillManager.EditClassName)) { return(FillValue(CCCFillManager.EditClassName, current, fillValue)); } else if (name.StartsWith(CCCFillManager.ButtonClassName)) { return(FillValue(CCCFillManager.ButtonClassName, current, fillValue)); } else if (name.StartsWith(CCCFillManager.ComboBoxClassName)) { #if export sheet.WriteNextRow(); sheet.WriteTextCell(1, writer.AddSharedString(key)); #endif return(FillValue(CCCFillManager.ComboBoxClassName, current, fillValue)); } else { // 多值填报 List <IntPtr> sortedControl = ControlSorter.SortContainer(current); if (sortedControl == null) { return(false); } else if (sortedControl.Count == 1) { return(FillValue(key, sortedControl[0])); } int valueIndex = 0; for (int i = 0; i < sortedControl.Count; i++, valueIndex++) { className.Clear(); NativeApi.GetClassName(sortedControl[i], className, 255); if (className.ToString().StartsWith(CCCFillManager.ButtonClassName)) { FillValue(CCCFillManager.ButtonClassName, ref valueIndex, sortedControl[i], fillValue); } else if (className.ToString().StartsWith(CCCFillManager.ComboBoxClassName)) { #if export sheet.WriteNextRow(); sheet.WriteTextCell(1, writer.AddSharedString(key)); #endif FillValue(CCCFillManager.ComboBoxClassName, ref valueIndex, sortedControl[i], fillValue); } else if (className.ToString().StartsWith(CCCFillManager.EditClassName)) { FillValue(CCCFillManager.EditClassName, ref valueIndex, sortedControl[i], fillValue); } } } return(true); }
public override bool DoFillWork(object state) { FillValue3C fillValue = state as FillValue3C; if (fillValue == null || fillValue.Value == null || fillValue.Separators == null || fillValue.Separators.Length < 2 || inputCount == 0) { return(false); } foreach (char c in fillValue.Separators) { fillValue.Value = fillValue.Value.Replace(c, ','); } List <string[]> values = new List <string[]>(); string[] array = fillValue.Value.Split(new char[] { ',' }, StringSplitOptions.None); string[] group = null; for (int i = 0; i < array.Length; i++) { int mod = (i % inputCount); if (mod == 0) { group = new string[inputCount]; values.Add(group); } group[mod] = array[i]; } //List<string[]> values = new List<string[]>(); //foreach (var item in fillValue.Value.Split(fillValue.Separators[1])) //{ // values.Add(item.Split(fillValue.Separators[0])); //} bool result = true; StringBuilder className = new StringBuilder(256); for (int index = 0; index < values.Count && current != IntPtr.Zero; index++) { List <IntPtr> sorted = ControlSorter.SortContainer(current); if (sorted != null) { string[] parametrValues = values[index]; for (int i = 0; i < sorted.Count && parametrValues.Length > i; i++) { NativeApi.GetClassName(sorted[i], className, 255); string classNameStr = className.ToString(); if (classNameStr.StartsWith(CCCFillManager.EditClassName)) { ApiSetter.SetText(sorted[i], parametrValues[i]); } else if (classNameStr.StartsWith(CCCFillManager.ComboBoxClassName)) { ApiSetter.SetComboBoxSelected(base.HWnd, sorted[i], parametrValues[i]); } } } if (index < values.Count - 1) { ApiSetter.ClickButton(addButton, base.HWnd, null, null); } current = NativeApi.FindWindowEx(container, current, null, null); } return(result && ApiSetter.ClickButton(saveButton, base.HWnd, null, null)); }
private void FillWorker(object state) { string windowType = null; FillDialog_3C fill = FillDialog_3C.GetFillDialog(out windowType, processId); try { // 存储数据文件所在目录下的所有文件(不包括子文件夹中的文件) _fillParameters = this.ReadFillParameter(state as string); TreeValue root = ReadAndConvertData(); windowType = null; FillDialog_3C.BeginListen(); fill = FillDialog_3C.GetFillDialog(out windowType, processId); if (fill != null) { if (windowType == CCCWindowType.LoginWindow) { fill.FillValue = _data["厂商关系"] as FillValue3C; fill.DoFillWork(_data["登录证书"]); } else if (windowType == CCCWindowType.FirmWindow) { FillValue3C value = _data["厂商关系"] as FillValue3C; fill.DoFillWork(value == null ? "" : value.Value); } } main = Main_3C.GetMainWindow(base.DataProvider.DataSourceFile, processId); //this.SetWindowPos(); //main.FileTable = this.files; main.FillParameters = this._fillParameters; main.Records = this._records; if (main.TreeView.GetCount() == 0) { this.GetTreeView(); } else { main.UpdateSelectedNode(); } main.TreeValue = root; FillDialog_3C.BeginListenSaveRequire(main); do { System.Threading.Thread.Sleep(200); main.FillPage(); } while (main.SelectNextNode(true)); this.EndFill(); OnFinished(EventArgs.Empty); WebFillManager.ShowMessageBox("填报完成!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (main != null) { LogHelper.Write(ex); MessageBox.Show(ex.StackTrace + ex.Message); this.EndFill(); } } }