Пример #1
0
        public RepositoryItemEventArgs(int key, IClientModel model)
        {
            Debug.Assert(key > 0);

            this.Key = key;
            this.Model = model;
        }
        public MainPageViewModel(
            [Import(typeof(IClientModel))] IClientModel clientModel, 
            [Import(typeof(ISystemModel))] ISystemModel systemModel, 
            [Import(typeof(IGlobals))] IGlobals globals) 
        {
            _clientModel = clientModel;
            _systemModel = systemModel;
            _globals = globals;

            this.LoginBoxVisibility = true;
            this.UserDetailsBoxVisibility = false;
            this.ErrorMessageVisibility = false;

            LoginCommand = new RelayCommand(LoginCommandAction);

            this.UserName = "******";

            this.MenuItemCommand = new RelayCommand<SYStblMenu>((menuItemClicked) =>
            {
                switch (menuItemClicked.Action)
                {
                    case "VIEW":
                        this.NavigateView(menuItemClicked.ActionObject, menuItemClicked.Name);
                        break;
                    case "DIALOG":
                        break;
                    default:
                        throw new Exception(string.Format("Don't know what to do with the navigation action {0} ", menuItemClicked.Action));
                }
            });
        }
Пример #3
0
	    public IClientModel BeginIterate(IClientModel model)
	    {
	        //var itemIdx = model.ToString().Split("item").Length;
	        var jsModel = model as JavascriptClientModel;
			var itemVariable = new JavascriptClientModel(model as JavascriptClientModel, "item" + jsModel.Depth);
            _writer.Write("for (var i{2} = 0; i{2} < {1}.length; i{2}++){{ var {0} = {1}[i{2}]; ", itemVariable, model, jsModel.Depth);

			return itemVariable;
		}
Пример #4
0
        public void Update(IClientModel model)
        {
            var typedModel = (Trip)model;

            this.DisplayName = typedModel.DisplayName;

            // Copy the expenses.
            this.Expenses = typedModel.Expenses.ToList();
        }
Пример #5
0
        public void Update(IClientModel model)
        {
            var typedModel = (Expense)model;

            this.Amount = typedModel.Amount;
            this.DisplayName = typedModel.DisplayName;
            this.RecordDate = typedModel.RecordDate;
            this.Receivers = typedModel.Receivers.ToList();
            this.Sender = typedModel.Sender;
        }
Пример #6
0
		public IClientModel Evaluate(IClientContext context, IClientModel model, string name, IDictionary<string, string> parameters)
		{
			// TODO: Use async
			var templateInfo = _templateRepository.GetTemplateAsync(parameters["template"].Trim('"')).Result;
			if (templateInfo == null)
				return model;

			_clientTemplateGenerator.Generate(templateInfo, new PartialClientContextAdapter(templateInfo.Id, context), model);

			return model;
		}
Пример #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="jsonString"></param>
 /// <param name="clientType"></param>
 /// <param name="requireDefinedOnClient">Define var on js</param>
 /// <param name="nameSpace">null: use namespace defined in client viewModel; empty: not use namespace;  otherwise use targetNameSpace</param>
 public void AddJson(string name, IClientModel model, bool requireDefinedOnClient = true,
                         string targetJsonClassName = null, string targetJsonNameSpace = null)
 {
     _jsonObjectDictionary.Add(name,
         new JsonScriptObject()
         {
             JsonModel = model,
             RequiredDefineOnClientSide = requireDefinedOnClient//,
             //TargetJsonNameSpace = targetJsonClassName,
             // TargetJsonClassName = targetJsonNameSpace
         });
 }
Пример #8
0
        public IClientModel Evaluate(IClientContext context, IClientModel model, string name, IDictionary<string, string> parameters)
        {
            var key = parameters.Keys.First().Trim('"');
            var builder = new StringBuilder();
            using (var writer = new StringWriter(builder))
            {
                _handler.RenderLabel(key, new RenderingContext(writer));
            }

            context.WriteLiteral(builder.ToString());
            return model;
        }
        public ClientMainWindow()
        {
            try
            {
                InitializeComponent();
                log4net.Config.BasicConfigurator.Configure();
                _logger = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().ToString());

                string serverHost = txtServer.Text.ToString();
                string localIP = ConfigurationManager.AppSettings["localIP"];

                _threadMouse = new Thread(delegate() { MouseThread(); });
                _threadDesktop = new Thread(delegate() { DesktopThread(); });

                _clientModel = new RemotingClient(localIP, serverHost, OnDesktopChanged);
                _clientControl = new ClientControl(_clientModel, this);
                WireUp(_clientControl, _clientModel);
                Update(_clientModel);
            }
            catch (Exception ex)
            {
                  MessageBox.Show(ex.ToString());
            }
        }
Пример #10
0
        private void UpdateInterface(IClientModel clientModel)
        {
            try
            {
                Utils.UpdateControlContent(Dispatcher, lblHostname, "Hostname: " + _clientModel.Hostname, Utils.ValueType.String);
                Utils.UpdateControlContent(Dispatcher, lblId, "ID: " + _clientModel.Id.ToString(), Utils.ValueType.String);
                Utils.UpdateControlContent(Dispatcher, lblIP, "IP: " + _clientModel.Ip, Utils.ValueType.String);
                ShowError(_clientModel.IsServerConfigured ? string.Empty : "Error: Server configuration failed");
                if (!_clientModel.Connected)
                {
                    Utils.UpdateControlContent(Dispatcher, btnConnect, "Connect", Utils.ValueType.String);
                    Utils.UpdateControlContent(Dispatcher, lblStatus, "Status: Disconnected", Utils.ValueType.String);
                    //Utils.UpdateControlContent(Dispatcher, txtServer, true, Utils.ValueType.Boolean);                   
                }
                else
                {
                    Utils.UpdateControlContent(Dispatcher, lblStatus, "Status: Connected", Utils.ValueType.String);
                    Utils.UpdateControlContent(Dispatcher, btnConnect, "Disconnect", Utils.ValueType.String);
                    //Utils.UpdateControlContent(Dispatcher, txtServer, false, Utils.ValueType.Boolean);  
                }

                // todo: use the _views member to update the interface

            }
            catch (Exception ex)
            {
                  MessageBox.Show(ex.ToString());
            }
        }
Пример #11
0
        public void Update(IClientModel model)
        {
            var typedModel = (Person)model;

            this.DisplayName = typedModel.DisplayName;
        }
Пример #12
0
        /// <summary>
        /// Adds the specified model to the repository.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns>The client key for the model</returns>
        public virtual int Add(IClientModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Debug.Assert(
                !this.models.Any(mkv => mkv.Value.GetType() == model.GetType() && mkv.Value.StoreId == model.StoreId),
                "A duplicate model already exists in the repository.");

            var key = Interlocked.Increment(ref this.lastKey);
            model.Key = key;

            Debug.WriteLine("Model [LocalId={0}; Type={1}; StoreId={2}] add to repository.", key, model.GetType().Name, model.StoreId);

            this.models.Add(key, model);

            // Resolve references
            var trip = model as Trip;

            if (trip != null)
            {
                foreach (var e in this.models.Values.OfType<Expense>().Where(e => e.TripId == trip.TripId))
                {
                    Debug.Assert(e.Trip == null);
                    e.Trip = trip;
                }
            }

            var expense = model as Expense;

            if (expense != null)
            {
                // Add to its trip, if the trip is in.
                var t = this.models.Values.OfType<Trip>().SingleOrDefault(x => x.TripId == expense.TripId);

                if (t != null)
                {
                    Debug.Assert(!t.Expenses.Any(x => x.ExpenseId == expense.ExpenseId));
                    t.Expenses.Add(expense);
                    // TODO: Inform of this update. Using this.Updated?
                }
            }

            if (this.Added != null)
            {
                this.Added(this, new RepositoryItemEventArgs(key, model));
            }

            return key;
        }
Пример #13
0
 private static void ClientDisconnected(object sender, IClientModel client) => Console.WriteLine("DISCONNECTED: " + client);
 public void WriteEncodeExpression(IClientModel model)
 {
     _writer.Write("we(");
     _writer.Write(model.ToString());
     _writer.Write(");");
 }
Пример #15
0
 public OperationCommandFactory(IClientModel userClient, IContainerInterfaces containerInterfaces, CommandHandler commandHandler)
 {
     _commandHandler      = commandHandler;
     _userClient          = userClient;
     _containerInterfaces = containerInterfaces;
 }
Пример #16
0
 public CommandHelperOption(IClientModel userClient, IContainerInterfaces containerInterfaces, CommandHandler commandHandler)
 {
     _userClient          = userClient;
     _commandHandler      = commandHandler;
     _containerInterfaces = containerInterfaces;
 }
Пример #17
0
 public LoadingPageViewModel(IClientModel client)
 {
     Client    = client;
     Authorize = new Command(Autho);
 }
 public IClientModel Evaluate(IClientContext context, IClientModel model, string name, IDictionary <string, string> parameters)
 {
     context.WriteLiteral(context.TemplateId);
     return(model);
 }
Пример #19
0
 public GetAllUserConnectedOption(IClientModel userClient, AllChatDetails allChatDetails, IContainerInterfaces containerInterfaces)
 {
     _containerInterfaces = containerInterfaces;
     _allChatDetails      = allChatDetails;
     _userClient          = userClient;
 }
Пример #20
0
 public void setModel(IClientModel model)
 {
     this.model = model;
 }
Пример #21
0
 /// <summary>
 /// Установка процедуры проверки подключения
 /// </summary>
 /// <param name="Period">Период проверки</param>
 /// <param name="Client">Клиент для подключения</param>
 public static void SetUpConnectionChecker(int Period, IClientModel Client)
 {
     TimerClient            = Client;
     ConnectionCheckerTimer = new Timer(OnTimer, null, 60 * 1000, Period);
 }
 public ViewModel(IClientModel clientModel, IProductModel productModel)
 {
     _clientModel  = clientModel;
     _productModel = productModel;
 }
Пример #23
0
	    public void WriteEncodeExpression(IClientModel model)
	    {
            _writer.Write("we(");
            _writer.Write(model.ToString());
            _writer.Write(");");
	    }
Пример #24
0
 public IClientModel Evaluate(IClientContext context, IClientModel model, string name, IDictionary<string, string> parameters)
 {
     context.WriteLiteral(context.TemplateId);
     return model;
 }
Пример #25
0
 private static void ClientConnected(object sender, IClientModel client)
 {
     Console.WriteLine("CONNECTED: " + client);
     s_server.SendMessageToClient(client, $"Telnet Server{Server.CRLF}Login: ");
 }
Пример #26
0
        public void AddOrUpdate(IClientModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.Key =
                this.models.SingleOrDefault(
                    x => x.Value.GetType() == model.GetType() && x.Value.StoreId == model.StoreId).Key;

            {
                // TODO: Move this out
                var trip = model as Trip;

                if (trip != null)
                {
                    Debug.Assert(trip.Expenses == null);
                    Debug.Assert(trip.TripId != default(int));

                    trip.Expenses =
                        new List<Expense>(
                            this.models.Select(x => x.Value).OfType<Expense>().Where(x => x.TripId == trip.TripId));
                }

                var expense = model as Expense;

                if (expense != null)
                {
                    Debug.Assert(expense.Trip == null);
                    Debug.Assert(expense.TripId != default(int));

                    expense.Trip =
                        this.models.Select(x => x.Value).OfType<Trip>().SingleOrDefault(x => x.TripId == expense.TripId);
                }

                // TODO: Person? Prob. not needed.
            }

            if (model.Key == default(int))
            {
                this.Add(model);
                return;
            }

            // Ensure that the model needs to be replaced.
            if (this[model.Key].RowId == model.RowId)
            {
                Debug.WriteLine(
                    "*** Not replacing model {0} with new model {1} because the row identifier is unchanged. Possibly wasted bandwidth?",
                    this[model.Key],
                    model);

                return;
            }

            var existingModel = this.models[model.Key];

            if (existingModel.RowId == model.RowId)
            {
                throw new Exception("The row identifier should have changed.");
            }

            if (existingModel.ChangeSetN >= model.ChangeSetN)
            {
                throw new Exception("The change set number should have increased.");
            }

            existingModel.RowId = model.RowId;
            existingModel.ChangeSetN = model.ChangeSetN;

            this.models[model.Key].Update(model);

            if (this.Updated != null)
            {
                this.Updated(this, new RepositoryItemEventArgs(model.Key, model));
            }

            Debug.WriteLine("Model [LocalId={0}; Type={1}; StoreId={2}] replaced in repository.", model.Key, model.GetType().Name, model.StoreId);
        }
Пример #27
0
		public void BeginIf(IClientModel model)
		{
			_writer.Write("if ({0}){{", model);
		}
Пример #28
0
        public IHtmlString RegisterJsonOnClientNow(string name, IClientModel clientModel, bool requireVarDefine = true,
                                                     bool requireScriptTag = true, bool requireDomReadyBlock = true)
        {
            StringBuilder sb = new StringBuilder();

            if (requireScriptTag) { AppendScriptBeginTag(sb); }
            if (requireDomReadyBlock) { AppendScriptDomReadyBeginTag(sb); }

            InsertSpaceTag(sb);
            if (requireVarDefine) { sb.Append("var "); }
            sb.AppendFormat("{0}=new {1}.{2}({3});", name, clientModel.TargetJsonModelNameSpace, clientModel.TargetJsonModelName, clientModel.ToJson());
            InsertSpaceTag(sb);

            if (requireDomReadyBlock) { AppendScriptDomReadyEndTag(sb); }
            if (requireScriptTag) { AppendScriptEndTag(sb); }

            return new HtmlString(sb.ToString());
        }
Пример #29
0
			public void WriteEncodeExpression(IClientModel model)
			{
				_adaptee.WriteEncodeExpression(model);
			}
Пример #30
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // set the image capture size
            this.WebCamCapture.CaptureHeight = this.pictureBox1.Height;
            this.WebCamCapture.CaptureWidth = this.pictureBox1.Width;
            string serverIP = ConfigurationManager.AppSettings["serverIP"];
            string serverHost = "http://" + serverIP + ":8083/SingletonServer";
            string localIP = ConfigurationManager.AppSettings["localIP"];

            //_threadMouse = new Thread(delegate() { MouseThread(); });
            //_threadDesktop = new Thread(delegate() { DesktopThread(); });

            _clientModel = new RemotingClient(localIP, serverHost, null);
            _clientControl = new ClientControl(_clientModel, null);
        }
Пример #31
0
			public void BeginIf(IClientModel model)
			{
				_adaptee.BeginIf(model);
			}
Пример #32
0
 public void Update(IClientModel clientModel)
 {
     this.UpdateInterface(clientModel);
 }
Пример #33
0
 public void SetModel(IClientModel clientModel)
 {
     this._clientModel = clientModel;
 }
Пример #34
0
 private void WireUp(IClientControl clientControl, IClientModel clientModel)
 {
     try
     {
         if (_clientModel != null)
         {
             _clientModel.RemoveObserver(this);
         }
         _clientModel = clientModel;
         _clientControl = clientControl;
         _clientControl.SetModel(_clientModel);
         _clientControl.SetView(this);
         _clientModel.AddObserver(this);
     }
     catch (Exception ex)
     {
           MessageBox.Show(ex.ToString());
     }
 }
        internal void GenerateForTemplate(string templateId, string template, IClientContext clientContext, IClientModel model)
        {
            var parser         = VeilStaticConfiguration.GetParserInstance("handlebars");
            var helperHandlers = _helperHandlerFactory.Create().ToArray();

            var tree = parser.Parse(templateId, new StringReader(template), typeof(object), _memberLocator, helperHandlers);

            new ClientNodeVisitor(clientContext, model).Visit(tree);
        }
Пример #36
0
 public bool IsClientManager(IClientModel client)
 {
     return(Managers.Any(m => m.Name == client.Name && base.IsClientExistInChat(client)));
 }
Пример #37
0
 private ClientController()
 {
     model = null;
 }
Пример #38
0
			public IClientModel BeginIterate(IClientModel model)
			{
				return _adaptee.BeginIterate(model);
			}
Пример #39
0
 public ClientController()
 {
     _clientModel = new ClientModel();
 }
Пример #40
0
 public ClientControl(IClientModel clientModel, IClientView clientView)
 {
     this._clientModel = clientModel;
     this._clientView = clientView;
 }
 public AddAdminPermissionOption(IClientModel userClient, AllChatDetails allChatDetails, IContainerInterfaces containerInterfaces)
 {
     _userClient          = userClient;
     _containerInterfaces = containerInterfaces;
     _allChatDetails      = allChatDetails;
 }
Пример #42
0
 public void setModelController(IClientModel model, IClientController controller)
 {
     this.model = model;
     this.controller = controller;
 }
 public void Generate(TemplateInfo templateInfo, IClientContext clientContext, IClientModel clientModel)
 {
     using (var stream = new StreamReader(templateInfo.Open()))
     {
         GenerateForTemplate(templateInfo.Id, stream.ReadToEnd(), clientContext, clientModel);
     }
 }