Exemple #1
0
 private bool SetSrvOption(K5SrvWrapper srv, K5SrvConstants.K5DbProperty property, string value)
 {
     return(srv.SetProperty(srv.ProjectHandle, property, value));
 }
Exemple #2
0
        internal void TryApplyOnlineChangeSettings(LogicProject zenonLogicProject, ImportOptions options = ImportOptions.Default)
        {
            if (!options.HasFlag(ImportOptions.ApplyOnlineSettings))
            {
                return;
            }

            var optionTuples = zenonLogicProject.Settings.OnlineChangeSettings.OptionTuples ?? Enumerable.Empty <LogicOptionTuple>();

            const uint callback            = 0x400;
            IntPtr     hwnd                = Process.GetCurrentProcess().MainWindowHandle;
            string     clientName          = System.Reflection.Assembly.GetEntryAssembly().GetName().Name;
            string     hotSizeBuffer       = string.Empty;
            bool       enableHot           = false;
            bool       hasHotOptionDefined = false;

            using (K5SrvWrapper srv = K5SrvWrapper.TryConnect(hwnd, callback, zenonLogicProject.Path, clientName, K5SrvConstants.K5DbSelfNotif))
            {
                while (!srv.IsReady)
                {
                    Thread.Sleep(100);
                }

                foreach (var optionTuple in optionTuples)
                {
                    if (!string.IsNullOrWhiteSpace(optionTuple.Name) && !string.IsNullOrWhiteSpace(optionTuple.Value))
                    {
                        if (optionTuple.Name.StartsWith("size_"))
                        {
                            hotSizeBuffer = hotSizeBuffer + optionTuple.Name.Replace("size_", "") + "=" + optionTuple.Value + ",";
                        }

                        else if (optionTuple.Name.Equals("enable"))
                        {
                            hasHotOptionDefined = true;
                            if (int.TryParse(optionTuple.Value, out var i))
                            {
                                enableHot = i > 0;
                            }
                            else if (bool.TryParse(optionTuple.Value, out var b))
                            {
                                enableHot = b;
                            }
                            else if (optionTuple.Value.Equals("ON", StringComparison.OrdinalIgnoreCase))
                            {
                                enableHot = true;
                            }
                            else if (optionTuple.Value.Equals("OFF", StringComparison.OrdinalIgnoreCase))
                            {
                                enableHot = false;
                            }
                        }
                    }
                }

                if (hasHotOptionDefined)
                {
                    srv.SetHot(enableHot);
                }

                if (hotSizeBuffer.Length > 0)
                {
                    srv.SetHotSizing(hotSizeBuffer);
                }
            }
        }