コード例 #1
0
        public void                 setupByForm(IDataItem aDataItem, IConnection aConnection, IWin32Window aOwner)
        {
            DataItem   lItem       = (DataItem)aDataItem;
            Connection lConnection = (Connection)aConnection;
            bool       lModified   = false;

            using (var lSetupForm = new ItemSetupForm(lConnection, lItem))
            {
                do
                {
                    lSetupForm.ShowDialog(aOwner);
                    if (lSetupForm.DialogResult == DialogResult.OK)
                    {
                        try
                        {
                            lConnection.modifyItem(lItem, lSetupForm.Topic, lSetupForm.Subscribe, lSetupForm.Publish);
                            lModified = true;
                        }
                        catch (Exception lExc)
                        {
                            Log.Error("Error while user was configuring data item for MQQT broker '"
                                      + lConnection.mHost + ":" + lConnection.mPort + "'. " + lExc.Message, lExc.ToString());
                            MessageForm.showMessage(lExc.Message, aOwner);
                        }
                    }
                }while (lSetupForm.DialogResult == DialogResult.OK && lModified == false);
            }
        }
コード例 #2
0
        public IDataItem            createByForm(IConnection aConnection, IWin32Window aOwner)
        {
            Connection lConnection = (Connection)aConnection;
            DataItem   lItem       = new DataItem();
            bool       lCreated    = false;

            using (var lSetupForm = new ItemSetupForm(lConnection, lItem))
            {
                do
                {
                    try
                    {
                        lSetupForm.ShowDialog(aOwner);
                        if (lSetupForm.DialogResult == DialogResult.OK)
                        {
                            lItem    = lConnection.addItem(lSetupForm.Topic, lSetupForm.Subscribe, lSetupForm.Publish, "");
                            lCreated = true;
                        }
                        else
                        {
                            lItem = null;
                        }
                    }
                    catch (Exception lExc)
                    {
                        Log.Error("Error while user was creating new data item for MQQT broker '"
                                  + lConnection.mHost + ":" + lConnection.mPort + "'. " + lExc.Message, lExc.ToString());
                        MessageForm.showMessage(lExc.Message, aOwner);
                    }
                }while (lSetupForm.DialogResult == DialogResult.OK && lCreated == false);
            }

            return(lItem);
        }