Example #1
0
        public bool CheckInputs()
        {
            MarkConnectionStateDelegate mcsd = new MarkConnectionStateDelegate(MarkConnectionState);

            foreach (PortData pd in InPortData)
            {
                //if the port data's object is null
                //or the port data's object type can not be matched
                if (pd.Object == null)  //|| pd.Object.GetType() != pd.PortType)
                {
                    Dispatcher.Invoke(mcsd, System.Windows.Threading.DispatcherPriority.Background,
                                      new object[] { true });

                    SetToolTipDelegate sttd = new SetToolTipDelegate(SetTooltip);
                    Dispatcher.Invoke(sttd, System.Windows.Threading.DispatcherPriority.Background,
                                      new object[] { "One or more connections is null." });

                    return(false);
                }
            }


            Dispatcher.Invoke(mcsd, System.Windows.Threading.DispatcherPriority.Background,
                              new object[] { false });

            return(true);
        }
Example #2
0
        public bool CheckInputs()
        {
            var mcsd = new MarkConnectionStateDelegate(MarkConnectionState);

            foreach (PortData pd in InPortData)
            {
                //if the port data's object is null
                //or the port data's object type can not be matched
                Dispatcher.Invoke(
                   mcsd,
                   System.Windows.Threading.DispatcherPriority.Background,
                   new object[] { true }
                );

                SetToolTipDelegate sttd = new SetToolTipDelegate(SetTooltip);
                Dispatcher.Invoke(
                   sttd, System.Windows.Threading.DispatcherPriority.Background,
                   new object[] { "One or more connections is null." }
                );

                return false;
            }

            Dispatcher.Invoke(mcsd, System.Windows.Threading.DispatcherPriority.Background,
               new object[] { false });

            return true;
        }
Example #3
0
        /// <summary>
        /// The build method is called back from the child class.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Build(object sender, EventArgs e)
        {
            dynElement el = sender as dynElement;

            bool useTransaction = true;

            object[] attribs = el.GetType().GetCustomAttributes(typeof(RequiresTransactionAttribute), false);
            if (attribs.Length > 0)
            {
                if ((attribs[0] as RequiresTransactionAttribute).RequiresTransaction == false)
                {
                    useTransaction = false;
                }
            }

            #region using transaction
            if (useTransaction)
            {
                Transaction t = new Transaction(dynElementSettings.SharedInstance.Doc.Document, el.GetType().ToString() + " update.");
                TransactionStatus ts = t.Start();

                try
                {
                    FailureHandlingOptions failOpt = t.GetFailureHandlingOptions();
                    failOpt.SetFailuresPreprocessor(dynElementSettings.SharedInstance.WarningSwallower);
                    t.SetFailureHandlingOptions(failOpt);

                    el.Destroy();
                    el.Draw();

                    UpdateLayoutDelegate uld = new UpdateLayoutDelegate(CallUpdateLayout);
                    Dispatcher.Invoke(uld, System.Windows.Threading.DispatcherPriority.Background, new object[] { el });

                    elementsHaveBeenDeleted = false;

                    ts = t.Commit();

                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message + " : " + ex.StackTrace);
                    dynElementSettings.SharedInstance.Bench.Log(ex.Message);

                    SetToolTipDelegate sttd = new SetToolTipDelegate(SetTooltip);
                    Dispatcher.Invoke(sttd, System.Windows.Threading.DispatcherPriority.Background,
                        new object[] { ex.Message});

                    MarkConnectionStateDelegate mcsd = new MarkConnectionStateDelegate(MarkConnectionState);
                    Dispatcher.Invoke(mcsd, System.Windows.Threading.DispatcherPriority.Background,
                        new object[] { true });

                    if (ts == TransactionStatus.Committed)
                    {
                        t.RollBack();
                    }

                    t.Dispose();

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }

                try
                {
                    el.UpdateOutputs();
                }
                catch(Exception ex)
                {

                    //Debug.WriteLine("Outputs could not be updated.");
                    dynElementSettings.SharedInstance.Bench.Log("Outputs could not be updated.");
                    if (ts == TransactionStatus.Committed)
                    {
                        t.RollBack();
                    }

                    t.Dispose();

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }
            }
            #endregion

            #region no transaction
            if (!useTransaction)
            {
                try
                {

                    el.Destroy();

                    el.Draw();

                    UpdateLayoutDelegate uld = new UpdateLayoutDelegate(CallUpdateLayout);
                    Dispatcher.Invoke(uld, System.Windows.Threading.DispatcherPriority.Background, new object[] { el });

                    elementsHaveBeenDeleted = false;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message + " : " + ex.StackTrace);
                    dynElementSettings.SharedInstance.Bench.Log(ex.Message);

                    SetToolTipDelegate sttd = new SetToolTipDelegate(SetTooltip);
                    Dispatcher.Invoke(sttd, System.Windows.Threading.DispatcherPriority.Background,
                        new object[] { ex.Message });

                    MarkConnectionState(true);

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);

                }

                try
                {
                    el.UpdateOutputs();
                }
                catch(Exception ex)
                {

                    //Debug.WriteLine("Outputs could not be updated.");
                    dynElementSettings.SharedInstance.Bench.Log("Outputs could not be updated.");

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }
            }
            #endregion
        }
Example #4
0
        /// <summary>
        /// The build method is called back from the child class.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Build(object sender, EventArgs e)
        {
            dynElement el = sender as dynElement;

            bool useTransaction = true;

            object[] attribs = el.GetType().GetCustomAttributes(typeof(RequiresTransactionAttribute), false);
            if (attribs.Length > 0)
            {
                if ((attribs[0] as RequiresTransactionAttribute).RequiresTransaction == false)
                {
                    useTransaction = false;
                }
            }

            #region using transaction
            if (useTransaction)
            {
                Transaction       t  = new Transaction(dynElementSettings.SharedInstance.Doc.Document, el.GetType().ToString() + " update.");
                TransactionStatus ts = t.Start();

                try
                {
                    FailureHandlingOptions failOpt = t.GetFailureHandlingOptions();
                    failOpt.SetFailuresPreprocessor(dynElementSettings.SharedInstance.WarningSwallower);
                    t.SetFailureHandlingOptions(failOpt);

                    el.Destroy();
                    el.Draw();

                    UpdateLayoutDelegate uld = new UpdateLayoutDelegate(CallUpdateLayout);
                    Dispatcher.Invoke(uld, System.Windows.Threading.DispatcherPriority.Background, new object[] { el });

                    elementsHaveBeenDeleted = false;

                    ts = t.Commit();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message + " : " + ex.StackTrace);
                    dynElementSettings.SharedInstance.Bench.Log(ex.Message);

                    SetToolTipDelegate sttd = new SetToolTipDelegate(SetTooltip);
                    Dispatcher.Invoke(sttd, System.Windows.Threading.DispatcherPriority.Background,
                                      new object[] { ex.Message });

                    MarkConnectionStateDelegate mcsd = new MarkConnectionStateDelegate(MarkConnectionState);
                    Dispatcher.Invoke(mcsd, System.Windows.Threading.DispatcherPriority.Background,
                                      new object[] { true });

                    if (ts == TransactionStatus.Committed)
                    {
                        t.RollBack();
                    }

                    t.Dispose();

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }

                try
                {
                    el.UpdateOutputs();
                }
                catch (Exception ex)
                {
                    //Debug.WriteLine("Outputs could not be updated.");
                    dynElementSettings.SharedInstance.Bench.Log("Outputs could not be updated.");
                    if (ts == TransactionStatus.Committed)
                    {
                        t.RollBack();
                    }

                    t.Dispose();

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }
            }
            #endregion

            #region no transaction
            if (!useTransaction)
            {
                try
                {
                    el.Destroy();

                    el.Draw();

                    UpdateLayoutDelegate uld = new UpdateLayoutDelegate(CallUpdateLayout);
                    Dispatcher.Invoke(uld, System.Windows.Threading.DispatcherPriority.Background, new object[] { el });

                    elementsHaveBeenDeleted = false;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message + " : " + ex.StackTrace);
                    dynElementSettings.SharedInstance.Bench.Log(ex.Message);

                    SetToolTipDelegate sttd = new SetToolTipDelegate(SetTooltip);
                    Dispatcher.Invoke(sttd, System.Windows.Threading.DispatcherPriority.Background,
                                      new object[] { ex.Message });

                    MarkConnectionState(true);

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }

                try
                {
                    el.UpdateOutputs();
                }
                catch (Exception ex)
                {
                    //Debug.WriteLine("Outputs could not be updated.");
                    dynElementSettings.SharedInstance.Bench.Log("Outputs could not be updated.");

                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.Message);
                    dynElementSettings.SharedInstance.Writer.WriteLine(ex.StackTrace);
                }
            }
            #endregion
        }