1 | using System;
|
---|
2 | using System.Drawing;
|
---|
3 | using System.Collections;
|
---|
4 | using System.ComponentModel;
|
---|
5 | using System.Windows.Forms;
|
---|
6 | using System.Data;
|
---|
7 | using IndianHealthService.BMXNet;
|
---|
8 | using System.Threading;
|
---|
9 | using System.Net;
|
---|
10 | using System.Net.Sockets;
|
---|
11 | using System.Diagnostics;
|
---|
12 |
|
---|
13 | namespace IndianHealthService.ClinicalScheduling
|
---|
14 | {
|
---|
15 | /// <summary>
|
---|
16 | /// Summary description for DCopyAppts.
|
---|
17 | /// </summary>
|
---|
18 | public class DCopyAppts : System.Windows.Forms.Form
|
---|
19 | {
|
---|
20 | private System.Windows.Forms.Button cmdCancel;
|
---|
21 | private System.Windows.Forms.Button cmdOK;
|
---|
22 | private System.Windows.Forms.Panel pnlOKCancel;
|
---|
23 | private System.Windows.Forms.Panel pnlDescription;
|
---|
24 | private System.Windows.Forms.GroupBox grpDescription;
|
---|
25 | private System.Windows.Forms.Label lblDescription;
|
---|
26 | private System.Windows.Forms.Label lblSummary;
|
---|
27 | private System.Windows.Forms.Label lblProgress;
|
---|
28 | private System.ComponentModel.IContainer components;
|
---|
29 |
|
---|
30 | #region Fields
|
---|
31 | private DateTime m_dtBegin;
|
---|
32 | private DateTime m_dtEnd;
|
---|
33 | private string m_HospLocationID;
|
---|
34 | private string m_HospLocationName;
|
---|
35 | private string m_ResourceID;
|
---|
36 | private string m_ResourceName;
|
---|
37 | private string m_sTask;
|
---|
38 | private CGDocumentManager m_DocManager;
|
---|
39 |
|
---|
40 | private System.Windows.Forms.Timer timerPoll;
|
---|
41 | private System.Windows.Forms.Label label1;
|
---|
42 | private System.Windows.Forms.Label label2;
|
---|
43 |
|
---|
44 | //protected delegate void UpdateDisplayDelegate(string sText);
|
---|
45 | //protected delegate void RegisterEventDelegate(string sPort, string sEvent);
|
---|
46 |
|
---|
47 | #endregion Fields
|
---|
48 |
|
---|
49 | public DCopyAppts()
|
---|
50 | {
|
---|
51 | InitializeComponent();
|
---|
52 | }
|
---|
53 |
|
---|
54 | /// <summary>
|
---|
55 | /// Clean up any resources being used.
|
---|
56 | /// </summary>
|
---|
57 | protected override void Dispose( bool disposing )
|
---|
58 | {
|
---|
59 | if( disposing )
|
---|
60 | {
|
---|
61 | if(components != null)
|
---|
62 | {
|
---|
63 | components.Dispose();
|
---|
64 | }
|
---|
65 | }
|
---|
66 | base.Dispose( disposing );
|
---|
67 | }
|
---|
68 |
|
---|
69 | #region Windows Form Designer generated code
|
---|
70 | /// <summary>
|
---|
71 | /// Required method for Designer support - do not modify
|
---|
72 | /// the contents of this method with the code editor.
|
---|
73 | /// </summary>
|
---|
74 | private void InitializeComponent()
|
---|
75 | {
|
---|
76 | this.components = new System.ComponentModel.Container();
|
---|
77 | this.pnlOKCancel = new System.Windows.Forms.Panel();
|
---|
78 | this.cmdCancel = new System.Windows.Forms.Button();
|
---|
79 | this.cmdOK = new System.Windows.Forms.Button();
|
---|
80 | this.pnlDescription = new System.Windows.Forms.Panel();
|
---|
81 | this.grpDescription = new System.Windows.Forms.GroupBox();
|
---|
82 | this.lblDescription = new System.Windows.Forms.Label();
|
---|
83 | this.lblSummary = new System.Windows.Forms.Label();
|
---|
84 | this.lblProgress = new System.Windows.Forms.Label();
|
---|
85 | this.timerPoll = new System.Windows.Forms.Timer(this.components);
|
---|
86 | this.label1 = new System.Windows.Forms.Label();
|
---|
87 | this.label2 = new System.Windows.Forms.Label();
|
---|
88 | this.pnlOKCancel.SuspendLayout();
|
---|
89 | this.pnlDescription.SuspendLayout();
|
---|
90 | this.grpDescription.SuspendLayout();
|
---|
91 | this.SuspendLayout();
|
---|
92 | //
|
---|
93 | // pnlOKCancel
|
---|
94 | //
|
---|
95 | this.pnlOKCancel.Controls.Add(this.cmdCancel);
|
---|
96 | this.pnlOKCancel.Controls.Add(this.cmdOK);
|
---|
97 | this.pnlOKCancel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
---|
98 | this.pnlOKCancel.Location = new System.Drawing.Point(0, 286);
|
---|
99 | this.pnlOKCancel.Name = "pnlOKCancel";
|
---|
100 | this.pnlOKCancel.Size = new System.Drawing.Size(376, 40);
|
---|
101 | this.pnlOKCancel.TabIndex = 4;
|
---|
102 | //
|
---|
103 | // cmdCancel
|
---|
104 | //
|
---|
105 | this.cmdCancel.Location = new System.Drawing.Point(288, 8);
|
---|
106 | this.cmdCancel.Name = "cmdCancel";
|
---|
107 | this.cmdCancel.Size = new System.Drawing.Size(64, 24);
|
---|
108 | this.cmdCancel.TabIndex = 1;
|
---|
109 | this.cmdCancel.Text = "Cancel";
|
---|
110 | this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
|
---|
111 | //
|
---|
112 | // cmdOK
|
---|
113 | //
|
---|
114 | this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
---|
115 | this.cmdOK.Location = new System.Drawing.Point(208, 8);
|
---|
116 | this.cmdOK.Name = "cmdOK";
|
---|
117 | this.cmdOK.Size = new System.Drawing.Size(64, 24);
|
---|
118 | this.cmdOK.TabIndex = 0;
|
---|
119 | this.cmdOK.Text = "OK";
|
---|
120 | //
|
---|
121 | // pnlDescription
|
---|
122 | //
|
---|
123 | this.pnlDescription.Controls.Add(this.grpDescription);
|
---|
124 | this.pnlDescription.Dock = System.Windows.Forms.DockStyle.Bottom;
|
---|
125 | this.pnlDescription.Location = new System.Drawing.Point(0, 222);
|
---|
126 | this.pnlDescription.Name = "pnlDescription";
|
---|
127 | this.pnlDescription.Size = new System.Drawing.Size(376, 64);
|
---|
128 | this.pnlDescription.TabIndex = 47;
|
---|
129 | //
|
---|
130 | // grpDescription
|
---|
131 | //
|
---|
132 | this.grpDescription.Controls.Add(this.lblDescription);
|
---|
133 | this.grpDescription.Dock = System.Windows.Forms.DockStyle.Fill;
|
---|
134 | this.grpDescription.Location = new System.Drawing.Point(0, 0);
|
---|
135 | this.grpDescription.Name = "grpDescription";
|
---|
136 | this.grpDescription.Size = new System.Drawing.Size(376, 64);
|
---|
137 | this.grpDescription.TabIndex = 0;
|
---|
138 | this.grpDescription.TabStop = false;
|
---|
139 | this.grpDescription.Text = "Description";
|
---|
140 | //
|
---|
141 | // lblDescription
|
---|
142 | //
|
---|
143 | this.lblDescription.Dock = System.Windows.Forms.DockStyle.Fill;
|
---|
144 | this.lblDescription.Location = new System.Drawing.Point(3, 16);
|
---|
145 | this.lblDescription.Name = "lblDescription";
|
---|
146 | this.lblDescription.Size = new System.Drawing.Size(370, 45);
|
---|
147 | this.lblDescription.TabIndex = 1;
|
---|
148 | this.lblDescription.Text = "This panel displays the progress of the appointment copy process. Press the \'Can" +
|
---|
149 | "cel\' button to stop copying appointments.";
|
---|
150 | //
|
---|
151 | // lblSummary
|
---|
152 | //
|
---|
153 | this.lblSummary.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
---|
154 | this.lblSummary.Location = new System.Drawing.Point(32, 32);
|
---|
155 | this.lblSummary.Name = "lblSummary";
|
---|
156 | this.lblSummary.Size = new System.Drawing.Size(312, 64);
|
---|
157 | this.lblSummary.TabIndex = 48;
|
---|
158 | this.lblSummary.Text = "lblSummary";
|
---|
159 | //
|
---|
160 | // lblProgress
|
---|
161 | //
|
---|
162 | this.lblProgress.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
---|
163 | this.lblProgress.Location = new System.Drawing.Point(32, 128);
|
---|
164 | this.lblProgress.Name = "lblProgress";
|
---|
165 | this.lblProgress.Size = new System.Drawing.Size(312, 72);
|
---|
166 | this.lblProgress.TabIndex = 49;
|
---|
167 | this.lblProgress.Text = "lblProgress";
|
---|
168 | //
|
---|
169 | // timerPoll
|
---|
170 | //
|
---|
171 | this.timerPoll.Tick += new System.EventHandler(this.timerPoll_Tick);
|
---|
172 | //
|
---|
173 | // label1
|
---|
174 | //
|
---|
175 | this.label1.Location = new System.Drawing.Point(32, 112);
|
---|
176 | this.label1.Name = "label1";
|
---|
177 | this.label1.Size = new System.Drawing.Size(144, 16);
|
---|
178 | this.label1.TabIndex = 50;
|
---|
179 | this.label1.Text = "Status:";
|
---|
180 | //
|
---|
181 | // label2
|
---|
182 | //
|
---|
183 | this.label2.Location = new System.Drawing.Point(32, 16);
|
---|
184 | this.label2.Name = "label2";
|
---|
185 | this.label2.Size = new System.Drawing.Size(144, 16);
|
---|
186 | this.label2.TabIndex = 51;
|
---|
187 | this.label2.Text = "Job Summary:";
|
---|
188 | //
|
---|
189 | // DCopyAppts
|
---|
190 | //
|
---|
191 | this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
---|
192 | this.ClientSize = new System.Drawing.Size(376, 326);
|
---|
193 | this.Controls.Add(this.label2);
|
---|
194 | this.Controls.Add(this.label1);
|
---|
195 | this.Controls.Add(this.lblProgress);
|
---|
196 | this.Controls.Add(this.lblSummary);
|
---|
197 | this.Controls.Add(this.pnlDescription);
|
---|
198 | this.Controls.Add(this.pnlOKCancel);
|
---|
199 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
---|
200 | this.MaximizeBox = false;
|
---|
201 | this.Name = "DCopyAppts";
|
---|
202 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
---|
203 | this.Text = "Copy Appointments";
|
---|
204 | this.Closing += new System.ComponentModel.CancelEventHandler(this.DCopyAppts_Closing);
|
---|
205 | this.Load += new System.EventHandler(this.DCopyAppts_Load);
|
---|
206 | this.pnlOKCancel.ResumeLayout(false);
|
---|
207 | this.pnlDescription.ResumeLayout(false);
|
---|
208 | this.grpDescription.ResumeLayout(false);
|
---|
209 | this.ResumeLayout(false);
|
---|
210 |
|
---|
211 | }
|
---|
212 | #endregion
|
---|
213 |
|
---|
214 | #region Methods and Handlers
|
---|
215 |
|
---|
216 | public void InitializePage(DateTime StartDate, DateTime EndDate,
|
---|
217 | string HospLocationID, string HospLocationName,
|
---|
218 | string ResourceID, string ResourceName,
|
---|
219 | CGDocumentManager DocManager)
|
---|
220 | {
|
---|
221 | string sMsg = "Copying appointments from " + HospLocationName + " to " + ResourceName + ", ";
|
---|
222 | sMsg += "beginning with apppointments on " + StartDate.ToLongDateString();
|
---|
223 | sMsg += " and going through " + EndDate.ToLongDateString() + ".";
|
---|
224 | lblSummary.Text = sMsg;
|
---|
225 | m_dtBegin = StartDate;
|
---|
226 | m_dtEnd = EndDate;
|
---|
227 | m_HospLocationID = HospLocationID;
|
---|
228 | m_HospLocationName = HospLocationName;
|
---|
229 | m_ResourceID = ResourceID;
|
---|
230 | m_ResourceName = ResourceName;
|
---|
231 | m_DocManager = DocManager;
|
---|
232 | }
|
---|
233 |
|
---|
234 | private void DCopyAppts_Load(object sender, System.EventArgs e)
|
---|
235 | {
|
---|
236 | try
|
---|
237 | {
|
---|
238 | //Start M copy job and get the ZTSK number
|
---|
239 | this.timerPoll.Stop();
|
---|
240 | lblProgress.Text = "Starting Process";
|
---|
241 |
|
---|
242 | string sSql = "BSDX COPY APPOINTMENTS^" + m_ResourceID + "^" + m_HospLocationID + "^" + m_dtBegin.ToShortDateString() + "^" + m_dtEnd.ToShortDateString();
|
---|
243 | DataTable dt = m_DocManager.RPMSDataTable(sSql, "ApptCopy");
|
---|
244 | Debug.Assert(dt.Rows.Count == 1);
|
---|
245 |
|
---|
246 |
|
---|
247 | DataRow dr = dt.Rows[0];
|
---|
248 | m_sTask = "0";
|
---|
249 | Object oTask = dr["TASK_NUMBER"];
|
---|
250 | m_sTask = oTask.ToString();
|
---|
251 |
|
---|
252 | Object oError = dr["ERRORID"];
|
---|
253 | string sError = oError.ToString();
|
---|
254 | if (sError != "OK")
|
---|
255 | {
|
---|
256 | timerPoll.Stop();
|
---|
257 | lblProgress.Text = sError;
|
---|
258 | cmdOK.Enabled = true;
|
---|
259 | cmdCancel.Enabled = false;
|
---|
260 | }
|
---|
261 | else
|
---|
262 | {
|
---|
263 | lblProgress.Text = "RPMS Job queued as Task #" + m_sTask;
|
---|
264 | ;//this.timerPoll.Start();
|
---|
265 | cmdOK.Enabled = false;
|
---|
266 | cmdCancel.Enabled = true;
|
---|
267 | }
|
---|
268 |
|
---|
269 | }
|
---|
270 | catch (Exception Ex)
|
---|
271 | {
|
---|
272 | MessageBox.Show(Ex.Message);
|
---|
273 | }
|
---|
274 |
|
---|
275 | }
|
---|
276 |
|
---|
277 | private void cmdCancel_Click(object sender, System.EventArgs e)
|
---|
278 | {
|
---|
279 | try
|
---|
280 | {
|
---|
281 | //Check status and update progress control
|
---|
282 | string sSql = "BSDX COPY APPOINTMENT CANCEL^" + m_sTask;
|
---|
283 | DataTable dt = m_DocManager.RPMSDataTable(sSql, "ApptCopyCancel");
|
---|
284 | Debug.Assert(dt.Rows.Count == 1);
|
---|
285 | DataRow dr = dt.Rows[0];
|
---|
286 | Object oCount = dr["RECORD_COUNT"];
|
---|
287 | string sCount = oCount.ToString();
|
---|
288 |
|
---|
289 | lblProgress.Text = "Cancelling job...";
|
---|
290 | }
|
---|
291 | catch (Exception Ex)
|
---|
292 | {
|
---|
293 | MessageBox.Show(Ex.Message);
|
---|
294 | }
|
---|
295 | }
|
---|
296 |
|
---|
297 | private void DCopyAppts_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
---|
298 | {
|
---|
299 |
|
---|
300 | }
|
---|
301 |
|
---|
302 | private void timerPoll_Tick(object sender, System.EventArgs e)
|
---|
303 | {
|
---|
304 | try
|
---|
305 | {
|
---|
306 | return;
|
---|
307 | //Check status and update progress control
|
---|
308 | //string sSql = "BSDX COPY APPOINTMENT STATUS^" + m_sTask;
|
---|
309 | //DataTable dt = m_DocManager.RPMSDataTable(sSql, "ApptCopyStatus");
|
---|
310 | //Debug.Assert(dt.Rows.Count == 1);
|
---|
311 | //DataRow dr = dt.Rows[0];
|
---|
312 | //Object oCount = dr["RECORD_COUNT"];
|
---|
313 | //string sCount = oCount.ToString();
|
---|
314 | //Object oError = dr["ERRORID"];
|
---|
315 | //string sError = oError.ToString();
|
---|
316 | //if (sError != "OK")
|
---|
317 | //{
|
---|
318 | // timerPoll.Stop();
|
---|
319 | // lblProgress.Text = sError;
|
---|
320 | //}
|
---|
321 | //else if ((sCount.StartsWith("Finished"))||(sCount.StartsWith("Cancelled")))
|
---|
322 | //{
|
---|
323 | // timerPoll.Stop();
|
---|
324 | // lblProgress.Text = sCount;
|
---|
325 | // cmdOK.Enabled = true;
|
---|
326 | // cmdCancel.Enabled = false;
|
---|
327 | //}
|
---|
328 | //else
|
---|
329 | //{
|
---|
330 | // lblProgress.Text = "RPMS Job queued as Task #" + m_sTask + ". " + sCount; // + " records copied so far.";
|
---|
331 | //}
|
---|
332 | }
|
---|
333 | catch (Exception Ex)
|
---|
334 | {
|
---|
335 | MessageBox.Show(Ex.Message);
|
---|
336 | }
|
---|
337 | }
|
---|
338 |
|
---|
339 | #endregion Methods and Handlers
|
---|
340 | }
|
---|
341 | }
|
---|