/// <summary> /// Sets a terrain node's worth of data to the world's terrain. Thread-safe. /// </summary> /// <exception cref="ArgumentNullException"> /// Thrown when passed null for node, instead of a <see cref="TerrainNode"/> /// reference /// </exception> public void SetNode(TerrainNode node, int tileX, int tileZ) { if (node == null) { throw new ArgumentNullException("node", "Expected a terrain node to send"); } lock (instance.Mutex) { var refNum = nextReference; var refNode = new Tuple <TerrainNode, int, int> (node, tileX, tileZ); nodeReferences.Add(refNum, refNode); Functions.vp_int_set(instance.Pointer, IntAttributes.ReferenceNumber, refNum); try { Functions.Call(() => Functions.vp_terrain_node_set( instance.Pointer, tileX, tileZ, node.X, node.Z, DataHandlers.NodeToNodeData(node)) ); } catch { nodeReferences.Remove(refNum); throw; } } }
/*public ActionResult OpenTargetEntry( string WorkflowID , int RequestStageID) { * * //string UserName = Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.LastIndexOf(@"\") + 1); * string UserName = @User.Identity.Name; * * if( UserName == null || UserName.Equals(String.Empty)){ * ViewBag.ErrorMessage="You must be logged in to continue."; * return RedirectToAction("AwaitingMyApproval","AwaitingApproval"); * } * * //now resolve the user profile from AD and Xceed * StaffADProfile staffADProfile = new StaffADProfile(); * staffADProfile.user_logon_name = UserName; * * * //AD * ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery( staffADProfile ); * staffADProfile = activeDirectoryQuery.GetStaffProfile(); * if( staffADProfile==null ){ * ViewBag.ErrorMessage="Your profile is not properly setup on the system. Please contact InfoTech."; * return RedirectToAction( "AwaitingMyApproval","AwaitingApproval",new { UserName = Session["UserName"] as string } ); * } * * string approvers = new LINQCalls().getApprovers( WorkflowID,RequestStageID ); * List<SignerDetails> realApprovers = new DataHandlers().GetApprovers( approvers ); * int index = realApprovers.FindIndex(f => f.ApproverStaffNumber == staffADProfile.employee_number); * bool isApprover = ( index >= 0 ) ? true : false; * * return RedirectToAction( "EditTarget","InputTarget",new {WorkflowID=WorkflowID , editMode =isApprover , myEntries=true } ); * }*/ public ActionResult OpenMemoEntry(string WorkflowID, int RequestStageID) { //string UserName = Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.LastIndexOf(@"\") + 1); string UserName = @User.Identity.Name; if (UserName == null || UserName.Equals(String.Empty)) { ViewBag.ErrorMessage = "You must be logged in to continue."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } //now resolve the user profile from AD and Xceed StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.user_logon_name = UserName; //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile); staffADProfile = activeDirectoryQuery.GetStaffProfile(); if (staffADProfile == null) { ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", null)); } string approvers = new LINQCalls().getApprovers(WorkflowID, RequestStageID); List <SignerDetails> realApprovers = new DataHandlers().GetApprovers(approvers); int index = realApprovers.FindIndex(f => f.ApproverStaffNumber == staffADProfile.employee_number); bool isApprover = (index >= 0) ? true : false; return(RedirectToAction("EditMemo", "MemoSetup", new { WorkflowID = WorkflowID, editMode = isApprover, myEntries = true })); }
/// <summary> /// Creates a terrain node from an instances' attributes and byte array /// </summary> public TerrainNode(IntPtr pointer) { X = Functions.vp_int(pointer, IntAttributes.TerrainNodeX); Z = Functions.vp_int(pointer, IntAttributes.TerrainNodeZ); Revision = Functions.vp_int(pointer, IntAttributes.TerrainNodeRevision); var data = DataHandlers.GetData(pointer, DataAttributes.TerrainNodeData); Cells = DataHandlers.NodeDataTo2DArray(data); }
/// <summary> /// Creates a VPObject from a native instance's attributes /// </summary> internal VPObject(IntPtr pointer) { Action = Functions.vp_string(pointer, StringAttributes.ObjectAction); Description = Functions.vp_string(pointer, StringAttributes.ObjectDescription); Id = Functions.vp_int(pointer, IntAttributes.ObjectId); Model = Functions.vp_string(pointer, StringAttributes.ObjectModel); Time = DateTimeExt.FromUnixTimestampUTC(Functions.vp_int(pointer, IntAttributes.ObjectTime)); Type = Functions.vp_int(pointer, IntAttributes.ObjectType); Owner = Functions.vp_int(pointer, IntAttributes.ObjectUserId); Data = DataHandlers.GetData(pointer, DataAttributes.ObjectData); Position = Vector3.FromObject(pointer); Rotation = Rotation.FromObject(pointer); }
public void Navigate(DataHandlers handler) { switch (handler) { case DataHandlers.Input: _mainWindow.ContentControl.Content = _inputView; break; case DataHandlers.Output: _mainWindow.ContentControl.Content = _outputView; break; default: throw new ArgumentOutOfRangeException(nameof(handler), handler, null); } }
internal void ToNative(IntPtr pointer) { Functions.vp_int_set(pointer, IntAttributes.ObjectId, this.Id); Functions.vp_string_set(pointer, StringAttributes.ObjectAction, this.Action); Functions.vp_string_set(pointer, StringAttributes.ObjectDescription, this.Description); Functions.vp_string_set(pointer, StringAttributes.ObjectModel, this.Model); Functions.vp_float_set(pointer, FloatAttributes.ObjectX, this.Position.X); Functions.vp_float_set(pointer, FloatAttributes.ObjectY, this.Position.Y); Functions.vp_float_set(pointer, FloatAttributes.ObjectZ, this.Position.Z); this.Rotation.ToObject(pointer); Functions.vp_int_set(pointer, IntAttributes.ObjectType, this.Type); if (Data != null) { DataHandlers.SetData(pointer, DataAttributes.ObjectData, Data); } }
public ActionResult HistoryIndex(string id) { // List<ApprovalDetails> History = new List<ApprovalDetails>(); //History = new AppClass().getHistory(id); XElement ApprovalHistory = new AppClass().getApprovalHistory(id); XDocument xDocument = DataHandlers.ToXDocument(ApprovalHistory); List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals") .Select(det => new ApprovalDetails { ApproverNames = det.Element("ApproverName").Value, ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value, ApprovedStages = det.Element("ApprovedStage").Value, ApproverAction = det.Element("ApproverAction").Value, ApprovalDateTime = det.Element("ApprovalDateTime").Value, ApproverComment = det.Element("ApproverComment").Value.Equals("") ? "None" : det.Element("ApproverComment").Value, }) .ToList(); return(PartialView("HistoryIndex", approvalHistory)); }
public void Navigate(DataHandlers handler) { _navigationModel?.Navigate(handler); }
//you gots data private void RxDone(int iNumBytes) { BaseDataPackage data; // save the current read position long lPos = _ms.Position; // seek to the end to append the data _ms.Seek(0, SeekOrigin.End); // append the new data to the end of the stream _ms.Write(_bBuff, 0, iNumBytes); // restore the read position back to where it started _ms.Position = lPos; // show byte count received //Console.WriteLine("RxDone: Added " + iNumBytes.ToString() + //" bytes... for a total of " + (_ms.Length - _ms.Position).ToString()); _iRecieves++; do { // attempt to extract 1 or more complete frames // save the stream position in case the // deserialization fails, and it has to be reset long lStartPos = _ms.Position; try { // attempt to deserialize an object at this position object o = _bf.Deserialize(_ms); // no exception, so process the received frame and move on if (o is BaseDataPackage) { data = (o as BaseDataPackage); _iFrames++; DataHandlers.CallMethod(_context, data); } else { Console.WriteLine("RxDone: unknown frame"); } } catch (System.Runtime.Serialization.SerializationException) { // deserialize failed, so move the read position back // assume more data will show up that this item needs to be deserialized _ms.Position = lStartPos; // show that this time, a full object could not be pulled Console.WriteLine("RxDone: Could not deserialize.... yet..."); _iFragments++; // get out of the destacking loop break; } }while (_ms.Position < _ms.Length); //update stats lables //if (_iBytesTotal < 1024) // lBytes.Text = "Bytes RX'ed: B" + _iBytesTotal.ToString(); //else // if (_iBytesTotal < 1048576) // lBytes.Text = "Bytes RX'ed: kB" + (_iBytesTotal / 1024.0).ToString("f2"); //else // if (m_iBytesTotal < 1073741824) // lBytes.Text = "Bytes RX'ed: MB" + (_iBytesTotal / 1048576.0).ToString("f2"); //else // lBytes.Text = "Bytes RX'ed: MB" + (_iBytesTotal / 1073741824.0).ToString("f2"); //lDestackAvg.Text = "Destack Avg.: " + (_iFrames / (double)_iRecieves).ToString("f2"); //lFragments.Text = "Fragments: " + _iFragments.ToString(); //lFrames.Text = "Frames RX'ed: " + _iFrames.ToString(); // if all data has been read from the rx memorystream, reset it // otherwise it will continue to hold all data EVER received if (_ms.Position == _ms.Length) { _ms.Position = 0; _ms.SetLength(0); Console.WriteLine("RxDone: Resetting RX Memorystream..."); } // do optional trim, if buffer pounding is a concern // start another rx operation try { _socket.BeginReceive(_bBuff, 0, _bBuff.Length, SocketFlags.None, cbRxDone, _socket); } catch (Exception) { Console.WriteLine("RxDone:BeginReceive"); } }
public ActionResult PassportReviewForm(string WorkflowID, bool editMode, bool?myEntries) { Session["UserName"] = @User.Identity.Name; this._UserName = Session["UserName"] as string ?? String.Empty; if (_UserName == null || _UserName.Equals(String.Empty)) { ViewBag.ErrorMessage = "You must be logged in to continue."; return(RedirectToAction("Login", "Login")); } //now resolve the user profile from AD and Xceed StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.user_logon_name = _UserName; //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile); staffADProfile = activeDirectoryQuery.GetStaffProfile(); if (staffADProfile == null) { ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } //Get the request identified by the workflow id and be sure the user is an approver List <RequestDetails> requestDetails = new List <RequestDetails>(); requestDetails = LINQCalls.getExistingPassportEntry(WorkflowID, staffADProfile.employee_number); if (requestDetails == null) { ViewBag.ErrorMessage = "You are not authorized to process this request"; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } List <PassportDetails> passportDetails = new List <PassportDetails>(); PassportDetails pDetails = LINQCalls.getPassportDetails(WorkflowID); passportDetails.Add(pDetails); EntryModel entryModel = new EntryModel(); entryModel = LINQCalls.getWorkflowEntry(WorkflowID); entryModel.DOE = LINQCalls.getXceedProfile(entryModel.StaffNumber).doe; ViewBag.StaffBranch = entryModel.Branch; int requeststageid = entryModel.RequestStageId; string requeststage = entryModel.RequestStage; DateTime requestdate = entryModel.DateSubmitted; string initiatornumber = entryModel.StaffNumber; //LINQCalls.getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number; string cansave = (!requeststage.Equals(INIT_STAGE) && !requeststage.Equals(DENIED) && !requeststage.Equals(APPROVED) && !initiatornumber.Equals(staffADProfile.employee_number)) ? "true" : "false"; XElement ApprovalHistory = LINQCalls.getApprovalHistory(WorkflowID); XDocument xDocument = DataHandlers.ToXDocument(ApprovalHistory); List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals").Select(det => new ApprovalDetails { ApproverNames = det.Element("ApproverName").Value, ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value, ApprovedStages = det.Element("ApprovedStage").Value, ApproverAction = det.Element("ApproverAction").Value, ApprovalDateTime = det.Element("ApprovalDateTime").Value, ApproverComments = det.Element("ApproverComment").Value }).ToList(); SuperPassportModel superPassportModel = new SuperPassportModel(); if (TempData["superPassportModel"] != null) { superPassportModel = TempData["superPassportModel"] as SuperPassportModel; } else { superPassportModel = new SuperPassportModel { WorkflowID = WorkflowID, RequestStageID = entryModel.RequestStageId, RequestStage = entryModel.RequestStage, RequestDate = entryModel.DateSubmitted, StaffADProfile = staffADProfile, RequestDetails = requestDetails, CanSave = cansave, ApprovalDetails = approvalHistory, EntryModel = entryModel, RequestBranch = entryModel.Branch, RequestBranchCode = entryModel.BranchCode, PassportDetails = passportDetails }; } Session["requestDetails"] = superPassportModel.RequestDetails; TempData["editMode"] = (editMode == true) ? "true" : "false"; if (TempData["ErrorMessage"] != null) { ViewBag.ErrorMessage = TempData["ErrorMessage"] as string; } Session["superPassportModel"] = superPassportModel; TempData["superPassportModel"] = superPassportModel; return(View(superPassportModel)); }
public ActionResult EditMemo(string WorkflowID, bool editMode, bool?myEntries) { _UserName = User.Identity.Name; Session["UserName"] = User.Identity.Name; if (_UserName == null || _UserName.Equals(String.Empty)) { ViewBag.ErrorMessage = "You must be logged in to continue."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } //now resolve the user profile from AD and Xceed StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.user_logon_name = _UserName; //staffADProfile.user_logon_name = "adebisi.olumoto"; //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile); staffADProfile = activeDirectoryQuery.GetStaffProfile(); staffADProfile.grade = new LINQCalls().getStaffGrade(staffADProfile.employee_number); if (staffADProfile == null) { ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string })); } //Get the request identified by the Workflow ID MemoSetup memoSetup = new MemoSetup(); memoSetup = new LINQCalls().getWorkflowEntry(WorkflowID); ViewBag.StaffBranch = memoSetup.Branch; int requeststageid = memoSetup.RequestStageId; string requeststage = memoSetup.RequestStage; DateTime requestdate = memoSetup.DateSubmitted; string initiatornumber = new LINQCalls().getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number; string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number) ? this.CANSAVE : "false"; XElement ApprovalHistory = new LINQCalls().getApprovalHistory(WorkflowID); XDocument xDocument = DataHandlers.ToXDocument(ApprovalHistory); List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals") .Select(det => new ApprovalDetails { ApproverNames = det.Element("ApproverName").Value, ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value, ApprovedStages = det.Element("ApprovedStage").Value, ApproverAction = det.Element("ApproverAction").Value, ApprovalDateTime = det.Element("ApprovalDateTime").Value, ApproverComments = det.Element("ApproverComment").Value }).ToList(); memoSetup.SignerDetailsList = GetApprovers(memoSetup); editMode = editMode && memoSetup.RequestStageId.Equals(1); TempData["editMode"] = editMode; //( editMode==true ) ? null : "false"; ViewBag.editMode = editMode; if (TempData["ErrorMessage"] != null) { ViewBag.ErrorMessage = TempData["ErrorMessage"] as string; } TempData["memoSetup"] = memoSetup; return(RedirectToAction("NewMemo", new { UserName = Session["UserName"] as string })); }
public ActionResult EditTarget(string UserName, string WorkflowID, bool editMode, bool?myEntries) { // editMode = true; if (UserName == null || UserName.Equals(String.Empty)) { ViewBag.ErrorMessage = "You must be logged in to continue."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } //now resolve the user profile from AD and Xceed StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.user_logon_name = UserName; //staffADProfile.user_logon_name = "adebisi.olumoto"; //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile); staffADProfile = activeDirectoryQuery.GetStaffProfile(); //GET ENTERY BRANC CODE staffADProfile.branch_code = new LINQCalls().getEntryProfile(WorkflowID).branch_code; staffADProfile.branch_name = new LINQCalls().getEntryProfile(WorkflowID).branch_name; if (staffADProfile == null) { ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string })); } //GET THE APPROVERS DETAILS FROM EXCEED //Approver Setup //Resolve the --branchname --branchcode --department --deptcode /* * staffADProfile = new LINQCalls().setInitiatorFields( staffADProfile ); * if( staffADProfile.branch_code==null ){ * ViewBag.ErrorMessage="Your profile is not properly setup on Exceed. Please contact Human Resources."; * return RedirectToAction( "AwaitingMyApproval","AwaitingApproval",new { UserName = Session["UserName"] as string } ); * } * */ //Get the request identified by the workflow id List <RequestDetails> requestDetails = new List <RequestDetails>(); if (myEntries != null && myEntries == true) { string entrykey = staffADProfile.employee_number + "_" + staffADProfile.appperiod + "_" + staffADProfile.branch_code; requestDetails = new LINQCalls().getExistingTargetEntry(WorkflowID, staffADProfile.employee_number, entrykey); } else { requestDetails = new LINQCalls().getExistingTargetEntry(WorkflowID, staffADProfile.employee_number); } EntryModel entryModel = new EntryModel(); entryModel = new LINQCalls().getWorkflowEntry(WorkflowID); ViewBag.StaffBranch = entryModel.Branch; int requeststageid = entryModel.RequestStageId; string requeststage = entryModel.RequestStage; DateTime requestdate = entryModel.DateSubmitted; string initiatornumber = new LINQCalls().getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number; //staffADProfile.branch_code = new LINQCalls().getProfile(staffADProfile.employee_number).branch_code; //if (requeststage.Equals(INIT_STAGE)) //{ // staffADProfile.branch_code = new LINQCalls().setInitiatorFields(staffADProfile).branch_code; //} string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number) ? this.CANSAVE : "false"; staffADProfile.appperiod = entryModel.AppraisalPeriod; XElement ApprovalHistory = new LINQCalls().getApprovalHistory(WorkflowID); XDocument xDocument = DataHandlers.ToXDocument(ApprovalHistory); List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals") .Select(det => new ApprovalDetails { ApproverNames = det.Element("ApproverName").Value, ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value, ApprovedStages = det.Element("ApprovedStage").Value, ApproverAction = det.Element("ApproverAction").Value, ApprovalDateTime = det.Element("ApprovalDateTime").Value }) .ToList(); SuperInputTargetModel superInputTargetModel = new SuperInputTargetModel(); if (TempData["superInputTargetModel"] != null) { superInputTargetModel = TempData["superInputTargetModel"] as SuperInputTargetModel; } else { superInputTargetModel = new SuperInputTargetModel { WorkflowID = WorkflowID, RequestStageID = entryModel.RequestStageId, RequestStage = entryModel.RequestStage, RequestDate = entryModel.DateSubmitted, StaffADProfile = staffADProfile, RequestDetails = requestDetails, CanSave = cansave, ApprovalDetails = approvalHistory, EntryModel = entryModel, RequestBranch = entryModel.Branch, RequestBranchCode = entryModel.BranchCode }; } //sort the list var d = from x in superInputTargetModel.RequestDetails orderby x.name == OTHERS, x.name select x; superInputTargetModel.RequestDetails = d.ToList(); Session["requestDetails"] = superInputTargetModel.RequestDetails; Session["UserName"] = UserName; TempData["editMode"] = (editMode == true) ? null : "false"; if (TempData["ErrorMessage"] != null) { ViewBag.ErrorMessage = TempData["ErrorMessage"] as string; } TempData["superInputTargetModel"] = superInputTargetModel; return(RedirectToAction("TargetInputForm", new { UserName = Session["UserName"] as string })); }
public ActionResult TargetInputForm(SuperInputTargetModel superInputTargetModel, string TargetAction, string StaffNumber) { List <RequestDetails> requestDetails = superInputTargetModel.RequestDetails; IEnumerable <RequestDetails> requestdetails = superInputTargetModel.RequestDetails; DataTable dataTable = DataHandlers.ToDataTable(requestdetails); string retVal = ""; switch (TargetAction) { case "AddStaff": //ADD the new Staff from the list if (AddStaff(superInputTargetModel)) { requestDetails.Add(TempData["newStaff"] as RequestDetails); } break; case "DeleteStaff": //DELETE the selected Staff from the list if (DeleteStaff(superInputTargetModel, StaffNumber)) { requestDetails = TempData["requestDetails"] as List <RequestDetails>; } break; case "Reset": // RESET all entries to ZERO requestDetails.Select(c => { c.cabal = c.cabal_l = c.sabal = c.sabal_l = c.fd = c.fx = c.inc = c.inc_l = c.rv = "0"; return(c); }).ToList(); break; case "Save": // GOSH!!! I CAN'T HIDE THE entry_key & workflow_id COLUMN---REBUILD IT AGAIN requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superInputTargetModel.StaffADProfile.appperiod + "_" + superInputTargetModel.StaffADProfile.branch_code; return(c); }).ToList(); requestDetails.Select(c => { c.workflowid = superInputTargetModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE requestdetails = superInputTargetModel.RequestDetails; dataTable = DataHandlers.ToDataTable(requestdetails); retVal = new AppDatabase().inputTargetEntries(dataTable, superInputTargetModel, "AppraisalDbConnectionString", SAVED_STATUS); Debug.WriteLine(retVal); if (retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = retVal; TempData["superInputTargetModel"] = superInputTargetModel; } else { return(RedirectToAction("MyEntries", "MyEntries", new { UserName = Session["UserName"] })); } break; case "Deny": // Good. let's send this f@*ker back requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superInputTargetModel.StaffADProfile.appperiod + "_" + superInputTargetModel.StaffADProfile.branch_code; return(c); }).ToList(); requestDetails.Select(c => { c.workflowid = superInputTargetModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE requestdetails = superInputTargetModel.RequestDetails; dataTable = DataHandlers.ToDataTable(requestdetails); retVal = new AppDatabase().inputTargetEntries(dataTable, superInputTargetModel, "AppraisalDbConnectionString", DENIED_STATUS); Debug.WriteLine(retVal); if (retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = retVal; TempData["superInputTargetModel"] = superInputTargetModel; } else { //String.format(SUMBMITTEDMSG)--add the approvers var approvers = new LINQCalls().getApproverNames(superInputTargetModel.WorkflowID, -1); TempData["PostBackMessage"] = DENIEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string })); } break; case "Submit": //LET'S SUBMIT THIS SHIT requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superInputTargetModel.StaffADProfile.appperiod + "_" + superInputTargetModel.StaffADProfile.branch_code; return(c); }).ToList(); requestDetails.Select(c => { c.workflowid = superInputTargetModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE IEnumerable <RequestDetails> _requestdetails = superInputTargetModel.RequestDetails; if (superInputTargetModel.EntryModel != null) { //EDITTED REQUEST---APPROVAL OR RESUBMISSION requestDetails.Select(c => { c.requeststageid = superInputTargetModel.RequestStageID; c.requeststage = superInputTargetModel.RequestStage; return(c); }).ToList(); } DataTable _dataTable = DataHandlers.ToDataTable(_requestdetails); StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.branch_code = new LINQCalls().getEntryProfile(superInputTargetModel.WorkflowID).branch_code; staffADProfile.branch_name = new LINQCalls().getEntryProfile(superInputTargetModel.WorkflowID).branch_name; string _retVal = new AppDatabase().inputTargetEntries(_dataTable, superInputTargetModel, "AppraisalDbConnectionString", SUBMIT_STATUS); Debug.WriteLine(_retVal); if (_retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = _retVal; TempData["superInputTargetModel"] = superInputTargetModel; } else { //String.format(SUMBMITTEDMSG)--add the approvers int newstageid = 0; switch (superInputTargetModel.RequestStageID) { case 0: newstageid = 3; break; case -1: newstageid = 3; break; case 3: newstageid = 20; break; case 20: newstageid = 100; break; } /*EntryModel EntryModel = new LINQCalls().getWorkflowEntry( superInputTargetModel.WorkflowID ); * var approvers = new LINQCalls().getApproverNames(superInputTargetModel.WorkflowID,EntryModel.RequestStageId);*/ var approvers = new LINQCalls().getApproverNames(superInputTargetModel.WorkflowID, newstageid); TempData["PostBackMessage"] = SUMBMITTEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval", new { UserName = Session["UserName"] as string })); } break; } superInputTargetModel.RequestDetails = requestDetails; TempData["superInputTargetModel"] = superInputTargetModel; return(RedirectToAction("TargetInputForm", new { UserName = Session["UserName"] as string })); }
/// <summary> /// Check if data is a complete package /// </summary> private void DataReceived(ClientReference client) { //remove client if it is required if (client.BytesReceived == 0) { try { //dispatch call into the proper thread _context.Post(s => { ClientDisconnected?.Invoke(client.Id); }, null); //ClientDisconnected?.Invoke(client.Id); } catch (Exception ex) { //dont trust user code Console.WriteLine("Calling server ClientDisconnected event handler threw an exception"); } lock (_clients) { _clients.Remove(client); } return; } //LineSegment LS; //Getting ready for some Lines received //List<LineSegment> lsList = new List<LineSegment>(); //Putting the memory stream pointer in the correct place long lPos = client.ms.Position; client.ms.Seek(0, SeekOrigin.End); client.ms.Write(client.Buffer, 0, client.BytesReceived); client.ms.Position = lPos; do //Defragmenting copy pasta { long lStartPos = client.ms.Position; try { object o = _bf.Deserialize(client.ms); //deserialize into object to check for types if (o is BaseDataPackage) { //Data received is of the correct type ClientReference.TotalRecieved++; client.Recieved++; //calls the method registered to handle this package DataHandlers.CallMethod(_context, (o as BaseDataPackage), client.Id); } else { //what the heck was this type? Someone trying to break our server! Console.WriteLine("unknown shiz"); } } catch (SerializationException) { //Get out of loop and wait for more data Console.WriteLine("fragmentation of data"); client.ms.Position = lStartPos; client.Fragments++; //increases the number of fragments that happened per connection break; } }while (client.ms.Position < client.ms.Length); //client.RecieveCalls++; //display traffic information //string s; //if (ClientReference.TotalBytes < 1024) // s = "Bytes RX'ed: B" + ClientReference.TotalBytes.ToString(); //else // if (ClientReference.TotalBytes < 1048576) // s = "Bytes RX'ed: kB" + (ClientReference.TotalBytes / 1024.0).ToString("f2"); //else // if (ClientReference.TotalBytes < 1073741824) // s = "Bytes RX'ed: MB" + (ClientReference.TotalBytes / 1048576.0).ToString("f2"); //else // s = "Bytes RX'ed: MB" + (ClientReference.TotalBytes / 1073741824.0).ToString("f2"); //Text = "TolalBytes: " + s + " TotalFrames: " + CSam.TotalRecieved.ToString(); //all data in stream has been read, reset stream if (client.ms.Position == client.ms.Length) { //reset the memory stream pointer and length client.ms.Position = 0; client.ms.SetLength(0); Console.WriteLine("Resetting RX Memory stream"); } try { //Receive more stuff! client.sock.BeginReceive(client.Buffer, 0, client.Buffer.Length, SocketFlags.None, cbRxDone, client); } catch (Exception ex) { Console.WriteLine("DataReceived:BeginReceive at end " + ex.ToString()); } }
public ActionResult ViewPassport(string WorkflowID, bool editMode, bool?myEntries, bool?viewMode) { Session["UserName"] = @User.Identity.Name; this._UserName = Session["UserName"] as string ?? ""; if (_UserName == null || _UserName.Equals(String.Empty)) { ViewBag.ErrorMessage = "You must be logged in to continue."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } //now resolve the user profile from AD and Xceed StaffADProfile staffADProfile = new StaffADProfile(); staffADProfile.user_logon_name = _UserName; //AD ActiveDirectoryQuery activeDirectoryQuery = new ActiveDirectoryQuery(staffADProfile); staffADProfile = activeDirectoryQuery.GetStaffProfile(); staffADProfile.branch_code = LINQCalls.getEntryProfile(WorkflowID).branch_code; staffADProfile.branch_name = LINQCalls.getEntryProfile(WorkflowID).branch_name; if (staffADProfile == null) { ViewBag.ErrorMessage = "Your profile is not properly setup on the system. Please contact InfoTech."; return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } //Get the request identified by the workflow id List <RequestDetails> requestDetails = new List <RequestDetails>(); if (myEntries != null && myEntries == true) { string entrykey = staffADProfile.employee_number + "_" + staffADProfile.branch_code; requestDetails = LINQCalls.getExistingPassportEntry(WorkflowID, staffADProfile.employee_number, entrykey); } else { requestDetails = LINQCalls.getExistingPassportEntry(WorkflowID, staffADProfile.employee_number); } EntryModel entryModel = new EntryModel(); entryModel = LINQCalls.getWorkflowEntry(WorkflowID); ViewBag.StaffBranch = entryModel.Branch; int requeststageid = entryModel.RequestStageId; string requeststage = entryModel.RequestStage; DateTime requestdate = entryModel.DateSubmitted; string initiatornumber = LINQCalls.getInitiatorNumber(WorkflowID) ?? staffADProfile.employee_number; string cansave = (requeststage.Equals(INIT_STAGE) || requeststage.Equals(DENIED)) && initiatornumber.Equals(staffADProfile.employee_number) ? "true" : "false"; staffADProfile.appperiod = entryModel.AppraisalPeriod; XElement ApprovalHistory = LINQCalls.getApprovalHistory(WorkflowID); XDocument xDocument = DataHandlers.ToXDocument(ApprovalHistory); List <ApprovalDetails> approvalHistory = xDocument.Descendants("Approvals").Select(det => new ApprovalDetails { ApproverNames = det.Element("ApproverName").Value, ApproverStaffNumbers = det.Element("ApproverStaffNumber").Value, ApprovedStages = det.Element("ApprovedStage").Value, ApproverAction = det.Element("ApproverAction").Value, ApprovalDateTime = det.Element("ApprovalDateTime").Value }) .ToList(); SuperPassportModel superPassportModel = new SuperPassportModel(); if (TempData["superPassportModel"] != null) { superPassportModel = TempData["superPassportModel"] as SuperPassportModel; } else { superPassportModel = new SuperPassportModel { WorkflowID = WorkflowID, RequestStageID = entryModel.RequestStageId, RequestStage = entryModel.RequestStage, RequestDate = entryModel.DateSubmitted, StaffADProfile = staffADProfile, RequestDetails = requestDetails, CanSave = cansave, ApprovalDetails = approvalHistory, EntryModel = entryModel, RequestBranch = entryModel.Branch, RequestBranchCode = entryModel.BranchCode }; } Session["requestDetails"] = superPassportModel.RequestDetails; TempData["editMode"] = (editMode == true) ? null : "false"; if (TempData["ErrorMessage"] != null) { ViewBag.ErrorMessage = TempData["ErrorMessage"] as string; } TempData["superPassportModel"] = superPassportModel; return(RedirectToAction("PassportInputForm")); }
public ActionResult PassportInputForm(SuperPassportModel superPassportModel, string PassportAction) { List <RequestDetails> requestDetails = superPassportModel.RequestDetails; IEnumerable <RequestDetails> requestdetails = superPassportModel.RequestDetails; string retVal = ""; switch (PassportAction) { case "CountryCountRefresh": //Form is submitted when the user selects the number of countries List <PassportDetails> passportDetails = new List <PassportDetails>(); string sex = (superPassportModel.StaffADProfile.gender.Equals(1)) ? SEX_FEMALE: SEX_MALE; for (int i = 0; i < superPassportModel.StaffADProfile.countryCount; i++) { PassportDetails pDetails = new PassportDetails(); pDetails.entry_key = ""; pDetails.passportAuthority = ""; pDetails.passportDateOfExpiry = ""; pDetails.passportDateOfIssue = ""; pDetails.passportNationality = ""; pDetails.passportNumber = ""; pDetails.passportOtherNames = ""; pDetails.passportPlaceOfBirth = ""; pDetails.passportSex = sex; pDetails.passportSurname = ""; pDetails.passportType = "P"; pDetails.passportDateOfBirth = superPassportModel.StaffADProfile.dob; pDetails.Nationality = SelectListItemHelper.GetCountries(); passportDetails.Add(pDetails); } superPassportModel.PassportDetails = passportDetails; break; case "Deny": // Good. let's send this f@*ker back //requestDetails.Select(c => { c.entry_key = c.employee_number + "_" + superPassportModel.StaffADProfile.appperiod + "_" + superPassportModel.StaffADProfile.branch_code; return c; }).ToList(); requestDetails.Select(c => { c.workflowid = superPassportModel.WorkflowID; return(c); }).ToList(); // SAVE the value to the DATABASE requestdetails = superPassportModel.RequestDetails; //dataTable = DataHandlers.ToDataTable(requestdetails); //retVal = new AppDatabase().inputPassportEntries(dataTable, superPassportModel, "AppraisalDbConnectionString", DENIED_STATUS); if (retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = retVal; TempData["superPassportModel"] = superPassportModel; } else { //String.format(SUMBMITTEDMSG)--add the approvers var approvers = LINQCalls.getApproverNames(superPassportModel.WorkflowID, -1); TempData["PostBackMessage"] = DENIEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } break; case "Submit": if (ModelState.IsValid) { if (!checkVlaidFileTypes(superPassportModel.PassportDetails)) { ViewBag.ErrorMessage = "Invalid file type. Only \"pdf\" files are supported."; //TempData["superPassportModel"] = superPassportModel; } else { IEnumerable <PassportDetails> _passportDetails = superPassportModel.PassportDetails; _passportDetails.Select(c => { c.entry_key = superPassportModel.StaffADProfile.employee_number + "_" + c.passportNumber.ToUpper(); return(c); }).ToList(); _passportDetails.Select(c => { c.passportFileName = c.passportUpload.FileName; return(c); }).ToList(); _passportDetails.Select(c => { c.passportNumber = c.passportNumber.ToUpper(); return(c); }).ToList(); _passportDetails.Select(c => { c.passportSurname = c.passportSurname.ToUpper(); return(c); }).ToList(); _passportDetails.Select(c => { c.passportOtherNames = c.passportOtherNames.ToUpper(); return(c); }).ToList(); _passportDetails.Select(c => { c.passportPlaceOfBirth = c.passportPlaceOfBirth.ToUpper(); return(c); }).ToList(); _passportDetails.Select(c => { c.passportAuthority = c.passportAuthority.ToUpper(); return(c); }).ToList(); _passportDetails.Select(c => { c.passportContentType = c.passportUpload.ContentType; return(c); }).ToList(); _passportDetails.Select(c => { Stream fs = c.passportUpload.InputStream; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((Int32)fs.Length); c.passportFileBytes = bytes; return(c); }).ToList(); DataTable dataTable = new DataTable(); dataTable = DataHandlers.ToDataTable(_passportDetails); string _retVal = new AppDatabase().inputPassportEntries(dataTable, superPassportModel, "AppraisalDbConnectionString", SUBMIT_STATUS); if (_retVal != null) { TempData["UploadComplete"] = "false"; TempData["ErrorMessage"] = _retVal; TempData["superPassportModel"] = superPassportModel; } else { int newstageid = 0; switch (superPassportModel.RequestStageID) { case 0: newstageid = 3; break; case -1: newstageid = 3; break; case 3: newstageid = 20; break; case 20: newstageid = 100; break; } var approvers = LINQCalls.getHRApproverNames(superPassportModel.WorkflowID, newstageid); TempData["PostBackMessage"] = SUMBMITTEDMSG; TempData["Approvers"] = string.Join("\\n", approvers.ToArray()); return(RedirectToAction("AwaitingMyApproval", "AwaitingApproval")); } } } break; } //superPassportModel.RequestDetails = requestDetails; TempData["superPassportModel"] = superPassportModel; return(RedirectToAction("PassportInputForm")); }