Exemplo n.º 1
0
        public void UpLoadLabelFile(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string LabelName  = Data["LabelName"].ToString();
            string PrintType  = Data["PrintType"].ToString();
            string ArryLength = Data["ArryLength"].ToString();

            MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow();

            SFCDB.BeginTrain();
            try
            {
                T_R_FILE TRF = new T_R_FILE(SFCDB, DB_TYPE_ENUM.Oracle);

                Row_R_FILE RRF = (Row_R_FILE)TRF.NewRow();
                RRF.ID       = TRF.GetNewID(BU, SFCDB);
                RRF.NAME     = Data["Name"].ToString();
                RRF.FILENAME = Data["FileName"].ToString();
                RRF.MD5      = Data["MD5"].ToString();
                RRF.USETYPE  = Data["UseType"].ToString();
                RRF.STATE    = "1";
                RRF.VALID    = 1;
                //不使用CLOB字段
                //RRF.CLOB_FILE = ":CLOB_FILE";// Data["Bas64File"].ToString();
                RRF.BLOB_FILE            = ":BLOB_FILE";
                RRF.EDIT_EMP             = LoginUser.EMP_NO;
                RRF.EDIT_TIME            = DateTime.Now;
                SFCDB.ThrowSqlExeception = true;
                //將同類文件改為歷史版本
                TRF.SetFileDisableByName(RRF.NAME, RRF.USETYPE, SFCDB);

                string strSql = RRF.GetInsertString(this.DBTYPE);
                strSql = strSql.Replace("':CLOB_FILE'", ":CLOB_FILE");
                strSql = strSql.Replace("':BLOB_FILE'", ":BLOB_FILE");
                System.Data.OleDb.OleDbParameter p = new System.Data.OleDb.OleDbParameter(":BLOB_FILE", System.Data.OleDb.OleDbType.Binary);
                string B64 = Data["Bas64File"].ToString();

                string b64  = B64.Remove(0, B64.LastIndexOf(',') + 1);
                byte[] data = Convert.FromBase64String(b64);
                p.Value = data;
                //new System.Data.OleDb.OleDbParameter(":CLOB_FILE", Data["Bas64File"].ToString()),
                SFCDB.ExecSqlNoReturn(strSql, new System.Data.OleDb.OleDbParameter[]
                                      { p });
                T_R_Label   TRL = new T_R_Label(SFCDB, DB_TYPE_ENUM.Oracle);
                Row_R_Label RRL = TRL.GetLabelConfigByLabelName(LabelName, SFCDB);
                if (RRL == null)
                {
                    RRL             = (Row_R_Label)TRL.NewRow();
                    RRL.ID          = TRL.GetNewID(BU, SFCDB);
                    RRL.LABELNAME   = LabelName;
                    RRL.R_FILE_NAME = RRF.FILENAME;
                    RRL.PRINTTYPE   = PrintType;
                    RRL.ARRYLENGTH  = double.Parse(ArryLength);
                    strSql          = RRL.GetInsertString(DB_TYPE_ENUM.Oracle);
                }
                else
                {
                    RRL.LABELNAME   = LabelName;
                    RRL.R_FILE_NAME = RRF.FILENAME;
                    RRL.PRINTTYPE   = PrintType;
                    RRL.ARRYLENGTH  = double.Parse(ArryLength);
                    strSql          = RRL.GetUpdateString(DB_TYPE_ENUM.Oracle);
                }
                string strRes = SFCDB.ExecSQL(strSql);

                //SFCDB.ExecSQL(RRF.GetInsertString(this.DBTYPE));
                SFCDB.CommitTrain();
                StationReturn.Status = StationReturnStatusValue.Pass;
            }
            catch (Exception ee)
            {
                SFCDB.RollbackTrain();
                //this.DBPools["SFCDB"].Return(SFCDB);
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000037";
                StationReturn.MessagePara.Add(ee.Message);
            }
            SFCDB.ThrowSqlExeception = false;
            this.DBPools["SFCDB"].Return(SFCDB);
            this.DBPools["SFCDB"].Return(SFCDB);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 提供工站打印本站
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void PrintStationLabelAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec SFCDB = Station.SFCDB;
            string  Run   = "";

            try
            {
                Run = (Station.StationSession.Find(T => T.MESDataType == Paras[0].SESSION_TYPE && T.SessionKey == Paras[0].SESSION_KEY).Value).ToString();
                if (Run.ToUpper() == "FALSE")
                {
                    return;
                }
            }
            catch
            {
            }


            SKU SKU = (SKU)(Station.StationSession.Find(T => T.MESDataType == Paras[1].SESSION_TYPE && T.SessionKey == Paras[1].SESSION_KEY).Value);

            List <string> ProcessLabType = new List <string>();

            if (Paras.Count > 1)
            {
                for (int i = 2; i < Paras.Count; i++)
                {
                    ProcessLabType.Add(Paras[i].VALUE.ToString());
                }
            }

            T_C_SKU_Label TCSL = new T_C_SKU_Label(SFCDB, DB_TYPE_ENUM.Oracle);
            //獲取label配置
            List <Row_C_SKU_Label> labs = TCSL.GetLabelConfigBySkuStation(SKU.SkuBase.SKUNO, Station.StationName, SFCDB);

            List <Label.LabelBase> PrintLabs = new List <Label.LabelBase>();
            T_R_Label      TRL  = new T_R_Label(SFCDB, DB_TYPE_ENUM.Oracle);
            T_C_Label_Type TCLT = new T_C_Label_Type(SFCDB, DB_TYPE_ENUM.Oracle);

            for (int i = 0; i < labs.Count; i++)
            {
                if (ProcessLabType.Count > 0)
                {
                    if (!ProcessLabType.Contains(labs[i].LABELTYPE))
                    {
                        continue;
                    }
                }
                Row_R_Label      RL = TRL.GetLabelConfigByLabelName(labs[i].LABELNAME, SFCDB);
                Row_C_Label_Type RC = TCLT.GetConfigByName(labs[i].LABELTYPE, SFCDB);

                string      path      = System.AppDomain.CurrentDomain.BaseDirectory;
                Assembly    assembly  = Assembly.LoadFile(path + RC.DLL);
                System.Type APIType   = assembly.GetType(RC.CLASS);
                object      API_CLASS = assembly.CreateInstance(RC.CLASS);

                LabelBase Lab = (LabelBase)API_CLASS;
                //給label的輸入變量加載值
                for (int j = 0; j < Lab.Inputs.Count; j++)
                {
                    if (Lab.Inputs[j].Name.ToUpper() == "STATION")
                    {
                        Lab.Inputs[j].Value = Station.StationName;
                    }

                    MESStationSession S = Station.StationSession.Find(T => T.MESDataType == Lab.Inputs[j].StationSessionType && T.SessionKey == Lab.Inputs[j].StationSessionKey);
                    if (S != null)
                    {
                        Lab.Inputs[i].Value = S.Value;
                    }
                }
                Lab.LabelName = RL.LABELNAME;
                Lab.FileName  = RL.R_FILE_NAME;
                Lab.PrintQTY  = (int)labs[i].QTY;
                Lab.MakeLabel(SFCDB);
                List <LabelBase> pages = MakePrintPage(Lab, RL);

                for (int k = 0; k < pages.Count; k++)
                {
                    pages[k].ALLPAGE = pages.Count;
                    Station.LabelPrint.Add(pages[k]);
                }
            }
        }