Example #1
0
        /// <summary>
        /// 按钮点击事件-上传报告
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void UpReportBtn_Click(object sender, RoutedEventArgs e)
        {
            if (MoldNRTB.Text.Length > 0 && OperatorNRTB.Text.Length > 0)
            {
                StorageManageServiceClient client = new StorageManageServiceClient();
                ConditionServiceClient conditionclient = new ConditionServiceClient();
                BasicMessage bmsg = new BasicMessage();
                if (!conditionclient.MoldExist(MoldNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("模具");
                }
                if (OperatorNRTB.Text.Length != 0 && !conditionclient.EmpExist(OperatorNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("试验员");
                }
                if (bmsg.Result == false)
                {
                    MessageBox.Show(bmsg.MsgText + " 不存在,请重新输入");
                    return;
                }
                // MoldPartInfoServiceClient bclient = new MoldPartInfoServiceClient();
                //MoldBaseInfo moldBaseInfo = bclient.GetMoldBaseInfoByNR(MoldNRTB.Text);
                //if (moldBaseInfo.State == ToolingManWPF.MoldPartInfoServiceReference.MoldStateType.NotReturned)
                //{
                //    MessageBox.Show("模具还未归还!");
                //    return;
                //}

                List<FileUP> files = null;
                long fileTotalLength = 0;
                if (FileNameList.Items.Count > 0)
                {
                    files = new List<FileUP>();
                    UserListBoxItem userListBoxItem;

                    imageFilter = FileFilterUtil.GetImageFilters();
                    documentFilter = FileFilterUtil.GetDocumentFilters();

                    foreach (object item in FileNameList.Items)
                    {
                        userListBoxItem = item as UserListBoxItem;
                        string path = userListBoxItem.Value;

                        if (File.Exists(path))
                        {
                            string fileType = path.Substring(path.LastIndexOf('.'), path.Length - path.LastIndexOf('.'));
                            string fileName = userListBoxItem.Display;

                            Stream stream = File.Open(path, FileMode.Open, FileAccess.Read);
                            byte[] data = new byte[stream.Length];
                            stream.Read(data, 0, data.Length);
                            stream.Seek(0, SeekOrigin.Begin);

                            fileTotalLength += stream.Length;

                            ToolingManWPF.StorageManageServiceReference.AttachmentType attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.PICTURE;

                            if (imageFilter.Contains(fileType))
                            {
                                attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.PICTURE;
                            }
                            else if (documentFilter.Contains(fileType))
                            {
                                attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.DOCUMENT;
                            }
                            files.Add(new FileUP() { Name = fileName, FileType = fileType, Type = attachType, Data = data });
                        }
                    }

                }

                if (fileTotalLength < long.Parse((new ConfigUtil("MAXFILELENGTH")).Get("MAXLENGTH")))
                {
                    Message msg = new Message();
                    switch ((ToolingManWPF.MoldPartInfoServiceReference.ReportType)int.Parse(MaintainTypeCB.SelectedValue.ToString()))
                    {
                        case ToolingManWPF.MoldPartInfoServiceReference.ReportType.MaintainReport:
                           // msg = client.MoldMaintain(MoldNRTB.Text, OperatorNRTB.Text, files, (bool)MoldStateCheckBox.IsChecked);
                            msg = client.MoldMaintain(MoldNRTB.Text, OperatorNRTB.Text, files, false);
                            break;
                        case ToolingManWPF.MoldPartInfoServiceReference.ReportType.TestReport:
                            int c = 0;
                            //int.TryParse(CurrentCutTimeTB.Text,out c);
                            msg = client.MoldTest(MoldNRTB.Text, OperatorNRTB.Text, files, c, false);
                            //msg = client.MoldTest(MoldNRTB.Text, OperatorNRTB.Text, files, c, (bool)MoldStateCheckBox.IsChecked);
                            break;
                    }

                    MessageBox.Show(msg.Content);
                }
                else
                    MessageBox.Show("一次上传文件大小不可大于50M", "", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Example #2
0
        /// <summary>
        /// 按钮点击事件-上传报告
        /// </summary>
        /// <param name="sender">事件源</param>
        /// <param name="e">事件参数</param>
        private void UpReportBtn_Click(object sender, RoutedEventArgs e)
        {
            if (MoldNRTB.Text.Length > 0 && OperatorNRTB.Text.Length > 0)
            {
                StorageManageServiceClient client          = new StorageManageServiceClient();
                ConditionServiceClient     conditionclient = new ConditionServiceClient();
                BasicMessage bmsg = new BasicMessage();
                if (!conditionclient.MoldExist(MoldNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("模具");
                }
                if (OperatorNRTB.Text.Length != 0 && !conditionclient.EmpExist(OperatorNRTB.Text))
                {
                    bmsg.Result = false;
                    bmsg.MsgContent.Add("试验员");
                }
                if (bmsg.Result == false)
                {
                    MessageBox.Show(bmsg.MsgText + " 不存在,请重新输入");
                    return;
                }
                // MoldPartInfoServiceClient bclient = new MoldPartInfoServiceClient();
                //MoldBaseInfo moldBaseInfo = bclient.GetMoldBaseInfoByNR(MoldNRTB.Text);
                //if (moldBaseInfo.State == ToolingManWPF.MoldPartInfoServiceReference.MoldStateType.NotReturned)
                //{
                //    MessageBox.Show("模具还未归还!");
                //    return;
                //}

                List <FileUP> files           = null;
                long          fileTotalLength = 0;
                if (FileNameList.Items.Count > 0)
                {
                    files = new List <FileUP>();
                    UserListBoxItem userListBoxItem;

                    imageFilter    = FileFilterUtil.GetImageFilters();
                    documentFilter = FileFilterUtil.GetDocumentFilters();


                    foreach (object item in FileNameList.Items)
                    {
                        userListBoxItem = item as UserListBoxItem;
                        string path = userListBoxItem.Value;

                        if (File.Exists(path))
                        {
                            string fileType = path.Substring(path.LastIndexOf('.'), path.Length - path.LastIndexOf('.'));
                            string fileName = userListBoxItem.Display;

                            Stream stream = File.Open(path, FileMode.Open, FileAccess.Read);
                            byte[] data   = new byte[stream.Length];
                            stream.Read(data, 0, data.Length);
                            stream.Seek(0, SeekOrigin.Begin);

                            fileTotalLength += stream.Length;

                            ToolingManWPF.StorageManageServiceReference.AttachmentType attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.PICTURE;

                            if (imageFilter.Contains(fileType))
                            {
                                attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.PICTURE;
                            }
                            else if (documentFilter.Contains(fileType))
                            {
                                attachType = ToolingManWPF.StorageManageServiceReference.AttachmentType.DOCUMENT;
                            }
                            files.Add(new FileUP()
                            {
                                Name = fileName, FileType = fileType, Type = attachType, Data = data
                            });
                        }
                    }
                }

                if (fileTotalLength < long.Parse((new ConfigUtil("MAXFILELENGTH")).Get("MAXLENGTH")))
                {
                    Message msg = new Message();
                    switch ((ToolingManWPF.MoldPartInfoServiceReference.ReportType) int.Parse(MaintainTypeCB.SelectedValue.ToString()))
                    {
                    case ToolingManWPF.MoldPartInfoServiceReference.ReportType.MaintainReport:
                        // msg = client.MoldMaintain(MoldNRTB.Text, OperatorNRTB.Text, files, (bool)MoldStateCheckBox.IsChecked);
                        msg = client.MoldMaintain(MoldNRTB.Text, OperatorNRTB.Text, files, false);
                        break;

                    case ToolingManWPF.MoldPartInfoServiceReference.ReportType.TestReport:
                        int c = 0;
                        //int.TryParse(CurrentCutTimeTB.Text,out c);
                        msg = client.MoldTest(MoldNRTB.Text, OperatorNRTB.Text, files, c, false);
                        //msg = client.MoldTest(MoldNRTB.Text, OperatorNRTB.Text, files, c, (bool)MoldStateCheckBox.IsChecked);
                        break;
                    }

                    MessageBox.Show(msg.Content);
                }
                else
                {
                    MessageBox.Show("一次上传文件大小不可大于50M", "", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
        }