Exemplo n.º 1
0
        private void CompletionMethod(
            string status,
            Exception exception,
            bool canceled,
            AsyncOperation asyncOp)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!canceled)
            {
                lock (userStateToLifetime.SyncRoot)
                {
                    userStateToLifetime.Remove(asyncOp.UserSuppliedState);
                }
            }

            // Output SendFileCompletedEventArgs
            WriteBackCompletedEventArgs e =
                new WriteBackCompletedEventArgs(status,
                                                exception,
                                                canceled,
                                                asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible
            // for marshaling the call.
            asyncOp.PostOperationCompleted(onWriteBackCompleted, e);
        }
Exemplo n.º 2
0
        private void WriteBackCompleted(object state)
        {
            WriteBackCompletedEventArgs e =
                state as WriteBackCompletedEventArgs;

            OnWriteBackCompleted(e);
        }
Exemplo n.º 3
0
        private void WritebackClass_WriteBackProcessCompleted(object sender, WriteBackCompletedEventArgs e)
        {
            IGTApplication app = GTClassFactory.Create <IGTApplication>();

            // Shared component should return either SUCCESS or FAILURE in the event argument (Status).
            // Notify the user via the status bar and configure the dialog box (if no errors).
            // If errors, dismiss the dialog box and display a message box containing the errors.

            switch (e.Status.ToUpper())
            {
            case "SUCCESS":
                app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Writeback complete.");

                // If the ConfirmComplete dialog has not been unloaded, then set its properties.
                if (null != cc)
                {
                    string sMessage = "Writeback complete.";
                    cc.Size       = TextRenderer.MeasureText(sMessage, new System.Drawing.Font("Arial", 10));
                    cc.statusText = sMessage;
                    cc.enableOK   = true;
                }

                break;

            case "TIMEOUT":

                app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Timeout waiting on Writeback Status.");
                DataAccess oDataAccess      = new DataAccess(m_oApp);
                int        iPollingInterval = Convert.ToInt32(oDataAccess.GetEFUrl("WMIS_WritebackPollingInterval", "WMIS"));

                if (null != cc)
                {
                    // Event Handler for FormClosed already disposes so no need to do that here.
                    string sMessage = "Write back timed out; No response received after " + iPollingInterval + " seconds.";
                    cc.Size       = TextRenderer.MeasureText(sMessage, new System.Drawing.Font("Arial", 10));
                    cc.statusText = sMessage;
                    cc.enableOK   = true;
                }

                // Timeouts will always have an event argument and message.

                break;

            case "FAILURE":
                app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Writeback failed.");

                if (null != e.Error && !string.IsNullOrEmpty(e.Error.Message))
                {
                    string sMessage = string.Format("Writeback failed: {0}.", e.Error.Message);
                    if (e.Error.Message.ToString().StartsWith("Writeback did not return a SUCCESS status for this job"))
                    {
                        sMessage = string.Format("Failed to request write back: {0}.", e.Error.Message);
                    }
                    cc.Size       = TextRenderer.MeasureText(sMessage, new System.Drawing.Font("Arial", 10));
                    cc.statusText = sMessage;
                    cc.enableOK   = true;

                    // MessageBox.Show(string.Format("Writeback failed: {0}.", e.Error.Message), "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string sMessage = "Writeback failed.  No additional information is available.";
                    cc.Size       = TextRenderer.MeasureText(sMessage, new System.Drawing.Font("Arial", 10));
                    cc.statusText = sMessage;
                    cc.enableOK   = true;

                    // MessageBox.Show("Writeback failed.  No additional information is available.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                break;

            default:
                // This should NEVER occur but covering it just in case...
                app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Error in writeback procedure.");

                //if (null != cc)
                //{
                //    // Event Handler for FormClosed already disposes so no need to do that here.
                //    cc.Close();
                //}

                // Assume e.Error.Message is not reliably set in this case so not displaying it.
                string msg = string.Format("{0}{1}{2}{3}", "Writeback procedure returned an unexpected status value: ", e.Status, Environment.NewLine, "Status of writeback is unknown.");
                cc.Size       = TextRenderer.MeasureText(msg, new System.Drawing.Font("Arial", 10));
                cc.statusText = msg;
                cc.enableOK   = true;
                // MessageBox.Show(msg, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
        }
Exemplo n.º 4
0
 protected void OnWriteBackCompleted(
     WriteBackCompletedEventArgs e)
 {
     WriteBackProcessCompleted?.Invoke(this, e);
 }