/** * Pedigree Service Implementation * Creates a new pedigree object at the request of PedigreeManager. * * */ public new void storePedigreeData(Pedigree pedigree) { Pedigree pED1 = new Pedigree(); try { Stream os = new System.IO.FileStream("pedigree1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write);; os.Equals(pED1); os.Close(); } catch (IOException ex) { Console.WriteLine(ex); } } // end Pedigree Service
/** * Sender's Data Service Implementation * Creates a new sender envelope data form at the request of the SenderDataManager. */ public new void storeSenderData(SendersEnvelopeDataForm sendersEnvelopeData) { SendersEnvelopeDataForm sED1 = new SendersEnvelopeDataForm(); try { Stream os = new System.IO.FileStream("senders1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); os.Equals(sED1); os.Close(); } catch (IOException ex) { Console.WriteLine(ex); } } // end Senders Data Service
/** * Product Service Implementation * Creates a new product object at the request of ProductManager. * */ public new void storeProductData(Product product) { Product pDT1 = new Product(); try { Stream os = new System.IO.FileStream("product1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); os.Equals(pDT1); os.Close(); } catch (IOException ex) { Console.WriteLine(ex); } } // end Product Service
/** * Manufacturer Service Implementation * Creates a new manufacturer profile object at the request of ManufacturerManager. * * */ public new void createMfgrProfile(Manufacturer manufacturer) { Manufacturer mFG1 = new Manufacturer(); try { Stream os = new System.IO.FileStream("manufacturer1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); os.Equals(mFG1); os.Close(); } catch (IOException ex) { Console.WriteLine(ex.ToString()); Console.Write(ex); } } // end Manufacturer
/** * Receiver's Data Service Implementation * Creates a new receiver envelope data form at the request of the ReceiverDataManager. * */ public new bool storeReceiverEnvelopeDataForm(ReceiversEnvelopeDataForm receiversEnvelopeDataForm) { bool isGood = false; ReceiversEnvelopeDataForm rED1 = new ReceiversEnvelopeDataForm(); try { Stream os = new System.IO.FileStream("receiver1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); os.Equals(rED1); os.Close(); } catch (IOException ex) { Console.WriteLine(ex); } return(isGood); } // end Receiver's Data Service
/// <summary> /// 写数据 /// </summary> /// <param name="writer">FileStream对象</param> /// <param name="data">数据</param> /// <returns>true-成功;false-失败</returns> private bool Save(FileStream writer, string data) { if (writer == null || writer.Equals(null)) return false; byte[] b = null; long len = 0; b = Utf8.GetBytes(data); len = writer.Length; try { writer.Lock(0, len); writer.Seek(0, SeekOrigin.End); writer.Write(b, 0, b.Length); writer.Unlock(0, len); writer.Flush(); } catch (IOException e) { throw e; } catch (Exception Ex) { throw Ex; } finally { try { writer.Close(); } catch (Exception Ex) { throw Ex; } } return true; }
/** * Envelope Service Implementation * Creates a new envelope object at the request of EnvelopeManager. * At the request of the "merge" button on the Envelope Tab, * it combines data entered from sender/receiver sub-forms to make * a complete and new envelope object. */ public new void createEnvelopeData(Envelope envelope) { // Final Envelope object to be serialized Envelope e1 = new Envelope(); //De-serialize sender object containing sender's information in sender place holder sEDF Stream sender1 = null; try { Stream os = new System.IO.FileStream("senders1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); } catch (FileNotFoundException e3) { // TODO Auto-generated catch block Console.WriteLine(e3); } catch (IOException e3) { // TODO Auto-generated catch block Console.WriteLine(e3); } SendersEnvelopeDataForm sEDF = null; try { sEDF = (SendersEnvelopeDataForm)sender1.GetLifetimeService(); } catch (IOException e2) { // TODO Auto-generated catch block Console.WriteLine(e2); } catch (Exception e2) { // TODO Auto-generated catch block Console.WriteLine(e2); } //Get data from sender's form String sFN1 = sEDF.getEnvelopeSendersFirstName(); String sML1 = sEDF.getEnvelopeSendersMiddleInitial(); String sLN1 = sEDF.getEnvelopeSendersLastName(); String sSA1 = sEDF.getEnvelopeSendersStreetAddress(); String sCT1 = sEDF.getEnvelopeSendersCity(); String sST1 = sEDF.getEnvelopeSendersState(); String sZC1 = sEDF.getEnvelopeSendersZipCode(); String sMg1 = sEDF.getEnvelopeMessageBody(); //Transfer data into target envelope e1.setEnvelopeSendersFirstName(sFN1); e1.setEnvelopeSendersMiddleInitial(sML1); e1.setEnvelopeSendersLastName(sLN1); e1.setEnvelopeSendersStreetAddress(sSA1); e1.setEnvelopeSendersCity(sCT1); e1.setEnvelopeSendersState(sST1); e1.setEnvelopeSendersZipCode(sZC1); e1.setEnvelopeMessageBody(sMg1); //De-serialize sender object containing sender's information in sender place holder sEDF Stream receiver1 = null; try { Stream os = new System.IO.FileStream("receiver1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); } catch (FileNotFoundException e) { // TODO Auto-generated catch block Console.WriteLine(e); } catch (IOException e) { // TODO Auto-generated catch block Console.WriteLine(e); } ReceiversEnvelopeDataForm rEDF = null; try { rEDF = (ReceiversEnvelopeDataForm)receiver1.GetLifetimeService(); } catch (IOException e) { // TODO Auto-generated catch block Console.WriteLine(e); } catch (Exception e) { // TODO Auto-generated catch block Console.WriteLine(e); //Get data from receiver's form String sFN2 = rEDF.getEnvelopeReceiversFirstName(); String sML2 = rEDF.getEnvelopeReceiversMiddleInitial(); String sLN2 = rEDF.getEnvelopeReceiversLastName(); String sSA2 = rEDF.getEnvelopeReceiversStreetAddress(); String sCT2 = rEDF.getEnvelopeReceiversCity(); String sST2 = rEDF.getEnvelopeReceiversState(); String sZC2 = rEDF.getEnvelopeReceiversZipCode(); //Transfer data into target envelope e1.setEnvelopeReceiversFirstName(sFN2); e1.setEnvelopeReceiversMiddleInitial(sML2); e1.setEnvelopeReceiversLastName(sLN2); e1.setEnvelopeReceiversStreetAddress(sSA2); e1.setEnvelopeReceiversCity(sCT2); e1.setEnvelopeReceiversState(sST2); e1.setEnvelopeReceiversZipCode(sZC2); //Serialize sender/receiver data into new Envelope1.obj try { Stream os = new System.IO.FileStream("envelope1.obj", System.IO.FileMode.Create, System.IO.FileAccess.Write); os.Equals(e1); os.Close(); } catch (IOException ex) { Console.WriteLine(ex); } if (e1 != null) { //Send user a create message if successful String name0 = null; String message0 = String.Format("Envelope1.obj created!", name0); MessageBox.Show(message0); } else { //Send user a fail message if not successful String name1 = null; String message1 = String.Format("Envelope1.obj not created, call support!", name1); MessageBox.Show(message1); } } // end Envelope Service }