private void LoadBOM_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg_im = new OpenFileDialog();
                dlg_im.Filter = "Excel File|*.xls;*.xlsx;*.xlsm";
                //dlg_im.Filter = "Excel File|*.xlsx";

                if (dlg_im.ShowDialog() == DialogResult.OK)
                {
                    //this.TopMost = true;
                    this.Enabled = false;
                    //dataGridView1.Rows.Clear();
                    txtBOMFilePath.Text = dlg_im.FileName;
                    _frmWait            = new FrmWait();
                    _frmWait.Show();

                    //await Task.Run(() => LoadBOMFromFile());
                    LoadBOMFromFile();
                    dataGridView1.DataSource = _dtSalesBOM;
                    _frmWait.Close();
                    this.Enabled = true;
                    this.TopMost = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#2
0
        // Refresh the list.
        private void mnuFileRefreshList_Click(object sender, System.EventArgs e)
        {
            // Warn them if they have stuff selected.
            if (HasStartedProcessing())
            {
                if (MessageBox.Show("This will wipe out your current selections. Refresh anyway?", "Refresh Lists", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            // Reload the claim list.
            FrmWait f = null;

            try
            {
                f = new FrmWait();
                f.Message.Text = "Please wait while the information is retrieved...";
                f.Show(); Application.DoEvents();
                RefreshList();
            }
            catch (Exception ex)
            {
                Globals.Logger.Warn("Could not load claims.", ex);
            }
            finally
            {
                if (f != null)
                {
                    f.Close();
                    f = null;
                }
            }
        }
        private void itemDeleteProject_Click(object sender, EventArgs e)
        {
            if (dataGridViewProjects.Rows.Count > 0 && dataGridViewProjects.SelectedRows.Count > 0)
            {
                //this.TopMost = true;
                this.Enabled = false;
                _frmWait     = new FrmWait();
                _frmWait.Show();

                //
                //await Task.Run(() => DeleteProjectAndChildern());
                DeleteProjectAndChildern();
                _frmWait.Close();
                this.Enabled = true;
                this.TopMost = false;

                DataView dv = _dtProjects.DefaultView;
                dv.Sort     = "ProjectCode desc";
                _dtProjects = dv.ToTable();
            }
            else
            {
                ClearAll();
            }
        }
示例#4
0
        private void downloadFile(object rowIndex)
        {
            int    BufferLen      = 4096;
            string folder         = folderBrowserDialog1.SelectedPath;
            string file           = this.dgvShareFile.Rows[(int)rowIndex].Cells["FilePath"].Value.ToString();
            string fileName       = Path.GetFileName(file);
            string fileServiceUrl = string.Empty;

            using (BugTraceEntities zentity = new BugTraceEntities(EntityContextHelper.GetEntityConnString()))
            {
                var currVersion = zentity.SYS_Version.Where(p => p.IsDefault == 1).FirstOrDefault();
                fileServiceUrl = currVersion.FileServiceUrlPort;
            }
            Stream sourceStream = null;

            try
            {
                EndpointAddress address = new EndpointAddress("http://" + fileServiceUrl + "/JAJ.WinServer/FileService");
                FileTransferSvc.FileServiceClient _client = new FileTransferSvc.FileServiceClient("BasicHttpBinding_IFileService", address);
                sourceStream = _client.DowndloadFile(file);
            }
            catch (Exception ex)
            {
                MyLog.LogError("文件下载失败!", ex);
                return;
            }
            FileStream targetStream = null;

            if (!sourceStream.CanRead)
            {
                MyLog.LogError("下载异常", new Exception("Invalid Stream!"));
                throw new Exception("Invalid Stream!");
            }

            string filePath = Path.Combine(folder, fileName);

            using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                byte[] buffer = new byte[BufferLen];
                int    count  = 0;
                while ((count = sourceStream.Read(buffer, 0, BufferLen)) > 0)
                {
                    targetStream.Write(buffer, 0, count);
                }
                targetStream.Close();
                sourceStream.Close();
            }
            this.Invoke(new MethodInvoker(() => {
                try
                {
                    wait.Close();
                }
                catch
                { }

                MessageBox.Show("下载成功!");
            }));
        }
示例#5
0
 void _client_UploadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         return;
     }
     if (e.Error != null)
     {
         MessageBox.Show(e.Error.Message);
         MyLog.LogError("问题列表上传文件错误", e.Error);
         return;
     }
     try
     {
         wait.Close();
     }
     catch
     {  }
     SaveProblemTrace(true);
 }
示例#6
0
        /// <summary>Initializes an instance of FrmMain.</summary>
        public frmMain()
        {
            // Build and initialize the form.
            InitializeComponent();
            StartEventProcessing();

            // Connect to the database.
            try
            {
                Globals.Logger.Debug("Opening database connection...");
                Globals.Database = new SqlConnection(SettingsManager.Instance.Settings["EClaims"].DatabaseConnection.GetSqlConnectionString("Application Name=EClaims"));
                Globals.Database.Open();
                Globals.Logger.Debug("Database open.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not open connection to database.", "EClaims");
                Globals.Logger.Error("Could not open connection to database.", ex);
            }

            // Load the claim list.
            FrmWait f = null;

            try
            {
                f = new FrmWait();
                f.Message.Text = "Please wait while the information is retrieved...";
                f.Show(); Application.DoEvents();
                RefreshList();
            }
            catch (Exception ex)
            {
                Globals.Logger.Warn("Could not load claims.", ex);
            }
            finally
            {
                if (f != null)
                {
                    f.Close();
                    f = null;
                }
            }

            // Build the handling menus.
            foreach (ClaimHandler hc in Globals.Settings.Handlers)
            {
                mnuClaims.MenuItems.Add(hc.Name, new System.EventHandler(this.SetHandling));
                mnuHandling.MenuItems.Add(hc.Name, new System.EventHandler(this.SetHandling));
            }
            mnuClaims.MenuItems.Add("-");
            mnuClaims.MenuItems.Add("Clear Handling", new System.EventHandler(this.SetNone));
            mnuHandling.MenuItems.Add("-");
            mnuHandling.MenuItems.Add("Clear Handling", new System.EventHandler(this.SetNone));
        }
示例#7
0
 private void MessageBoxInvoker(string message)
 {
     this.BeginInvoke(new MethodInvoker(() =>
     {
         MessageBox.Show(message);
         try
         {
             wait.Close();
         }
         catch
         {
         }
     }));
 }
示例#8
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            FrmWait frmwait = new FrmWait();

            frmwait.Show();

            //Application.DoEvents();
            this.Enabled = false;

            await Task.Run(() => SaveToRepository());


            //_LstProjects
            this.Enabled = true;
            frmwait.Close();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //this.TopMost = true;
            this.Enabled = false;
            _frmWait     = new FrmWait();
            _frmWait.Show();
            //await Task.Run(() => SaveToRepository());
            SaveToRepository();

            DataView dv = _dtProjects.DefaultView;

            dv.Sort     = "ProjectCode desc";
            _dtProjects = dv.ToTable();

            //_LstProjects
            _frmWait.Close();
            this.Enabled = true;
            this.TopMost = false;
        }
示例#10
0
 /// <summary>
 /// 显示窗口过程
 /// </summary>
 /// <param name="pComponet"></param>
 static void show(object pComponet)
 {
     if (pComponet != null &&
         pComponet is Control)
     {
         //设置显示状态
         mShowing = true;
         //当调用对象为Win控件时
         (pComponet as Control).BeginInvoke(new ExecutedInvokeHeandle(delegate()
         {
             //进行异步调用
             if (pComponet != null &&
                 pComponet is Control)
             {
                 //显示等待窗口
                 mWait.Show((pComponet as Control).FindForm());
                 //设置父级窗口关闭事件
                 (pComponet as Control).FindForm().FormClosed += new FormClosedEventHandler(WaitForm_FormClosed);
                 //激活父级窗口,
                 (pComponet as Control).FindForm().Activate();
             }
             else
             {
                 //如查询不到父级窗口设置顶层显示,此处可用GetDesktop的API来获取桌面窗口,并设置为父级窗口
                 mWait.TopMost = true;
                 //显示等待窗口
                 mWait.Show();
             }
         }));
         //设置等待信号
         mWaiting = true;
         mEvents.WaitOne();
         //等待结束
         mWaiting = false;
         (pComponet as Control).BeginInvoke(new ExecutedInvokeHeandle(delegate()
         {
             //关闭窗口
             mWait.Close();
         }));
     }
 }
示例#11
0
        // Process the claims.
        private void btnProcess_Click(object sender, System.EventArgs e)
        {
            // Make sure they want to do this.
            if (MessageBox.Show("Process the claims as defined?", "Process", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            // Show the 'please wait' dialog.
            FrmWait f = new FrmWait();

            f.Message.Text = "Please wait while the claims are processed.";
            f.Show();
            btnProcess.Enabled = false;
            Application.DoEvents();

            Globals.Logger.Info("Processing claims...");
            SqlTransaction trans = Globals.Database.BeginTransaction();

            // Work the claims one handling method at a time.
            bool         success = true;
            ClaimHandler ch;
            Claim        cl;

            Globals.Settings.ResetHandlers();
            foreach (ListViewItem lvi in listClaims.Items)
            {
                if (lvi.SubItems[5].Text != string.Empty)
                {
                    ch = Globals.Settings.GetHandlerByName(lvi.SubItems[5].Text);
                    if (ch.Batch == null)
                    {
                        ch.CreateBatch(trans);
                    }
                    try
                    {
                        cl = new Claim(((int[])lvi.Tag)[0], ((int[])lvi.Tag)[1], trans);
                        try
                        {
                            ValidateClaim.Validate(cl);
                        }
                        catch (Exception ex2)
                        {
                            if (MessageBox.Show("Warning: " + lvi.SubItems[0].Text + " Claim for " + lvi.SubItems[1].Text + " (" + lvi.SubItems[4].Text + ": " + lvi.SubItems[3].Text + ") failed validation. Process anyway?" + Environment.NewLine + Environment.NewLine + ex2.Message, "Process Claims", MessageBoxButtons.YesNo) == DialogResult.No)
                            {
                                Globals.Logger.Info("Claim " + ((int[])lvi.Tag)[0].ToString() + "/" + ((int[])lvi.Tag)[1].ToString() + " not added to batch. " + ex2.Message);
                                continue;
                            }
                        }
                        ch.AddClaim(trans, cl);
                    }
                    catch (Exception ex)
                    {
                        Globals.Logger.Error("Could not add claim " + ((int[])lvi.Tag)[0].ToString() + "/" + ((int[])lvi.Tag)[1].ToString() + " to batch.", ex);
                        success = false;
                    }
                }
            }
            trans.Commit();


            // Process the electronic claims.
            foreach (ClaimHandler c in Globals.Settings.Handlers)
            {
                if ((c is ElectronicClaimHandler) && (c.Batch != null))
                {
                    Globals.Logger.Info("Executing post-processing for handler " + c.Name + " (batch " + c.Batch.BatchInformation.BatchID.ToString() + ")...");
                    try
                    {
                        ((ElectronicClaimHandler)c).Process();
                    }
                    catch (Exception ex)
                    {
                        Globals.Logger.Error("Processing failed.", ex);
                        success = false;
                    }
                    Globals.Logger.Info("Post-processing complete for handler " + c.Name + " (batch " + c.Batch.BatchInformation.BatchID.ToString() + ").");
                }
            }

            // Let them know we're done.
            Globals.Logger.Info("Claim processing complete.");
            if (success)
            {
                MessageBox.Show("Claim processing complete.", "Process");
            }
            else
            {
                MessageBox.Show("Claim processing completed with errors. See log for details.", "Process");
            }

            // Reload the claim list.
            try
            {
                f.Message.Text = "Please wait while the information is retrieved...";
                Application.DoEvents();
                RefreshList();
            }
            catch (Exception ex)
            {
                Globals.Logger.Warn("Could not load claims.", ex);
            }
            finally
            {
                if (f != null)
                {
                    f.Close();
                    f = null;
                }
            }

            btnProcess.Enabled = true;
        }