Exemplo n.º 1
0
        /// <summary>
        /// Searches the database for nodes with the given name as used
        /// for mapping new additions.
        /// </summary>
        /// <param name="nodeName">The name of the node to map</param>
        /// <param name="dataType">The data type of the node being searched</param>
        /// <returns>A list of matching records</returns>
        public List <AutocompleteRecord> MappingSearch(string nodeName, NodeContentType dataType)
        {
            List <AutocompleteRecord> records = new List <AutocompleteRecord>();

            // Create a session
            using (ISession session = connection.Connect(autocompleteKeySpace))
            {
                PreparedStatement      statement   = session.Prepare($"SELECT * FROM {autocompleteTable} WHERE prefix = ? AND remaining = ?");
                Tuple <string, string> nameBinding = BindName(nodeName);
                // Run the statement
                RowSet result = session.Execute(statement.Bind(nameBinding.Item1, nameBinding.Item2));
                if (result.Count() > 0)
                {
                    // For each of the rows in the result
                    foreach (Row r in result)
                    {
                        records.Add(new AutocompleteRecord
                        {
                            CommonName  = r.GetValue <string>("commonnme"),
                            MatchedName = r.GetValue <string>("name"),
                            DataType    = (NodeContentType)r.GetValue <int>("datatype"),
                            Id          = r.GetValue <string>("id"),
                        });
                    }
                }
            }

            return(records.Where(x => x.DataType == dataType).ToList());
        }
Exemplo n.º 2
0
        private bool CheckExistProductNewSale(long ID)
        {
            string query  = string.Format("SELECT id FROM product WHERE id = {0}", ID);
            RowSet rowSet = this._session.Execute(query);
            int    i      = rowSet.Count <Row>();

            return(i > 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Liefert eine Summenzeile für den BusinessProcess
        /// </summary>
        protected override Sagede.Shared.RealTimeData.Common.Row GetTotalLine(Sagede.Shared.RealTimeData.Common.RowSet originalData, Sagede.Shared.RealTimeData.Common.RowSet handledData, Sagede.Shared.RealTimeData.Common.RowSet totalLineData)
        {
            var sumRow = new Row();

            sumRow["ID"]     = zeilen.Count();
            sumRow["Text"]   = "Summe";
            sumRow["Betrag"] = zeilen.Sum(sum => (long)sum["Betrag"]);
            return(sumRow);
        }
Exemplo n.º 4
0
        public ViewResult GetSinglePost(string user, string id)
        {
            ISession session = SessionManager.GetSession();

            System.Guid post_id = System.Guid.Parse(id);

            if (session == null)
            {
                return(View("Error"));
            }

            var st = session.Prepare("SELECT user_name, post_id, toTimestamp(post_id) as date_posted, number_of_likes, post_blob, post_description, user_image_blob " +
                                     "FROM post WHERE user_name= ? AND post_id = ?");
            var statement  = st.Bind(user, post_id);
            var st2        = session.Prepare("SELECT post_likes FROM post_stats WHERE post_id = ?");
            var statement2 = st2.Bind(post_id);



            Row result = session.Execute(statement).FirstOrDefault();;

            if (result.Count() == 0)
            {
                return(View("Error"));
            }

            Post post = new Post(result);

            Row result2 = session.Execute(statement2).FirstOrDefault();;

            if (result2 != null)
            {
                post.number_of_likes = (long)result2["post_likes"];
            }
            else
            {
                post.number_of_likes = 0;
            }

            if (Session["user_name"] == null)
            {
                post.did_i_like = false;
            }
            else
            {
                var    st3        = session.Prepare("SELECT user_name FROM post_likes WHERE post_id = ? AND user_name = ?;");
                var    statement3 = st3.Bind(post_id, Session["user_name"].ToString());
                RowSet result3    = session.Execute(statement3);
                post.SetLikeFlag(result3.Count());
            }
            return(View((object)post));
        }
Exemplo n.º 5
0
        public void Jira_CSHARP_40()
        //During reconnect the tablespace name becomes invalid
        {
            var clusterInfo = TestUtils.CcmSetup(2);

            try
            {
                var    Session  = clusterInfo.Session;
                string Keyspace = "excelsior";
                Session.CreateKeyspaceIfNotExists(Keyspace);
                Thread.Sleep(1000);
                Session.ChangeKeyspace(Keyspace);
                const string cqlKeyspaces = "SELECT * from system.schema_keyspaces";
                var          query        = new SimpleStatement(cqlKeyspaces).EnableTracing();
                {
                    var result = Session.Execute(query);
                    Assert.True(result.Count() > 0, "It should return rows");
                }

                TestUtils.CcmStopForce(clusterInfo, 1);
                TestUtils.CcmStopForce(clusterInfo, 2);
                TestUtils.waitForDown("127.0.0.1", clusterInfo.Cluster, 40);
                TestUtils.waitForDown("127.0.0.2", clusterInfo.Cluster, 40);

                try
                {
                    var result = Session.Execute(query);
                    Assert.True(result.Count() > 0, "It should return rows");
                }
                catch (Exception)
                {
                }


                TestUtils.CcmStart(clusterInfo, 1);
                Thread.Sleep(35000);
                TestUtils.waitFor("127.0.0.1", clusterInfo.Cluster, 60);

                {
                    RowSet result = Session.Execute(query);
                    Assert.True(result.Count() > 0, "It should return rows");
                }
            }
            finally
            {
                TestUtils.CcmRemove(clusterInfo);
            }
        }
Exemplo n.º 6
0
        public int GetViewCount(long ProductID)
        {
            RowSet rs = this._session.Execute(string.Format("SELECT wss_view_count FROM sale.product where id = {0}", ProductID));

            if (rs.Count <Row>() == 0)
            {
                return(0);
            }
            try
            {
                return(Common.Obj2Int(rs.First <Row>()["wss_view_count"]));
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Exemplo n.º 7
0
        public ViewResult FollowingPosts()
        {
            ISession session = SessionManager.GetSession();

            if (session == null || Session["user_name"] == null)
            {
                return(View("Error"));
            }


            var st        = session.Prepare("select following_user_name from people_i_follow where user_name = ?");
            var statement = st.Bind(Session["user_name"]);



            RowSet        result = session.Execute(statement);
            List <String> names  = new List <String>();

            foreach (Row row in result)
            {
                names.Add(row["following_user_name"].ToString());
            }


            var st2 = session.Prepare("SELECT user_name, post_id, toTimestamp(post_id) as date_posted, number_of_likes, post_blob, post_description, user_image_blob " +
                                      "FROM post WHERE user_name in :names");
            var statement2 = st2.Bind(names).SetAutoPage(false).SetPageSize(10);

            if (Session["pagination"] != null)
            {
                statement2.SetPagingState((byte[])Session["pagination"]);
            }

            RowSet result2 = session.Execute(statement2);

            Session["pagination"] = result2.PagingState;

            List <Post> posts = new List <Post>();

            foreach (Row row in result2)
            {
                Post post       = new Post(row);
                var  st3        = session.Prepare("SELECT post_likes FROM post_stats WHERE post_id = ?");
                var  statement3 = st3.Bind(post.post_id);
                var  result3    = session.Execute(statement3).FirstOrDefault();

                if (result3 != null)
                {
                    post.number_of_likes = (long)result3["post_likes"];
                }
                else
                {
                    post.number_of_likes = 0;
                }

                var    st4        = session.Prepare("SELECT user_name FROM post_likes WHERE post_id = ? AND user_name = ?;");
                var    statement4 = st4.Bind(post.post_id, Session["user_name"].ToString());
                RowSet result4    = session.Execute(statement4);
                post.SetLikeFlag(result4.Count());

                posts.Add(post);
            }

            return(View((object)posts));
        }