Exemplo n.º 1
0
 public void SaveUpdateConveyance(Conveyance model)
 {
     try
     {
         var userid = _httpContextAccessor.HttpContext.User.GetLoggedInUserId <string>();
         if (string.IsNullOrEmpty(userid))
         {
             throw new InvalidOperationException("User Not found");
         }
         CoreSQLConnection CoreSQL = new CoreSQLConnection();
         var Query   = "SELECT  cast(count( Isnull(visitid,0))  AS float)  AS visitid FROM tblConveyance_Main where visitid = '" + model.visitId + "'";
         var visitid = CoreSQL.CoreSQL_GetDoubleData(Query);
         if (visitid > 0)
         {
             UpdateConveyance(model);
         }
         else
         {
             SaveConveyance(model);
         }
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(ex.Message);
     }
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ConId,RegNum,StdName,Clss,RollNo,Gender,Parents,Address,UniReg,StopId,Stops,RouteId,DateFrom,DateTo")] Conveyance conveyance)
        {
            if (id != conveyance.ConId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(conveyance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConveyanceExists(conveyance.ConId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(conveyance));
        }
Exemplo n.º 3
0
        public string SaveConveyance(Conveyance model)
        {
            var userid = _httpContextAccessor.HttpContext.User.GetLoggedInUserId <string>();

            if (string.IsNullOrEmpty(userid))
            {
                throw new InvalidOperationException("User Not found");
            }

            CoreSQLConnection CoreSQL   = new CoreSQLConnection();
            ArrayList         arrayList = new ArrayList();
            var Query = "SELECT  cast(Isnull(MAX(ConveyId),0) + 1 AS float)  AS ConveyId FROM tblConveyance_Main";
            var NewId = CoreSQL.CoreSQL_GetDoubleData(Query);

            if (String.IsNullOrEmpty(model.ConveyDescription))
            {
                model.ConveyDescription = "";
            }
            var sqlQuery = "Insert Into tblConveyance_Main(ConveyId, dtConveyance, LUserId, visitid ,ConveyDescription)" +
                           " Values ('" + NewId + "', getdate(),'" + userid + "','" + model.visitId + "',N'" + model.ConveyDescription.Replace("'", "`") + "')";

            arrayList.Add(sqlQuery);

            sqlQuery = "Insert Into tblConveyance_Sub(ConveyId, ConveyTypeId, ConveyAmount)" +
                       " Values ('" + NewId + "', '" + model.conveyTypeId + "', '" + model.conveyAmount + "')";
            arrayList.Add(sqlQuery);


            CoreSQL.CoreSQL_SaveDataUseSQLCommand(arrayList);
            return("Success");
        }
Exemplo n.º 4
0
        public string UpdateConveyance(Conveyance model)
        {
            var userid = _httpContextAccessor.HttpContext.User.GetLoggedInUserId <string>();

            if (string.IsNullOrEmpty(userid))
            {
                throw new InvalidOperationException("User Not found");
            }

            CoreSQLConnection CoreSQL   = new CoreSQLConnection();
            ArrayList         arrayList = new ArrayList();

            var Query    = "SELECT  cast(Isnull(ConveyId,0)  AS float)  AS ConveyId FROM tblConveyance_Main where visitid = '" + model.visitId + "'";
            var ConveyId = CoreSQL.CoreSQL_GetDoubleData(Query);

            if (ConveyId == 0)
            {
                throw new InvalidOperationException("Conveyance History Not found");
            }

            var sqlQuery = "delete tblConveyance_Sub where ConveyId = '" + ConveyId + "'";

            arrayList.Add(sqlQuery);

            sqlQuery = "Update tblConveyance_Main set dtConveyance = getdate() , LUserId = '" + userid + "', ConveyDescription= N'" + model.ConveyDescription.Replace("'", "`") + "' where ConveyId = '" + ConveyId + "'";
            arrayList.Add(sqlQuery);

            sqlQuery = "Insert Into tblConveyance_Sub(ConveyId, ConveyTypeId, ConveyAmount)" +
                       " Values ('" + ConveyId + "', '" + model.conveyTypeId + "', '" + model.conveyAmount + "')";
            arrayList.Add(sqlQuery);

            CoreSQL.CoreSQL_SaveDataUseSQLCommand(arrayList);
            return("Success");
        }
Exemplo n.º 5
0
    public virtual void FindPath(ref Conveyance currentConveyance, ref List <Destination> destinations)
    {
        //Debug.Break();

        //get walking path distance
        Vector3 guestPosition       = transform.position;
        Vector3 destinationPosition = Destination.transform.position;
        float   distance            = AgentWalkDistance(_agent, transform, guestPosition, destinationPosition, Color.yellow);

        //test all conveyances
        currentConveyance = null;
        Conveyance[] conveyances = GameObject.FindObjectsOfType <Conveyance>();
        foreach (Conveyance c in conveyances)
        {
            //guard statement,
            if (c.IsFull())
            {
                continue;             //how many people are on the conveyance
            }
            if (!c.IsConveyanceActive())
            {
                continue;                          //is conveyance active
            }
            float distToC   = AgentWalkDistance(_agent, transform, guestPosition, c.StartPosition(guestPosition, this), Color.green);
            float distC     = c.WeightedTravelDistance(guestPosition, destinationPosition, this);
            float distFromC = AgentWalkDistance(_agent, transform, c.EndPosition(destinationPosition, this), destinationPosition, Color.red);

            //Debug.DrawLine(guestPosition, c.StartPosition(), Color.black);
            Debug.DrawLine(c.StartPosition(guestPosition, this), c.EndPosition(destinationPosition, this), Color.cyan);
            //Debug.DrawLine(c.EndPosition(), destinationPosition, Color.white);

            if (distance > distToC + distC + distFromC)
            {
                currentConveyance = c;
                distance          = distToC + distC + distFromC;
            }
        }

        //if there are no conveyances, we update the destination list with current destination
        if (currentConveyance == null)
        {
            destinations.Clear();
            destinations.Add(Destination);
            UpdateDestination();
            return;
        }

        //update destinations
        if (currentConveyance.GetType() == typeof(Vehicle))
        {
            Vehicle vehicle = _currentConveyance as Vehicle;
            vehicle.SetWaiting(this);
        }

        destinations.Clear();
        destinations.Add(currentConveyance.GetDestination(guestPosition, this));
        destinations.Add(Destination);
        Destination = destinations[0];
        UpdateDestination();
    }
Exemplo n.º 6
0
 private void DestinationDistance()
 {
     //test agent distance from destination
     if (Vector3.Distance(transform.position, Destination.transform.position) < 1.1f)
     {
         if (Destination.GetComponentInParent <Conveyance>())
         {
             Status             = Action.RIDING;
             _agent.enabled     = false;
             _currentConveyance = Destination.GetComponentInParent <Conveyance>();
             return;
         }
         else if (Destination.tag == "Bath")
         {
             StartBath();
             return;
         }
         else if (Destination.tag == "Entrance")
         {
             Destination.gameObject.GetComponent <GuestManager>().GuestExit(this);
             //GuestManager manager = Destination.gameObject.GetComponent<GuestManager>();
             //manager.GuestExit(this);
             return;
         }
     }
 }
Exemplo n.º 7
0
    private void ToggleConveyanceActivation()
    {
        Vector3    screenPoint = Input.mousePosition;                       //mouse position on the screen
        Ray        ray         = Camera.main.ScreenPointToRay(screenPoint); //converting the mouse position to ray from mouse position
        RaycastHit hit;

        if (!Physics.Raycast(ray.origin, ray.direction * 1000, out hit))
        {
            return;                                                              //was something hit?
        }
        Debug.Log(hit.transform.gameObject.name);
        if (!hit.transform.gameObject.GetComponentInParent <Conveyance>())
        {
            return;                                                               //was hit on the layer?
        }
        //if a layer was hit, set the camera follow and lookat
        Conveyance conveyance = hit.transform.gameObject.GetComponentInParent <Conveyance>();

        //if IsActive is public, you can do this, conveyance.IsActive = !conveyance.IsActive;
        if (conveyance.IsConveyanceActive())
        {
            conveyance.Deactivate();
        }
        else
        {
            conveyance.Activate();
        }
    }
Exemplo n.º 8
0
        /// <summary>
        /// ตรวจสอบว่าข้อมูลที่กรอกเข้ามาถูกต้องหรือไม่
        /// โดยเป็นส่วนของ logic ที่ไม่สามารถระบุใน metadata ไม่ได้ และไม่ได้ระบุเอาไว้ใน constraint ของ database
        /// </summary>
        /// <param name="conv"></param>
        /// <param name="isCreate"></param>
        private void _validate(Conveyance conv, bool isCreate)
        {
            var errors = new RulesException <Conveyance>();

            if (errors.Errors.Any())
            {
                throw errors;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// prepare data and save to ef, ใช้ทั้ง update และ insert
        /// </summary>
        /// <param name="conv"></param>
        /// <param name="isCreate">ส่ง true ถ้าต้องการ insert</param>
        public void DoSave(Conveyance conv, bool isCreate)
        {
            if (isCreate)
            {
                _add(conv);
            }

            _doBeforePost(conv);
            _validate(conv, isCreate);
            _saveCheckCode(conv);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("ConId,RegNum,StdName,Clss,RollNo,Gender,Parents,Address,UniReg,StopId,Stops,RouteId,DateFrom,DateTo")] Conveyance conveyance)
        {
            if (ModelState.IsValid)
            {
                _context.Add(conveyance);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(conveyance));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> PutConveyance([FromRoute] int id, [FromBody] Conveyance conveyance)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                conveyance.StopId = SchDataApi.GenFunc.ConVeyFunc.getStopID(_context, conveyance.Stops, conveyance.DBid);
                var conn = _context.Database.GetDbConnection();
                if (conn.State == ConnectionState.Closed)
                {
                    await conn.OpenAsync();
                }
                using (var command = conn.CreateCommand())
                {
                    if (conveyance.Stops == "None")
                    {
                        if (conveyance.ConId != 0)
                        {
                            MySql = " UPDATE Conveyance SET ";
                            MySql = MySql + " Dormant = 1 ";
                            MySql = MySql + " WHERE ConID = " + conveyance.ConId;
                            MySql = MySql + " AND RegNumber = " + conveyance.RegNum;
                            command.CommandType = CommandType.Text;
                            command.CommandText = MySql;
                            command.ExecuteNonQuery();
                        }
                    }
                    else
                    {
                        MySql = " INSERT INTO Conveyance (ConID, RegNum, StopID, ClssName, RouteID, DateFrom, "
                                + " UniReg, ";
                        MySql = MySql + " Dormant, LoginName, ModTime, cTerminal, dBID) Values (0, ";
                        MySql = MySql + conveyance.RegNum + "," + conveyance.StopId + ",'"
                                + conveyance.Clss + "'," + conveyance.RouteId + ","
                                + SchDataApi.GenFunc.GloFunc.ToOADate(conveyance.DateFrom) + ",0,";
                        MySql = MySql + "0,'" + conveyance.LoginName + "'," + SchDataApi.GenFunc.GloFunc.ToOADate(DateTime.Now);
                        MySql = MySql + ",'" + conveyance.CTerminal + "'," + conveyance.DBid + ")";

                        command.CommandType = CommandType.Text;
                        command.CommandText = MySql;
                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(NoContent());
        }
Exemplo n.º 12
0
        public async Task <IActionResult> PostConveyance([FromBody] Conveyance conveyance)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Conveyance.Add(conveyance);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetConveyance", new { id = conveyance.AutoId }, conveyance));
        }
Exemplo n.º 13
0
 public void CopyFrom(Conveyance conv)
 {
     if (conv != null)
     {
         this.Id             = conv.Id;
         this.Name           = conv.Name;
         this.OwnerName      = conv.OwnerName;
         this.RegistrationNo = conv.RegistrationNo;
         this.UpdateInfo     = conv.UpdateInfo;
         this.IsCancel       = conv.IsCancel;
     }
 }
Exemplo n.º 14
0
 public IActionResult SaveConveyance([FromBody] Conveyance model)
 {
     try
     {
         _conveyanceQuery.SaveUpdateConveyance(model);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// เรียกการบันทึกข้อมูล โดยตรวจสอบว่า Code ซ้ำหรือไม่
 /// </summary>
 /// <param name="conv"></param>
 /// <param name="numRecursive">จำนวนที่ให้วน loop ปรกติไม่ต้องใส่มา</param>
 private void _saveCheckCode(Conveyance conv, int numRecursive = 5)
 {
     try
     {
         _save();
     }
     catch (ApplicationException ex)
     {
         var clash = new RulesException <Conveyance>();
         clash.ErrorFor(x => x.Name, "Error :" + ex.ExMessage());
         throw clash;
     }
 }
Exemplo n.º 16
0
    private void DestinationDistance()
    {
        //test agent distance from destination
        //UpdateDestination();

        if (Vector3.Distance(transform.position, Destination.transform.position) < 2.1f)
        {
            //Debug.Log(Destination);
            if (Destination.GetComponentInParent <Conveyance>())
            {
                Status             = Action.RIDING;
                _agent.enabled     = false;
                _currentConveyance = Destination.GetComponentInParent <Conveyance>();
                return;
            }
            else if (Destination.tag == "Bath")
            {
                if (Destination.GetType() == typeof(DestinationMovingBath))
                {
                    UpdateDestination();
                    GameObject go = Destination.transform.gameObject;
                    _agent.transform.position = go.transform.position;
                    _agent.transform.parent   = go.transform;
                    //Debug.Log(go);
                    StartMovingBath(go);
                    return;
                }
                if (Destination.GetType() == typeof(Destination))
                {
                    StartBath();
                    //Debug.Log("Bath");
                    return;
                }

                //Debug.Log(Destination.name);
            }
            else if (Destination.tag == "Entrance")
            {
                Destination.gameObject.GetComponent <GuestManager>().GuestExit(this);
                Debug.Log("exit");
                //GuestManager manager = Destination.gameObject.GetComponent<GuestManager>();
                //manager.GuestExit(this);
                return;
            }
        }
    }
Exemplo n.º 17
0
    public void FindPath()
    {
        //get walking path distance
        Vector3 guestPosition       = transform.position;
        Vector3 destinationPosition = Destination.transform.position;
        float   distance            = AgentWalkDistance(guestPosition, destinationPosition, Color.magenta);

        //Debug.Break();

        //test all conveyances
        _currentConveyance = null;
        Conveyance[] conveyances = GameObject.FindObjectsOfType <Conveyance>();
        foreach (Conveyance c in conveyances)
        {
            float distToC   = AgentWalkDistance(guestPosition, c.StartPosition(), Color.green);
            float distC     = c.WeightedTravelDistance();
            float distFromC = AgentWalkDistance(c.EndPosition(), destinationPosition, Color.red);

            Debug.DrawLine(guestPosition, c.StartPosition(), Color.cyan);
            Debug.DrawLine(c.StartPosition(), c.EndPosition(), Color.cyan);
            Debug.DrawLine(c.EndPosition(), destinationPosition, Color.cyan);

            if (distance > distToC + distC + distFromC)
            {
                _currentConveyance = c;
                distance           = distToC + distC + distFromC;
            }
        }

        //if there are no conveyances, we update the destination list with current destination
        //Zixuan.Gong:Refactor repeated Lines for Extra Credits.(Also Line 67 is not needed)
        _destinations.Clear();

        if (_currentConveyance == null)
        {
            _destinations.Add(Destination);
        }
        else
        {
            _destinations.Add(_currentConveyance.GetDestination());
            _destinations.Add(Destination);
            Destination = _destinations[0];
        }
        //update destinations
        UpdateDestination();
    }
Exemplo n.º 18
0
    public bool CanGuestSeeConveyance(Conveyance conveyance)
    {
        Vector3    guestPosition = transform.position; //mouse position on the screen
        Vector3    startPosition = conveyance.StartPosition(guestPosition, this);
        RaycastHit hit;

        Debug.DrawLine(guestPosition, startPosition, Color.red);
        Debug.Break();
        if (!Physics.Linecast(guestPosition, startPosition, out hit))
        {
            return(true);
        }                                                                              //if nothing is hit we can assume it is scene
        Debug.Log(conveyance.name + ": " + hit.transform.name + ": " + hit.transform.gameObject.tag);
        Debug.DrawLine(hit.point, guestPosition, Color.cyan);
        if (hit.transform.gameObject.tag != "Conveyance")
        {
            return(false); //if the thing hit was not a conveyance
        }
        return(true);      //if nothing or conveyance was hit
    }
Exemplo n.º 19
0
    public void FindPath()
    {
        //get walking path distance
        Vector3 guestPosition       = transform.position;
        Vector3 destinationPosition = Destination.transform.position;
        float   distance            = AgentWalkDistance(guestPosition, destinationPosition, Color.magenta);

        Debug.Break();

        //test all conveyances
        _currentConveyance = null;
        Conveyance[] conveyances = GameObject.FindObjectsOfType <Conveyance>();
        foreach (Conveyance c in conveyances)
        {
            float distToC   = AgentWalkDistance(guestPosition, c.StartPosition(), Color.green);
            float distC     = c.WeightedTravelDistance();
            float distFromC = AgentWalkDistance(c.EndPosition(), destinationPosition, Color.red);

            Debug.DrawLine(guestPosition, c.StartPosition(), Color.cyan);
            Debug.DrawLine(c.StartPosition(), c.EndPosition(), Color.cyan);
            Debug.DrawLine(c.EndPosition(), destinationPosition, Color.cyan);

            if (distance > distToC + distC + distFromC)
            {
                _currentConveyance = c;
                distance           = distToC + distC + distFromC;
            }
        }

        if (_currentConveyance == null)
        {
            UpdateDestination(); return;
        }

        //update destinations
        _destinations.Clear();
        _destinations.Add(_currentConveyance.GetDestination());
        _destinations.Add(Destination);
        Destination = _destinations[0];
        UpdateDestination();
    }
Exemplo n.º 20
0
        public ActionResult _ConveyanceSearch(string conv_Owner, string conv_Name)
        {
            ViewData["ConveyanceSearch_OwnerName"] = conv_Owner;
            ViewData["ConveyanceSearch_Name"]      = conv_Name;

            var convJSON  = new ConveyanceViewModel();
            int convCount = 0;
            int convId    = 0;

            try
            {
                IEnumerable <Conveyance> convList = convRepo.Search(conv_Owner, conv_Name).ToList();
                if (convList.Count() > 0)
                {
                    convCount = convList.Count();
                    Conveyance conv = convList.FirstOrDefault();
                    if ((conv != null) && (convCount == 1))
                    {
                        convJSON.Conveyance.CopyFrom(conv);
                        convId = conv.Id;
                    }
                }
            }
            catch (FormatException)
            {
            }

            return(new JsonResult
            {
                Data = new
                {
                    convcount = convCount,
                    conv_id = convId,
                    partialview = this.RenderPartialViewToString("ConveyanceEditDetail", convJSON)
                }
            });
        }
Exemplo n.º 21
0
        private static void Translate2_0(Stream CaseXML, ref CaseObject CaseObj)
        {
            CaseObject caseObj = new CaseObject();

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(L3.Cargo.Common.Xml.XCase_2_0.XCase));
                L3.Cargo.Common.Xml.XCase_2_0.XCase xcase = (L3.Cargo.Common.Xml.XCase_2_0.XCase)serializer.Deserialize(CaseXML);

                if (xcase.version == "2.0")
                {
                    caseObj.CaseId = xcase.id;
                    caseObj.createTime = xcase.createTime;
                    caseObj.LinkedCaseId = xcase.linkedCase;
                    caseObj.AbortedBy = xcase.abortedby;
                    caseObj.CurrentArea = xcase.currentArea;

                    Location location = null;
                    if (xcase.scanInfo != null && xcase.scanInfo.location != null)
                    {
                        location = new Location(String.Empty, String.Empty);
                        location.Latitude = xcase.scanInfo.location.latitude;
                        location.Longitude = xcase.scanInfo.location.longitude;
                    }

                    Conveyance convey = null;
                    if (xcase.scanInfo != null && xcase.scanInfo.conveyance != null)
                    {
                        convey = new Conveyance(String.Empty, String.Empty, String.Empty);
                        convey.BatchNum = xcase.scanInfo.conveyance.batchNum;
                        convey.Id = xcase.scanInfo.conveyance.id;
                        convey.TotalWeight = xcase.scanInfo.conveyance.totalWeight;
                    }

                    Container cont = null;
                    if (xcase.scanInfo != null && xcase.scanInfo.container != null)
                    {
                        cont = new Container(String.Empty, String.Empty, String.Empty, String.Empty);
                        cont.Code = xcase.scanInfo.container.code;
                        cont.Id = xcase.scanInfo.container.id;
                        cont.SequenceNum = xcase.scanInfo.container.sequenceNum;
                        cont.Weight = xcase.scanInfo.container.weight;
                    }

                    if (xcase.scanInfo != null)
                        caseObj.scanInfo = new ScanInfo(xcase.scanInfo.type, location, convey, cont);

                    if (xcase.systemInfo != null)
                    {
                        caseObj.systemInfo = new SystemInfo(xcase.systemInfo.systemType, xcase.systemInfo.baseLocation);
                    }


                    caseObj.ResultsList = new List<result>();

                    if (xcase.results != null)
                    {
                        foreach (L3.Cargo.Common.Xml.XCase_2_0.Result result in xcase.results)
                        {
                            WorkstationDecision decision = (WorkstationDecision)Enum.ToObject(typeof(WorkstationDecision), result.decision);
                            caseObj.ResultsList.Add(new result(decision.ToString(), result.reason, result.createTime, result.user, result.comment,
                                result.stationType, result.analysisTime));
                        }
                    }

                    if (xcase.attachments != null)
                    {
                        foreach (L3.Cargo.Common.Xml.XCase_2_0.Attachment attach in xcase.attachments)
                        {
                            DataAttachment attachment = new DataAttachment();
                            attachment.attachmentType = (AttachmentType)Enum.Parse(typeof(AttachmentType), attach.type);
                            attachment.attachmentId = attach.filename;
                            attachment.CreateTime = attach.createTime;
                            attachment.User = attach.user;
                            caseObj.attachments.Add(attachment);
                        }
                    }

                    CaseObj = caseObj;
                }
                else
                {
                    throw new Exception(ErrorMessages.CASE_VERSION_MISMATCH);
                }
            }
            catch (Exception exp)
            {
                throw;
            }
        }
Exemplo n.º 22
0
 //
 // Insert / Delete Method
 /// <summary>
 /// สำหรับเพิ่ม record ลง ef
 /// </summary>
 /// <param name="conv"></param>
 private void _add(Conveyance conv)
 {
     entities.Conveyances.AddObject(conv);
 }
Exemplo n.º 23
0
        private static CaseObject Translate1_0(Stream CaseXML)
        {
            CaseObject caseObj = new CaseObject();

            XmlSerializer serializer = new XmlSerializer(typeof(L3.Cargo.Common.Xml.XCase_1_0.XCase));

            L3.Cargo.Common.Xml.XCase_1_0.XCase xcase = (L3.Cargo.Common.Xml.XCase_1_0.XCase)serializer.Deserialize(CaseXML);

            caseObj.CaseId       = xcase.id;
            caseObj.createTime   = xcase.createTime;
            caseObj.LinkedCaseId = xcase.linkedCase;
            caseObj.AbortedBy    = xcase.abortedBy;
            caseObj.CurrentArea  = xcase.currentArea;

            Location location = null;

            Conveyance convey = null;

            Container cont = null;

            caseObj.attachments = new DataAttachments();

            if (xcase.vehicle != null)
            {
                cont        = new Container(String.Empty, String.Empty, String.Empty, String.Empty);
                cont.Id     = xcase.vehicle.registrationNum;
                cont.Weight = xcase.vehicle.weight.ToString();

                if (xcase.vehicle.manifest != null)
                {
                    foreach (L3.Cargo.Common.Xml.XCase_1_0.Manifest manifest in xcase.vehicle.manifest)
                    {
                        DataAttachment attach = new DataAttachment();
                        attach.attachmentType = AttachmentType.Manifest;
                        attach.attachmentId   = manifest.image;
                        attach.User           = String.Empty;
                        attach.CreateTime     = String.Empty;
                        caseObj.attachments.Add(attach);
                    }
                }
            }

            caseObj.scanInfo = new ScanInfo(String.Empty, location, convey, cont);

            caseObj.systemInfo = new SystemInfo(String.Empty, xcase.siteId);

            if (xcase.xRayImage != null)
            {
                foreach (String str in xcase.xRayImage)
                {
                    DataAttachment attach = new DataAttachment();
                    attach.attachmentType = AttachmentType.XRayImage;
                    attach.attachmentId   = str;
                    attach.User           = String.Empty;
                    attach.CreateTime     = String.Empty;
                    caseObj.attachments.Add(attach);
                }
            }

            if (xcase.attachment != null)
            {
                foreach (L3.Cargo.Common.Xml.XCase_1_0.Attachment atch in xcase.attachment)
                {
                    if (atch.File != String.Empty)
                    {
                        DataAttachment attach = new DataAttachment();
                        if (atch.type.ToLower() == "unknown" || atch.type == String.Empty)
                        {
                            attach.attachmentType = AttachmentType.Unknown;
                        }
                        else
                        {
                            attach.attachmentType = (AttachmentType)Enum.Parse(typeof(AttachmentType), atch.type);
                        }

                        attach.attachmentId = atch.File;
                        attach.User         = String.Empty;
                        attach.CreateTime   = String.Empty;
                        caseObj.attachments.Add(attach);
                    }
                }
            }

            if (xcase.tdsResultFile != null && xcase.tdsResultFile != String.Empty)
            {
                DataAttachment attach = new DataAttachment();
                attach.attachmentType = AttachmentType.TDSResultFile;
                attach.attachmentId   = xcase.tdsResultFile;
                attach.User           = String.Empty;
                attach.CreateTime     = String.Empty;
                caseObj.attachments.Add(attach);
            }

            if (xcase.eventRecord != null)
            {
                caseObj.EventRecords = new List <CaseObject.CaseEventRecord>();

                foreach (L3.Cargo.Common.Xml.XCase_1_0.EventRecord record in xcase.eventRecord)
                {
                    CaseObject.CaseEventRecord eventRecord = new CaseObject.CaseEventRecord(record.createTime, record.description, false);
                    caseObj.EventRecords.Add(eventRecord);
                }
            }

            caseObj.ResultsList = new List <result>();

            if (xcase.awsResult != null)
            {
                String decision;

                switch (xcase.awsResult.decision)
                {
                case L3.Cargo.Common.Xml.XCase_1_0.AWSDecision.AWS_CAUTION:
                    decision = WorkstationDecision.Caution.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.AWSDecision.AWS_CLEAR:
                    decision = WorkstationDecision.Clear.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.AWSDecision.AWS_REJECT:
                    decision = WorkstationDecision.Reject.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.AWSDecision.AWS_UNKNOWN:
                    decision = WorkstationDecision.Unknown.ToString();
                    break;

                default:
                    decision = WorkstationDecision.Unknown.ToString();
                    break;
                }

                result res = new result(decision, xcase.awsResult.reason.ToString(),
                                        String.Empty, xcase.awsResult.awsUserId, xcase.awsResult.comment, "Analyst", String.Empty);

                caseObj.ResultsList.Add(res);
            }

            if (xcase.ewsResult != null)
            {
                String decision;

                switch (xcase.ewsResult.decision)
                {
                case L3.Cargo.Common.Xml.XCase_1_0.EWSDecision.EWS_RELEASE:
                case L3.Cargo.Common.Xml.XCase_1_0.EWSDecision.EWS_CLEAR:
                    decision = WorkstationDecision.Clear.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.EWSDecision.EWS_REJECT:
                    decision = WorkstationDecision.Reject.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.EWSDecision.EWS_UNKNOWN:
                    decision = WorkstationDecision.Unknown.ToString();
                    break;

                default:
                    decision = WorkstationDecision.Unknown.ToString();
                    break;
                }

                result res = new result(decision, String.Empty,
                                        String.Empty, xcase.ewsResult.ewsUserId, xcase.ewsResult.comment, "EWS", String.Empty);

                caseObj.ResultsList.Add(res);
            }

            if (xcase.insResult != null)
            {
                String decision;

                switch (xcase.insResult.decision)
                {
                case L3.Cargo.Common.Xml.XCase_1_0.INSDecision.INS_CLEAR:
                    decision = WorkstationDecision.Clear.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.INSDecision.INS_REJECT:
                    decision = WorkstationDecision.Reject.ToString();
                    break;

                default:
                    decision = WorkstationDecision.Unknown.ToString();
                    break;
                }

                result res = new result(decision, String.Empty,
                                        String.Empty, xcase.insResult.insUserId, xcase.insResult.comment, "Inspector", String.Empty);

                caseObj.ResultsList.Add(res);
            }

            if (xcase.supResult != null)
            {
                String decision;

                switch (xcase.supResult.decision)
                {
                case L3.Cargo.Common.Xml.XCase_1_0.SUPDecision.SUP_CLEAR:
                    decision = WorkstationDecision.Clear.ToString();
                    break;

                case L3.Cargo.Common.Xml.XCase_1_0.SUPDecision.SUP_REJECT:
                    decision = WorkstationDecision.Reject.ToString();
                    break;

                default:
                    decision = WorkstationDecision.Unknown.ToString();
                    break;
                }

                result res = new result(decision, String.Empty,
                                        String.Empty, xcase.supResult.supUserId, xcase.supResult.comment, "Supervisor", String.Empty);

                caseObj.ResultsList.Add(res);
            }

            return(caseObj);
        }
Exemplo n.º 24
0
 /// <summary>
 /// prepare data and delete from ef
 /// </summary>
 /// <param name="conv"></param>
 public void DoDelete(Conveyance conv)
 {
     _delete(conv);
     _save();
 }
Exemplo n.º 25
0
        public IEnumerable <Conveyance> Get(string clss, float stDate, string dSess, int mdBId)
        {
            string            fName          = "";
            string            mName          = "";
            string            lName          = "";
            string            strReg         = "";
            List <Conveyance> ConveyanceList = new List <Conveyance>();
            var conn = _context.Database.GetDbConnection();

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            using (var command = conn.CreateCommand())
            {
                MySql = " SELECT  RegNumber, FirstName, MiddleName, LastName, PresentRollNo, Address, Address1, City," +
                        " State, PostalCode FROM Students  WITH (NOLOCK) ";
                MySql = MySql + " WHERE  Dormant = 0";
                MySql = MySql + " AND dBID = " + mdBId;
                MySql = MySql + " AND PresentClass = '" + clss + "'";
                MySql = MySql + " AND StdSession = '" + dSess + "'";
                MySql = MySql + " AND StdStatus <= 0";
                command.CommandType = CommandType.Text;
                command.CommandText = MySql;
                DbDataReader kMyReader = command.ExecuteReader();
                if (kMyReader.HasRows)
                {
                    while (kMyReader.Read())
                    {
                        Conveyance convs = new Conveyance();

                        if (!kMyReader.IsDBNull(0))
                        {
                            convs.RegNum = kMyReader.GetInt32(0);
                            strReg       = strReg + ", " + convs.RegNum;
                        }
                        if (!kMyReader.IsDBNull(1))
                        {
                            fName = kMyReader.GetString(1);
                        }
                        if (!kMyReader.IsDBNull(2))
                        {
                            mName = kMyReader.GetString(2);
                        }
                        if (!kMyReader.IsDBNull(3))
                        {
                            lName = kMyReader.GetString(3);
                        }
                        convs.StdName = fName + " " + mName + " " + lName;
                        if (!kMyReader.IsDBNull(4))
                        {
                            convs.RollNo = kMyReader.GetInt32(4);
                        }
                        if (!kMyReader.IsDBNull(5))
                        {
                            convs.Address = kMyReader.GetString(5);
                        }
                        if (!kMyReader.IsDBNull(6))
                        {
                            convs.Address = convs.Address + ": " + kMyReader.GetString(6);
                        }
                        if (!kMyReader.IsDBNull(7))
                        {
                            convs.Address = convs.Address + ": " + kMyReader.GetString(7);
                        }
                        if (!kMyReader.IsDBNull(8))
                        {
                            convs.Address = convs.Address + ": " + kMyReader.GetString(8);
                        }
                        if (!kMyReader.IsDBNull(9))
                        {
                            convs.Address = convs.Address + ": " + kMyReader.GetString(9);
                        }
                        convs.StopId = 0;
                        ConveyanceList.Add(convs);
                    }
                }
                kMyReader.Close();
                if (strReg.Trim(',') != "")
                {
                    MySql = " SELECT   ConID, RegNum, StopId, RouteID, DateFrom "
                            + " FROM Conveyance WITH (NOLOCK)";
                    MySql = MySql + " WHERE Dormant = 0";
                    MySql = MySql + " AND RegNum IN (" + strReg.Trim(',') + ")";
                    MySql = MySql + " AND dBID = " + mdBId;
                    MySql = MySql + " AND DateFrom <= " + (int)stDate;
                    MySql = MySql + " ORDER BY DateFrom ASC ";
                    command.CommandType = CommandType.Text;
                    command.CommandText = MySql;
                    kMyReader           = command.ExecuteReader();
                    if (kMyReader.HasRows)
                    {
                        while (kMyReader.Read())
                        {
                            foreach (Conveyance conv in ConveyanceList)
                            {
                                if (!kMyReader.IsDBNull(0))
                                {
                                    if (conv.RegNum == kMyReader.GetInt32(1))
                                    {
                                        conv.ConId    = kMyReader.GetInt32(0);
                                        conv.StopId   = kMyReader.GetInt32(2);
                                        conv.DateFrom = DateTime.FromOADate(kMyReader.GetDouble(4));
                                    }
                                }
                            }
                        }
                    }
                    kMyReader.Close();
                    foreach (Conveyance conv in ConveyanceList)
                    {
                        if (conv.StopId != 0)
                        {
                            MySql = " SELECT   Stops, FareFromMonth, ConveyanceMode, Circuit, MonthlyFare "
                                    + " FROM Stops WITH (NOLOCK)";
                            MySql = MySql + " WHERE Dormant = 0";
                            MySql = MySql + " AND dBID = " + mdBId;
                            MySql = MySql + " AND StopID = " + conv.StopId;
                            MySql = MySql + " AND FareFromMonth <= " + (int)stDate;
                            MySql = MySql + " ORDER BY FareFromMonth ASC ";
                            command.CommandType = CommandType.Text;
                            command.CommandText = MySql;
                            kMyReader           = command.ExecuteReader();
                            if (kMyReader.HasRows)
                            {
                                while (kMyReader.Read())
                                {
                                    conv.Stops = kMyReader.GetString(0);
                                    conv.Fare  = kMyReader.GetDouble(4);
                                }
                            }
                            kMyReader.Close();
                        }
                    }
                }
            }
            return(ConveyanceList);
        }
Exemplo n.º 26
0
        public ActionResult Edit(int id)
        {
            Conveyance alien = convRepo.GetOne(id);

            return(View(alien));
        }
Exemplo n.º 27
0
        private static void Translate2_0(Stream CaseXML, ref CaseObject CaseObj)
        {
            CaseObject caseObj = new CaseObject();

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(L3.Cargo.Common.Xml.XCase_2_0.XCase));
                L3.Cargo.Common.Xml.XCase_2_0.XCase xcase = (L3.Cargo.Common.Xml.XCase_2_0.XCase)serializer.Deserialize(CaseXML);

                if (xcase.version == "2.0")
                {
                    caseObj.CaseId       = xcase.id;
                    caseObj.createTime   = xcase.createTime;
                    caseObj.LinkedCaseId = xcase.linkedCase;
                    caseObj.AbortedBy    = xcase.abortedby;
                    caseObj.CurrentArea  = xcase.currentArea;

                    Location location = null;
                    if (xcase.scanInfo != null && xcase.scanInfo.location != null)
                    {
                        location           = new Location(String.Empty, String.Empty);
                        location.Latitude  = xcase.scanInfo.location.latitude;
                        location.Longitude = xcase.scanInfo.location.longitude;
                    }

                    Conveyance convey = null;
                    if (xcase.scanInfo != null && xcase.scanInfo.conveyance != null)
                    {
                        convey             = new Conveyance(String.Empty, String.Empty, String.Empty);
                        convey.BatchNum    = xcase.scanInfo.conveyance.batchNum;
                        convey.Id          = xcase.scanInfo.conveyance.id;
                        convey.TotalWeight = xcase.scanInfo.conveyance.totalWeight;
                    }

                    Container cont = null;
                    if (xcase.scanInfo != null && xcase.scanInfo.container != null)
                    {
                        cont             = new Container(String.Empty, String.Empty, String.Empty, String.Empty);
                        cont.Code        = xcase.scanInfo.container.code;
                        cont.Id          = xcase.scanInfo.container.id;
                        cont.SequenceNum = xcase.scanInfo.container.sequenceNum;
                        cont.Weight      = xcase.scanInfo.container.weight;
                    }

                    if (xcase.scanInfo != null)
                    {
                        caseObj.scanInfo = new ScanInfo(xcase.scanInfo.type, location, convey, cont);
                    }

                    if (xcase.systemInfo != null)
                    {
                        caseObj.systemInfo = new SystemInfo(xcase.systemInfo.systemType, xcase.systemInfo.baseLocation);
                    }


                    caseObj.ResultsList = new List <result>();

                    if (xcase.results != null)
                    {
                        foreach (L3.Cargo.Common.Xml.XCase_2_0.Result result in xcase.results)
                        {
                            WorkstationDecision decision = (WorkstationDecision)Enum.ToObject(typeof(WorkstationDecision), result.decision);
                            caseObj.ResultsList.Add(new result(decision.ToString(), result.reason, result.createTime, result.user, result.comment,
                                                               result.stationType, result.analysisTime));
                        }
                    }

                    if (xcase.attachments != null)
                    {
                        foreach (L3.Cargo.Common.Xml.XCase_2_0.Attachment attach in xcase.attachments)
                        {
                            DataAttachment attachment = new DataAttachment();
                            attachment.attachmentType = (AttachmentType)Enum.Parse(typeof(AttachmentType), attach.type);
                            attachment.attachmentId   = attach.filename;
                            attachment.CreateTime     = attach.createTime;
                            attachment.User           = attach.user;
                            caseObj.attachments.Add(attachment);
                        }
                    }

                    CaseObj = caseObj;
                }
                else
                {
                    throw new Exception(ErrorMessages.CASE_VERSION_MISMATCH);
                }
            }
            catch (Exception exp)
            {
                throw;
            }
        }
Exemplo n.º 28
0
 public ConveyanceLite(Conveyance conv)
 {
     this.CopyFrom(conv);
 }
Exemplo n.º 29
0
    public void FindPath()
    {
        NavMeshPath navMeshPath = _agent.path;

        if (!_agent.CalculatePath(Destination.transform.position, navMeshPath))
        {
            return;
        }

        Vector3[] path = navMeshPath.corners;
        if (path.Length < 2)
        {
            return;
        }

        //get walking path distance
        float distance = 0;

        for (int i = 1; i < path.Length; i++)
        {
            distance += Vector3.Distance(path[i - 1], path[i]);
            Debug.DrawLine(path[i - 1], path[i], Color.red);
        }
        Debug.Break();
        //code below break still runs

        //test all conveyances
        _currentConveyance = null;
        Vector3 guestPosition       = transform.position;
        Vector3 destinationPosition = Destination.transform.position;

        Conveyance[] conveyances = GameObject.FindObjectsOfType <Conveyance>();
        foreach (Conveyance c in conveyances)
        {
            float distToC   = Vector3.Distance(guestPosition, c.StartPosition());
            float distC     = c.WeightedTravelDistance();
            float distFromC = Vector3.Distance(c.EndPosition(), destinationPosition);

            Debug.DrawLine(guestPosition, c.StartPosition(), Color.cyan);
            Debug.DrawLine(c.StartPosition(), c.EndPosition(), Color.cyan);
            Debug.DrawLine(c.EndPosition(), destinationPosition, Color.cyan);

            if (distance > distToC + distC + distFromC)
            {
                _currentConveyance = c;
                distance           = distToC + distC + distFromC;
            }
        }

        if (_currentConveyance == null)
        {
            UpdateDestination(); return;
        }

        //update destinations
        _destinations.Clear();
        _destinations.Add(_currentConveyance.GetDestination());
        _destinations.Add(Destination);
        Destination = _destinations[0];
        UpdateDestination();
    }
Exemplo n.º 30
0
 public ConveyanceViewModel(Conveyance conv)
 {
     this.Conveyance = new ConveyanceLite();
     this.Conveyance.CopyFrom(conv);
 }
Exemplo n.º 31
0
 /// <summary>
 /// สำหรับลบ record ออกจาก ef รวมทั้งลบลูกที่เกี่ยวข้อง (ถ้ามี)
 /// </summary>
 /// <param name="conv"></param>
 private void _delete(Conveyance conv)
 {
     // ถ้ามี ref ตัวลูก ให้ loop ลบ ref ก่อน...
     //entities.Conveyances.DeleteObject(conv);
     conv.IsCancel = true;
 }