Beispiel #1
0
 /// <summary>
 /// 修改缓存托盘集合
 /// </summary>
 /// <param name="cacheTrayList"></param>
 public void UpdateCacheTableList(List <CacheStackTray> cacheTrayList)
 {
     using (BaseAccess access = new BaseAccess(true))
     {
         try
         {
             access.Open();
             access.BeginTransaction();
             foreach (CacheStackTray entity in cacheTrayList)
             {
                 string updateSql = string.Format("UPDATE {0} SET Barcode='{1}',Batch={2} WHERE Id ={3}", lineDevice.PrefixTable + "CacheStackTray", entity.Barcode, entity.Batch, entity.Id);
                 access.ExecuteNonQuery(updateSql);
                 //access.Update(entity, new string[] { CacheStackTray.ID }, CacheStackTray.BARCODE, CacheStackTray.BATCH);
             }
             access.Commit();
         }
         catch (Exception ex)
         {
             access.Rollback();
             PrintInfo.I(ex.Message);
             Console.WriteLine(ex.Message);
         }
         finally
         {
             access.Close();
         }
     }
 }
 public static void CreateTable(string prefixTable)
 {
     using (BaseAccess access = new BaseAccess(true))
     {
         try
         {
             access.Open();
             access.BeginTransaction();
             //创建缓存托盘表
             access.ExecuteNonQuery(GetCacheStackTraySql(prefixTable));
             //创建托盘详情表
             access.ExecuteNonQuery(GetStackTrayFlowSql(prefixTable));
             //创建托盘表
             access.ExecuteNonQuery(GetStackTraysSql(prefixTable));
             //创建注册托盘表
             //access.ExecuteNonQuery(GetRegisterTraySql(prefixTable));
             //创建用户事件日志表
             access.ExecuteNonQuery(GetUserEventLogSql(prefixTable));
             access.Commit();
         }
         catch (Exception ex)
         {
             access.Rollback();
             throw new Exception("创建表失败:" + ex.Message);
         }
         finally
         {
             access.Close();
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 保存InStack为2的缓存数据
        /// </summary>
        private void SaveCacheData()
        {
            //if (trayCodeList.Count < 2)
            //{
            //    PrintInfo.I("托盘个数小于2个,当前{0}个", trayCodeList.Count);
            //    BindDataResult(CommandValue.TRAY_COUNT_ERROR);
            //    return;
            //}
            // 此时叠盘机中应该只有一个托盘
            // 保存叠盘机堆叠InStack为2的所有托盘数据
            using (BaseAccess access = new BaseAccess(true))
            {
                try
                {
                    access.Open();
                    access.BeginTransaction();

                    SaveStackFlowTray(trayCodeList[trayCodeList.Count - 2], access);
                    SaveStackTrays(trayCodeList, access, "2");
                    DeleteCacheData(access, "2");
                    //清空托盘list中InStack为2的
                    int count = trayCodeList.Count;
                    for (int i = count - 1; i > -1; i--)
                    {
                        if (trayCodeList[i].InStack == 2)
                        {
                            trayCodeList.RemoveAt(i);
                        }
                    }
                    access.Commit();
                    this.mixBatch = false;
                    WriteRunningState("Running", "处理完成", ServicesConfig.WorkStationGroups[0].Key);
                }
                catch (Exception ex)
                {
                    access.Rollback();
                    WriteRunningState("Error", "保存缓存异常", ServicesConfig.WorkStationGroups[0].Key);
                    PrintInfo.I("异常:{0}", ex.Message);
                }
            }
            BindDataResult(CommandValue.BIND_COMPLETE);
        }
Beispiel #4
0
        /// <summary>
        /// 保存所有缓存数据
        /// </summary>
        private void SaveAllCacheData()
        {
            //if (trayCodeList.Count < 2 && type == "2")
            //{
            //    PrintInfo.I("托盘个数小于2个,当前{0}个", trayCodeList.Count);
            //    BindDataResult(CommandValue.TRAY_COUNT_ERROR);
            //    return;
            //}
            // 保存叠盘机堆叠的所有托盘数据
            using (BaseAccess access = new BaseAccess(true))
            {
                try
                {
                    access.Open();
                    access.BeginTransaction();

                    SaveStackFlowTray(trayCodeList[trayCodeList.Count - 1], access);
                    SaveStackTrays(trayCodeList, access, "1");
                    DeleteCacheData(access, "1");
                    //清空托盘list
                    trayCodeList.Clear();

                    access.Commit();
                    this.mixBatch = false;
                    trayCodeList.Clear();
                    WriteRunningState("Running", "处理完成", ServicesConfig.WorkStationGroups[0].Key);
                }
                catch (Exception ex)
                {
                    access.Rollback();
                    WriteRunningState("Error", "保存缓存异常", ServicesConfig.WorkStationGroups[0].Key);
                    PrintInfo.I("异常:{0}", ex.Message);
                }
            }

            //可以放行
            BindDataResult(CommandValue.BIND_COMPLETE);
        }