Exemplo n.º 1
0
        public void VisitSegmentSkipsSegmentsWhenUseStructureLockerFalse()
        {
            // Arrange
            var text     = "matchtome";
            var settings = utility.CreateSettings(useSegmentLocker: false,
                                                  useStructureLocker: false, // false instead of true
                                                  contextDef: new ContextDef()
            {
                Type = text
            });

            var segment       = utility.CreateSegment();
            var paragraphUnit = utility.CreateParagraphUnit(text);

            segment.ParentParagraphUnit.Returns(paragraphUnit);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
Exemplo n.º 2
0
        public int ProcessHandPay(Treasury Treasury, int TE_ID)
        {
            LockHandler Lock = new LockHandler();

            int SPResult = TE_ID==0 ? 0: Lock.InsertLockRecord(0, Dns.GetHostName(), "ATTENDANTPAY", "TE_ID", TE_ID.ToString());
            int ReturnValue = -1;

            switch (SPResult)
            {
                case 0: ReturnValue= handPay.ProcessHandpay(Treasury, TE_ID);
                    if (TE_ID == 0) return ReturnValue;
                    break;
                case 1:
                    ReturnValue = -2;//LockExists
                    return ReturnValue;
                case 2:
                    ReturnValue = -3;//LockError
                    return ReturnValue;
                default:
                    ReturnValue = -4;//DatabaseError
                    return ReturnValue;

            }
            Lock.DeleteLockRecord(0, Dns.GetHostName(), "ATTENDANTPAY", "TE_ID", TE_ID.ToString());
            return ReturnValue;
                        
            
        }
Exemplo n.º 3
0
        public EnrollmentErrorCodes InstallMachine(PositionDetails PosDetails, int userid, out int installationNo)
        {
            LockHandler Lock = new LockHandler();
            EnrollmentErrorCodes ReturnValue;
            installationNo = 0;

            int SPResult = Lock.InsertLockRecord(userid, Dns.GetHostName(), "MACHINEADMIN", "POS", PosDetails.Position);
            switch (SPResult)
            {
                case 0: ReturnValue = enrollment.InstallMachine(PosDetails, out installationNo);

                    break;
                case 1:
                    ReturnValue = EnrollmentErrorCodes.LockExists;
                    break;
                case 2:
                    ReturnValue = EnrollmentErrorCodes.LockError;
                    break;
                default:
                    ReturnValue = EnrollmentErrorCodes.DatabaseError;
                    break;

            }
            Lock.DeleteLockRecord(userid, Dns.GetHostName(), "MACHINEADMIN", "POS", PosDetails.Position);
            return ReturnValue;

            
        }
        public int VoidTransaction(VoidTranCreate VoidTransactionEntity)
        {
            LockHandler Lock = new LockHandler();

            int SPResult = Lock.InsertLockRecord(0, Dns.GetHostName(), "VOID", "TreasuryID", VoidTransactionEntity.TreasuryID.ToString());
            int ReturnValue = -1;

            switch (SPResult)
            {
                case 0: ReturnValue = voidTransaction.VoidCreate(VoidTransactionEntity);
                    
                    break;
                case 1:
                    ReturnValue = -2;//LockExists
                    return ReturnValue;
                case 2:
                    ReturnValue = -3;//LockError
                    return ReturnValue;
                default:
                    ReturnValue = -4;//DatabaseError
                    return ReturnValue;

            }
            Lock.DeleteLockRecord(0, Dns.GetHostName(), "VOID", "TreasuryID", VoidTransactionEntity.TreasuryID.ToString());
            return ReturnValue;
            
            
            
        }
Exemplo n.º 5
0
        public EnrollmentErrorCodes InstallMachine(PositionDetails PosDetails, int userid, out int installationNo)
        {
            LockHandler          Lock = new LockHandler();
            EnrollmentErrorCodes ReturnValue;

            installationNo = 0;

            int SPResult = Lock.InsertLockRecord(userid, Dns.GetHostName(), "MACHINEADMIN", "POS", PosDetails.Position);

            switch (SPResult)
            {
            case 0: ReturnValue = enrollment.InstallMachine(PosDetails, out installationNo);

                break;

            case 1:
                ReturnValue = EnrollmentErrorCodes.LockExists;
                break;

            case 2:
                ReturnValue = EnrollmentErrorCodes.LockError;
                break;

            default:
                ReturnValue = EnrollmentErrorCodes.DatabaseError;
                break;
            }
            Lock.DeleteLockRecord(userid, Dns.GetHostName(), "MACHINEADMIN", "POS", PosDetails.Position);
            return(ReturnValue);
        }
Exemplo n.º 6
0
        public int ProcessHandPay(Treasury Treasury, int TE_ID)
        {
            LockHandler Lock = new LockHandler();

            int SPResult    = TE_ID == 0 ? 0: Lock.InsertLockRecord(0, Dns.GetHostName(), "ATTENDANTPAY", "TE_ID", TE_ID.ToString());
            int ReturnValue = -1;

            switch (SPResult)
            {
            case 0: ReturnValue = handPay.ProcessHandpay(Treasury, TE_ID);
                if (TE_ID == 0)
                {
                    return(ReturnValue);
                }
                break;

            case 1:
                ReturnValue = -2;    //LockExists
                return(ReturnValue);

            case 2:
                ReturnValue = -3;    //LockError
                return(ReturnValue);

            default:
                ReturnValue = -4;    //DatabaseError
                return(ReturnValue);
            }
            Lock.DeleteLockRecord(0, Dns.GetHostName(), "ATTENDANTPAY", "TE_ID", TE_ID.ToString());
            return(ReturnValue);
        }
        public int VoidTransaction(VoidTranCreate VoidTransactionEntity)
        {
            LockHandler Lock = new LockHandler();

            int SPResult    = Lock.InsertLockRecord(0, Dns.GetHostName(), "VOID", "TreasuryID", VoidTransactionEntity.TreasuryID.ToString());
            int ReturnValue = -1;

            switch (SPResult)
            {
            case 0: ReturnValue = voidTransaction.VoidCreate(VoidTransactionEntity);

                break;

            case 1:
                ReturnValue = -2;    //LockExists
                return(ReturnValue);

            case 2:
                ReturnValue = -3;    //LockError
                return(ReturnValue);

            default:
                ReturnValue = -4;    //DatabaseError
                return(ReturnValue);
            }
            Lock.DeleteLockRecord(0, Dns.GetHostName(), "VOID", "TreasuryID", VoidTransactionEntity.TreasuryID.ToString());
            return(ReturnValue);
        }
Exemplo n.º 8
0
        public void VisitSegmentDoesNotLockSegmentWhenWholeSegmentDoesNotMatch()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex    = true,
                SearchText = @"^[0-9]+$"
            });

            var segment         = utility.CreateSegment();
            var txt1            = utility.CreateText(text: "12345", segment: segment);
            var txt2            = utility.CreateText(text: "not a number", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt1);
            handler.VisitText(txt2);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
    private void Awake()
    {
        _containerHandler = GameObject.Find("Shop/ShopObj/ChampContainer").GetComponent <RollChampions>();
        _lockHandler      = GameObject.Find("Shop/ShopObj/ShopUi/LockButton").GetComponent <LockHandler>();
        rerollCost        = 2;

        goldUi = MyFunc.GetObject(MyFunc.ObjType.PLAYER_UI).GetComponent <GoldUi>();
        msg    = MyFunc.GetObject(MyFunc.ObjType.MESSAGE_BOX).GetComponent <MessageBox>();
    }
Exemplo n.º 10
0
        public void VisitSegmentThrowsOnNull()
        {
            var settings        = Substitute.For <ICleanUpSourceSettings>();
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            Assert.Throws <ArgumentNullException>(() => handler.VisitSegment(null));
        }
Exemplo n.º 11
0
 // Update is called once per frame
 void Update()
 {
     if (handler == null)
     {
         handler = GetComponentInParent <LockHandler>();
     }
     if (gazedAt && InputControl.GetButtonDown(Controls.buttons.fire1))
     {
         //Debug.LogError("Selecting: " + this.gameObject);
         OnPlayerEvent();
     }
     OnNoPlayerEvent();
 }
Exemplo n.º 12
0
        public MainForm()
        {
            _lockHandler           = new LockHandler();
            _lockHandler.Bind     += lockHandler_Bind;
            _lockHandler.Unbind   += lockHandler_Unbind;
            _lockHandler.FormShow += lockHandler_FormShow;
            _lockHandler.FormHide += lockHandler_FormHide;

            // Transparent background
            this.TransparencyKey = Color.White;
            this.BackColor       = Color.White;

            InitializeComponent();
        }
Exemplo n.º 13
0
        public void LockHandler_Unlock_Test()
        {
            Node node = CreateTestPage();

            LockHandler target = new LockHandler(node);

            if (!target.Locked)
            {
                target.Lock();
            }
            target.Unlock(VersionStatus.Approved, VersionRaising.None);

            Assert.IsTrue(!GetNodeInfo_Locked(node));
        }
Exemplo n.º 14
0
    static AssetLocker()
    {
        EditorApplication.update   += Update;
        Selection.selectionChanged += OnSelectionChanged;

        add       = new AddHandler();
        isTracked = new IsTrackedHandler();
        lck       = new LockHandler();
        unlock    = new UnlockHandler();
        isLocked  = new IsLockedHandler();
        getInfo   = new GetInfoHandler();

        lockedInfo = new Dictionary <string, Asset>();
        Debug.Log("AssetLocker initialized");
    }
Exemplo n.º 15
0
        public void LockHandler_Lock_LockedTest()
        {
            Node node = CreateTestPage();

            LockHandler target = new LockHandler(node);

            target.Lock();
            DateTime dt1 = target.LastLockUpdate;

            Thread.Sleep(10);

            target.Lock();
            DateTime dt2 = target.LastLockUpdate;

            Assert.IsTrue(dt1 < dt2);
        }
Exemplo n.º 16
0
        public void Open(string path)
        {
            _path = path;
            _doc  = new XmlDocument();
            _doc.Load(path);
            _doc.PreserveWhitespace = true;

            _nsmgr = new XmlNamespaceManager(_doc.NameTable);
            _nsmgr.AddNamespace("o", "urn:oasis:names:tc:xliff:document:1.2");
            _nsmgr.AddNamespace("s", "http://sdl.com/FileTypes/SdlXliff/1.0");
            _nsmgr.AddNamespace("sdl", "http://sdl.com/FileTypes/SdlXliff/1.0");

            _commenter           = new CommentHandler(_doc, _nsmgr);
            _locker              = new LockHandler(_doc, _nsmgr, _commenter);
            _selector            = new SegmentSelector(_doc, _nsmgr, _commenter, _locker);
            _selector.GetContext = true;
        }
Exemplo n.º 17
0
    // Use this for initialization
    void Start()
    {
        EventTrigger trigger = gameObject.AddComponent <EventTrigger>();

        EventTrigger.Entry entry = new EventTrigger.Entry();
        entry.eventID = EventTriggerType.PointerEnter;
        entry.callback.AddListener((d) => { SetGazedAt(true); });
        trigger.triggers.Add(entry);
        entry         = new EventTrigger.Entry();
        entry.eventID = EventTriggerType.PointerExit;
        entry.callback.AddListener((data) => { SetGazedAt(false); });
        trigger.triggers.Add(entry);

        myRenderer = GetComponent <Renderer>();
        //inactiveMaterial = new Material(myRenderer.material);
        //gazedAtMaterial = Color.yellow;
        handler = GetComponentInParent <LockHandler>();
    }
Exemplo n.º 18
0
        public void LockHandler_RefreshLock_Test()
        {
            Node node = CreateTestPage();

            LockHandler target = new LockHandler(node);

            if (!target.Locked)
            {
                target.Lock();
            }
            long time = GetNodeInfo_LastLockUpdate(node).Ticks;

            Thread.Sleep(10);

            target.RefreshLock();

            Assert.IsTrue(GetNodeInfo_LastLockUpdate(node).Ticks > time);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Execute the given callback having optionally acquired the given lock.
        /// Because CMT assumes that the connection is already part of a managed
        /// transaction, it does not attempt to commit or rollback the
        /// enclosing transaction.
        /// </summary>
        /// <seealso cref="JobStoreSupport.ExecuteInNonManagedTXLock" />
        /// <seealso cref="JobStoreSupport.ExecuteInLock" />
        /// <seealso cref="JobStoreSupport.GetNonManagedTXConnection()" />
        /// <seealso cref="JobStoreSupport.GetConnection()" />
        /// <param name="lockName">
        /// The name of the lock to acquire, for example
        /// "TRIGGER_ACCESS".  If null, then no lock is acquired, but the
        /// txCallback is still executed in a transaction.
        /// </param>
        /// <param name="txCallback">Callback to execute.</param>
        /// <param name="cancellationToken">The cancellation instruction.</param>
        protected override async Task <T> ExecuteInLock <T>(
            string lockName,
            Func <ConnectionAndTransactionHolder, Task <T> > txCallback,
            CancellationToken cancellationToken = default)
        {
            bool transOwner = false;
            ConnectionAndTransactionHolder conn = null;
            Guid requestorId = Guid.NewGuid();

            try
            {
                if (lockName != null)
                {
                    // If we aren't using db locks, then delay getting DB connection
                    // until after acquiring the lock since it isn't needed.
                    if (LockHandler.RequiresConnection)
                    {
                        conn = GetNonManagedTXConnection();
                    }

                    transOwner = await LockHandler.ObtainLock(requestorId, conn, lockName, cancellationToken).ConfigureAwait(false);
                }

                if (conn == null)
                {
                    conn = GetNonManagedTXConnection();
                }

                return(await txCallback(conn).ConfigureAwait(false));
            }
            finally
            {
                try
                {
                    await ReleaseLock(requestorId, lockName, transOwner, cancellationToken).ConfigureAwait(false);
                }
                finally
                {
                    CleanupConnection(conn);
                }
            }
        }
Exemplo n.º 20
0
        public void LockHandler_Lock_Test()
        {
            Node node = CreateTestPage();

            LockHandler target = new LockHandler(node);

            if (target.Locked)
            {
                target.Unlock(VersionStatus.Approved, VersionRaising.None);
            }
            target.Lock();

            Assert.IsTrue(
                !(string.IsNullOrEmpty(GetNodeInfo_LockToken(node))) &&
                GetNodeInfo_LockedById(node) == User.Current.Id &&
                GetNodeInfo_LockDate(node) != DateTime.MinValue &&
                GetNodeInfo_LastLockUpdate(node) != DateTime.MinValue &&
                GetNodeInfo_LockTimeout(node) > 0
                );
        }
Exemplo n.º 21
0
        /// <summary>
        /// Execute the given callback having optionally acquired the given lock.
        /// Because CMT assumes that the connection is already part of a managed
        /// transaction, it does not attempt to commit or rollback the
        /// enclosing transaction.
        /// </summary>
        /// <seealso cref="JobStoreSupport.ExecuteInNonManagedTXLock(string,System.Func{Quartz.Impl.AdoJobStore.ConnectionAndTransactionHolder,object})" />
        /// <seealso cref="JobStoreTX.ExecuteInLock(string,System.Func{Quartz.Impl.AdoJobStore.ConnectionAndTransactionHolder,object})" />
        /// <seealso cref="JobStoreSupport.GetNonManagedTXConnection()" />
        /// <seealso cref="JobStoreSupport.GetConnection()" />
        /// <param name="lockName">
        /// The name of the lock to acquire, for example
        /// "TRIGGER_ACCESS".  If null, then no lock is acquired, but the
        /// txCallback is still executed in a transaction.
        /// </param>
        /// <param name="txCallback">Callback to execute.</param>
        protected override object ExecuteInLock(
            string lockName,
            Func <ConnectionAndTransactionHolder, object> txCallback)
        {
            bool transOwner = false;
            ConnectionAndTransactionHolder conn = null;

            try
            {
                if (lockName != null)
                {
                    // If we aren't using db locks, then delay getting DB connection
                    // until after acquiring the lock since it isn't needed.
                    if (LockHandler.RequiresConnection)
                    {
                        conn = GetNonManagedTXConnection();
                    }

                    transOwner = LockHandler.ObtainLock(DbMetadata, conn, lockName);
                }

                if (conn == null)
                {
                    conn = GetNonManagedTXConnection();
                }

                return(txCallback(conn));
            }
            finally
            {
                try
                {
                    ReleaseLock(LockTriggerAccess, transOwner);
                }
                finally
                {
                    CleanupConnection(conn);
                }
            }
        }
Exemplo n.º 22
0
        public void VisitSegmentsLocksSegmentsOnNormalMatch()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex    = false,
                SearchText = "123"
            });

            var segment         = utility.CreateSegment();
            var txt             = utility.CreateText(text: "ABCabc123%- ", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.True(segment.Properties.IsLocked);
        }
Exemplo n.º 23
0
        public void VisitSegmentIgnoresInvalidRegexExpressions()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex    = true,
                SearchText = @"^[ ("
            });

            var segment         = utility.CreateSegment(isLocked: false);
            var txt             = utility.CreateText(text: "whatever", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
Exemplo n.º 24
0
        public void VisitTextDoesNotLockSegmentOnWholeWordNoMatch()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                WholeWord  = true,
                SearchText = @"d"
            });

            var segment         = utility.CreateSegment();
            var txt             = utility.CreateText(text: "hidden dad dear red", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
Exemplo n.º 25
0
        public void VisitSegmentIgnoresSegmentsOnCaseSensitiveRegex()
        {
            // Arrange
            var settings = utility.CreateSettings(useContentLocker: true,
                                                  segmentLockItem: new SegmentLockItem()
            {
                IsRegex         = true,
                IsCaseSensitive = true,
                SearchText      = @"[A-Z]+"
            });

            var segment         = utility.CreateSegment();
            var txt             = utility.CreateText(text: "abcdefg", segment: segment);
            var itemFactory     = Substitute.For <IDocumentItemFactory>();
            var reporter        = Substitute.For <ICleanUpMessageReporter>();
            var reportGenerator = Substitute.For <IXmlReportGenerator>();
            var handler         = new LockHandler(settings, itemFactory, reporter, reportGenerator);

            // Act
            handler.VisitText(txt);
            handler.VisitSegment(segment);

            Assert.False(segment.Properties.IsLocked);
        }
        public bool DeclarePartCollection(int userID,int Part_Collection_No)
        {
            var lockHelper = new LockHandler(exchangeConnectionString);
            _collectionDataContext.SavePartDeclaration(Dns.GetHostName(), userID, Part_Collection_No);
          
            return true;

        }
Exemplo n.º 27
0
        private void HandleConnection(Socket sock)
        {
            NetworkStream stream    = new NetworkStream(sock);
            string        line      = null;
            bool          error     = false;
            bool          keepAlive = false;
            DateTime      startTime = DateTime.Now;

            sock.ReceiveTimeout      = RequestHandler.Timeout * 100;
            sock.Blocking            = false;
            sock.NoDelay             = true;
            sock.SendBufferSize      = 16 * 1024;
            sock.UseOnlyOverlappedIO = true;

            string type = "";
            string path = "";

            do
            {
                bool           first   = true;
                RequestHandler handler = null;

                do
                {
                    line = null;
                    try
                    {
                        line             = ReadLine(stream);
                        BytesReadHeader += line.Length + 2;
                    }
                    catch (ThreadAbortException e)
                    {
                        keepAlive = false;
                        error     = true;
                        break;
                    }
                    catch (IOException e)
                    {
                        keepAlive = false;
                        error     = true;
                        break;
                    }
                    catch (Exception e)
                    {
                        keepAlive = false;
                        error     = true;
                        break;
                    }

                    /* connection timed out or closed */
                    if (line == null)
                    {
                        sock.Close();
                        LogRequest("  (Socket closed)");
                        return;
                    }

                    if (first)
                    {
                        LogRequest("  (Connection from " + sock.RemoteEndPoint + ")");
                    }
                    LogRequest("< " + line);

                    /* not an empty line? */
                    if (line != "")
                    {
                        /* the first line contains the request */
                        if (first)
                        {
                            if (line.Contains(' '))
                            {
                                type = line.Substring(0, line.IndexOf(' '));
                                path = line.Substring(line.IndexOf(' ')).Trim();
                                try
                                {
                                    switch (type)
                                    {
                                    case "OPTIONS":
                                        handler = new OptionsHandler(this, path);
                                        break;

                                    case "PROPFIND":
                                        handler = new PropFindHandler(this, path);
                                        break;

                                    case "GET":
                                        handler = new GetHandler(this, path);
                                        break;

                                    case "HEAD":
                                        handler = new HeadHandler(this, path);
                                        break;

                                    case "PUT":
                                        handler = new PutHandler(this, path);
                                        break;

                                    case "LOCK":
                                        handler = new LockHandler(this, path);
                                        break;

                                    case "UNLOCK":
                                        handler = new UnlockHandler(this, path);
                                        break;

                                    case "DELETE":
                                        handler = new DeleteHandler(this, path);
                                        break;

                                    case "MOVE":
                                        handler = new MoveHandler(this, path);
                                        break;

                                    case "COPY":
                                        handler = new CopyHandler(this, path);
                                        break;

                                    case "MKCOL":
                                        handler = new MkColHandler(this, path);
                                        break;

                                    case "PROPPATCH":
                                        handler = new PropPatchHandler(this, path);
                                        break;

                                    default:
                                        handler = new RequestHandler(this, "/");
                                        break;
                                    }
                                }
                                catch (IOException e)
                                {
                                    Log("[i] Connection from " + sock.RemoteEndPoint + " (" + type + ") had IOException");
                                }
                                catch (Exception e)
                                {
                                    Log("[E] '" + e.GetType().ToString() + "' in connection from " + sock.RemoteEndPoint + " (" + type + ")");
                                }
                            }

                            first = false;
                        }
                        else
                        {
                            try
                            {
                                handler.AddHeaderLine(line);
                            }
                            catch (IOException e)
                            {
                                /* just close */
                                sock.Close();
                                LogRequest("  (Socket closed)");
                                return;
                            }
                            catch (Exception e)
                            {
                                Log("[E] '" + e.GetType().ToString() + "' in connection from " + sock.RemoteEndPoint + " (AddHeaderLine)");
                            }
                            //stream.Flush();
                        }
                    }
                } while (line != "");

                if (handler == null)
                {
                    Log("[E] Empty request in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)");
                    handler.KeepAlive = false;
                    return;
                }

                if (!error)
                {
                    try
                    {
                        if (handler.RequestContentLength > 0)
                        {
                            handler.HandleContent(stream);
                        }

                        handler.HandleRequest(stream);
                        stream.Flush();
                    }
                    catch (FileNotFoundException e)
                    {
                        Log("[E] 404 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)");

                        /* respond with error */
                        handler            = new RequestHandler(this, "/");
                        handler.StatusCode = RequestHandler.GetStatusCode(404);
                        handler.KeepAlive  = false;
                        handler.HandleRequest(stream);
                        stream.Flush();
                    }
                    catch (SocketException e)
                    {
                        Log("[E] '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)");
                        handler.KeepAlive = false;
                        return;
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        Log("[i] 403 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)");

                        /* respond with error */
                        handler            = new RequestHandler(this, "/");
                        handler.StatusCode = RequestHandler.GetStatusCode(403);
                        handler.KeepAlive  = false;
                        handler.HandleRequest(stream);
                        stream.Flush();
                    }
                    catch (Exception e)
                    {
                        Log("[E] 500 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)");

                        /* respond with error */
                        handler            = new RequestHandler(this, "/");
                        handler.StatusCode = RequestHandler.GetStatusCode(500);
                        handler.KeepAlive  = false;
                        handler.HandleRequest(stream);
                        stream.Flush();
                    }


                    if (EnableRequestLog)
                    {
                        DateTime endTime = DateTime.Now;
                        Log("[i] Connection from " + sock.RemoteEndPoint + " (" + type + " " + path + ") took " + (endTime - startTime).TotalMilliseconds + " ms (" + handler.StatusCode + ")");
                    }
                    LogRequest("");

                    lock (StatisticsLock)
                    {
                        BytesWrittenHeader += handler.BytesWrittenHeader;
                        BytesWrittenData   += handler.BytesWrittenData;
                        BytesReadHeader    += handler.BytesReadHeader;
                        BytesReadData      += handler.BytesReadData;
                    }

                    keepAlive = handler.KeepAlive;

                    /* windows isnt really using keepalive :( */
                    keepAlive = false;
                }
            } while (keepAlive);

            sock.Close();
            LogRequest("  (Socket closed)");
        }
        //
        #endregion STM Methods
        //
        #endregion Functionality Methods
        //
        #region Event Methods
        //
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            int iResult = 0;
            LockHandler Lock = new LockHandler();
            //
            try
            {
                MarkSelectedMachines();
                if (TOTAL_SELECTED_MACHINES <= 0)
                {
                    MessageBox.ShowBox(iResult == -1 ? "MessageID378" : "MessageID80", BMC_Icon.Information);
                    return;
                }
                if ((rdoFinalCount.IsChecked == true) && (!AbandonCreditonAutoDrop()))
                {
                    return;
                }
                int m_count = 0;
                StringBuilder strMsg = new StringBuilder();
                foreach (int installation_no in _selectedInstallationNos)
                {
                    if (m_count > 3)
                    {
                        break;
                    }
                    if (!_collectionHelper.IsUndeclaredPartCollection(installation_no))
                    {
                        strMsg.Append(GetStockNo(installation_no) + ",");
                        m_count++;
                    }

                }
                if (strMsg.Length > 0)
                {
                    strMsg = strMsg.Remove(strMsg.Length-1, 1);
                    if (m_count > 3)
                    {
                        strMsg.Append("... ");
                    }
                    MessageBox.ShowBox(System.Windows.Application.Current.FindResource("MessageID82a").ToString().Replace("@@@@@", strMsg.ToString()),BMC_Icon.Information, true);
                    PopulateActiveMachine(true);
                    return;
                }
                //
                iResult = Lock.InsertLockRecord(0, "", "AUTODROP", "START", "START");
                LogManager.WriteLog("AUTODROP Lock Result: " + iResult.ToString(), LogManager.enumLogLevel.Debug);
                if (iResult == 1)
                {
                    MessageBox.ShowBox("MessageID380", BMC_Icon.Error);
                    InitializeAutoDropSession();
                    return;
                }
                //
                StartDropSession();
                //
                InitializeAutoDropSession();
                isADropStarted = true;

            }
            catch (Exception ex)
            {
                EnableDisableAutoDropScreen(true);
                Lock.DeleteLockRecord(0, "", "AUTODROP", "START", "START");
                LogError("btnStart_Click", ex);
                isADropStarted = false;
            }

        }
        private void btnVoid_Click(object sender, RoutedEventArgs e)
        {

            int iVoid;
            int iResult = 0;
            LockHandler Lock = new LockHandler();

            if (dgHandpay.Items.Count > 0)
            {
                if (dgHandpay.SelectedItem != null)
                {
                    sPos = "";
                    sTEid = "";
                    FillTreasuryList handpay_Fill = dgHandpay.SelectedItem as FillTreasuryList;
                    sPos = handpay_Fill.Pos;
                    sTEid = handpay_Fill.TE_ID.ToString();
                    iResult = Lock.InsertLockRecord(0, "", "HANDPAY", "HP", sTEid);
                    //
                    if (iResult == 1)
                    {
                        MessageBox.ShowBox("MessageID380", BMC_Icon.Error);
                        return;
                    }
                    if (MessageBox.ShowBox("MessageID109", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        if (Clearhandpay(Convert.ToInt32(handpay_Fill.Installation_No)))
                        {
                            IsHandpayVoid = true;
                            ProcessHandpay(true);

                            if (Treasury_No < 0 || Treasury_No == 0)
                                return;
                            iVoid = VoidHandpay();

                            try
                            {

                                Asset = handpay_Fill.Asset.ToString();
                                VoidAmount = handpay_Fill.Amount;
                                if (iVoid > 0)
                                {
                                    MessageBox.ShowBox("MessageID110", BMC_Icon.Information);

                                    // Newly Added by Venkatesh Kumar.J - SGVI Requirements
                                    if (!Settings.CAGE_ENABLED)
                                        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, handpay_Fill.HP_Type, iVoid.ToString());
                                    //if (VoidAmount > Settings.W2GWinAmount)
                                    //{
                                    //    if (Settings.W2GMessage)
                                    //    {
                                    //        if (AppSettings.IsReceiptRequired && !Settings.CAGE_ENABLED)
                                    //        {

                                    //            (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, handpay_Fill.HP_Type, iVoid.ToString());


                                    //        }
                                    //    }
                                    //}

                                    //else
                                    //{
                                    //    if (VoidAmount <= Settings.W2GWinAmount && !Settings.CAGE_ENABLED)
                                    //    {
                                    //        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, handpay_Fill.HP_Type, iVoid.ToString());

                                    //    }

                                    //}



                                    //if (AppSettings.IsReceiptRequired && (!Settings.CAGE_ENABLED))
                                    //{
                                    //    (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, handpay_Fill.HP_Type, iVoid.ToString());
                                    //}

                                    //-----------Untill Here-------------------------------

                                    string TreasuryDate = handpay_Fill.TreasuryDate.ToString();
                                    string Amount = handpay_Fill.Amount.ToString();
                                    string TreasuryNo = handpay_Fill.TE_ID.ToString();
                                    string TreasuryType = handpay_Fill.HP_Type;
                                    string amount = BMC.Business.CashDeskOperator.CommonUtilities.GetCurrency(Convert.ToDouble(Amount));

                                    //FillTreasury((dgHandpay.SelectedItem as FillTreasuryList).Pos);
                                    FillTreasury(string.Empty);
                                    //BindListView();
                                    // Helper_classes.Common.BindListView(treasuryList, dgHandpay);

                                    dgHandpay.ItemsSource = treasuryList;

                                    if (Settings.CAGE_ENABLED)
                                    {
                                        jackpotProcessInfoDTO jpinfo = new jackpotProcessInfoDTO();
                                        jpinfo.Slot = this.BarPosition;
                                        jpinfo.assetConfigNumber = Asset;
                                        jpinfo.Denom = 0.01M;

                                        jpinfo.jackpotTypeId = handpay_Fill.HP_Type.ToLower() == "attendantpay Credit" ? Convert.ToInt16(1) :
                                                         handpay_Fill.HP_Type.ToLower() == "attendantpay jackpot" ? Convert.ToInt16(2) :
                                                         handpay_Fill.HP_Type.ToLower() == "progressive" ? Convert.ToInt16(3) : Convert.ToInt16(1);


                                        jpinfo.Slot = handpay_Fill.Pos;
                                        jpinfo.assetConfigNumber = Asset;

                                        double value = 0;
                                        double.TryParse(Amount, out value);
                                        jpinfo.hpjpAmount = (long)(-1 * (value * 100));
                                        try { jpinfo.jackpotNetAmount = (long)value; }
                                        catch { }


                                        double.TryParse(TreasuryNo, out value);
                                        jpinfo.sequenceNumber = (long)value;

                                        jpinfo.TransactionDate = TreasuryDate;
                                        jpinfo.UserID = Security.SecurityHelper.CurrentUser.SecurityUserID.ToString();
                                        jpinfo.siteNo = Settings.SiteName;
                                        jpinfo.siteId = Convert.ToInt32(Settings.SiteCode);
                                        //Commented for not printing in cage slip format

                                        handpay.PrintSlip(jpinfo);
                                    }
                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {

                                        AuditModuleName = ModuleName.Void,
                                        Audit_Screen_Name = "Postion Details|Attendant Pay|Void",
                                        Audit_Desc = TreasuryType + " Date: " + TreasuryDate + " Amount:" + amount,
                                        AuditOperationType = OperationType.ADD,
                                        Audit_Field = "Treasury Number",
                                        Audit_New_Vl = TreasuryNo,
                                        Audit_Slot = Asset
                                    });
                                    //BMC.Business.CashDeskOperator.CommonUtilities.GetCurrency(0.00)
                                }
                                else if (iVoid == -1)
                                    MessageBox.ShowBox("MessageID111", BMC_Icon.Information);
                                else
                                {
                                    MessageBox.ShowBox("MessageID113", BMC_Icon.Error);

                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {
                                        AuditModuleName = ModuleName.Void,
                                        Audit_Screen_Name = "Postion Details|Attendant Pay|Void",
                                        Audit_Desc = "Error occured while voiding this transaction.",
                                        AuditOperationType = OperationType.ADD,
                                        Audit_Slot = Asset
                                    });
                                }
                            }
                            catch (Exception Ex)
                            {
                                ExceptionManager.Publish(Ex);
                                MessageBox.ShowBox("MessageID113", BMC_Icon.Error);
                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {
                                    AuditModuleName = ModuleName.Void,
                                    Audit_Screen_Name = "Postion Details|Attendant Pay|Void",
                                    Audit_Desc = "Error occured while voiding this transaction.",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Slot = Asset
                                });
                            }
                        }
                        else
                        {
                            MessageBox.ShowBox("MessageID382", BMC_Icon.Information);
                        }
                    }
                    Lock.DeleteLockRecord(0, "", "HANDPAY", "HP", sTEid);
                }
                else
                    MessageBox.ShowBox("MessageID114", BMC_Icon.Information);
            }
            else
                MessageBox.ShowBox("MessageID115", BMC_Icon.Information);
        }
 public void BindLockHandler(LockHandler handler)
 {
     SimpleGrpcMessageLayer.Instance.BindLockHandler(handler);
 }
        private void btnProcess_Click(object sender, RoutedEventArgs e)
        {
            int iResult = 0;
            LockHandler Lock = new LockHandler();
            btnProcess.IsEnabled = false;


            try
            {
                if (lstHandpay.Items.Count > 0)
                {
                    if (lstHandpay.SelectedItem != null)
                    {
                        sPos = "";
                        sTEid = "";

                        sPos = Convert.ToString((lstHandpay.SelectedItem as FillTreasuryList).Pos);
                        sTEid = Convert.ToString((lstHandpay.SelectedItem as FillTreasuryList).TE_ID);

                        /*Lock the Handpay Process Transaction*/
                        iResult = Lock.InsertLockRecord(0, "", "HANDPAY", "HP", sTEid);
                        LogManager.WriteLog("Lock Result: " + iResult.ToString(), LogManager.enumLogLevel.Debug);
                        if (iResult == 1)
                        {
                            MessageBox.ShowBox("MessageID380", BMC_Icon.Error);
                            return;
                        }

                        if (MessageBox.ShowBox("MessageID106", BMC_Icon.Question, BMC_Button.YesNo) ==
                            System.Windows.Forms.DialogResult.Yes)
                        {
                            btnProcess.IsEnabled = false;
                            if (Clearhandpay(Convert.ToInt32((lstHandpay.SelectedItem as FillTreasuryList).Installation_No)))
                            {
                                ProcessHandpay(false);

                            }
                            else
                            {
                                MessageBox.ShowBox("MessageID382", BMC_Icon.Information);
                            }
                        }
                        Lock.DeleteLockRecord(0, "", "HANDPAY", "HP", sTEid);
                        // btnProcess.IsEnabled = true;
                    }
                    else
                        MessageBox.ShowBox("MessageID107", BMC_Icon.Information);
                }
                else
                    MessageBox.ShowBox("MessageID108", BMC_Icon.Information);
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                LogManager.WriteLog("Process Handpay Exception", LogManager.enumLogLevel.Debug);
            }
            finally
            {

                btnProcess.IsEnabled = true;
            }

        }
        private void btnVoid_Click(object sender, RoutedEventArgs e)
        {
            int iVoid;
            int iResult = 0;
            LockHandler Lock = new LockHandler();

            if (lstHandpay.Items.Count > 0)
            {
                if (lstHandpay.SelectedItem != null)
                {
                    sPos = "";
                    sTEid = "";
                    sPos = Convert.ToString((lstHandpay.SelectedItem as FillTreasuryList).Pos);
                    sTEid = Convert.ToString((lstHandpay.SelectedItem as FillTreasuryList).TE_ID);
                    iResult = Lock.InsertLockRecord(0, "", "HANDPAY", "HP", sTEid);
                    //
                    if (iResult == 1)
                    {
                        MessageBox.ShowBox("MessageID380", BMC_Icon.Error);
                        return;
                    }
                    if (MessageBox.ShowBox("MessageID109", BMC_Icon.Question, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        if (Clearhandpay(Convert.ToInt32((lstHandpay.SelectedItem as FillTreasuryList).Installation_No)))
                        {
                            IsHandpayVoid = true;
                            ProcessHandpay(true);
                            if (Treasury_No < 0 || Treasury_No == 0)
                                return;
                            iVoid = VoidHandpay();

                            try
                            {

                                string TreasuryDate = (lstHandpay.SelectedItem as FillTreasuryList).TreasuryDate.ToString();
                                string Amount = (lstHandpay.SelectedItem as FillTreasuryList).Amount.ToString();
                                string TreasuryNo = (lstHandpay.SelectedItem as FillTreasuryList).TE_ID.ToString();
                                string TreasuryType = (lstHandpay.SelectedItem as FillTreasuryList).HP_Type;
                                string amount = BMC.Business.CashDeskOperator.CommonUtilities.GetCurrency(Convert.ToDouble(Amount));
                                string Position = (lstHandpay.SelectedItem as FillTreasuryList).Pos.ToString();

                                Asset = (lstHandpay.SelectedItem as FillTreasuryList).Asset.ToString();
                                VoidAmount = (lstHandpay.SelectedItem as FillTreasuryList).Amount;

                                if (iVoid > 0)
                                {
                                    MessageBox.ShowBox("MessageID110", BMC_Icon.Information);
                                    if (!Settings.CAGE_ENABLED)
                                    {
                                        oCommonUtilities objCommUtil = oCommonUtilities.CreateInstance();

                                        objCommUtil.PrintCommonReceipt(true, TreasuryType, iVoid.ToString());
                                    }
                                    // Already handled in the CAGE Printslip

                                    // Newly Added - Venkatesh Kumart.J - SGVI Requirements

                                    ////if (VoidAmount> Settings.W2GWinAmount)
                                    ////{
                                    ////    if (Settings.W2GMessage)
                                    ////    {
                                    ////        if (AppSettings.IsReceiptRequired && !Settings.CAGE_ENABLED)
                                    ////        {

                                    ////            (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, (lstHandpay.SelectedItem as FillTreasuryList).HP_Type, iVoid.ToString());


                                    ////        }
                                    ////    }
                                    ////}

                                    ////else
                                    ////{
                                    ////    if (VoidAmount <= Settings.W2GWinAmount && !Settings.CAGE_ENABLED)
                                    ////    {
                                    ////        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, (lstHandpay.SelectedItem as FillTreasuryList).HP_Type, iVoid.ToString());
                                    ////    }

                                    ////}

                                    //if (AppSettings.IsReceiptRequired)
                                    //{
                                    //    if (!Settings.CAGE_ENABLED)
                                    //        (oCommonUtilities.CreateInstance()).PrintCommonReceipt(true, (lstHandpay.SelectedItem as FillTreasuryList).HP_Type, iVoid.ToString());
                                    //}

                                    //-----------------Untill Here -------------------------



                                    FillTreasury(Position);
                                    //BindListView();
                                    Helper_classes.Common.BindListView(treasuryList, lstHandpay);

                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {

                                        AuditModuleName = ModuleName.Void,
                                        Audit_Screen_Name = "Postion Details|Attendant Pay|Void",
                                        Audit_Desc = TreasuryType + " Date: " + TreasuryDate + " Amount:" + Amount,
                                        AuditOperationType = OperationType.ADD,
                                        Audit_Field = "Treasury Number",
                                        Audit_New_Vl = TreasuryNo,
                                        Audit_Slot = Asset
                                    });
                                    //BMC.Business.CashDeskOperator.CommonUtilities.GetCurrency(0.00)
                                }
                                else if (iVoid == -1)
                                    MessageBox.ShowBox("MessageID111", BMC_Icon.Information);
                                else
                                {
                                    MessageBox.ShowBox("MessageID113", BMC_Icon.Error);

                                    AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                    {

                                        AuditModuleName = ModuleName.Void,
                                        Audit_Screen_Name = "Postion Details|Attendant Pay|Void",
                                        Audit_Desc = "Error occured while voiding this transaction.",
                                        AuditOperationType = OperationType.ADD,
                                        Audit_Slot = Asset
                                    });
                                }
                            }
                            catch (Exception Ex)
                            {
                                ExceptionManager.Publish(Ex);
                                MessageBox.ShowBox("MessageID113", BMC_Icon.Error);
                                AuditViewerBusiness.InsertAuditData(new Audit.Transport.Audit_History
                                {

                                    AuditModuleName = ModuleName.Void,
                                    Audit_Screen_Name = "Postion Details|Attendant Pay|Void",
                                    Audit_Desc = "Error occured while voiding this transaction.",
                                    AuditOperationType = OperationType.ADD,
                                    Audit_Slot = Asset
                                });

                            }
                        }
                        else
                        {
                            MessageBox.ShowBox("MessageID382", BMC_Icon.Information);
                        }
                    }

                    Lock.DeleteLockRecord(0, "", "HANDPAY", "HP", sTEid);
                }
                else
                    MessageBox.ShowBox("MessageID114", BMC_Icon.Information);
            }
            else
                MessageBox.ShowBox("MessageID115", BMC_Icon.Information);
        }
Exemplo n.º 33
0
 public void BindLockHandler(LockHandler handler)
 {
     lockHandler = handler;
 }
 private void InitLockHander()
 {
     _lockHandler = new LockHandler(this);
     _lockHandler.LockStateChanged += OnLockStateChanged;
     _lockHandler.LockError        += OnLockError;
 }
        public bool SaveFullCollection(UndeclaredCollectionRecord undeclaredCollectionRecord, int userId)
        {
            var collectionType = undeclaredCollectionRecord.Type == "Defloat" ? "DC" : "FC";
            if (InsertCollectionDeclaration(collectionType, undeclaredCollectionRecord.InstallationNo,
                                               undeclaredCollectionRecord.CollectionNo, userId, undeclaredCollectionRecord.TotalAmountValue > 0 ? true : false, false, false, 0.175,
                                               false,
                                               undeclaredCollectionRecord.TotalCoinsValue, 0, 0, undeclaredCollectionRecord.HandpayValue, 0, 0, 0, 0, 0, 0, 0, undeclaredCollectionRecord.P1, undeclaredCollectionRecord.P2, undeclaredCollectionRecord.P5, undeclaredCollectionRecord.P10, undeclaredCollectionRecord.P20, undeclaredCollectionRecord.P50, undeclaredCollectionRecord.P100, undeclaredCollectionRecord.P200, undeclaredCollectionRecord.P500, undeclaredCollectionRecord.P1000,
                                               undeclaredCollectionRecord.P2000, undeclaredCollectionRecord.P5000, undeclaredCollectionRecord.P10000, undeclaredCollectionRecord.P20000, undeclaredCollectionRecord.P50000, undeclaredCollectionRecord.P100000, undeclaredCollectionRecord.TicketsInValue, 0, 0, 0, 0, 0, 0, 0, 0, 0) == 0)
            {
                LogManager.WriteLog("InsertCollectonDeclaration", LogManager.enumLogLevel.Info);
                var lockHelper = new LockHandler(exchangeConnectionString);
                lockHelper.DeleteLockRecord(userId, Dns.GetHostName(), "COLLECT", "INST", undeclaredCollectionRecord.InstallationNo.ToString());
                return true;
            }

            return false;


        }
Exemplo n.º 36
0
    private void StartLockedAction(AnimeAction act, LockHandler onCompleted, bool isForceStop = false)
    {
        if (isForceStop) {
            ForceStop ();
        }

        // anime
        InLockAction(act);
        stateMachines.ForEach (m => m.OnExit = (hash) => {
            OutLockAction(act);
            onCompleted(act);
        });
        animator.SetAnimeAction ((int)act);
    }
Exemplo n.º 37
0
 public void BindLockHandler(LockHandler handler)
 {
     SimpleNamingServiceLayer.Instance.BindLockHandler(handler);
 }
Exemplo n.º 38
0
 public void BindLockHandler(LockHandler handler)
 {
     incomingDispatcher.BindLockHandler(handler);
 }