Exemplo n.º 1
0
        protected void btnCreateECE_Click(object sender, EventArgs e)
        {
            ECEClass ece = new ECEClass();

            ece.initializeDefaultECEXml();

            ECEClass.Subject subject = new ECEClass.Subject();
            subject._Subject = txtSubject.Text;

            ECEClass.LetterNo letterno = new ECEClass.LetterNo();
            letterno._LetterNo = txtLetterNo.Text;

            ECEClass.LetterDateTime letterDateTime = new ECEClass.LetterDateTime();
            //PersianCalendar persianCalendar = new PersianCalendar ();
            ////suppose format of farsi date is like 1392/11/16
            //string[] farsidate=txtLetterDate.Text.Split(new char[]{'/'});
            //DateTime dateTime = persianCalendar.ToDateTime (int.Parse(farsidate[0]),int.Parse(farsidate[1]),int.Parse(farsidate[2]),0,0,0,0);
            //letterDateTime._LetterDateTime = dateTime.ToString();
            letterDateTime._LetterDateTime = txtLetterDate.Text;
            letterDateTime.ShowAs          = drpDateType.SelectedValue;


            ECEClass.Priority priority = new ECEClass.Priority();
            priority.Code = drpLetterPriority.SelectedItem.Value;
            priority.Name = drpLetterPriority.SelectedItem.Text;


            ECEClass.Classification classification = new ECEClass.Classification();
            classification.Code = drpLetterClassification.SelectedItem.Value;
            classification.Name = drpLetterClassification.SelectedItem.Text;


            ECEClass.Keywords letterKeyword = new ECEClass.Keywords();
            letterKeyword.Keyword = txtKeyword.Text;

            /////////////////////////////////////////////////////////////////
            //loop to get all letters
            //here assumed only one letter

            ECEClass.Origin origin = new ECEClass.Origin();
            origin.Description = txtOriginFileDesc.Text;
            origin.ContentType = drpOriginFileType.SelectedItem.Text;
            string pathToSaveOrigin = "E:\\sample\\";

            upldFilePath.SaveAs(pathToSaveOrigin + upldFilePath.FileName);
            origin.encodedBase64String = ece.createECEBase64EncodedText(pathToSaveOrigin + upldFilePath.FileName);
            FileInfo fiO = new FileInfo(pathToSaveOrigin + upldFilePath.FileName);

            origin.Extension = fiO.Extension.Remove(0, 1);//remove " ."
            ECEClass.Origins origins = new ECEClass.Origins();
            origins.addOrigin(origin);

            /////////////////////////////////////////////////////
            ECEClass.Attachment attachment = new ECEClass.Attachment();
            attachment.ContentType = drpAttachmentFileType.SelectedItem.Text;
            attachment.Description = txtAttchFileDesc.Text;
            string pathToSaveAttachment = "E:\\sample\\";

            upldAttachFilePath.SaveAs(pathToSaveAttachment + upldAttachFilePath.FileName);
            attachment.encodedBase64String = ece.createECEBase64EncodedText(pathToSaveAttachment + upldAttachFilePath.FileName);
            FileInfo fiA = new FileInfo(pathToSaveAttachment + upldAttachFilePath.FileName);

            attachment.Extension = fiA.Extension.Remove(0, 1);
            ECEClass.Attachments attachments = new ECEClass.Attachments();
            attachments.addAttachment(attachment);

            ///////////////////////////////////////////

            ECEClass.Receiver receiver = new ECEClass.Receiver();
            receiver.Code         = txtReceiverCode.Text; // "125;234";
            receiver.Department   = txtReceiverDepartment0.Text;
            receiver.Name         = txtReceiverName.Text; //
            receiver.Organization = txtReceiverOrg.Text;
            receiver.Position     = txtReceiverPosition.Text;
            receiver.ReceiveType  = drpReceiverType.SelectedItem.Text;

            ////////////////////////////////////////////////////////////

            otherReceiver              = new ECEClass.OtherReceiver();
            otherReceiver.Code         = txtOtherReceiverCode.Text;
            otherReceiver.Department   = txtOtherReceiverDepartment.Text;
            otherReceiver.Name         = txtOtherReceiverName.Text;
            otherReceiver.Organization = txtOtherReceiverOrg.Text;
            otherReceiver.Position     = txtOtherReceiverPosition.Text;
            otherReceiver.ReceiveType  = drpOtherReceiverType.SelectedItem.Text;
            ECEClass.OtherReceivers otherReceivers = new ECEClass.OtherReceivers();
            otherReceivers.addOtherReceiver(otherReceiver);

            ///////////////////////////////////////////////////////////////////////

            ECEClass.Sender letterSender = new ECEClass.Sender();
            letterSender.Code         = txtSenderCode.Text;
            letterSender.Department   = txtSenderDepartment0.Text;
            letterSender.Name         = txtSenderName.Text;
            letterSender.Organization = txtSenderOrg.Text;
            letterSender.Position     = txtSenderPosition.Text;

            //////////////////////////////////////////////////////////////////////


            string eceXml = ece.exportEceXml();

            ece.exportEceXml("e:\\sample2.xml");
        }
Exemplo n.º 2
0
        protected void btnLoadEceXml_Click(object sender, EventArgs e)
        {
            ECEClass ece = new ECEClass();

            ece.loadECEXml("e:\\sample.xml");

            ECEClass.Subject subject = new ECEClass.Subject();
            txtSubject.Text = subject._Subject;
            /////////////////////////////////////////////////

            ECEClass.LetterNo letterno = new ECEClass.LetterNo();
            txtLetterNo.Text = letterno._LetterNo;

            /////////////////////////////////////////////////////

            ECEClass.LetterDateTime letterDateTime = new ECEClass.LetterDateTime();
            txtLetterDate.Text        = letterDateTime._LetterDateTime;
            drpDateType.SelectedValue = letterDateTime.ShowAs;
            //////////////////////////////////////////////////////

            ECEClass.Priority priority = new ECEClass.Priority();
            drpLetterPriority.SelectedItem.Value = priority.Code;
            /////////////////////////////////////////////////////////

            ECEClass.Classification classification = new ECEClass.Classification();
            drpLetterClassification.SelectedItem.Value = classification.Code;
            ///////////////////////////////////////////////////////////

            ECEClass.Keywords letterKeyword = new ECEClass.Keywords();
            txtKeyword.Text = letterKeyword.Keyword;

            /////////////////////////////////////////////////////////////////

            ECEClass.Origins       origins       = new ECEClass.Origins();
            List <ECEClass.Origin> arrayOfOrigin = origins.getOrigins();

            foreach (var origin in arrayOfOrigin)
            {
                txtOriginFileDesc.Text = origin.Description;
                drpOriginFileType.SelectedItem.Text = origin.ContentType;
                ece.createBinaryFileFromECEText("E:\\sample\\ece\\" + origin.Description + "." + origin.Extension, origin.encodedBase64String);
            }


            /////////////////////////////////////////////////////
            ECEClass.Attachments       attachments       = new ECEClass.Attachments();
            List <ECEClass.Attachment> arrayOfAttachment = attachments.getAttachment();

            foreach (var attachment in arrayOfAttachment)
            {
                txtAttchFileDesc.Text = attachment.Description;
                drpAttachmentFileType.SelectedItem.Text = attachment.ContentType;
                ece.createBinaryFileFromECEText("E:\\sample\\ece\\" + attachment.Description + "." + attachment.Extension, attachment.encodedBase64String);
            }

            ///////////////////////////////////////////

            ECEClass.Receiver receiver = new ECEClass.Receiver();
            txtReceiverCode.Text              = receiver.Code;
            txtReceiverDepartment0.Text       = receiver.Department;
            txtReceiverName.Text              = receiver.Name;   //
            txtReceiverOrg.Text               = receiver.Organization;
            txtReceiverPosition.Text          = receiver.Position;
            drpReceiverType.SelectedItem.Text = receiver.ReceiveType;


            ////////////////////////////////////////////////////////////
            ECEClass.OtherReceivers       otherReceivers       = new ECEClass.OtherReceivers();
            List <ECEClass.OtherReceiver> arrayOfOtherReceiver = otherReceivers.getOtherRecivers();

            foreach (var otherReceiver in arrayOfOtherReceiver)
            {
                txtOtherReceiverCode.Text              = otherReceiver.Code;
                txtOtherReceiverDepartment.Text        = otherReceiver.Department;
                txtOtherReceiverName.Text              = otherReceiver.Name;
                txtOtherReceiverOrg.Text               = otherReceiver.Organization;
                txtOtherReceiverPosition.Text          = otherReceiver.Position;
                drpOtherReceiverType.SelectedItem.Text = otherReceiver.ReceiveType;
            }


            ///////////////////////////////////////////////////////////////////////

            ECEClass.Sender letterSender = new ECEClass.Sender();
            txtSenderCode.Text        = letterSender.Code;
            txtSenderDepartment0.Text = letterSender.Department;
            txtSenderName.Text        = letterSender.Name;
            txtSenderOrg.Text         = letterSender.Organization;
            txtSenderPosition.Text    = letterSender.Position;

            //////////////////////////////////////////////////////////////////////
        }