Exemplo n.º 1
0
        private void SetTableToList(DataTable dt, string configName, ImportDataType dataType)
        {
            var arr    = (dataType == ImportDataType.交割单) ? deliPropertyNames : softPropertyNames;
            var config = CommonUtils.GetConfig(configName);

            if (string.IsNullOrEmpty(config))
            {
                NotMatchConfigData.Add(dt);
            }
            else
            {
                bool isFitConfig = true;

                var dict = config.FromJson <Dictionary <string, string> >();
                foreach (var item in arr)
                {
                    isFitConfig = isFitConfig && (!dict.ContainsKey(item) || dt.Columns.Contains(dict[item]));
                }

                if (isFitConfig)
                {
                    MatchConfigData.Add(dt);
                }
                else
                {
                    NotMatchConfigData.Add(dt);
                }
            }
        }
Exemplo n.º 2
0
        private void Save()
        {
            ControlUtils.ShowLoading(this.loading, "保存中……");
            bool isAutoSearch = cbNeedAutoSearchDel.IsChecked == true;

            lock (sync)
            {
                if (!IsUpdating)
                {
                    IsUpdating = true;

                    var delieryConfig = GetPageConfig(ImportDataType.交割单);
                    var softConfig    = GetPageConfig(ImportDataType.软件委托);

                    if (SelectedTable != null)
                    {
                        SaveOneTable(SelectedTable, delieryConfig, softConfig);
                    }
                    else if (MatchConfigData.Count > 0)
                    {
                        List <string> groupNames = new List <string>();
                        foreach (string item in listBoxMatched.Items)
                        {
                            var groupName = item.GetFileName().GetGroupName();
                            if (item.GetImportType() == ImportDataType.软件委托 && !string.IsNullOrEmpty(groupName) && !groupNames.Contains(groupName))
                            {
                                groupNames.Add(groupName.ToUpper());
                            }
                        }

                        listBoxMatched.ItemsSource    = null;
                        listBoxNotMatched.ItemsSource = NotMatchConfigData.Select(_ => _.TableName.GetFileName());
                        MatchConfigData.Clear();

                        var saving = new Action(() => { SaveMatchedTables(delieryConfig, softConfig); });

                        var completeUIAction = new Action(() => {
                            ControlUtils.HideLoading(this.loading);
                            if (OnDBChangeComplete != null)
                            {
                                OnDBChangeComplete.Invoke();
                            }

                            if (cbNeedAutoSearchDel.IsChecked == true)
                            {
                                AutoSaveDelivery(groupNames, this.dpDate.SelectedDate.Value);
                            }
                        });

                        CommonUtils.RunAsync(this.Dispatcher, saving, null, null, completeUIAction);
                    }
                    IsUpdating = false;
                }
            }
        }
Exemplo n.º 3
0
 private void listBoxMatched_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         var tableName = e.AddedItems[0] as string;
         if (!string.IsNullOrEmpty(tableName))
         {
             var dt = MatchConfigData.First(_ => _.TableName.EndsWith(tableName));
             InitPageByFileName(dt.TableName);
             SetPageData(dt);
         }
     }
 }