예제 #1
0
 public void Delete(AscmMarkTaskLog ascmMarkTaskLog)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmMarkTaskLog>(ascmMarkTaskLog);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmMarkTaskLog)", ex);
         throw ex;
     }
 }
예제 #2
0
        public ContentResult MarkTask(int? id, int? wipEntityId)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();

            string userName = string.Empty;
            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;
            }

            try
            {
                bool isContainWarehouse = false;
                string warehouse = string.Empty;
                AscmGetMaterialTask ascmGetMaterialTask = null;
                if (id.HasValue)
                {
                    ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(id.Value);
                    if (ascmGetMaterialTask == null)
                        throw new Exception("该任务不存在!");
                    warehouse = string.IsNullOrEmpty(ascmGetMaterialTask.warehouserId) ? null : ascmGetMaterialTask.warehouserId.Substring(0, 4).ToUpper().ToString();
                }

                string whereOther = "", whereQueryWord = "";

                whereQueryWord = "ruleType = '" + AscmGenerateTaskRule.RuleTypeDefine.typeofWarehouse + "'";
                whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord);

                whereQueryWord = "identificationId = " + ascmGetMaterialTask.IdentificationId;
                whereOther = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(whereOther, whereQueryWord);

                List<AscmGenerateTaskRule> list = AscmGenerateTaskRuleService.GetInstance().GetList(null, "", "", "", whereOther);
                if (list != null && list.Count > 0)
                {
                    foreach (AscmGenerateTaskRule ascmGenerateTaskRule in list)
                    {
                        if (!string.IsNullOrEmpty(ascmGenerateTaskRule.relatedRanker) && ascmGenerateTaskRule.relatedRanker == ascmGetMaterialTask.rankerId)
                        {
                            if (!string.IsNullOrEmpty(ascmGenerateTaskRule.ruleCode))
                            {
                                string[] myArray = ascmGenerateTaskRule.ruleCode.Split('&');
                                string warehouseString = myArray[0].Substring(myArray[0].IndexOf("(") + 1, myArray[0].IndexOf(")") - myArray[0].IndexOf("(") - 1);
                                if (!string.IsNullOrEmpty(warehouse) && warehouseString.IndexOf(warehouse) > -1)
                                {
                                    isContainWarehouse = true;
                                    break;
                                }
                            }
                        }
                        else if (string.IsNullOrEmpty(ascmGenerateTaskRule.relatedRanker))
                        {
                            if (!string.IsNullOrEmpty(ascmGenerateTaskRule.ruleCode))
                            {
                                string[] myArray = ascmGenerateTaskRule.ruleCode.Split('&');
                                string warehouseString = myArray[0].Substring(myArray[0].IndexOf("(") + 1, myArray[0].IndexOf(")") - myArray[0].IndexOf("(") - 1);
                                if (!string.IsNullOrEmpty(warehouse) && warehouseString.IndexOf(warehouse) > -1)
                                {
                                    isContainWarehouse = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                if (!isContainWarehouse)
                    throw new Exception("该子库无法标记!");

                if (isContainWarehouse)
                {
                    AscmMarkTaskLog ascmMarkTaskLog = null;
                    if (!(id.HasValue && wipEntityId.HasValue))
                        throw new Exception("请选择须标记的作业!");

                    if (id.HasValue && wipEntityId.HasValue)
                    {
                        object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMarkTaskLog where wipEntityId = " + wipEntityId.ToString() + " and taskId = " + id.ToString() + " and isMark = 1");
                        if (object1 == null)
                            throw new Exception("查询异常!");
                        int iCount = 0;
                        if (int.TryParse(object1.ToString(), out iCount) && iCount > 0)
                            throw new Exception("该作业已标记!");

                        int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMarkTaskLog");
                        ascmMarkTaskLog = new AscmMarkTaskLog();
                        ascmMarkTaskLog.id = ++maxId;
                        ascmMarkTaskLog.createUser = userName;
                        ascmMarkTaskLog.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmMarkTaskLog.modifyUser = userName;
                        ascmMarkTaskLog.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmMarkTaskLog.wipEntityId = wipEntityId.Value;
                        ascmMarkTaskLog.taskId = id.Value;
                        ascmMarkTaskLog.isMark = 1;
                        ascmMarkTaskLog.markType = "NONAUTO";
                        ascmMarkTaskLog.warehouseId = warehouse;

                        if (!string.IsNullOrEmpty(ascmGetMaterialTask.relatedMark))
                            ascmGetMaterialTask.relatedMark += ",";
                        ascmGetMaterialTask.relatedMark += ascmMarkTaskLog.id.ToString();
                        ascmGetMaterialTask.modifyUser = userName;
                        ascmGetMaterialTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                        //执行事务
                        ISession session = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession();
                        session.Clear();
                        using (ITransaction tx = session.BeginTransaction())
                        {
                            try
                            {
                                //更改任务标记
                                if (ascmGetMaterialTask != null)
                                    AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask);
                                //保存标记
                                if (ascmMarkTaskLog != null)
                                AscmMarkTaskLogService.GetInstance().Save(ascmMarkTaskLog);
                            }
                            catch (Exception ex)
                            {
                                tx.Rollback();
                                YnBaseClass2.Helper.LogHelper.GetLog().Error("标记失败(Mark AscmMarkTaskLog)", ex);
                            }
                        }

                        jsonObjectResult.result = true;
                        jsonObjectResult.message = "";
                    }
                }
            }
            catch (Exception ex)
            {
                jsonObjectResult.result = false;
                jsonObjectResult.message = ex.Message;
            }

            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
예제 #3
0
        public ContentResult MarkTask(int? id, int? wipEntityId)
        {
            string userName = string.Empty;
            if (User.Identity.IsAuthenticated)
            {
                userName = User.Identity.Name;
            }

            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            try
            {
                string warehouse = string.Empty;
                if (id.HasValue)
                {
                    AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(id.Value);
                    if (ascmGetMaterialTask == null)
                        throw new Exception("该任务不存在!");
                    warehouse = string.IsNullOrEmpty(ascmGetMaterialTask.warehouserId) ? null : ascmGetMaterialTask.warehouserId.Substring(0, 4).ToUpper().ToString();
                }

                if (AscmCommonHelperService.GetInstance().IsJudgeSpecWareHouse(warehouse))
                {
                    AscmMarkTaskLog ascmMarkTaskLog = null;
                    if (id.HasValue && wipEntityId.HasValue)
                    {
                        object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMarkTaskLog where wipEntityId = " + wipEntityId.ToString() + " and taskId = " + id.ToString() + " and isMark = 1");
                        if (object1 == null)
                            throw new Exception("查询异常!");
                        int iCount = 0;
                        if (int.TryParse(object1.ToString(), out iCount) && iCount > 0)
                            throw new Exception("该作业已标记!");

                        int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMarkTaskLog");
                        ascmMarkTaskLog = new AscmMarkTaskLog();
                        ascmMarkTaskLog.id = ++maxId;
                        ascmMarkTaskLog.createUser = userName;
                        ascmMarkTaskLog.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmMarkTaskLog.modifyUser = userName;
                        ascmMarkTaskLog.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmMarkTaskLog.wipEntityId = wipEntityId.Value;
                        ascmMarkTaskLog.taskId = id.Value;
                        ascmMarkTaskLog.isMark = 1;
                        ascmMarkTaskLog.markType = "NONAUTO";
                        ascmMarkTaskLog.warehouseId = warehouse;

                        AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(id.Value);
                        if (!string.IsNullOrEmpty(ascmGetMaterialTask.relatedMark))
                            ascmGetMaterialTask.relatedMark += ",";
                        ascmGetMaterialTask.relatedMark += ascmMarkTaskLog.id.ToString();
                        ascmGetMaterialTask.modifyUser = userName;
                        ascmGetMaterialTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask);

                        AscmMarkTaskLogService.GetInstance().Save(ascmMarkTaskLog);

                        jsonObjectResult.result = true;
                        jsonObjectResult.message = "";
                    }
                    else
                    {
                        jsonObjectResult.result = false;
                        jsonObjectResult.message = "该标记不存在!";
                    }
                }
                else
                {
                    jsonObjectResult.result = false;
                    jsonObjectResult.message = "非特殊子库违法标记失败!";
                }
            }
            catch (Exception ex)
            {
                jsonObjectResult.message = ex.Message;
            }
            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
예제 #4
0
 public void Update(AscmMarkTaskLog ascmMarkTaskLog)
 {
     using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
     {
         try
         {
             YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmMarkTaskLog>(ascmMarkTaskLog);
             tx.Commit();//正确执行提交
         }
         catch (Exception ex)
         {
             tx.Rollback();//回滚
             YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmMarkTaskLog)", ex);
             throw ex;
         }
     }
 }
예제 #5
0
        public bool MarkTask(string ticket, string userName, string taskId, string jobId, ref string message)
        {
            try
            {
                string warehouse = string.Empty;
                if (string.IsNullOrEmpty(taskId) || string.IsNullOrEmpty(jobId))
                    throw new Exception("标记异常:任务号或作业号为空!");

                if (!string.IsNullOrEmpty(taskId))
                {
                    AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(int.Parse(taskId));
                    if (ascmGetMaterialTask == null)
                        throw new Exception("该任务不存在!");
                    warehouse = string.IsNullOrEmpty(ascmGetMaterialTask.warehouserId) ? null : ascmGetMaterialTask.warehouserId.Substring(0, 4).ToUpper().ToString();
                }

                if (AscmCommonHelperService.GetInstance().IsJudgeSpecWareHouse(warehouse))
                {
                    AscmMarkTaskLog ascmMarkTaskLog = null;
                    object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmMarkTaskLog where wipEntityId = " + jobId + " and taskId = " + taskId + " and isMark = 1");
                    if (object1 == null)
                        throw new Exception("查询异常!");
                    int iCount = 0;
                    if (int.TryParse(object1.ToString(), out iCount) && iCount > 0)
                        throw new Exception("该作业已标记!");

                    int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmMarkTaskLog");
                    ascmMarkTaskLog = new AscmMarkTaskLog();
                    ascmMarkTaskLog.id = ++maxId;
                    ascmMarkTaskLog.createUser = userName;
                    ascmMarkTaskLog.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    ascmMarkTaskLog.modifyUser = userName;
                    ascmMarkTaskLog.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    ascmMarkTaskLog.wipEntityId = int.Parse(jobId);
                    ascmMarkTaskLog.taskId = int.Parse(taskId);
                    ascmMarkTaskLog.isMark = 1;
                    ascmMarkTaskLog.markType = "NONAUTO";
                    ascmMarkTaskLog.warehouseId = warehouse;

                    AscmGetMaterialTask ascmGetMaterialTask = AscmGetMaterialTaskService.GetInstance().Get(int.Parse(taskId));
                    if (!string.IsNullOrEmpty(ascmGetMaterialTask.relatedMark))
                        ascmGetMaterialTask.relatedMark += ",";
                    ascmGetMaterialTask.relatedMark += ascmMarkTaskLog.id.ToString();
                    ascmGetMaterialTask.modifyUser = userName;
                    ascmGetMaterialTask.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    AscmGetMaterialTaskService.GetInstance().Update(ascmGetMaterialTask);

                    AscmMarkTaskLogService.GetInstance().Save(ascmMarkTaskLog);
                    return true;
                }
                else
                {
                    throw new Exception("非特殊子库违规标记失败!");
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return false;
        }