Exemple #1
0
        public void Insert(Requirement item, bool saveImmediately = true)
        {
            if (_requirements.Exists(p=>p.Code==item.Code))
                throw new Exception("Can't insert the data as the object has already existed.");

            _requirements.Add(item);

            if (File.Exists(GetCombinePath(item)))
            {
                File.Delete(GetCombinePath(item));
            }
            using (var streamWriter = new StreamWriter(GetCombinePath(item)))
            {
                streamWriter.Write(item.Context);
            }
        }
        public static Requirement ParseJobXML(string xdata, Requirement insertRequirement)
        {
            //Remove the $ and ',' from the xdata so that I can convert the numbers to ints.

            xdata = xdata.Replace(",", "");
            //Read in the xml string
            String pattern = "(<.*?>)|(.+?(?=<|$))"; //"(?<=>)(\w*)(?=<\/)";
            //Break it up using Regex
            Regex           rgx     = new Regex(pattern);
            MatchCollection matches = rgx.Matches(xdata);


            //<xdata><statusx>Certified</statusx><travelrequired></travelrequired><annualsalary></annualsalary><placementfee></placementfee><hourlypayrate></hourlypayrate><hourlybillrate></hourlybillrate><contractduration>3 Week Assignment</contractduration></xdata>
            //Go through the matches list and assign the values between the tags to the correct spots in the DB
            if (matches.Count > 0)
            {
                foreach (Match match in matches)
                {
                    //Console.WriteLine("XML: " + match.Value);
                    var nextValue = match.NextMatch().Value;

                    if (nextValue == "</xdata>")
                    {
                        //At this point we are at the end of the xdata string and it will error if it runs again.  Once on "</xdata>" there is no NextValue to grab.
                        break;
                    }
                    else if (match.Value == "<statusx>" && nextValue != "</statusx>")
                    {
                    }
                    else if (match.Value == "<travelrequired>" && nextValue != "</travelrequired>")
                    {
                        if (nextValue.ToLower().Contains("yes"))
                        {
                            //insertRequirement.TravelRequired = true;
                        }
                        else
                        {
                            //insertRequirement.TravelRequired = false;
                        }
                    }
                    else if (match.Value == "<annualsalary>" && nextValue != "</annualsalary>")
                    {
                        nextValue = CleanMoneyString.Replace(nextValue, "");
                        insertRequirement.MinRate = Convert.ToInt32(nextValue);
                        insertRequirement.MaxRate = Convert.ToInt32(nextValue);
                    }
                    else if (match.Value == "<annualsalary>" && nextValue == "</annualsalary>")
                    {
                        insertRequirement.MinRate = Convert.ToInt32(0);
                        insertRequirement.MaxRate = Convert.ToInt32(0);
                    }
                    else if (match.Value == "<placementfee>" && nextValue != "</placementfee>")
                    {
                    }
                    else if (match.Value == "<hourlypayrate>" && nextValue != "</hourlypayrate>")
                    {
                    }
                    else if (match.Value == "<hourlybillrate>" && nextValue != "</hourlybillrate>")
                    {
                    }
                    else if (match.Value == "<contactduration>" && nextValue != "</contactduration>")
                    {
                    }
                    else if (match.Value == "<accountmanager>" && nextValue != "</accountmanager>")
                    {
                    }
                    else if (match.Value == "<Textbox1>" && nextValue != "</Textbox1>")
                    {
                    }
                }
            }
            return(insertRequirement);
        }
Exemple #3
0
        public void Update(Requirement item, bool saveImmediately = true)
        {
            _requirements.Find(requirement => requirement.Code == item.Code).Context = item.Context;

            if (File.Exists(GetCombinePath(item)))
            {
                File.Delete(GetCombinePath(item));
            }
            using (var streamWriter = new StreamWriter(GetCombinePath(item)))
            {
                streamWriter.Write(item.Context);
            }
        }
Exemple #4
0
 public void Delete(Requirement item, bool saveImmediately = true)
 {
     _requirements.Remove(item);
     File.Delete(GetCombinePath(item));
 }
Exemple #5
0
 private string GetCombinePath(Requirement item)
 {
     return Path.Combine(WorkDirectory, item.Code+Extension);
 }
 protected bool Equals(Requirement other)
 {
     return string.Equals(Code, other.Code);
 }
        //static List<KeyValuePair<int, string>> _sourceList = new List<KeyValuePair<int, string>>();


        public static void JobImport()
        {
            using (_db = new Entities())
            {
                try
                {
                    //Reads in the job record from tbJob MPLOY table:
                    var jobData = _db.ReadJob().ToList();

                    //For each job record from the job file table:
                    foreach (var requirementRecord in jobData)
                    {
                        // Sets requirement fields to job data coming from MPLOY
                        var Name      = requirementRecord.PositionTitle;
                        var vMSField  = requirementRecord.RequirementNumber;
                        var startDate = requirementRecord.StartDate;
                        var requirementDescription    = requirementRecord.Description;
                        var requirementTypeId         = requirementRecord.idJobType;
                        var requirementPriorityTypeId = requirementRecord.Priority;
                        var createDate           = requirementRecord.Created;
                        var MPLOYIdUser          = requirementRecord.iduser;
                        var MPLOYIdJob           = requirementRecord.idJob;
                        var MPLOYIdUserRecruiter = requirementRecord.idUserRecruiter;
                        var MPLOYIdUserClosed    = requirementRecord.idUserClosed;
                        var MPLOYIdUserFilled    = requirementRecord.idUserFilled;

                        //var requirementCity = String.Empty;
                        //var requirementState = String.Empty;
                        //if (!string.IsNullOrEmpty(requirementRecord.City))
                        //{

                        //}

                        //These come from XData -->  Get RequirementStatusTypeId, Get IsTravelRequired, Get MinRate, Get MaxRate, Get RequirementDuration
                        Requirement requirementData = new Requirement();

                        //Set the needed variables to a default. If there is xdata for these fields, they will be reset in the ParseJobXML:
                        requirementData.IsBackgroundCheckRequired = false;
                        requirementData.IsDrugTestRequired        = false;
                        requirementData.IsTravelRequired          = false;
                        requirementData.IsWorkFromHome            = false;

                        if (!string.IsNullOrEmpty(requirementRecord.XData))
                        {
                            requirementData = LookupValue.ParseJobXML(requirementRecord.XData, requirementData);
                        }

                        var priorityType = GetRequirementPriorityTypeId(Convert.ToInt32(requirementPriorityTypeId));

                        var reqStatusTypeId = GetRequirementStatusTypeId(requirementRecord.Closed);

                        var insertRequirement = _db.InsertRequirement(
                            Name
                            , requirementDescription
                            , vMSField
                            , requirementTypeId
                            , priorityType
                            , 3
                                << << << < HEAD
                                , null
                                , null
                                == == == =
                                , requirementRecord.City
                                , requirementRecord.State
                                >> >> >> > 9dc0ab1491ec17863937115775e8178ebadf2f1e
                                , 3
                                , 11
                                , requirementData.PaymentTermTypeId
                                , requirementRecord.Created
                                , null
                                , null
                                , null
                                , requirementRecord.Closed
                                , requirementData.MinRate
                                , requirementData.MaxRate
                                , requirementData.Budget
                                , requirementData.Duration
                                , requirementData.ContractDetails
                                , requirementData.IsTravelRequired
                                , requirementData.IsDrugTestRequired
                                , requirementData.IsBackgroundCheckRequired
                                , requirementData.IsWorkFromHome
                                , createDate
                                , 0
                                , MPLOYIdJob
                                , requirementRecord.idContactManager
                                , MPLOYIdUserFilled
                                , MPLOYIdUserClosed
                                , MPLOYIdUserRecruiter
                                , MPLOYIdUser).ToList();

                        //Get the Requirement Info:
                        //var reqInfo = _db.FindRequirementInfo(requirementRecord.idJob).ToList();

                        foreach (var item in insertRequirement)
                        {
                            _requirementId = item.Id;
                        }


                        if (!string.IsNullOrEmpty(requirementRecord.InternalNote))
                        {
                            var requirementNoteId = _db.InsertRequirementNote(_requirementId, requirementRecord.InternalNote, createDate, 0);
                        }
                        //Store the Closed Reason from Mploy as a RequirementNote:
                        if (!string.IsNullOrEmpty(requirementRecord.ClosedReason))
                        {
                            //Add a new requirement note record for the closed reason, append "Closed Reason" to the front for clarity of where the note came from in the MPLOY db:
                            var reqClosedReasonNote = "Closed Reason: " + requirementRecord.ClosedReason;
                            var requirementNoteId   = _db.InsertRequirementNote(_requirementId, reqClosedReasonNote, createDate, 0);
                        }


                        //*********************** Create the RequirementCustomer records ****************
                        //The idContact on the Requirement should be associated to a customer. Create that requirementCustomer association here.
                        //It will be updated during the HiringActivity import if there is a newer association from teh hiring activities.

                        var returnedIds = _db.GetRequirementContactAssociation(requirementRecord.idJob,
                                                                               requirementRecord.idContactManager);

                        //Find the customeid in intersect that matches the mploy contact
                        var errorString = string.Empty;
                        var personId    = -1;
                        foreach (var result in returnedIds)
                        {
                            _requirementId = Convert.ToInt32(result.jobId);
                            _candidateId   = Convert.ToInt32(result.candidateId);
                            _customerId    = Convert.ToInt32(result.customerId);
                            personId       = Convert.ToInt32(result.personId);
                            errorString    = Convert.ToString(result.errorString);
                        }
                        //***** This RequirementCustomer Relationship is populated during the Requirement import process *****
                        //Insert the new record into the RequirementCustomer table if the _customerId is not null:
                        if (_customerId != 0)
                        {
                            var requirementCustomer = _db.InsertRequirementCustomer(_requirementId, _customerId, true, 0, requirementRecord.Created, requirementRecord.iduser);
                        }


                        Debug.WriteLine("\n" + "Requirement imported: " + MPLOYIdJob + " : " + Name + " CustomerId: " + _customerId);
                    }
                }
                catch
                (Exception ex)
                {
                    new LogWriterFactory().Create().Write(ex.Expand("Error occured with RequirementId: " + _requirementId));
                }
            }
        }