Exemple #1
0
 private void SaveLicenseTemplete(LicenseTemplete licenseTemplete)
 {
     PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA_FreqStation>(channel =>
     {
         channel.SaveLicenseTemplete(licenseTemplete);
     });
 }
Exemple #2
0
        private void btnSendLicense_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedEquipmentInspection != null)
            {
                if (SelectedEquipmentInspection.CheckState != CheckStateEnum.Qualified)
                {
                    MessageBox.Show("不可以发放许可证!");
                }
                else
                {
                    LicenseTemplete template = FreqStationHelper.GetLicenseTemplete(CO_IA.Client.RiasPortal.ModuleContainer.Activity.Guid);
                    if (template == null)
                    {
                        MessageBox.Show("没有许可证模板,请设置许可证模板");
                    }
                    else
                    {
                        List <EquipmentInspection> equs = new List <EquipmentInspection>();
                        equs.Add(SelectedEquipmentInspection);

                        SendLicense(equs);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _btnSave_Click(object sender, RoutedEventArgs e)
        {
            LicenseTemplete licenseTemplete = new LicenseTemplete();

            licenseTemplete.ActivityGuid = CO_IA.Client.RiasPortal.ModuleContainer.Activity.Guid;
            licenseTemplete.Height       = double.Parse(this._txtHeight.Text);
            licenseTemplete.Width        = double.Parse(this._txtWidth.Text);

            licenseTemplete.IsShowImage     = _chkImage.IsChecked.Value;
            licenseTemplete.BackgroundImage = this.backgroundImageSource;

            licenseTemplete.IsShowQRCode = _chkQRCode.IsChecked.Value;
            if (this.QRCodeImageSource == null)
            {
                MessageBox.Show("请生成二维码");
                return;
            }
            else
            {
                licenseTemplete.QRCode = this.QRCodeImageSource;
            }

            if (_canvasPanel.Children.Count > 0)
            {
                foreach (FrameworkElement itemcontrol in _canvasPanel.Children)
                {
                    if (itemcontrol.GetType() == typeof(LicenseItemControl))
                    {
                        LicenseItemControl licenseControl = (LicenseItemControl)itemcontrol;

                        LicenseItem licenseitem = new LicenseItem();
                        licenseitem.Left         = (double)licenseControl.GetValue(Canvas.LeftProperty);
                        licenseitem.Top          = (double)licenseControl.GetValue(Canvas.TopProperty);
                        licenseitem.PropertyName = licenseControl.PropertyName;
                        licenseTemplete.LicenseItems.Add(licenseitem);
                    }
                }
            }
            else
            {
                MessageBox.Show("请添加模板内容");
                return;
            }
            licenseTemplete.XMLLicenseItems = GetXmlByLicenseTemplete(licenseTemplete);
            try
            {
                SaveLicenseTemplete(licenseTemplete);
                MessageBox.Show("保存成功");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetExceptionMessage());
            }
        }
Exemple #4
0
 private void LoadXml(LicenseTemplete licenseTemplete)
 {
     try
     {
         XmlDocument xmldoc = new XmlDocument();
         xmldoc.LoadXml(licenseTemplete.XMLLicenseItems);
         tempxmlnode = xmldoc.SelectSingleNode(FreqStationHelper.template);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.GetExceptionMessage());
     }
 }
Exemple #5
0
        private void btnBathSendLicense_Click(object sender, RoutedEventArgs e)
        {
            List <EquipmentInspection> selects = equipmentInspectionListControl.EquipmentInspectionItemsSource.Where(r => r.IsChecked == true).ToList();

            if (selects.Count == 0)
            {
                MessageBox.Show("请勾选要批量发放许可证的设备");
                return;
            }
            else
            {
                StringBuilder error = new StringBuilder();
                error.AppendLine("请移除不可以发放许可证的设备:");

                bool isok = true;
                foreach (EquipmentInspection equ in selects)
                {
                    if (equ.CheckState != CheckStateEnum.Qualified)
                    {
                        error.AppendFormat("{0}、", equ.ActivityEquipment.Name);
                        isok = false;
                    }
                }
                if (isok)
                {
                    LicenseTemplete template = FreqStationHelper.GetLicenseTemplete(CO_IA.Client.RiasPortal.ModuleContainer.Activity.Guid);
                    if (template == null)
                    {
                        MessageBox.Show("没有许可证模板,请设置许可证模板");
                    }
                    else
                    {
                        SendLicense(selects);
                    }
                }
                else
                {
                    MessageBox.Show(error.ToString().TrimEnd('、'), "提示");
                }
            }
        }
Exemple #6
0
        private bool InitLicenseTemplete()
        {
            LicenseTemplete = FreqStationHelper.GetLicenseTemplete(CO_IA.Client.RiasPortal.ModuleContainer.Activity.Guid);
            if (LicenseTemplete != null)
            {
                LoadXml(LicenseTemplete);
                if (tempxmlnode != null)
                {
                    XmlNode xmlnode = tempxmlnode.SelectSingleNode(FreqStationHelper.licenseItems);
                    this.LicenseItems = FreqStationHelper.XMLLicenseItems(xmlnode);
                    if (this.LicenseTemplete.IsShowQRCode)
                    {
                        XmlNode fieldsnode = tempxmlnode.SelectSingleNode(FreqStationHelper.qrCodeFields);
                        this.QRCodeFields = FreqStationHelper.XMLQRCodeFields(fieldsnode);
                    }
                }
                return(true);
            }

            return(false);
        }
Exemple #7
0
        private void InitLicenseTemplete()
        {
            licenseTemplete = FreqStationHelper.GetLicenseTemplete(CO_IA.Client.RiasPortal.ModuleContainer.Activity.Guid);
            if (licenseTemplete != null)
            {
                this._txtHeight.EditValue  = licenseTemplete.Height.ToString();
                this._txtWidth.EditValue   = licenseTemplete.Width.ToString();
                this.defaultheight         = licenseTemplete.Height;
                this.defaultwidth          = licenseTemplete.Width;
                this.BackgroundImageSource = licenseTemplete.BackgroundImage;
                this.QRCodeImageSource     = licenseTemplete.QRCode;
                this._chkImage.IsChecked   = licenseTemplete.IsShowImage;
                this._chkQRCode.IsChecked  = licenseTemplete.IsShowQRCode;

                XmlDocument xmldoc = null;
                try
                {
                    xmldoc = new XmlDocument();
                    xmldoc.LoadXml(licenseTemplete.XMLLicenseItems);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.GetExceptionMessage());
                    return;
                }

                XmlNode tempxmlnode = xmldoc.SelectSingleNode(FreqStationHelper.template);
                XmlNode xmlnode     = tempxmlnode.SelectSingleNode(FreqStationHelper.licenseItems);
                if (xmlnode != null && xmlnode.HasChildNodes)
                {
                    licenseTemplete.LicenseItems = FreqStationHelper.XMLLicenseItems(xmlnode);
                }
                if (licenseTemplete.IsShowQRCode)
                {
                    XmlNode qrpropertynode = tempxmlnode.SelectSingleNode(FreqStationHelper.qrCodeProperty);
                    if (qrpropertynode != null)
                    {
                        InitInitQRCodeProperty(qrpropertynode);
                    }

                    XmlNode qrfieldsnode = tempxmlnode.SelectSingleNode(FreqStationHelper.qrCodeFields);
                    if (qrfieldsnode != null && qrfieldsnode.HasChildNodes)
                    {
                        this.QRFields = FreqStationHelper.XMLQRCodeFields(qrfieldsnode);
                    }
                }

                foreach (LicenseItem item in licenseTemplete.LicenseItems)
                {
                    LicenseItemControl licenseitem = CreateLicenseItemControl(item.PropertyName);
                    Canvas.SetLeft(licenseitem, item.Left);
                    Canvas.SetTop(licenseitem, item.Top);
                    _canvasPanel.Children.Add(licenseitem);
                    property.Add(item.PropertyName);
                }
            }
            else
            {
                licenseTemplete = new LicenseTemplete();
            }
        }
Exemple #8
0
        /// <summary>
        /// 构造xml
        /// </summary>
        /// <param name="_licenseTemplete"></param>
        /// <returns></returns>
        private string GetXmlByLicenseTemplete(LicenseTemplete licenseTemplete)
        {
            XmlDocument xmldoc  = new XmlDocument();
            XmlNode     xmlnode = xmldoc.CreateXmlDeclaration("1.0", "gb2312", null);

            xmldoc.AppendChild(xmlnode);

            //加Template元素
            XmlElement rootxmlelem = xmldoc.CreateElement("", FreqStationHelper.template, "");
            XmlText    xmltext     = xmldoc.CreateTextNode("");

            rootxmlelem.AppendChild(xmltext);
            xmldoc.AppendChild(rootxmlelem);

            //加入LicenseItems元素
            XmlElement licensexmlelem = xmldoc.CreateElement("", FreqStationHelper.licenseItems, "");

            xmltext = xmldoc.CreateTextNode("");
            licensexmlelem.AppendChild(xmltext);
            rootxmlelem.AppendChild(licensexmlelem);

            //加入LicenseItems子元素
            foreach (LicenseItem item in licenseTemplete.LicenseItems)
            {
                XmlElement element = xmldoc.CreateElement("", item.PropertyName, "");
                xmltext = xmldoc.CreateTextNode("");
                element.AppendChild(xmltext);
                element.SetAttribute("Top", item.Top.ToString());
                element.SetAttribute("Left", item.Left.ToString());
                licensexmlelem.AppendChild(element);
            }

            //加入QRCodeProperty元素
            if (licenseTemplete.IsShowQRCode)
            {
                string left = _borderqriamge.GetValue(Canvas.LeftProperty).ToString();
                string top  = _borderqriamge.GetValue(Canvas.TopProperty).ToString();

                XmlElement qrelement = xmldoc.CreateElement("", FreqStationHelper.qrCodeProperty, "");
                xmltext = xmldoc.CreateTextNode("");
                qrelement.AppendChild(xmltext);

                qrelement.SetAttribute("Top", top);
                qrelement.SetAttribute("Left", left);
                qrelement.SetAttribute("Height", this._txtqrHeight.EditValue.ToString());
                qrelement.SetAttribute("Width", this._txtqrWidth.EditValue.ToString());
                rootxmlelem.AppendChild(qrelement);
            }

            if (licenseTemplete.IsShowQRCode)
            {
                XmlElement qrfieldselement = xmldoc.CreateElement("", FreqStationHelper.qrCodeFields, "");
                xmltext = xmldoc.CreateTextNode("");
                qrfieldselement.AppendChild(xmltext);

                foreach (string field in QRFields)
                {
                    string     f            = field.Replace(" ", "");
                    XmlElement fieldelement = xmldoc.CreateElement("", f, "");
                    xmltext = xmldoc.CreateTextNode("");
                    fieldelement.AppendChild(xmltext);
                    qrfieldselement.AppendChild(fieldelement);
                }
                rootxmlelem.AppendChild(qrfieldselement);
            }

            return(xmldoc.InnerXml.ToString());
        }