コード例 #1
0
ファイル: Program.cs プロジェクト: aawadall/grpc-dotnet-core
        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("GRPC_DNS_RESOLVER",
                                               "native");
            var option = 3; // int.Parse(args[0]);

            var            cacert  = File.ReadAllText(@"certs/ca.crt");
            var            cert    = File.ReadAllText(@"certs/client.crt");
            var            key     = File.ReadAllText(@"certs/client.key");
            var            keypair = new KeyCertificatePair(cert, key);
            SslCredentials creds   = new SslCredentials(cacert, keypair);
            var            channel = new Channel("DESKTOP-AQ2TIF3", Port, creds);
            var            client  = new EmployeeServiceClient(channel);

            switch (option)
            {
            case 1:
                SendMetadataAsync(client).Wait();
                break;

            case 2:
                GetByBadgeNumber(client).Wait();
                break;

            case 3:
                GetAll(client).Wait();
                break;

            case 4:
                AddPhoto(client).Wait();
                break;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: aawadall/grpc-dotnet-core
        public static async Task SendMetadataAsync(EmployeeServiceClient client)
        {
            Console.WriteLine($"Establishing hollow connection using:");

            Metadata metadata = new Metadata();

            metadata.Add("md01", "0x00");
            metadata.Add("md03", "0xd0");
            //metadata.Add("username", "username1");
            //metadata.Add("password", "password1");

            foreach (var item in metadata)
            {
                Console.WriteLine($"{item.Key}: {item.Value}");
            }
            try
            {
                await client.GetByBadgeNumberAsync(new Messages.GetByBadgeNumberRequest(), metadata);
            }
            catch (Exception e)
            {
                Console.WriteLine($"{e.Message}");
                // Just swallow the expected exception
            }
        }
コード例 #3
0
        protected void GetEmployeeData_Click(object sender, EventArgs e)
        {
            try
            {
                MessageHeader         header;
                OperationContextScope scope;
                string userToken = string.Empty;

                EmployeeServiceClient objEmployeeClient = new EmployeeServiceClient();

                userToken = objEmployeeClient.Login("guest1", "ABC");

                scope = new OperationContextScope(objEmployeeClient.InnerChannel);

                header = MessageHeader.CreateHeader("TokenHeader", "TokenNameSpace", userToken);

                OperationContext.Current.OutgoingMessageHeaders.Add(header);

                EmployeeDetails objEmployee1 = new EmployeeDetails();
                objEmployee1 = objEmployeeClient.GetMyEmployees();

                //Displaying result
                FirstName.Text      = objEmployee1.FirstName;
                LastName.Text       = objEmployee1.LastName;
                Department.Text     = objEmployee1.Department;
                Designation.Text    = objEmployee1.Designation;
                DisplayMessage.Text = "No Error";
            }
            catch (Exception ex)
            {
                DisplayMessage.Text = ex.Message;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: NellyHaglund/WCF
        private void buttonGetEmployee_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateInputWhenGetButtonIsPressed()) return;
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var employee = host.GetEmployeeById(int.Parse(textBoxEmployeeCode.Text));
                textBoxId.Text = employee.EmployeeID.ToString();
                textBoxFirstname.Text = employee.FirstName;
                textBoxLastName.Text = employee.LastName;
                textBoxTitle.Text = employee.Title;
                textBoxContry.Text = employee.Country;
            }
            catch (FaultException<SqlException> exception)
            {
                MessageBox.Show(exception.Detail.Message);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #5
0
        private static Employee GetStoredEmployee(string username)
        {
            EmployeeServiceClient client = new EmployeeServiceClient();
            Employee employee            = client.ReadByUsername(username);

            return(employee);
        }
コード例 #6
0
        public async Task <List <Employee> > GetAllSubordinatesAsync(string empEmail)
        {
            var empSvc = new EmployeeServiceClient();
            var result = await empSvc.findByAllSubordinatesAsync(empEmail);

            return(GetEmployeeModel(result.empdiectsubordinates));
        }
コード例 #7
0
        public ActionResult Employees(EmployeeModel e)
        {
            EmployeeServiceClient esc = new EmployeeServiceClient();

            if (ModelState.IsValid)
            {
                if (e.Id != -1)
                {
                    EditEmployee(e.Id, e.Name, e.Hiredate, e.Salary, e.Deptname, e.Address);
                }
                else
                {
                    AddEmployee(e.Name, e.Hiredate, e.Salary, e.Deptname, e.Address);
                }
                System.Diagnostics.Debug.WriteLine(e.Id);
                e = new EmployeeModel
                {
                    Address  = "",
                    Deptname = "",
                    Name     = "",
                    Salary   = 0,
                    Id       = -1
                };
            }
            ViewBag.employees = esc.GetAll().ToList();
            ViewBag.props     = typeof(EmployeeEnt).GetProperties().Where(a => a.Name != "ExtensionData").ToList();
            return(View(e));
        }
コード例 #8
0
        public void Run()
        {
            _logger.LogInformation("Running WcfGeneratedServiceDemo");
            _logger.LogInformation("*******************************");

            Contracts.Model.Employees.EmployeeResponse response = null;

            try
            {
                using (var client = new EmployeeServiceClient())
                {
                    response = AsyncHelper.RunSync(() => client.GetAsync(new Contracts.Model.Employees.EmployeeRequest {
                        ActiveOnly = true
                    }));
                }

                _logger.LogInformation($"Employees found: {response?.Employees.Length}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Oh noes!");
            }

            _logger.LogInformation("End WcfGeneratedServiceDemo");
            _logger.LogInformation("*******************************");
        }
コード例 #9
0
        private void buttonGetEmployee_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateInputWhenGetButtonIsPressed())
                {
                    return;
                }
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var employee = host.GetEmployeeById(int.Parse(textBoxEmployeeCode.Text));
                textBoxId.Text        = employee.EmployeeID.ToString();
                textBoxFirstname.Text = employee.FirstName;
                textBoxLastName.Text  = employee.LastName;
                textBoxTitle.Text     = employee.Title;
                textBoxContry.Text    = employee.Country;
            }
            catch (FaultException <SqlException> exception)
            {
                MessageBox.Show(exception.Detail.Message);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Employee employee = null;

            if ((EmployeeType)Convert.ToInt32(ddlEmployeeType.SelectedValue) == EmployeeType.FullTime)
            {
                employee = new FullTimeEmployee
                {
                    AnnualSalary = Convert.ToInt32(txtAnnualSalary.Text),
                    Type         = EmployeeType.FullTime
                };
            }
            else
            {
                employee = new PartTimeEmployee
                {
                    HourlyPay   = Convert.ToInt32(txtHourlyPay.Text),
                    HoursWorked = Convert.ToInt32(txtHoursWorked.Text),
                    Type        = EmployeeType.PartTime
                };
            }

            employee.ID          = Convert.ToInt32(txtID.Text);
            employee.Name        = txtName.Text;
            employee.Gender      = txtGender.Text;
            employee.DateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text);

            EmployeeServiceClient client = new EmployeeServiceClient();

            client.SaveEmployee(employee);

            lblMessage.Text = "Employee saved";
        }
コード例 #11
0
        protected void btnGetEmployee_Click(object sender, EventArgs e)
        {
            EmployeeServiceClient client = new EmployeeServiceClient();

            Employee employee =
                client.GetEmployee(Convert.ToInt32(txtID.Text));

            if (employee.Type == EmployeeType.FullTime)
            {
                txtAnnualSalary.Text   = ((FullTimeEmployee)employee).AnnualSalary.ToString();
                trAnnualSalary.Visible = true;
                trHourlPay.Visible     = false;
                trHoursWorked.Visible  = false;
            }
            else
            {
                txtHourlyPay.Text      = ((PartTimeEmployee)employee).HourlyPay.ToString();
                txtHoursWorked.Text    = ((PartTimeEmployee)employee).HoursWorked.ToString();
                trAnnualSalary.Visible = false;
                trHourlPay.Visible     = true;
                trHoursWorked.Visible  = true;
            }

            ddlEmployeeType.SelectedValue = ((int)employee.Type).ToString();
            txtName.Text        = employee.Name;
            txtGender.Text      = employee.Gender;
            txtDateOfBirth.Text = employee.DateOfBirth.ToShortDateString();
        }
コード例 #12
0
        private void ButtonNew_Click(object sender, RoutedEventArgs e)
        {
            EmployeeServiceClient klijent = new EmployeeServiceClient();
            WindowNewEmployee     w1      = new WindowNewEmployee();

            w1.Title = "Enter employee information";
            w1.Owner = this;

            if (w1.ShowDialog() == true)
            {
                EmployeeCon e1 = w1.EmployeeCon;

                int id = klijent.InsertEmployees(e1);

                if (id != -1)
                {
                    ShowEmployees();
                    //ListBox1.SelectedIndex = employeeList
                    //   .Where(a => a.EmployeeID == id);
                    MessageBox.Show("New employee added");
                }
                else
                {
                    MessageBox.Show("Error");
                }
            }
        }
コード例 #13
0
        protected void btnGetEmployee_Click(object sender, EventArgs e)
        {
            lblGetEmployeeError.Text = "";
            try
            {
                NwnWebClient.ServiceReference1.EmployeeServiceClient client = new EmployeeServiceClient();
                var result = client.GetEmployee(int.Parse(txtGetEmployee.Text));
                txtAddress.Text = result.Address;
                txtBirthDate.Text = result.BirthDate.ToString();
                txtCity.Text = result.City;
                txtCountry.Text = result.Country;
                txtCourtesy.Text = result.TitleOfCourtesy;
                txtEmployeeId.Text = result.EmployeeID.ToString();
                txtFirstName.Text = result.FirstName;
                txtLastName.Text = result.LastName;
                txtHireDate.Text = result.HireDate.ToString();
                txtHomePhone.Text = result.HomePhone;
                txtTitle.Text = result.Title;
                txtPostalCode.Text = result.PostalCode;
                txtRegion.Text = result.Region;

            }
            catch (Exception)
            {

                lblGetEmployeeError.Text = "Some data could not be found, either you entered any letters or the ID doesn't exist!";
                lblGetEmployeeError.ForeColor = Color.Red;
            }

        }
コード例 #14
0
        static void Main(string[] args)
        {
            // Create a service proxy.
            using (EmployeeServiceClient employeeService
                       = new EmployeeServiceClient())
            {
                // Create a new Employee.
                Employee emp = new Employee()
                {
                    DateOfBirth = DateTime.Now,
                    Name        = "Allen Jones"
                };

                // Call the EmployeeService to create a new Employee record.
                emp = employeeService.CreateEmployee(emp);

                Console.WriteLine("Created employee record - {0}",
                                  FormatEmployee(emp));

                // Update the existing Employee.
                emp.DateOfBirth = new DateTime(1950, 10, 13);
                emp             = employeeService.UpdateEmployee(emp);

                Console.WriteLine("Updated employee record - {0}",
                                  FormatEmployee(emp));

                // Wait to continue.
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine("Main method complete. Press Enter");
                Console.ReadLine();
            }
        }
コード例 #15
0
        public ActionResult Index()
        {
            EmployeeServiceClient bsc = new EmployeeServiceClient();

            ViewBag.listEmployees = bsc.getAllEmployee();
            return(View());
        }
コード例 #16
0
        protected void btnGetEmployeeMessageContract_Click(object sender, EventArgs e)
        {
            IEmployeeService client       = new EmployeeServiceClient();
            EmployeeRequest  request      = new EmployeeRequest("KEY12345", Convert.ToInt32(txtID.Text));
            EmployeeInfo     employeeInfo = client.GetEmployeeMessageContract(request);

            if (employeeInfo.Type == EmployeeType.FullTime)
            {
                txtAnnualSalary.Text   = employeeInfo.AnnualSalary.ToString();
                trAnnualSalary.Visible = true;
                trHourlPay.Visible     = false;
                trHoursWorked.Visible  = false;
            }
            else
            {
                txtHourlyPay.Text      = employeeInfo.HourlyPay.ToString();
                txtHoursWorked.Text    = employeeInfo.HoursWorked.ToString();
                trAnnualSalary.Visible = false;
                trHourlPay.Visible     = true;
                trHoursWorked.Visible  = true;
            }

            ddlEmployeeType.SelectedValue = ((int)employeeInfo.Type).ToString();
            txtName.Text        = employeeInfo.Name;
            txtGender.Text      = employeeInfo.Gender;
            txtDateOfBirth.Text = employeeInfo.DOB.ToShortDateString();
        }
コード例 #17
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateInputWhenSaveButtonIsPressed())
                {
                    return;
                }
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var employee = new Employee
                {
                    EmployeeID = int.Parse(textBoxId.Text),
                    FirstName  = textBoxFirstname.Text,
                    LastName   = textBoxLastName.Text,
                    Title      = textBoxTitle.Text,
                    Country    = textBoxContry.Text
                };

                host.SaveEmployee(employee);
                MessageBox.Show("Changes Saved");
            }
            catch (FaultException <SqlException> exception)
            {
                MessageBox.Show(exception.Detail.Message);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #18
0
 public async Task <List <Employee> > GetAsync()
 {
     using (EmployeeServiceClient employeeServiceClient = new EmployeeServiceClient())
     {
         return(await employeeServiceClient.GetAsync());
     }
 }
コード例 #19
0
ファイル: Window1.xaml.cs プロジェクト: changhongfu/TDDKata
 private void LoadButtonOnClick(object sender, RoutedEventArgs e)
 {
     var proxy = new EmployeeServiceClient();
     var employees = proxy.LoadEmployees();
     _textBlock1.Text = employees[0].FirstName;
     _textBlock2.Text = employees[1].FirstName;
 }
コード例 #20
0
ファイル: Form1.cs プロジェクト: Montagu-Evans/WCF
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var saveEmployee = new Employee()
                {
                    EmployeeId = int.Parse(txtBoxForEmpId.Text),
                    FirstName = txtBox_First.Text,
                    LastName = txtBox_Last.Text,
                    Country = txtBox_Country.Text,
                    Title = txtBox_Title.Text
                };

                host.SaveEmployee(saveEmployee);
            }
            catch (FaultException<SqlException> ex)
            {
                MessageBox.Show(ex.Detail.Message);
            }
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: NellyHaglund/WCF
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateInputWhenSaveButtonIsPressed()) return;
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var employee = new Employee
                {
                    EmployeeID = int.Parse(textBoxId.Text),
                    FirstName = textBoxFirstname.Text,
                    LastName = textBoxLastName.Text,
                    Title = textBoxTitle.Text,
                    Country = textBoxContry.Text
                };

                host.SaveEmployee(employee);
                MessageBox.Show("Changes Saved");
            }
            catch (FaultException<SqlException> exception)
            {
                MessageBox.Show(exception.Detail.Message);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
コード例 #22
0
            public override bool IsValid(object value)
            {
                EmployeeServiceClient esc = new EmployeeServiceClient();
                var val = (string)value;

                return(esc.GetDepts("").Contains(val));
            }
コード例 #23
0
 public ActionResult Index(DepartmentEmployeeModel model)
 {
     var client = new EmployeeServiceClient();
     var departments = client.GetDepartments(model.StartDate, model.EndDate, model.Name).ToList();
     model.Items = departments;
     return View(model);
 }
コード例 #24
0
ファイル: Form1.cs プロジェクト: Montagu-Evans/WCF
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var saveEmployee = new Employee()
                {
                    EmployeeId = int.Parse(txtBoxForEmpId.Text),
                    FirstName  = txtBox_First.Text,
                    LastName   = txtBox_Last.Text,
                    Country    = txtBox_Country.Text,
                    Title      = txtBox_Title.Text
                };

                host.SaveEmployee(saveEmployee);
            }
            catch (FaultException <SqlException> ex)
            {
                MessageBox.Show(ex.Detail.Message);
            }
        }
コード例 #25
0
 public List <Employee> Get()
 {
     using (EmployeeServiceClient employeeServiceClient = new EmployeeServiceClient())
     {
         return(employeeServiceClient.Get());
     }
 }
コード例 #26
0
        public PartialViewResult GetEmployee(int id)
        {
            EmployeeServiceClient client = new EmployeeServiceClient("BasicHttpBinding_IEmployeeService");
            Employee employee            = client.GetEmployee(id);

            return(PartialView("GetEmployee", employee));
        }
コード例 #27
0
        public static void Main(string[] args)
        {
            var option = int.Parse(args[0]);

            var            cacert  = File.ReadAllText(@"ca.crt");
            var            cert    = File.ReadAllText(@"client.crt");
            var            key     = File.ReadAllText(@"client.key");
            var            keypair = new KeyCertificatePair(cert, key);
            SslCredentials creds   = new SslCredentials(cacert, keypair);
            var            channel = new Channel("DESKTOP-1UHNCG6", Port, creds);
            var            client  = new EmployeeServiceClient(channel);

            switch (option)
            {
            case 1:
                SendMetadataAsync(client).Wait();
                break;

            case 2:
                GetByBadgeNumber(client).Wait();
                break;

            case 3:
                GetAll(client).Wait();
                break;

            case 4:
                AddPhoto(client).Wait();
                break;

            case 5:
                SaveAll(client).Wait();
                break;
            }
        }
コード例 #28
0
 /// <summary>
 /// Returns the employee that's currently logged into the server POS workstation
 /// </summary>
 /// <returns>Information about the employee. NULL if no one is currently logged into the workstation</returns>
 public Employee GetCurrentUser()
 {
     using (var client = new EmployeeServiceClient())
     {
         client.Open();
         return(client.GetCurrentUser());
     }
 }
コード例 #29
0
 /// <summary>
 /// Returns the employee that's currently logged into the server POS workstation
 /// </summary>
 /// <returns>Information about the employee. NULL if no one is currently logged into the workstation</returns>
 public Employee GetCurrentUser()
 {
     using (var client = new EmployeeServiceClient())
     {
         client.Open();
         return client.GetCurrentUser();
     }
 }
コード例 #30
0
        private void EditEmployee(int id, string name, DateTime hiredate, decimal salary, string deptname, string address)
        {
            EmployeeServiceClient esc = new EmployeeServiceClient();
            EmployeeEnt           e   = new EmployeeEnt();

            e.GetType().GetProperties();
            esc.EditEmployee(id, name, hiredate, salary, deptname, address);
        }
コード例 #31
0
 /// <summary>
 /// Verifies that an employee's credentials are valid.  Use this method to validate the login to your own program.
 /// </summary>
 /// <param name="userName">The employee's username</param>
 /// <param name="password">The employee's password</param>
 /// <returns>Information about the employee. NULL if the authentication fails.</returns>
 public Employee AuthenticateEmployee(string userName, string password)
 {
     using (var client = new EmployeeServiceClient())
     {
         client.Open();
         return(client.AuthenticateEmployee(userName, password));
     }
 }
コード例 #32
0
        public ActionResult Index(DepartmentEmployeeModel model)
        {
            var client      = new EmployeeServiceClient();
            var departments = client.GetDepartments(model.StartDate, model.EndDate, model.Name).ToList();

            model.Items = departments;
            return(View(model));
        }
コード例 #33
0
 public ActionResult Edit(int id)
 {
     using (var client = new EmployeeServiceClient())
     {
         var employee = client.RetreiveEmployeeByID(id).FirstOrDefault();
         return(View(employee));
     }
 }
コード例 #34
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         Session["escObj"] = new EmployeeServiceClient();
         lblHeader.Text    = (Session["escObj"] as EmployeeServiceClient).GetServiceProvider();
     }
 }
コード例 #35
0
 /// <summary>
 /// Verifies that an employee's credentials are valid.  Use this method to validate the login to your own program.
 /// </summary>
 /// <param name="userName">The employee's username</param>
 /// <param name="password">The employee's password</param>
 /// <returns>Information about the employee. NULL if the authentication fails.</returns>
 public Employee AuthenticateEmployee(string userName, string password)
 {
     using (var client = new EmployeeServiceClient())
     {
         client.Open();
         return client.AuthenticateEmployee(userName, password);
     }
 }
コード例 #36
0
 protected void btnGetEmployee_Click(object sender, EventArgs e)
 {
     EmployeeReference.EmployeeServiceClient esc = new EmployeeServiceClient();
     Employee emp = esc.GetEmployee(int.Parse(txtID.Text));
     txtFirstName.Text = emp.FirstName;
     txtLastName.Text = emp.LastName;
     txtStatus.Text = emp.Status;
     txtSalary.Text = emp.MonthlySalary.ToString();
 }
コード例 #37
0
        public async Task <Employee> FindEmployeeWithKACAREIDAsync(string kacare_id)
        {
            var empSvc = new EmployeeServiceClient();
            var result = await empSvc.findBy_KACARE_IdAsync(kacare_id);

            var theEmp = result.employee;

            return(GetEmployeeModel(theEmp));
        }
コード例 #38
0
 public ActionResult Delete(int id)
 {
     using (var client = new EmployeeServiceClient())
     {
         var status = client.DeleteEmployee(id);
         ViewBag.Title = status ? "Successfully Deleted" : "Failed to Delete";
         return(View());
     }
 }
コード例 #39
0
        public static async Task GetByBadgeNumber(EmployeeServiceClient client)
        {
            var res = await client.GetByBadgeNumberAsync(new Messages.GetByBadgeNumberRequest()
            {
                BadgeNumber = 2080
            });

            Console.WriteLine(res.Employee);
        }
コード例 #40
0
ファイル: Employees.aspx.cs プロジェクト: SirLopez/WCFLabb3
 protected void ButtonSave_Click(object sender, EventArgs e)
 {
     try
     {
         var host = new EmployeeServiceClient();
         host.SaveEmployee(int.Parse(TextBoxShowEmployeeID.Text), TextBoxShowFirstname.Text, TextBoxShowLastname.Text, TextBoxShowTitle.Text, TextBoxShowAddress.Text, TextBoxShowCity.Text);
     }
     catch (FaultException error)
     {
         MessageBox.Show($"Something went wrong here, please read the message for more details: {error.Message}");
     }
 }
コード例 #41
0
ファイル: Program.cs プロジェクト: apdekock/WebSite_eoh_test
 static void Main(string[] args)
 {
     while (true)
     {
         Console.WriteLine("Async get employees");
         EmployeeServiceClient sc = new EmployeeServiceClient();
         sc.GetEmployeesCompleted += Completed;
         sc.GetEmployeesAsync();
         Console.WriteLine("Done");
         Console.ReadLine();
     }
 }
コード例 #42
0
ファイル: Default.aspx.cs プロジェクト: raldholm/LAB3
        protected void GetEmployee_Button_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeeServiceClient client = new EmployeeServiceClient();
                if (client.State == CommunicationState.Faulted)
                    client = new EmployeeServiceClient();

                var employee = client.GetEmployee(int.Parse(EnterEmployeeID_TextBox.Text));
                DisplayEmployee_TextBox.Text = employee.EmployeeId.ToString();
                LastName_TextBox.Text = employee.LastName.Trim();
                FirstName_TextBox.Text = employee.LastName.Trim();
                Title_TextBox.Text = employee.Title.Trim();
                TitleOfCourtesy_TextBox.Text = employee.TitleOfCourtesy;
                BirthDate_TextBox.Text = (employee.BirthDate.ToString());
                HireDate_TextBox.Text = (employee.HireDate.ToString());
                Adress_TextBox.Text = employee.Address;
                City_TextBox.Text = employee.City;
                Region_TextBox.Text = employee.Region;
                PostalCode_TextBox.Text = employee.PostalCode;
                Country_TextBox.Text = employee.Country;
                HomePhone_TextBox.Text = employee.HomePhone;
                Extension_TextBox.Text = employee.Extension;
                Notes_TextBox.Text = employee.Notes;
                ReportsTo_TextBox.Text = employee.ReportsTo.ToString();
            }
            catch (FormatException ex)
            {
                Response.Write("Opps! Employeen finns inte! / felaktig data inmatad - ");
                Response.Write("Felmeddelande: ");
                Response.Write(ex.Message);
                Response.Write(" Börja om genom att klicka <a href='Default.aspx'>" +
                               "här.");
            }
            catch (NullReferenceException ex)
            {
                Response.Write("Opps! Employeen finns inte! - ");
                Response.Write("Felmeddelande: ");
                Response.Write(ex.Message);
                Response.Write(" Börja om genom att klicka <a href='Default.aspx'>" +
                               "här.");
            }
            catch (FaultException ex)
            {
                Response.Write("Opps! något gick fel! - ");
                Response.Write("Felmeddelande: ");
                Response.Write(ex.Message);
                Response.Write(" Börja om genom att klicka <a href='Default.aspx'>" +
                    "här.");
            }
           
        }
コード例 #43
0
 private void btnsave_Click(object sender, RoutedEventArgs e)
 {
     Entity entobject = new Entity();
     entobject.Employeeid = Convert.ToInt32(txtid.Text);
     entobject.Firstname = Convert.ToString(txtfname.Text);
     entobject.Lastname = Convert.ToString(txtlname.Text);
     entobject.Birthdate = Convert.ToString(txtbirth.Text);
     entobject.Sex = Convert.ToString(txtsex.Text);
     EmployeeReference.EmployeeServiceClient sclient = new EmployeeServiceClient();
     sclient.EmployeeAsync(entobject);
     Clear();
     txtblock.Text = "Record Inserted Successfully";
 }
コード例 #44
0
        public ActionResult Employee(string id)
        {
            var model = new DepartmentEmployeeModel();
            if (!string.IsNullOrEmpty(id))
            {
                var departmentID = short.Parse(id);
                if (departmentID > 0)
                {
                    var client = new EmployeeServiceClient();
                    var departments = client.GetEmployeesByDepartmentID(departmentID).ToList();
                    model.Items = departments;
                }
            }

            return View(model);
        }
コード例 #45
0
ファイル: Default.aspx.cs プロジェクト: raldholm/LAB3
        protected void SaveEmployee_Button_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeeServiceClient client = new EmployeeServiceClient();
                if (client.State == CommunicationState.Faulted)
                    client = new EmployeeServiceClient();

                MyEmployee employee = new MyEmployee();
                employee.EmployeeId = Convert.ToInt32(DisplayEmployee_TextBox.Text.Trim());
                employee.LastName = LastName_TextBox.Text.Trim();
                employee.FirstName = FirstName_TextBox.Text.Trim();
                employee.Title = Title_TextBox.Text.Trim();
                employee.TitleOfCourtesy = TitleOfCourtesy_TextBox.Text.Trim();
                employee.BirthDate = Convert.ToDateTime(BirthDate_TextBox.Text.Trim());
                employee.HireDate = Convert.ToDateTime(HireDate_TextBox.Text.Trim());
                employee.Address = Adress_TextBox.Text.Trim();
                employee.City = City_TextBox.Text.Trim();
                employee.Region = Region_TextBox.Text.Trim();
                employee.PostalCode = PostalCode_TextBox.Text.Trim();
                employee.Country = Country_TextBox.Text.Trim();
                employee.HomePhone = HomePhone_TextBox.Text.Trim();
                employee.Extension = Extension_TextBox.Text.Trim();
                employee.Notes = Notes_TextBox.Text.Trim();
                employee.ReportsTo = Convert.ToInt32(ReportsTo_TextBox.Text.Trim());

                client.SaveEmployee(employee);
                Response.Write("SPARAT!");
            }
            catch (FormatException ex)
            {
                Response.Write("Opps! Felaktig data inmatad - ");
                Response.Write("Felmeddelande: ");
                Response.Write(ex.Message);
                Response.Write(" Börja om genom att klicka <a href='Default.aspx'>" +
                    "här.");
            }
            catch (NullReferenceException ex)
            {
                Response.Write("Opps! Du måste sätta ett värde! - ");
                Response.Write("Felmeddelande: ");
                Response.Write(ex.Message);
                Response.Write(" Börja om genom att klicka <a href='Default.aspx'>" +
                    "här.");
            }

        }
コード例 #46
0
ファイル: Program.cs プロジェクト: chaithu563/KC_Tutorial
        static void Main(string[] args)
        {
            //Service1Client ob = new Service1Client();

            //CompositeType ct = new CompositeType();
            //ct.StringValue = "kcr";
            //ct.BoolValue = true;

            //ct = ob.GetDataUsingDataContract(ct);

            //Console.WriteLine(ct.StringValue);

            EmployeeServiceClient ob = new EmployeeServiceClient();
            Employee[] ob1=   ob.GetAllEmployeeDetails();

            Console.Read();
        }
コード例 #47
0
ファイル: Default.aspx.cs プロジェクト: Win14Therese/wcf-lab3
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                var client = new EmployeeServiceClient();
                var employeeId = 0;
                int.TryParse(TextBoxGetEmployeeID.Text, out employeeId);
                client.SaveEmployee(employeeId, TextBoxFirstName.Text, TextBoxLastName.Text, TextBoxAddress.Text, TextBoxNotes.Text);
                Label7.Text = "Employee has been updated!";

            }
            catch (FaultException ex)
            {
                MessageBox.Show($"An error has occured: {ex.Message}");

            }
        }
コード例 #48
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                lblErrorMessage.Text = "";

                if (DateTime.Parse(textBoxBirthdate.Text) >= new DateTime(1753, 01, 01) &&
                    DateTime.Parse(textBoxHiredate.Text) >= new DateTime(1753, 01, 01))
                {
                    EmployeeServiceClient client = new EmployeeServiceClient();
                    Employee employee = new Employee
                    {
                        Address = textBoxAddress.Text,
                        BirthDate = DateTime.Parse(textBoxBirthdate.Text),
                        City = textBoxCity.Text,
                        Country = textBoxCountry.Text,
                        FirstName = textBoxFirstname.Text,
                        HireDate = DateTime.Parse(textBoxHiredate.Text),
                        HomePhone = textBoxHomePhone.Text,
                        LastName = textBoxLastname.Text,
                        PostalCode = textBoxPostalCode.Text,
                        Region = textBoxRegion.Text,
                        Title = textBoxTitle.Text,
                        TitleOfCourtesy = textBoxCourtesy.Text
                    };
                    client.AddEmployee(employee);
                    ClearTextboxes();
                }
                else
                {
                    lblErrorMessage.Text = "Date can not that early!";
                }
            }
            catch (FaultException ex)
            {
                lblErrorMessage.Text = $"FaultException: {ex.Message}";
            }
            catch (Exception exception)
            {
                lblErrorMessage.Text = exception.Message;
            }

        }
コード例 #49
0
ファイル: Form1.cs プロジェクト: Montagu-Evans/WCF
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (host.State == CommunicationState.Faulted)
                {
                    host = new EmployeeServiceClient();
                }

                var getEmployee = host.GetEmployees(int.Parse(txtBoxForEmpId.Text));
                txtBox_First.Text = getEmployee.FirstName;
                txtBox_Last.Text = getEmployee.LastName;
                txtBox_Country.Text = getEmployee.Country;
                txtBox_Title.Text = getEmployee.Title;
            }
            catch (FaultException<SqlException> ex)
            {
                MessageBox.Show(ex.Detail.Message);
            }
        }
コード例 #50
0
        protected void btnCreateEmployee_Click(object sender, EventArgs e)
        {
            try
            {
                if (DateTime.Parse(txtBirthDateCreate.Text) >= new DateTime(1753, 01, 01) && DateTime.Parse(txtHireDateCreate.Text) >= new DateTime(1753, 01, 01))
                {


                    EmployeeServiceClient client = new EmployeeServiceClient();
                    Employee employee = new Employee
                    {
                        Address = txtAddressCreate.Text,
                        BirthDate = DateTime.Parse(txtBirthDateCreate.Text),
                        City = txtCityCreate.Text,
                        Country = txtCountryCreate.Text,
                        FirstName = txtFirstNameCreate.Text,
                        HireDate = DateTime.Parse(txtHireDateCreate.Text),
                        HomePhone = txtHomePhoneCreate.Text,
                        LastName = txtLastNameCreate.Text,
                        PostalCode = txtPostalCodeCreate.Text,
                        Region = txtRegionCreate.Text,
                        Title = txtTitleCreate.Text,
                        TitleOfCourtesy = txtCourtesyCreate.Text

                    };

                    client.AddEmployee(employee);
                }
                else
                {
                    lblCreateError.Text = "Date must be after 1 January 1753!";
                }

            }
            catch (Exception)
            {

                lblCreateError.Text = "All inputs must have values!";
                lblCreateError.ForeColor = Color.Red;
            }
        }
コード例 #51
0
        private void btnGetEmployee_Click(object sender, EventArgs e)
        {
            try
            {
                lblErrorMessageGet.Text = "";
                listView1.Clear();
                EmployeeServiceClient client = new EmployeeServiceClient();
                List<Employee> result = new List<Employee>();
                result.Add(client.GetEmployee((int)numericUpDown1.Value));
                client.GetEmployee((int)numericUpDown1.Value);


                foreach (var i in result)
                {
                    listView1.Items.Add(i.EmployeeID.ToString());
                    listView1.Items.Add(i.Address);
                    listView1.Items.Add(i.City);
                    listView1.Items.Add(i.Country);
                    listView1.Items.Add(i.PostalCode);
                    listView1.Items.Add(i.FirstName);
                    listView1.Items.Add(i.LastName);
                    listView1.Items.Add(i.HomePhone);
                    listView1.Items.Add(i.Region);
                    listView1.Items.Add(i.Title);
                    listView1.Items.Add(i.TitleOfCourtesy);
                    listView1.Items.Add(i.HireDate.ToString());
                    listView1.Items.Add(i.BirthDate.ToString());

                }
            }
            catch (FaultException ex)
            {
                lblErrorMessageGet.Text = $"FaultException: {ex.Message}";
            }
            catch (Exception exception)
            {
                lblErrorMessageGet.Text = exception.Message;
            }
           

        }
コード例 #52
0
ファイル: Employees.aspx.cs プロジェクト: SirLopez/WCFLabb3
 protected void ButtonFind_Click(object sender, EventArgs e)
 {
     try
     {
         var host = new EmployeeServiceClient();
         TextBoxShowEmployeeID.Text = host.GetEmployeeByID(int.Parse(TextBoxFindEmployee.Text)).EmployeeID.ToString();
         TextBoxShowFirstname.Text = host.GetEmployeeByID(int.Parse(TextBoxFindEmployee.Text)).FirstName;
         TextBoxShowLastname.Text = host.GetEmployeeByID(int.Parse(TextBoxFindEmployee.Text)).LastName;
         TextBoxShowTitle.Text = host.GetEmployeeByID(int.Parse(TextBoxFindEmployee.Text)).Title;
         TextBoxShowAddress.Text = host.GetEmployeeByID(int.Parse(TextBoxFindEmployee.Text)).Address;
         TextBoxShowCity.Text = host.GetEmployeeByID(int.Parse(TextBoxFindEmployee.Text)).City;
     }
     catch (FaultException error)
     {
         MessageBox.Show($"Something went wrong here, please read the message for more details: {error.Message}");
     }
     catch (Exception error)
     {
         MessageBox.Show($"Something went wrong here, please read the message for more details: {error.Message}");
     }
 }
コード例 #53
0
ファイル: Default.aspx.cs プロジェクト: Win14Therese/wcf-lab3
        protected void ButtonGetEmployee_Click(object sender, EventArgs e)
        {
            try
            {
                var client = new EmployeeServiceClient();
                var employeeId = 0;
                int.TryParse(TextBoxGetEmployeeID.Text, out employeeId);
                var employee = client.GetEmployee(employeeId);
                TextBoxEmployeeID.Text = employee.EmployeeId.ToString();
                TextBoxFirstName.Text = employee.FirstName;
                TextBoxLastName.Text = employee.LastName;
                TextBoxAddress.Text = employee.Address;
                TextBoxNotes.Text = employee.Notes;
                Label7.Text = "";
            }
            catch (FaultException ex)
            {

                MessageBox.Show($"An error has occured: {ex.Message}");
            }

        }
コード例 #54
0
 public WcfEmployeeService(EmployeeServiceClient service)
 {
     _service = service;
 }
コード例 #55
0
ファイル: Form1.cs プロジェクト: NellyHaglund/WCF
 public Form1()
 {
     InitializeComponent();
     host = new EmployeeServiceClient();
 }