Beispiel #1
0
 public void setNewEntry(UDT u)
 {
     lock (m_IDLock)
     {
         m_vNewEntry.Add(u);
     }
 }
Beispiel #2
0
 public void remove(UDT u)
 {
     lock (m_ListLock)
     {
         remove_(u);
     }
 }
Beispiel #3
0
        public void RcvUListTest()
        {
            UDT udt = new UDT();

            udt.m_pRNode               = new RNode();
            udt.m_pRNode.m_pUDT        = udt;
            udt.m_pRNode.m_llTimeStamp = 1;
            udt.m_pRNode.m_bOnList     = false;

            UDT udt2 = new UDT();

            udt2.m_pRNode               = new RNode();
            udt2.m_pRNode.m_pUDT        = udt2;
            udt2.m_pRNode.m_llTimeStamp = 1;
            udt2.m_pRNode.m_bOnList     = false;

            RcvUList rcvUList = new RcvUList();

            udt.m_pRNode.m_bOnList = true;
            rcvUList.insert(udt);
            Assert.IsTrue(udt.m_pRNode.m_llTimeStamp > 1);

            udt2.m_pRNode.m_bOnList = true;
            rcvUList.insert(udt2);
            Assert.IsTrue(udt2.m_pRNode.m_llTimeStamp > 1);
            Assert.IsTrue(udt2.m_pRNode.m_llTimeStamp > udt.m_pRNode.m_llTimeStamp);

            rcvUList.update(udt);
            Assert.IsTrue(udt.m_pRNode.m_llTimeStamp > udt2.m_pRNode.m_llTimeStamp);

            rcvUList.remove(udt);
            rcvUList.remove(udt2);
        }
        private void addLog(UDT.Experience rec)
        {
            this.logAgent.ActionType = Log.LogActionType.Delete;
            this.logAgent.SetLogValue("公司名稱", rec.Company);
            this.logAgent.SetLogValue("職稱", rec.Position);
            //this.logAgent.SetLogValue("是否現職", rec.IsCurrent.ToString());
            this.logAgent.SetLogValue("產業別", rec.Industry);
            this.logAgent.SetLogValue("部門類別", rec.DepartmentCategory);
            this.logAgent.SetLogValue("層級別", rec.PostLevel);
            this.logAgent.SetLogValue("工作地點", rec.WorkPlace);
            this.logAgent.SetLogValue("工作狀態", rec.WorkStatus);
            DateTime work_begin_date;
            if (DateTime.TryParse(rec.WorkBeginDate + "", out work_begin_date))
                this.logAgent.SetLogValue("工作起日", work_begin_date.ToString("yyyy/MM/dd"));
            else
                this.logAgent.SetLogValue("工作起日", rec.WorkBeginDate + "");

            DateTime work_end_date;
            if (DateTime.TryParse(rec.WorkEndDate + "", out work_end_date))
                this.logAgent.SetLogValue("工作迄日", work_end_date.ToString("yyyy/MM/dd"));
            else
                this.logAgent.SetLogValue("工作迄日", rec.WorkEndDate + "");

            this.logAgent.SetLogValue("公關連絡人", rec.Publicist);
            this.logAgent.SetLogValue("公關室電話", rec.PublicRelationsOfficeTelephone);
            this.logAgent.SetLogValue("公關室傳真", rec.PublicRelationsOfficeFax);
            this.logAgent.SetLogValue("公關EMAIL", rec.PublicistEmail);
            this.logAgent.SetLogValue("公司網址", rec.CompanyWebsite);
            this.logAgent.SetLogValue("最後更新日期", rec.TimeStamp.HasValue ? rec.TimeStamp.Value.ToString("yyyy/MM/dd") : "");
        }
        void AddLog(UDT.StudentBrief2 udtObj)
        {
            this.logAgent.SetLogValue("畢業學期", udtObj.GraduateSemester);
            this.logAgent.SetLogValue("畢業學年度", udtObj.GraduateYear);

            this.logAgent.SetLogValue("電子郵件", udtObj.EmailList);
        }
        public Survey(UDT.Survey survey)
        {
            this.Questions = new List<Question>();
            this.uSurvey = survey;

            this.InitQuestions();
        }
Beispiel #7
0
        private Thread mUpdateThread; //Thread used to poll the CB280 inputs

        #endregion Fields

        #region Constructors

        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes flags and creates I/O tag arrays
        /// </summary>
        ///////////////////////////////////////////////////////////////////////////////////////////
        public CB280()
        {
            mInitialized = false;

            mInputBuffer = new byte[2];  //Only buffer digital inputs. Analog are read on demand.
            mOutputBuffer = new byte[2];	//Only buffer digital outputs. PWM are not implemented.

            mTags = new UDT(mID);

            mInputTags = new UDT("I");
            mOutputTags = new UDT("O");

            mTags.Add(mInputTags);
            mTags.Add(mOutputTags);

            for (int i = 0; i < 11; i++) {
                mInputTags.Add(new Tag("D" + i.ToString("00"), DataType.Bool, TagDirection.Input));
            }
            for (int i = 11; i < 19; i++) {
                mInputTags.Add(new Tag("A" + (i - 11).ToString("00"), DataType.Int16, TagDirection.Input));
                mInputTags[i].TagRead += new TagEventHandler(OnInputTagRead);
            }
            for (int i = 0; i < 8; i++) {
                mOutputTags.Add(new Tag("D" + i.ToString("00"), DataType.Bool, TagDirection.Output));
                mOutputTags[i].TagChanged += new TagEventHandler(OnOutputTagChanged);
            }
        }
Beispiel #8
0
        public void update(UDT u, bool reschedule = true)
        {
            lock (m_ListLock)
            {
                SNode n = u.m_pSNode;

                if (n.m_iHeapLoc >= 0)
                {
                    if (!reschedule)
                    {
                        return;
                    }

                    if (n.m_iHeapLoc == 0)
                    {
                        n.m_llTimeStamp = 1;
                        m_pTimer.interrupt();
                        return;
                    }

                    remove_(u);
                }

                insert_(1, u);
            }
        }
        public frmHTML_Preview(UDT.Survey Survey)
        {
            InitializeComponent();

            this._Survey = Survey;
            this.Access = new AccessHelper();
            this.Load += new System.EventHandler(this.Form_Load);
        }
 public frmFAQ_SingleForm(UDT.CSFaq CSFaq)
 {
     InitializeComponent();
     this.CSFaq = CSFaq;
     Access = new AccessHelper();
     this.ErrorProvider = new ErrorProvider();
     this.Load += new EventHandler(frmFAQ_SingleForm_Load);
 }
        public void SetAbsence(UDT.Absence abs, int rowIndex, int colIndex)
        {
            if (abs == null)  this.Close();

            this.abs = abs;
            this.rowIndex = rowIndex;
            this.colIndex = colIndex;
        }
Beispiel #12
0
        /// <summary>
        /// 新增一筆 UDTAccess 紀錄
        /// </summary>
        /// <param name="club"></param>
        public static void Insert(UDT.UDTTeacherWords healthy)
        {
            List<ActiveRecord> healthys = new List<ActiveRecord>();
            healthys.Add(healthy);

            udtHelper.InsertValues(healthys);
            if (ItemChanged != null)
                ItemChanged(null, EventArgs.Empty);
        }
 public frmStatistics_SingleForm(UDT.StatisticsGroup StatisticsGroup, UDT.Survey Survey)
 {
     InitializeComponent();
     this.StatisticsGroup = StatisticsGroup;
     this.Survey = Survey;
     Access = new AccessHelper();
     this.ErrorProvider = new ErrorProvider();
     this.Load += new EventHandler(frmStatistics_SingleForm_Load);
 }
 public Question(UDT.Question uQ)
 {
     this.uQuestion = uQ;
     this.QuestionOptions = new List<QuestionOption>();
     this.Answers = new List<Answer>();
     this.Cases = new List<Case>();
     this.InitQuestionOptions();
     this.Score = null;
 }
Beispiel #15
0
        public void insert(UDT u)
        {
            RNode n = u.m_pRNode;

            n.m_llTimeStamp = Timer.rdtsc();

            // always insert at the end for RcvUList
            m_nodeList.Add(n);
        }
Beispiel #16
0
        protected void sendCustomMsg(Packet pkt)
        {
            UDT u = UDT.s_UDTUnited.lookup(m_UDT);

            if (null != u)
            {
                pkt.SetId(u.m_PeerID);
                u.m_pSndQueue.sendto(u.m_pPeerAddr, pkt);
            }
        }
        public CS_Template_NoSubject(UDT.CSConfiguration.TemplateName TemplateName)
        {
            InitializeComponent();

            this.TemplateName = TemplateName;
            this.Text = "編輯「" + this.TemplateName.ToString() + "」文字樣版";
            this.TitleText = "編輯「" + this.TemplateName.ToString() + "」文字樣版";

            webBrowser1.GotFocus += new EventHandler(webBrowser1_GotFocus);
        }
        public int AddSubject(UDT.Subject subject)
        {
            IEnumerable<DataGridViewRow> dgvrs = this.dgvMotherData.Rows.Cast<DataGridViewRow>();

            if (dgvrs.Where(x => ((x.Tag as UDT.Subject).UID == subject.UID)).Count() == 0)
            {
                return AddSubjectToDataGridView(subject);
            }
            return 0;
        }
        public SurveyCreator(UDT.Survey Survey)
        {
            InitializeComponent();

            this.Load += new System.EventHandler(this.Form_Load);

            this._Survey = Survey;

            Access = new AccessHelper();
        }
Beispiel #20
0
 public void removeListener(UDT u)
 {
     lock (m_LSLock)
     {
         if (u == m_pListener)
         {
             m_pListener = null;
         }
     }
 }
 public frmAssignedSurvy_SingleForm(UDT.AssignedSurvey AssignedSurvey, CourseRecord Course, TeacherRecord Teacher, string CaseName)
 {
     InitializeComponent();
     this.AssignedSurvey = AssignedSurvey;
     this.Course = Course;
     this.Teacher = Teacher;
     this.CaseName = CaseName;
     Access = new AccessHelper();
     this.ErrorProvider = new ErrorProvider();
     this.Load += new EventHandler(frmAssignedSurvy_SingleForm_Load);
 }
Beispiel #22
0
        public void remove(UDT u)
        {
            RNode n = u.m_pRNode;

            if (!n.m_bOnList)
            {
                return;
            }

            m_nodeList.Remove(n);
        }
        public ImportReportDocumentTemplate(UDT.ReportTemplate template = null, string templateName = "")
        {
            InitializeComponent();

            Access = new AccessHelper();
            Query = new QueryHelper();
            this.Template = template;
            this.TemplateName = templateName;

            this.Load += new System.EventHandler(this.ImportReceiptDocumentTemplate_Load);
        }
Beispiel #24
0
 public int Receive(byte[] data, int offset, int length)
 {
     try
     {
         UDT udt = UDT.s_UDTUnited.lookup(mSocketId);
         return(udt.recv(data, offset, length));
     }
     catch (UdtException udtException)
     {
         throw new Exception("Problem when receiving data", udtException);
     }
 }
Beispiel #25
0
 public int Send(byte[] data, int offset, int length)
 {
     try
     {
         UDT udt = UDT.s_UDTUnited.lookup(mSocketId);
         return(udt.send(data, offset, length));
     }
     catch (UdtException udtException)
     {
         throw new Exception(udtException.getErrorMessage(), udtException);
     }
 }
Beispiel #26
0
        public int setListener(UDT u)
        {
            lock (m_LSLock)
            {
                if (null != m_pListener)
                {
                    return(-1);
                }

                m_pListener = u;
                return(0);
            }
        }
        public ExcelDocumentMaker(Dictionary<string, Dictionary<string, Color>> dicEvaluationBackgroundColor, Dictionary<string, Dictionary<string, Color>> dicQuestionBackgroundColor, List<UDT.QHRelation> QHRelations, List<UDT.Hierarchy> Hierarchies, UDT.TeacherStatistics Statistics, Workbook wb)
        {
            this.Access = new AccessHelper();
            this.Query = new QueryHelper();

            this.QHRelations = QHRelations;
            this.Hierarchies = Hierarchies;
            this._Statistics = Statistics;
            this._Template = wb;
            this._DataBindedSheets = new List<DataBindedSheet>();
            this._DicEvaluationBackgroundColor = dicEvaluationBackgroundColor;
            this._DicQuestionBackgroundColor = dicQuestionBackgroundColor;
            this.dicCellStyles = new Dictionary<CellObject, CellStyle>();
        }
Beispiel #28
0
        UDT getNewEntry()
        {
            lock (m_IDLock)
            {
                if (m_vNewEntry.Count == 0)
                {
                    return(null);
                }

                UDT u = m_vNewEntry[0];
                m_vNewEntry.RemoveAt(0);
                return(u);
            }
        }
Beispiel #29
0
        public void insert(ulong ts, UDT u)
        {
            lock (m_ListLock)
            {
                // increase the heap array size if necessary
                if (m_iLastEntry == m_iArrayLength - 1)
                {
                    Array.Resize(ref m_pHeap, m_iArrayLength * 2);
                    m_iArrayLength *= 2;
                }

                insert_(ts, u);
            }
        }
Beispiel #30
0
        public void insert(int id, UDT u, AddressFamily ipv, IPEndPoint addr, ulong ttl)
        {
            CRL r;

            r.m_iID        = id;
            r.m_pUDT       = u;
            r.m_iIPversion = ipv;
            r.m_pPeerAddr  = addr;
            r.m_ullTTL     = ttl;

            lock (m_RIDVectorLock)
            {
                m_lRendezvousID.Add(r);
            }
        }
Beispiel #31
0
        void insert_(ulong ts, UDT u)
        {
            SNode n = u.m_pSNode;

            // do not insert repeated node
            if (n.m_iHeapLoc >= 0)
            {
                return;
            }

            m_iLastEntry++;
            m_pHeap[m_iLastEntry] = n;
            n.m_llTimeStamp       = ts;

            int q = m_iLastEntry;
            int p = q;

            while (p != 0)
            {
                p = (q - 1) >> 1;
                if (m_pHeap[p].m_llTimeStamp > m_pHeap[q].m_llTimeStamp)
                {
                    SNode t = m_pHeap[p];
                    m_pHeap[p]   = m_pHeap[q];
                    m_pHeap[q]   = t;
                    t.m_iHeapLoc = q;
                    q            = p;
                }
                else
                {
                    break;
                }
            }

            n.m_iHeapLoc = q;

            // an earlier event has been inserted, wake up sending worker
            if (n.m_iHeapLoc == 0)
            {
                m_pTimer.interrupt();
            }

            // first entry, activate the sending queue
            if (0 == m_iLastEntry)
            {
                m_pWindowCond.Set();
            }
        }
 public frmCase_SingleForm(UDT.Case Case, List<DataItems.CloudFileUrlItem> googleDocsRowSource)
 {
     InitializeComponent();
     this.Case = Case;
     this.GoogleDocsRowSource = googleDocsRowSource;
     Access = new AccessHelper();
     this.ErrorProvider = new ErrorProvider();
     this.dgvData.CellEnter += new DataGridViewCellEventHandler(dgvData_CellEnter);
     this.dgvData.CurrentCellDirtyStateChanged += new EventHandler(dgvData_CurrentCellDirtyStateChanged);
     this.dgvData.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(dgvData_EditingControlShowing);
     this.dgvData.DataError += new DataGridViewDataErrorEventHandler(dgvData_DataError);
     this.dgvData.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgvData_ColumnHeaderMouseClick);
     this.dgvData.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgvData_RowHeaderMouseClick);
     this.dgvData.MouseClick += new System.Windows.Forms.MouseEventHandler(this.dgvData_MouseClick);
     this.Load += new EventHandler(frmCase_SingleForm_Load);
 }
Beispiel #33
0
        public void RendezvouzQueueTest()
        {
            IPEndPoint endPointA = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 8000);
            IPEndPoint endPointB = new IPEndPoint(IPAddress.Parse("1.1.1.1"), 5000);
            IPEndPoint endPointC = new IPEndPoint(IPAddress.Parse("2.2.2.2"), 8000);
            IPEndPoint endPointD = new IPEndPoint(IPAddress.Parse("3.3.3.3"), 8000);

            UDT udt = new UDT();

            udt.m_SocketID = 1;

            UDT udt2 = new UDT();

            udt2.m_SocketID = 2;

            RendezvousQueue rendezvousQueue = new RendezvousQueue();

            rendezvousQueue.insert(1, udt, AddressFamily.InterNetwork, endPointA, 100);
            rendezvousQueue.insert(2, udt2, AddressFamily.InterNetwork, endPointC, 100);

            int foundId  = 0;
            UDT foundUdt = rendezvousQueue.retrieve(endPointB, ref foundId);

            Assert.IsNull(foundUdt);
            foundUdt = rendezvousQueue.retrieve(endPointD, ref foundId);
            Assert.IsNull(foundUdt);

            foundUdt = rendezvousQueue.retrieve(endPointC, ref foundId);
            Assert.AreEqual(2, foundId);
            Assert.AreEqual(2, foundUdt.m_SocketID);

            foundId  = 0;
            foundUdt = rendezvousQueue.retrieve(endPointA, ref foundId);
            Assert.AreEqual(1, foundId);
            Assert.AreEqual(1, foundUdt.m_SocketID);

            rendezvousQueue.remove(2);
            rendezvousQueue.remove(1);

            foundId  = 0;
            foundUdt = rendezvousQueue.retrieve(endPointA, ref foundId);
            Assert.IsNull(foundUdt);

            foundUdt = rendezvousQueue.retrieve(endPointC, ref foundId);
            Assert.IsNull(foundUdt);
        }
Beispiel #34
0
        protected PerfMon getPerfInfo()
        {
            try
            {
                UDT u = UDT.s_UDTUnited.lookup(m_UDT);
                if (null != u)
                {
                    u.sample(m_PerfInfo, false);
                }
            }
            catch (Exception e)
            {
                return(null);
            }

            return(m_PerfInfo);
        }
Beispiel #35
0
        void remove_(UDT u)
        {
            SNode n = u.m_pSNode;

            if (n.m_iHeapLoc >= 0)
            {
                // remove the node from heap
                m_pHeap[n.m_iHeapLoc] = m_pHeap[m_iLastEntry];
                m_iLastEntry--;
                m_pHeap[n.m_iHeapLoc].m_iHeapLoc = n.m_iHeapLoc;

                int q = n.m_iHeapLoc;
                int p = q * 2 + 1;
                while (p <= m_iLastEntry)
                {
                    if ((p + 1 <= m_iLastEntry) && (m_pHeap[p].m_llTimeStamp > m_pHeap[p + 1].m_llTimeStamp))
                    {
                        p++;
                    }

                    if (m_pHeap[q].m_llTimeStamp > m_pHeap[p].m_llTimeStamp)
                    {
                        SNode t = m_pHeap[p];
                        m_pHeap[p]            = m_pHeap[q];
                        m_pHeap[p].m_iHeapLoc = p;
                        m_pHeap[q]            = t;
                        m_pHeap[q].m_iHeapLoc = q;

                        q = p;
                        p = q * 2 + 1;
                    }
                    else
                    {
                        break;
                    }
                }

                n.m_iHeapLoc = -1;
            }

            // the only event has been deleted, wake up immediately
            if (0 == m_iLastEntry)
            {
                m_pTimer.interrupt();
            }
        }
Beispiel #36
0
        public void update(UDT u)
        {
            RNode n = u.m_pRNode;

            if (!n.m_bOnList)
            {
                return;
            }

            RNode match = m_nodeList.Find(x => x.Equals(n));

            if (match.Equals(default(RNode)))
            {
                return;
            }

            match.m_llTimeStamp = Timer.rdtsc();
        }
Beispiel #37
0
        public void RcvQueueTest()
        {
            RcvQueue rcvQueue = new RcvQueue();

            UDT udt  = new UDT();
            UDT udt2 = new UDT();

            Assert.AreEqual(0, rcvQueue.setListener(udt));
            Assert.AreEqual(-1, rcvQueue.setListener(udt2));
            rcvQueue.removeListener(udt2);
            Assert.AreEqual(-1, rcvQueue.setListener(udt2));
            rcvQueue.removeListener(udt);
            Assert.AreEqual(0, rcvQueue.setListener(udt2));

            rcvQueue.registerConnector(1, udt, AddressFamily.InterNetwork, null, 100);
            rcvQueue.registerConnector(2, udt2, AddressFamily.InterNetwork, null, 100);

            rcvQueue.removeConnector(1);
            rcvQueue.removeConnector(2);
        }
Beispiel #38
0
        public int pop(ref IPEndPoint addr, ref Packet pkt)
        {
            lock (m_ListLock)
            {
                if (-1 == m_iLastEntry)
                {
                    return(-1);
                }

                // no pop until the next schedulled time
                ulong ts = Timer.rdtsc();
                if (ts < m_pHeap[0].m_llTimeStamp)
                {
                    return(-1);
                }

                UDT u = m_pHeap[0].m_pUDT;
                remove_(u);

                if (!u.m_bConnected || u.m_bBroken)
                {
                    return(-1);
                }

                // pack a packet from the socket
                if (u.packData(pkt, ref ts) <= 0)
                {
                    return(-1);
                }

                addr = u.m_pPeerAddr;

                // insert a new entry, ts is the next processing time
                if (ts > 0)
                {
                    insert_(ts, u);
                }

                return(1);
            }
        }
        private void addLog(UDT.Experience rec)
        {
            this.logAgent.ActionType = Log.LogActionType.Delete;
            this.logAgent.SetLogValue("公司名稱", rec.Company);
            this.logAgent.SetLogValue("職稱", rec.Position);
            //this.logAgent.SetLogValue("是否現職", rec.IsCurrent.ToString());
            this.logAgent.SetLogValue("產業別", rec.Industry);
            this.logAgent.SetLogValue("部門類別", rec.DepartmentCategory);
            this.logAgent.SetLogValue("層級別", rec.PostLevel);
            this.logAgent.SetLogValue("工作地點", rec.WorkPlace);
            this.logAgent.SetLogValue("工作狀態", rec.WorkStatus);
            DateTime work_begin_date;
            if (DateTime.TryParse(rec.WorkBeginDate + "", out work_begin_date))
                this.logAgent.SetLogValue("工作起日", work_begin_date.ToString("yyyy/MM/dd"));
            else
                this.logAgent.SetLogValue("工作起日", rec.WorkBeginDate + "");

            DateTime work_end_date;
            if (DateTime.TryParse(rec.WorkEndDate + "", out work_end_date))
                this.logAgent.SetLogValue("工作迄日", work_end_date.ToString("yyyy/MM/dd"));
            else
                this.logAgent.SetLogValue("工作迄日", rec.WorkEndDate + "");
        }
 public QuestionOption(UDT.QuestionOption uQ)
 {
     this.uQuestionOption = uQ;
     this.AnswerCount = 0;
 }
Beispiel #41
0
        static void worker(object param)
        {
            RcvQueue self = param as RcvQueue;

            if (self == null)
            {
                return;
            }

            IPEndPoint addr = new IPEndPoint(IPAddress.Any, 0);
            UDT        u    = null;
            int        id;

            while (!self.m_bClosing)
            {
                self.m_pTimer.tick();

                // check waiting list, if new socket, insert it to the list
                while (self.ifNewEntry())
                {
                    UDT ne = self.getNewEntry();
                    if (null != ne)
                    {
                        self.m_pRcvUList.insert(ne);
                        self.m_hash.Add(ne.m_SocketID, ne);
                    }
                }

                // find next available slot for incoming packet
                Unit unit = new Unit();
                unit.m_Packet.setLength(self.m_iPayloadSize);

                // reading next incoming packet, recvfrom returns -1 is nothing has been received
                if (self.m_pChannel.recvfrom(ref addr, unit.m_Packet) < 0)
                {
                    goto TIMER_CHECK;
                }

                id = unit.m_Packet.GetId();

                // ID 0 is for connection request, which should be passed to the listening socket or rendezvous sockets
                if (0 == id)
                {
                    if (null != self.m_pListener)
                    {
                        self.m_pListener.listen(addr, unit.m_Packet);
                    }
                    else if (null != (u = self.m_pRendezvousQueue.retrieve(addr, ref id)))
                    {
                        // asynchronous connect: call connect here
                        // otherwise wait for the UDT socket to retrieve this packet
                        if (!u.m_bSynRecving)
                        {
                            u.connect(unit.m_Packet);
                        }
                        else
                        {
                            Packet newPacket = new Packet();
                            newPacket.Clone(unit.m_Packet);
                            self.storePkt(id, newPacket);
                        }
                    }
                }
                else if (id > 0)
                {
                    if (self.m_hash.TryGetValue(id, out u))
                    {
                        if (addr.Equals(u.m_pPeerAddr))
                        {
                            if (u.m_bConnected && !u.m_bBroken && !u.m_bClosing)
                            {
                                if (0 == unit.m_Packet.getFlag())
                                {
                                    u.processData(unit);
                                }
                                else
                                {
                                    u.processCtrl(unit.m_Packet);
                                }

                                u.checkTimers();
                                self.m_pRcvUList.update(u);
                            }
                        }
                    }
                    else if (null != (u = self.m_pRendezvousQueue.retrieve(addr, ref id)))
                    {
                        if (!u.m_bSynRecving)
                        {
                            u.connect(unit.m_Packet);
                        }
                        else
                        {
                            Packet newPacket = new Packet();
                            newPacket.Clone(unit.m_Packet);
                            self.storePkt(id, newPacket);
                        }
                    }
                }

TIMER_CHECK:
                // take care of the timing event for all UDT sockets

                ulong currtime = Timer.rdtsc();

                ulong ctime = currtime - 100000 * Timer.getCPUFrequency();
                for (int i = 0; i < self.m_pRcvUList.m_nodeList.Count; ++i)
                {
                    RNode ul = self.m_pRcvUList.m_nodeList[0];
                    if (ul.m_llTimeStamp >= ctime)
                    {
                        break;
                    }

                    u = ul.m_pUDT;

                    if (u.m_bConnected && !u.m_bBroken && !u.m_bClosing)
                    {
                        u.checkTimers();
                        self.m_pRcvUList.update(u);
                    }
                    else
                    {
                        // the socket must be removed from Hash table first, then RcvUList
                        self.m_hash.Remove(u.m_SocketID);
                        self.m_pRcvUList.remove(u);
                        u.m_pRNode.m_bOnList = false;
                    }
                }

                // Check connection requests status for all sockets in the RendezvousQueue.
                self.m_pRendezvousQueue.updateConnStatus();
            }


            self.m_ExitCond.Set();
        }
 public static void OpenQueryRow(object Row, out UDT.TParams Value)
 {
     Value = (UDT.TParams)Row;
 }
 public static IEnumerable OpenParameterizedRemoteQuery(String ALinkedServer, String ASQL, UDT.TParams AParams)
 {
     return OpenQuery(OpenQueryString(ALinkedServer, FinalSQL(ASQL, AParams)));
 }
    public static IEnumerable OpenParameterizedQuery(String ASQL, UDT.TParams AParams)
    {
        if (String.IsNullOrEmpty(ASQL)) return null;

        return OpenQuery(FinalSQL(ASQL, AParams));
    }
    //[SqlFunction(Name = "Final SQL(Custom)", DataAccess = DataAccessKind.None, IsDeterministic = true)]
    // EXEC [A].[B] :Param1, :[Param2], :[$Params;Param2]
    public static String FinalSQLEx(String ASQL, UDT.TParams AParams, Boolean AOnlyQuoted)
    {
        if(String.IsNullOrEmpty(ASQL)) return ASQL;

        StringBuilder Result = new StringBuilder(ASQL.Length);

        Sql.ParamsParser Parser =
          new Sql.ParamsParser
          (
            ASQL,
            ':',
            TCommentMethods.DoubleMinus | TCommentMethods.SlashRange,
            new char[] { '[' },
            new char[] { '\'', '"', '[' }
          );

        while (Parser.MoveNext())
        {
          Result.Append(Parser.Current.Gap);
          Object LParamValue;
          if (!String.IsNullOrEmpty(Parser.Current.Value))
        if (AOnlyQuoted && (Parser.Current.Quote == (Char)0))
        {
          Result.Append(':');
          Result.Append(Parser.Current.Value);
        }
        else if (AParams == null)
          Result.Append("NULL");
        else if(Parser.Current.Value[0] == '$')
        {
          String LValues = (Parser.Current.Value.Length == 1 ? AParams.CastAsString() : AParams.CastAsStringCustom(Parser.Current.Value.Substring(1)));
          Result.Append(LValues == null ? "NULL" : Strings.QuoteString(LValues));
        }
        else if(AParams.TryGetValue(Parser.Current.Value, out LParamValue))
        {
          Result.Append(Sql.ValueToText(LParamValue, Sql.ValueDbStyle.SQL, '\''));
        }
        else
          Result.Append("NULL");
        }

        return Result.ToString();
    }
Beispiel #46
0
 public void registerConnector(int id, UDT u, AddressFamily ipv, IPEndPoint addr, ulong ttl)
 {
     m_pRendezvousQueue.insert(id, u, ipv, addr, ttl);
 }
 public static Object ExecuteRemoteParameterizedScalar(String ALinkedServer, String AQuery, UDT.TParams AParams)
 {
     return ExecuteScalar(OpenQueryString(ALinkedServer, FinalSQL(AQuery, AParams)));
 }
 public static void ExecuteRemoteParameterizedNonQuery(String ALinkedServer, String AQuery, UDT.TParams AParams)
 {
     ExecuteNonQuery(OpenQueryString(ALinkedServer, FinalSQL(AQuery, AParams)));
 }
 public static void ExecuteRemoteParameterized(String ALinkedServer, String AQuery, UDT.TParams AParams, String AResultSets)
 {
     Execute(OpenQueryString(ALinkedServer, FinalSQL(AQuery, AParams)), AResultSets);
 }
    //[SqlProcedure(Name = "Execute(Params)=>XML")]
    public static void ExecuteParameterizedToXML(
    String      AQuery,
    UDT.TParams AParams, 
    String      AResultSets,
out SqlXml      AXml,
    String      ARowsetNamePrefix  = null,
    String      ARootTag           = null,
    String      ARowsetTag         = null,
    String      ARowTag            = null
  )
    {
        if (String.IsNullOrEmpty(AQuery))
          throw new ArgumentNullException(PARAM_QUERY);

        ExecuteToXML
        (
          AQuery            :     FinalSQL(AQuery, AParams),
          AResultSets       :     AResultSets,
          AXml              : out AXml,
          ARowsetNamePrefix : ARowsetNamePrefix,
          ARootTag          : ARootTag,
          ARowsetTag        : ARowsetTag,
          ARowTag           : ARowTag
        );
    }
Beispiel #51
0
        // GET: Export
        public ActionResult Index()
        {
            var userName = User.Identity.GetUserName();
            var xmlDB    = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject);

            String pageName;

            if (String.IsNullOrEmpty(userName))
            {
                pageName = "";
            }
            else
            {
                pageName = _context.Users.First(c => c.Name == userName).ActProject;
            }

            var viewModel = new ExportViewModel
            {
                Controller = xmlDB.PLC,
                Modules    = xmlDB.Modules,
                UDTs       = new List <UDT>(),
                AOIs       = new List <Standard>(),
                Tags       = new List <Tag>(),
                Tasks      = new List <Task>()
            };

            var project = Generate();

            foreach (var udt in project.Element("Controller").Element("DataTypes").Elements())
            {
                var addUDT = new UDT
                {
                    Name = udt.Attribute("Name").Value,
                };

                if (udt.Elements("Description").Any())
                {
                    addUDT.Description = udt.Element("Description").Value;
                }
                else
                {
                    addUDT.Description = "No description";
                }

                viewModel.UDTs.Add(addUDT);
            }

            foreach (var tag in project.Element("Controller").Element("Tags").Elements())
            {
                var addTag = new Tag
                {
                    Name = tag.Attribute("Name").Value,
                    Type = tag.Attribute("DataType").Value,
                };

                if (tag.Elements("Description").Any())
                {
                    addTag.Description = tag.Element("Description").Value;
                }
                else
                {
                    addTag.Description = "No description";
                }

                viewModel.Tags.Add(addTag);
            }

            foreach (var aoi in project.Element("Controller").Element("AddOnInstructionDefinitions").Elements())
            {
                var addStandard = new Standard
                {
                    AOIName = aoi.Attribute("Name").Value,
                };

                if (aoi.Elements("Description").Any())
                {
                    addStandard.Description = aoi.Element("Description").Value;
                }
                else
                {
                    addStandard.Description = "No description";
                }

                String name = aoi.Attribute("Name").Value;
                addStandard.Group = xmlDB.Standards.First(c => c.AOIName == name).Group;

                viewModel.AOIs.Add(addStandard);
            }

            foreach (var task in project.Element("Controller").Element("Tasks").Elements())
            {
                var addTask = new Task
                {
                    Name     = task.Attribute("Name").Value,
                    Type     = task.Attribute("Type").Value,
                    Programs = new List <Program>(),
                };

                if (task.Elements("Description").Any())
                {
                    addTask.Description = task.Element("Description").Value;
                }
                else
                {
                    addTask.Description = "No description";
                }

                // Add all tasks programs
                foreach (var program in task.Element("ScheduledPrograms").Elements())
                {
                    var addProgram = new Program
                    {
                        Name     = program.Attribute("Name").Value,
                        Routines = new List <Routine>()
                    };

                    var locatedProgram = project.Element("Controller").Element("Programs").Elements().First(c => c.Attribute("Name").Value == program.Attribute("Name").Value);

                    if (locatedProgram.Elements("Description").Any())
                    {
                        addProgram.Description = locatedProgram.Element("Description").Value;
                    }
                    else
                    {
                        addProgram.Description = "No description";
                    }

                    // Add all programs routines
                    foreach (var routine in locatedProgram.Element("Routines").Elements())
                    {
                        var addRoutine = new Routine
                        {
                            Name = routine.Attribute("Name").Value,
                        };

                        if (routine.Elements("Description").Any())
                        {
                            addRoutine.Description = routine.Element("Description").Value;
                        }
                        else
                        {
                            addRoutine.Description = "No description";
                        }

                        if (routine.Elements("RLLContent").Any())
                        {
                            addRoutine.Type = "LAD";
                        }
                        else
                        {
                            addRoutine.Type = "STL";
                        }

                        addProgram.Routines.Add(addRoutine);
                    }
                    addTask.Programs.Add(addProgram);
                }
                viewModel.Tasks.Add(addTask);
            }



            return(View(viewModel));
        }
Beispiel #52
0
        public void SndUListTest()
        {
            UDT udt = new UDT();

            udt.m_pSNode               = new SNode();
            udt.m_pSNode.m_pUDT        = udt;
            udt.m_pSNode.m_llTimeStamp = 1;
            udt.m_pSNode.m_iHeapLoc    = -1;

            SndUList sndUList = new SndUList();

            sndUList.m_pTimer      = new UdtSharp.Timer();
            sndUList.m_pWindowLock = new object();
            sndUList.m_pWindowCond = new EventWaitHandle(false, EventResetMode.AutoReset);

            IPEndPoint endPoint = null;
            Packet     packet   = null;

            Assert.AreEqual(-1, sndUList.pop(ref endPoint, ref packet));

            sndUList.insert(100, udt);

            sndUList.update(udt, false);
            sndUList.update(udt, true);

            Assert.AreEqual(-1, sndUList.pop(ref endPoint, ref packet));

            udt.m_pSNode.m_llTimeStamp = 1;
            udt.m_pSNode.m_iHeapLoc    = -1;

            UDT udt2 = new UDT();

            udt2.m_pSNode               = new SNode();
            udt2.m_pSNode.m_pUDT        = udt2;
            udt2.m_pSNode.m_llTimeStamp = 1;
            udt2.m_pSNode.m_iHeapLoc    = -1;

            sndUList.insert(10, udt);

            Assert.AreEqual(10UL, sndUList.getNextProcTime());
            Assert.AreEqual(0, udt.m_pSNode.m_iHeapLoc);

            sndUList.insert(5, udt2);

            Assert.AreEqual(5UL, sndUList.getNextProcTime());
            Assert.AreEqual(1, udt.m_pSNode.m_iHeapLoc);
            Assert.AreEqual(0, udt2.m_pSNode.m_iHeapLoc);

            sndUList.remove(udt2);

            Assert.AreEqual(10UL, sndUList.getNextProcTime());
            Assert.AreEqual(0, udt.m_pSNode.m_iHeapLoc);
            Assert.AreEqual(-1, udt2.m_pSNode.m_iHeapLoc);

            sndUList.remove(udt);

            Assert.AreEqual(0UL, sndUList.getNextProcTime());
            Assert.AreEqual(-1, udt.m_pSNode.m_iHeapLoc);
            Assert.AreEqual(-1, udt2.m_pSNode.m_iHeapLoc);

            sndUList.insert(10, udt);
            sndUList.insert(5, udt2);
            Assert.AreEqual(1, udt.m_pSNode.m_iHeapLoc);
            Assert.AreEqual(0, udt2.m_pSNode.m_iHeapLoc);

            sndUList.update(udt, true);
            Assert.AreEqual(0, udt.m_pSNode.m_iHeapLoc);
            Assert.AreEqual(1, udt2.m_pSNode.m_iHeapLoc);
        }
 public void SubjectSemesterScore_AfterUpdate(object sender, UDT.ParameterEventArgs e)
 {
     LoadSubjectSemesterScores(null);
     DataGridView_DataBinding();
 }
 private string makeScoreMsg(UDT.SubjectSemesterScore scr)
 {
     string msg = string.Format("{0}, {1}, 課號:{2}, 課程:{3}, 班次:{8}, 學分數:{4}, 必選修: {5}, 成績:{6}, 是否取得學分:{7}, 抵免課程:{9} ",
             (scr.SchoolYear == null ? "" : scr.SchoolYear.ToString()),
             (scr.Semester == null ? "" : DataItems.SemesterItem.GetSemesterByCode(scr.Semester.ToString()).Name),
             scr.NewSubjectCode, scr.SubjectName, scr.Credit.ToString(),
             scr.IsRequired.ToString(), scr.Score, scr.IsPass.ToString(), (this.dicCourseExts.ContainsKey(scr.CourseID) ? this.dicCourseExts[scr.CourseID].ClassName : ""), scr.OffsetCourse);
     return msg;
 }
 public static String FinalSQL(String ASQL, UDT.TParams AParams)
 {
     return FinalSQLEx(ASQL, AParams, false);
 }