Пример #1
0
        void DoLogOn()
        {
            using (ForAssortingKanbanService proxy = new ForAssortingKanbanService())
            {
                proxy.Url = string.Format(CultureInfo.InvariantCulture, "http://{0}:{1}/ForAssortingKanbanService/", this.textBoxServerIP.Text, this.textBoxServicePort.Text);

                CFG_ChannelDto[] cfgChannels = proxy.QueryChannels();
                if (cfgChannels.All(c => c.Code != this.comboBoxCfgChannelCode.Text))
                {
                    this.comboBoxCfgChannelCode.Items.Clear();
                    foreach (CFG_ChannelDto cfgChannel in cfgChannels)
                    {
                        this.comboBoxCfgChannelCode.Items.Add(cfgChannel.Code);
                    }

                    throw new Exception("无效的巷道编码。");
                }
            }

            XmlSerializerWrapper <LocalSettings> localSettingsXmlSerializer = new XmlSerializerWrapper <LocalSettings>();
            LocalSettings localSettings = localSettingsXmlSerializer.Entity;

            localSettings.ServerIP       = this.textBoxServerIP.Text;
            localSettings.ServicePort    = int.Parse(this.textBoxServicePort.Text, CultureInfo.InvariantCulture);
            localSettings.CfgChannelCode = this.comboBoxCfgChannelCode.Text;

            localSettingsXmlSerializer.Save();
        }
Пример #2
0
        void ThreadStart()
        {
            while (true)
            {
                try
                {
                    //第一次需要额外获取分拣口名称
                    if (this.channelId == null)
                    {
                        LocalSettings localSettings = new XmlSerializerWrapper <LocalSettings>().Entity;

                        using (ForAssortingKanbanService proxy = new ForAssortingKanbanService())
                        {
                            proxy.Url = this.serviceUrl;

                            CFG_ChannelDto[] cfgChannels = proxy.QueryChannels();
                            CFG_ChannelDto   cfgChannel  = cfgChannels
                                                           .First(c => c.Code == localSettings.CfgChannelCode);

                            this.channelId   = cfgChannel.Id;
                            this.ChannelName = cfgChannel.Name;
                            this.TaskInfo    = proxy.QueryCurrentTaskInfo(this.channelId.Value);

                            if (this.TaskInfo.CurrentBatchInfo.PickType == "P") //PTL料架拣料
                            {
                                this.TodayStatistics = proxy.QueryTodayStatistics(this.channelId.Value);
                            }
                            else
                            {
                                this.TodayStatistics = proxy.QueryPDATodayStatistics(this.channelId.Value);
                            }
                        }
                    }

                    using (ForAssortingKanbanService proxy = new ForAssortingKanbanService())
                    {
                        proxy.Url = this.serviceUrl;

                        this.TaskInfo = proxy.QueryCurrentTaskInfo(this.channelId.Value);

                        //每 10 秒一次汇总
                        if (DateTime.Now.Second % 10 == 0)
                        {
                            if (this.TaskInfo.CurrentBatchInfo.PickType == "P") //PTL料架拣料
                            {
                                this.TodayStatistics = proxy.QueryTodayStatistics(this.channelId.Value);
                            }
                            else
                            {
                                this.TodayStatistics = proxy.QueryPDATodayStatistics(this.channelId.Value);
                            }
                        }
                    }

                    this.ServiceError = false;
                }
                catch
                {
                    this.ServiceError = true;
                }
                finally
                {
                    Thread.Sleep(this.pollingPeriod);
                }
            }
        }