Ejemplo n.º 1
0
        private void UpdateDomainObject(Esoppicsng picNG)
        {
            if (m_EsopPicsNGFacade == null)
            {
                m_EsopPicsNGFacade = new EsopPicsNGFacade(this.DataProvider);
            }
            Messages msg = new Messages();

            this.DataProvider.BeginTransaction();
            try
            {
                if (UpLoadFile(picNG, "UPDATE"))
                {
                    m_EsopPicsNGFacade.UpdateEsoppicsng(picNG);
                    this.DataProvider.CommitTransaction();
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_Save_Success"));
                    ApplicationRun.GetInfoForm().Add(msg);
                }
                else
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_Save_Lot_Error"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.DataProvider.RollbackTransaction();
                }
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                msg.Add(new UserControl.Message(MessageType.Error, "$CS_Save_Lot_Error"));
                ApplicationRun.GetInfoForm().Add(msg);
            }
        }
Ejemplo n.º 2
0
        private void listPicsNG_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (listPicsNG.SelectedItems.Count > 0)
                {
                    this.pbEsopIMG.Image   = null;
                    this.txtNGPicMemo.Text = string.Empty;
                    this.listPics.SelectedItems.Clear();


                    int        num         = listPicsNG.Items.IndexOf(listPicsNG.SelectedItems[0]);
                    Esoppicsng selectedPic = (Esoppicsng)this.listPicsNG.SelectedItems[0].Tag;
                    this.txtNGPicMemo.Text = selectedPic.Ngpicmemo;
                    string filaPath = "";

                    if (_facade == null)
                    {
                        _facade = new SystemSettingFacade(this.DataProvider);
                    }
                    object parameter = _facade.GetParameter("PUBLISHESOPPICSDIRPATH", "PUBLISHEOPSPICSDIRPATHGROUP");

                    if (parameter != null)
                    {
                        //服务器目录路径
                        filaPath = ((Domain.BaseSetting.Parameter)parameter).ParameterAlias;
                    }

                    string fileName = filaPath + "TS/" + selectedPic.Picsname + ".jpg";

                    try
                    {
                        WebClient wc = new WebClient();
                        wc.Credentials = CredentialCache.DefaultCredentials;
                        // wc.DownloadData(fileName);
                        Stream fs  = wc.OpenRead(fileName);
                        Image  img = Image.FromStream(fs);
                        this.pbEsopIMG.Size  = img.Size;
                        this.pbEsopIMG.Image = img;
                        fs.Flush();
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Messages msg = new Messages();
                msg.Add(new UserControl.Message(MessageType.Error, "$Error_NoDataSelected"));
                ApplicationRun.GetInfoForm().Add(msg);
                return;
            }
        }
Ejemplo n.º 3
0
 public void UpdateEsoppicsng(Esoppicsng esoppicsng)
 {
     this.DataProvider.Update(esoppicsng);
 }
Ejemplo n.º 4
0
 public void DeleteEsoppicsng(Esoppicsng esoppicsng)
 {
     this.DataProvider.Delete(esoppicsng);
 }
Ejemplo n.º 5
0
 public void AddEsoppicsng(Esoppicsng esoppicsng)
 {
     this.DataProvider.Insert(esoppicsng);
 }
Ejemplo n.º 6
0
        private bool UpLoadFile(Esoppicsng picNG, string action)
        {
            try
            {
                if (_facade == null)
                {
                    _facade = new SystemSettingFacade(this.DataProvider);
                }
                object parameter = _facade.GetParameter("PUBLISHESOPPICSDIRPATH", "PUBLISHEOPSPICSDIRPATHGROUP");
                if (parameter != null)
                {
                    //服务器目录路径
                    string filePath = ((Domain.BaseSetting.Parameter)parameter).ParameterAlias + "TS/";
                    string fileName = filePath + picNG.Picsname + ".jpg";
                    if (picNG != null)
                    {
                        /**/
                        /// 创建WebClient实例
                        WebClient myWebClient = new WebClient();
                        myWebClient.Credentials = CredentialCache.DefaultCredentials;

                        string localPath = "c:\\esop\\";
                        if (!Directory.Exists(localPath))
                        {
                            Directory.CreateDirectory(localPath);
                        }

                        Image image = this.pbEsopIMG.Image;
                        image.Save("c:\\esop\\1.jpg", pbEsopIMG.Image.RawFormat);

                        FileStream   fs         = new FileStream("C:\\esop\\1.jpg", FileMode.Open, FileAccess.ReadWrite);
                        BinaryReader br         = new BinaryReader(fs);
                        byte[]       postArray  = br.ReadBytes((int)fs.Length);
                        Stream       postStream = myWebClient.OpenWrite(fileName, "PUT");
                        try
                        {
                            if (postStream.CanWrite)
                            {
                                postStream.Write(postArray, 0, postArray.Length);
                                postStream.Close();
                                fs.Dispose();
                            }
                            else
                            {
                                postStream.Close();
                                fs.Dispose();
                            }
                        }
                        catch (Exception err)
                        {
                            postStream.Close();
                            fs.Close();
                            throw err;
                        }
                        finally
                        {
                            postStream.Close();
                            fs.Dispose();
                        }
                    }
                    return(true);
                }
                else
                {
                    Messages msg = new Messages();
                    msg.Add(new UserControl.Message(MessageType.Error, "$Error_PicDirPath_NotExist"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Messages msg = new Messages();
                msg.Add(new UserControl.Message(MessageType.Error, "$Error_UpLoadFile_Exception"));
                ApplicationRun.GetInfoForm().Add(msg);
                return(false);
            }
        }
Ejemplo n.º 7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (listPicsNG.SelectedItems.Count > 0 && this.pbEsopIMG.Image != null)
            {
                try
                {
                    Esoppicsng selectedPic = (Esoppicsng)this.listPicsNG.SelectedItems[0].Tag;
                    if (m_EsopPicsNGFacade == null)
                    {
                        m_EsopPicsNGFacade = new EsopPicsNGFacade(this.DataProvider);
                    }
                    this.DataProvider.BeginTransaction();
                    m_EsopPicsNGFacade.DeleteEsoppicsng(selectedPic);
                    string filaPath = "";

                    if (_facade == null)
                    {
                        _facade = new SystemSettingFacade(this.DataProvider);
                    }
                    object parameter = _facade.GetParameter("PUBLISHESOPPICSDIRPATH", "PUBLISHEOPSPICSDIRPATHGROUP");

                    if (parameter != null)
                    {
                        //服务器目录路径
                        filaPath = ((Domain.BaseSetting.Parameter)parameter).ParameterAlias + "TS/";
                    }

                    string fileName = filaPath + selectedPic.Picsname + ".jpg";
                    /// 创建WebClient实例
                    WebClient myWebClient = new WebClient();
                    myWebClient.Credentials = CredentialCache.DefaultCredentials;

                    byte[] postArray  = new byte[0];
                    Stream postStream = myWebClient.OpenWrite(fileName, "PUT");
                    try
                    {
                        if (postStream.CanWrite)
                        {
                            postStream.Write(postArray, 0, 0);
                            postStream.Close();
                        }
                        else
                        {
                            postStream.Close();
                        }
                    }
                    catch (Exception err)
                    {
                        postStream.Close();
                        throw err;
                    }
                    finally
                    {
                        postStream.Close();
                    }

                    this.DataProvider.CommitTransaction();
                    imageListCache.Clear();
                    this.pbEsopIMG.Image = null;
                    QueryPicsNG();
                    Messages msg = new Messages();
                    msg.Add(new UserControl.Message(MessageType.Success, "$CS_Delete_Success"));
                    ApplicationRun.GetInfoForm().Add(msg);
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();
                }
            }
            else
            {
                Messages msg = new Messages();
                msg.Add(new UserControl.Message(MessageType.Error, "$Error_NoDataSelected"));
                ApplicationRun.GetInfoForm().Add(msg);
            }
        }
Ejemplo n.º 8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (pbEsopIMG.Image == null)
            {
                return;
            }

            Messages msg = new Messages();

            if (_tsFacade == null)
            {
                _tsFacade = new TSFacade(this.DataProvider);
            }
            if (string.IsNullOrEmpty(this.txtRcard.Text))
            {
                return;
            }

            object obj = _tsFacade.QueryLastTSByRunningCard(this.txtRcard.Text);

            if (obj != null)
            {
                Domain.TS.TS ts = (Domain.TS.TS)obj;
                if (ts.TSStatus == TSStatus.TSStatus_Complete)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_TS_Completed"));
                    ApplicationRun.GetInfoForm().Add(msg);
                }
                else
                {
                    DBDateTime       dbDateTime         = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    EsopPicsNGFacade m_EsopPicsNGFacade = new EsopPicsNGFacade(this.DataProvider);

                    if (this.listPicsNG.SelectedItems.Count == 0)
                    {
                        Esoppicsng picNG = m_EsopPicsNGFacade.CreateNewEsoppicsng();
                        picNG.Serial    = ((Esoppicsng)m_EsopPicsNGFacade.GetEsoppicNGNextSerial()[0]).Serial;
                        picNG.Rcard     = FormatHelper.CleanString(this.txtRcard.Text, 40);
                        picNG.Ngpicmemo = FormatHelper.CleanString(this.txtNGPicMemo.Text, 500);
                        picNG.Tsid      = ts.TSId;
                        picNG.Picsname  = "NG" + picNG.Rcard + picNG.Tsid + dbDateTime.DateTime.ToString("yyyyMMddHHmmss");
                        picNG.Muser     = ApplicationService.Current().LoginInfo.UserCode;
                        picNG.Mdate     = dbDateTime.DBDate;
                        picNG.Mtime     = dbDateTime.DBTime;
                        AddDomainObject(picNG);
                    }
                    else
                    {
                        Esoppicsng picNG = (Esoppicsng)this.listPicsNG.SelectedItems[0].Tag;
                        picNG.Muser     = ApplicationService.Current().LoginInfo.UserCode;
                        picNG.Ngpicmemo = FormatHelper.CleanString(this.txtNGPicMemo.Text, 500);
                        picNG.Mdate     = dbDateTime.DBDate;
                        picNG.Mtime     = dbDateTime.DBTime;
                        UpdateDomainObject(picNG);
                    }
                    Init(this.txtRcard.Text);
                    this.pbEsopIMG.Image   = null;
                    this.txtNGPicMemo.Text = string.Empty;
                    imageListCache.Clear();
                }
            }
            else
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$CS_TS_Not_Exist"));
                ApplicationRun.GetInfoForm().Add(msg);
            }
        }