public ActionResult SearchPreviousDelegation(EditDelegationViewModel viewmodel, int id) { string token = GetToken(); UserModel um = GetUser(); DelegationModel um1 = new DelegationModel(); try { if (viewmodel != null) { viewmodel.assignedby = um.Userid; um1.Delid = id; DelegationModel um2 = APIDelegation.GetDelegationByDeleid(token, id, out string delerror); um1.Startdate = um2.Startdate; um1.Enddate = viewmodel.EndDate; um1.Userid = um2.Userid; um1.AssignedbyId = um.Userid; um1.Active = ConDelegation.Active.ACTIVE; APIDelegation.UpdateDelegation(token, um1, out string error); } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } Session["noti"] = true; Session["notitype"] = "success"; Session["notititle"] = "Update Delegation"; Session["notimessage"] = "Delegation is updated successfully"; return(RedirectToAction("SearchPreviousDelegation")); }
public ActionResult Upload(DelegationModel Model) { if (ModelState.IsValid) { foreach (DelegationItem data in Model.Details) { try { data.CreatedDate = DateTime.Now; data.CreatedBy = CurrentUser.USERNAME; data.ModifiedDate = null; data.IsActive = true; var dto = Mapper.Map <DelegationDto>(data); _DelegationBLL.Save(dto); AddMessageInfo(Constans.SubmitMessage.Saved, Enums.MessageInfoType.Success); } catch (Exception exception) { AddMessageInfo(exception.Message, Enums.MessageInfoType.Error); return(View(Model)); } } } return(RedirectToAction("Index", "MstDelegation")); }
public ActionResult CreateDelegationList(CreateDelegationViewModel viewmodel, int userid) { string token = GetToken(); UserModel um = GetUser(); DelegationModel dm = new DelegationModel(); try { if (viewmodel != null) { viewmodel.assignedby = um.Userid; dm.Userid = userid; dm.Enddate = (DateTime)viewmodel.EndDate; dm.Startdate = (DateTime)viewmodel.StartDate; dm.AssignedbyId = viewmodel.assignedby; dm = APIDelegation.CreateDelegation(token, dm, out string error); } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } Session["noti"] = true; Session["notitype"] = "success"; Session["notititle"] = "Delegation"; Session["notimessage"] = dm.Username + " is Delegated as Head of Department"; return(RedirectToAction("SearchPreviousDelegation")); }
public static DelegationModel GetPreviousDelegationByDepid(string token, int id, out string error) { string url = APIHelper.Baseurl + "/delegation/search/" + id; DelegationModel delelist = APIHelper.Execute <DelegationModel>(token, url, out error); return(delelist); }
//update Delegation public static DelegationModel UpdateDelegation(DelegationModel dm, out String error) { error = ""; // declare and initialize new LUSSISEntities to perform update LUSSISEntities entities = new LUSSISEntities(); delegation d = new delegation(); try { // finding the delegation object using delegation API model d = entities.delegations.Where(p => p.delid == dm.Delid).First <delegation>(); // transfering data from API model to DB Model d.startdate = dm.Startdate; d.enddate = dm.Enddate; d.userid = dm.Userid; d.active = dm.Active; d.assignedby = dm.AssignedbyId; // saving the update entities.SaveChanges(); // return the updated model dm = CovertDBDelegationtoAPIUser(d); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(dm); }
public void ExecuteSendPlaceOrderData1(object para) { try { DelegationModel rtm = para as DelegationModel; DelegationModelViewModel dmvm = OrderCancelViewModel.Instance().Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId); if (dmvm == null) { OrderCancelViewModel.Instance().Delegations.Add(new DelegationModelViewModel(rtm)); } else { dmvm.OrderStatus = rtm.order_status; //详细状态 dmvm.FailMsg = rtm.fail_msg; } DelegationModelViewModel dmvm1 = OrderCancelViewModel.Instance().KCDelegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId); if (dmvm1 != null) { OrderCancelViewModel.Instance().KCDelegations.Remove(dmvm1); } } catch (Exception ex) { LogHelper.Info(ex.ToString()); } }
public string IsDuplicate([FromBody] DelegationModel e) { int depid = Convert.ToInt32(e.DepartmentID); DateTime start = (DateTime)e.StartDate; DateTime end = (DateTime)e.StartDate; return(new DelegationRepo().IsDuplicate(depid, start, end)); }
private MemoryStream WhichS89(DelegationModel delegationModel) { if (delegationModel.Name.Contains(Constant.J_STR)) { return(new MemoryStream(necessaryFileService.GetNecessaryFileData(Constant.S89J_FILE_NAME))); } return(new MemoryStream(necessaryFileService.GetNecessaryFileData(Constant.S89CH_FILE_NAME))); }
public ActionResult Upload() { var model = new DelegationModel(); model.MainMenu = _mainMenu; model.CurrentLogin = CurrentUser; return(View(model)); }
public static DelegationModel CancelDelegation(string token, DelegationModel dm, out string error) { error = ""; string url = APIHelper.Baseurl + "/delegation/cancel/"; string objectstring = JsonConvert.SerializeObject(dm); dm = APIHelper.Execute <DelegationModel>(token, objectstring, url, out error); return(dm); }
private static DelegationModel CovertDBDelegationtoAPIUser(delegation delegation) { DelegationModel dgm = new DelegationModel(delegation.delid, delegation.startdate, delegation.enddate, delegation.userid, delegation.user.username, delegation.user.role, delegation.user.department.deptname, delegation.active, delegation.assignedby, delegation.user1.username, delegation.user1.role, delegation.user1.department.deptname); return(dgm); }
public IHttpActionResult CreateDelegation(DelegationModel dele) { string error = ""; DelegationModel dm = DelegationRepo.CreateDelegation(dele, out error); if (error != "" || dm == null) { return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(dm)); }
//search the previous delegation with userlist public static DelegationModel SearchPreviousDelegation(int deptid, out string error) { error = ""; LUSSISEntities entities = new LUSSISEntities(); List <department> dept = new List <department>(); List <user> ums = new List <user>(); List <UserModel> urm = new List <UserModel>(); try { ums = entities.users.Where(p => p.deptid == deptid && p.role != ConUser.Role.HOD).ToList <user>(); foreach (user u in ums) { urm.Add(UserRepo.CovertDBUsertoAPIUser(u)); } } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } delegation d = new delegation(); DelegationModel ndel = new DelegationModel(); try { foreach (UserModel um in urm) { List <DelegationModel> delee = GetDelegationByUserId(um.Userid, out error); foreach (DelegationModel dm in delee) { if (dm.Active == ConDelegation.Active.ACTIVE) { ndel = dm; } } } } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(ndel); }
//cancel delegation public static DelegationModel CancelDelegation(DelegationModel dm, out String error) { error = ""; // declare and initialize new LUSSISEntities to perform update LUSSISEntities entities = new LUSSISEntities(); delegation d = new delegation(); try { // finding the delegation object using delegation API model d = entities.delegations.Where(p => p.delid == dm.Delid).First <delegation>(); d.active = ConDelegation.Active.INACTIVE; // saving the update entities.SaveChanges(); UserRepo.Canceldelegateuser(dm.Userid); // return the updated model dm = GetDelegationByDelegationID(d.delid, out error); user us = entities.users.Where(p => p.userid == dm.Userid).FirstOrDefault(); NotificationModel nom = new NotificationModel(); nom.Deptid = us.deptid; nom.Role = ConUser.Role.EMPLOYEEREP; nom.Title = "Authority Cancellation"; nom.NotiType = ConNotification.NotiType.DelegationAssigned; nom.ResID = dm.Userid; nom.Remark = us.fullname + " has been removed as a Temp Head of Department!"; nom = NotificationRepo.CreatNotification(nom, out error); nom.Deptid = us.deptid; nom.Role = ConUser.Role.TEMPHOD; nom.Title = "Authority Cancellation"; nom.NotiType = ConNotification.NotiType.DelegationAssigned; nom.ResID = dm.Userid; nom.Remark = us.fullname + " has been removed as a Temp Head of Department!"; nom = NotificationRepo.CreatNotification(nom, out error); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(dm); }
// // GET: /MstDelegation/ public ActionResult Index() { var data = _DelegationBLL.GetDelegation(); var model = new DelegationModel(); model.Details = Mapper.Map <List <DelegationItem> >(data); this.CheckDelegationPeriod(model.Details); model.MainMenu = _mainMenu; model.CurrentLogin = CurrentUser; model.CurrentPageAccess = CurrentPageAccess; return(View(model)); }
private void SetPdfField(IDictionary <string, PdfFormField> fields, DelegationModel delegation, PdfDocument pdfDoc) { //我她X的,SetFont要在SetValue之前 SetPdfFeldValueCenter(fields, pdfDoc, S89PdfField.NAME, delegation.Name.Replace(Constant.J_STR, "")); SetPdfFeldValueCenter(fields, pdfDoc, S89PdfField.ASSISTANT, delegation.Assistant); SetPdfFieldTitle(fields, delegation, pdfDoc); SetPdfFieldSubjectCell(fields, delegation, pdfDoc); SetPdfFieldClass(fields, delegation, pdfDoc); }
private List <DelegationModel> ReadOneClass(ISheet sheet, int classInt) { List <DelegationModel> tempList = new List <DelegationModel>(); for (int i = 4; i <= sheet.LastRowNum; i++) { DelegationModel delegationModel = new DelegationModel(); try { delegationModel.Name = sheet.GetRow(i).GetCell(2 + (classInt - 1) * 2).ToString(); if (string.IsNullOrEmpty(delegationModel.Name)) { continue; } } catch (Exception) { continue; } try { delegationModel.Assistant = sheet.GetRow(i).GetCell(3 + (classInt - 1) * 2).ToString(); } catch (Exception) { delegationModel.Assistant = ""; } delegationModel.Subject = StringUtil.GetChinesePrintAble(sheet.GetRow(i).GetCell(1).ToString()); delegationModel.DelegationClass = classInt.ToString(); try { delegationModel.Date = sheet.GetRow(i).GetCell(0).ToString(); if (string.IsNullOrEmpty(delegationModel.Date)) { delegationModel.Date = blockDate; } else { blockDate = delegationModel.Date; } } catch (Exception) { delegationModel.Date = blockDate; } tempList.Add(delegationModel); } return(tempList); }
private void SetPdfFieldTitle(IDictionary <string, PdfFormField> fields, DelegationModel delegation, PdfDocument pdfDoc) { if (delegation.Date.Equals(previousDate) && delegation.Subject.Contains(previousSubject)) { sameSubjectCount++; SetPdfFeldValueSmall(fields, pdfDoc, S89PdfField.DATE, delegation.Date + "-" + delegation.Subject.Replace(delegation.Subject, delegation.Subject + "-" + sameSubjectCount)); } else { sameSubjectCount = 1; SetPdfFeldValueSmall(fields, pdfDoc, S89PdfField.DATE, delegation.Date + "-" + delegation.Subject); } previousDate = delegation.Date; }
public IHttpActionResult GetDelegationByDeleid(int deleid) { string error = ""; DelegationModel dm = DelegationRepo.GetDelegationByDelegationID(deleid, out error); if (error != "" || dm == null) { if (error == ConError.Status.NOTFOUND) { return(Content(HttpStatusCode.NotFound, "Requisition Not Found")); } return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(dm)); }
public IHttpActionResult SearchPreviousDelegationwithdepid(int depid) { string error = ""; DelegationModel dele = DelegationRepo.SearchPreviousDelegation(depid, out error); if (error != "" || dele == null) { if (error == ConError.Status.NOTFOUND) { return(Content(HttpStatusCode.NotFound, "Delegation Not Found")); } return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(dele)); }
public JsonResult CancelDelegation(int id) { string token = GetToken(); UserModel um = GetUser(); bool result = false; if (id != 0) { DelegationModel dm = APIDelegation.GetDelegationByDeleid(token, id, out string error); DelegationModel dm1 = APIDelegation.CancelDelegation(token, dm, out string cancelerror); result = true; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult CancelDelegationi(DelegationModel del) { string error = ""; DelegationModel dele = DelegationRepo.CancelDelegation(del, out error); if (error != "" || dele == null) { if (error == ConError.Status.NOTFOUND) { return(Content(HttpStatusCode.NotFound, "Delegation Not Found")); } return(Content(HttpStatusCode.BadRequest, error)); } return(Ok(dele)); }
public int CreateDelegation(DelegationModel d) { using (StationeryStoreEntities context = new StationeryStoreEntities()) { Delegation s = new Delegation { EmployeeID = d.EmployeeID, DepartmentID = d.DepartmentID, StartDate = d.StartDate, EndDate = d.EndDate, }; context.Delegations.Add(s); context.SaveChanges(); return(1); } }
private void SetPdfFieldClass(IDictionary <string, PdfFormField> fields, DelegationModel delegation, PdfDocument pdfDoc) { switch (delegation.DelegationClass) { case "1": SetPdfCheckBoxSelected(fields, pdfDoc, S89PdfField.CLASS1); break; case "2": SetPdfCheckBoxSelected(fields, pdfDoc, S89PdfField.CLASS2); break; default: Console.WriteLine("班別填錯了吧\n"); break; } }
public void ExecuteDelegationData(object para) { try { DelegationModel rtm = para as DelegationModel; OrderCancelViewModel ocvm = OrderCancelViewModel.Instance(); if (ocvm.Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id) != null) { return; } if (rtm.bLast) { //PositionViewModel.Instance().JSAbleVolume(); TransactionViewModel.Instance().FigureUpNum(TransactionViewModel.Instance()._futures); return; } VarietyModel vm = null; string[] values = rtm.contract_code.Split(' '); if (values.Length == 3) { string varietie = values[1]; if (ContractVariety.Varieties.ContainsKey(varietie)) { vm = ContractVariety.Varieties[varietie]; } if (vm != null) { rtm.precision = vm.precision; } } DelegationModelViewModel dmvm = new DelegationModelViewModel(rtm); ocvm.Delegations.Add(dmvm); if (rtm.order_status == (int)DeleteType.CreateSuccess || rtm.order_status == (int)DeleteType.PortionTakeEffect) { ocvm.KCDelegations.Add(dmvm); } } catch (Exception ex) { LogHelper.Info(ex.ToString()); } }
public void ExecutePlaceOrderData(object para) { try { DelegationModel rtm = para as DelegationModel; //添加持仓集合 if (!rtm.bLast) { VarietyModel vm = null; string[] values = rtm.contract_id.Split(' '); if (values.Length == 3) { string varietie = values[1]; if (ContractVariety.Varieties.ContainsKey(varietie)) { vm = ContractVariety.Varieties[varietie]; } if (vm != null) { rtm.precision = vm.precision; } } } if (OrderCancelViewModel.Instance().Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id) == null) { OrderCancelViewModel.Instance().Delegations.Add(new DelegationModelViewModel(rtm)); LogHelper.Info("4002 增加" + rtm.contract_code + ":" + rtm.direction + ":" + rtm.open_offset + ":" + rtm.order_status); } if (CommParameterSetting.MessageAlert.OrderAlert == "窗口提示") { MessageBox.Show(rtm.contract_id + " 委托创建成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (CommParameterSetting.MessageAlert.OrderAlert == "声音提示") { SoundPlayerHelper.Play(); } } catch (Exception ex) { LogHelper.Info(ex.ToString()); } }
public DelegationModel GetDelegatedTaskInfo(string Id) { DelegationModel delegationModel = new DelegationModel(); int listItemId = 0; if (int.TryParse(Id, out listItemId)) { string[] viewFields = new string[] { StringConstant.BusinessTripManagementList.Fields.DH, StringConstant.BusinessTripManagementList.Fields.DirectBOD, StringConstant.BusinessTripManagementList.Fields.BOD, StringConstant.BusinessTripManagementList.Fields.AdminDept, StringConstant.CommonSPListField.ApprovalStatusField, StringConstant.CommonSPListField.CommonDepartmentField, CommonSPListField.CommonLocationField }; string queryStr = $@"<Where> <Eq> <FieldRef Name='ID' /> <Value Type='Counter'>{listItemId}</Value> </Eq> </Where>"; string siteUrl = SPContext.Current.Site.Url; List <Biz.Models.BusinessTripManagement> businessTripManagementCollection = _businessTripManagementDAL.GetByQuery(queryStr, viewFields); if (businessTripManagementCollection != null && businessTripManagementCollection.Count > 0) { EmployeeInfo currentApprover = null; Biz.Models.BusinessTripManagement businessTripManagement = businessTripManagementCollection[0]; StepManagementDAL _stepManagementDAL = new StepManagementDAL(siteUrl); var currentStep = _stepManagementDAL.GetStepManagement(businessTripManagement.ApprovalStatus, StepModuleList.BusinessTripManagement, businessTripManagement.CommonDepartment.LookupId); if (currentStep != null) { currentApprover = _businessTripManagementDAL.GetApproverAtStep(businessTripManagement.CommonDepartment.LookupId, businessTripManagement.CommonLocation.LookupId, StepModuleList.BusinessTripManagement, currentStep.StepNumber); } if (currentApprover != null) { Delegation delegation = DelegationPermissionManager.IsDelegation(currentApprover.ID, StringConstant.BusinessTripManagementList.Url, businessTripManagement.ID); delegationModel = new DelegationModel(delegation); } } } return(delegationModel); }
public static DelegationModel GetDelegationByDelegationID(int delid, out string error) { error = ""; delegation dele = new delegation(); DelegationModel dm = new DelegationModel(); try { dele = entities.delegations.Where(p => p.delid == delid).FirstOrDefault <delegation>(); dm = CovertDBDelegationtoAPIUser(dele); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(dm); }
public ActionResult SearchPreviousDelegation() { string token = GetToken(); UserModel um = GetUser(); DelegationModel reqms = new DelegationModel(); EditDelegationViewModel viewmodel = new EditDelegationViewModel(); UserModel DelegatedUser = new UserModel(); try { reqms = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out string error); ViewBag.Userid = reqms.Userid; ViewBag.name = reqms.Username; ViewBag.StartDate = reqms.Startdate; ViewBag.Enddate = reqms.Enddate; ViewBag.Deleid = reqms.Delid; if (reqms.Userid == 0 || reqms == null) { ViewBag.name = ""; } else { DelegatedUser = APIUser.GetUserByUserID(reqms.Userid, token, out error); if (DelegatedUser != null && DelegatedUser.Userid != 0) { ViewBag.name = DelegatedUser.Fullname; } } } catch (Exception ex) { return(RedirectToAction("Index", "Error", new { error = ex.Message })); } return(View(viewmodel)); }
//create delegation public static DelegationModel CreateDelegation(DelegationModel dele, out string error) { error = ""; LUSSISEntities entities = new LUSSISEntities(); delegation d = new delegation(); DelegationModel ndel = new DelegationModel(); try { DepartmentModel dep = DepartmentRepo.GetDepartmentByUserid(dele.Userid, out error); List <UserModel> userlist = UserRepo.GetUserByDeptid(dep.Deptid, out error); foreach (UserModel u in userlist) { List <DelegationModel> delelist = GetDelegationByUserId(u.Userid, out error); foreach (DelegationModel deleg in delelist) { delegation del = entities.delegations.Where(p => p.delid == deleg.Delid).FirstOrDefault <delegation>(); del.active = ConDelegation.Active.INACTIVE; if (u.Role != ConUser.Role.DEPARTMENTREP) { UserRepo.Canceldelegateuser(u.Userid); } entities.SaveChanges(); } } d.startdate = dele.Startdate; d.enddate = dele.Enddate; d.userid = dele.Userid; d.active = ConDelegation.Active.ACTIVE; d.assignedby = dele.AssignedbyId; d = entities.delegations.Add(d); entities.SaveChanges(); dele = GetDelegationByDelegationID(d.delid, out error); user us = entities.users.Where(p => p.userid == dele.Userid).FirstOrDefault(); NotificationModel nom = new NotificationModel(); nom.Deptid = us.deptid; nom.Role = ConUser.Role.TEMPHOD; nom.Title = "New Authority"; nom.NotiType = ConNotification.NotiType.DelegationAssigned; nom.ResID = dele.Userid; nom.Remark = us.fullname + " has been assigned as a Temp HOD from " + dele.Startdate.Value.ToShortDateString() + " to " + dele.Enddate.Value.ToShortDateString(); nom = NotificationRepo.CreatNotification(nom, out error); nom.Deptid = us.deptid; nom.Role = ConUser.Role.EMPLOYEEREP; nom.Title = "New Authority"; nom.NotiType = ConNotification.NotiType.DelegationAssigned; nom.ResID = dele.Userid; nom.Remark = us.fullname + " has been assigned as a Temp HOD from " + dele.Startdate.Value.ToShortDateString() + " to " + dele.Enddate.Value.ToShortDateString(); nom = NotificationRepo.CreatNotification(nom, out error); } catch (NullReferenceException) { error = ConError.Status.NOTFOUND; } catch (Exception e) { error = e.Message; } return(dele); }