Exemplo n.º 1
0
        public bool ImportSerialToEpicor(SessionInfo _session, PlanningHeadModel model, out string msg)
        {
            msg = string.Empty;
            //boolean IsSuccess = false;
            Session currSession;
            var resultContinue = GetSerialAllByWorkOrder(model.WorkOrderID).ToList();
            try
            {
                currSession = new Session(_session.UserID, _session.UserPassword, _session.AppServer, Session.LicenseType.Default);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return false;
            }

            foreach (var item in resultContinue)
            {
                try
                {
                    LotSelectUpdate lotPart = new LotSelectUpdate(currSession.ConnectionPool);
                    LotSelectUpdateDataSet dsLot = new LotSelectUpdateDataSet();
                    lotPart.GetNewPartLot(dsLot, string.IsNullOrEmpty(item.NORNum) ? item.MCSSNo : item.NORNum);

                    DataRow drLot = dsLot.Tables[0].Rows[0];
                    drLot.BeginEdit();

                    drLot["LotNum"] = item.SerialNo;
                    drLot["PartLotDescription"] = item.SerialNo;
                    drLot["Number01"] = item.Thick;
                    drLot["Number02"] = item.Width;
                    drLot["Number03"] = item.Length;
                    drLot["Number04"] = item.UnitWeight;
                    drLot["Number05"] = 1;
                    drLot["Number08"] = 0;
                    drLot["Character02"] = item.BussinessType.GetString();
                    drLot["ShortChar06"] = item.WorkOrderNum.ToString();
                    drLot["Date05"] = DateTime.Now;

                    drLot.EndEdit();
                    lotPart.Update(dsLot);
                    msg = "Successful";
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                }

                string sql = string.Format(@"UPDATE ucc_pln_SerialGenerated
                                                SET GeneratedFlag = 1 --<GeneratedFlag, tinyint,>
                                                    ,LastUpdateDate = GETDATE() --<LastUpdateDate, datetime,>
                                                    ,UpdatedBy = N'{1}' --<UpdatedBy, nvarchar(45),>
                                                    ,ImportMessage = N'{2}' --<ImportMessage, nvarchar(max),>
                                                WHERE SerialNo =  N'{0}'", item.SerialNo, _session.UserID, msg);
                Repository.Instance.ExecuteWithTransaction(sql, "Update Import SN");
            }

            return true;
        }
Exemplo n.º 2
0
        public bool ClearSerialInEpicor(SessionInfo _session, ProductionHeadModel model, out string msg)
        {
            msg = string.Empty; bool IsSuccess = false; Session currSession;
            try
            {
                currSession = new Session(_session.UserID, _session.UserPassword, _session.AppServer, Session.LicenseType.Default);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return false;
            }

            foreach (var item in model.SerialLines.Where(i => i.CutSeq.Equals(model.CutSeq)))
            {
                try
                {
                    LotSelectUpdate lotPart = new LotSelectUpdate(currSession.ConnectionPool);
                    lotPart.DeleteByID(item.MCSSNo, item.SerialNo);
                }
                catch (Exception ex)
                {
                    msg = ex.Message + ": Status = " + IsSuccess.ToString();
                    IsSuccess = false;
                }
            }
            string sql = string.Format(@"DELETE FROM ucc_pln_SerialGenerated WHERE WorkOrderID = {0} ", model.WorkOrderID);
            Repository.Instance.ExecuteWithTransaction(sql, "Delete Serial");
            return true;
        }
Exemplo n.º 3
0
        public bool ClearSerialInEpicor(SessionInfo _session, PlanningHeadModel model, out string msg)
        {
            msg = string.Empty;
            bool IsSuccess = true;
            string sql = string.Empty;
            Session currSession = null;
            var resultContinue = GetSerialAllByWorkOrder(model.WorkOrderID).ToList();
            try
            {
                currSession = new Session(_session.UserID, _session.UserPassword, _session.AppServer, Session.LicenseType.Default);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                IsSuccess = false;
            }

            foreach (var item in resultContinue)
            {
                try
                {
                    LotSelectUpdate lotPart = new LotSelectUpdate(currSession.ConnectionPool);
                    lotPart.DeleteByID(string.IsNullOrEmpty(item.NORNum) ? item.MCSSNo : item.NORNum, item.SerialNo);
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                    IsSuccess = false;
                }

                //TODO : There are has one more case for delete S/N.
                sql += string.Format(@"DELETE FROM ucc_pln_SerialGenerated WHERE WorkOrderID = {0} AND SerialNo = '{1}' {2}{3}{4}"
                                        , item.WorkOrderID, item.SerialNo, Environment.NewLine, "", Environment.NewLine);
            }

            sql += string.Format(@"UPDATE ucc_pln_PlanHead SET GenSerialFlag = 0 WHERE WorkOrderID = {0} ", model.WorkOrderID);
            Repository.Instance.ExecuteWithTransaction(sql, "Delete Serial");
            return IsSuccess;
        }