示例#1
0
 /// <summary>
 /// get the required start position, for use when there's a "locate" command
 /// </summary>
 /// <param name="reverse"></param>
 /// <returns></returns>
 internal DbPos SetCursorOnPosition(bool reverse, DbPos position, BoudariesFlags cursorPositionFlag)
 {
     OpenCursor(reverse, position, cursorPositionFlag);
     CursorFetch();
     CloseCursor();
     return(CurrentCursor.CursorDefinition.CurrentPosition);
 }
示例#2
0
    void Start()
    {
        spriteRenderer = GetComponent <SVGImage>();
        if (Switch != null)
        {
            _SwitchConducting = Switch.SwitchConducting;//true;
            if (_SwitchConducting == true)
            {
                spriteRenderer.sprite = close;
                position = DbPos.close;
            }
            else
            {
                spriteRenderer.sprite = open;
                position = DbPos.open;
            }
        }
        else
        {
            _SwitchConducting     = false;
            spriteRenderer.sprite = bad;
            position = DbPos.bad;
        }
        oldSwitchConducting = _SwitchConducting;

        if (Resources.FindObjectsOfTypeAll <OperateDialog>().Length > 0)
        {
            operateDialog = Resources.FindObjectsOfTypeAll <OperateDialog>()[0];
        }
        else
        {
            Debug.Log("cannot find operateDialog");
        }
    }
        void FetchValuesFromView()
        {
            // Using a dictionary here, because I don't have a 'hash set' available.
            var usedLinkValues = new com.magicsoftware.util.MgHashSet <FieldValue>();

            displayValues  = new List <string>();
            linkValues     = new List <string>();
            nullValueFlags = new List <bool>();
            linkType       = StorageAttribute.NONE;

            DbPos pos = new DbPos(true);

            view.OpenCursor(false, pos, BoudariesFlags.Range);
            while (view.CursorFetch().Success)
            {
                linkType = (StorageAttribute)valueField.Attr;
                FieldValue linkValue = view.GetFieldValue(valueField);

                // According to Online and RC-non-offline behavior, null link values should not
                // be added to the data control. The server does not send them at all.
                if (!linkValue.IsNull && !usedLinkValues.Contains(linkValue))
                {
                    nullValueFlags.Add(false);
                    linkValues.Add(linkValue.Value.ToString());
                    displayValues.Add(ConvertToDisplayValue(view.GetFieldValue(displayField)));
                    usedLinkValues.Add(linkValue.Clone());
                }
            }
            view.CloseCursor();
        }
示例#4
0
        /// <summary>
        /// get position
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        internal DbPos GetPosition(IRecord record)
        {
            DbPos      pos        = null;
            PositionId positionId = GetPositionId(record);

            PositionCache.TryGetValue(positionId, out pos);
            return(pos);
        }
示例#5
0
        /// <summary>
        /// Get DbRowIdx of current record.
        /// </summary>
        internal override int GetDbViewRowIdx()
        {
            //Get current Position
            DbPos currPos = TaskViews.ViewMain.GetCurrentPosition();
            int   idx     = DataviewSynchronizer.DataviewManager.PositionCache.IdxOf(currPos) + 1;

            return(idx);
        }
示例#6
0
        /// <summary>
        /// get current  position
        /// </summary>
        /// <returns></returns>
        internal DbPos GetCurrentPosition()
        {
            DbPos      pos        = null;
            IRecord    currRec    = ((DataView)LocalDataviewManager.Task.DataView).getCurrRec();
            PositionId positionId = GetPositionId(currRec);

            PositionCache.TryGetValue(positionId, out pos);
            return(pos);
        }
示例#7
0
        /// <summary>
        /// fetch the current record from the gateway
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        internal GatewayResult CursorGetCurrent(DbPos position)
        {
            GatewayCommandBase cursorCommand = new GatewayCommandCursorGetCurrent();

            CurrentCursor.CursorDefinition.CurrentPosition = position;
            cursorCommand.RuntimeCursor = CurrentCursor;
            cursorCommand.LocalManager  = LocalDataviewManager.LocalManager;
            return(cursorCommand.Execute());
        }
示例#8
0
        /// <summary>
        /// open cursor
        /// </summary>
        /// <param name="reverse"></param>
        /// <param name="startPosition"></param>
        /// <param name="useLocate">If this is the 1st access to the table, locate values should be considered.
        /// if not - use only ranges</param>
        /// <returns></returns>
        internal GatewayResult OpenCursor(bool reverse, DbPos startPosition, BoudariesFlags boundariesFlag)
        {
            CurrentCursor.CursorDefinition.SetFlagValue(CursorProperties.DirReversed, reverse);
            CurrentCursor.CursorDefinition.StartPosition = startPosition;

            // build the RangeData list
            CurrentCursor.RuntimeCursorData.Ranges = RangeBuilder.Build(boundariesFlag);

            GatewayCommandBase cursorCommand = GatewayCommandsFactory.CreateCursorOpenCommand(CurrentCursor, LocalDataviewManager.LocalManager);

            //String r = CurrentCursor.Serialize();

            return(cursorCommand.Execute());
        }
示例#9
0
        /// <summary>
        /// get the key of a specific position
        /// </summary>
        /// <param name="value"></param>
        /// <param name="viewId">id of view of the record</param>
        /// <returns></returns>
        internal PositionId GetKeyOfValue(DbPos value, int viewId)
        {
            if (positions.ContainsValue(value))
            {
                foreach (var item in positions)
                {
                    if (item.Value.Equals(value) && item.Key.ViewId == viewId)
                    {
                        return(item.Key);
                    }
                }
            }

            return(new PositionId(0));
        }
示例#10
0
 /// <summary>
 /// updates inscludesFirst/includeslast
 /// </summary>
 /// <param name="startPosition"></param>
 void UpdateViewBoundaries(DbPos startPosition)
 {
     if (startPosition.IsZero)
     {
         if (Reverse)
         {
             PositionCache.IncludesLast  = true;
             PositionCache.IncludesFirst = false;
         }
         else
         {
             PositionCache.IncludesFirst = true;
             PositionCache.IncludesLast  = false;
         }
     }
 }
示例#11
0
    IEnumerator Open()
    {
        inTransition          = true;
        spriteRenderer.sprite = intermediate;
        position                = DbPos.intermediate;
        _SwitchConducting       = false;
        Switch.SwitchConducting = _SwitchConducting;
        yield return(new WaitForSecondsRealtime(transitionTime));

        spriteRenderer.sprite = open;
        position            = DbPos.open;
        inTransition        = false;
        oldSwitchConducting = _SwitchConducting;
        if (operateDialog != null)
        {
            operateDialog.SetOperateResult(0);
        }
    }
示例#12
0
        /// <summary>
        /// fetch the current record
        /// </summary>
        /// <param name="record"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        internal override GatewayResult FetchCurrent(IRecord record)
        {
            GatewayResult result = new GatewayResult();

            result.ErrorCode = GatewayErrorCode.LostRecord;

            DbPos position = GetPosition(record);

            if (position != null)
            {
                result = CursorGetCurrent(position);
                if (result.Success)
                {
                    CopyValues(record);
                    base.FetchCurrent(record);
                }
            }
            return(result);
        }
示例#13
0
        /// <summary>
        /// delete cursor
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        internal GatewayResult DeleteRecord(IRecord record)
        {
            GatewayResult result = CheckTransactionValidation();

            if (result.Success)
            {
                DbPos pos = GetPosition(record);

                GatewayCommandBase cursorCommand = new GatewayCommandCursorDeleteRecord();
                cursorCommand.RuntimeCursor = CurrentCursor;
                CurrentCursor.CursorDefinition.CurrentPosition = pos;
                cursorCommand.LocalManager = LocalDataviewManager.LocalManager;
                result = cursorCommand.Execute();
                if (result.Success)
                {
                    ClearRecord(record);
                }
            }
            return(result);
        }
示例#14
0
        /// <summary>
        /// get Idx of Position passed in Position Cache.
        /// </summary>
        /// <param name="value"></param>
        internal int IdxOf(DbPos value)
        {
            int idx = -1;

            if (positions.ContainsValue(value))
            {
                int         i             = 0;
                IEnumerator posEnumerator = positions.Values.GetEnumerator();
                while (posEnumerator.MoveNext())
                {
                    DbPos currPos = (DbPos)posEnumerator.Current;

                    if (currPos.Equals(value))
                    {
                        return(i);
                    }
                    i++;
                }
            }
            return(idx);
        }
        /// <summary>
        /// find the start record and get its position
        /// </summary>
        /// <returns></returns>
        internal override ReturnResultBase Execute()
        {
            IRecord origRecord = DataviewSynchronizer.GetCurrentRecord();

            bool recordFound = FindMatchingRecord();

            if (recordFound)
            {
                // found a record - keep its position
                IRecord currentRecord = DataviewSynchronizer.GetCurrentRecord();
                DbPos   outPos;
                PositionCache.TryGetValue(new PositionId(currentRecord.getId()), out outPos);
                ResultStartPosition = outPos;
                LocalDataviewManager.Reset();
                DataviewSynchronizer.RemoveRecord(currentRecord);
            }
            else
            {
                DataviewSynchronizer.SetCurrentRecord(origRecord != null ? origRecord.getId() : Int32.MinValue);
            }

            return(new GatewayResult());
        }
示例#16
0
        /// <summary>
        /// open cursors
        /// </summary>
        /// <param name="reverse"> direction reverse</param>
        /// <param name="startPosition"> start position</param>
        /// <returns></returns>

        internal GatewayResult OpenCursors(bool reverse, DbPos startPosition)
        {
            ///vew_crsr_open
            ///

            GatewayResult result = new GatewayResult();

            if (ViewMain != null)
            {
                SortCollection userSortCollection = GetPrimaryView().LocalDataviewManager.UserSorts;

                //user sorts may have added in task prefix. So, apply them and use the sort key.
                if (userSortCollection != null && userSortCollection.getSize() > 0)
                {
                    ApplySort(userSortCollection);
                    ViewMain.CurrentCursor.CursorDefinition.Key = ViewMain.DataSourceViewDefinition.DbKey;
                }

                result = ViewMain.OpenCursor(reverse, startPosition, BoudariesFlags.Range);
            }

            return(result);
        }
示例#17
0
 public void SetBadState(bool value)
 {
     if (/*inTransition == false &&*/ value == true)
     {
         StopAllCoroutines();
         spriteRenderer.sprite = bad;
         position     = DbPos.bad;
         inTransition = true; // switch is blocked in bad state
         AlarmWindow.instance.SetAlarm("Sub_S42", gameObject.name, Name, "Controlable Switch failed", "On");
         if (operateDialog != null)
         {
             operateDialog.SetOperateResult(-2);
         }
     }
     if (value == false)//re-enable switch
     {
         AlarmWindow.instance.SetAlarm("Sub_S42", gameObject.name, Name, "Controllable Switch failed", "Off");
         inTransition = false;
         if (operateDialog != null)
         {
             operateDialog.SetOperateResult(2);
         }
     }
 }
示例#18
0
 /// <summary>
 /// get position value
 /// </summary>
 /// <param name="positionId"></param>
 /// <param name="position"></param>
 /// <returns></returns>
 internal bool TryGetValue(PositionId positionId, out DbPos position)
 {
     return(positions.TryGetValue(positionId, out position));
 }
示例#19
0
 /// <summary>
 /// Adds position value
 /// </summary>
 /// <param name="clientId"></param>
 /// <param name="position"></param>
 internal void Set(PositionId positionId, DbPos position)
 {
     positions[positionId] = position.Clone();
 }
示例#20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="startPosition"></param>
 public LocateNextRecordComputerBuilder(DbPos startPosition)
 {
     StartPosition = startPosition;
 }
示例#21
0
 /// <summary>
 /// is the position present in the cache?
 /// </summary>
 /// <param name="dbPos"></param>
 /// <returns></returns>
 internal bool ContainsValue(DbPos dbPos)
 {
     return(positions.ContainsValue(dbPos));
 }
示例#22
0
        //internal List<BlobInfo> BlobInfo;

        /// <summary>
        ///
        /// </summary>
        internal void CrsrInit(GatewayAdapterCursor dbCrsr, SQLiteGateway gtwyObj)
        {
            SQL3Dbd pSQL3Dbd = null;
            int     segs     = 0;

            PosKey = null;

            InUse          = true;
            XtraPoskeyCnt  = 0;
            XtraSortkeyCnt = 0;

            SQLiteGateway = gtwyObj;

            /* assign the gateway cursor id to the DB_CRSR structure */

            SQLiteGateway.DbdTbl.TryGetValue(dbCrsr.Definition.DataSourceDefinition, out pSQL3Dbd);

            Logger.Instance.WriteDevToLog(string.Format("CrsrInit(): >>>>> GTWY cursor cnt = %d", SQLiteGateway.GatewayCursorTbl.Count));

            Output = null;
            Input  = null;
            Ranges = new Sql3Sqldata(SQLiteGateway);

            StartPos = new Sql3Sqldata(SQLiteGateway);

            SearchKey = null;
            Key       = null;
            Update    = null;

            GcurrInput  = null;
            GcurrOutput = null;
            StmtRanges  = null;

            /* for cascading startpos */
            /* not direct sql */
            this.PosKey = SQLiteGateway.FindPoskey(dbCrsr.Definition.DataSourceDefinition);

            Sql3PrepareForTimeStamp(dbCrsr);

            if (pSQL3Dbd != null)
            {
                /* if there is a key */
                if (dbCrsr.Definition.Key != null)
                {
                    segs = dbCrsr.Definition.Key.Segments.Count + 1;
                }

                /*--------------------------------------------------------------*/
                /* fix bug #210900 - when no key selected - use the poskey segs */
                /*--------------------------------------------------------------*/
                else if (this.PosKey != null)
                {
                    segs = PosKey.Segments.Count;
                }
                else
                {
                    segs = 1;
                }

                Logger.Instance.WriteDevToLog(string.Format("CrsrInit(): segs in startpos = {0}", segs));
                StmtStartpos = new List <string>(segs);

                for (int i = 0; i < segs; i++)
                {
                    StmtStartpos.Add(null);
                }
            }

            StmtOrderBy     = null;
            StmtOrderByRev  = null;
            StmtInsert      = null;
            StmtDelete      = null;
            StmtUpdate      = null;
            StmtWhereKey    = null;
            StmtFields      = null;
            StmtKeyFields   = null;
            StmtExtraFields = null;
            StmtAllTables   = null;

            JoinStmtBuiltWithInnerJoin = false;
            StmtAllTablesUpdLock       = null;

            StmtAllTablesWithOtimizer = null;

            SourceDbh      = null;
            DbhPrefix      = null;
            StmtJoinCond   = null;
            StmtJoinRanges = null;
            StmtSqlRng     = null;
            /* created for optimizer hints in join tables but will be use always */
            StmtAllTablesWithOtimizer = null;


            StmtJoinCond   = null;
            StmtJoinRanges = null;
            StmtSqlRng     = null;
            OuterJoin      = false;

            if (dbCrsr.CursorType != CursorType.Join)
            {
                NullIndicator = new List <int>();
                for (int i = 0; i < dbCrsr.Definition.DataSourceDefinition.Fields.Count; i++)
                {
                    NullIndicator.Add(0);
                }
            }

            /* sql3_stmt structures */
            /* Stmt allocation will be done on demand */

            SReadA     = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("ReadA", crsr_hdl);  */
            sReadD     = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("ReadD", crsr_hdl);  */
            SRngA      = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("RngA", crsr_hdl);   */
            SRngD      = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("RngD", crsr_hdl);   */
            SStrt      = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("Strt", crsr_hdl);   */
            SGCurr     = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("Gcurr", crsr_hdl);  */
            SGCurrlock = SqliteConstants.NULL_STMT;
            SGKey      = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("Gkey", crsr_hdl);   */
            SInsert    = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("Ins", crsr_hdl);    */
            SUpdate    = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("Upd", crsr_hdl);    */
            SDelete    = SqliteConstants.NULL_STMT; /*  sql3_stmt_alloc ("Del", crsr_hdl);    */

            /* indexes to SQL3_CURSOR 's */
            /* Cusror allocation will also be done on demand */

            CRead   = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Read", crsr_hdl);  */
            CRange  = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Range", crsr_hdl); */
            CGcurr  = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Gcurr", crsr_hdl); */
            CGkey   = SqliteConstants.NULL_CURSOR; /* sql3_cursor_alloc ("Gkey", crsr_hdl);  */
            CInsert = SqliteConstants.NULL_CURSOR;

            LastPos = new DbPos(true);
            CurrPos = new DbPos(true);

            Logger.Instance.WriteDevToLog("CrsrInit(): <<<<< ");
        }
示例#23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="startPosition"></param>
 public LocateNextComputeStrategy(DbPos startPosition)
 {
     StartPosition = startPosition;
 }