Пример #1
0
        private void GetDataSet()
        {
            try
            {
                using (PersistentManager pmServer = new PersistentManager("ServerConnection"))
                {
                    ServerDao serverDao = new ServerDao();
                    serverDao.SetPersistentManager(pmServer);
                    channelReport = new SortChannelReport();

                    DataTable         printBatchTable   = serverDao.FindPrintBatchTable();
                    PrintSelectDialog printSelectDialog = new PrintSelectDialog(printBatchTable);

                    if (printSelectDialog.ShowDialog() == DialogResult.OK)
                    {
                        string orderDate = "";
                        string batchNo   = "";
                        string lineCode  = "";

                        orderDate = printSelectDialog.SelectedPrintBatch.Split("|"[0])[0];
                        batchNo   = printSelectDialog.SelectedPrintBatch.Split("|"[0])[1];
                        lineCode  = printSelectDialog.SelectedPrintBatch.Split("|"[0])[2];

                        DataTable table = serverDao.FindChannelUSED(orderDate, batchNo, lineCode);

                        if (table.Rows.Count == 0)
                        {
                            throw new Exception("没有数据");
                        }
                        channelReport.SetDataSource(table);
                        SetReportToCrv(channelReport);
                    }
                }
            }
            catch (Exception ex)
            {
                SetLblInfo(ex.Message);
            }
            finally
            {
                //t.Abort();
            }
        }
Пример #2
0
        public void Scan(string text, string cigaretteCode, string barcode)
        {
            using (PersistentManager pm = new PersistentManager())
            {
                StockOutDao outDao    = new StockOutDao();
                SupplyDao   supplyDao = new SupplyDao();

                if (barcode != string.Empty && supplyDao.Exist(barcode))
                {
                    return;
                }

                DataTable table = supplyDao.FindCigaretteAll(cigaretteCode);

                if (table.Rows.Count > 0)
                {
                    THOK.AS.Stocking.View.ScanDialog scanDialog = new THOK.AS.Stocking.View.ScanDialog(table);
                    scanDialog.setInformation(text, barcode);
                    if (scanDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (scanDialog.IsPass && scanDialog.Barcode.Length == 6)
                        {
                            cigaretteCode = scanDialog.SelectedCigaretteCode;
                            barcode       = scanDialog.Barcode;

                            using (PersistentManager pmServer = new PersistentManager("ServerConnection"))
                            {
                                ServerDao serverDao = new ServerDao();
                                serverDao.SetPersistentManager(pmServer);
                                serverDao.UpdateCigaretteToServer(barcode, cigaretteCode);
                            }
                            outDao.UpdateCigarette(barcode, cigaretteCode);
                        }
                        else
                        {
                            MessageBox.Show("验证码错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
        public async Task <ServiceResultMessage> RemoveAsync(string userId, string id)
        {
            ServiceResultMessage message = new ServiceResultMessage();

            try
            {
                var daoResult = await LogoDao.DeleteLogoTemplate(id);

                if (daoResult.Code == DaoResultCode.Success)
                {
                    var logo = daoResult.para as LogoTemplateEntity;
                    if (logo != null && File.Exists(logo.FilePath))
                    {
                        try
                        {
                            File.Delete(logo.FilePath);
                        }
                        catch (Exception e)
                        {
                            LogHelper.Error($"删除Logo文件失败: 路径:{logo.FilePath}");
                        }
                    }
                    var serverEntities = await ServerDao.GetServerEntitys(userId);

                    foreach (ServerEntity entity in serverEntities)
                    {
                        try
                        {
                            var config      = JsonConvert.DeserializeObject <LiveServiceConfig>(entity.Option);
                            var liveService = new DjLiveService(config);
                            liveService.RemoveLogoFile(id);
                        }
                        catch (Exception e)
                        {
                            message.ErrorId +=
                                ("  " + LogHelper.ErrorWithId($"删除服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}", e));
                            message.Message += $"删除服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}";
                        }
                    }
                    var updateResult = await ServerNodeService.UpdateSrsConf(userId);

                    message = updateResult;
                    if (updateResult.code == ServiceResultCode.Warning)
                    {
                        message.code = ServiceResultCode.Success;
                    }
                    await ServerNodeService.UpdateSrsConf(userId);
                }
                else
                {
                    message = ServiceResultBase.DaoResult2ServiceResult(daoResult);
                }
                return(message);
            }
            catch (Exception e)
            {
                message.code    = ServiceResultCode.UnExceptError;
                message.Message = e.Message;
                message.ErrorId = LogHelper.ErrorWithId(e.Message, e);
                return(message);
            }
        }
        public async Task <ServiceResultMessage> AddLogeTemplate(string userId, string id, LogoTemplateModel logoTemplateModel)
        {
            ServiceResultMessage message = new ServiceResultMessage();

            try
            {
                string filePath = string.Concat(ConfigurationValue.TempLogoPath, $"{id}");
                var    options  = JsonConvert.SerializeObject(new LogoOption()
                {
                    Height = logoTemplateModel.Height,
                    Width  = logoTemplateModel.Width,
                });
                var path = EncryptUtils.Base64SaveImg(logoTemplateModel.Base64String, filePath);
                if (path == null)
                {
                    message.code    = ServiceResultCode.ImageTranscodeError;
                    message.Message = "base64转 图片失败.";
                    return(message);
                }
                var daoresult = await LogoDao.Add2Account(userId, new LogoTemplateEntity()
                {
                    Id         = id,
                    Name       = logoTemplateModel.Name,
                    Base64Vale = logoTemplateModel.Base64String,
                    FilePath   = path,
                    Option     = options,
                });

                if (daoresult.Code == DaoResultCode.Success)
                {
                    var serverEntities = await ServerDao.GetServerEntitys(userId);

                    foreach (ServerEntity entity in serverEntities)
                    {
                        try
                        {
                            var config      = JsonConvert.DeserializeObject <LiveServiceConfig>(entity.Option);
                            var liveService = new DjLiveService(config);
                            liveService.UploadLogoFile(id, path);
                        }
                        catch (Exception e)
                        {
                            message.ErrorId +=
                                ("  " + LogHelper.ErrorWithId($"上传服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}", e));
                            message.Message += $"上传服务器Logo文件失败,ServerId{entity.Id},LogoId:{id}";
                        }
                    }
                    await ServerNodeService.UpdateSrsConf(userId);

                    return(message);
                }
                else
                {
                    message = ServiceResultBase.DaoResult2ServiceResult(daoresult);
                }
                return(message);
            }
            catch (NullReferenceException e)
            {
                message.code    = ServiceResultCode.SaveFileError;
                message.Message = e.Message;
                message.ErrorId = LogHelper.ErrorWithId(e.Message, e);
                return(message);
            }
            catch (Exception e)
            {
                message.code    = ServiceResultCode.UnExceptError;
                message.Message = e.Message;
                message.ErrorId = LogHelper.ErrorWithId(e.Message, e);
                return(message);
            }
        }
Пример #5
0
        /// <summary>
        /// 下载数据 最后修改日期 2010-10-30
        /// </summary>
        private void DownloadData()
        {
            try
            {
                using (PersistentManager pm = new PersistentManager())
                {
                    ChannelDao       channelDao       = new ChannelDao();
                    StockOutBatchDao stockOutBatchDao = new StockOutBatchDao();
                    StockInBatchDao  stockInBatchDao  = new StockInBatchDao();
                    StockOutDao      stockOutDao      = new StockOutDao();
                    StockInDao       stockInDao       = new StockInDao();
                    SupplyDao        supplyDao        = new SupplyDao();

                    if (supplyDao.FindCount() != stockOutDao.FindOutQuantity())
                    {
                        if (DialogResult.Cancel == MessageBox.Show("还有未处理的数据,您确定要重新下载数据吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                        {
                            return;
                        }
                    }

                    using (PersistentManager pmServer = new PersistentManager("ServerConnection"))
                    {
                        ServerDao serverDao = new ServerDao();
                        serverDao.SetPersistentManager(pmServer);

                        //ORDER BY ORDERDATE,BATCHNO  查找第一批次(符合已优化,并已上传一号工程,未下载的批次)
                        DataTable table = serverDao.FindBatch();
                        if (table.Rows.Count != 0)
                        {
                            using (PersistentManager pmWES = new PersistentManager("WESConnection"))
                            {
                                StockInBatchDao stockInBatchDaoWES = new StockInBatchDao();
                                stockInBatchDaoWES.SetPersistentManager(pmWES);
                                stockInBatchDaoWES.Delete();
                            }

                            string batchID   = table.Rows[0]["BATCHID"].ToString();
                            string orderDate = table.Rows[0]["ORDERDATE"].ToString();
                            string batchNo   = table.Rows[0]["BATCHNO"].ToString();

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("清空作业表", 5, 1));
                            channelDao.Delete();
                            stockOutBatchDao.Delete();
                            stockOutDao.Delete();
                            stockInBatchDao.Delete();
                            stockInDao.Delete();
                            supplyDao.Delete();
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载补货烟道表", 5, 2));
                            table = serverDao.FindStockChannel(orderDate, batchNo);
                            channelDao.InsertChannel(table);
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载补货混合烟道表", 5, 3));
                            table = serverDao.FindMixChannel(orderDate, batchNo);
                            channelDao.InsertMixChannel(table);
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载分拣烟道表", 5, 4));
                            table = serverDao.FindChannelUSED(orderDate, batchNo);
                            channelDao.InsertChannelUSED(table);
                            System.Threading.Thread.Sleep(100);

                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState("下载补货计划表", 5, 5));
                            table = serverDao.FindSupply(orderDate, batchNo);
                            supplyDao.Insert(table);
                            System.Threading.Thread.Sleep(100);

                            serverDao.UpdateBatchStatus(batchID);
                            Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState());
                            Logger.Info("数据下载完成");

                            //初始化PLC数据(叠垛线PLC,补货线PLC)
                            Context.ProcessDispatcher.WriteToService("StockPLC_01", "RestartData", 3);
                            Context.ProcessDispatcher.WriteToService("StockPLC_02", "RestartData", 1);

                            //初始化入库扫码器
                            Context.ProcessDispatcher.WriteToProcess("ScanProcess", "Init", null);

                            //初始化状态管理器
                            Context.ProcessDispatcher.WriteToProcess("LedStateProcess", "Init", null);
                            Context.ProcessDispatcher.WriteToProcess("OrderDataStateProcess", "Init", null);
                            Context.ProcessDispatcher.WriteToProcess("ScannerStateProcess", "Init", null);

                            //生成入库请求任务数据
                            Context.ProcessDispatcher.WriteToProcess("StockInRequestProcess", "FirstBatch", null);
                            //生成补货请求任务数据
                            //Context.ProcessDispatcher.WriteToProcess("SupplyFirstRequestProcess", "FirstBatch", null);
                        }
                        else
                        {
                            MessageBox.Show("没有补货计划数据!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("数据下载处理失败,原因:" + e.Message);
            }
        }
 public static void ServerStop()
 {
     ServerDao.ServerStop();
 }