예제 #1
0
        private WorkModel PopulateWorkModel()
        {
            var payment = SelectedPayment;
            int?paymentId;

            if (payment != null && Paid == true)
            {
                paymentId = payment.Id;
            }
            else
            {
                paymentId = null;
            }

            var output = new WorkModel
            {
                Id          = SelectedDate.Id,
                Hours       = double.Parse(Hours),
                Title       = Title,
                Description = Description,
                Paid        = Paid ? 1 : 0,
                PaymentId   = paymentId
            };

            return(output);
        }
예제 #2
0
        private void ReloadData()
        {
            Text = "Statistics for " + ExaminedUser.FullName;
            lvStats.Items.Clear();
            Dictionary <int, ListViewGroup> listGroups = new Dictionary <int, ListViewGroup>();

            foreach (var work in WorkModel.List(ExaminedUser))
            {
                if (!listGroups.Keys.Contains(work.ProjectId))
                {
                    listGroups[work.ProjectId] = new ListViewGroup()
                    {
                        Header = work.Project.Name
                    };
                }
                var newitem = new ListViewItem();
                newitem.Text = work.Comment;
                newitem.SubItems.Add(work.WorkType.Name);
                newitem.SubItems.Add(work.TimeFormatted);

                listGroups[work.ProjectId].Items.Add(newitem);
            }
            foreach (ListViewGroup lg in listGroups.Values)
            {
                lvStats.Groups.Add(lg);
                foreach (ListViewItem lvm in lg.Items)
                {
                    lvStats.Items.Add(lvm);
                }
            }
        }
예제 #3
0
        public WorkModel GetProfileInfo(string userName)
        {
            panconDatabaseEntities entities = new panconDatabaseEntities();

            try
            {
                Employees profile = (from p in entities.Employees
                                     where (p.Active == true) &&
                                     (p.Username == userName)
                                     select p).FirstOrDefault();

                string cont = (from c in entities.Contractors
                               where (c.ContractorId == profile.ContractorId)
                               select c.CompanyName).Single();

                WorkModel loggedProfile = new WorkModel()
                {
                    ContractorName = cont,
                    Firstname      = profile.Firstname,
                    Lastname       = profile.Lastname,
                    Phone          = profile.Phone,
                    Email          = profile.Email,
                    Picture        = profile.EmployeePicture,
                    Username       = profile.Username
                };
                return(loggedProfile);
            }
            finally
            {
                entities.Dispose();
            }
        }
        private void setControl(bool working, WorkModel workModel)
        {
            if (InvokeRequired)
            {
                this.Invoke(new Action <bool, WorkModel>(setControl), new object[] { working, workModel });
            }
            else
            {
                _mainController.DoWork(working);

                btnCreate.Enabled = !working;
                btnFolder.Enabled = !working;
                btnOutput.Enabled = !working;

                if (working == false & workModel != null)
                {
                    _workManager.LoadDataToDgv(dgvDetial, workModel, 0);
                }

                //dgvDetial.Rows.Insert(0, new object[] { true,
                //                                    workModel.WorkCreateDate,
                //                                    workModel.WorkNumber,
                //                                    workModel.CustomName,
                //                                    workModel.CustcName,
                //                                    workModel.RightDegree,
                //                                    workModel.LeftDegree,
                //                                    workModel.FrameMode,
                //                                    workModel.Degree,
                //                                    workModel.GlassType,
                //                                    workModel.AddDegree,
                //                                    workModel.CreateMan,
                //                                    workModel.Memo });
            }
        }
예제 #5
0
 public WorkpieceDrawing(WorkpieceDrawingModel drawModel, WorkModel workModel, WorkDrawingModel workDra, Point originPoint)
 {
     this.drawModel   = drawModel;
     this.workModel   = workModel;
     this.originPoint = originPoint;
     this.workDra     = workDra;
 }
예제 #6
0
        /// <summary>
        /// 获得选择工件work副本的矩阵
        /// </summary>
        /// <param name="ct"></param>
        /// <returns></returns>
        private Matrix4 GetParentWorkMatr(NXOpen.Assemblies.Component ct)
        {
            NXOpen.Assemblies.Component workComp = ct.Parent.Parent;
            WorkModel work = new WorkModel(workComp.Prototype as Part);

            return(work.Info.Matr);
        }
예제 #7
0
 public WorkpieceInfo(Part workpiece, WorkModel work)
 {
     this.workpiece = workpiece;
     this.work      = work;
     workpieceComp  = AssmbliesUtils.GetPartComp(this.work.PartTag, this.workpiece);
     this.poin      = CreateMinAndMaxPt();
 }
        public IActionResult OnGet(string title)
        {
            IEnumerable <WorkItemModel> workItems       = _resumeRepository.GetSideProjects();
            IEnumerable <string>        _availableWorks = workItems.Select(x => x.Alias);

            if (title == "idkcss")
            {
                return(RedirectToPage("IdkCss"));
            }
            else if (title == "footystats")
            {
                return(RedirectToPage("footystats"));
            }
            else if (_availableWorks.Contains(title))
            {
                WorkModel = _workRepository.GetWorkModel(title);
                if (WorkModel != null)
                {
                    return(Page());
                }
                else
                {
                    return(RedirectToPage("Index"));
                }
            }
            else
            {
                return(RedirectToPage("Index"));
            }
        }
예제 #9
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://worksheet.azurewebsites.net");
            string json = await client.GetStringAsync("/api/login?userName="******"Username:  " + ProfileInfo.UserName;
        }
예제 #10
0
        public bool CreateWorkNumber(WorkModel workModel)
        {
            bool result = false;

            ExcelPackage pkgXLS;

            if (doConnect(out pkgXLS, DefineSeting.ServerNonFinish, true))
            {
                ExcelWorksheet sheet1 = pkgXLS.Workbook.Worksheets[1]; // 取得Sheet1

                int currentRow = 1;
                if (sheet1.Dimension != null)
                {
                    currentRow = sheet1.Dimension.End.Row + 1;
                }

                foreach (var item in _stepList.OrderBy(x => x.Key).ToList())
                {
                    workModel.Step.Add(item.Key, workModel.WorkCreateDate);
                    break;
                }

                logWork("工單建立", workModel);
                setRowData(sheet1, currentRow, workModel);

                pkgXLS.Save();
                pkgXLS.Dispose();
                result = true;
            }

            return(result);
        }
예제 #11
0
        private void setRowData(ExcelWorksheet sheet, int rowIndex, WorkModel workModel)
        {
            sheet.Cells[rowIndex, _workCreateDate].Value = workModel.WorkCreateDate;
            sheet.Cells[rowIndex, _workNumber].Value     = workModel.WorkNumber;
            sheet.Cells[rowIndex, _workNo].Formula       = string.Format("\"d\"&{0}&\"d\"", sheet.Cells[rowIndex, _workNumber].Address);

            sheet.Cells[rowIndex, _customName].Value = workModel.CustomName;
            sheet.Cells[rowIndex, _custcName].Value  = workModel.CustcName;
            sheet.Cells[rowIndex, _r].Value          = workModel.RightDegree;
            sheet.Cells[rowIndex, _l].Value          = workModel.LeftDegree;

            sheet.Cells[rowIndex, _frameMode].Value = workModel.FrameMode;
            sheet.Cells[rowIndex, _degree].Value    = workModel.Degree;
            sheet.Cells[rowIndex, _glassType].Value = workModel.GlassType;
            sheet.Cells[rowIndex, _addDegree].Value = workModel.AddDegree;
            sheet.Cells[rowIndex, _createMan].Value = workModel.CreateMan;

            sheet.Cells[rowIndex, _memo].Value = workModel.Memo;

            for (int i = 0; i < workModel.Step.Count; i++)
            {
                sheet.Cells[rowIndex, _stepStart + i].Value = workModel.Step[i + 1];
            }


            string range = string.Format("{0}:{1}", sheet.Cells[rowIndex, 1].Address, sheet.Cells[rowIndex, _stepStart + _stepList.Count - 1].Address);

            sheet.Cells[range].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
            sheet.Cells[range].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
            sheet.Cells[range].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
            sheet.Cells[range].Style.Border.Right.Style  = ExcelBorderStyle.Thin;
        }
예제 #12
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://worksheet.azurewebsites.net");
                string json = await client.GetStringAsync("/api/employee?employeeName=" + employeeId);

                WorkModel chosenWorkModel = JsonConvert.DeserializeObject <WorkModel>(json);
                FirstNameEntry.Text   = chosenWorkModel.FirstName;
                LastNameEntry.Text    = chosenWorkModel.LastName;
                PhoneNumberEntry.Text = chosenWorkModel.PhoneNumber.ToString();
                EmailEntry.Text       = chosenWorkModel.Email;

                if (chosenWorkModel.Picture != null)
                {
                    byte[]      photo  = chosenWorkModel.Picture;
                    Stream      stream = new MemoryStream(photo);
                    ImageSource img    = ImageSource.FromStream(() => stream);
                    EmployeePhoto.Source = img;
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.GetType().Name + ": " + ex.Message;
                FirstNameEntry.Text = errorMessage;
            }
        }
예제 #13
0
        public WorkModel GetProfileInfo(string userName)
        {
            WorksheetEntities entities = new WorksheetEntities();

            try
            {
                Employee profile = (from p in entities.Employees where (p.Active == true) && (p.Username == userName) select p).FirstOrDefault();
                string   cont    = (from c in entities.Contractors where (c.Id_Contractor == profile.Id_Contractor) select c.CompanyName).Single();


                WorkModel loggedProfile = new WorkModel()
                {
                    ContractorName = cont,
                    FirstName      = profile.FirstName,
                    LastName       = profile.LastName,
                    PhoneNumber    = int.Parse(profile.PhoneNumber),
                    Email          = profile.EmailAddress,
                    Picture        = profile.EmployeePicture,
                    UserName       = profile.Username
                };

                return(loggedProfile);
            }

            finally
            {
                entities.Dispose();
            }
        }
        public WorkModel GetWork(int id)
        {
            var work      = _repositoryManager.Works.GetSingle(id);
            var creator   = _repositoryManager.Users.GetSingle(work.CreatorId.Value);
            var location  = _repositoryManager.Locations.GetSingle(creator.LocationId.Value);
            var feedbacks = _repositoryManager.Feedbacks.GetAll().Where(f => f.ReceiverId == creator.Id);
            var workKeys  = _repositoryManager.WorkKeys.GetAll().Where(k => k.WorkId == id).Select(wk => wk.KeyId);
            var keys      = _repositoryManager.Keys.GetAll().Where(k => workKeys.Any(i => i == k.Id));

            var workModel = new WorkModel()
            {
                Creator = new UserModel
                {
                    Id        = creator.Id,
                    Firstname = creator.Firstname,
                    Lastname  = creator.Lastname,
                    Location  = new LocationModel
                    {
                        Id      = location.Id,
                        Country = location.Country
                    },
                    TimePlusUTC = creator.TimePlusUTC,
                },
                Description = work.Description,
                Header      = work.Header,
                WorkKeys    = keys.Select(k => k.Name).ToList(),
                Feedbacks   = feedbacks.Select(f => new FeedbackModel
                {
                    Message = f.Message,
                    Rating  = f.Rating
                }).ToList(),
            };

            return(workModel);
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://worksheet.azurewebsites.net");
                string json = await client.GetStringAsync("/api/contractor?contractorName=" + contractorName);

                WorkModel chosenCustomerModel = JsonConvert.DeserializeObject <WorkModel>(json);
                ContractorNameEntry.Text = chosenCustomerModel.ContractorName;
                ContactPersonEntry.Text  = chosenCustomerModel.ContractorContactPerson;
                PhoneNumberEntry.Text    = chosenCustomerModel.ContractorPhoneNumber;
                EmailEntry.Text          = chosenCustomerModel.ContractorEmail;
                VatIDEntry.Text          = chosenCustomerModel.VatId;
                HourlyRateEntry.Text     = chosenCustomerModel.HourlyRate;
                contID = chosenCustomerModel.ContractorId;
            }
            catch (Exception ex)
            {
                string errorMessage = ex.GetType().Name + ": " + ex.Message;
                ContractorNameEntry.Text = errorMessage;
            }
        }
예제 #16
0
        public ActionResult FindAllCondidate()
        {
            List <Condidate> LCondidate       = new List <Condidate>();
            List <WorkModel> LWorkModel       = new List <WorkModel>();
            CondidateReposit condidateReposit = new CondidateReposit();

            LCondidate = condidateReposit.GetAll();
            foreach (var item in LCondidate)
            {
                WorkModel model = new WorkModel();
                model.modelCondidate.FIO        = item.FIO;
                model.modelCondidate.DataBirth  = item.DataBirth;
                model.modelCondidate.experience = item.experience;
                model.modelCondidate.Skill      = item.Skill;
                model.modelCondidate.Telephone  = item.Telephone;
                model.modelCondidate.City       = item.City;
                LWorkModel.Add(model);
            }
            if (LCondidate.Count == 0)
            {
                ModelState.AddModelError("", "Кондидатов для данной вакансии не найдено ( поиск идёт по требованию навыка )");
            }

            return(View("FindCondidate", LWorkModel));
        }
예제 #17
0
        public ActionResult FindVacancyALL()
        {
            List <Vacancy>   LVacancy       = new List <Vacancy>();
            List <WorkModel> LWorkModel     = new List <WorkModel>();
            VacancyReposit   vacanceReposit = new VacancyReposit();

            LVacancy = vacanceReposit.GetVacancyAll();
            foreach (var item in LVacancy)
            {
                WorkModel model = new WorkModel();
                model.modelVacancy.Name        = item.Name;
                model.modelVacancy.Description = item.Description;
                model.modelVacancy.Time        = item.Time;
                model.modelVacancy.CompanyName = item.CompanyName;
                model.modelVacancy.Request     = item.Request;
                model.modelVacancy.Pay         = item.Pay;
                model.modelVacancy.NameAutor   = item.NameAutor;
                model.modelVacancy.OpenVacancy = item.OpenVacancy;
                LWorkModel.Add(model);
            }
            if (LVacancy.Count == 0)
            {
                ModelState.AddModelError("", "Вакансий не найдено");
            }
            return(View("FindVacancy", LWorkModel));
        }
예제 #18
0
        public ElectrodeBomBuilder(ElectrodeInfo info, AssembleModel assemble)
        {
            this.info = info;
            foreach (ElectrodeModel model in assemble.Electrodes)
            {
                if (model.EleInfo.EleName == info.EleName)
                {
                    Model.Add(model);
                }
            }
            foreach (WorkModel wk in assemble.Works)
            {
                if (wk.WorkNumber == Model[0].WorkNumber)
                {
                    work = wk;
                }
            }
            EletrodePreparation pre;

            if (info.Material.Equals("紫铜"))
            {
                pre = new EletrodePreparation("CuLength", "CuWidth");
            }
            else
            {
                pre = new EletrodePreparation("WuLength", "WuWidth");
            }
            int[] temp = new int[2] {
                info.Preparation[0], info.Preparation[1]
            };
            info.IsPreparation = pre.IsPreCriterion(temp);
        }
예제 #19
0
        // GET: Getting model
        public WorkModel GetCustomerModel(string customerName)
        {
            WorksheetEntities entities = new WorksheetEntities();

            try
            {
                string   chosenCustomer = customerName;
                Customer customer       = (from c in entities.Customers where (c.Active == true) && (c.CustomerName == chosenCustomer) select c).FirstOrDefault();

                WorkModel chosenCustomerModel = new WorkModel()
                {
                    CustomerName        = customer.CustomerName,
                    ContactPerson       = customer.ContactPerson,
                    CustomerPhoneNumber = customer.PhoneNumber,
                    CustomerEmail       = customer.EmailAddress,
                    CustomerId          = customer.Id_Customer
                };

                return(chosenCustomerModel);
            }

            finally
            {
                entities.Dispose();
            }
        }
        private void UpdateData()
        {
            while (true)
            {
                if (_inserWorkModel.Count == 0)
                {
                    _idleCommandSendEvent.WaitOne();
                }
                else
                {
                    WorkModel workModel = _inserWorkModel.Dequeue();

                    if (_workManager.UpdateWorkNumber(workModel, int.Parse(DefineSeting.LoginStepNo)))
                    {
                        // 如果是最後一站,將未完成的搬到已完成
                        if (int.Parse(DefineSeting.LoginStepNo) == _workManager.StepList.Count)
                        {
                            if (_workManager.changeToFinish(tbxWorkNumber.Text))
                            {
                            }
                        }

                        _currentWorkModel.Remove(workModel);

                        setControl(false, workModel);
                    }
                }
            }
        }
예제 #21
0
        private WorkModel getRowData(ExcelWorksheet sheet, int rowIndex, Dictionary <int, string> stepList)
        {
            WorkModel model = new WorkModel();

            model.WorkCreateDate = sheet.GetValue <DateTime>(rowIndex, _workCreateDate);
            model.WorkNumber     = sheet.Cells[rowIndex, _workNumber].Text;
            model.CustomName     = sheet.Cells[rowIndex, _customName].Text;
            model.CustcName      = sheet.Cells[rowIndex, _colcustcName].Text;//新加入
            model.RightDegree    = sheet.Cells[rowIndex, _r].Text;
            model.LeftDegree     = sheet.Cells[rowIndex, _l].Text;
            model.Memo           = sheet.Cells[rowIndex, _memo].Text;

            model.FrameMode = sheet.Cells[rowIndex, _frameMode].Text;
            model.Degree    = sheet.Cells[rowIndex, _degree].Text;
            model.GlassType = sheet.Cells[rowIndex, _glassType].Text;
            model.AddDegree = sheet.Cells[rowIndex, _addDegree].Text;
            model.CreateMan = sheet.Cells[rowIndex, _createMan].Text;


            model.Step = new Dictionary <int, DateTime>();
            for (int i = 0; i < stepList.Count; i++)
            {
                model.Step.Add(i + 1, sheet.GetValue <DateTime>(rowIndex, _stepStart + i));
            }



            return(model);
        }
예제 #22
0
        public WorkModel GetModel(string employeeName)
        {
            panconDatabaseEntities entities = new panconDatabaseEntities();

            try
            {
                string    chosenEmployee = employeeName;
                Employees employee       = (from e in entities.Employees
                                            where (e.Active == true) &&
                                            (e.EmployeeId.ToString() == chosenEmployee)
                                            select e).FirstOrDefault();

                WorkModel chosenEmployeeModel = new WorkModel()
                {
                    Firstname = employee.Firstname,
                    Lastname  = employee.Lastname,
                    Phone     = employee.Phone,
                    Email     = employee.Email,
                    Picture   = employee.EmployeePicture
                };
                return(chosenEmployeeModel);
            }
            finally
            {
                entities.Dispose();
            }
        }
예제 #23
0
        public bool UpdateWorkNumber(WorkModel workModel, int stepNumber)
        {
            bool result = false;

            ExcelPackage pkgXLS;

            if (result = doConnect(out pkgXLS, DefineSeting.ServerNonFinish, true))
            {
                ExcelWorksheet sheet1 = pkgXLS.Workbook.Worksheets[1]; // 取得Sheet1

                for (int rowIndex = 2; rowIndex <= sheet1.Dimension.End.Row; rowIndex++)
                {
                    if (sheet1.Cells[rowIndex, _workNumber].Text == workModel.WorkNumber)
                    {
                        logWork(DefineSeting.LoginStepName + "完成", workModel);
                        sheet1.Cells[rowIndex, _stepStart + stepNumber - 1].Value = workModel.Step[stepNumber];
                        break;
                    }
                }

                pkgXLS.Save();
                pkgXLS.Dispose();
            }

            return(result);
        }
예제 #24
0
    public HttpResponseMessage Xamarin_reg(WorkModel input)
    {
        try
        {
            var same = entities.Employees.Any(u => u.Username == input.Username);
            if (same == true)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, "Username is in use, try a."
                                              + same.ToString()));
            }
            else
            {
                Employees employee = new Employees();
                employee.Firstname = input.Firstname;
                employee.Lastname  = input.Lastname;
                employee.Phone     = input.Phone;
                employee.Email     = input.Email;
                employee.Username  = input.Username;
                employee.Password  = input.Password;
                entities.Employees.Add(employee);
                entities.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.Accepted, "Successfully Created"));
            }
        }
        finally
        {
            entities.Dispose();
        }
    }
예제 #25
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                Session.UndoMarkId markId;
                markId = Session.GetSession().SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "跑位");
                WorkModel work = new WorkModel(workPart);
                NXOpen.Assemblies.Component eleCt = this.SeleElePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;

                PositionElectrodeBuilder builder = new PositionElectrodeBuilder(eleCt, work);
                if (this.double_x.Value == 0 && this.double_y.Value == 0 && this.double_z.Value == 0)
                {
                    return(1);
                }
                else
                {
                    Vector3d vec  = new Vector3d(this.double_x.Value, this.double_y.Value, this.double_z.Value);
                    bool     isok = builder.PositionBuilder(vec);
                    if (!isok)
                    {
                        theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "电极跑位错误!");
                    }
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
        public async Task <IActionResult> AddNew(int id)
        {
            if (_signInManager.Context.User.Identity.IsAuthenticated)
            {
                if (HttpContext.User.IsInRole("Hr"))
                {
                    await Initializer.InitialLayout("Work Places", ViewBag, _db, _signInManager, "Add New work places");

                    if (id == 0)
                    {
                        return(BadRequest());
                    }
                    Employee employee = await _db.Employees
                                        .Where(e => e.Id == id)
                                        .FirstOrDefaultAsync();

                    List <Holding> holdings = await _db.Holdings.ToListAsync();

                    List <Department> departments = await _db.Departments.ToListAsync();

                    WorkModel model = new WorkModel
                    {
                        EmployeeId  = employee.Id,
                        Employee    = employee,
                        Holdings    = holdings,
                        Departments = departments
                    };
                    return(View(model));
                }
            }
            return(RedirectToAction("Forbidden", "Error"));
        }
예제 #27
0
        // GET: Trying to return model
        public WorkModel GetModel(string workName)
        {
            WorksheetEntities entities = new WorksheetEntities();

            try
            {
                string         chosenWorkId   = workName;
                WorkAssignment chosenWorkData = (from cw in entities.WorkAssignments
                                                 where (cw.Active == true) && (cw.Id_WorkAssignment.ToString() == chosenWorkId)
                                                 select cw).FirstOrDefault();

                WorkModel chosenWorkModel = new WorkModel()
                {
                    WorkTitle   = chosenWorkData.Title,
                    Description = chosenWorkData.Description,
                    Deadline    = chosenWorkData.Deadline.Value
                };

                return(chosenWorkModel);
            }

            finally
            {
                entities.Dispose();
            }
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://worksheet.azurewebsites.net");
                string json = await client.GetStringAsync("/api/work?workName=" + workId);

                WorkModel chosenWorkModel = JsonConvert.DeserializeObject <WorkModel>(json);
                TitleLabel.Text       = chosenWorkModel.WorkTitle;
                DescriptionLabel.Text = chosenWorkModel.Description;
                DeadlineLabel.Text    = chosenWorkModel.Deadline.ToString();
            }
            catch (Exception ex)
            {
                string errorMessage = ex.GetType().Name + ": " + ex.Message;
                TitleLabel.Text = errorMessage;
            }

            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("https://worksheet.azurewebsites.net");
                string json = await client.GetStringAsync("/api/employee");

                string[] employees = JsonConvert.DeserializeObject <string[]>(json);
                EmployeePicker.ItemsSource = employees;
            }
            catch
            {
            }
        }
예제 #29
0
        public WorkModel GetCustomerModel(string customerName)
        {
            panconDatabaseEntities entities = new panconDatabaseEntities();

            try
            {
                string    chosenCustomer = customerName;
                Customers customer       = (from c in entities.Customers
                                            where (c.Active == true) &&
                                            (c.CustomerName == chosenCustomer)
                                            select c).FirstOrDefault();

                WorkModel chosenCustomerModel = new WorkModel()
                {
                    CustomerName  = customer.CustomerName,
                    ContactPerson = customer.ContactPerson,
                    CustomerPhone = customer.Phone,
                    CustomerEmail = customer.Email,
                    CustomerId    = customer.CustomerId
                };
                return(chosenCustomerModel);
            }
            finally
            {
                entities.Dispose();
            }
        }
예제 #30
0
        private WorkService()
        {
            AddressModel address = new AddressModel()
            {
                City       = "Lisboa",
                Country    = "Portugal",
                PostalCode = "2790-485",
                Street     = "Rua das cenas"
            };

            WorkModel work1 = new WorkModel()
            {
                Id             = 1,
                Name           = "Instituto Agronomia",
                JobDescription = "Forestry",
                Picture        = "https://www.isa.ulisboa.pt/files/logo_green.png",
                Address        = address
            };
            WorkModel work2 = new WorkModel()
            {
                Id             = 2,
                Name           = "Cintell Corp",
                JobDescription = "Marketing",
                Picture        = "http://cintell.net/wp/wp-content/uploads/2015/01/Cintell_Logo_Print_v1.0.png",
                Address        = address
            };

            works.Add(work1);
            works.Add(work2);
        }
예제 #31
0
        public List<WorkModel> GetForPassport(int psid)
        {
            WorkModel m1 = new WorkModel() {
                BN = "Test BN",
                BNId = 1,
                Buy = 20,
                Comments = "Test",
                Cost = 25,
                GUID = "---",
                Id = 444,
                Marga = 37,
                Marga_Percent = 45,
                Executor = "Иван и сын",
                KomCost = 33,
                Nalog = 13,
                ResType = "Res1",
                ResTypeId = 1,
                WorksName = "Копать",
                WorkType = 0

            };

            WorkModel m2 = new WorkModel()
            {
                BN = "Test BN 2",
                BNId = 2,
                Buy = 20,
                Comments = "Test",
                Cost = 25,
                GUID = "---",
                Id = 444,
                Marga = 37,
                Marga_Percent = 45,
                Executor = "Иван и сын",
                KomCost = 33,
                Nalog = 13,
                ResType = "Res1",
                ResTypeId = 1,
                WorksName = "Копать",
                WorkType = 0

            };

            List<WorkModel> works = new List<WorkModel>() { m1, m2 };
            return works;
            //throw new NotImplementedException();
        }
예제 #32
0
        public void verify_attributes_compilation_caching_indirectly()
        {
            const int testLoops = 10;
            var model = new WorkModel();
            var context = new ValidationContext(model);

            model.Value = 0; // tests asserthat
            var nonCached = MeasureExecutionTime(() => Validator.TryValidateObject(model, context, null, true));
            for (var i = 0; i < testLoops; i++)
            {
                var cached = MeasureExecutionTime(() => Validator.TryValidateObject(model, context, null, true));
                Assert.True(nonCached > cached);
            }

            model.Value = null; // tests requiredif
            nonCached = MeasureExecutionTime(() => Validator.TryValidateObject(model, context, null, true));
            for (var i = 0; i < testLoops; i++)
            {
                var cached = MeasureExecutionTime(() => Validator.TryValidateObject(model, context, null, true));
                Assert.True(nonCached > cached);
            }
        }