Пример #1
0
        public long AddInventory(InventoryAddModel model)
        {
            try
            {
                var sqlQuery = GetAddInventoryQuery(model);

                var result = _db.ExecuteScalar <long>(sqlQuery, new
                {
                    @brandName     = model.BrandName,
                    @name          = model.Name,
                    @inventoryCode = model.InventoryCode,
                    @imagePath     = model.ImagePath,
                    @createdBy     = SessionRegistry.GetUserData().Id,
                    @createdDate   = DateTime.Now,
                    @modifiedBy    = SessionRegistry.GetUserData().Id,
                    @modifiedDate  = DateTime.Now,
                    @volumeType    = model.VolumeType,
                    @volume        = model.Volume,
                    @specification = model.Specification.Replace("'", "''"),
                    @inPrice       = model.InPrice,
                    @outPrice      = model.OutPriceIncVat,
                    @rea           = model.REA,
                    @supplier      = model.Supplier
                });
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
        }
Пример #2
0
        public static IProfilerServer CreateServer(SessionRegistry sessionRegistry)
        {
            ProfilerService server      = new ProfilerService(sessionRegistry);
            ServiceHost     serviceHost = new ServiceHost(server, new Uri(ProfilerIpc.ServiceBase));

            serviceHost.AddServiceEndpoint(
                typeof(IProfilerService),
                new NetNamedPipeBinding(),
                ProfilerIpc.ServiceName);
            serviceHost.Open();

            return(server);
        }
Пример #3
0
        protected override bool AuthorizeCore(HttpContextBase filterContext)
        {
            bool authorize = false;

            foreach (var role in allowedRoles)
            {
                var user = SessionRegistry.GetUserData();
                if (user != null && user.RoleId == role)
                {
                    authorize = true;
                }
            }
            return(authorize);
        }
        public ActionResult EndShopping(string cartId)
        {
            try
            {
                var storeId = Convert.ToString(Session["StoreId"]);
                var user    = SessionRegistry.GetUserData();
                var message = _receiptService.Payment(user.Id.ToString(), storeId, cartId);

                return(Json(new { success = true, data = message }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Following error occured while payment customer view shop purchase item. Error: {0}", ex.Message);
                return(Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            MatchService      matchService    = new MatchService();
            MessageDispatcher dispatcher      = new MessageDispatcher(matchService);
            SessionRegistry   sessionRegistry = new SessionRegistry();

            SessionService sessionService = new SessionService(sessionRegistry, dispatcher);

            sessionService.Start();
            Console.WriteLine("Server start.");

            autoEvent.WaitOne();
            Console.WriteLine("Server exit.");
        }
Пример #6
0
        public CollaborationSession StartCollaboration()
        {
            Logger.Info("Starting collaboration");

            lock (_locker)
            {
                SessionRegistry sreg = GetSessions();
                try
                {
                    _theSession = sreg.getSession();
                    Logger.Info("Session retrieved: " + OrbServices.GetSingleton().object_to_string(_theSession));
                }
                catch (TargetInvocationException e)
                {
                    if (e.InnerException is SessionDoesNotExist)
                    {
                        Logger.Warn("Session not found for entity " + (e.InnerException as SessionDoesNotExist).entity);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error("Error trying to obtain session: " + e);
                    throw;
                }

                if (_theSession == null)
                {
                    try
                    {
                        CollaborationRegistry collab = GetCollabs();
                        _theSession = collab.createCollaborationSession();
                        sreg.registerSession(_theSession);
                    }
                    catch (Exception e)
                    {
                        Logger.Error("Error creating the session (it will be destroyed): " + e);
                        if (_theSession != null)
                        {
                            _theSession.destroy();
                        }
                        throw;
                    }
                }
                UpdateActivation();
            }
            return(_theSession);
        }
        public ActionResult AddItemInCart(string inventoryCode)
        {
            try
            {
                var user     = SessionRegistry.GetUserData();
                var storeId  = Convert.ToString(Session["StoreId"]);
                var cartId   = _cartService.GenerateCart(user.Id.ToString(), storeId);
                var cartItem = _cartService.AddCartItemForCustomerShop(user.Id.ToString(), cartId.ToString(), storeId, inventoryCode);

                return(Json(new { success = true, data = cartItem }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Following error occured while storing customer view shop purchase item. Error: {0}", ex.Message);
                return(Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult GetAllCartItemCustomerShop()
        {
            try
            {
                var user      = SessionRegistry.GetUserData();
                var storeId   = Convert.ToString(Session["StoreId"]);
                var cartId    = _cartService.GenerateCart(user.Id.ToString(), storeId);
                var cartItems = _cartService.GetAllCartItemList(cartId.ToString());

                return(Json(new { success = true, data = cartItems }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Following error occured while fetching customer view shop purchase list. Error: {0}", ex.Message);
                return(Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #9
0
        public PacChatServer()
        {
            instance = this;
            new ServerSettings();

            protocolProvider = new ProtocolProvider();
            SessionRegistry  = new SessionRegistry();

            Mongo.StartService();
            ProfileCache.StartService();
            CommandManager.StartService();

            RegisterCommand();

            Sticker.StartService();

            StartNetworkService();
        }
Пример #10
0
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            var user = SessionRegistry.GetUserData();

            if (user == null)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
                {
                    { "action", "Index" },
                    { "controller", "Login" }
                }).WithError("Please login to continue");
            }
            else
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
                {
                    { "action", "Index" },
                    { "controller", "Dashboard" }
                }).WithError("You are not authorized to access this page.");
            }
        }
Пример #11
0
 public void ExitCollaboration()
 {
     lock (_locker)
     {
         try
         {
             DeactivateConsumer();
             DeactivateObserver();
             Logger.Info("Collaboration finished");
         }
         finally
         {
             _subsId     = 0;
             _obsId      = 0;
             _theSession = null;
             _consumer   = null;
             _observer   = null;
             _collabs    = null;
             _sessions   = null;
         }
     }
 }
Пример #12
0
 public ProfilerService(SessionRegistry sessionRegistry)
 {
     this.sessionRegistry     = sessionRegistry;
     this.clientEndpointToPid = new ConcurrentDictionary <EndpointAddress, int>();
 }
Пример #13
0
 public HostIpcService(SessionRegistry sessionRegistry)
 {
     this.sessionRegistry = sessionRegistry;
 }
Пример #14
0
        private static string GetEditInventoryQuery(InventoryAddModel model)
        {
            var sqlQuery = new StringBuilder();

            sqlQuery.Append(string.Format(@"UPDATE Inventory SET BrandName='{0}',Name='{1}',InventoryCode='{2}',ModifiedBy={3},ModifiedDate='{4}',ImagePath='{5}',VolumeType='{6}',Supplier='{7}',InPrice='{8}',OutPriceIncVat='{9}',REA={10},Volume='{11}',Specification='{12}' WHERE Id={13} ", model.BrandName, model.Name, model.InventoryCode, SessionRegistry.GetUserData().Id, DateTime.Now, model.ImagePath, model.VolumeType, model.Supplier, model.InPrice, model.OutPriceIncVat, model.REA, model.Volume, model.Specification, model.Id));
            return(sqlQuery.ToString());
        }
Пример #15
0
        private SessionRegistry GetSessions()
        {
            bool find = _sessions == null;

            if (!find)
            {
                try
                {
                    find = !_context.ORB.non_existent(_sessions);
                }
                catch (Exception)
                {
                    find = true;
                }
            }
            if (find)
            {
                ServiceProperty[] serviceProperties = new ServiceProperty[1];
                string            sessionRegType    = Repository.GetRepositoryID(typeof(SessionRegistry));
                serviceProperties[0] =
                    new ServiceProperty("openbus.component.interface", sessionRegType);
                ServiceOfferDesc[] services = _context.OfferRegistry.findServices(serviceProperties);

                foreach (ServiceOfferDesc offerDesc in services)
                {
                    try
                    {
                        MarshalByRefObject obj =
                            offerDesc.service_ref.getFacet(sessionRegType);
                        if (obj == null)
                        {
                            continue;
                        }
                        _sessions = obj as SessionRegistry;
                        if (_sessions != null)
                        {
                            break; // found one
                        }
                    }
                    catch (Exception e)
                    {
                        NO_PERMISSION npe = null;
                        if (e is TargetInvocationException)
                        {
                            npe = e.InnerException as NO_PERMISSION;
                        }
                        // caso não seja uma NO_PERMISSION{NoLogin} descarta essa oferta.
                        if ((npe == null) && (!(e is NO_PERMISSION)))
                        {
                            continue;
                        }
                        npe = npe ?? e as NO_PERMISSION;
                        switch (npe.Minor)
                        {
                        case NoLoginCode.ConstVal:
                            throw;
                        }
                    }
                }
            }
            return(_sessions);
        }