m-old"> 21
+import '@ionic/vue/css/display.css';
22
+
23
+/* Theme variables */
24
+import './theme/variables.css';
25
+
26
+const app = createApp(App)
27
+  .use(IonicVue)
28
+  .use(router);
29
+  
30
+router.isReady().then(() => {
31
+  app.mount('#app');
32
+});

+ 39 - 0
src/router/index.ts

@@ -0,0 +1,39 @@
1
+import { createRouter, createWebHistory } from '@ionic/vue-router';
2
+import { RouteRecordRaw } from 'vue-router';
3
+import TabsPage from '../views/TabsPage.vue'
4
+
5
+const routes: Array<RouteRecordRaw> = [
6
+  {
7
+    path: '/',
8
+    redirect: '/tabs/tab1'
9
+  },
10
+  {
11
+    path: '/tabs/',
12
+    component: TabsPage,
13
+    children: [
14
+      {
15
+        path: '',
16
+        redirect: '/tabs/tab1'
17
+      },
18
+      {
19
+        path: 'tab1',
20
+        component: () => import('@/views/Tab1Page.vue')
21
+      },
22
+      {
23
+        path: 'tab2',
24
+        component: () => import('@/views/Tab2Page.vue')
25
+      },
26
+      {
27
+        path: 'tab3',
28
+        component: () => import('@/views/Tab3Page.vue')
29
+      }
30
+    ]
31
+  }
32
+]
33
+
34
+const router = createRouter({
35
+  history: createWebHistory(import.meta.env.BASE_URL),
36
+  routes
37
+})
38
+
39
+export default router

+ 242 - 0
src/theme/variables.css

@@ -0,0 +1,242 @@
1
+/* Ionic Variables and Theming. For more info, please see:
2
+http://ionicframework.com/docs/theming/ */
3
+
4
+/** Ionic CSS Variables **/
5
+:root {
6
+  /** primary **/
7
+  --ion-color-primary: #3880ff;
8
+  --ion-color-primary-rgb: 56, 128, 255;
9
+  --ion-color-primary-contrast: #ffffff;
10
+  --ion-color-primary-contrast-rgb: 255, 255, 255;
11
+  --ion-color-primary-shade: #3171e0;
12
+  --ion-color-primary-tint: #4c8dff;
13
+
14
+  /** secondary **/
15
+  --ion-color-secondary: #3dc2ff;
16
+  --ion-color-secondary-rgb: 61, 194, 255;
17
+  --ion-color-secondary-contrast: #ffffff;
18
+  --ion-color-secondary-contrast-rgb: 255, 255, 255;
19
+  --ion-color-secondary-shade: #36abe0;
20
+  --ion-color-secondary-tint: #50c8ff;
21
+
22
+  /** tertiary **/
23
+  --ion-color-tertiary: #5260ff;
24
+  --ion-color-tertiary-rgb: 82, 96, 255;
25
+  --ion-color-tertiary-contrast: #ffffff;
26
+  --ion-color-tertiary-contrast-rgb: 255, 255, 255;
27
+  --ion-color-tertiary-shade: #4854e0;
28
+  --ion-color-tertiary-tint: #6370ff;
29
+
30
+  /** success **/
31
+  --ion-color-success: #2dd36f;
32
+  --ion-color-success-rgb: 45, 211, 111;
33
+  --ion-color-success-contrast: #ffffff;
34
+  --ion-color-success-contrast-rgb: 255, 255, 255;
35
+  --ion-color-success-shade: #28ba62;
36
+  --ion-color-success-tint: #42d77d;
37
+
38
+  /** warning **/
39
+  --ion-color-warning: #ffc409;
40
+  --ion-color-warning-rgb: 255, 196, 9;
41
+  --ion-color-warning-contrast: #000000;
42
+  --ion-color-warning-contrast-rgb: 0, 0, 0;
43
+  --ion-color-warning-shade: #e0ac08;
44
+  --ion-color-warning-tint: #ffca22;
45
+
46
+  /** danger **/
47
+  --ion-color-danger: #eb445a;
48
+  --ion-color-danger-rgb: 235, 68, 90;
49
+  --ion-color-danger-contrast: #ffffff;
50
+  --ion-color-danger-contrast-rgb: 255, 255, 255;
51
+  --ion-color-danger-shade: #cf3c4f;
52
+  --ion-color-danger-tint: #ed576b;
53
+
54
+  /** dark **/
55
+  --ion-color-dark: #222428;
56
+  --ion-color-dark-rgb: 34, 36, 40;
57
+  --ion-color-dark-contrast: #ffffff;
58
+  --ion-color-dark-contrast-rgb: 255, 255, 255;
59
+  --ion-color-dark-shade: #1e2023;
60
+  --ion-color-dark-tint: #383a3e;
61
+
62
+  /** medium **/
63
+  --ion-color-medium: #92949c;
64
+  --ion-color-medium-rgb: 146, 148, 156;
65
+  --ion-color-medium-contrast: #ffffff;
66
+  --ion-color-medium-contrast-rgb: 255, 255, 255;
67
+  --ion-color-medium-shade: #808289;
68
+  --ion-color-medium-tint: #9d9fa6;
69
+
70
+  /** light **/
71
+  --ion-color-light: #f4f5f8;
72
+  --ion-color-light-rgb: 244, 245, 248;
73
+  --ion-color-light-contrast: #000000;
74
+  --ion-color-light-contrast-rgb: 0, 0, 0;
75
+  --ion-color-light-shade: #d7d8da;
76
+  --ion-color-light-tint: #f5f6f9;
77
+}
78
+
79
+@media (prefers-color-scheme: dark) {
80
+  /*
81
+   * Dark Colors
82
+   * -------------------------------------------
83
+   */
84
+
85
+  body {
86
+    --ion-color-primary: #428cff;
87
+    --ion-color-primary-rgb: 66,140,255;
88
+    --ion-color-primary-contrast: #ffffff;
89
+    --ion-color-primary-contrast-rgb: 255,255,255;
90
+    --ion-color-primary-shade: #3a7be0;
91
+    --ion-color-primary-tint: #5598ff;
92
+
93
+    --ion-color-secondary: #50c8ff;
94
+    --ion-color-secondary-rgb: 80,200,255;
95
+    --ion-color-secondary-contrast: #ffffff;
96
+    --ion-color-secondary-contrast-rgb: 255,255,255;
97
+    --ion-color-secondary-shade: #46b0e0;
98
+    --ion-color-secondary-tint: #62ceff;
99
+
100
+    --ion-color-tertiary: #6a64ff;
101
+    --ion-color-tertiary-rgb: 106,100,255;
102
+    --ion-color-tertiary-contrast: #ffffff;
103
+    --ion-color-tertiary-contrast-rgb: 255,255,255;
104
+    --ion-color-tertiary-shade: #5d58e0;
105
+    --ion-color-tertiary-tint: #7974ff;
106
+
107
+    --ion-color-success: #2fdf75;
108
+    --ion-color-success-rgb: 47,223,117;
109
+    --ion-color-success-contrast: #000000;
110
+    --ion-color-success-contrast-rgb: 0,0,0;
111
+    --ion-color-success-shade: #29c467;
112
+    --ion-color-success-tint: #44e283;
113
+
114
+    --ion-color-warning: #ffd534;
115
+    --ion-color-warning-rgb: 255,213,52;
116
+    --ion-color-warning-contrast: #000000;
117
+    --ion-color-warning-contrast-rgb: 0,0,0;
118
+    --ion-color-warning-shade: #e0bb2e;
119
+    --ion-color-warning-tint: #ffd948;
120
+
121
+    --ion-color-danger: #ff4961;
122
+    --ion-color-danger-rgb: 255,73,97;
123
+    --ion-color-danger-contrast: #ffffff;
124
+    --ion-color-danger-contrast-rgb: 255,255,255;
125
+    --ion-color-danger-shade: #e04055;
126
+    --ion-color-danger-tint: #ff5b71;
127
+
128
+    --ion-color-dark: #f4f5f8;
129
+    --ion-color-dark-rgb: 244,245,248;
130
+    --ion-color-dark-contrast: #000000;
131
+    --ion-color-dark-contrast-rgb: 0,0,0;
132
+    --ion-color-dark-shade: #d7d8da;
133
+    --ion-color-dark-tint: #f5f6f9;
134
+
135
+    --ion-color-medium: #989aa2;
136
+    --ion-color-medium-rgb: 152,154,162;
137
+    --ion-color-medium-contrast: #000000;
138
+    --ion-color-medium-contrast-rgb: 0,0,0;
139
+    --ion-color-medium-shade: #86888f;
140
+    --ion-color-medium-tint: #a2a4ab;
141
+
142
+    --ion-color-light: #222428;
143
+    --ion-color-light-rgb: 34,36,40;
144
+    --ion-color-light-contrast: #ffffff;
145
+    --ion-color-light-contrast-rgb: 255,255,255;
146
+    --ion-color-light-shade: #1e2023;
147
+    --ion-color-light-tint: #383a3e;
148
+  }
149
+
150
+  /*
151
+   * iOS Dark Theme
152
+   * -------------------------------------------
153
+   */
154
+
155
+  .ios body {
156
+    --ion-background-color: #000000;
157
+    --ion-background-color-rgb: 0,0,0;
158
+
159
+    --ion-text-color: #ffffff;
160
+    --ion-text-color-rgb: 255,255,255;
161
+
162
+    --ion-color-step-50: #0d0d0d;
163
+    --ion-color-step-100: #1a1a1a;
164
+    --ion-color-step-150: #262626;
165
+    --ion-color-step-200: #333333;
166
+    --ion-color-step-250: #404040;
167
+    --ion-color-step-300: #4d4d4d;
168
+    --ion-color-step-350: #595959;
169
+    --ion-color-step-400: #666666;
170
+    --ion-color-step-450: #737373;
171
+    --ion-color-step-500: #808080;
172
+    --ion-color-step-550: #8c8c8c;
173
+    --ion-color-step-600: #999999;
174
+    --ion-color-step-650: #a6a6a6;
175
+    --ion-color-step-700: #b3b3b3;
176
+    --ion-color-step-750: #bfbfbf;
177
+    --ion-color-step-800: #cccccc;
178
+    --ion-color-step-850: #d9d9d9;
179
+    --ion-color-step-900: #e6e6e6;
180
+    --ion-color-step-950: #f2f2f2;
181
+
182
+    --ion-item-background: #000000;
183
+
184
+    --ion-card-background: #1c1c1d;
185
+  }
186
+
187
+  .ios ion-modal {
188
+    --ion-background-color: var(--ion-color-step-100);
189
+    --ion-toolbar-background: var(--ion-color-step-150);
190
+    --ion-toolbar-border-color: var(--ion-color-step-250);
191
+  }
192
+
193
+
194
+  /*
195
+   * Material Design Dark Theme
196
+   * -------------------------------------------
197
+   */
198
+
199
+  .md body {
200
+    --ion-background-color: #121212;
201
+    --ion-background-color-rgb: 18,18,18;
202
+
203
+    --ion-text-color: #ffffff;
204
+    --ion-text-color-rgb: 255,255,255;
205
+
206
+    --ion-border-color: #222222;
207
+
208
+    --ion-color-step-50: #1e1e1e;
209
+    --ion-color-step-100: #2a2a2a;
210
+    --ion-color-step-150: #363636;
211
+    --ion-color-step-200: #414141;
212
+    --ion-color-step-250: #4d4d4d;
213
+    --ion-color-step-300: #595959;
214
+    --ion-color-step-350: #656565;
215
+    --ion-color-step-400: #717171;
216
+    --ion-color-step-450: #7d7d7d;
217
+    --ion-color-step-500: #898989;
218
+    --ion-color-step-550: #949494;
219
+    --ion-color-step-600: #a0a0a0;
220
+    --ion-color-step-650: #acacac;
221
+    --ion-color-step-700: #b8b8b8;
222
+    --ion-color-step-750: #c4c4c4;
223
+    --ion-color-step-800: #d0d0d0;
224
+    --ion-color-step-850: #dbdbdb;
225
+    --ion-color-step-900: #e7e7e7;
226
+    --ion-color-step-950: #f3f3f3;
227
+
228
+    --ion-item-background: #1e1e1e;
229
+
230
+    --ion-toolbar-background: #1f1f1f;
231
+
232
+    --ion-tab-bar-background: #1f1f1f;
233
+
234
+    --ion-card-background: #1e1e1e;
235
+  }
236
+}
237
+
238
+html {
239
+  /* For more information on dynamic font scaling, visit the documentation: 
240
+  https://ionicframework.com/docs/layout/dynamic-font-scaling */
241
+  --ion-dynamic-font: var(--ion-default-dynamic-font);
242
+}

+ 23 - 0
src/views/Tab1Page.vue

@@ -0,0 +1,23 @@
1
+<template>
2
+  <ion-page>
3
+    <ion-header>
4
+      <ion-toolbar>
5
+        <ion-title>Tab 1</ion-title>
6
+      </ion-toolbar>
7
+    </ion-header>
8
+    <ion-content :fullscreen="true">
9
+      <ion-header collapse="condense">
10
+        <ion-toolbar>
11
+          <ion-title size="large">Tab 1</ion-title>
12
+        </ion-toolbar>
13
+      </ion-header>
14
+
15
+      <ExploreContainer name="Tab 1 page" />
16
+    </ion-content>
17
+  </ion-page>
18
+</template>
19
+
20
+<script setup lang="ts">
21
+import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/vue';
22
+import ExploreContainer from '@/components/ExploreContainer.vue';
23
+</script>

+ 23 - 0
src/views/Tab2Page.vue

@@ -0,0 +1,23 @@
1
+<template>
2
+  <ion-page>
3
+    <ion-header>
4
+      <ion-toolbar>
5
+        <ion-title>Tab 2</ion-title>
6
+      </ion-toolbar>
7
+    </ion-header>
8
+    <ion-content :fullscreen="true">
9
+      <ion-header collapse="condense">
10
+        <ion-toolbar>
11
+          <ion-title size="large">Tab 2</ion-title>
12
+        </ion-toolbar>
13
+      </ion-header>
14
+
15
+      <ExploreContainer name="Tab 2 page" />
16
+    </ion-content>
17
+  </ion-page>
18
+</template>
19
+
20
+<script setup lang="ts">
21
+import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/vue';
22
+import ExploreContainer from '@/components/ExploreContainer.vue';
23
+</script>

+ 23 - 0
src/views/Tab3Page.vue

@@ -0,0 +1,23 @@
1
+<template>
2
+  <ion-page>
3
+    <ion-header>
4
+      <ion-toolbar>
5
+        <ion-title>Tab 3</ion-title>
6
+      </ion-toolbar>
7
+    </ion-header>
8
+    <ion-content :fullscreen="true">
9
+      <ion-header collapse="condense">
10
+        <ion-toolbar>
11
+          <ion-title size="large">Tab 3</ion-title>
12
+        </ion-toolbar>
13
+      </ion-header>
14
+
15
+      <ExploreContainer name="Tab 3 page" />
16
+    </ion-content>
17
+  </ion-page>
18
+</template>
19
+
20
+<script setup lang="ts">
21
+import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/vue';
22
+import ExploreContainer from '@/components/ExploreContainer.vue';
23
+</script>

+ 28 - 0
src/views/TabsPage.vue

@@ -0,0 +1,28 @@
1
+<template>
2
+  <ion-page>
3
+    <ion-tabs>
4
+      <ion-router-outlet></ion-router-outlet>
5
+      <ion-tab-bar slot="bottom">
6
+        <ion-tab-button tab="tab1" href="/tabs/tab1">
7
+          <ion-icon aria-hidden="true" :icon="triangle" />
8
+          <ion-label>Tab 1</ion-label>
9
+        </ion-tab-button>
10
+
11
+        <ion-tab-button tab="tab2" href="/tabs/tab2">
12
+          <ion-icon aria-hidden="true" :icon="ellipse" />
13
+          <ion-label>Tab 2</ion-label>
14
+        </ion-tab-button>
15
+
16
+        <ion-tab-button tab="tab3" href="/tabs/tab3">
17
+          <ion-icon aria-hidden="true" :icon="square" />
18
+          <ion-label>Tab 3</ion-label>
19
+        </ion-tab-button>
20
+      </ion-tab-bar>
21
+    </ion-tabs>
22
+  </ion-page>
23
+</template>
24
+
25
+<script setup lang="ts">
26
+import { IonTabBar, IonTabButton, IonTabs, IonLabel, IonIcon, IonPage, IonRouterOutlet } from '@ionic/vue';
27
+import { ellipse, square, triangle } from 'ionicons/icons';
28
+</script>

+ 1 - 0
src/vite-env.d.ts

@@ -0,0 +1 @@
1
+/// <reference types="vite/client" />

+ 5 - 0
tests/e2e/fixtures/example.json

@@ -0,0 +1,5 @@
1
+{
2
+  "name": "Using fixtures to represent data",
3
+  "email": "hello@cypress.io",
4
+  "body": "Fixtures are a great way to mock data for responses to routes"
5
+}

+ 6 - 0
tests/e2e/specs/test.cy.ts

@@ -0,0 +1,6 @@
1
+describe('My First Test', () => {
2
+  it('Visits the app root url', () => {
3
+    cy.visit('/')
4
+    cy.contains('ion-content', 'Tab 1 page')
5
+  })
6
+})

+ 37 - 0
tests/e2e/support/commands.ts

@@ -0,0 +1,37 @@
1
+/// <reference types="cypress" />
2
+// ***********************************************
3
+// This example commands.ts shows you how to
4
+// create various custom commands and overwrite
5
+// existing commands.
6
+//
7
+// For more comprehensive examples of custom
8
+// commands please read more here:
9
+// https://on.cypress.io/custom-commands
10
+// ***********************************************
11
+//
12
+//
13
+// -- This is a parent command --
14
+// Cypress.Commands.add('login', (email, password) => { ... })
15
+//
16
+//
17
+// -- This is a child command --
18
+// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19
+//
20
+//
21
+// -- This is a dual command --
22
+// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23
+//
24
+//
25
+// -- This will overwrite an existing command --
26
+// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27
+//
28
+// declare global {
29
+//   namespace Cypress {
30
+//     interface Chainable {
31
+//       login(email: string, password: string): Chainable<void>
32
+//       drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33
+//       dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34
+//       visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35
+//     }
36
+//   }
37
+// }

+ 20 - 0
tests/e2e/support/e2e.ts

@@ -0,0 +1,20 @@
1
+// ***********************************************************
2
+// This example support/e2e.ts is processed and
3
+// loaded automatically before your test files.
4
+//
5
+// This is a great place to put global configuration and
6
+// behavior that modifies Cypress.
7
+//
8
+// You can change the location of this file or turn off
9
+// automatically serving support files with the
10
+// 'supportFile' configuration option.
11
+//
12
+// You can read more here:
13
+// https://on.cypress.io/configuration
14
+// ***********************************************************
15
+
16
+// Import commands.js using ES2015 syntax:
17
+import './commands'
18
+
19
+// Alternatively you can use CommonJS syntax:
20
+// require('./commands')

+ 10 - 0
tests/unit/example.spec.ts

@@ -0,0 +1,10 @@
1
+import { mount } from '@vue/test-utils'
2
+import Tab1Page from '@/views/Tab1Page.vue'
3
+import { describe, expect, test } from 'vitest'
4
+
5
+describe('Tab1Page.vue', () => {
6
+  test('renders tab 1 Tab1Page', () => {
7
+    const wrapper = mount(Tab1Page)
8
+    expect(wrapper.text()).toMatch('Tab 1 page')
9
+  })
10
+})

+ 21 - 0
tsconfig.json

@@ -0,0 +1,21 @@
1
+{
2
+  "compilerOptions": {
3
+    "target": "ESNext",
4
+    "useDefineForClassFields": true,
5
+    "module": "ESNext",
6
+    "moduleResolution": "Node",
7
+    "strict": true,
8
+    "jsx": "preserve",
9
+    "resolveJsonModule": true,
10
+    "isolatedModules": true,
11
+    "esModuleInterop": true,
12
+    "lib": ["ESNext", "DOM"],
13
+    "skipLibCheck": true,
14
+    "noEmit": true,
15
+    "paths": {
16
+      "@/*": ["./src/*"]
17
+    }
18
+  },
19
+  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
20
+  "references": [{ "path": "./tsconfig.node.json" }]
21
+}

+ 9 - 0
tsconfig.node.json

@@ -0,0 +1,9 @@
1
+{
2
+  "compilerOptions": {
3
+    "composite": true,
4
+    "module": "ESNext",
5
+    "moduleResolution": "Node",
6
+    "allowSyntheticDefaultImports": true
7
+  },
8
+  "include": ["vite.config.ts"]
9
+}

+ 21 - 0
vite.config.ts

@@ -0,0 +1,21 @@
1
+import legacy from '@vitejs/plugin-legacy'
2
+import vue from '@vitejs/plugin-vue'
3
+import path from 'path'
4
+import { defineConfig } from 'vite'
5
+
6
+// https://vitejs.dev/config/
7
+export default defineConfig({
8
+  plugins: [
9
+    vue(),
10
+    legacy()
11
+  ],
12
+  resolve: {
13
+    alias: {
14
+      '@': path.resolve(__dirname, './src'),
15
+    },
16
+  },
17
+  test: {
18
+    globals: true,
19
+    environment: 'jsdom'
20
+  }
21
+})

tum/OBAppSrc - Gogs: Simplico Git Service

暂无描述

Utils.cs 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Win32;
  6. using System.IO.Ports;
  7. using System.Configuration;
  8. using System.Data.SqlClient;
  9. using System.Data.SqlServerCe;
  10. namespace WpfApplication19
  11. {
  12. class Utils
  13. {
  14. static public Dictionary<string, string> BuildPortNameHash(string[] portsToMap)
  15. {
  16. Dictionary<string, string> oReturnTable = new Dictionary<string, string>();
  17. MineRegistryForPortName("SYSTEM\\CurrentControlSet\\Enum", oReturnTable, portsToMap);
  18. return oReturnTable;
  19. }
  20. static void MineRegistryForPortName(string startKeyPath, Dictionary<string, string> targetMap,
  21. string[] portsToMap)
  22. {
  23. if (targetMap.Count >= portsToMap.Length)
  24. return;
  25. using (RegistryKey currentKey = Registry.LocalMachine)
  26. {
  27. try
  28. {
  29. using (RegistryKey currentSubKey = currentKey.OpenSubKey(startKeyPath))
  30. {
  31. string[] currentSubkeys = currentSubKey.GetSubKeyNames();
  32. if (currentSubkeys.Contains("Device Parameters") &&
  33. startKeyPath != "SYSTEM\\CurrentControlSet\\Enum")
  34. {
  35. object portName = Registry.GetValue("HKEY_LOCAL_MACHINE\\" +
  36. startKeyPath + "\\Device Parameters", "PortName", null);
  37. if (portName == null ||
  38. portsToMap.Contains(portName.ToString()) == false)
  39. return;
  40. object friendlyPortName = Registry.GetValue("HKEY_LOCAL_MACHINE\\" +
  41. startKeyPath, "FriendlyName", null);
  42. string friendlyName = "N/A";
  43. if (friendlyPortName != null)
  44. friendlyName = friendlyPortName.ToString();
  45. if (friendlyName.Contains(portName.ToString()) == false)
  46. friendlyName = string.Format("{0} ({1})", friendlyName, portName);
  47. targetMap[portName.ToString()] = friendlyName;
  48. }
  49. else
  50. {
  51. foreach (string strSubKey in currentSubkeys)
  52. MineRegistryForPortName(startKeyPath + "\\" + strSubKey, targetMap, portsToMap);
  53. }
  54. }
  55. }
  56. catch (Exception)
  57. {
  58. //Console.WriteLine("Error accessing key '{0}'.. Skipping..", startKeyPath);
  59. }
  60. }
  61. }
  62. public static void UpdateSetting(string key, string value)
  63. {
  64. Configuration oConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  65. if (oConfig.AppSettings.Settings[key] == null)
  66. {
  67. oConfig.AppSettings.Settings.Add(key, value);
  68. }
  69. else
  70. {
  71. oConfig.AppSettings.Settings[key].Value = value;
  72. }
  73. oConfig.Save(ConfigurationSaveMode.Modified);
  74. ConfigurationManager.RefreshSection("appSettings");
  75. }
  76. public static string getSetting(string key)
  77. {
  78. Configuration oConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  79. return oConfig.AppSettings.Settings[key].Value;
  80. }
  81. public static SqlConnection createSqlConnection(string configType)
  82. {
  83. SqlConnection sqlConn = new SqlConnection();
  84. string cs = Utils.getSetting(configType);
  85. sqlConn.ConnectionString = cs;
  86. sqlConn.Open();
  87. return sqlConn;
  88. }
  89. public static SqlCeConnection createSqlCeConnection(string configType)
  90. {
  91. SqlCeConnection sqlConn = new SqlCeConnection();
  92. string cs = Utils.getSetting(configType);
  93. sqlConn.ConnectionString = cs;
  94. sqlConn.Open();
  95. return sqlConn;
  96. }
  97. public static SqlDataReader Query(SqlConnection connection, string sql)
  98. {
  99. SqlCommand catCMD = connection.CreateCommand();
  100. catCMD.CommandText = sql;
  101. Console.WriteLine(sql);
  102. SqlDataReader reader = catCMD.ExecuteReader();
  103. return reader;
  104. }
  105. public static SqlCeDataReader Query(SqlCeConnection connection, string sql)
  106. {
  107. SqlCeCommand catCMD = connection.CreateCommand();
  108. catCMD.CommandText = sql;
  109. Console.WriteLine(sql);
  110. SqlCeDataReader reader = catCMD.ExecuteReader();
  111. return reader;
  112. }
  113. }
  114. }