Exemplo n.º 1
0
        public int AddOrUpdate(ClientModel obj)
        {
            try
            {
                if (obj != null)
                {
                    var currentuser = UserManager.Current();

                    if (currentuser != null)
                    {
                        Client usr = new Client();
                        int orgid; int client_Id; int user_id; string name = string.Empty; string main_Phone = string.Empty; string main_Email = string.Empty; string main_URL = string.Empty; ;

                        // using (var transaction = new TransactionScope())
                        // {
                        client_Id = obj.Row_Id;
                        main_Phone = obj.Main_Phone;
                        obj.OrgId = int.Parse(currentuser.OrgId.ToString());

                        obj.IsDeleted = false;
                        _repository.UpdateClients(obj.OrgId, obj.Row_Id, currentuser.Row_Id, obj.Name, obj.Main_Phone, obj.Main_Email, obj.Main_URL);

                        //   transaction.Complete();
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }
            return 1;
        }
 CreateClientViewModel (WorkspaceModel workspaceModel)
 {
     model = new ClientModel {
         Workspace = workspaceModel
     };
     ServiceContainer.Resolve<ITracker> ().CurrentScreen = "New Client Screen";
 }
Exemplo n.º 3
0
 protected  ClientJsonResult ClientJson(ClientModel model, string contentType , Encoding contentEncoding)
 {
     return new ClientJsonResult()
     {
         ContentEncoding = contentEncoding,
         ContentType = contentType,
         Model = model
     };
 }
        public NewClientViewController (WorkspaceModel workspace)
        {
            this.model = new ClientModel () {
                Workspace = workspace,
                Name = "",

            };
            Title = "NewClientTitle".Tr ();
        }
Exemplo n.º 5
0
 public static void Main()
 {
     ClientController controller = ClientController.Instance;
     ClientModel model = new ClientModel();
     LoginForm loginForm = new LoginForm(controller);
     controller.setView(loginForm);
     controller.setModel(model);
     loginForm.setModelController(model, controller);
     Application.Run(loginForm);
 }
Exemplo n.º 6
0
        public ActionResult Create(ClientModel cm)
        {
            DataService.Client.Add(new Client()
            {
                Name = cm.Name,
                Address = cm.Address,
                Telephone = cm.PhoneNumber,
                Cell_Phone = cm.Cell,
                Email = cm.Email,
                Birthday = cm.Birthday
            });

            return RedirectToAction("Index");
        }
Exemplo n.º 7
0
        public async Task<ClientData> SaveNewClient ()
        {
            var store = ServiceContainer.Resolve<IDataStore>();
            var existing = await store.Table<ClientData>()
                           .Where (r => r.WorkspaceId == model.Workspace.Id && r.Name == ClientName)
                           .ToListAsync().ConfigureAwait (false);

            if (existing.Count > 0) {
                model = new ClientModel (existing [0]);
            } else {
                model.Name = ClientName;
            }
            await model.SaveAsync ();
            return model.Data;
        }
Exemplo n.º 8
0
        public ClientEditViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog,
                                   IToolBarService toolBarService, BindableCollection<IToolBarItem> toolBarCollection,
                                   IClientEditService service, ClientModel model, BindableCollection<string> genderCollection)
            : base(log, scheduler, standardDialog)
        {
            _service = service;

            ToolBarItems = toolBarCollection;

            Model = model;
            Model.AddDisposable(Disposables);

            Genders = genderCollection;

            CreateSaveToolBar(toolBarService);
            CreateCancelToolBar(toolBarService);
        }
Exemplo n.º 9
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            ClientModel clientModel = new ClientModel();
            Client client = CreateClient();
  
            //Redirect to login page
            HtmlMeta meta = new HtmlMeta();
            meta.HttpEquiv = "Refresh";
            lblResult.Text = clientModel.InsertClient(client);
            meta.Content = "3; url = /ZHUW15/asp_practical/Pages/Accounts/Login.aspx";
            this.Page.Controls.Add(meta);

            //SendEmail();
        }
    }
Exemplo n.º 10
0
        public async Task Mobile_ClientModel_GetPersonWithDisaster()
        {
            try
            {
                var entityManager = GetInitializedEntityManager();

                Breeze.Sharp.Configuration.Instance.ProbeAssemblies(typeof(ClientModel).Assembly);
                var model = new ClientModel(entityManager);
                await model.RefreshAsync();
                Assert.IsNotNull(model.Person.Commitments[0].Disaster);
            }
            catch (Exception ex)
            {
                var e = ex;
                Assert.Fail(ex.Message);
            }
        }
Exemplo n.º 11
0
    protected void btnsubmit_click(object sender, EventArgs e)
    {
        ZHUW15sqlserver1Entities db = new ZHUW15sqlserver1Entities();
        ClientModel clientModel = new ClientModel();
        List<Client> clients = clientModel.GetAllClients();

        String clientId = "";

        if (clients != null)
        {
            //Check if product in DB
            foreach (Client client in clients)

            {
                if (client.Name == txtName.Text.Trim() && client.Password == txtPassword.Text.Trim() && client.ActiveUser == true)
                {        
                        int Id = client.ID;
                        Application["clientId"] = Id;
                        Application["clientName"] = client.Name;

                        //Redirect page to WebShop after lable showing 
                        HtmlMeta meta = new HtmlMeta();
                        meta.HttpEquiv = "Refresh";                     
                        lblResult.Text =  Application["clientName"].ToString() + ", your login is successful!";
                        meta.Content = "3; url = /ZHUW15/asp_practical/Pages/WebShop.aspx";
                        this.Page.Controls.Add(meta);
                 
                }

                else if (client.Name == txtName.Text.Trim() && client.Password == txtPassword.Text.Trim() && client.ActiveUser == false)
                {
                    lblResult.Text = ("Sorry, this account is disable, please contact us for further help.");
                }
                else
                {
                    lblResult.Text = ("Invalid username or password!");
                    
                }
            }
            
        }

    }
Exemplo n.º 12
0
	static void Main(string[] args) {

		// Handle the command line stuff
		if ( args.Length != 1 ) {
			Console.Error.WriteLine( "Usage: [mono] Ftp server" );
			Environment.Exit( 1 );
		}

		try {
			var connection = new TcpClient(args[0], 21);
		
			var proxy = new Proxy(connection, args[0]);
			var client = new ClientModel(proxy);
			client.run();
		} catch (Exception e) {
			Console.Error.WriteLine("Failed to connect to server");
			Environment.Exit(1);
		}
	}
Exemplo n.º 13
0
        public ClientViewModel(ClientModel model)
        {
            this.Id = model.Id;                                         //主键
            this.No = model.No;                                         //客户编号
            this.Type = model.Type;                                     //客户类别

            this.ChName = model.ChName;                                 //中文名称
            this.EnName = model.EnName;                                 //英文名称
            this.ShortName = model.ShortName;                           //简称

            this.Countryid = model.Countryid.ToString();                //国家
            this.Address = model.Address;                               //地址
            this.Phone = model.Phone;                                   //电话

            this.Email = model.Email;                                   //邮箱
            this.Linkman = model.Linkman;                               //联系人
            this.Remark = model.Remark;                                 //备注

            this.ApprovalStatus = model.ApprovalStatus;                 //审批状态
        }
Exemplo n.º 14
0
	public ClientControl(ClientModel model) {
   		this.model = model;	
	}
 protected override ClientModel.IType NormalizeType(ClientModel.IType type)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 16
0
 public void Dispose ()
 {
     model = null;
 }
Exemplo n.º 17
0
        private ClientModel GetClientCreate()
        {
            var client = new ClientModel()
            {
                Id = Guid.NewGuid(),
                Address = txtAddress.Text,
                CellPhone = txtCellPhone.Text,
                City = txtCity.Text,
                Name = txtName.Text,
                Email = txtEmail.Text,
                Referent = txtReferent.Text,
                Tel1 = txtPhoneNumber1.Text,
                Tel2 = txtPhoneNumber2.Text,
                WebSite = txtWebsite.Text
            };

            return client;
        }
Exemplo n.º 18
0
 public ClientJsonResult(ClientModel data)
 {
     Model = data;
 }
Exemplo n.º 19
0
        public void DeleteUser(string userid)
        {
            try
            {
                if (!string.IsNullOrEmpty(userid))
                {

                    var currentuser = UserManager.Current();

                    if (currentuser != null)
                    {

                        var lstClient = GetClients(string.Empty, int.Parse(userid)).ToList();

                        if (lstClient != null)
                        {
                            var model = new ClientModel();
                            foreach (var item in lstClient)
                            {
                                model.OrgId = item.Org_Id.Value;
                                model.Main_Email = item.Main_Email;
                                model.Name = item.Name;
                                model.Main_URL = item.Main_URL;
                                model.Main_Phone = item.Main_Phone;
                                model.Row_Id = item.Row_Id;
                                model.IsDeleted = true;
                                _repository.UpdateClients(model.OrgId, model.Row_Id, currentuser.Row_Id, model.Name, model.Main_Phone, model.Main_Email, model.Main_URL, model.IsDeleted);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }
        }
Exemplo n.º 20
0
 public void SendGetMsgToMDS(ClientModel clientModel)
 {
     string messageStr = CommonFlag.F_MDSVerifyMCSGetMSG + JsonConvert.SerializeObject(clientModel);
     CommonVariables.Listener.SendMsg(clientModel.MDS_IP, clientModel.MDS_Port, messageStr, clientModel.ObjectID);
 }
Exemplo n.º 21
0
 public static Client ToEntity(this ClientModel clientModel)
 {
     return(clientModel.MapTo <ClientModel, Client>());
 }
Exemplo n.º 22
0
        public string Add(ClientViewModel model)
        {
#if DEBUG
            SysConfig.CurrentUser = UserModel.SingleOrDefault("3");
#endif
            if (ModelState.IsValid)
            {
                ClientModel client = new ClientModel();
                client.No = CommonMethod.GetLatestSerialNo(SysConfig.SerialNo.ClientNo);    //客户编号
                client.Type = model.Type;                                                   //客户类别

                client.ChName = model.ChName;                                               //中文名称
                client.EnName = model.EnName;                                               //英文名称
                client.ShortName = model.ShortName;                                         //简称

                client.Countryid = model.Countryid.ToInt();                                 //国家
                client.Address = model.Address;                                             //地址
                client.Phone = model.Phone;                                                 //电话

                client.Email = model.Email;                                                 //邮箱
                client.Linkman = model.Linkman;                                             //联系人
                client.Remark = model.Remark;                                               //备注

                client.BelongsMan = CommonMethod.GetBelongsMan(                             //业务员
                    SysConfig.CurrentUser.Departmentid.ToString());
                client.BelongsDepartment = CommonMethod.GetBelongsDepartment(               //所属部门
                    SysConfig.CurrentUser.Departmentid.ToString());


                ApprovalRuleModel rule = ApprovalRuleModel.FirstOrDefault(@"where Del_Flag = 0 and Doc_Type = 1 
                                                                                and DepartmentID = @0", client.BelongsDepartment);
                //如果没有审批规则 则直接生效
                if (rule == null)
                {
                    client.ApprovalStatus = "4";                                            //审批状态  4:已生效
                }
                //如果有审批规则 则待提交
                else
                {
                    client.ApprovalStatus = "1";                                            //审批状态  1:待提交
                }

                client.DelFlag = 0;                                                         //有效状态
                client.CreateMan = SysConfig.CurrentUser.Id;                                //制单人
                client.CreateTime = DateTime.Now;                                           //制单时间
                int result = client.Insert().ToInt();

                if (result > 0)
                {
                    //更新客户最大序列号
                    CommonMethod.UpdateSerialNo(SysConfig.SerialNo.ClientNo);

                    //记录操作日志
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Client");
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_SerialNo");

                    return "1";
                }
            }
            return "0";
        }
 public override ClientModel.IType NormalizeTypeDeclaration(ClientModel.IType type)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 24
0
        public string UpdateClientModel(ClientModel clientModel)
        {
            DateTime dt = DateTime.Now;
            if (!clientModels.ContainsKey(clientModel.ObjectID))
            {
                clientModel.LatestTime = dt.ToString(CommonFlag.F_DateTimeFormat);
                clientModels.Add(clientModel.ObjectID, clientModel);
            }
            else
            {
                clientModels[clientModel.ObjectID].LatestTime = dt.ToString(CommonFlag.F_DateTimeFormat);
                clientModels[clientModel.ObjectID].Client_IP = clientModel.Client_IP;
                clientModels[clientModel.ObjectID].Client_Port = clientModel.Client_Port;
            }

            if (clientModel.LatestTime.CompareTo(dt.AddSeconds(0-_clientModelTimeoutSec))<=0)
            {
                SendGetMsgToMDS(clientModel);
            }

            return clientModels[clientModel.ObjectID].LatestTime;
        }
Exemplo n.º 25
0
 protected  ClientJsonResult ClientJson(ClientModel model)
 {
     return new ClientJsonResult() { Model = model };
 }
Exemplo n.º 26
0
        /// <summary>
        /// 重要:连接服务端,一般做为入口方法
        /// 该方法主要操作一些配置和心跳
        /// AlwaysReconnect:始终重试,开启此选项,无论何时,一旦程序在连接不上时都会进行重试,否则只在连接成功后的断线时才重试。
        /// </summary>
        /// <returns></returns>
        public async Task Start(bool AlwaysReconnect = false)
        {
            if (AlwaysReconnect)
            {
                IsStarted = true;
            }
            var oneLiveToken = ONE_LIVE_TOKEN_SRC.Token;

            while (!oneLiveToken.IsCancellationRequested)
            {
                CANCEL_TOKEN_SRC      = new CancellationTokenSource();
                TRANSFERING_TOKEN_SRC = new CancellationTokenSource();
                HEARTBEAT_TOKEN_SRC   = new CancellationTokenSource();
                _waiter = new TaskCompletionSource <object>();
                var appIdIpPortConfig = ClientConfig.Clients;
                int clientId          = 0;

                //0.5 如果有文件,取出缓存中的clientid
                try
                {
                    if (File.Exists(NSMART_CLIENT_CACHE_PATH))
                    {
                        using (var stream = File.OpenRead(NSMART_CLIENT_CACHE_PATH))
                        {
                            byte[] bytes = new byte[2];
                            stream.Read(bytes, 0, bytes.Length);
                            clientId = StringUtil.DoubleBytesToInt(bytes);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex.Message, ex);
                }
                //1.获取配置
                ConnectionManager = ServerConnnectionManager.Create(clientId);
                ConnectionManager.ClientGroupConnected += ServerConnnectionManager_ClientGroupConnected;
                ConnectionManager.ServerNoResponse      = DoServerNoResponse; //下钻事件
                ClientModel clientModel = null;                               //
                try
                {
                    //非第一次则算作重连,发送clientid过去
                    clientModel = await ConnectionManager.InitConfig(this.ClientConfig).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    //TODO 状态码:连接失败
                    Router.Logger.Error("连接失败:" + ex.Message, ex);
                    //throw;
                }

                //HasConnected = true;
                if (clientModel != null)
                {
                    int counter = 0;

                    //1.5 写入缓存
                    File.WriteAllBytes(NSMART_CLIENT_CACHE_PATH, StringUtil.IntTo2Bytes(clientModel.ClientId));
                    //2.分配配置:appid为0时说明没有分配appid,所以需要分配一个
                    foreach (var app in appIdIpPortConfig)
                    {
                        if (app.AppId == 0)
                        {
                            app.AppId = clientModel.AppList[counter].AppId;
                            counter++;
                        }
                    }
                    Logger.Debug("****************port list*************");
                    List <string> tunnelstrs = new List <string>();
                    foreach (var ap in clientModel.AppList)
                    {
                        var cApp      = appIdIpPortConfig.First(obj => obj.AppId == ap.AppId);
                        var tunnelStr = ap.AppId.ToString() + ":  " + ClientConfig.ProviderAddress + ":" +
                                        ap.Port.ToString() + "=>" +
                                        cApp.IP + ":" + cApp.TargetServicePort;
                        Logger.Debug(tunnelStr);
                        tunnelstrs.Add(tunnelStr);
                    }
                    Logger.Debug("**************************************");
                    ConnectionManager.PollingToProvider(StatusChanged, tunnelstrs);
                    //3.创建心跳连接
                    ConnectionManager.StartHeartBeats(Global.HeartbeatInterval, HEARTBEAT_TOKEN_SRC.Token);

                    IsStarted = true;
                    Exception exception = await _waiter.Task.ConfigureAwait(false) as Exception;

                    if (exception != null)
                    {
                        Router.Logger.Debug($"程序异常终止:{exception.Message}。");
                    }
                    else
                    {
                        Router.Logger.Debug($"未知异常。");
                    }
                }
                else
                {
                    Router.Logger.Debug($"程序启动失败。");
                    //如果程序从未启动过就出错,则终止程序,否则重试。
                    if (IsStarted == false)
                    {
                        StatusChanged(ClientStatus.Stopped, null); return;
                    }
                }

                Router.Logger.Debug($"连接故障,尝试关闭连接并重试");
                if (ConnectionManager != null)
                {
                    ConnectionManager.CloseAllConnections();//关闭所有连接
                }
                //出错重试
                await Task.Delay(Global.ClientReconnectInterval, ONE_LIVE_TOKEN_SRC.Token);

                //TODO 返回错误码
                //await Task.Delay(TimeSpan.FromHours(24), CANCEL_TOKEN.Token).ConfigureAwait(false);
                Router.Logger.Debug($"连接关闭,开启重试");
            }
            //正常终止
            Router.Logger.Debug($"停止重试,循环终止。");
        }