private void adjustParamType() { if (_var != null) { bool bOK = false; _valType.SetDataType(new DataTypePointer(new TypePointer(typeof(Type)))); _valType.SetConstructorTypeScope(_var.ObjectType); DataTypePointer vType; if (_var.VariableLibType == null) { vType = new DataTypePointer(_var.VariableCustomType); } else { vType = new DataTypePointer(new TypePointer(_var.VariableLibType)); } DataTypePointer dp = _valType.ConstantValue.Value as DataTypePointer; if (dp != null) { bOK = vType.IsAssignableFrom(dp); } if (!bOK) { _valType.SetValue(vType); dp = vType; } if (!vType.IsAssignableFrom(_val.DataType)) { _val.SetDataType(dp); } } }
public byte[][] RenderReport(string reportPath, int id, string docType, short paperSize, bool save) { string historyID = null; string deviceInfo = ""; //@"<DeviceInfo><DpiX>300</DpiX><DpiY>300</DpiY></DeviceInfo> "; Byte[] results; const string format = "IMAGE"; string encoding = String.Empty; string mimeType = String.Empty; string extension = String.Empty; Warning[] warnings = null; string[] streamIDs = null; System.Collections.Generic.List <byte[]> list = new System.Collections.Generic.List <byte[]>(); try { ParameterValue[] rp = new ParameterValue[2]; rp.SetValue(new ParameterValue { Name = "id", Value = id.ToString() }, 0); rp.SetValue(new ParameterValue { Name = "DT", Value = DateTime.Now.ToString() }, 1); ei = res.LoadReport(reportPath, historyID); res.SetExecutionParameters(rp, "ru-ru"); int page = 0; while (true) { deviceInfo = string.Format(@"<DeviceInfo><OutputFormat>{0}</OutputFormat><PrintDpiX>300</PrintDpiX><PrintDpiY>300</PrintDpiY><StartPage>{1}</StartPage></DeviceInfo>", docType, ++page); results = res.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs); ExecutionInfo2 ei2 = res.GetExecutionInfo2(); if (results != null && results.Length > 0) { list.Add(results); } else { break; } } m_numberOfPages = list.Count; if (m_numberOfPages > 0) { return(list.ToArray()); } else { return(null); } } catch (Exception ex) { throw new Kesco.Lib.Log.DetailedException(ex.Message, ex, Kesco.Lib.Log.Priority.ExternalError, string.Format("Parameters - reportPath (URL): {0} DocumentID: {1} DocumentType: {2}", reportPath, id, docType)); } }
public bool printReport(string printer, string report, Int16 copies, bool landscape, List <string> parameterNames, List <string> parameterValues) { bool success = true; if (debugOn) { eventLog.WriteEntry("Parameters: " + parameterNames.Count.ToString(), EventLogEntryType.Information, 7001); } ParameterValue[] reportParameters = new ParameterValue[parameterNames.Count]; for (int i = 0; i < parameterNames.Count; i++) { ParameterValue a = new ParameterValue(); a.Name = parameterNames[i]; a.Value = parameterValues[i]; reportParameters.SetValue(a, i); } try { success = this.printReport(printer, report, copies, landscape, reportParameters); } catch (Exception ex) { eventLog.WriteEntry(ex.ToString(), EventLogEntryType.Information, 7001); Console.WriteLine(ex); } return(success); }
private void adjustParamType() { checkVariable(); if (_var != null) { bool bOK = false; _valType.SetDataType(new DataTypePointer(new TypePointer(typeof(Type)))); bool isString = (typeof(JsString).Equals(_var.BaseClassType) || typeof(PhpString).Equals(_var.BaseClassType)); _valType.SetConstructorTypeScope(_var.BaseClassType); DataTypePointer dp = _valType.ConstantValue.Value as DataTypePointer; if (dp != null) { bOK = _var.ClassType.IsAssignableFrom(dp); } if (!bOK) { _valType.SetValue(_var.ClassType); dp = _var.ClassType; } if (isString) { DataTypePointer st = new DataTypePointer(new TypePointer(typeof(string))); if (!st.IsAssignableFrom(_val.DataType)) { _val.SetDataType(st); } } else { if (!_var.ClassType.IsAssignableFrom(_val.DataType)) { _val.SetDataType(dp); } } } }
/// <summary> /// set the string value to be the constant value of the ParameterValue /// </summary> /// <param name="context"></param> /// <param name="culture"></param> /// <param name="value"></param> /// <returns></returns> public override Object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) { string sv = value as string; if (sv != null && context != null) { ParameterValue pv = context.PropertyDescriptor.GetValue(context.Instance) as ParameterValue; if (pv != null) { pv.SetValue(value); return(pv); } else { context.PropertyDescriptor.SetValue(context.Instance, value); } return(value); } else { return(base.ConvertFrom(context, culture, value)); } }
public ParameterValue CreateDefaultParameterValue(int i) { IParameter p = MethodParameterTypes[i]; ParameterValue pv = new ParameterValue(_action); pv.Name = p.Name; pv.ParameterID = p.ParameterID; ParameterClass pc = p as ParameterClass; if (pc != null) { pv.SetDataType(pc); } else { pv.SetDataType(p.ParameterLibType); } pv.SetOwnerAction(_action); pv.ValueType = EnumValueType.Property; CustomMethodParameterPointer cmpp = new CustomMethodParameterPointer(pc); pv.SetValue(cmpp); return(pv); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { ParameterValue pv = context.Instance as ParameterValue; if (pv == null) { MapItem item = context.Instance as MapItem; if (item != null) { pv = item.Item.Value as ParameterValue; } } if (pv == null) { pv = value as ParameterValue; } if (pv != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { IMathExpression mew = value as IMathExpression; if (mew == null) { mew = pv.MathExpression; if (mew == null) { MathNodeRoot r = new MathNodeRoot(); r.Name = pv.Name; mew = r; } } System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position; rc.X = curPoint.X; rc.Y = curPoint.Y; IMathEditor dlg = mew.CreateEditor(rc); // MathPropertyGrid pg = null; Type t = edSvc.GetType(); PropertyInfo pif0 = t.GetProperty("OwnerGrid"); if (pif0 != null) { object g = pif0.GetValue(edSvc, null); pg = g as MathPropertyGrid; } IMethod imScope = pv.ScopeMethod; if (imScope == null) { imScope = mew.ScopeMethod; if (imScope == null) { if (pg != null) { imScope = pg.ScopeMethod; } } } // dlg.ActionContext = pv.ActionContext; dlg.SetScopeMethod(imScope); dlg.VariableMapTargetType = typeof(ParameterValue); dlg.MathExpression = (IMathExpression)mew.Clone(); dlg.MathExpression.ScopeMethod = imScope; dlg.MathExpression.EnableUndo = true; if (edSvc.ShowDialog((Form)dlg) == DialogResult.OK) { mew = dlg.MathExpression; if (value != pv) { value = mew; pv.SetValue(value); } else { pv.SetValue(mew); } if (pg != null) { pg.OnValueChanged(mew, EventArgs.Empty); } } } } } return(value); }
public bool printReport(string printer, string report, Int16 copies, bool landscape, List<string> parameterNames, List<string> parameterValues) { bool success = true; if (debugOn) eventLog.WriteEntry("Parameters: " + parameterNames.Count.ToString(), EventLogEntryType.Information, 7001); ParameterValue[] reportParameters = new ParameterValue[parameterNames.Count]; for (int i = 0; i < parameterNames.Count; i++) { ParameterValue a = new ParameterValue(); a.Name = parameterNames[i]; a.Value = parameterValues[i]; reportParameters.SetValue(a, i); } try { success = this.printReport(printer, report, copies, landscape, reportParameters); } catch (Exception ex) { eventLog.WriteEntry(ex.ToString(), EventLogEntryType.Information, 7001); Console.WriteLine(ex); } return success; }