private async Task GetFieldsAsync()
        {
            ReportFields.Clear();
            SelectedFields.Clear();
            if (SelectedLayer == null)
            {
                return;
            }

            await QueuedTask.Run((Action)(() =>
            {
                foreach (FieldDescription fd in SelectedLayer?.GetFieldDescriptions())
                {
                    string shapeField = SelectedLayer.GetFeatureClass().GetDefinition().GetShapeField();
                    if (fd.Name == shapeField)
                    {
                        continue;                        //filter out the shape field.
                    }
                    var defFieldAction = (Action)(() =>
                    {
                        var field = new ReportField {
                            IsSelected = false, DisplayName = fd.Alias, Name = fd.Name
                        };
                        ReportFields.Add(field);
                        field.FieldSelectionChanged += this.Field_FieldSelectionChanged;
                        //field.IsSelected = true;
                    });
                    ActionOnGuiThread(defFieldAction);
                }
            }));
        }
Beispiel #2
0
 private void XMLSaveButton_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter = "XML files (*.xml)|*.xml";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         WaitLabel.Visible = true;
         WaitLabel.Text    = "Сохранение XML файла ...";
         XMLWriter writer         = new XMLWriter(saveFileDialog1.FileName);
         bool[]    selectedFields = new bool[6];
         for (int i = 0; i < 6; i++)
         {
             selectedFields[i] = SelectedFields.GetSelected(i);
         }
         writer.selectedItems = selectedFields;
         writer.result        = GetResult();
         if (writer.result.Count == 0)
         {
             MessageBox.Show("Внимание! Нет записей, соответствующих выбранным Вами настройкам. Возможная проблема: не выбрано ни одно поле для экспорта.",
                             "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         Thread xmlThread = new Thread(writer.WriteXML);
         xmlThread.Start();
         WaitLabel.Text = "XML файл успешно сохранен!";
     }
 }
Beispiel #3
0
 private void ExcelSaveButton_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter = "Excel files (*.xls)|*.xls";
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         if (workThread.IsAlive)
         {
             MessageBox.Show("Внимание! Дождитесь завершения предидущего процесса!", "Предыдущий процесс завершен не полностью!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             ExcelWriter writer         = new ExcelWriter(saveFileDialog1.FileName);
             bool[]      selectedFields = new bool[6];
             for (int it = 0; it < 6; it++)
             {
                 selectedFields[it] = SelectedFields.GetSelected(it);
             }
             writer.selectedFields = selectedFields;
             writer.currentForm    = this;
             writer.result         = GetResult();
             if (writer.result.Count == 0)
             {
                 MessageBox.Show("Внимание! Нет записей, соответствующих выбранным Вами настройкам. Возможная проблема: не выбрано ни одно поле для экспорта.",
                                 "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             workThread = new Thread(writer.WriteExcel);
             workThread.Start();
         }
     }
 }
    private bool CanUpdateReport()
		{
			var canUpdateReport = false;
			if (_reportsInProject.Any(r => r.Name == ReportName))
				canUpdateReport = true;
			//Check if there are fields selected in the UI not in the report. If yes, then we need to update.
			var reportToUpdate = _reportsInProject.FirstOrDefault(r => r.Name == ReportName);
			if (reportToUpdate == null) return false;
			var cimFieldsInReport = reportToUpdate.DataSource.Fields.ToList();
			//This is a "ReportField" collection. Change to CIMReportField collection
			var reportFieldsSelected = SelectedFields.ToList();
			List<CIMReportField> cimReportFieldsSelected = new List<CIMReportField>();
			foreach (var rfld in reportFieldsSelected)
			{
				var cimReportField = new CIMReportField() { Name = rfld.Name };
				cimReportFieldsSelected.Add(cimReportField);
			}
			//New fields: Fields in the "SelectedFields" of dockpane, but not in the report object.
			_fieldsAddToReport = cimReportFieldsSelected.Except(cimFieldsInReport, new ReportFieldComparer()).ToList();

			canUpdateReport = _fieldsAddToReport.Count == 0 ? false : true;

			//TODO: Check if a new statistics is checked
			//If nothing new, no need to update

			return canUpdateReport;
		}
		private void Field_FieldSelectionChanged(object sender, FieldSelectionChangedEventArgs e)
		{
			var reportField = e.ChangedReportField;
			if (reportField.IsSelected)
				SelectedFields.Add(new ReportField { DisplayName = reportField.DisplayName, Name = reportField.Name });
			else
				SelectedFields.Remove(SelectedFields.Where((fld) => fld.Name == reportField.Name).FirstOrDefault());
		}
 private void listViewEx1_ItemChecked(object sender, ItemCheckedEventArgs e)
 {
     SelectedFields.Clear();
     foreach (ListViewItem item in listViewEx1.Items)
     {
         if (item != null && item.Checked && _ExportableFields.Contains(item.Text))
         {
             SelectedFields.Add(item.Text);
         }
     }
 }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        internal override void Init()
        {
            var fieldsTable = Task.DataView.GetFieldsTab();

            dataViewContent    = new StringBuilder();
            selectedFldIdxList = new List <bool>();

            for (var i = 0; i < fieldsTable.getSize(); i++)
            {
                selectedFldIdxList.Add(SelectedFields.Contains((Field)fieldsTable.getField(i)));
            }

            dataViewContent.Append("<" + ConstInterface.MG_TAG_DATAVIEW + XMLConstants.TAG_CLOSE);
        }
Beispiel #8
0
        protected override void LoadNewDeclarationBlocks()
        {
            if (_stateUDTField.IsExistingDeclaration)
            {
                return;
            }

            _stateUDTField.AddMembers(SelectedFields.Cast <IConvertToUDTMember>());

            AddContentBlock(NewContentTypes.TypeDeclarationBlock, _stateUDTField.TypeDeclarationBlock(_indenter));

            AddContentBlock(NewContentTypes.DeclarationBlock, _stateUDTField.FieldDeclarationBlock);
            return;
        }
Beispiel #9
0
        protected override void ModifyFields(IRewriteSession refactorRewriteSession)
        {
            var rewriter = refactorRewriteSession.CheckOutModuleRewriter(_targetQMN);

            rewriter.RemoveVariables(SelectedFields.Select(f => f.Declaration)
                                     .Cast <VariableDeclaration>());

            if (_stateUDTField.IsExistingDeclaration)
            {
                _stateUDTField.AddMembers(SelectedFields.Cast <IConvertToUDTMember>());

                rewriter.Replace(_stateUDTField.AsTypeDeclaration, _stateUDTField.TypeDeclarationBlock(_indenter));
            }
        }
        internal static Tuple <Db, string, SelectedFields, Dictionary <string, string>, string, SelectedFields, List <string> > UpdateJoinParam <TModel>(this IBatchRunner runner,
                                                                                                                                                         IQueryable <TModel> query, ObjectQuery <TModel> objectQuery, EntityMap entityMap)
            where TModel : class
        {
            var    db        = GetDb(objectQuery.Context);
            string keySelect = null;
            int    i         = 0;
            var    idFields  = new List <string>();

            try
            {
                keySelect = GetSelectKeySql(objectQuery, entityMap, null, runner, idFields);
            }
            catch (NotSupportedException ex)
            {
                //if (ex.HResult == -2146233067)
                throw new ArgumentException("The select statement must include the key(s) of updated table. The keys themselves would not be updated.", "query");
                //throw ex;
            }
            var selectKeyFields = new SelectedFields(keySelect, runner.CharToEscapeQuote);
            var idFieldsMap     = new Dictionary <string, string>();

            for (i = 0; i < idFields.Count; i++)
            {
                if (idFields[i] == null)
                {
                    continue;
                }
                string valueField = selectKeyFields[i];
                if (selectKeyFields.AliasIndexes[i] > 0)
                {
                    valueField = valueField.Substring(0, selectKeyFields.AliasIndexes[i]);
                }
                idFieldsMap[idFields[i]] = valueField;
            }

            var selectedProperties = GetSelectedProperties(query.Expression, entityMap);

            if (selectedProperties == null || selectedProperties.Count() < 1)
            {
                throw new ArgumentException("Cannot read the selected fields in the query", "query");
            }

            var    updateFields = new List <string>();
            string selectSql    = GetSelectSql(objectQuery, selectedProperties, db.Command, runner, updateFields);
            var    selectFields = new SelectedFields(selectSql, runner.CharToEscapeQuote);

            return(Tuple.Create(db, keySelect, selectKeyFields, idFieldsMap, selectSql, selectFields, updateFields));
        }
        /// <summary>
        /// Handler for when someone closes the dialog with the OK button
        /// </summary>
        /// <param name="obj"></param>
        private void OnOkButtonPressedCommand(object obj)
        {
            if (!string.IsNullOrWhiteSpace(SelectedField1))
            {
                SelectedFields.Add(SelectedField1);
            }

            if (UseTwoFields && !string.IsNullOrWhiteSpace(SelectedField2))
            {
                SelectedFields.Add(SelectedField2);
            }

            // close dialog
            DialogResult = true;
        }
 /// <summary>
 /// Create service model from api model
 /// </summary>
 public PublishedDataSetEventsModel ToServiceModel()
 {
     return(new PublishedDataSetEventsModel {
         Id = Id,
         DiscardNew = DiscardNew,
         EventNotifier = EventNotifier,
         BrowsePath = BrowsePath,
         Filter = Filter?.ToServiceModel(),
         QueueSize = QueueSize,
         MonitoringMode = MonitoringMode,
         TriggerId = TriggerId,
         SelectedFields = SelectedFields?
                          .Select(f => f.ToServiceModel())
                          .ToList()
     });
 }
Beispiel #13
0
        protected override List <TplResult> InnerProcess(List <TplResult> input)
        {
            for (int j = 0; j < input.Count; j++)
            {
                var result = input[j];

                //Remove fields
                for (int i = 0; i < result.Count; i++)
                {
                    var key = result.Fields.Keys.ElementAt(i);
                    if (!SelectedFields.Contains(key))
                    {
                        if (result.RemoveField(key))
                        {
                            i--;
                        }

                        else
                        {
                            result.SetFieldVisibility(key, false);
                        }
                    }
                    else
                    {
                        result.SetFieldVisibility(key, true);
                    }
                }

                //Remove empty results
                bool containsAllSelectedFields = true;
                bool containsOneSelectedField  = false;
                foreach (var f in SelectedFields)
                {
                    containsAllSelectedFields &= result.HasField(f);
                    containsOneSelectedField  |= result.HasField(f);
                }

                if (!containsOneSelectedField || (!containsAllSelectedFields && RemoveEntriesWithNullValues))
                {
                    input.RemoveAt(j);
                    j--;
                }
            }

            return(input);
        }
 public void MoveFields(FieldData[] fieldsData)
 {
     foreach (var field in fieldsData)
     {
         if (field.IsSelected)
         {
             field.IsSelected = false;
             AvailableFields.Add(field);
             SelectedFields.Remove(field);
         }
         else
         {
             field.IsSelected = true;
             AvailableFields.Remove(field);
             SelectedFields.Add(field);
         }
     }
 }
Beispiel #15
0
        protected override void ModifyFields(IRewriteSession refactorRewriteSession)
        {
            var rewriter = refactorRewriteSession.CheckOutModuleRewriter(_targetQMN);

            rewriter.RemoveVariables(_fieldsToDeleteAndReplace.Select(f => f.Declaration).Cast <VariableDeclaration>());

            foreach (var field in SelectedFields.Except(_fieldsToDeleteAndReplace))
            {
                if (field.Declaration.HasPrivateAccessibility() && field.BackingIdentifier.Equals(field.Declaration.IdentifierName))
                {
                    rewriter.MakeImplicitDeclarationTypeExplicit(field.Declaration);
                    continue;
                }

                rewriter.Rename(field.Declaration, field.BackingIdentifier);
                rewriter.SetVariableVisiblity(field.Declaration, Accessibility.Private.TokenString());
                rewriter.MakeImplicitDeclarationTypeExplicit(field.Declaration);
            }
        }
Beispiel #16
0
        public Model(List <Field> fields, List <Constraint> constraints, List <Table> tables)
        {
            this._fields      = fields;
            this._constraints = constraints;
            this._tables      = tables;

            //Attach event on every Field
            this._fields.ForEach((field) =>
            {
                if (field.IsSelected)
                {
                    SelectedFields.Add(field);
                }
                else
                {
                    field.OnSelectField += new Field.OnSelectFieldEventHandler((args) =>
                    {
                        SelectedFields.Add(field);
                    });
                }
            });
        }
Beispiel #17
0
 public UseBackingFields(IDeclarationFinderProvider declarationFinderProvider, EncapsulateFieldModel model, IIndenter indenter, ICodeBuilder codeBuilder)
     : base(declarationFinderProvider, model, indenter, codeBuilder)
 {
     _fieldsToDeleteAndReplace = SelectedFields.Where(f => f.Declaration.IsDeclaredInList() && !f.Declaration.HasPrivateAccessibility()).ToList();
 }
Beispiel #18
0
        /// <summary>
        /// 載入匯入的相關檔案與執行相關初始化動作。
        /// </summary>
        public void RefreshImportSource()
        {
            FileInfo file       = new FileInfo(SourceFileName);
            string   backupName = Path.Combine(file.DirectoryName, "原始資備份_" + file.Name);

            if (!File.Exists(backupName))
            {
                File.Copy(SourceFileName, backupName);
            }

            Workbook book = new Workbook();

            book.Open(SourceFileName);

            _workbook = book;
            Worksheet sheet;

            try
            {
                // sheet = _workbook.Worksheets["學生資料"];

                // 先改成預設讀取第1個工作表,保持與其他匯入一致。
                sheet = _workbook.Worksheets[0];
            }
            catch (Exception)
            {
                sheet = _workbook.Worksheets[0];
            }
            // 2017/8/22 穎驊依據高雄小組專案 [03-05][04+] EXCEL匯入格式可否修正為xlsx也可匯入? 更改為新版 Aspose.Cells_201402 寫法 ,GetStyle()
            //_styles = new TipStyle(_workbook, sheet.Cells[0, 0].Style); //用第一格來當作樣版。


            _styles = new TipStyle(_workbook, sheet.Cells[0, 0].GetStyle()); //用第一格來當作樣版。


            _source_sheet = sheet;

            _source_reader = new SheetReader();
            _source_reader.BindSheet(sheet, 0, 0);

            //設定資料讀取器的「識別欄」。
            if (!string.IsNullOrEmpty(IdentifyField))
            {
                _source_reader.SetKeyColumn(IdentifyField);
            }

            //取得可匯入欄位與使用者提供的欄位交集。
            _accept_columns = BulkDescription.Columns.GetInstersection(_source_reader.Columns.GetNames());

            //檢查是否有之前驗證過的欄位。
            //將 Accept SheetColumn 與 BulkColumn 建立關係。
            foreach (SheetColumn each in SourceColumns.Values)
            {
                // 2017/8/22 穎驊依據高雄小組專案 [03-05][04+] EXCEL匯入格式可否修正為xlsx也可匯入? 更改為新版 Aspose.Cells_201402 寫法 ,GetStyle()
                //Style s = each.BindingCell.Style, t = TipStyle.Header;

                Style s = each.BindingCell.GetStyle(), t = TipStyle.Header;

                if (s.ForegroundColor == t.ForegroundColor && s.Font.Color == t.Font.Color)
                {
                    each.UsedValid = true;
                }
                else
                {
                    each.UsedValid = false;
                }

                if (_accept_columns.ContainsKey(each.Name))
                {
                    each.SetBulkColumn(_accept_columns[each.Name]);
                }
            }

            //復原欄位到預設樣式。
            foreach (SheetColumn each in SourceColumns.Values)
            {
                each.SetStyle(TipStyle.Normal);
            }

            //設定「識別欄」樣式。
            if (!string.IsNullOrEmpty(IdentifyField))
            {
                SourceColumns[IdentifyField].SetStyle(TipStyle.Header);
            }

            //設定「檢查欄」樣式。
            if (!string.IsNullOrEmpty(ShiftCheckField))
            {
                SourceColumns[ShiftCheckField].SetStyle(TipStyle.Header);
            }

            //將使用者選擇的欄位設成「欄」樣式。
            foreach (SheetColumn each in SourceColumns.Values)
            {
                if (SelectedFields != null)
                {
                    if (SelectedFields.ContainsKey(each.Name))
                    {
                        each.SetStyle(TipStyle.Header);
                    }
                }
            }
        }
Beispiel #19
0
        //[System.Diagnostics.DebuggerStepThrough]
        public string ToSQLString(string Quotes, string paramPrefix, List <XSqlCommandParam> Params, ISqlCompiler compiler)
        {
            var ret = "";

            if (this.source == null)
            {
                if (SelectedFields == null || this.SelectedFields.Count == 0)
                {
                    if (this.filter == null)
                    {
                        ret = "select * From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler);
                    }
                    else
                    {
                        ret = "select * From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler);
                    }
                }
                else
                {
                    if (this.filter == null)
                    {
                        ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler);
                    }
                    else
                    {
                        ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.GetFromClause(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler);
                    }
                }
            }
            else
            {
                if (SelectedFields == null || this.SelectedFields.Count == 0)
                {
                    if (this.filter == null)
                    {
                        ret = "select * From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler);
                    }
                    else
                    {
                        ret = "select * From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler);
                    }
                }
                else
                {
                    if (this.filter == null)
                    {
                        ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler);
                    }
                    else
                    {
                        ret = "select " + string.Join(",", SelectedFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler))) + " From " + this.source.ToSQLString(Quotes, paramPrefix, Params, compiler) + " where " + this.filter.ToSQLString(Quotes, paramPrefix, Params, compiler);
                    }
                }
            }
            if (this.GroupByFields != null)
            {
                ret += " Group By " + string.Join(",", this.GroupByFields.Select(p => p.ToSQLString(Quotes, paramPrefix, Params, compiler)));
            }
            if (ret != "")
            {
                return(ret);
            }
            throw new NotImplementedException();
        }