Exemplo n.º 1
0
        public async Task <IActionResult> Post()
        {
            if (Request == null)
            {
                return(BadRequest());
            }

            try
            {
                var recv = await new StreamReader(Request.Body).ReadToEndAsync();
                if (string.IsNullOrEmpty(recv))
                {
                    return(BadRequest());
                }

                var json = JsonConvert.DeserializeObject <Dictionary <string, object> >(recv);
                ObjectToDictionaryHelper.ConvertJsonToDictionary(json);

                return(Ok(json));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentPack"></param>
        /// <param name="farm"></param>
        /// <returns></returns>
        private bool ProcessContentPack(IContentPack contentPack, out CustomFarm farm)
        {
            Dictionary <string, object> Extra;
            bool results;

            if (contentPack.Manifest.ExtraFields != null && contentPack.Manifest.ExtraFields.ContainsKey("ContentPackType"))
            {
                Extra = (Dictionary <string, object>)ObjectToDictionaryHelper.ToDictionary(contentPack.Manifest.ExtraFields["ContentPackType"]);
                if (Extra.ContainsKey("Farm") && bool.Parse(Extra["Farm"].ToString()))
                {
                    farm    = contentPack.ReadJsonFile <CustomFarm>("farmType.json");
                    results = true;
                }
                else
                {
                    farm    = null;
                    results = false;
                }
            }
            else
            {
                farm    = contentPack.ReadJsonFile <CustomFarm>("farmType.json");
                results = true;
            }
            return(results);
        }
Exemplo n.º 3
0
        public IList <User> Getusers(User user)
        {
            var userAsDictionary = ObjectToDictionaryHelper.ToDictionary(user) as Dictionary <string, dynamic>;

            IVisitor <User> v = new EvalVisitor <User>(filter);

            var iterator = userAsDictionary.GetEnumerator();

            while (iterator.MoveNext())
            {
                v.visit(iterator.Current.Key, iterator.Current.Value);
            }
            return(repository.GetUsers(filter));
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentPack"></param>
        /// <param name="greenHouse"></param>
        /// <returns></returns>
        private bool ProcessContentPack(IContentPack contentPack, out CustomGreenHouse greenHouse)
        {
            Dictionary <string, object> Extra;

            if (contentPack.Manifest.ExtraFields != null && contentPack.Manifest.ExtraFields.ContainsKey("ContentPackType"))
            {
                Extra = (Dictionary <string, object>)ObjectToDictionaryHelper.ToDictionary(contentPack.Manifest.ExtraFields["ContentPackType"]);
                if (Extra.ContainsKey("Greenhouse") && bool.Parse(Extra["Greenhouse"].ToString()))
                {
                    greenHouse = contentPack.ReadJsonFile <CustomGreenHouse>("greenHouseType.json");
                    return(true);
                }
            }
            greenHouse = null;
            return(false);
        }
Exemplo n.º 5
0
        public JsonData loadRequests(string requestNumber)
        {
            JsonData jd   = new JsonData();
            var      list = new List <SerializableDictionary <string, object> >();

            using (ISession session = NHibernateHelper.OpenSession())
            {
                var model = session.CreateQuery("from Requests where RequestNumber=?").SetParameter(0, requestNumber).UniqueResult <Requests>();
                if (model != null)
                {
                    var dict = ObjectToDictionaryHelper.ToDictionary(model);
                    list.Add(dict);
                }
            }
            jd.rows = list;
            return(jd);
        }
Exemplo n.º 6
0
        public JsonData ListMessage(string contactId, int start, int limit)
        {
            JsonData jd   = new JsonData();
            var      list = new List <SerializableDictionary <string, object> >();

            using (ISession session = NHibernateHelper.OpenSession())
            {
                ICriteria criteria = session.CreateCriteria <LineMessages>()
                                     .Add(Expression.Eq("ContactId", Guid.Parse(contactId)));
                var rowcount = CriteriaTransformer.Clone(criteria).SetProjection(Projections.RowCount());
                criteria.AddOrder(Order.Desc("Timestamp"))
                .SetFirstResult(start)
                .SetMaxResults(limit);
                var models = criteria.List <LineMessages>();
                foreach (var model in models)
                {
                    var dict         = ObjectToDictionaryHelper.ToDictionary(model);
                    var lineContacts = session.CreateQuery("from LineContacts where LineId=?")
                                       .SetParameter(0, model.SourceUserId).List <LineContacts>();
                    if (lineContacts.Count > 0)
                    {
                        if (model.SourceType == "agent")
                        {
                            var agent = session.Get <Agents>(Guid.Parse(lineContacts[0].LineId));
                            dict["PersonCode"] = "";
                            dict["PersonName"] = agent.AgentName;
                        }
                        else
                        {
                            var contactPerson = session.Get <ContactPersons>(lineContacts[0].ContactPersonId);
                            dict["PersonCode"] = contactPerson.PersonCode;
                            dict["PersonName"] = contactPerson.PersonName;
                        }
                    }
                    list.Add(dict);
                }
                jd.total = rowcount.FutureValue <int>().Value;
            }
            jd.rows = list;
            return(jd);
        }
Exemplo n.º 7
0
        public JsonData ListContactPerson(string contactId)
        {
            JsonData jd   = new JsonData();
            var      list = new List <SerializableDictionary <string, object> >();

            using (ISession session = NHibernateHelper.OpenSession())
            {
                ICriteria criteria = session.CreateCriteria <LineContacts>()
                                     .Add(Expression.Eq("ContactId", Guid.Parse(contactId)))
                                     .Add(Expression.Eq("ActiveFlag", "1"));
                var models = criteria.List <LineContacts>();
                foreach (var model in models)
                {
                    var dict          = ObjectToDictionaryHelper.ToDictionary(model);
                    var contactPerson = session.Get <ContactPersons>(model.ContactPersonId);
                    dict["PersonCode"] = contactPerson.PersonCode;
                    dict["PersonName"] = contactPerson.PersonName;
                    list.Add(dict);
                }
            }
            jd.rows  = list;
            jd.total = list.Count;
            return(jd);
        }
Exemplo n.º 8
0
 public BsonDocument toDoc()
 {
     return(new BsonDocument(ObjectToDictionaryHelper.toDictionary(this)));
 }