private void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (_fields.Count < 2) { return; } switch (e.PropertyName) { case "Length": //recalculate the begin of each field RecalculateBegin(); break; case "Begin": Field modifiedField = sender as Field; int indexOfModifiedField = FieldsCollection.IndexOf(modifiedField); if (indexOfModifiedField > 0) { //recalculate the length of the previous field: Field previousField = FieldsCollection[indexOfModifiedField - 1]; previousField.Length = modifiedField.Begin - previousField.Begin; } //...and the recalculate the begin of the rest of the fields: RecalculateBegin(); break; } }
public SqlCommand InsertCommand(TEntity entity) { var obj = GetObjectContext <TEntity>(); FieldsCollection fields = new FieldsCollection(); bool skip = false; foreach (var prop in obj.Properties) { skip = false; foreach (var attr in prop.Attributes) { if (attr is IgnoreAttribute) { skip = true; } } if (!skip) { fields.Add(new Field(prop.Info.Name, prop.Info.GetValue(entity))); } } var com = CommandBuilder.InsertCommand(obj.Table, fields); return(com); }
public SqlCommand UpdateCommand(TEntity entity) { var obj = GetObjectContext <TEntity>(); FieldsCollection fields = new FieldsCollection(); List <Filter> filters = new List <Filter>(); foreach (var prop in obj.Properties) { var value = prop.Info.GetValue(entity); bool isContinue = true; foreach (var attr in prop.Attributes) { if (attr is PrimaryKeyAttribute keyAttr) { filters.Add(new Equal(prop.Info.Name, value)); isContinue = false; } } if (!isContinue) { continue; } fields.Add(new Field(prop.Info.Name, value)); } return(CommandBuilder.UpdateCommand(obj.Table, fields, filters)); }
/// <summary> /// 更新命令(批量) /// </summary> /// <param name="table"></param> /// <param name="fields"></param> /// <param name="filters"></param> /// <returns></returns> public SqlCommand UpdateCommandBatch(string table, Dictionary <FieldsCollection, IEnumerable <Filter> > dic) { if (dic == null || dic.Count == 0) { throw new ApplicationException("Invalid fields can be update."); } if (string.IsNullOrEmpty(table)) { throw new ApplicationException("Invalid table's name."); } StringBuilder sb = new StringBuilder(); var param = new DynamicParameters(); FieldsCollection fields = null; IEnumerable <Filter> filters = null; int index = 0; foreach (var keyValuePair in dic) { if (keyValuePair.Key == null || keyValuePair.Key.Count == 0) { throw new ApplicationException("Invalid fields can be inserted."); } if (keyValuePair.Value == null || keyValuePair.Value.AsList().Count == 0) { throw new ApplicationException("Invalid fields can be inserted."); } var columnStrs = new List <string>(); var filterStrs = new List <string>(); fields = keyValuePair.Key; filters = keyValuePair.Value; foreach (var field in fields) { columnStrs.Add($"`{field.Name}`=@{field.Name}_{index}"); param.Add($"@{field.Name}_{index}", field.Value); } if (filters != null) { foreach (var filter in filters) { var filterCommand = filter.ToSqlCommand(index); if (filterCommand != null) { filterStrs.Add(filterCommand.SqlString); param.AddDynamicParams(filterCommand.Parameters); } } } sb.Append($@"UPDATE `{table}` SET {string.Join(",", columnStrs)} {(filterStrs.Count > 0 ? $" WHERE {string.Join(" AND ", filterStrs)}" : "")};"); index++; } return(new SqlCommand(sb.ToString(), param)); }
///<summary> /// Creates new instance of DocxDocument using <paramref name="template"/> ///</summary> ///<param name="template">Binary content of docx file</param> public DocxDocument(byte[] template) { _documentStream = new MemoryStream(); _documentStream.Write(template, 0, template.Length); _wordDocument = WordprocessingDocument.Open(_documentStream, true); var sdtElements = _wordDocument.MainDocumentPart.Document.Body.Descendants<SdtElement>(); _fields = new FieldsCollection(sdtElements); }
///<summary> /// Creates new instance of DocxDocument using <paramref name="template"/> ///</summary> ///<param name="template">Binary content of docx file</param> public DocxDocument(byte[] template) { _documentStream = new MemoryStream(); _documentStream.Write(template, 0, template.Length); _wordDocument = WordprocessingDocument.Open(_documentStream, true); var sdtElements = _wordDocument.MainDocumentPart.Document.Body.Descendants <SdtElement>(); _fields = new FieldsCollection(sdtElements); }
///<summary> /// Creates new instance of DocxDocument from scratch ///</summary> public DocxDocument() { _documentStream = new MemoryStream(); _wordDocument = WordprocessingDocument.Create(_documentStream, WordprocessingDocumentType.Document, true); _wordDocument.AddMainDocumentPart(); _wordDocument.MainDocumentPart.Document = new Document(new Body()); var sdtElements = _wordDocument.MainDocumentPart.Document.Body.Descendants<SdtElement>(); _fields = new FieldsCollection(sdtElements); }
public virtual IQueryable <TEntity> GetAll() { var entity = GetObjectContext <TEntity>(); FieldsCollection columns = new FieldsCollection { entity.Properties.Select(e => new Field(e.Info.Name)) }; QueryParameter queryParameter = new QueryParameter(columns); SqlCommand command = CommandBuilder.QueryCommand(entity.Table, queryParameter); return(Query <TEntity>(command.SqlString, command.Parameters).AsQueryable()); }
///<summary> /// Creates new instance of DocxDocument from scratch ///</summary> public DocxDocument() { _documentStream = new MemoryStream(); _wordDocument = WordprocessingDocument.Create(_documentStream, WordprocessingDocumentType.Document, true); _wordDocument.AddMainDocumentPart(); _wordDocument.MainDocumentPart.Document = new Document(new Body()); var sdtElements = _wordDocument.MainDocumentPart.Document.Body.Descendants <SdtElement>(); _fields = new FieldsCollection(sdtElements); }
public SqlCommand InsertCommand(TEntity entity) { var obj = GetObjectContext <TEntity>(); FieldsCollection fields = new FieldsCollection(); foreach (var prop in obj.Properties) { fields.Add(new Field(prop.Info.Name, prop.Info.GetValue(entity))); } var com = CommandBuilder.InsertCommand(obj.Table, fields); return(com); }
public override int GetHashCode() { unchecked { var hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (FieldsCollection != null ? FieldsCollection.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DisplayName != null ? DisplayName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ UpdateAllOccurrences.GetHashCode(); hashCode = (hashCode * 397) ^ CreateBookmark.GetHashCode(); hashCode = (hashCode * 397) ^ (ServiceHost != null ? ServiceHost.GetHashCode() : 0); return(hashCode); } }
public string HTTPDotNetPostback(string page, string formName, string formAction, string postbackField, string eventArg, string url, FieldsCollection variablePostbackFields, int timeout) { FieldsCollection input = GetDotNetPostbackInput(page, formName, formAction, postbackField, eventArg, url, variablePostbackFields, timeout, true); //return input.GetHTTPKeysAndValuesStringWithBR(); if (input != null) { return(HTTPPost(url, input, timeout)); } else { return(page); } }
public override void UpdateForEachOutputs(IList <Tuple <string, string> > updates) { foreach (Tuple <string, string> t in updates) { // locate all updates for this tuple var t1 = t; var items = FieldsCollection.Where(c => !string.IsNullOrEmpty(c.FieldName) && c.FieldName.Contains(t1.Item1)); // issues updates foreach (var a in items) { a.FieldName = a.FieldName.Replace(t.Item1, t.Item2); } } }
public FieldsCollection GetDotNetPostbackInput(string page, string formName, string formAction, string postbackField, string eventArg, string url, FieldsCollection variablePostbackFields, int timeout, bool fieldValidation) { FieldsCollection input = new FieldsCollection(); input.AutogenerateDefaultFields(page, formName, formAction); if (fieldValidation == true) { //check to see that postback field exist try { input.GetKey(postbackField); } catch (FieldDoesNotExistException) { throw new BrowserEmulatorException("Postback field (" + postbackField + ") does not exist on the page"); } } input["__EVENTTARGET"].HttpValue = postbackField; input["__EVENTARGUMENT"].HttpValue = eventArg; input["__VIEWSTATE"].HttpValue = FieldsCollection.GetVIEWSTATE(page, formName, formAction); // if value changed we submit bool submit = true; if (fieldValidation == true) { if (input[postbackField].HttpValue == variablePostbackFields[postbackField].HttpValue) { submit = false; } } input.MergeReplace(variablePostbackFields); input.DoNotSubmitSubmit(); input.ValidateAgainstHTMLPage(page, formName, formAction); //if we don't need to submit we return null if (submit == true) { return(input); } else { return(null); } }
/// <summary> /// Loads the document by using the specified importer. /// </summary> /// <param name="file">The the file.</param> /// <param name="importer"></param> public void Load(string file, IImporter importer) { _importer = importer; _isLoadedFile = true; Styles = new StyleCollection(); _fields = new FieldsCollection(); Content = new ContentCollection(); _xmldoc = XDocument.Parse(TextDocumentHelper.GetBlankDocument()); if (_importer != null) { if (_importer.NeedNewOpenDocument) { New(); } _importer.Import(this, file); if (_importer.ImportError != null) { if (_importer.ImportError.Count > 0) { foreach (AODLWarning ob in _importer.ImportError) { if (ob.Message != null) { Console.WriteLine("Err: {0}", ob.Message); } if (ob.Node != null) { using (XmlWriter writer = XmlWriter.Create(Console.Out, new XmlWriterSettings { Indent = true })) { ob.Node.WriteTo(writer); } } } } } } _formCollection.Clearing += FormsCollection_Clear; _formCollection.Removed += FormsCollection_Removed; }
public bool Equals(DsfMultiAssignObjectActivity other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(base.Equals(other) && FieldsCollection.SequenceEqual(other.FieldsCollection, new ActivityDtoObjectComparer()) && UpdateAllOccurrences == other.UpdateAllOccurrences && CreateBookmark == other.CreateBookmark && string.Equals(ServiceHost, other.ServiceHost) && string.Equals(DisplayName, other.DisplayName)); }
public ItemFields(Guid itemId, [NotNull] DataContext dataContext) { Assert.ArgumentNotNull(dataContext, nameof(dataContext)); this.ItemId = itemId; this.DataContext = dataContext; var sharedFields = this.DataContext .GetTable<SharedFieldData>() .Where(x => x.ItemId == this.ItemId) .ToDictionary(x => x.FieldId.ToString(), x => x.Value); var unversionedFields = this .DataContext .GetTable<UnversionedFieldData>() .Where(x => x.ItemId == this.ItemId) .GroupBy(x => x.Language); var versionedFields = this .DataContext .GetTable<VersionedFieldData>() .Where(x => x.ItemId == this.ItemId) .GroupBy(x => x.Language); this._Shared = new FieldsCollection(sharedFields); this._Unversioned = unversionedFields .ToDictionary( x => x.Key, x => new FieldsCollection(x .ToDictionary(z => z.FieldId.ToString(), z => z.Value))); this._Versioned = versionedFields .ToDictionary( x => x.Key, x => x .GroupBy(z => z.Version) .ToDictionary( c => c.Key, c => new FieldsCollection(c .ToDictionary(v => v.FieldId.ToString(), v => v.Value)))); }
public byte[] HTTPPostReceiveBinary(string url, FieldsCollection fields, int timeout) { HttpWebRequest request = SetUpHeader(url, timeout); request.Method = "POST"; request.Proxy = Proxy; UTF8Encoding utf8Encoding = new UTF8Encoding(); Byte[] requestBody = utf8Encoding.GetBytes(fields.GetHTTPKeysAndValuesString()); request.ContentLength = requestBody.Length; request.GetRequestStream().Write(requestBody, 0, requestBody.Length); request.GetRequestStream().Close(); byte[] file = GetBinaryResponse(request); SessionCookies = request.CookieContainer; mReferrer = url; return(file); }
/// <summary> /// Create a new TextDocument object. /// </summary> public TextDocument() { _fields = new FieldsCollection(); Content = new ContentCollection(); Styles = new StyleCollection(); m_styleFactory = new StyleFactory(this); CommonStyles = new StyleCollection(); FontList = new List <string>(); _graphics = new List <Graphic>(); _formCollection = new ODFFormCollection(); _formCollection.Clearing += FormsCollection_Clear; _formCollection.Removed += FormsCollection_Removed; VariableDeclarations = new VariableDeclCollection(); _customFiles = new CustomFileCollection(); _customFiles.Clearing += CustomFiles_Clearing; _customFiles.Inserting += CustomFiles_Inserting; _customFiles.Removing += CustomFiles_Removing; }
public SqlCommand GetCommand(TPrimaryKey key) { var obj = GetObjectContext <TEntity>(); FieldsCollection fields = new FieldsCollection(); List <Filter> filters = new List <Filter>(); foreach (var prop in obj.Properties) { foreach (var attr in prop.Attributes) { if (attr is PrimaryKeyAttribute keyAttr) { filters.Add(new Equal(prop.Info.Name, key)); } } fields.Add(new Field(prop.Info.Name)); } QueryParameter queryParameter = new QueryParameter(fields, filters); return(CommandBuilder.QueryCommand(obj.Table, queryParameter, count: 1)); }
/// <summary> /// 更新命令 /// </summary> /// <param name="table"></param> /// <param name="fields"></param> /// <param name="filters"></param> /// <returns></returns> public SqlCommand UpdateCommand(string table, FieldsCollection fields, IEnumerable <Filter> filters) { if (fields == null || fields.Count == 0) { throw new ApplicationException("Invalid fields can be update."); } if (string.IsNullOrEmpty(table)) { throw new ApplicationException("Invalid table's name."); } var param = new DynamicParameters(); var columnStrs = new List <string>(); var filterStrs = new List <string>(); foreach (var field in fields) { columnStrs.Add($"`{field.Name}`=@{field.Name}"); param.Add(field.Name, field.Value); } if (filters != null) { foreach (var filter in filters) { var filterCommand = filter.ToSqlCommand(); if (filterCommand != null) { filterStrs.Add(filterCommand.SqlString); param.AddDynamicParams(filterCommand.Parameters); } } } string strSql = $@"UPDATE `{table}` SET {string.Join(",", columnStrs)} {(filterStrs.Count > 0 ? $" WHERE {string.Join(" AND ", filterStrs)}" : "")};"; return(new SqlCommand(strSql, param)); }
/// <summary> /// 插入命令 /// </summary> /// <param name="table"></param> /// <param name="fields"></param> /// <returns></returns> public SqlCommand InsertCommand(string table, FieldsCollection fields) { if (fields == null || fields.Count == 0) { throw new ApplicationException("Invalid fields can be inserted."); } if (string.IsNullOrEmpty(table)) { throw new ApplicationException("Invalid table's name."); } var param = new DynamicParameters(); var colNames = new List <string>(); var prmNames = new List <string>(); foreach (var field in fields) { colNames.Add($"`{field.Name}`"); prmNames.Add($"@{field.Name}"); param.Add(field.Name, field.Value); } string strSql = $@"INSERT INTO `{table}`({string.Join(",", colNames)}) VALUES ({string.Join(",", prmNames)});"; return(new SqlCommand(strSql, param)); }
public override List <string> GetOutputs() => FieldsCollection.Select(dto => dto.FieldName).ToList();
void ComputedFields_InitField(object sender, FieldsCollection<ComputedField>.FieldEventArgs e) { e.Field.Manager = this.Manager; }
public PowerfulImportWizard(string title, Image img) { InitializeComponent(); #region 加入進階按紐跟HELP按鈕 _OptionsContainer = new PanelEx(); _OptionsContainer.Font = this.Font; _OptionsContainer.ColorSchemeStyle = eDotNetBarStyle.Office2007; _OptionsContainer.Size = new Size(100, 100); _OptionsContainer.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; _OptionsContainer.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; _OptionsContainer.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; _OptionsContainer.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; _OptionsContainer.Style.GradientAngle = 90; _Options = new OptionCollection(); _Options.ItemsChanged += new EventHandler(_Options_ItemsChanged); advContainer = new ControlContainerItem(); advContainer.AllowItemResize = false; advContainer.GlobalItem = false; advContainer.MenuVisibility = eMenuVisibility.VisibleAlways; advContainer.Control = _OptionsContainer; ItemContainer itemContainer2 = new ItemContainer(); itemContainer2.LayoutOrientation = DevComponents.DotNetBar.eOrientation.Vertical; itemContainer2.MinimumSize = new System.Drawing.Size(0, 0); itemContainer2.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] { advContainer}); advButton = new ButtonX(); advButton.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; advButton.Text = " 進階"; advButton.Top = this.wizard1.Controls[1].Controls[0].Top; advButton.Left = 5; advButton.Size = this.wizard1.Controls[1].Controls[0].Size; advButton.Visible = true; advButton.SubItems.Add(itemContainer2); advButton.PopupSide = ePopupSide.Top; advButton.SplitButton = true; advButton.Enabled = false; advButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; advButton.AutoExpandOnClick = true; advButton.SubItemsExpandWidth = 16; advButton.FadeEffect = false; advButton.FocusCuesEnabled = false; this.wizard1.Controls[1].Controls.Add(advButton); helpButton = new LinkLabel(); helpButton.AutoSize = true; helpButton.BackColor = System.Drawing.Color.Transparent; helpButton.Location = new System.Drawing.Point(81, 10); helpButton.Size = new System.Drawing.Size(69, 17); helpButton.TabStop = true; helpButton.Text = "Help"; helpButton.Visible = false; helpButton.Click += delegate { if (HelpButtonClick != null)HelpButtonClick(this, new EventArgs()); }; helpButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; this.wizard1.Controls[1].Controls.Add(helpButton); #endregion #region 設定Wizard會跟著Style跑 //this.wizard1.FooterStyle.ApplyStyle(( GlobalManager.Renderer as Office2007Renderer ).ColorTable.GetClass(ElementStyleClassKeys.RibbonFileMenuBottomContainerKey)); //this.wizard1.HeaderStyle.ApplyStyle((GlobalManager.Renderer as Office2007Renderer).ColorTable.GetClass(ElementStyleClassKeys.RibbonFileMenuBottomContainerKey)); this.wizard1.FooterStyle.BackColorGradientAngle = -90; this.wizard1.FooterStyle.BackColorGradientType = eGradientType.Linear; //this.wizard1.FooterStyle.BackColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.Start; //this.wizard1.FooterStyle.BackColor2 = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.End; //this.wizard1.BackColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.Start; //this.wizard1.BackgroundImage = null; //for (int i = 0; i < 6; i++) //{ // (this.wizard1.Controls[1].Controls[i] as ButtonX).ColorTable = eButtonColor.OrangeWithBackground; //} //(this.wizard1.Controls[0].Controls[1] as System.Windows.Forms.Label).ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.MouseOver.TitleText; //(this.wizard1.Controls[0].Controls[2] as System.Windows.Forms.Label).ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TitleText; _CheckAllManager.TargetComboBox = this.checkBox1; _CheckAllManager.TargetListView = this.listView1; #endregion _Title = this.Text = title; lblReqFields.Text = ""; foreach (WizardPage page in wizard1.WizardPages) { page.PageTitle = _Title; if (img != null) { Bitmap b = new Bitmap(48, 48); using (Graphics g = Graphics.FromImage(b)) g.DrawImage(img, 0, 0, 48, 48); page.PageHeaderImage = b; } } _RequiredFields = new FieldsCollection(); _ImportableFields = new FieldsCollection(); _SelectedFields = new FieldsCollection(); _RequiredFields.ItemsChanged += new EventHandler(FieldsChanged); _ImportableFields.ItemsChanged += new EventHandler(FieldsChanged); }
// ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedMember.Local public Issue(string key, FieldsCollection fields) { Key = key; Fields = fields; }