コード例 #1
0
ファイル: COPRAR.aspx.cs プロジェクト: souvik0682/ems-nvocc
        public string COPRAR_TXT()
        {
            string rpd;
            int    LocationId = Convert.ToInt32(ddlLoc.SelectedValue);
            int    LineID     = Convert.ToInt32(ddlLine.SelectedValue);
            int    VesselID   = Convert.ToInt32(ddlVessel.SelectedValue);
            int    VoyageID   = Convert.ToInt32(ddlVoyage.SelectedValue);
            //DateTime dt = DateTime.Now;

            string VCN;
            string CallSign;
            string IMONo;
            string VoyageNo;
            string Port;
            string Country;
            string Containers;

            string uniqueFileName = Guid.NewGuid().ToString();


            //File.Create(Server.MapPath(@"~/Import/COPRARFILE/") + uniqueFileName + "_IMP_EDI.IGM");
            string FileName = Server.MapPath(@"~/Import/EDIFile/") + uniqueFileName + "_COPRAR.TXT";
            string PCSLogin = Convert.ToString(new DBInteraction().GetPCSLogin(LocationId).Tables[0].Rows[0]["PCSLoginID"]);
            string CurDate  = DateTime.Now.ToString("ddMMyyyy") + "00000001";

            string pod = ((TextBox)AutoCompletepPort1.FindControl("txtPort")).Text;

            pod = pod.Contains(',') ? pod.Split(',')[1] : "";

            if (pod == "INCCU1")
            {
                rpd = "kopt001";
            }
            else
            {
                rpd = "haldia001";
            }

            int PortCode = dbinteract.GetId("Port", pod);

            StreamWriter writer = new StreamWriter(FileName);

            //  ("myfile.txt")

            writer.WriteLine(("UNH" + ('' + ("COPRAR" + (''
                                                          + ("Advance Container List" + ('' + (CurDate + (''
                                                                                                           + (CurDate + ('' + ("9" + ('' + (PCSLogin))))))))))))));

            writer.WriteLine(("RPD" + ('' + (rpd))));

            //System.Data.DataTable dt = EquipmentBLL.GetOMHinformation(LocationId, LineID, VesselID, VoyageID, PortCode);

            System.Data.DataSet ds = EquipmentBLL.GetOMHinformation(LocationId, LineID, VesselID, VoyageID, PortCode);

            //if (ds.Tables[0].Rows.Count > 0)
            //{
            VCN        = ds.Tables[0].Rows[0]["VCN"].ToString();
            CallSign   = ds.Tables[0].Rows[0]["CallSign"].ToString();
            IMONo      = ds.Tables[0].Rows[0]["IMONumber"].ToString();
            VoyageNo   = ds.Tables[0].Rows[0]["VoyageNo"].ToString();
            Port       = ds.Tables[0].Rows[0]["PortCode"].ToString();
            Country    = ds.Tables[0].Rows[0]["CountryAbbr"].ToString();
            Containers = ds.Tables[0].Rows[0]["TotContainers"].ToString();
            //}


            writer.WriteLine(("OMH" + (''
                                       + (VCN + (''
                                                 + (CallSign + (''
                                                                + (IMONo + (''
                                                                            + (VoyageNo + (''
                                                                                           + (Port + (''
                                                                                                      + (Country + (''
                                                                                                                    + ("BLA" + ('' + ('' + ('' + ('' + (''
                                                                                                                                                            + (Containers))))))))))))))))))))));

            DataSet DsContain = EquipmentBLL.GetCOPRARContainerInfo(VesselID, VoyageID, PortCode);
            //.GetCOPRARContainerInfo(Convert.ToInt32(ddlVessel.SelectedValue), Convert.ToInt32(ddlVoyage.SelectedValue));
            //             TextShippingCode.Text = Ds.Tables(0).Rows(0).Item("ShippingLineCode")
            DataTable DtContain = DsContain.Tables[0];
            int       Srl1      = 0;


            foreach (DataRow Dr in DtContain.Rows)
            {
                Srl1 = (Srl1 + 1);
                writer.WriteLine(("OMD" + (''
                                           + ("3" + (''
                                                     + (Dr["ContainerNo"].ToString() + (''
                                                                                        + (Dr["cstatus"].ToString() + (''
                                                                                                                       + (Dr["ISOCode"].ToString() + (''
                                                                                                                                                      + (Dr["TareWeight"].ToString() + (''
                                                                                                                                                                                        + (Dr["CargoWtTon"].ToString() + ('' + (''
                                                                                                                                                                                                                                 + (Dr["SealNo"].ToString() + (''
                                                                                                                                                                                                                                                               + (Dr["loadport"].ToString().Substring(0, 5) + "1" + (''
                                                                                                                                                                                                                                                                                                                     + (Dr["loadport"].ToString().Substring(0, 5) + "1" + ('' + (''
                                                                                                                                                                                                                                                                                                                                                                                  + (Dr["Commodity"].ToString() + (''
                                                                                                                                                                                                                                                                                                                                                                                                                   + (Dr["ImpLineBLNo"].ToString() + ('' + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                             + (Dr["ItemLineNo"].ToString() + ('' + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      + ("12" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 + ("BLA" + ('' + ('' + ('' + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  + (Dr["discport"].ToString() + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  + (Dr["finalDestination"].ToString().Substring(0, 5) + "1" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                + (Dr["TMODE"].ToString() + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             + (Dr["ICD"].ToString() + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        + ("1" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  + ("" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           + ("" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    + ("" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             + ("" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      + ("" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               + ("" + (''
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        + ("" + (''

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
            }
            string dt = DateTime.Now.ToString("ddMMyyyyhhmmss");

            writer.WriteLine(("UNT" + (''
                                       + (dt))));
            writer.Close();
            writer.Dispose();

            return(FileName);
        }