Example #1
0
    /// <summary>
    /// event
    /// pulls the latest data from MDWS and loads the checklist items'
    /// everytime the timer ticks
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void OnRefresh(object sender, EventArgs e)
    {
        ShowMPE();
        CStatus status = null;

        if (BaseMstr.MDWSTransfer)
        {
            //get the selected patient checklist id
            long lPatCLID = Convert.ToInt64(ddlPatChecklist.SelectedValue);

            //talk to the communicator to update the
            //patient checklist from mdws
            CCommunicator com = new CCommunicator();
            status = com.RefreshPatientCheckList(
                BaseMstr.DBConn,
                BaseMstr.BaseData,
                PatientID,
                lPatCLID);
            if (!status.Status)
            {
                ShowStatusInfo(status);
                return;
            }
        }

        status = LoadChecklist();
        if (!status.Status)
        {
            ShowStatusInfo(status);
        }

        //set the UI permissions based on the user logged in
        SetPermissions(btnTIU.Enabled);
    }
            /// <summary>
            /// US:834 method  called by the timer delegate when the timer fires
            /// </summary>
            /// <param name="stateInfo"></param>
            public void OnTimer(Object stateInfo)
            {
                CStatus       status = new CStatus();
                CCommunicator com    = new CCommunicator();

                status = com.ProcessOpenChecklistItems();
            }
Example #3
0
    protected void OnContinueExisting(object sender, CAppUserControlArgs e)
    {
        CPatChecklistDataItem di = new CPatChecklistDataItem();

        di.ProcedureDate    = CDataUtils.GetNullDate();
        di.AssignmentDate   = DateTime.Now;
        di.ChecklistID      = ucExistingChecklist.ChecklistID;
        di.ChecklistStateID = k_CHECKLIST_STATE_ID.Open;
        di.PatientID        = PatientID;
        di.StateID          = k_STATE_ID.Unknown;

        long lPatCLID            = 0;
        CPatChecklistData pcld   = new CPatChecklistData(BaseMstr.BaseData);
        CStatus           status = pcld.InsertPatChecklist(di, out lPatCLID);

        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        if (BaseMstr.MDWSTransfer)
        {
            //talk to the communicator to update the
            //patient checklist from mdws
            CCommunicator com = new CCommunicator();
            status = com.RefreshPatientCheckList(
                BaseMstr.DBConn,
                BaseMstr.BaseData,
                PatientID,
                lPatCLID);
            if (!status.Status)
            {
                ShowStatusInfo(status);
                return;
            }
        }

        CPatientChecklist pcl = new CPatientChecklist();

        status = pcl.LoadPatientChecklists(BaseMstr, PatientID, ddlPatChecklist);
        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }
        ddlPatChecklist.SelectedValue = lPatCLID.ToString();

        status = LoadChecklist();
        if (!status.Status)
        {
            ShowStatusInfo(status);
            return;
        }

        //set the UI permissions based on the user logged in
        SetPermissions(btnTIU.Enabled);
    }
        /// <summary>
        /// US:834 Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            components       = new System.ComponentModel.Container();
            this.ServiceName = "VAPPCTCommService";

            //TODO: just testing below...
            CCommunicator com = new CCommunicator();

            com.ProcessOpenChecklistItems();
        }
        /// <summary>
        /// Thread gets market data from DataRecieve
        /// and copy it to the MarketViewModel
        /// </summary>
        private void ThreadDataReciever()
        {
            CCommunicator communicator = _kernelTerminal.Communicator;



            while (IsAlive)
            {
                try
                {
                    //whait till data is available
                    while (IsDataUnavailable(_dataReciever))
                    {
                        _dataReciever = communicator.GetDataReciever(ConnId);
                        Thread.Sleep(100);

                        if (!IsAlive)
                        {
                            return;
                        }
                    }
                    DateTime dtBegin = DateTime.Now;
                    ProcessStocks();
                    ProcessAggrDeals();
                    ProcessRowDeals();


                    int parSleep = GetParSleepBeetwenStockUpd();



                    //  int minSleePeriod = 50;


                    double dt = parSleep - (DateTime.Now - dtBegin).TotalMilliseconds;
                    //  dt = Math.Max(dt,minSleePeriod);

                    if (dt > 0)
                    {
                        Thread.Sleep((int)dt);
                    }
                }

                catch (Exception e)
                {
                    Error("MarketViewModel.ThreadDataReciever", e);
                }
            }


            IsDead = true;
        }
Example #6
0
        public CKernelTerminal()
        {
            CUtil.ThreadStart(ThreadWatchDog);

            //2018-03-28 moved up as it was after ViewDispatcher create line
            _evntGUIDispatcher = new CEvntDispTerminal(this);

            if (!IsUniqueProcess())
            {
                return;
            }

            CheckPreRunCondProcessed();

            ReadGlobalConfig();

            ReadTerminalConfig();

            ReadVisualStockConfig();
            SetMinThreads();

            Communicator        = new CCommunicator(this);
            ViewModelDispatcher = new CViewModelDispatcher(this);
            ViewDispatcher      = new CViewDispatcher(this);

            _passwordSaver = new CPasswordSaver(this);


            LoadColorList();

            //Bind connection trial and auth success events
            //for manual (GUI) and aftomatic(passwordsave) auth requesters.
            ConnectionTrial += Communicator.OnUserTryConnectToServer;
            ConnectionTrial += _passwordSaver.OnConnectionTrial;

            AuthSuccess += _passwordSaver.OnConnectedSuccess;
            AuthSuccess += SubscribeTickersFromConfig;
            AuthSuccess += SendTeminalInfoForDealingServer;
        }
    /// <summary>
    /// do the actual work of assigning the checklist
    /// </summary>
    /// <param name="state"></param>
    public void DoWork(Object state)
    {
        //thread hashcount work
        lock (HashCount)
        {
            if (!HashCount.ContainsKey(Thread.CurrentThread.GetHashCode()))
            {
                HashCount.Add(Thread.CurrentThread.GetHashCode(), 0);
            }

            HashCount[Thread.CurrentThread.GetHashCode()] = ((int)HashCount[Thread.CurrentThread.GetHashCode()]) + 1;
        }

        //do the real work here
        //////////////////////////////////////////////////////////////

        //create a new connection for the thread
        CDataDBConn conn = new CDataDBConn();

        conn.Connect();
        CData data = new CData(
            conn,
            this.ClientIP,
            this.UserID,
            this.SessionID,
            this.WebSession,
            this.MDWSTransfer);


        CPatChecklistData     pcl          = new CPatChecklistData(data);
        string                strPatientID = PatientID;
        CPatChecklistDataItem di           = new CPatChecklistDataItem();

        di.ProcedureDate    = CDataUtils.GetNullDate();
        di.AssignmentDate   = DateTime.Now;
        di.ChecklistID      = ChecklistID;
        di.ChecklistStateID = k_CHECKLIST_STATE_ID.Open;
        di.PatientID        = strPatientID;
        di.StateID          = k_STATE_ID.Unknown;

        long lPatCLID = 0;

        Status = pcl.InsertPatChecklist(di, out lPatCLID);
        if (Status.Status)
        {
            if (MDWSTransfer)
            {
                //talk to the communicator to update the
                //patient checklist from mdws
                CCommunicator com = new CCommunicator();
                Status = com.RefreshPatientCheckList(
                    conn,
                    data,
                    strPatientID,
                    lPatCLID);
            }

            if (Status.Status)
            {
                CPatientChecklistLogic pcll = new CPatientChecklistLogic(data);
                Status = pcll.RunLogic(lPatCLID);
            }
        }

        //cleanup the database connection
        conn.Close();

        //signals we are done.
        Interlocked.Increment(ref ThreadCount);
        if (ThreadCount == ThreadMax)
        {
            if (eventX != null)
            {
                eventX.Set();
                ThreadCount = 0;
                ThreadMax   = 0;
            }
        }
    }
        public MarketViewModel(int stockNum, ControlMarket controlMain, CKernelTerminal kernelTerminal,
                               CStocksVisual stockVisual, CInstrumentConfig instrumentConfig)
        {
            StockNum = stockNum;
            string tickerName = stockVisual.Ticker;


            IsAlive = true;
            IsDead  = false;


            SelectionMode = new CSelectionMode();
            string tf = instrumentConfig.MarketProperties.ClusterProperties.TimeFrame;

            _clusterProcessor = new CClusterProcessor(tickerName, tf);
            _userLevels       = new CUserLevels(tickerName);


            _eventRouterViewModel = new CEventRouterViewModel(this);

            // int conId = stockVisual.ConNumm;



            _orders = new OrderData[Params.MaxUserOrdersPerInstr];



            _terminalViewModel = CViewModelDispatcher.GetTerminalViewModel();



            int parUpdateStockPerSec = kernelTerminal.TerminalConfig.UpdateStockPerSec;

            _parSleep = (int)(1 / (double)parUpdateStockPerSec * 1000);

            _instrumentConfig = instrumentConfig;

            //    (new Thread(TestPar)).Start();


            GUIDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;

            _controlMarket  = controlMain;
            _kernelTerminal = kernelTerminal;
            _communicator   = kernelTerminal.Communicator;

            //TextPriceSize = "10";
            //  StringHeight = "10";

            CurrAmountNum  = "0";
            ListWorkAmount = new List <CWorkAmount>();

            SetInstrumentParams(stockVisual);
            _vmUserPos = new ViewModelUserPos(Decimals, Step);



            _parMaxVolumeBar = Int32.MaxValue;

            //RaisePropertyChanged("Contract_ShortName");


            ConnId = stockVisual.ConNumm;// conId;



            MonitorUserOrders = new Dictionary <long, COrder>();


            if (tickerName != null)
            {
                _logger = new CLogger("MarketViewModel_" + tickerName);
            }

            Log("Start logging__________________________________________");



            InitBidsAsks();



            //TODO remove
            this.InitializeStockData();

            SetMouseMode(true);

            _threadDataReciever = new Thread(ThreadDataReciever);
            _threadDataReciever.Start();


            //BindWorkAmount();
        }
Example #9
0
    /// <summary>
    /// do the actual work of assigning the checklist
    /// </summary>
    /// <param name="state"></param>
    public void DoWork(Object state)
    {
        //thread hashcount work
        lock (HashCount)
        {
            if (!HashCount.ContainsKey(Thread.CurrentThread.GetHashCode()))
            {
                HashCount.Add(Thread.CurrentThread.GetHashCode(), 0);
            }

            HashCount[Thread.CurrentThread.GetHashCode()] = ((int)HashCount[Thread.CurrentThread.GetHashCode()]) + 1;
        }

        //create a new connection for the thread
        CDataDBConn conn = new CDataDBConn();

        conn.Connect();
        CData data = new CData(conn,
                               this.ClientIP,
                               this.UserID,
                               this.SessionID,
                               this.WebSession,
                               this.MDWSTransfer);
        //do real work here

        //get the items for this pat checklist id
        CStatus         status           = new CStatus();
        DataSet         dsChecklistItems = null;
        CVAPPCTCommData commData         = new CVAPPCTCommData(data);

        status = commData.GetPatChecklistItemDS(PatientChecklistID,
                                                out dsChecklistItems);
        if (!status.Status)
        {
            //todo
        }
        else
        {
            CCommunicator comm = new CCommunicator();

            //refresh the checklist items
            status = comm.RefreshPatientCheckList(conn,
                                                  data,
                                                  dsChecklistItems);
            if (!status.Status)
            {
                //todo:
            }
            else
            {
                //refresh the checklist collection items
                DataSet dsCLCollectionItems = null;
                status = commData.GetPatientCLCollectionItemDS(PatientChecklistID,
                                                               out dsCLCollectionItems);
                if (!status.Status)
                {
                    //todo:
                }
                else
                {
                    //refresh the checklist items
                    status = comm.RefreshPatientCheckList(conn,
                                                          data,
                                                          dsCLCollectionItems);
                    if (!status.Status)
                    {
                        //todo
                    }
                }
            }
        }

        //cleanup the database connection
        conn.Close();

        //signals we are done.
        Interlocked.Increment(ref ThreadCount);
        if (ThreadCount == ThreadMax)
        {
            if (eventX != null)
            {
                eventX.Set();
                ThreadCount = 0;
                ThreadMax   = 0;
            }
        }
    }