Esempio n. 1
0
        public int GetShippingFilesST()
        {
            Jinsdb.GetImportShippingST();

            var rs = Jinsdb.GetUnShippingFilesST();

            if (rs.Tables[0].Rows.Count <= 0)
            {
                return(0);
            }
            foreach (DataRow item in rs.Tables[0].Rows)
            {
                OrdMain model = this.PrepareShippingModel(item);
                model.SubST = new List <OrdST>();
                var rsdetail = Jinsdb.GetOrdShipDetail(model.ID);
                foreach (DataRow item2 in rsdetail.Tables[0].Rows)
                {
                    var subid   = item2["SubID"].ToString().GetIntFromStr();
                    var opc     = item2["OPC"].ToString();
                    var qtyship = item2["QtyShip"].ToString().GetIntFromStr();
                    model.SubST.Add(new OrdST()
                    {
                        ID = model.ID, SubID = subid, OPC = opc, Qty = qtyship
                    });
                }
                var xmldoc = Jinsxml.CreateShippingXMLFile(model);
                xmldoc.Save(localFolder_shipping + @"\" + model.OrdID + @".xml");
                Jinsdb.UpdateShippingFlatST(model);
            }
            return(rs.Tables[0].Rows.Count);
        }
Esempio n. 2
0
 private void t1_Elapsed(object source, ElapsedEventArgs e)
 {
     try
     {
         RunGetXMLFiles();
     }
     catch (Exception ex)
     {
         Default.html += DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + "[Getting]" + ex.Message + "<br />";
         Jinsdb.AddLog(ex.Message);
     }
 }
Esempio n. 3
0
 void t4_Elapsed(object sender, ElapsedEventArgs e)
 {
     try
     {
         RunConvertXMLFiles();
     }
     catch (Exception ex)
     {
         Default.html += DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + "[Convert]" + ex.Message + "<br />";
         Jinsdb.AddLog(ex.Message);
     }
 }
Esempio n. 4
0
 void t3_Elapsed(object sender, ElapsedEventArgs e)
 {
     try
     {
         RunGetShippingXMLFiles();
         RunUploadShippingXMLFiles();
     }
     catch (Exception ex)
     {
         Default.html += DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + "[Shipping]" + ex.Message + "<br />";
         Jinsdb.AddLog(ex.Message);
     }
 }
Esempio n. 5
0
        public int GetShippingFilesRX()
        {
            var rs = Jinsdb.GetUnShippingFilesRX();

            if (rs.Tables[0].Rows.Count <= 0)
            {
                return(0);
            }
            foreach (DataRow item in rs.Tables[0].Rows)
            {
                OrdMain model  = this.PrepareShippingModel(item);
                var     xmldoc = Jinsxml.CreateShippingXMLFile(model);
                xmldoc.Save(localFolder_shipping + @"\" + model.OrdID + @".xml");
                Jinsdb.UpdateShippingFlatRX(model.OrdID);
            }
            return(rs.Tables[0].Rows.Count);
        }
Esempio n. 6
0
        public int GetConfirmFiles()
        {
            var rs = Jinsdb.GetUnConfirmFiles();

            if (rs.Tables[0].Rows.Count <= 0)
            {
                return(0);
            }
            foreach (DataRow item in rs.Tables[0].Rows)
            {
                var _ID       = item["ID"].ToString();
                var _OrdType  = item["OrdType"].ToString();
                var _OrdHdID  = item["OrdHdID"].ToString();
                var _OrdID    = item["OrdID"].ToString();
                var _F_Reject = item["F_Reject"].ToString().GetBoolStr();
                JinsPub.OrdID = _OrdID;
                OrdMain model = new OrdMain()
                {
                    ID       = _ID,
                    OrdID    = _OrdID,
                    OrdHdID  = _OrdHdID,
                    OrdType  = _OrdType,
                    F_Reject = _F_Reject
                };
                if (model.OrdType.ToLower() != "rx")
                {
                    model.SubST = new List <OrdST>();
                    var rsdetail = Jinsdb.GetOrdDetail(model.ID);
                    foreach (DataRow item2 in rsdetail.Tables[0].Rows)
                    {
                        var subid = item2["SubID"].ToString().GetIntFromStr();
                        var opc   = item2["OPC"].ToString();
                        var qty   = item2["Qty"].ToString().GetIntFromStr();
                        model.SubST.Add(new OrdST()
                        {
                            ID = model.ID, SubID = subid, OPC = opc, Qty = qty
                        });
                    }
                }
                var xmldoc = Jinsxml.CreateConfirmXMLFile(model);
                xmldoc.Save(localFolder_confirm + @"\" + model.OrdID + @".xml");
                Jinsdb.UpdateConfirmFlat(model.OrdID);
            }
            return(rs.Tables[0].Rows.Count);
        }
Esempio n. 7
0
        public static OrdMain ConvertXMLtoOrdModel(string xmlPath)
        {
            OrdMain model = new OrdMain();
            var     file  = xmlPath.Substring(xmlPath.LastIndexOf("\\") + 1);

            model.OrdID = file.Substring(0, file.LastIndexOf("."));
            model.ID    = "";
            try
            {
                using (XmlReader _XReader = XmlReader.Create(xmlPath))
                {
                    XElement _XElement = XElement.Load(_XReader);
                    model.OrdHdID  = _XElement.Element("purchase_order_header_id").Value;
                    model.OrdType  = _XElement.Element("po_type_id").Value;
                    model.Address1 = _XElement.Element("address").Value;
                    model.Postal   = _XElement.Element("postal").Value;
                    model.Tel      = _XElement.Element("telephone").Value;
                    model.Memo     = _XElement.Element("memorandum").Value;
                    var t = _XElement.Element("created").Value;
                    try { model.Created = Convert.ToDateTime(t); }
                    catch { model.Created = DateTime.Now; }
                    model.SalesOfficeCode = _XElement.Element("salesOfficeCode").Value;
                    model.SalesOfficeName = _XElement.Element("salesOfficeName").Value;
                    try { model.Procurement_Type = _XElement.Element("procurement_type").Value; }
                    catch { model.Procurement_Type = ""; }
                    //
                    switch (model.OrdType)
                    {
                    case "rx":
                        model.SubRX = new OrdRX();
                        var modelrx = model.SubRX;
                        var _detail = _XElement.Elements("detail").FirstOrDefault();
                        //
                        modelrx.SpecialRight1 = _detail.Element("specialright1").Value;
                        modelrx.SpecialRight2 = _detail.Element("specialright2").Value;
                        modelrx.SpecialRight3 = _detail.Element("specialright3").Value;
                        modelrx.SpecialRight4 = _detail.Element("specialright4").Value;
                        modelrx.SpecialLeft1  = _detail.Element("specialleft1").Value;
                        modelrx.SpecialLeft2  = _detail.Element("specialleft2").Value;
                        modelrx.SpecialLeft3  = _detail.Element("specialleft3").Value;
                        modelrx.SpecialLeft4  = _detail.Element("specialleft4").Value;
                        //
                        modelrx.Lens_Type = _detail.Element("lens_type").Value;
                        modelrx.Tint_Type = _detail.Element("tint_type").Value;
                        modelrx.Tint      = _detail.Element("tint").Value;
                        modelrx.Polarized = _detail.Element("polarized").Value;
                        modelrx.Mirrored  = _detail.Element("mirrored").Value;
                        //
                        modelrx.Oculus_Dexter_Sphere     = _detail.Element("oculus_dexter_sphere").Value.GetDecimalStr();
                        modelrx.Oculus_Sinister_Sphere   = _detail.Element("oculus_sinister_sphere").Value.GetDecimalStr();
                        modelrx.Oculus_Dexter_Cylinder   = _detail.Element("oculus_dexter_cylinder").Value.GetDecimalStr();
                        modelrx.Oculus_Sinister_Cylinder = _detail.Element("oculus_sinister_cylinder").Value.GetDecimalStr();
                        modelrx.Oculus_Dexter_Axis       = _detail.Element("oculus_dexter_axis").Value.GetDecimalStr();
                        modelrx.Oculus_Sinister_Axis     = _detail.Element("oculus_sinister_axis").Value.GetDecimalStr();
                        modelrx.Oculus_Dexter_Add        = _detail.Element("oculus_dexter_add").Value.GetDecimalStr();
                        modelrx.Oculus_Sinister_Add      = _detail.Element("oculus_sinister_add").Value.GetDecimalStr();
                        //
                        modelrx.Oculus_Dexter_Diameter   = _detail.Element("oculus_dexter_diameter").Value.GetIntFromStr();
                        modelrx.Oculus_Sinister_Diameter = _detail.Element("oculus_sinister_diameter").Value.GetIntFromStr();
                        //
                        modelrx.Oculus_Dexter_Quantity   = _detail.Element("oculus_dexter_quantity").Value.GetIntFromStr();
                        modelrx.Oculus_Sinister_Quantity = _detail.Element("oculus_sinister_quantity").Value.GetIntFromStr();

                        //new column
                        try { modelrx.Frame_Code = _detail.Element("frame_code").Value; }
                        catch { modelrx.Frame_Code = ""; }
                        try { modelrx.Polishing = _detail.Element("polishing").Value; }
                        catch { modelrx.Polishing = ""; }
                        try { modelrx.Oculus_Eye_Point = _detail.Element("oculus_eye_point").Value; }
                        catch { modelrx.Oculus_Eye_Point = ""; }
                        try { modelrx.Oculus_Dexter_Pupillary_Distance = _detail.Element("oculus_dexter_pupillary_distance").Value; }
                        catch { modelrx.Oculus_Dexter_Pupillary_Distance = ""; }
                        try { modelrx.Oculus_Sinister_Pupillary_Distance = _detail.Element("oculus_sinister_pupillary_distance").Value; }
                        catch { modelrx.Oculus_Sinister_Pupillary_Distance = ""; }

                        break;

                    default:

                        model.SubST = new List <OrdST>();
                        var   modelst = model.SubST;
                        OrdST ordst   = null;
                        var   details = _XElement.Elements("detail");
                        foreach (var item in details)
                        {
                            ordst = new OrdST()
                            {
                                SubID = item.Attribute("id").Value.GetIntFromStr(),
                                OPC   = item.Element("opc").Value,
                                Qty   = item.Element("qty").Value.GetIntFromStr(),
                            };
                            modelst.Add(ordst);
                        }
                        break;
                    }
                }
                //ordz
                InitOrdZ(model);
                //ordzmain
                InitOrdZMain(model);

                return(model);
            }
            catch (Exception ex)
            {
                Jinsdb.AddLog(ex.Message);
                throw;
            }
        }
Esempio n. 8
0
        public int ConvertXMLFile()
        {
            DirectoryInfo folder = new DirectoryInfo(localFolder_order);

            FileInfo[] fileList = null;
            string     fileName = "";
            var        count    = 0;

            fileList = folder.GetFiles("*.xml");
            if (fileList.Count() <= 0)
            {
                return(0);
            }

            foreach (FileInfo fi in fileList)
            {
                fileName      = fi.Name;
                JinsPub.OrdID = fileName.Substring(0, fileName.LastIndexOf("."));
                var     fullPath = localFolder_order + @"\" + fileName;
                OrdMain model    = Jinsxml.ConvertXMLtoOrdModel(fullPath);
                if (Jinsdb.CheckOrdReject(model.OrdID))
                {
                    fi.Delete();
                    continue;
                }
                Jinsdb.DeleteOrdErr(model.OrdID);
                try
                {
                    Jinsdb.AddOrd(model);
                    fi.Delete();
                }
                catch (Exception ex)
                {
                    OrdMain modelErr = new OrdMain()
                    {
                        Address1         = "",
                        Created          = DateTime.Now,
                        ECode            = "",
                        OrdHdID          = model.OrdHdID,
                        Postal           = "",
                        SalesOfficeCode  = "",
                        SalesOfficeName  = "",
                        OrdType          = model.OrdType,
                        OrdID            = model.OrdID,
                        Tel              = "",
                        Memo             = "Err",
                        Procurement_Type = "",
                    };
                    modelErr.SubZ = new OrdZ()
                    {
                        BillCode    = model.OrdID,
                        Remark      = ex.Message,
                        BillDate    = model.Created,
                        BillType    = "",
                        ConsignDate = model.Created,
                        CusCode     = "",
                        ML          = "",
                        MR          = "",
                        Notes       = "",
                        OBillCode   = "",
                        QtyL        = 0,
                        QtyR        = 0,
                        SumQty      = 0
                    };
                    modelErr.SubConet = new OrdConet()
                    {
                        BCode1        = model.OrdID,
                        BCode2        = "*轉換錯誤請參考備註信息*",
                        F_Confirm     = false,
                        F_Read        = false,
                        F_Reject      = false,
                        F_Shipping    = 0,
                        F_Err_Convert = true
                    };
                    switch (ex.Message)
                    {
                    case "RX001":
                        modelErr.SubConet.BCode2   = "已拒絕[自動標記]";
                        modelErr.SubConet.F_Read   = true;
                        modelErr.SubConet.F_Reject = true;
                        modelErr.SubZ.Remark       = "鏡片資料缺失";
                        break;

                    default:
                        break;
                    }
                    //
                    Jinsdb.AddOrdErr(modelErr);
                    //
                    switch (ex.Message)
                    {
                    case "RX001":
                        fi.Delete();
                        break;

                    default:
                        break;
                    }
                }
                count++;
            }

            return(count);
        }