private void GetPositionByID() { List <Performance.Error> errors = new List <Performance.Error>(); PositionViewModel pvm = null; try { Position p = BllInstance.PositionBllInstance.GetPositionById(Convert.ToInt32(_Context.Request.Params["Pkid"]), _Operator); pvm = new PositionViewModel(p); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"item\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(pvm), JsonConvert.SerializeObject(errors)); }
private void GetPositionHistoryByID() { List <Performance.Error> errors = new List <Performance.Error>(); PositionViewModel pvm = null; try { PositionHistory p = InstanceFactory.CreatePositionHistoryFacade().GetPositionHistoryByPKID( Convert.ToInt32(_Context.Request.Params["HistoryId"])); pvm = new PositionViewModel(p); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"item\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(pvm), JsonConvert.SerializeObject(errors)); }
private void GetPositionHistory() { List <Performance.Error> errors = new List <Performance.Error>(); List <PositionViewModel> positionViewModelUIs = new List <PositionViewModel>(); try { List <PositionHistory> phs = InstanceFactory.CreatePositionHistoryFacade().GetPositionHistoryByPositionID( Convert.ToInt32(_Context.Request.Params["Pkid"])); positionViewModelUIs = PositionViewModel.Turn(phs); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"itemList\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(positionViewModelUIs), JsonConvert.SerializeObject(errors)); }
private void SearchPosition() { List <Performance.Error> errors = new List <Performance.Error>(); List <PositionViewModel> positionViewModelUIs = new List <PositionViewModel>(); try { string Name = (_Context.Request.Params["Name"] ?? string.Empty).Replace(';', ';').Trim().Trim(';').Trim(); //string Grade = // (_Context.Request.Params["Grade"] ?? string.Empty).Replace(';', ';').Trim().Trim(';').Trim(); string Nature = (_Context.Request.Params["Nature"] ?? string.Empty).Replace(';', ';').Trim().Trim(';').Trim(); string Department = (_Context.Request.Params["Department"] ?? string.Empty).Replace(';', ';').Trim().Trim(';').Trim(); string AccountName = (_Context.Request.Params["AccountName"] ?? string.Empty).Replace(';', ';').Trim().Trim(';').Trim(); string NameWhere = string.Empty; foreach (string str in Name.Split(';')) { NameWhere += string.IsNullOrEmpty(NameWhere) ? "positionname like '%" + str.Trim() + "%' " : "or positionname like '%" + str.Trim() + "%' "; } //string GradeWhere = string.Empty; //foreach (string str in Grade.Split(';')) //{ // GradeWhere += string.IsNullOrEmpty(GradeWhere) // ? "PositionGradeName like '%" + str.Trim() + "%' " // : "or PositionGradeName like '%" + str.Trim() + "%' "; //} string NatureWhere = string.Empty; foreach (string str in Nature.Split(';')) { NatureWhere += string.IsNullOrEmpty(NatureWhere) ? "tpositionnature.name like '%" + str.Trim() + "%' " : "or tpositionnature.name like '%" + str.Trim() + "%' "; } string DepartmentWhere = string.Empty; foreach (string str in Department.Split(';')) { DepartmentWhere += string.IsNullOrEmpty(DepartmentWhere) ? "Departmentname like '%" + str.Trim() + "%' " : "or Departmentname like '%" + str.Trim() + "%' "; } string AccountNameWhere = string.Empty; foreach (string str in AccountName.Split(';')) { AccountNameWhere += string.IsNullOrEmpty(AccountNameWhere) ? "employeename like '%" + str.Trim() + "%' " : "or employeename like '%" + str.Trim() + "%' "; } string sql = "select distinct tposition.pkid " + "from tposition " + "where (" + NameWhere + ") " + "and ( '' = '" + Nature + "' " + " or" + " (" + " tposition.pkid in " + " ( select tpositionnaturerelationship.positionid " + " from tpositionnature,tpositionnaturerelationship " + " where tpositionnature.pkid = tpositionnaturerelationship.positionnatureid " + " and ("+ NatureWhere + ") " + " ) " + " ) " + " ) " + "and ( '' = '" + Department + "' " + " or" + " (" + " tposition.pkid in " + " ( select tpositiondeptrelationship.positionid " + " from tDepartment,tpositiondeptrelationship " + " where tDepartment.pkid = tpositiondeptrelationship.deptid " + " and ("+ DepartmentWhere + ") " + " ) " + " ) " + " ) " + "and ( '' = '" + AccountName + "' " + " or " + " ( " + " tposition.pkid in " + " ( select taccount.positionid " + " from taccount " + " where ("+ AccountNameWhere + ") " + " ) " + " ) " + " ) "; //+ "and ( '' = '" + Grade + "' " //+ " or " //+ " ( " //+ " tposition.pkid in " //+ " ( select tposition.pkid " //+ " from tpositiongrade,tposition " //+ " where tpositiongrade.pkid = tposition.levelid " //+ " and (" + GradeWhere + ") " //+ " ) " //+ " ) " //+ " ) "; List <Position> Positions = BllInstance.PositionBllInstance.GetPositionByCondition(sql); for (int i = 0; i < Positions.Count; i++) { Positions[i] = BllInstance.PositionBllInstance.GetPositionById(Positions[i].Id, _Operator); } positionViewModelUIs = PositionViewModel.Turn(Positions); } catch (Exception e) { errors.Add(new Performance.Error("lblMessage", e.Message)); } _ResponseString = string.Format("{{\"itemList\":{0},\"error\":{1}}}", JsonConvert.SerializeObject(positionViewModelUIs), JsonConvert.SerializeObject(errors)); }
private string ToCreateFile(Position p, string leaderName, string leaderPosition, string dept) { string ret = ""; PositionViewModel pvm = new PositionViewModel(p); Application app = new Application(); object nothing = Type.Missing; object localPatho = _Context.Server.MapPath(ConstParameters.Template_PositionInfoDoc); Document doc = app.Documents.Add(ref localPatho, ref nothing, ref nothing, ref nothing); try { if (!Directory.Exists(_EmployeeExportLocation)) { Directory.CreateDirectory(_EmployeeExportLocation); } Table tb = doc.Tables[1]; tb.Cell(2, 2).Range.Text = pvm.Name; tb.Cell(2, 4).Range.Text = leaderPosition; tb.Cell(3, 2).Range.Text = pvm.Members; tb.Cell(3, 4).Range.Text = leaderName; tb.Cell(4, 2).Range.Text = string.IsNullOrEmpty(dept) ? pvm.Depts : dept; tb.Cell(4, 4).Range.Text = pvm.NatureNames; tb.Cell(6, 1).Range.Text = pvm.Summary; tb.Cell(8, 1).Range.Text = pvm.MainDuties; tb.Cell(10, 2).Range.Text = pvm.ReportScope; tb.Cell(11, 2).Range.Text = pvm.ControlScope; tb.Cell(12, 2).Range.Text = pvm.Coordination; tb.Cell(14, 1).Range.Text = pvm.Authority; tb.Cell(16, 1).Range.Text = pvm.Qualification;; tb.Cell(18, 2).Range.Text = pvm.KnowledgeAndSkills; tb.Cell(19, 2).Range.Text = pvm.RelatedProcesses; tb.Cell(20, 2).Range.Text = pvm.ManagementSkills; tb.Cell(21, 2).Range.Text = pvm.AuxiliarySkills; tb.Cell(22, 2).Range.Text = pvm.Competence; tb.Cell(23, 2).Range.Text = pvm.OtherRequirements; object fileFormat = WdSaveFormat.wdFormatTemplate97; object filename = _EmployeeExportLocation + "\\" + "职位说明书-" + p.Name + ".doc"; doc.SaveAs(ref filename, ref fileFormat, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing); ret = filename.ToString(); } catch (Exception e) { doc.Tables[1].Cell(3, 2).Range.Text = e.Message; object filename = _EmployeeExportLocation + "\\" + "temp.doc"; object fileFormat = WdSaveFormat.wdFormatTemplate97; doc.SaveAs(ref filename, ref fileFormat, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing); } finally { doc.Close(ref nothing, ref nothing, ref nothing); app.Quit(ref nothing, ref nothing, ref nothing); } return(ret); }