Пример #1
0
        public static IwrService GetService()
        {
            try
            {
                wrService ws = new wrService();
                foreach (var item in ws.Endpoint.Contract.Operations)
                {
                    DataContractSerializerOperationBehavior dc = item.Behaviors.Find <DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
                    if (dc != null)
                    {
                        dc.MaxItemsInObjectGraph = int.MaxValue;
                    }
                }

                return(ws.GetChannel());
                //return new wrService().GetChannel();
            }
            catch (System.Exception ex)
            {
                if (log == null)
                {
                    log = LogService.Getlog(typeof(wrService));
                }

                log.Error(ex);

                throw;
            }
        }
Пример #2
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_UnhandledException);

                LogService.InitializeService(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Start.exe.config"));
                log = LogService.Getlog(typeof(Program));
                log.Fatal("======>=Start up=>=====");

                #region 检查是否有服务器地址
                string url = Config.GetXmlValue(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Start.exe.config"), "RemoteURL");
                if (string.IsNullOrEmpty(url))
                {
                    frm_Set frmSet = new frm_Set();
                    frmSet.ShowDialog();
                }

                url = Config.GetXmlValue(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Start.exe.config"), "RemoteURL");
                if (string.IsNullOrEmpty(url))
                {
                    MessageBox.Show("没有指定服务器地址,不能启动程序!", "信息提示", MessageBoxButtons.OK);
                    return;
                }
                #endregion

                #region 检查是否有更新文件
                using (frm_update set = new frm_update())
                {
                    if (set.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                }
                #endregion

                //System.Diagnostics.Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WR.Pos.exe"));
                Form frm = System.Reflection.Assembly.LoadFrom(Application.StartupPath + "\\WR.Client.UI.dll").CreateInstance("WR.Client.UI.frm_main") as Form;
                if (frm != null)
                {
                    Application.Run(frm);
                    log.Fatal("=========<=Shut down=<============");
                }
                else
                {
                    log.Fatal("not find Assembly");
                }

                Application.DoEvents();
                Application.Exit();
            }
            catch (Exception ex)
            {
                log.Error(ex);
                MessageBox.Show("操作中出现错误!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void fileWatcher_Changed(object sender, FileSystemEventArgs e)
        {
            if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                LoggerEx logEx = new LoggerEx(log);
                try
                {
                    fileWatcher.EnableRaisingEvents = false;
                    try
                    {
                        if (e.ChangeType == WatcherChangeTypes.Changed)
                        {
                            uint resultErr = 0;

                            byte[] bteLic;
                            if (File.Exists(strPathLic))
                            {
                                Thread.Sleep(1000);
                                FileStream files = File.Open(strPathLic, FileMode.Open, FileAccess.Read, FileShare.Read);
                                if (files.Length != 0)
                                {
                                    byte[] btemp = new byte[files.Length];
                                    files.Read(btemp, 0, btemp.Length);
                                    bteLic = btemp;
                                }
                                else
                                {
                                    bteLic = new byte[0];
                                }
                                files.Close();
                            }
                            else
                            {
                                byte[] b = new byte[0];
                                bteLic = b;
                            }
                            CLicenseManagedAdapter licMan = new CLicenseManagedAdapter();
                            SmcErr smcErr = Convert2ErrNo(licMan.ActivateLicenseKey(bteLic, ref resultErr));
                        }
                        GetControlLicItem(null);
                    }
                    catch (System.Exception ex)
                    {
                        logEx.Error("fileWatcher_Changed Exception:{0}", ex.ToString());
                    }
                    finally
                    {
                        fileWatcher.EnableRaisingEvents = true;
                    }
                }
                finally
                {
                    this.licenseFileOperateLock.ExitWriteLock();
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 写文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="content"></param>
        public void WriteFile(string path, string content)
        {
            LoggerEx logEx = new LoggerEx(log);

            try
            {
                FileStream   fs = new FileStream(path, FileMode.Create, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs, Encoding.Default);
                sw.Write(content);
                sw.Close();
                fs.Close();
            }
            catch (System.Exception ex)
            {
                logEx.Error("FileOperation.WriteFile failed. message:{0}", ex.ToString());
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void fileWatcher_Deleted(object sender, FileSystemEventArgs e)
        {
            if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                LoggerEx logEx = new LoggerEx(log);
                try
                {
                    fileWatcher.EnableRaisingEvents = false;
                    if (e.ChangeType == WatcherChangeTypes.Deleted)
                    {
                        uint   resultErr = 0;
                        byte[] bteLic;
                        if (File.Exists(strPathLic))
                        {
                            bteLic = File.ReadAllBytes(strPathLic);
                        }
                        else
                        {
                            byte[] b = new byte[0];
                            bteLic = b;
                            int licCountNew = 0;
                            if (licCount != licCountNew)
                            {
                                SessionManage.Instance().RemoveAllSession();
                                logEx.Trace("License have changed! the New Count is:{0}, the Old Count:{1} ", licCountNew.ToString(), licCount.ToString());
                                licCount = licCountNew;
                            }
                        }
                        CLicenseManagedAdapter licMan = new CLicenseManagedAdapter();
                        SmcErr smcErr = Convert2ErrNo(licMan.ActivateLicenseKey(bteLic, ref resultErr));
                    }
                    fileWatcher.EnableRaisingEvents = true;
                }

                catch (Exception ex)
                {
                    logEx.Error("fileWatcher_Deleted Exception:{0}", ex.ToString());
                }
                finally
                {
                    this.licenseFileOperateLock.ExitWriteLock();
                }
            }
        }
Пример #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void fileWatcher_Created(object sender, FileSystemEventArgs e)
 {
     if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
     {
         LoggerEx logEx = new LoggerEx(log);
         try
         {
             fileWatcher.EnableRaisingEvents = false;
             if (e.ChangeType == WatcherChangeTypes.Created)
             {
                 uint   resultErr = 0;
                 byte[] bteLic;
                 if (File.Exists(strPathLic))
                 {
                     Thread.Sleep(1000);
                     bteLic = File.ReadAllBytes(strPathLic);
                 }
                 else
                 {
                     byte[] b = new byte[0];
                     bteLic = b;
                 }
                 CLicenseManagedAdapter licMan = new CLicenseManagedAdapter();
                 SmcErr smcErr = Convert2ErrNo(licMan.ActivateLicenseKey(bteLic, ref resultErr));
             }
             fileWatcher.EnableRaisingEvents = true;
         }
         catch (Exception ex)
         {
             logEx.Error("fileWatcher_Created Exception:{0}", ex.ToString());
         }
         finally
         {
             this.licenseFileOperateLock.ExitWriteLock();
         }
     }
 }
Пример #7
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     log.Error(e.Exception);
     MessageBox.Show("操作中出现错误!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Пример #8
0
        public bool Export(string path, string device, string lot, string wafer, string notchlocation,
                           WMDIELAYOUT dielayout, List <WmdielayoutlistEntitiy> dielist, List <WmdefectlistEntity> defectlist)
        {
            var sinfList = dielist.OrderBy(s => s.DIEADDRESSX).OrderByDescending(s => s.DIEADDRESSY).ToList();

            var sinfString = new StringBuilder();

            var rowIndex = 0;

            try
            {
                if (DataCache.SinfType == "000")
                {
                    //特殊坐标点
                    string[] AnchorDie = dielayout.ANCHORDIE.Substring(0, dielayout.ANCHORDIE.IndexOf("|")).Split(new char[] { ',' });
                    string[] pitch     = dielayout.PITCH.Split(new char[] { ',' });

                    double xd = double.Parse(pitch[0]);
                    double yd = double.Parse(pitch[1]);

                    double xxd = xd == 0 ? 0 : xd / 1000;
                    double yyd = yd == 0 ? 0 : yd / 1000;

                    sinfString.AppendLine(string.Format("DEVICE:{0}", device));
                    sinfString.AppendLine(string.Format("LOT:{0}", lot));
                    sinfString.AppendLine(string.Format("WAFER:{0}", wafer));
                    sinfString.AppendLine(string.Format("FNLOC:{0}", notchlocation));
                    sinfString.AppendLine(string.Format("ROWCT:{0}", dielayout.ROWS_));
                    sinfString.AppendLine(string.Format("COLCT:{0}", dielayout.COLUMNS_));
                    sinfString.AppendLine(string.Format("BCEQU:{0}", "000"));
                    sinfString.AppendLine(string.Format("REFPX:{0}", AnchorDie[0]));
                    sinfString.AppendLine(string.Format("REFPY:{0}", AnchorDie[1]));
                    sinfString.AppendLine(string.Format("DUTMS:{0}", "MM"));
                    sinfString.AppendLine(string.Format("XDIES:{0:N6}", xxd));
                    sinfString.AppendLine(string.Format("YDIES:{0:N6}", yyd));

                    for (int i = 0; i < sinfList.Count; i++)
                    {
                        if (sinfList[i].DIEADDRESSY != rowIndex)
                        {
                            rowIndex = sinfList[i].DIEADDRESSY;
                            sinfString.AppendFormat("RowData:");
                        }

                        var j = sinfList[i].DIEADDRESSX;

                        string address = string.Format("{0},{1}", j, sinfList[i].DIEADDRESSY);
                        var    defect  = defectlist.FirstOrDefault(p => p.DieAddress == address);

                        if (defect != null)
                        {
                            var cclassid = defectlist.Where(p => p.DieAddress == address).Max(s => s.Cclassid);

                            if (DataCache.BinCodeType == "10")
                            {
                                sinfString.AppendFormat("{0}", cclassid.Value.ToString("D3"));
                            }
                            else
                            {
                                sinfString.AppendFormat("{0}", cclassid.Value.ToString("X").ToUpper().PadLeft(3, '0'));
                            }
                        }
                        else
                        {
                            if (sinfList[i].DISPOSITION != "NotExist")
                            {
                                if (sinfList[i].DISPOSITION.Trim() == "NotProcess")
                                {
                                    sinfString.AppendFormat("@@@");
                                }
                                else
                                {
                                    sinfString.AppendFormat("000");
                                }
                            }
                            else
                            {
                                sinfString.AppendFormat("___");
                            }
                        }

                        if ((sinfList[i].DIEADDRESSX + 1) != dielayout.COLUMNS_)
                        {
                            sinfString.AppendFormat(" ");
                        }
                        else
                        {
                            sinfString.AppendLine();
                        }
                    }
                }
                else
                {
                    //特殊坐标点
                    string[] AnchorDie = dielayout.ANCHORDIE.Substring(0, dielayout.ANCHORDIE.IndexOf("|")).Split(new char[] { ',' });
                    string[] pitch     = dielayout.PITCH.Split(new char[] { ',' });

                    double xd = double.Parse(pitch[0]);
                    double yd = double.Parse(pitch[1]);

                    double xxd = xd == 0 ? 0 : xd / 1000;
                    double yyd = yd == 0 ? 0 : yd / 1000;

                    sinfString.AppendLine(string.Format("DEVICE:{0}", device));
                    sinfString.AppendLine(string.Format("LOT:{0}", lot));
                    sinfString.AppendLine(string.Format("WAFER:{0}", wafer));
                    sinfString.AppendLine(string.Format("FNLOC:{0}", notchlocation));
                    sinfString.AppendLine(string.Format("ROWCT:{0}", dielayout.ROWS_));
                    sinfString.AppendLine(string.Format("COLCT:{0}", dielayout.COLUMNS_));
                    sinfString.AppendLine(string.Format("BCEQU:{0}", "00"));
                    sinfString.AppendLine(string.Format("REFPX:{0}", AnchorDie[0]));
                    sinfString.AppendLine(string.Format("REFPY:{0}", AnchorDie[1]));
                    sinfString.AppendLine(string.Format("DUTMS:{0}", "MM"));
                    sinfString.AppendLine(string.Format("XDIES:{0:N6}", xxd));
                    sinfString.AppendLine(string.Format("YDIES:{0:N6}", yyd));

                    for (int i = 0; i < sinfList.Count; i++)
                    {
                        if (sinfList[i].DIEADDRESSY != rowIndex)
                        {
                            rowIndex = sinfList[i].DIEADDRESSY;
                            sinfString.AppendFormat("RowData:");
                        }

                        var j = sinfList[i].DIEADDRESSX;

                        string address = string.Format("{0},{1}", j, sinfList[i].DIEADDRESSY);
                        var    defect  = defectlist.FirstOrDefault(p => p.DieAddress == address);

                        if (defect != null)
                        {
                            var cclassid = defectlist.Where(p => p.DieAddress == address).Max(s => s.Cclassid);

                            if (DataCache.BinCodeType == "10")
                            {
                                sinfString.AppendFormat("{0}", cclassid.Value.ToString("D2"));
                            }
                            else
                            {
                                sinfString.AppendFormat("{0}", cclassid.Value.ToString("X").ToUpper().PadLeft(2, '0'));
                            }
                        }
                        else
                        {
                            if (sinfList[i].DISPOSITION != "NotExist")
                            {
                                if (sinfList[i].DISPOSITION.Trim() == "NotProcess")
                                {
                                    sinfString.AppendFormat("@@");
                                }
                                else
                                {
                                    sinfString.AppendFormat("00");
                                }
                            }
                            else
                            {
                                sinfString.AppendFormat("__");
                            }
                        }

                        if ((sinfList[i].DIEADDRESSX + 1) != dielayout.COLUMNS_)
                        {
                            sinfString.AppendFormat(" ");
                        }
                        else
                        {
                            sinfString.AppendLine();
                        }
                    }
                }

                using (FileStream fs = File.Create(path))
                {
                    Byte[] info = new UTF8Encoding(true).GetBytes(sinfString.ToString());

                    fs.Write(info, 0, info.Length);
                }

                return(true);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(false);
            }
        }
Пример #9
0
        /// <summary>
        /// 读取license信息
        /// </summary>
        /// <param name="licMsg"></param>
        /// <returns></returns>
        public uint ReceiveLicMsg(ref LicMsg licMsg)
        {
            CLicenseManagedAdapter licMan = new CLicenseManagedAdapter();
            SmcErr   smcErr = new SmcErr();
            LoggerEx logEx  = new LoggerEx(log);

            if (null == licMsg)
            {
                smcErr.ErrNo = SmcErr.SMC_INVALID_PARAM;
                logEx.Warn("Perform ReceiveLicMsg's licMsg is null msg!");
                return(smcErr.ErrNo);
            }
            else
            {
                logEx.Trace("ReceiveLicMsg licMsg msg: {0}", licMsg.GetType());
            }

            if (LicCallBackType.LicLKReadRevokeTicket == licMsg.MsgID)
            {
                LicMsg license = new LicMsg();
                if (LicPersisFileType.LicPersistentSafemem == licMsg.FileType)
                {
                    if (File.Exists(strPathPersistent))
                    {
                        license.MsgParam = File.ReadAllBytes(strPathPersistent);
                        logEx.Info("LoadLicPersistentSafemem is successful!");
                    }
                    else
                    {
                        //string str = "0x";
                        //byte[] b = Encoding.Default.GetBytes(str);
                        byte[] b = new byte[0];
                        license          = new LicMsg();
                        license.MsgParam = b;
                    }
                }
                else if (LicPersisFileType.LicPersistentInfo == licMsg.FileType)
                {
                    if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                    {
                        try
                        {
                            try
                            {
                                if (File.Exists(strPathLic))
                                {
                                    license.MsgParam = File.ReadAllBytes(strPathLic);
                                    logEx.Info("LoadLicenseInfo is successful!");
                                }
                                else
                                {
                                    byte[] b = new byte[0];
                                    license          = new LicMsg();
                                    license.MsgParam = b;
                                }
                            }
                            catch (System.Exception ex)
                            {
                                logEx.Error(ex, "LicLKReadRevokeTicket faild!");
                                //记录系统加载License失败
                                SmcErr recordErr = new SmcErr(SmcErr.LICENSE_LOAD_ERR);
                                recordErr.ErrorInfoParam = new ErrorInfo();
                                recordErr.ErrorInfoParam.AddSmcErrInfo(smcErr);

                                logEx.Error(recordErr);
                            }
                        }
                        finally
                        {
                            this.licenseFileOperateLock.ExitWriteLock();
                        }
                    }
                }
                licMsg = license;
            }
            //License变更
            else if (LicCallBackType.LicLKStateChange == licMsg.MsgID)
            {
                GetControlLicItem(null);
            }
            //保存Licsense失效信息
            else if (LicCallBackType.LicLKWriteRevokeTicket == licMsg.MsgID)
            {
                File.WriteAllBytes(strPathPersistent, licMsg.MsgParam);
            }

            return(smcErr.ErrNo);
        }