public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Employer theEmployer = context.Employers.Find(addJobViewModel.EmployerId);
                Job      newJob      = new Job
                {
                    Name      = addJobViewModel.Name,
                    Employer  = theEmployer,
                    JobSkills = new List <JobSkill>()
                };

                foreach (string skill in selectedSkills)
                {
                    JobSkill jobskill = new JobSkill
                    {
                        JobId   = newJob.Id,
                        SkillId = Int32.Parse(skill)
                    };
                    newJob.Add(jobskill);
                    context.JobSkills.Add(jobskill);
                }

                context.Jobs.Add(newJob);
                context.SaveChanges();

                return(Redirect("/Home"));
            }
            List <Employer> employers          = context.Employers.ToList();
            List <Skill>    skills             = context.Skills.ToList();
            AddJobViewModel newAddJobViewModel = new AddJobViewModel(employers, skills);

            return(View("AddJob", newAddJobViewModel));
        }
        private void AddJob_Click_1(object sender, EventArgs e)
        {
            JobModel jmodel = new JobModel();

            if (0 != job.Get_Item("Name", JobText.Text, ConditionType.Equal).Id)
            {
                MessageBox.Show("Такая должность уже существует");
                JobText.Clear();
            }
            else
            {
                JobModel model = new JobModel();
                model.Name = JobText.Text;
                job.Add(model);
                MessageBox.Show("Запись внесена");
                JobText.Clear();
            }
        }
示例#3
0
        /// <summary>
        /// 添加岗位信息
        /// 调用jobService完成添加
        /// 根据返回结果判断是否成功
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void dvJob_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            JobInfo jobInfo = new JobInfo();

            jobInfo.No   = (dvJob.Rows[0].Controls[1].Controls[0] as TextBox).Text.Trim();
            jobInfo.Name = (dvJob.Rows[1].Controls[1].Controls[0] as TextBox).Text.Trim();
            bool addResult = jobService.Add(jobInfo);

            if (addResult)
            {
                gvJob.DataSource = jobService.Query(null);
                gvJob.DataBind();
            }
            else
            {
                string script = "<script> alert('添加的信息已存在,请检查!') </script>";
                Page.RegisterStartupScript("", script);
            }
        }
示例#4
0
        public void ForceSet()
        {
            this.Name = "张无忌";
            if (!Ls.ok(Job))
            {
                Job = new List <Tuple <string, string> >();
                Job.Add(new Tuple <string, string>("2010", "志愿者工作-01"));
                Job.Add(new Tuple <string, string>("2015", "志愿者工作-02"));
            }

            if (Book == null)
            {
                Book.AddItem(new UserBook()
                {
                    Number = 0, Name = "三国演义", Page = 5000, Price = 200
                });
            }
            Book.AddItem(new UserBook()
            {
                Number = 1, Name = "红楼梦", Page = 8000, Price = 260
            });
            Book.AddItem(new UserBook()
            {
                Number = 2, Name = "西游记", Page = 9000, Price = 180
            });
            Book.AddItem(new UserBook()
            {
                Number = 3, Name = "水浒传", Page = 2000, Price = 100
            });
            Book.AddItem(new UserBook()
            {
                Name = "C#", Page = 1000, Price = 80
            });
            Book.AddItem(new UserBook()
            {
                Number = 15, Name = "JAVA", Page = 1200, Price = 20.99
            });
            Book.OrderByNumber();


            Job.Add(new Tuple <string, string>("2010", "志愿者工作-99"));
        }
示例#5
0
        /*
         * Load and parse data from job_data.csv
         */
        private static void LoadData()
        {
            if (IsDataLoaded)
            {
                return;
            }

            List <string[]> rows = new List <string[]>();

            using (StreamReader reader = File.OpenText("job_data.csv"))
            {
                while (reader.Peek() >= 0)
                {
                    string   line      = reader.ReadLine();
                    string[] rowArrray = CSVRowToStringArray(line);
                    if (rowArrray.Length > 0)
                    {
                        rows.Add(rowArrray);
                    }
                }
            }

            string[] headers = rows[0];
            rows.Remove(headers);

            // Parse each row array into a more friendly Dictionary
            foreach (string[] row in rows)
            {
                Job rowDict = new Job();

                for (int i = 0; i < headers.Length; i++)
                {
                    rowDict.Add(headers[i], row[i]);
                }
                AllJobs.Add(rowDict);
            }

            IsDataLoaded = true;
        }
示例#6
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Job.Clear();
                var Jobs = await DataStore.GetItemsAsync(true);

                foreach (var item in Jobs)
                {
                    Job.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#7
0
        public void SetDefinitionModel(Resource resource, IEnumerable <CMSDDocumentDataSectionJob> CMSDjobs)
        {
            foreach (ResourceProperty resourceProperty in resource.Property)
            {
                if (resourceProperty != null)
                {
                    switch (resourceProperty.Name)
                    {
                    case "MTTR":
                        var distsource = resourceProperty.Distribution.First();
                        MTTR.Distribution = IDistribution.GetFromCmsd(distsource);
                        MTTR.Distribution.ParameterConverter.UnitType = GeneralConverter.GetInstance(resourceProperty.Unit);
                        break;

                    case "MTBF":
                        distsource        = resourceProperty.Distribution.First();
                        MTBF.Distribution = IDistribution.GetFromCmsd(distsource);
                        MTBF.Distribution.ParameterConverter.UnitType = GeneralConverter.GetInstance(resourceProperty.Unit);
                        break;

                    case "Capacity":
                        try
                        {
                            Capacity = Int32.Parse(resourceProperty.Value);
                        }
                        catch
                        {
                        }
                        break;

                    case "Speed":
                        try
                        {
                            Speed = Int32.Parse(resourceProperty.Value, CultureInfo.InvariantCulture);
                        }
                        catch
                        {
                        }
                        break;

                    case "DistanceToNode":
                        try
                        {
                            DistansToNode = int.Parse(resourceProperty.Value, CultureInfo.InvariantCulture);
                        }
                        catch
                        { }
                        break;
                    }
                }
            }

            ProcessName = resource.Name;

            AddConsumption(resource.Property.FirstOrDefault(t => t.Name.StartsWith("Idle")), Idle);
            AddConsumption(resource.Property.FirstOrDefault(t => t.Name.StartsWith("Off")), Off);
            AddConsumption(resource.Property.FirstOrDefault(t => t.Name.StartsWith("Down")), Down);

            Job.Clear();
            var cmsdDocumentDataSectionJobs = CMSDjobs as IList <CMSDDocumentDataSectionJob> ?? CMSDjobs.ToList();

            foreach (var sectionJob in cmsdDocumentDataSectionJobs.Where(t => t.Identifier.StartsWith("BaseJob")))
            {
                var job = new Job()
                {
                    Name = sectionJob.Identifier.Remove(0, 7).Replace(ProcessName, "")
                };
                AddConsumption(resource.Property.FirstOrDefault(t => t.Name.Contains(job.Name)), job.State);
                job.Subjobs.Clear();
                foreach (var pointSubJob in sectionJob.SubJob)
                {
                    var cmsdSubJob = cmsdDocumentDataSectionJobs.FirstOrDefault(t => t.Identifier == pointSubJob.JobIdentifier);
                    if (cmsdSubJob != null)
                    {
                        var sub = new SubJob()
                        {
                            Description  = cmsdSubJob.Description,
                            Distribution = IDistribution.GetFromCmsd(cmsdSubJob.PlannedEffort.ProcessingTime.Distribution)
                        };
                        sub.Distribution.ParameterConverter.UnitType = GeneralConverter.TimeConverters.FirstOrDefault(
                            t => t.ToString() == cmsdSubJob.PlannedEffort.ProcessingTime.TimeUnit);
                        job.Subjobs.Add(sub);
                    }
                }

                Job.Add(job);
                LoadDistances(new [] { this }, new [] { resource });
            }
            foreach (var reloadJob in _reloadJobs)
            {
                var productcollection = reloadJob.Key.Nodes.Where(t => t.Key.ResourceModel == this).GetEnumerator();
                foreach (var jobstring in reloadJob.Value)
                {
                    productcollection.MoveNext();
                    productcollection.Current.Value = Job.First(t => t.Name == jobstring);
                }
            }
        }
示例#8
0
        public void SaveParsedJob(ParsedJob jobParsed)
        {
            if (!Company.Any(f => f.Name.Equals(jobParsed.ComapnyName.Trim())))
            {
                Company.Add(new Company()
                {
                    Name = jobParsed.ComapnyName.Trim()
                });
                SaveChanges();
            }
            int idCompany = Company.First(c => c.Name.Equals(jobParsed.ComapnyName.Trim())).id;

            if (!Region.Any(r => r.Name.Equals(jobParsed.Region.Trim())))
            {
                Region.Add(new Region()
                {
                    Name = jobParsed.Region.Trim()
                });
                SaveChanges();
            }
            int idRegion = Region.First(r => r.Name.Equals(jobParsed.Region.Trim())).id;

            if (!Portal.Any(r => r.Name.Equals(jobParsed.Portal.Trim())))
            {
                Portal.Add(new Portal()
                {
                    Name = jobParsed.Portal.Trim()
                });
                SaveChanges();
            }
            int idPortal = Portal.First(r => r.Name.Equals(jobParsed.Portal.Trim())).id;

            if (!Job.Any(r => r.WebIdJob.Equals(jobParsed.WebIdJob.Trim()) && r.idPortal.Equals(idPortal)))
            {
                Job.Add(new Job()
                {
                    Name           = jobParsed.JobName.Trim(),
                    idCompany      = idCompany,
                    idRegion       = idRegion,
                    Description    = jobParsed.Description,
                    ParsedDateTime = DateTime.Now,
                    Url            = jobParsed.JobUrl,
                    Salary         = jobParsed.Salary,
                    WebIdJob       = jobParsed.WebIdJob,
                    idPortal       = idPortal
                });
                SaveChanges();
            }
            // int idJob = Job.Where(r => r.WebIdJob.Equals(jobParsed.WebIdJob.Trim())).First().id;
            if (jobParsed.Categories != null)
            {
                foreach (string keyword in jobParsed.Categories)
                {
                    if (!JobCategory.Any(r => r.Name.Equals(keyword.Trim())))
                    {
                        JobCategory.Add(new JobCategory()
                        {
                            Name = keyword.Trim()
                        });
                        SaveChanges();
                    }

                    var jobCategory = JobCategory.First(r => r.Name.Equals(keyword.Trim()));

                    var job = Job.First(r => r.WebIdJob.Equals(jobParsed.WebIdJob.Trim()));

                    if (!job.JobCategory.Any(jc => jc.Name.Equals(keyword.Trim())))
                    {
                        job.JobCategory.Add(jobCategory);
                        SaveChanges();
                    }
                }
            }
        }
示例#9
0
        public void IncompleteJobSpecTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            string targetJob = "testJob";

            for (int i = 0; i < 2; i++) // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 11, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        try
                        {
                            Job u = new Job();
                            u.Id = targetJob;
                            u.Add("Status", "open");
                            u.Add("User", "admin");
                            Job job = rep.CreateJob(u, null);
                        }
                        catch (P4Exception e)
                        {
                            Assert.AreEqual(822153261, e.ErrorCode, "Error in job specification.\nMissing required field 'Description'.\n");
                        }

                        try
                        {
                            Job u = new Job();
                            u.Id = targetJob;
                            u.Add("Status", "open");
                            u.Add("Description", "this is a test job");
                            Job job = rep.CreateJob(u, null);
                        }
                        catch (P4Exception e)
                        {
                            Assert.AreEqual(822153261, e.ErrorCode, "Error in job specification.\nMissing required field 'User'.\n");
                        }

                        try
                        {
                            Job u = new Job();
                            u.Id = targetJob;
                            u.Add("Status", "open");
                            u.Add("User", "admin");
                            Job job = rep.CreateJob(u, null);
                        }
                        catch (P4Exception e)
                        {
                            Assert.AreEqual(822153261, e.ErrorCode, "Error in job specification.\nMissing required field 'Status'.\n");
                        }
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }
示例#10
0
        public void CreateJobTest()
        {
            bool unicode = false;

            string uri       = "localhost:6666";
            string user      = "******";
            string pass      = string.Empty;
            string ws_client = "admin_space";

            string targetJob = "thenewjob";

            for (int i = 0; i < 2; i++)             // run once for ascii, once for unicode
            {
                Process p4d    = Utilities.DeployP4TestServer(TestDir, 7, unicode);
                Server  server = new Server(new ServerAddress(uri));
                try
                {
                    Repository rep = new Repository(server);

                    using (Connection con = rep.Connection)
                    {
                        con.UserName    = user;
                        con.Client      = new Client();
                        con.Client.Name = ws_client;

                        bool connected = con.Connect(null);
                        Assert.IsTrue(connected);

                        Assert.AreEqual(con.Status, ConnectionStatus.Connected);

                        Job u = new Job();
                        u.Id = targetJob;
                        u.Add("Status", "open");
                        u.Add("User", "admin");
                        u.Add("Description", "this is a test job");

                        Job newGuy = rep.CreateJob(u, null);

                        Job equalJob = rep.GetJob("thenewjob");

                        Assert.IsNotNull(equalJob);
                        Assert.AreEqual(equalJob.Id, newGuy.Id);

                        u    = new Job();
                        u.Id = "new";
                        u.Add("Status", "open");
                        u.Add("User", "admin");
                        u.Add("Description", "this is a test job");

                        newGuy = rep.CreateJob(u, null);

                        equalJob = rep.GetJob(newGuy.Id);

                        Assert.IsNotNull(equalJob);
                        Assert.AreEqual("job000002", newGuy.Id);

                        u    = new Job();
                        u.Id = "new";
                        u.Add("Status", "open");
                        u.Add("User", "admin");
                        u.Add("Description", "this is a test job");

                        newGuy = rep.CreateJob(u, new Options(JobCmdFlags.Input));

                        equalJob = rep.GetJob(newGuy.Id);

                        Assert.IsNotNull(equalJob);
                        Assert.AreEqual("job000003", newGuy.Id);
                        // test to confirm creating a new job without
                        // specifying .Id will not fail if there is a
                        // Job object in the spec
                        u = new Job();
                        u.Add("Job", "targetJobWithoutId");
                        u.Add("Status", "open");
                        u.Add("User", "admin");
                        u.Add("Description", "this is a test job");

                        newGuy = rep.CreateJob(u, null);

                        equalJob = rep.GetJob(u.Id);

                        Assert.IsNotNull(equalJob);
                        Assert.AreEqual("targetJobWithoutId", newGuy.Id);

                        Job testJob = rep.GetJob(u.Id, null);
                    }
                }
                finally
                {
                    Utilities.RemoveTestServer(p4d, TestDir);
                }
                unicode = !unicode;
            }
        }