Example #1
0
        public bool UpdateStatus()
        {
            bool           isSaved = false;
            SqlTransaction tran    = null;
            SqlConnection  conn    = null;
            int            at      = -1;

            try
            {
                TrucksMissingOnSamplingBLL objNew = new TrucksMissingOnSamplingBLL();
                TrucksMissingOnSamplingBLL objOld = TrucksMissingOnSamplingDAL.GetById(this.Id);
                objNew        = objOld.Copy(objOld);
                objNew.Id     = this.Id;
                objNew.Status = this.Status;
                conn          = Connection.getConnection();
                tran          = conn.BeginTransaction();
                isSaved       = TrucksMissingOnSamplingDAL.SetStatus(objNew.Id, objNew.Status, tran);
                if (isSaved == true)
                {
                    AuditTrailBLL objAt = new AuditTrailBLL();
                    at = objAt.saveAuditTrail(objNew, objOld, WFStepsName.TrucksMissingForSamp.ToString(), UserBLL.GetCurrentUser(), "Update Status Missing Traucks");
                    if (at == 1)
                    {
                        tran.Commit();
                    }
                    else
                    {
                        tran.Rollback();
                        isSaved = false;
                    }
                }
                else
                {
                    isSaved = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (tran != null)
                {
                    tran.Dispose();
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(isSaved);
        }
Example #2
0
        public TrucksMissingOnSamplingBLL Copy(TrucksMissingOnSamplingBLL obj)
        {
            TrucksMissingOnSamplingBLL objC = new TrucksMissingOnSamplingBLL();

            objC.Id = obj.Id;
            objC.TrucksForSamplingId = obj.TrucksForSamplingId;
            objC.DateTimeReported    = obj.DateTimeReported;
            objC.Status                = obj.Status;
            objC.Remark                = obj.Remark;
            objC.WarehouseId           = obj.WarehouseId;
            objC.ReRequestedTime       = obj.ReRequestedTime;
            objC.IsRequested           = obj.IsRequested;
            objC.TrailerPlateNo        = obj.TrailerPlateNo;
            objC.PlateNo               = obj.PlateNo;
            objC.TrackingNo            = obj.TrackingNo;
            objC.CreatedBy             = obj.CreatedBy;
            objC.CreatedTimestamp      = obj.CreatedTimestamp;
            objC.LastModifiedBy        = obj.LastModifiedBy;
            objC.LastModifiedTimestamp = obj.LastModifiedTimestamp;

            return(objC);
        }
Example #3
0
        public bool Confirm(List <TrucksForSamplingBLL> list)
        {
            SqlTransaction tran;
            SqlConnection  conn;

            conn = Connection.getConnection();
            tran = conn.BeginTransaction();

            //List<MesseageTracking> msgList = new List<MesseageTracking>();
            //msgList = (List<MesseageTracking>)HttpContext.Current.Session["msgList"];
            try
            {
                bool isSaved = false;

                foreach (TrucksForSamplingBLL obj in list)
                {
                    if (obj.Status == TrucksForSamplingStatus.Confirmed)
                    {
                        ECXWF.CMessage msg = null;
                        try
                        {
                            msg = WFTransaction.Request(obj.TrackingNo.ToString().Trim());
                        }
                        catch
                        {
                            msg = null;
                        }
                        if (msg != null)
                        {
                            if (msg.Name.Trim().ToUpper() == "ConfirmTrucksForSamp".ToUpper().Trim())
                            {
                                isSaved = TrucksForSamplingDAL.UpdateConfirmation(obj, tran);
                                if (isSaved == true)
                                {
                                    string        strNew = "(Id=" + obj.Id.ToString() + "),(Status-" + obj.Status.ToString() + "),(Remark-" + obj.Remark.ToString() + "),(LastModifiedBy-" + UserBLL.GetCurrentUser().ToString() + "),(LastModifiedTimeStamp-" + DateTime.Now.ToString() + ")";
                                    int           at     = -1;
                                    AuditTrailBLL objAt  = new AuditTrailBLL();
                                    at = objAt.saveAuditTrailStringFormat("Truck Ready For Sampling Confirmed", strNew, WFStepsName.ConfirmTrucksForsamp.ToString(), UserBLL.GetCurrentUser(), "Confirm Trucks for sampling");
                                    if (at == 1)
                                    {
                                        #region depricatedcode
                                        //var xmsg = (from c in msgList
                                        //        where c.trackingNo == obj.TrackingNo
                                        //        select c.message).Single();
                                        //ECXWF.CMessage msg = (ECXWF.CMessage)xmsg;


                                        //foreach (MesseageTracking i in msgList)
                                        //{
                                        //    if (i.trackingNo.Trim().ToUpper() == obj.TrackingNo.Trim().ToUpper())
                                        //    {
                                        //        msg = i.message;
                                        //    }
                                        //}
                                        //if (msg == null)
                                        //{
                                        //    throw new Exception("Invalid Message Exception");
                                        //}
                                        #endregion

                                        WFTransaction.WorkFlowManager(obj.TrackingNo.Trim(), msg);
                                    }
                                    else
                                    {
                                        isSaved = false;
                                    }
                                }
                                else
                                {
                                    isSaved = false;
                                }
                            }
                            else
                            {
                                WFTransaction.UnlockTask(obj.TrackingNo.Trim());
                            }
                        }
                    }
                    else
                    {
                        TrucksMissingOnSamplingBLL objTM = new TrucksMissingOnSamplingBLL();
                        objTM.Id = Guid.NewGuid();
                        objTM.TrucksForSamplingId = obj.Id;
                        objTM.DateTimeReported    = DateTime.Now;
                        objTM.Remark           = obj.Remark;
                        objTM.Status           = TrucksMissingOnSamplingStatus.New;
                        objTM.CreatedBy        = UserBLL.GetCurrentUser();
                        objTM.CreatedTimestamp = DateTime.Now;
                        objTM.WarehouseId      = UserBLL.GetCurrentWarehouse();
                        objTM.TrackingNo       = obj.TrackingNo;
                        isSaved = objTM.Save(tran);
                    }

                    if (isSaved == false)
                    {
                        tran.Rollback();
                        return(false);
                    }
                }

                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            finally
            {
                tran.Dispose();
                conn.Close();
            }
            return(true);
        }