//create constructor
 public SupplierUserControl(Supplier supplier, SimulationModel model, ConnectionCreator creator)
 {
     InitializeComponent();
     this.SupplierModel     = supplier;
     this.SimulationModel   = model;
     this.ConnectionCreator = creator;
 }
Beispiel #2
0
 //create constructor
 public ShopUserControl(Shop shop, SimulationModel model, ConnectionCreator creator)
 {
     InitializeComponent();
     this.SimulationModel   = model;
     this.ShopModel         = shop;
     this.ConnectionCreator = creator;
 }
 //create constructor
 public BuyerUserControl(Buyer buyer, SimulationModel model, ConnectionCreator creator)
 {
     InitializeComponent();
     this.BuyerModel        = buyer;
     this.SimulationModel   = model;
     this.ConnectionCreator = creator;
 }
 public ConnectionUI(SimulationModel model, Canvas target, Connection connection, ConnectionCreator connCreator)
 {
     Line = new Line();
     this.SimulationModel   = model;
     this.Target            = target;
     this.Connection        = connection;
     this.ConnectionCreator = connCreator;
 }
 //copy constructor
 public SupplierUserControl(SupplierUserControl supplier, SimulationModel model, ConnectionCreator creator)
 {
     InitializeComponent();
     this.supplierUI.Height = supplier.supplierUI.Height;
     this.supplierUI.Width  = supplier.supplierUI.Height;
     this.SupplierModel     = new Supplier(supplier.SupplierModel);
     this.SimulationModel   = model;
     this.ConnectionCreator = creator;
 }
 //copy constructor
 public BuyerUserControl(BuyerUserControl buyer, SimulationModel model, ConnectionCreator creator)
 {
     InitializeComponent();
     this.buyerUI.Height    = buyer.buyerUI.Height;
     this.buyerUI.Width     = buyer.buyerUI.Height;
     this.SimulationModel   = model;
     this.BuyerModel        = new Buyer(buyer.BuyerModel);
     this.ConnectionCreator = creator;
 }
Beispiel #7
0
 //copy constructor
 public ShopUserControl(ShopUserControl shop, SimulationModel model, ConnectionCreator creator)
 {
     InitializeComponent();
     this.shopUI.Height     = shop.shopUI.Height;
     this.shopUI.Width      = shop.shopUI.Height;
     this.ShopModel         = new Shop(shop.ShopModel);
     this.SimulationModel   = model;
     this.ConnectionCreator = creator;
 }
            public WhenCreatingAnOpenedConnectionWithAnInvalidPort()
            {
                _connectionFactory = new Mock <IConnectionFactory>();
                _connection        = new Mock <IOpenableConnection>();
                _connectionFactory
                .Setup(cf => cf.Create(It.IsAny <IPEndPoint>()))
                .Returns(_connection.Object);

                _connectionOpener = new ConnectionCreator(_connectionFactory.Object);
            }
        public void WritesPromptToConsoleForUserInput()
        {
            var console = Substitute.For <IConsole>();

            console.ReadLine().Returns("");
            var connectionCreator = new ConnectionCreator(console);

            connectionCreator.CreateClient();
            console.Received(1).WriteToBuffer(Arg.Any <string>());
        }
Beispiel #10
0
        public static void Boot(ConnectionCreator creator)
        {
            CreateConnection = creator;
            _Configured      = true;

            System.Timers.Timer t = new System.Timers.Timer();
            t.Interval  = 100;
            t.AutoReset = true;
            t.Elapsed  += new ElapsedEventHandler(t_Elapsed);
            t.Start();
        }
Beispiel #11
0
        public static void Boot(ConnectionCreator creator)
        {
            CreateConnection = creator;
            _Configured = true;

            System.Timers.Timer t = new System.Timers.Timer();
            t.Interval = 100;
            t.AutoReset = true;
            t.Elapsed += new ElapsedEventHandler(t_Elapsed);
            t.Start();
        }
            public WhenCreatingAnOpenedConnectionWithAHostName()
            {
                _connectionFactory = new Mock <IConnectionFactory>();
                _connection        = new Mock <IOpenableConnection>();
                _connectionFactory
                .Setup(cf => cf.Create(It.IsAny <IPEndPoint>()))
                .Returns(_connection.Object);

                _connectionOpener = new ConnectionCreator(_connectionFactory.Object);

                _connectionOpener.CreateOpenedAsync("localhost", 1234, CancellationToken.None).Wait();
            }
        public void CreatesClientWithCorrectRemoteAddress()
        {
            var address = "http://74.125.224.72:105";

            var console = Substitute.For <IConsole>();

            console.ReadLine().Returns(address);
            var connectionCreator = new ConnectionCreator(console);

            var client = connectionCreator.CreateClient();

            Assert.AreEqual(address, client.BaseUrl);
        }
        public void CreatesClientWithCorrectLocalhostAddress()
        {
            var address = "http://127.0.0.1:5823";

            var console = Substitute.For <IConsole>();

            console.ReadLine().Returns(address);
            var connectionCreator = new ConnectionCreator(console);

            var client = connectionCreator.CreateClient();

            Assert.AreEqual(address, client.BaseUrl);
        }
Beispiel #15
0
        public MainWindow()
        {
            InitializeComponent();
            LogUtils.ConfigureLog4NetForPluginMode(false);

            _tfsVersion         = Helpers.GetInstalledTfsVersion();
            lbl_Version.Content = $"ver {Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}";
            switch (_tfsVersion)
            {
            case TfsVersion.Tfs2015:
                Set2015FieldsVisibility(Visibility.Visible);
                break;

            case TfsVersion.Tfs2017:
                Set2017FieldsVisibility(Visibility.Visible);
                break;

            case TfsVersion.NotDefined:
                break;

            default:
                Set2017FieldsVisibility(Visibility.Visible);
                break;
            }

            try
            {
                Helper.CheckedConnection = false;

                TfsLocation.Text = ConnectionCreator.GetTfsLocationFromHostName();
                if (!ConfigurationManager.ConfigurationExists())
                {
                    return;
                }

                var connectionDetails = ConfigurationManager.Read(false);

                Location.Text          = connectionDetails.ALMOctaneUrl;
                ClientId.Text          = connectionDetails.ClientId;
                ClientSecret.Password  = connectionDetails.ClientSecret;
                TfsLocation.Text       = connectionDetails.TfsLocation;
                Pat.Password           = connectionDetails.Pat;
                _instanceId            = connectionDetails.InstanceId;
                PasswordInput.Password = connectionDetails.Password;
                UsernameInput.Text     = connectionDetails.Pat;
            }
            catch (Exception ex)
            {
                Log.Warn("Could not parse existing configuration file", ex);
            }
        }
Beispiel #16
0
 private void ReadConfigurationFile()
 {
     try
     {
         ConnectionDetails tempConf = ConfigurationManager.Read(true);
         ConnectionCreator.CheckMissingValues(tempConf);
         _connectionDetails = tempConf;
     }
     catch (Exception e)
     {
         Log.Error($"Failed to load configuration file : {e.Message}");
         _connectionDetails = null;
     }
 }
Beispiel #17
0
        private void StartPluginInternal(CancellationToken token)
        {
            Status = StatusEnum.Connecting;
            while (Status != StatusEnum.Connected && !token.IsCancellationRequested)
            {
                try
                {
                    TfsApis    tfsApis    = ConnectionCreator.CreateTfsConnection(_connectionDetails);
                    OctaneApis octaneApis = ConnectionCreator.CreateOctaneConnection(_connectionDetails);

                    _taskManager = new OctaneTaskManager(tfsApis, octaneApis);
                    _taskManager.Start();
                    _queuesManager = new QueuesManager(tfsApis, octaneApis);
                    _queuesManager.Start();

                    _initFailCounter = 0;
                    Status           = StatusEnum.Connected;
                }
                catch (Exception ex)
                {
                    Log.Error($"Error in StartPlugin : {ex.Message}", ex);
                    if (_queuesManager != null)
                    {
                        _queuesManager.ShutDown();
                        _queuesManager = null;
                    }
                    if (_taskManager != null)
                    {
                        _taskManager.ShutDown();
                        _taskManager = null;
                    }
                }

                //Sleep till next retry
                if (Status != StatusEnum.Connected)
                {
                    int initTimeoutIndex   = Math.Min((_initFailCounter / 3), _initTimeoutInMinutesArr.Length - 1);
                    int initTimeoutMinutes = _initTimeoutInMinutesArr[initTimeoutIndex];
                    Log.Info($"Wait {initTimeoutMinutes} minute(s) till next initialization attempt...");
                    Thread.Sleep(initTimeoutMinutes * 1000 * 60);
                    _initFailCounter++;
                }
            }
        }
Beispiel #18
0
        private void TestConnectionButton_OnClick(object sender, RoutedEventArgs e)
        {
            NetworkSettings.EnableAllSecurityProtocols();
            NetworkSettings.IgnoreServerCertificateValidation();
            RestConnector.AwaitContinueOnCapturedContext = false;

            ReadFields();
            try
            {
                ConnectionCreator.CheckMissingValues(_conDetails);
                ConnectionCreator.CreateOctaneConnection(_conDetails);
                ConnectionCreator.CreateTfsConnection(_conDetails);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "ALM Octane", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                ErrorMessageWindow.Show("ALM Octane", ex.Message);
                return;
            }

            Helper.CheckedConnection = true;

            MessageBox.Show("Connection successfull", "ALM Octane", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
        }
Beispiel #19
0
        public RestBase()
        {
            Get["/"] = _ =>
            {
                String view = GetView("console.html");
                return(view);
            };

            Get["/status"] = _ =>
            {
                Dictionary <string, object> map = new Dictionary <string, object>();
                map["pluginStatus"]       = PluginManager.GetInstance().Status.ToString();
                map["pluginVersion"]      = Helpers.GetPluginVersion();
                map["tfsVersion"]         = RunModeManager.GetInstance().TfsVersion.ToString();
                map["generalEventsQueue"] = PluginManager.GetInstance().GeneralEventsQueue.Count;
                map["scmEventsQueue"]     = PluginManager.GetInstance().ScmEventsQueue.Count;
                map["testResultsQueue"]   = PluginManager.GetInstance().TestResultsQueue.Count;

                map["isLocal"] = AllowConfigurationModifyAccess(Request);

                return(map);
            };

            Post["/build-event/"] = _ =>
            {
                RunModeManager runModeManager = RunModeManager.GetInstance();
                if (runModeManager.RunMode == PluginRunMode.ConsoleApp)
                {
                    HandleBuildEvent();
                }

                return("Received");
            };

            Get["/logs/{logType}/{logId}"] = parameters =>
            {
                return(HandleGetLogRequest(parameters.logType, parameters.logId));
            };

            Get["/logs"] = parameters =>
            {
                String view = GetView("logs.html");
                return(view);
                //return HandleGetLogListRequest();
            };

            Get["/logs/download/all"] = _ =>
            {
                string zipPath  = CreateZipFileFromLogFiles();
                string fileName = Path.GetFileName(zipPath);
                DeleteTempZipFileWithDelay(zipPath);

                var file     = new FileStream(zipPath, FileMode.Open);
                var response = new StreamResponse(() => file, MimeTypes.GetMimeType(fileName));
                return(response.AsAttachment(fileName));
            };

            Post["/config", AllowConfigurationModifyAccess] = _ =>
            {
                var configStr = Context.Request.Body.AsString();
                Log.Debug($"Received new configuration");//dont log received log configuration as it contains plain passwords
                var config = JsonHelper.DeserializeObject <ConnectionDetails>(configStr);
                try
                {
                    ConnectionCreator.CheckMissingValues(config);
                    ConfigurationManager.ResetSensitiveInfo(config);
                    ConfigurationManager.WriteConfig(config);
                }
                catch (Exception e)
                {
                    string msg = "Failed to save configuration" + e.Message;
                    Log.Error(msg, e);
                    return(new TextResponse(msg).WithStatusCode(HttpStatusCode.BadRequest));
                }

                return("Configuration changed");
            };

            Post["/config/test", AllowConfigurationModifyAccess] = _ =>
            {
                try
                {
                    var configStr = Context.Request.Body.AsString();
                    var config    = JsonHelper.DeserializeObject <ConnectionDetails>(configStr);

                    ConnectionCreator.CheckMissingValues(config);
                    ConfigurationManager.ResetSensitiveInfo(config);
                    ConnectionCreator.CheckProxySettings(config.TfsLocation);
                    ConnectionCreator.CheckProxySettings(config.ALMOctaneUrl);
                    ConnectionCreator.CreateTfsConnection(config);
                    ConnectionCreator.CreateOctaneConnection(config);
                }
                catch (Exception e)
                {
                    return(new TextResponse(e.Message).WithStatusCode(HttpStatusCode.BadRequest));
                }

                return("");
            };

            Get["/config"] = _ =>
            {
                if (AllowConfigurationModifyAccess(Request))
                {
                    String            view = GetView("config.html");
                    ConnectionDetails conf = null;
                    try
                    {
                        conf = ConfigurationManager.Read(false).GetInstanceWithoutSensitiveInfo();
                    }
                    catch (FileNotFoundException)
                    {
                        conf             = new ConnectionDetails();
                        conf.TfsLocation = ConnectionCreator.GetTfsLocationFromHostName();
                    }

                    string confJson = JsonHelper.SerializeObject(conf);
                    view = view.Replace("//{defaultConf}", "var defaultConf =" + confJson);

                    return(view);
                }
                else
                {
                    string prefix = "Configuration is read-only. To modify configuration, access http://localhost:4567/config on the TFS machine.";
                    string config = JsonHelper.SerializeObject(ConfigurationManager.Read(false).GetInstanceWithoutSensitiveInfo(), true);

                    return(new TextResponse(prefix + Environment.NewLine + config));
                }
            };

            Get["/proxy"] = _ =>
            {
                if (AllowConfigurationModifyAccess(Request))
                {
                    String       view = GetView("proxy.html");
                    ProxyDetails conf = null;
                    try
                    {
                        conf = ProxyManager.Read(false).GetInstanceWithoutSensitiveInfo();
                    }
                    catch (FileNotFoundException)
                    {
                        conf = new ProxyDetails();
                    }

                    string confJson = JsonHelper.SerializeObject(conf);
                    view = view.Replace("//{defaultConf}", "var defaultConf =" + confJson);

                    return(view);
                }
                else
                {
                    string prefix = "Proxy is read-only. To modify proxy, access http://localhost:4567/proxy on the TFS machine.";
                    string config = JsonHelper.SerializeObject(ProxyManager.Read(false).GetInstanceWithoutSensitiveInfo(), true);

                    return(new TextResponse(prefix + Environment.NewLine + config));
                }
            };

            Post["/proxy", AllowConfigurationModifyAccess] = _ =>
            {
                var configStr = Context.Request.Body.AsString();
                Log.Debug($"Received new proxy settings");//dont log received log configuration as it contains plain passwords
                try
                {
                    var proxyDetails = JsonHelper.DeserializeObject <ProxyDetails>(configStr);
                    ConnectionCreator.CheckMissingValues(proxyDetails);
                    ProxyManager.ResetSensitiveInfo(proxyDetails);
                    ProxyManager.WriteConfig(proxyDetails);
                }
                catch (Exception e)
                {
                    string msg = "Failed to save proxy settings: " + e.Message;
                    Log.Error(msg, e);
                    return(new TextResponse(msg).WithStatusCode(HttpStatusCode.BadRequest));
                }

                return("Configuration changed");
            };

            Get["/resources/{resourceName}"] = parameters =>
            {
                var    assembly     = Assembly.GetExecutingAssembly();
                var    resourceName = $"{PATH_TO_RESOURCE}.RestServer.Views.Resources.{parameters.resourceName}";
                Stream stream       = assembly.GetManifestResourceStream(resourceName);
                if (stream == null)
                {
                    return(new TextResponse("Resource not found").WithStatusCode(HttpStatusCode.NotFound));
                }

                var response = new StreamResponse(() => stream, MimeTypes.GetMimeType(resourceName));
                return(response);
            };

            Post["/start", AllowConfigurationModifyAccess] = _ =>
            {
                if (PluginManager.GetInstance().Status == PluginManager.StatusEnum.Connected)
                {
                    return("ALM Octane plugin is already running");
                }

                Log.Debug("Plugin start requested");

                PluginManager.GetInstance().StartPlugin();
                return("Starting ALM Octane plugin");
            };

            Post["/stop", AllowConfigurationModifyAccess] = _ =>
            {
                Log.Debug("Plugin stop requested");
                PluginManager.GetInstance().StopPlugin();
                return("Stopping ALM Octane plugin");
            };

            Post["/queues/clear", AllowConfigurationModifyAccess] = _ =>
            {
                Dictionary <string, object> queueStatus = new Dictionary <string, object>();
                queueStatus["GeneralEventsQueue"] = PluginManager.GetInstance().GeneralEventsQueue.Count;
                queueStatus["ScmEventsQueue"]     = PluginManager.GetInstance().ScmEventsQueue.Count;
                queueStatus["TaskResultQueue"]    = PluginManager.GetInstance().TestResultsQueue.Count;

                string json = JsonHelper.SerializeObject(queueStatus, true);
                Log.Debug($"Clear event queues requested : {json}");

                PluginManager.GetInstance().GeneralEventsQueue.Clear();
                PluginManager.GetInstance().ScmEventsQueue.Clear();
                PluginManager.GetInstance().TestResultsQueue.Clear();
                return($"Cleared {json}");
            };
        }
 public NotificationDataFacade()
 {
     _connectionCreator = new ConnectionCreator(Scope.CustomerPayment);
 }
 public NotificationDataFacade()
 {
     _connectionCreator = new ConnectionCreator(Scope.CustomerPayment);
 }
        public void OnInputClicked(InputClickedEventData eventData)
        {
            //Needs: SourceName, TargetName, ActuatorOperation, ConditionOperator, rightSide of Condition as String

            //SensActConnection.commands targetCommand;

            SenActFensterName = this.gameObject.transform.parent.name;
            SenActFenster     = this.gameObject.transform.parent.gameObject;

            this.LineID         = SenActFenster.GetComponent <LogicSenActInput>().LineID;
            this.SourceNamelong = SenActFenster.GetComponent <LogicSenActInput>().SourceName;
            this.TargetNamelong = SenActFenster.GetComponent <LogicSenActInput>().TargetName;
            this.condOperator   = SenActFenster.GetComponent <LogicSenActInput>().GetOperator();

            bool targetOp = SenActFenster.GetComponent <LogicSenActInput>().GetTargetStatus();

            if (!targetOp)
            {
                targetCommand = SensActConnection.commands.OFF;
            }
            else
            {
                targetCommand = SensActConnection.commands.ON;
            }

            Item source = ItemManager.getInstance().getItem(SourceNamelong);
            Item target = ItemManager.getInstance().getItem(TargetNamelong);

            if (source is NfcReader || source is MyoArmband)
            {
                this.rightSideString = SenActFenster.GetComponent <LogicSenActInput>().GetSenValueString();
            }
            else
            {
                this.rightSide = SenActFenster.GetComponent <LogicSenActInput>().GetSenValue();
            }

            if (source is Sensor && target is Actuator)
            {
                if (!ConnectionManager.getInstance().getConnections().ContainsKey(LineID))
                {
                    Sensor   sSens   = (Sensor)source;
                    Actuator tDimmer = (Actuator)target;
                    if (source is NfcReader || source is MyoArmband)
                    {
                        if (source is NfcReader)
                        {
                            NfcReader nfcr = (NfcReader)source;
                            nc = ConnectionCreator.createNfcActConnection(LineID, SourceNamelong, TargetNamelong, rightSideString, condOperator, targetCommand);
                        }
                        else
                        {
                            MyoArmband myoa = (MyoArmband)source;
                            mc = ConnectionCreator.createMyoActConnection(LineID, SourceNamelong, TargetNamelong, rightSideString, condOperator, targetCommand);
                        }
                    }
                    else
                    {
                        c = ConnectionCreator.createSensActConnection(LineID, SourceNamelong, TargetNamelong, rightSide, condOperator, targetCommand);
                    }
                    ConnectionManager.getInstance().startConnection(LineID);
                }
                else
                {
                    if (source is NfcReader || source is MyoArmband)
                    {
                        if (source is NfcReader)
                        {
                            nc = (NfcActConnection)ConnectionManager.getInstance().getConnection(LineID);
                        }
                        else
                        {
                            mc = (MyoActConnection)ConnectionManager.getInstance().getConnection(LineID);
                        }
                    }
                    else
                    {
                        c = (SensActConnection)ConnectionManager.getInstance().getConnection(LineID);
                    }
                    ConnectionManager.getInstance().startConnection(LineID);
                }
            }

            SenActFenster.transform.GetChild(1).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            this.transform.localScale = new Vector3(0, 0, 0);
        }
Beispiel #23
0
 public LoggingDataCanFacade()
 {
     _connectionCreator = new ConnectionCreator(Scope.Logging);
 }
Beispiel #24
0
 public PaymentsDataCanFacade()
 {
     _connectionCreator = new ConnectionCreator(Scope.CustomerPayment);
 }
 public OfflineDataFacade()
 {
     _customerPaymentsConnection = new ConnectionCreator(Scope.CustomerPayment);
 }
Beispiel #26
0
        public void OnInputClicked(InputClickedEventData eventData)
        {
            if (SourceName.Contains("dimmer"))
            {
                if (SourceType.Equals("Sensor"))
                {
                    SourceName = SourceName + "_Sensor";
                }
                else
                {
                    SourceName = SourceName + "_Actuator";
                }
            }

            Item source = ItemManager.getInstance().getItem(SourceName);
            Item target = ItemManager.getInstance().getItem(TargetName);

            AktuellesFenster   = this.gameObject.transform.parent;
            AktuellesFensterGO = this.gameObject.transform.parent.gameObject;
            Line = GameObject.Find(LineID);

            if ((source is Poti && target is DimmerActuator) || (source is Poti && target is HueDimmer) || (source is ColorSensor && target is HueDimmer))
            {
                this.transform.localScale = new Vector3(0, 0, 0);
                Debug.Log("ich versuche auf (0 0 0) zu skalieren: " + this.transform.name);
                AktuellesFensterGO.transform.GetChild(2).transform.localScale = new Vector3(0, 0, 0);
                Debug.Log("ich versuche auf (0 0 0) zu skalieren: " + AktuellesFensterGO.transform.GetChild(2).name);
                AktuellesFensterGO.transform.GetChild(3).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                Debug.Log("ich versuche auf (0,1 0,1 0,1) zu skalieren: " + AktuellesFensterGO.transform.GetChild(3).name);
                AktuellesFensterGO.transform.GetChild(4).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                Debug.Log("ich versuche auf (0,1 0,1 0,1) zu skalieren: " + AktuellesFensterGO.transform.GetChild(4).name);

                if (!ConnectionManager.getInstance().getConnections().ContainsKey(LineID))
                {
                    if (source is Poti)
                    {
                        if (target is DimmerActuator)
                        {
                            this.c = ConnectionCreator.createPotiDimmerConnection(LineID, SourceName, TargetName);
                        }
                        else
                        {
                            this.c = ConnectionCreator.createPotiHueConnection(LineID, SourceName, TargetName);
                        }
                    }
                    else
                    {
                        this.c = ConnectionCreator.createColorHueConnection(LineID, SourceName, TargetName);
                    }
                    ConnectionManager.getInstance().startConnection(LineID);
                }
                else
                {
                    ConnectionManager.getInstance().startConnection(LineID);
                }
            }

            else
            {
                if (source is Sensor)
                {
                    Destroy(AktuellesFensterGO);
                    LogicSenActInitializer = Instantiate(LogicSenActPrefabb) as Transform;
                    LogicSenActInitializer.transform.position = FensterPoss;
                    LogicSenActInitializer.name = "Window_" + SourceName + TargetName;
                    EingabeFensterName          = LogicSenActInitializer.name; // weiß nicht ob es sinnvoll ist das nochmal irgendwohin zu übergeben
                    LogicSenActInitializer.GetChild(0).GetChild(1).GetChild(1).GetComponent <Text>().text = SourceNameShort;
                    LogicSenActInitializer.GetChild(0).GetChild(3).GetChild(1).GetComponent <Text>().text = TargetNameShort;
                    LogicSenActInitializer.GetChild(0).GetChild(2).GetChild(2).GetComponent <Text>().text = source.state;
                    Debug.Log("source " + SourceName + " is of type " + SourceType);
                    Sensor Sens = (Sensor)source;
                    LogicSenActInitializer.GetChild(0).GetChild(2).GetChild(4).GetComponent <Text>().text = Sens.unit;

                    LogicSenActInitializer.GetComponent <LogicSenActInput>().SourceName = SourceName;
                    LogicSenActInitializer.GetComponent <LogicSenActInput>().TargetName = TargetName;
                    LogicSenActInitializer.GetComponent <LogicSenActInput>().LineID     = LineID;

                    LogicSenActInitializer.GetChild(2).GetComponent <DeleteConnection>().LineID = LineID;

                    LogicSenActInitializer.GetChild(1).GetComponent <StopConnection>().LineID = LineID;
                    LogicSenActInitializer.GetChild(1).transform.localScale = new Vector3(0, 0, 0);
                }

                else
                {
                    Destroy(AktuellesFensterGO);
                    LogicActActInitializer = Instantiate(LogicActActPrefabb) as Transform;
                    LogicActActInitializer.transform.position = FensterPoss;
                    LogicActActInitializer.name = "Window_" + SourceName + TargetName;
                    EingabeFensterName          = LogicActActInitializer.name; // weiß nicht ob es sinnvoll ist das nochmal irgendwohin zu übergeben

                    LogicActActInitializer.GetChild(0).GetChild(1).GetChild(1).GetComponent <Text>().text = SourceNameShort;
                    LogicActActInitializer.GetChild(0).GetChild(2).GetChild(1).GetComponent <Text>().text = TargetNameShort;

                    LogicActActInitializer.GetChild(3).GetComponent <StartActActConnection>().SourceNamelong = SourceName;
                    LogicActActInitializer.GetChild(3).GetComponent <StartActActConnection>().TargetNamelong = TargetName;
                    LogicActActInitializer.GetChild(3).GetComponent <StartActActConnection>().LineID         = LineID;

                    LogicActActInitializer.GetChild(2).GetComponent <DeleteConnection>().LineID = LineID;

                    LogicActActInitializer.GetChild(1).GetComponent <StopConnection>().LineID = LineID;
                    LogicActActInitializer.GetChild(1).transform.localScale = new Vector3(0, 0, 0);
                }
            }

            isSelected = !isSelected;
        }
 public PaymentEventsDataCanFacade()
 {
     _connectionCreator = new ConnectionCreator(Scope.Monitoring);
 }
 public SystemEventSummaryWindow()
 {
     _connectionCreator = new ConnectionCreator(Scope.Monitoring);
 }
Beispiel #29
0
        public async Task PrintAsync(DiscoveredPrinter printer, string message)
        {
            Connection connection       = null;
            bool       linePrintEnabled = false;

            try
            {
                await Task.Factory.StartNew(() =>
                {
                    connection = ConnectionCreator.Create(printer);
                    connection.Open();

                    string originalPrinterLanguage = SGD.GET(DeviceLanguagesSgd, connection);
                    linePrintEnabled = "line_print".Equals(originalPrinterLanguage, StringComparison.OrdinalIgnoreCase);

                    if (linePrintEnabled)
                    {
                        SGD.SET(DeviceLanguagesSgd, "zpl", connection);
                    }

                    ZebraPrinter zebraPrinter        = ZebraPrinterFactory.GetInstance(connection);
                    ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(zebraPrinter);

                    string errorMessage = GetPrinterStatusErrorMessage(zebraPrinter.GetCurrentStatus());
                    if (errorMessage != null)
                    {
                        throw new PrinterNotReadyException($"{errorMessage}. Please check your printer and try again.");
                    }
                    else
                    {
                        connection.Write(Encoding.UTF8.GetBytes(message));
                    }
                });

                if (linePrintEnabled)
                {
                    await ResetPrinterLanguageToLinePrintAsync(connection);
                }
            }
            catch (PrinterNotReadyException e)
            {
                if (linePrintEnabled)
                {
                    await ResetPrinterLanguageToLinePrintAsync(connection);
                }
                throw new Exception(e.Message);
            }
            catch (Exception e)
            {
                if (linePrintEnabled)
                {
                    await ResetPrinterLanguageToLinePrintAsync(connection);
                }
                throw new Exception(e.Message);
            }
            finally
            {
                await Task.Factory.StartNew(() =>
                {
                    try
                    {
                        connection?.Close();
                    }
                    catch (ConnectionException) { }
                });
            }
        }
 public SystemEventSummaryWindow()
 {
     _connectionCreator = new ConnectionCreator(Scope.Monitoring);
 }
 public ErrorSummaryWindow()
 {
     _sql = GetSqlScript();
     _connectionCreator = new ConnectionCreator(Scope.Monitoring);
 }
        public void OnInputClicked(InputClickedEventData eventData)
        {
            //Needs: LineID, Source Name, Target Name, Source Operation, Target Operation

            bool exists = false;

            if (ConnectionManager.getInstance().getConnections().ContainsKey(LineID))
            {
                exists = true;
            }

            ActActFensterName = this.gameObject.transform.parent.name;
            ActActFenster     = this.gameObject.transform.parent.gameObject;

            ActActConnection.commands sourceCommand;
            ActActConnection.commands targetCommand;

            bool opSource = ActActFenster.GetComponent <LogicActActInput>().GetSourceStatus(); //false = off, true = on
            bool opTarget = ActActFenster.GetComponent <LogicActActInput>().GetTargetStatus(); //false = off, true = on

            if (!opSource)
            {
                sourceCommand = ActActConnection.commands.OFF;
            }
            else
            {
                sourceCommand = ActActConnection.commands.ON;
            }
            if (!opTarget)
            {
                targetCommand = ActActConnection.commands.OFF;
            }
            else
            {
                targetCommand = ActActConnection.commands.ON;
            }

            Item source = ItemManager.getInstance().getItem(SourceNamelong);
            Item target = ItemManager.getInstance().getItem(TargetNamelong);

            if (source is Actuator && target is Actuator)
            {
                Actuator aSource = (Actuator)source;
                Actuator aTarget = (Actuator)target;
                if (!exists)
                {
                    ActActConnection c = ConnectionCreator.createActActConnection(LineID, SourceNamelong, TargetNamelong, sourceCommand, targetCommand);
                }

                ConnectionManager.getInstance().startConnection(LineID);
                if (sourceCommand.Equals(ActActConnection.commands.ON))
                {
                    StartCoroutine(aSource.sendON());
                    ConnectionManager.getInstance().stopConnection(LineID);
                }
                else if (sourceCommand.Equals(ActActConnection.commands.OFF))
                {
                    StartCoroutine(aSource.sendOFF());
                    ConnectionManager.getInstance().stopConnection(LineID);
                }

                if (targetCommand.Equals(ActActConnection.commands.ON))
                {
                    StartCoroutine(aTarget.sendON());
                    ConnectionManager.getInstance().stopConnection(LineID);
                }
                else if (targetCommand.Equals(ActActConnection.commands.OFF))
                {
                    StartCoroutine(aTarget.sendOFF());
                    ConnectionManager.getInstance().stopConnection(LineID);
                }
            }

            //ActActFenster.transform.GetChild(1).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            //this.transform.localScale = new Vector3(0, 0, 0);
        }
Beispiel #33
0
 public ErrorSummaryWindow()
 {
     _sql = GetSqlScript();
     _connectionCreator = new ConnectionCreator(Scope.Monitoring);
 }