Example #1
0
        public static BitmapImage GetImage(WorkLogStuff logStuff)
        {
            if (!logStuff.IsLoaded)
            {
                if (!logStuff.IsLoaded)
                {
                    PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.MonitorTask.I_CO_IA_MonitorTask>(channel =>
                    {
                        byte[] result = channel.GetWorkLogStuffByID(logStuff.Key);
                        if (result != null && result.Length > 0)
                        {
                            logStuff.Content = result;
                        }
                    });
                }
            }

            MemoryStream stream = new MemoryStream(logStuff.Content);
            BitmapImage  bmp    = new BitmapImage();

            bmp.BeginInit();           //初始化
            bmp.StreamSource = stream; //设置源
            bmp.EndInit();             //初始化结束
            return(bmp);
        }
Example #2
0
        public static string SaveStuffFile(WorkLogStuff logStuff)
        {
            string filePath = System.IO.Path.Combine(basePath, string.Format("{0}.{1}", logStuff.Key, ((AT_BC.Data.IFileDescription)logStuff).Extension));

            if (!System.IO.File.Exists(filePath))
            {
                if (!logStuff.IsLoaded)
                {
                    PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.MonitorTask.I_CO_IA_MonitorTask>(channel =>
                    {
                        byte[] result = channel.GetWorkLogStuffByID(logStuff.Key);
                        if (result != null && result.Length > 0)
                        {
                            logStuff.Content = result;
                        }
                    });
                }
                using (var fs = System.IO.File.Create(filePath))
                {
                    fs.Write(logStuff.Content, 0, logStuff.Content.Length);
                    //fs.Close();
                }
            }
            return(filePath);
        }
Example #3
0
        public static string GetDisplayFile(WorkLogStuff logStuff)
        {
            string filePath = SaveStuffFile(logStuff);

            if (!OfficeConverter.IsValidOfficeFile(filePath))
            {
                return(filePath);
            }
            else
            {
                string xpsFilePath = System.IO.Path.Combine(basePath, string.Format("{0}.xps", logStuff.Key));
                OfficeConverter.ConvertToXps(filePath, xpsFilePath);
                return(xpsFilePath);
            }
        }
 private void buttonWorkLogAdd_Click(object sender, RoutedEventArgs e)
 {
     if (CurrentWorkLog != null)
     {
         byte[]         bytes  = null;
         OpenFileDialog dialog = new OpenFileDialog();
         if (dialog.ShowDialog() == true)
         {
             Stream fs = null;
             try
             {
                 fs    = dialog.OpenFile();
                 bytes = new byte[fs.Length];
                 fs.Read(bytes, 0, bytes.Length);
             }
             catch
             {
                 throw;
             }
             finally
             {
                 if (fs != null)
                 {
                     fs.Close();
                 }
             }
             if (bytes != null)
             {
                 WorkLogStuff stuff = new WorkLogStuff();
                 stuff.Key                 = Utility.NewGuid();
                 stuff.IsLoaded            = true;
                 stuff.Content             = bytes;
                 stuff.ContentLength       = bytes.Length;
                 stuff.Name                = dialog.SafeFileName;
                 stuff.WorkLogGuid         = CurrentWorkLog.Key;
                 stuff.SubmitUser          = RiasPortal.Current.UserSetting.UserName;
                 CurrentWorkLog.SubmitTime = DateTime.Now;
                 stuff.DataState           = DataStateEnum.Added;
                 CurrentWorkLog.StuffList.Add(stuff);
                 //PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke<I_CO_IA.MonitorTask.I_CO_IA_MonitorTask>(channel =>
                 //{
                 //    channel.SaveWorkLogStuff(stuff);
                 //});
                 WorkLogStuffSource.Add(stuff);
             }
         }
     }
 }
 private void FileDescriptionSaveAsCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (e.Parameter is WorkLogStuff)
     {
         WorkLogStuff logStuff = e.Parameter as WorkLogStuff;
         if (logStuff != null)
         {
             PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.MonitorTask.I_CO_IA_MonitorTask>(channel =>
             {
                 var result = channel.GetWorkLogStuffByID(logStuff.Key);
                 if (result != null && result.Length > 0)
                 {
                     logStuff.Content = result;
                 }
             });
         }
         FileDescriptionHelper.SaveAs(sender, e);
     }
 }
        //private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        //{
        //    CO_IA.Client.AudioPlayer.Stop();
        //}

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonWorkLogDelete_Click(object sender, RoutedEventArgs e)
        {
            var hyperlink = sender as Hyperlink;

            if (hyperlink != null)
            {
                WorkLogStuff logStuff = hyperlink.DataContext as WorkLogStuff;
                if (logStuff != null)
                {
                    if (MessageBox.Show("确实要删除选中的资料吗? 删除后将不能取消", "删除提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.MonitorTask.I_CO_IA_MonitorTask>(channel =>
                        {
                            channel.DeleteWorkLogStuff(logStuff.Key);
                        });
                        WorkLogStuffSource.Remove(logStuff);
                    }
                }
            }
        }