Exemplo n.º 1
2
		public static GcmNotification WithData(this GcmNotification n, IDictionary<string, string> data)
		{
			if (data == null)
				return n;

			var json = new Newtonsoft.Json.Linq.JObject();

			try
			{
				if (!String.IsNullOrEmpty (n.JsonData))
					json = Newtonsoft.Json.Linq.JObject.Parse (n.JsonData);
			}
			catch { } 

			foreach (var pair in data)
				json.Add (pair.Key, new Newtonsoft.Json.Linq.JValue (pair.Value));

			n.JsonData = json.ToString (Newtonsoft.Json.Formatting.None);

			return n;
		}
Exemplo n.º 2
1
 public void unsubscribeTrades()
 {
     JSONObject ob = new JSONObject();
     ob.Add("command", "stopTrades");
     writeMessage(ob.ToString());
 }
Exemplo n.º 3
0
        public void Index()
        {
            var    context      = HttpContext;
            string ApplyNo      = context.Request["ApplyNo"];
            string CustomerName = context.Request["CustomerName"];
            string Saletor      = context.Request["Saletor"];
            string CarType      = context.Request["CarType"];
            string FkState      = context.Request["FkState"];
            string DyState      = context.Request["DyState"];
            string GdTime       = context.Request["GdTime"];
            string StartTime    = context.Request["StartTime"];
            string EndTime      = context.Request["EndTime"];
            string Page         = context.Request["Page"];
            string Size         = context.Request["Size"];

            OThinker.H3.Controllers.UserValidator User = context.Session[OThinker.H3.Controllers.Sessions.GetUserValidator()] as OThinker.H3.Controllers.UserValidator;
            string userCode = User.UserCode;
            string ObjectID = context.Request["ObjectID"] + string.Empty;

            Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
            int total = 0;

            ret.Add("Data", new ReturnData()
            {
                ApplyNo = ApplyNo, GdTime = GdTime, FkTime = StartTime, DyTime = EndTime, CustomerName = CustomerName, Saletor = Saletor, CarType = CarType, FkState = FkState, DyState = DyState, userCode = userCode
            }.GetJson(Page, Size, out total));
            ret.Add("Total", total);

            context.Response.Write(ret);
        }
Exemplo n.º 4
0
        public Newtonsoft.Json.Linq.JObject AuthenticateCenterCode(string UserID, string Password)
        {
            var request = new RestRequest(ApiPath + "/authenticates", Method.POST);

            request.AddParameter("email", UserID);
            request.AddParameter("password", Password);
            request.AddParameter("external", "centercode");
            request.RequestFormat = DataFormat.Json;

            Newtonsoft.Json.Linq.JObject response = new Newtonsoft.Json.Linq.JObject();
            try
            {
                IRestResponse httpResponse = RestClient.Execute(request);

                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    return(JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>(httpResponse.Content, TSCloud.serializer_settings()));
                }
                else
                {
                    response.Add("error", (int)httpResponse.StatusCode);
                }
            }
            catch (Exception ee)
            {
                response.Add("error", ee.ToString());
            }

            return(response);
        }
Exemplo n.º 5
0
        public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
        {
            var exception = value as System.Exception;

            if (exception != null)
            {
                var resolver = serializer.ContractResolver as Newtonsoft.Json.Serialization.DefaultContractResolver ?? _defaultContractResolver;

                var jObject = new Newtonsoft.Json.Linq.JObject();
                jObject.Add(resolver.GetResolvedPropertyName("discriminator"), exception.GetType().Name);
                jObject.Add(resolver.GetResolvedPropertyName("Message"), exception.Message);
                jObject.Add(resolver.GetResolvedPropertyName("StackTrace"), _hideStackTrace ? "HIDDEN" : exception.StackTrace);
                jObject.Add(resolver.GetResolvedPropertyName("Source"), exception.Source);
                jObject.Add(resolver.GetResolvedPropertyName("InnerException"),
                            exception.InnerException != null ? Newtonsoft.Json.Linq.JToken.FromObject(exception.InnerException, serializer) : null);

                foreach (var property in GetExceptionProperties(value.GetType()))
                {
                    var propertyValue = property.Key.GetValue(exception);
                    if (propertyValue != null)
                    {
                        jObject.AddFirst(new Newtonsoft.Json.Linq.JProperty(resolver.GetResolvedPropertyName(property.Value),
                                                                            Newtonsoft.Json.Linq.JToken.FromObject(propertyValue, serializer)));
                    }
                }

                value = jObject;
            }

            serializer.Serialize(writer, value);
        }
Exemplo n.º 6
0
        public IActionResult InstanceManage()
        {
            string groupId = Request.Querys("groupid");

            Business.FlowTask flowTask = new Business.FlowTask();
            var groupTasks             = flowTask.GetListByGroupId(groupId.ToGuid());

            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();
            foreach (var groupTask in groupTasks)
            {
                Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject();
                string opation = "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"cngStatus('" + groupTask.Id.ToString() + "');\"><i class=\"fa fa-exclamation\"></i>状态</a>";
                if (groupTask.ExecuteType.In(0, 1) && 5 != groupTask.TaskType)
                {
                    opation += "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"designate('" + groupTask.Id.ToString() + "');\"><i class=\"fa fa-hand-o-right\"></i>指派</a>"
                               + "<a class=\"list\" href=\"javascript:void(0);\" onclick=\"goTo('" + groupTask.Id.ToString() + "');\"><i class=\"fa fa-level-up\"></i>跳转</a>";
                }
                jObject.Add("id", groupTask.Id);
                jObject.Add("StepID", groupTask.StepName);
                jObject.Add("SenderName", groupTask.SenderName);
                jObject.Add("ReceiveTime", groupTask.ReceiveTime.ToDateTimeString());
                jObject.Add("ReceiveName", groupTask.ReceiveName);
                jObject.Add("CompletedTime1", groupTask.CompletedTime1.HasValue ? groupTask.CompletedTime1.Value.ToDateTimeString() : "");
                jObject.Add("Status", flowTask.GetExecuteTypeTitle(groupTask.ExecuteType));
                jObject.Add("Comment", groupTask.Comments);
                jObject.Add("Note", groupTask.Note);
                jObject.Add("Opation", opation);
                jArray.Add(jObject);
            }
            ViewData["json"]     = jArray.ToString();
            ViewData["appid"]    = Request.Querys("appid");
            ViewData["iframeid"] = Request.Querys("iframeid");
            return(View());
        }
Exemplo n.º 7
0
        public static List <T> GetList <T>(DbDataReader dataReader)
        {
            // 列名
            var cols = new List <string>();

            for (int index = 0; index < dataReader.FieldCount; index++)
            {
                cols.Add(dataReader.GetName(index));
            }

            // 赋值
            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();
            while (dataReader.Read() == true)
            {
                var toAdd_JObject = new Newtonsoft.Json.Linq.JObject();

                foreach (string col in cols)
                {
                    if (dataReader[col] != DBNull.Value)
                    {
                        toAdd_JObject.Add(col, dataReader[col].ToString());
                    }
                    else
                    {
                        toAdd_JObject.Add(col, null);
                    }
                }

                jArray.Add(toAdd_JObject);
            }

            return(jArray.ToObject <List <T> >());
        }
 public Newtonsoft.Json.Linq.JObject GetJson(Score score)
 {
     Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
     ret.Add("Score", score.score);
     ret.Add("Memo", score.memo);
     return(ret);
 }
        public void Index()
        {
            var    context    = HttpContext;
            string BClassName = context.Request["BClassName"];
            string RATE       = context.Request["RATE"];
            string ClassName  = context.Request["ClassName"];
            string Page       = context.Request["Page"];
            string Size       = context.Request["Size"];
            string method     = context.Request["method"];
            string Pid        = context.Request["Pid"];
            string GetState   = context.Request["GetState"];
            string ObjectID   = context.Request["ObjectID"] + string.Empty;

            Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();

            int total = 0;

            //增加删除
            if (method == "AddRuleName")
            {
                string sql = "";
                if (string.IsNullOrEmpty(ObjectID))
                {
                    sql = @"
INSERT into C_RULENAME (ObjectID,BClassName,ClassName,RATE,pid) 
VALUES('" + Guid.NewGuid().ToString() + "','" + BClassName + "','" + ClassName + "','" + RATE + "','" + Pid + "')";
                }
                else
                {
                    sql = @"update C_RULENAME set BClassName='" + BClassName + "',ClassName='" + ClassName + "',RATE='" + RATE + "' where objectID='" + ObjectID + "'";
                }
                int i = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteNonQuery(sql);
                if (i > 0)
                {
                    context.Response.Write(1);
                }
                else
                {
                    context.Response.Write(0);
                }
            }
            //增加的时候加载性质
            else if (!string.IsNullOrEmpty(GetState))
            {
                string sql  = @"select classname from C_RULEPROPERTY  where objectid='" + Pid + "'";
                string name = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql) + string.Empty;
                context.Response.Write(name);
            }
            //加载
            else
            {
                ret.Add("Data", new ReturnData()
                {
                    ClassName = ClassName, Rate = RATE, ObjectID = ObjectID
                }.GetJson(Page, Size, Pid, out total));
                ret.Add("Total", total);
                context.Response.Write(ret);
            }
        }
Exemplo n.º 10
0
 public virtual JSONObject toJSONObject()
 {
     JSONObject obj = new JSONObject();
     obj.Add("symbol", symbol);
     obj.Add("period", (long?)period.longValue());
     obj.Add("start", start);
     return obj;
 }
        public void Index()
        {
            var context = HttpContext;

            string PropertyName = context.Request["PropertyName"];        //规则名称
            string Page         = context.Request["Page"];
            string Size         = context.Request["Size"];
            string method       = context.Request["method"];
            string Grade        = context.Request["Grade"];
            string RangeTo      = context.Request["RangeTo"];
            string RangeFrom    = context.Request["RangeFrom"];
            string Pid          = context.Request["Pid"];
            string GetState     = context.Request["GetState"];
            string ObjectID     = context.Request["ObjectID"] + string.Empty;

            Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
            int total = 0;

            if (method == "AddScoringRank")
            {
                string sql = "";
                if (string.IsNullOrEmpty(ObjectID))
                {
                    sql = @"
INSERT into C_GRADE (ObjectID,GRADE,RANGEFROM,RANGETO,pid,STATES) 
VALUES('" + Guid.NewGuid().ToString() + "','" + Grade + "','" + RangeFrom + "','" + RangeTo + "','" + Pid + "','1')";
                }
                else
                {
                    sql = @"update C_GRADE set GRADE='" + Grade + "',RANGEFROM='" + RangeFrom + "',RANGETO='" + RangeTo + "' where objectID='" + ObjectID + "'";
                }
                int i = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteNonQuery(sql);
                if (i > 0)
                {
                    context.Response.Write(1);
                }
                else
                {
                    context.Response.Write(0);
                }
            }
            else if (!string.IsNullOrEmpty(GetState))
            {
                string sql  = @"select concat(concat(classname,'-'),internettype) from C_RULEPROPERTY  where objectid='" + Pid + "'";
                string name = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql) + string.Empty;
                context.Response.Write(name);
            }
            //加载
            else
            {
                ret.Add("Data", new ReturnData()
                {
                    PropertyName = PropertyName, ObjectID = ObjectID
                }.GetJson(Page, Size, Pid, out total));
                ret.Add("Total", total);
                context.Response.Write(ret);
            }
        }
Exemplo n.º 12
0
        public string get(string data)
        {
            // try
            // {
            //     tou = JSONObject.Parse(data);

            //     //  string userid="1";
            //     //  string userpasword="123";
            //     //  string mw=userid+userpasword;

            //     //  HttpContext.Session.SetString("token",Program.tool.Get32MD5One(mw));


            try
            {
                tou = JSONObject.Parse(data);
            }
            catch (Exception)
            {
                string a1 = "{'type':'error','message':'string change JSONObject Error'}";
                a1 = a1.Replace("\'", "\"");
                return(a1);
            }

            tou.Add("islogin", false);

            if (Request.Headers["token"].ToString().Trim() != "")
            {
                string     retxt = Program.tool.AES.Decode(Request.Headers["token"].ToString(), "jsd7yfjysd98f7");
                JSONObject obj;
                obj = JSONObject.Parse(retxt);

                //-----判断有效期 start
                DateTime objdatetime  = (Convert.ToDateTime(obj["date"]));
                DateTime carrdatetime = DateTime.Now;
                TimeSpan ts           = carrdatetime - objdatetime;
                if (ts.Days < 30)
                {
                    //有效

                    tou.Add("islogin", true);
                    tou.Add("crrloginuserid", obj["userid"].ToString());
                }
            }

            return(TodoApi.Program.请求接口.请求处理(tou.ToString()).ToString());

            //     return TodoApi.Program.请求接口.请求处理(tou.ToString()).ToString();
            // }
            // catch (Exception)
            // {
            //     Console.WriteLine("token=" + HttpContext.Session.GetString("token"));

            //     string a1 = "{'type':'error','message':'string change JSONObject Error'}";
            //     a1 = a1.Replace("\'", "\"");
            //     return a1;
            // }
        }
Exemplo n.º 13
0
        /// <summary>
        /// BulkCopyInsert  批量插入数据库
        /// </summary>
        /// <param name="logAppendToForms"></param>
        /// <param name="jobInfo"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public int BulkCopyInsert(Log4netUtil.LogAppendToForms logAppendToForms, Model.JobEntity jobInfo, string tableName, string strSql)
        {
            string logMessage = string.Empty;
            //string strSql = Util.ConvertHelper.DataTableToStrInsert(dt, tableName) + "\r";
            string targetDatabase = jobInfo.TargetDatabase;

            IDAL.IDBHelper _idbHelper = DALFactory.DBHelperFactory.CreateInstance(targetDatabase);//创建接口/创建接口
            System.Data.Common.DbParameter[] cmdParams = null;
            string jsonSql = Util.DbSqlLog.SqlToJson("9999", strSql, cmdParams);

            logMessage = string.Format("【{0}_{1}】 JsonSql:{2} ", jobInfo.JobCode, jobInfo.JobName, jsonSql);
            Log4netUtil.Log4NetHelper.LogMessage(logAppendToForms, jobInfo.IsDebug, logMessage, @"Database");
            try
            {
                if (_idbHelper.ExecuteNonQuery(System.Data.CommandType.Text, strSql, targetDatabase, cmdParams) > 0)
                {
                    logMessage = string.Format("【{0}_{1}】  执行BulkCopyInsert成功!", jobInfo.JobCode, jobInfo.JobName);
                    Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                    resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("0000"));
                    resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                    resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                    logMessage = string.Format("【{0}_{1}】 {2}", jobInfo.JobCode, jobInfo.JobName, Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                    Log4netUtil.Log4NetHelper.LogMessage(logAppendToForms, jobInfo.IsDebug, logMessage, @"Database");
                    return(1);
                }
                else
                {
                    logMessage = string.Format("【{0}_{1}】  执行BulkCopyInsert失败!", jobInfo.JobCode, jobInfo.JobName);
                    Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                    resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                    resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                    resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                    logMessage = string.Format("【{0}_{1}】 {2}", jobInfo.JobCode, jobInfo.JobName, Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                    Log4netUtil.Log4NetHelper.LogError(logAppendToForms, jobInfo.IsDebug, logMessage, @"Database");
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                //违反了 PRIMARY KEY 约束

                logMessage = string.Format("【{0}_{1}】  执行BulkCopyInsert失败! 失败原因:{2}", jobInfo.JobCode, jobInfo.JobName, ex.Message);
                Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                logMessage = string.Format("【{0}_{1}】 {2}", jobInfo.JobCode, jobInfo.JobName, Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                Log4netUtil.Log4NetHelper.LogError(logAppendToForms, jobInfo.IsDebug, logMessage, @"Database");
                if (ex.Message.Contains("违反了 PRIMARY KEY 约束"))
                {
                    return(2);
                }
                else
                {
                    return(-1);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// GetResult
        /// </summary>
        /// <param name="code"></param>
        /// <param name="msg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private string GetResult(string code, string msg, string data)
        {
            Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject();

            jObject.Add("code", code);
            jObject.Add("msg", msg);
            jObject.Add("data", data);
            return(jObject.ToString());
        }
 public Newtonsoft.Json.Linq.JObject GetJson(int index)
 {
     Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
     ret.Add("No", index);
     ret.Add("InternetType", InternetType);
     ret.Add("ClassName", ClassName);
     ret.Add("ObjectID", ObjectID);
     return(ret);
 }
Exemplo n.º 16
0
 public override string toJSONString()
 {
     JSONObject obj = new JSONObject();
     obj.Add("command", commandName);
     obj.Add("prettyPrint", prettyPrint);
     obj.Add("arguments", arguments);
     obj.Add("extended", true);
     return obj.ToString();
 }
 public Newtonsoft.Json.Linq.JObject GetJson(int index)
 {
     Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
     ret.Add("No", index);
     ret.Add("Rate", Rate);
     ret.Add("RuleName", RuleName);
     ret.Add("DetaileName", DetaileName);
     ret.Add("ObjectID", ObjectID);
     return(ret);
 }
Exemplo n.º 18
0
        public override string ToJSONString()
        {
            JSONObject obj = new JSONObject();

            obj.Add("command", commandName);
            obj.Add("prettyPrint", prettyPrint);
            obj.Add("arguments", arguments);
            obj.Add("extended", true);
            return(obj.ToString());
        }
 public Newtonsoft.Json.Linq.JObject GetJson(int index)
 {
     Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
     ret.Add("No", index);
     ret.Add("Rate", Rate);
     ret.Add("BClassName", BClassName);
     ret.Add("ClassName", ClassName);
     ret.Add("ObjectID", ObjectID);
     return(ret);
 }
Exemplo n.º 20
0
 public Newtonsoft.Json.Linq.JObject GetJson(int index)
 {
     Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
     ret.Add("No", index);
     ret.Add("DISTRIBUTOR", DISTRIBUTOR);
     ret.Add("VERIFYLOAN", VERIFYLOAN);
     ret.Add("QUOTA", QUOTA);
     ret.Add("USEQUOTA", USEQUOTA);
     return(ret);
 }
        public void Index()
        {
            var    context      = HttpContext;
            string InternetType = context.Request["InternetType"];
            string ClassName    = context.Request["ClassName"];
            string Page         = context.Request["Page"];
            string Size         = context.Request["Size"];
            string method       = context.Request["method"];
            string ObjectID     = context.Request["ObjectID"] + string.Empty;

            Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();

            int total = 0;

            if (method == "AddRuleProperty")
            {
                string sql = "";
                if (string.IsNullOrEmpty(ObjectID))
                {
                    sql = @"
INSERT into C_RULEPROPERTY (ObjectID,InternetType,ClassName) 
VALUES('" + Guid.NewGuid().ToString() + "','" + InternetType + "','" + ClassName + "')";
                }
                else
                {
                    sql = @"update C_RULEPROPERTY set InternetType='" + InternetType + "',ClassName='" + ClassName + "' where objectID='" + ObjectID + "'";
                }
                int i = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteNonQuery(sql);
                if (i > 0)
                {
                    context.Response.Write(1);
                }
                else
                {
                    context.Response.Write(0);
                }
            }
            else if (method == "GetPerproty")
            {
                var dt  = GetPerproty("性质");
                var dt0 = GetPerproty("渠道分类");
                ret.Add("property", dt);
                ret.Add("type", dt0);
                context.Response.Write(ret);
            }
            else
            {
                ret.Add("Data", new ReturnData()
                {
                    InternetType = InternetType, ClassName = ClassName, ObjectID = ObjectID
                }.GetJson(Page, Size, out total));
                ret.Add("Total", total);
                context.Response.Write(ret);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// ErpWriteback
        /// </summary>
        /// <param name="logAppendToForms"></param>
        /// <param name="writebackParam"></param>
        /// <returns></returns>
        public bool ErpWriteback(Log4netUtil.LogAppendToForms logAppendToForms, Model.WritebackParam writebackParam)
        {
            string logMessage     = string.Empty;
            string procedureName  = writebackParam.ProcedureName;
            string targetDatabase = writebackParam.TargetDatabase;

            IDAL.IDBHelper _idbHelper = DALFactory.DBHelperFactory.CreateInstance(targetDatabase);//创建接口
            System.Data.Common.DbParameter[] cmdParams = { _idbHelper.CreateInParam(targetDatabase, ":i_WritebackType", writebackParam.WritebackType),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_BillCodes",     string.IsNullOrEmpty(writebackParam.BillCodes)?string.Empty:writebackParam.BillCodes),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_Type",          string.IsNullOrEmpty(writebackParam.Type)?string.Empty:writebackParam.Type),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_Status",        writebackParam.Status),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_WritebackInfo", string.IsNullOrEmpty(writebackParam.WritebackInfo)?string.Empty:writebackParam.WritebackInfo) };
            try
            {
                writebackParam.IsDebug = true;
                int r = _idbHelper.ExecuteNonQuery(System.Data.CommandType.StoredProcedure, procedureName, targetDatabase, cmdParams);
                if (r > 0)
                {
                    string jsonSql = Util.DbSqlLog.SqlToJson("0000", procedureName, cmdParams);
                    logMessage = string.Format("ErpWriteback回写成功!!!{0}", string.Empty);
                    Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                    resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("0000"));
                    resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                    resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                    logMessage = string.Format("【{0}_{1}】 {2}", writebackParam.jobInfo.JobCode, writebackParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                    Log4netUtil.Log4NetHelper.LogMessage(logAppendToForms, writebackParam.IsDebug, logMessage, @"Database");
                    return(true);
                }
                else
                {
                    string jsonSql = Util.DbSqlLog.SqlToJson("9999", procedureName, cmdParams);
                    logMessage = string.Format("ErpWriteback回写失败!!!!{0}", string.Empty);
                    Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                    resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                    resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                    resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                    logMessage = string.Format("【{0}_{1}】 {2}", writebackParam.jobInfo.JobCode, writebackParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                    Log4netUtil.Log4NetHelper.LogError(logAppendToForms, writebackParam.IsDebug, logMessage, @"Database");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                string jsonSql = Util.DbSqlLog.SqlToJson("9999", procedureName, cmdParams);
                logMessage = string.Format("ErpWriteback回写失败!!!原因:{0};", ex.Message);
                Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                logMessage = string.Format("【{0}_{1}】 {2}", writebackParam.jobInfo.JobCode, writebackParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                Log4netUtil.Log4NetHelper.LogError(logAppendToForms, writebackParam.IsDebug, logMessage, @"Database");
                return(false);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Post方式提交数据,返回网页的源代码
        /// </summary>
        /// <param name="url">发送请求的 URL</param>
        /// <param name="param">请求的参数集合</param>
        /// <returns>远程资源的响应结果</returns>
        private string sendPost(string url, Dictionary <string, string> param)
        {
            string        result   = "";
            StringBuilder postData = new StringBuilder();

            if (param != null && param.Count > 0)
            {
                foreach (var p in param)
                {
                    if (postData.Length > 0)
                    {
                        postData.Append("&");
                    }
                    postData.Append(p.Key);
                    postData.Append("=");
                    postData.Append(p.Value);
                }
            }

            byte[] byteData = Encoding.GetEncoding("UTF-8").GetBytes(postData.ToString());
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.ContentType   = "application/x-www-form-urlencoded"; //"application/json"; //
                request.Referer       = url;
                request.Accept        = "*/*";
                request.Timeout       = 30 * 1000;
                request.UserAgent     = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";
                request.Method        = "POST";
                request.ContentLength = byteData.Length;
                Stream stream = request.GetRequestStream();
                stream.Write(byteData, 0, byteData.Length);
                stream.Flush();
                stream.Close();
                HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
                Stream          backStream = response.GetResponseStream();
                StreamReader    sr         = new StreamReader(backStream, Encoding.GetEncoding("UTF-8"));
                result = sr.ReadToEnd();
                sr.Close();
                backStream.Close();
                response.Close();
                request.Abort();
            }
            catch (Exception ex)
            {
                Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                resultJObject.Add("ErrCode", new Newtonsoft.Json.Linq.JValue("999"));
                resultJObject.Add("ErrMsg", new Newtonsoft.Json.Linq.JValue(ex.Message));
                Log4netUtil.Log4NetHelper.Error("SendPost Api接口失败 失败原因:", ex, @"DtyApi");
                result = Util.NewtonsoftCommon.SerializeObjToJson(resultJObject);
            }
            return(result);
        }
        public void Index()
        {
            var    context     = HttpContext;
            string DetaileName = context.Request["DetaileName"];
            string Page        = context.Request["Page"];
            string Size        = context.Request["Size"];
            string method      = context.Request["method"];
            string Pid         = context.Request["Pid"];
            string Cid         = context.Request["Cid"];
            string GetState    = context.Request["GetState"];
            string ObjectID    = context.Request["ObjectID"] + string.Empty;

            Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();

            int total = 0;

            //增加删除
            if (!string.IsNullOrEmpty(Cid))
            {
                string    sql = @"select a.rulename,a.detailename,a.rate,c.internettype,c.classname from C_RULEDETAILS a left join C_RULENAME B ON  a.pid=B.OBJECTID LEFT JOIN C_RULEPROPERTY C 
ON B.PID=C.OBJECTID  where a.objectid='" + Cid + "'";
                DataTable dt  = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    string state = "0";
                    if (Pid == "check")
                    {
                        state = "1";
                    }
                    ret.Add("RuleName", dt.Rows[0]["RULENAME"].ToString());
                    ret.Add("DetaileName", dt.Rows[0]["DETAILENAME"].ToString());
                    ret.Add("Rate", dt.Rows[0]["RATE"].ToString());
                    ret.Add("Internettype", dt.Rows[0]["INTERNETTYPE"].ToString());
                    ret.Add("Classname", dt.Rows[0]["CLASSNAME"].ToString());
                    ret.Add("State", state);
                    var result = GetScore(Cid);
                    ret.Add("datas", result);
                }
                context.Response.Write(ret);
            }
            //增加的时候加载性质
            else if (!string.IsNullOrEmpty(GetState))
            {
                string sql  = @"select classname from C_RULEName  where objectid='" + Pid + "'";
                string name = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(sql) + string.Empty;
                context.Response.Write(name);
            }
            //加载
            else
            {
                ret.Add("Data", new ReturnData()
                {
                    DetaileName = DetaileName, ObjectID = ObjectID
                }.GetJson(Page, Size, Pid, out total));
                ret.Add("Total", total);
                context.Response.Write(ret);
            }
        }
Exemplo n.º 25
0
        public string post(string data_)
        {
            string data = Request.Form["data"];

            Console.WriteLine("login data=" + data);

            try
            {
                tou = JSONObject.Parse(data);
            }
            catch (Exception)
            {
                string a1 = "{'type':'error','message':'string change JSONObject Error'}";
                a1 = a1.Replace("\'", "\"");
                return(a1);
            }

            JSONObject ret = TodoApi.Program.请求接口.请求处理(tou.ToString());

            //return  TodoApi.Program.请求接口.请求处理(tou.ToString()).ToString();
            if (ret["code"].ToString() == "200")
            {
                Console.WriteLine("login ok=" + ret["code"].ToString());
                //token md5 = 手机号 + 短信验证码

                //  string token = Program.tool.Get32MD5One(ret["phonenumber"].ToString() + ret["VerificationCode"].ToString());
                //--构造token json对象 start
                JSONObject token = new JSONObject();
                token.Add("userid", ret["userid"].ToString());
                token.Add("date", DateTime.Now.ToString("yyyy-MM-dd HH:mm"));

                //--构造token json对象 end

                //--加密  start
                string ciphertext = Program.tool.AES.Encode(token.ToString(), "jsd7yfjysd98f7");
                //  string ciphertext = Program.tool.AES.Encode(token.ToString(), "HttpContextSessionSetString");
                //  Console.WriteLine("密文=" + ciphertext);

                //--加密 end

                //  Console.WriteLine("login token=" + token);
                // Response.HttpContext.Session.SetString("token", token.ToString());
                // Response.HttpContext.Session.SetString("userid", ret["userid"].ToString());

                ret.Add("token", ciphertext);
            }



            return(ret.ToString());
        }
Exemplo n.º 26
0
        /// <summary>
        /// selects all rows from a table, creates a JObject for each row with the field names and adds the row JObject to a parent table JObject
        /// </summary>
        ///
        private Newtonsoft.Json.Linq.JObject createExportRows(string pTableName, Newtonsoft.Json.Linq.JObject pTable)
        {
            Newtonsoft.Json.Linq.JObject exportRow;
            Newtonsoft.Json.Linq.JObject exportTable = pTable;
            string sTableName  = pTableName;
            Int32  iRowCounter = 0;

            try
            {
                DataTable    fields           = this.getTableFields(pTableName);
                Int32        iFieldNameColumn = fields.Columns.IndexOf("COLUMN_NAME");
                Int32        iDataTypeColumn  = fields.Columns.IndexOf("DATA_TYPE");
                DbDataReader dataReader;
                dataReader = this.returnDataReader("select * from " + sTableName);
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        exportRow = new Newtonsoft.Json.Linq.JObject();
                        foreach (DataRow row in fields.Rows)
                        {
                            this.createExportJSONField(exportRow, dataReader, row, iDataTypeColumn, row[iFieldNameColumn].ToString());
                        }
                        iRowCounter++;
                        exportTable.Add(iRowCounter.ToString(), exportRow);

                        /*
                         * Write log message to show something is still happening
                         */

                        if (iRowCounter % 100 == 0)
                        {
                            this.OnLogEvent(new LogEventArgs("createExportRows Reading from row " + iRowCounter.ToString() + " (" + sTableName + ")", true));
                        }
                    }
                }
                else
                {
                    exportTable.Add("NoRows", 1);
                }
            }
            catch (Exception e)
            {
                this.writeLog("createExportRows :: " + e.ToString());
                exportTable = new Newtonsoft.Json.Linq.JObject();
            }
            return(exportTable);
        }
Exemplo n.º 27
0
        public override string ToJSONString()
        {
            JSONObject obj = new JSONObject();

            obj.Add("command", this.commandName);
            return(obj.ToString());
        }
Exemplo n.º 28
0
        /// <summary>
        /// 得到一个流程所有的表和字段
        /// </summary>
        /// <returns></returns>
        public string GetTableJSON()
        {
            string dbs = Request.Forms("dbs");

            if (dbs.IsNullOrWhiteSpace())
            {
                return("[]");
            }
            Newtonsoft.Json.Linq.JArray jArray = null;
            try
            {
                jArray = Newtonsoft.Json.Linq.JArray.Parse(dbs);
            }
            catch
            {
                return("[]");
            }
            if (null == jArray)
            {
                return("[]");
            }
            Business.DbConnection       dbConnection = new Business.DbConnection();
            Newtonsoft.Json.Linq.JArray jArray1      = new Newtonsoft.Json.Linq.JArray();
            foreach (Newtonsoft.Json.Linq.JObject jObject in jArray)
            {
                string table  = jObject.Value <string>("table");
                string connId = jObject.Value <string>("link");
                int    type   = 0;
                if (!connId.IsGuid(out Guid cid))
                {
                    continue;
                }
                var dbConnModel = dbConnection.Get(cid);
                if (null == dbConnModel)
                {
                    continue;
                }
                Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject
                {
                    { "table", table },
                    { "connId", connId },
                    { "type", type },
                    { "connName", dbConnModel.Name + "(" + dbConnModel.ConnType + ")" }
                };
                var fields = dbConnection.GetTableFields(cid, table);
                Newtonsoft.Json.Linq.JArray fieldArray = new Newtonsoft.Json.Linq.JArray();
                foreach (var field in fields)
                {
                    Newtonsoft.Json.Linq.JObject jObject2 = new Newtonsoft.Json.Linq.JObject
                    {
                        { "name", field.FieldName },
                        { "comment", field.Comment }
                    };
                    fieldArray.Add(jObject2);
                }
                jObject1.Add("fields", fieldArray);
                jArray1.Add(jObject1);
            }
            return(jArray1.ToString());
        }
Exemplo n.º 29
0
        public static GcmNotification WithData(this GcmNotification n, IDictionary <string, string> data)
        {
            if (data == null)
            {
                return(n);
            }

            var json = new Newtonsoft.Json.Linq.JObject();

            try
            {
                if (!String.IsNullOrEmpty(n.JsonData))
                {
                    json = Newtonsoft.Json.Linq.JObject.Parse(n.JsonData);
                }
            }
            catch { }

            foreach (var pair in data)
            {
                json.Add(pair.Key, new Newtonsoft.Json.Linq.JValue(pair.Value));
            }

            n.JsonData = json.ToString(Newtonsoft.Json.Formatting.None);

            return(n);
        }
Exemplo n.º 30
0
        public Newtonsoft.Json.Linq.JArray GetEXP(string sql, out string outStr)
        {
            outStr = "";
            Newtonsoft.Json.Linq.JArray data = new Newtonsoft.Json.Linq.JArray();
            var dt = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);

            if (dt.Rows.Count > 0)
            {
                //提取公式内{}内容获取规则明细名称
                string exp = dt.Rows[0]["EXPRESSION"] + string.Empty;
                exp.Replace('×', '*');
                exp.Replace('÷', '/');
                outStr = exp;
                MatchCollection mc = Regex.Matches(exp, @"{([^}]+)}");
                foreach (var item in mc)
                {
                    string s       = item.ToString();
                    string s0      = s.Substring(1, s.Length - 2);
                    string Namesql = string.Format("select DETAILENAME from C_RULEDETAILS where objectid='{0}' ", s0);
                    var    name    = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteScalar(Namesql) + string.Empty;
                    string s1      = "<button style='margin:1px' value='" + s0 + "'>" + name + "</button>";
                    exp = exp.Replace(s, s1);
                }
                Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
                ret.Add("exp", exp);
                data.Add(ret);
            }
            return(data);
        }
Exemplo n.º 31
0
        public void Index()
        {
            var context = HttpContext;
            Dictionary <int, int> baseProducts = new Dictionary <int, int>();
            string Dealer = UserValidatorFactory.CurrentUser.UserCode;

            System.Data.DataTable allProducts = this.ExecuteDataTableSql("CAPDB", @"SELECT distinct FD.FINANCIAL_PRODUCT_ID ProductID,FP.FINANCIAL_PRODUCT_NME ProductName
FROM 
FP_DEALER@to_cms FD 
JOIN FINANCIAL_PRODUCT@to_cms FP ON FD.FINANCIAL_PRODUCT_ID=FP.FINANCIAL_PRODUCT_ID
JOIN 
(SELECT BSU.WORKFLOW_LOGIN_NME , BM2.BUSINESS_PARTNER_ID ,BM2.BUSINESS_PARTNER_NME 
FROM BP_SYS_USER@to_cms BSU 
JOIN BP_MAIN@to_cms BM ON BSU.BP_SECONDARY_ID=BM.BUSINESS_PARTNER_ID 
JOIN BP_RELATIONSHIP@to_cms BRE ON BRE.BP_SECONDARY_ID=BM.BUSINESS_PARTNER_ID AND BRE.RELATIONSHIP_CDE='00112'
JOIN BP_MAIN@to_cms BM2 ON BM2.BUSINESS_PARTNER_ID=BRE.BP_PRIMARY_ID
WHERE  BSU.WORKFLOWLOGIN_ACTIVE_IND='T' ) 
WORKFLOW_LOGIN ON 
WORKFLOW_LOGIN.BUSINESS_PARTNER_ID=FD.BUSINESS_PARTNER_ID
WHERE to_char(FP.VALID_FROM_DTE,'yyyymmdd')< to_char(sysdate,'yyyymmdd') and to_char(FP.VALID_TO_DTE,'yyyymmdd')>to_char(sysdate,'yyyymmdd')"
                                                                         + " and WORKFLOW_LOGIN.WORKFLOW_LOGIN_NME='" + Dealer + "'"
                                                                         + " ORDER BY FD.FINANCIAL_PRODUCT_ID ASC");
            Newtonsoft.Json.Linq.JArray ret = new Newtonsoft.Json.Linq.JArray();
            if (allProducts != null)
            {
                for (int i = 0; i < allProducts.Rows.Count; i++)
                {
                    Newtonsoft.Json.Linq.JObject token = new Newtonsoft.Json.Linq.JObject();
                    token.Add("ProductID", int.Parse(ReadCell(allProducts.Rows[i], "ProductID")));
                    token.Add("ProductName", ReadCell(allProducts.Rows[i], "ProductName"));
                    token.Add("ProductDescription", "暂无描述");
                    ret.Add(token);
                    baseProducts.Add(int.Parse(ReadCell(allProducts.Rows[i], "ProductID")), i);
                }
            }

            System.Data.DataTable products = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable("SELECT p.* FROM C_PRODUCTS p LEFT JOIN OT_USER u ON p.dealer=u.appellation WHERE u.Code='" + UserValidatorFactory.CurrentUser.UserCode + "' ORDER BY ProductId ASC");
            foreach (DataRow row in products.Rows)
            {
                if (baseProducts.ContainsKey(int.Parse(ReadCell(row, "ProductID"))))
                {
                    ret[baseProducts[int.Parse(ReadCell(row, "ProductID"))]]["ProductName"]        = ReadCell(row, "ProductAlias");
                    ret[baseProducts[int.Parse(ReadCell(row, "ProductID"))]]["ProductDescription"] = ReadCell(row, "ProductDescription");
                }
            }
            context.Response.Write(ret);
        }
Exemplo n.º 32
0
        public string get(string data)
        {
            JSONObject ret = new JSONObject();;

            ret.Add("type", "error");

            return(data);
        }
Exemplo n.º 33
0
        public Newtonsoft.Json.Linq.JArray GetDealer()
        {
            Newtonsoft.Json.Linq.JArray data = new Newtonsoft.Json.Linq.JArray();
            DataTable dt  = new DataTable();
            string    sql = "Select DISTINCT * FROM (SELECT \"DealerName\" as \"经销商编号\",\"DealerName\" as \"经销商名称\" FROM DEALERACCEDE UNION ALL SELECT cast(\"经销商名称\" as nvarchar2(1000)) as 经销商编号, cast(\"经销商名称\" as nvarchar2(1000)) as 经销商名称 FROM in_cms.MV_H3_DEALER_OD_INFO_CN)";

            dt = AppUtility.Engine.EngineConfig.CommandFactory.CreateCommand().ExecuteDataTable(sql);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Newtonsoft.Json.Linq.JObject ret = new Newtonsoft.Json.Linq.JObject();
                ret.Add("key", dt.Rows[i]["经销商编号"].ToString());
                ret.Add("value", dt.Rows[i]["经销商名称"].ToString());
                data.Add(ret);
            }
            return(data);
        }
Exemplo n.º 34
0
        public static string GetRegisterNewAccountString(string EmployeeName, string CompanyName)
        {
            Newtonsoft.Json.Linq.JObject jo = new Newtonsoft.Json.Linq.JObject();
            Newtonsoft.Json.Linq.JObject jp = new Newtonsoft.Json.Linq.JObject();

            jo.Add("interface", "ADSFPRestAPI");
            jo.Add("method", "registerAccountNew");

            jp.Add("prmAccountID", AccountInfo.GetDeviceID());
            jp.Add("prmCompanyName", CompanyName);
            jp.Add("prmEmployeeName", EmployeeName);
            jp.Add("parameters", jp);

            jo.Add("parameters", jp);

            return(jo.ToString());
        }
        private void web1_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            GTMAccessToken _gtmAccessToken = null;

            if (e.Uri.Query.ToLower().IndexOf("code") != -1 )
            {
                //get the "code" from GTM
                string _code = e.Uri.Query.Replace("?code=", "");
                e.Cancel = true;

                var _rc = new RestSharp.RestClient(@"https://api.citrixonline.com");
                RestSharp.RestRequest _gtmTokenCodeReq = new RestSharp.RestRequest("/oauth/access_token?grant_type=authorization_code&code={responseKey}&client_id={api_key}", RestSharp.Method.GET);
                _gtmTokenCodeReq.AddUrlSegment("responseKey", _code);
                _gtmTokenCodeReq.AddUrlSegment("api_key", this.gtmAPIKey.Text);

                var _gtmTokenCodeResp = _rc.Execute(_gtmTokenCodeReq);

                if (_gtmTokenCodeResp.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var jsonCode = _gtmTokenCodeResp.Content;
                    _gtmAccessToken = Newtonsoft.Json.JsonConvert.DeserializeObject<GTMAccessToken>(jsonCode);
                }

                //now we have the token. Create a meeting
                var _gtmMeetingReq = new RestSharp.RestRequest(@"/G2M/rest/meetings", RestSharp.Method.POST);
                _gtmMeetingReq.AddHeader("Accept", "application/json");
                _gtmMeetingReq.AddHeader("Content-type", "application/json");
                _gtmMeetingReq.AddHeader("Authorization", string.Format("OAuth oauth_token={0}", _gtmAccessToken.access_token));

                //creating the meeting request json for the request.
                Newtonsoft.Json.Linq.JObject _meetingRequestJson = new Newtonsoft.Json.Linq.JObject();
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("subject", "Immediate Meeting"));
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("starttime", DateTime.UtcNow.AddSeconds(30).ToString("s")));
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("endtime", DateTime.UtcNow.AddHours(1).AddSeconds(30).ToString("s")));
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("passwordrequired", "false"));
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("conferencecallinfo", "Hybrid"));
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("timezonekey", ""));
                _meetingRequestJson.Add(new Newtonsoft.Json.Linq.JProperty("meetingtype", "Immediate"));

                //converting the jobject back to string for use within the request
                string gtmJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_meetingRequestJson);

                _gtmMeetingReq.AddParameter("text/json", gtmJSON, RestSharp.ParameterType.RequestBody);

                var _responseMeetingRequest = _rc.Execute(_gtmMeetingReq);

                if (_responseMeetingRequest.StatusCode == System.Net.HttpStatusCode.Created)
                {
                    // meeting created to add a message, format it and add it to the list
                    string _meetingResponseJson = _responseMeetingRequest.Content;

                    Newtonsoft.Json.Linq.JArray _meetingResponse = Newtonsoft.Json.Linq.JArray.Parse(_meetingResponseJson);
                    var _gtmMeetingObject = _meetingResponse[0];

                    MessageBox.Show(_gtmMeetingObject["joinURL"].ToString());
                }
            }
        }
Exemplo n.º 36
0
 public string ToJson()
 {
     Newtonsoft.Json.Linq.JObject res = new Newtonsoft.Json.Linq.JObject();
     res.Add("state", _state);
     if (_state)
     {
         if (_data.Count > 0)
         {
             Newtonsoft.Json.Linq.JObject data = new Newtonsoft.Json.Linq.JObject();
             Newtonsoft.Json.Linq.JProperty propData = new Newtonsoft.Json.Linq.JProperty("data", data);
             res.Add(propData);
             foreach (string key in _data.Keys)
             {
                 data.Add(key, _data[key].ToString());
             }
         }
     }
     else
     {
         res.Add("message", _message ?? "错误");
     }
     return res.ToString();
 }
Exemplo n.º 37
0
        public void GET(string key, RequestInfo info)
        {
            // Start with a scratch object
            var o = new Newtonsoft.Json.Linq.JObject();

            // Add application wide settings
            o.Add("ApplicationOptions", new Newtonsoft.Json.Linq.JArray(
                from n in Program.DataConnection.Settings
                select Newtonsoft.Json.Linq.JObject.FromObject(n)
            ));

            try
            {
                // Add built-in defaults
                Newtonsoft.Json.Linq.JObject n;
                using(var s = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".newbackup.json")))
                    n = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(s.ReadToEnd());

                MergeJsonObjects(o, n);
            }
            catch
            {
            }

            try
            {
                // Add install defaults/overrides, if present
                var path = System.IO.Path.Combine(Duplicati.Library.AutoUpdater.UpdaterManager.InstalledBaseDir, "newbackup.json");
                if (System.IO.File.Exists(path))
                {
                    Newtonsoft.Json.Linq.JObject n;
                    n = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(path));

                    MergeJsonObjects(o, n);
                }
            }
            catch
            {
            }

            info.OutputOK(new
            {
                success = true,
                data = o
            });
        }
Exemplo n.º 38
0
 public static TradingHoursCommand createTradingHoursCommand(LinkedList<string> symbols, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     JSONArray arr = new JSONArray();
     foreach (string symbol in symbols)
     {
         arr.Add(symbol);
     }
     args.Add("symbols", arr);
     return new TradingHoursCommand(args, prettyPrint);
 }
Exemplo n.º 39
0
 public virtual JSONObject toJSONObject()
 {
     JSONObject obj = new JSONObject();
     obj.Add("cmd", (long)cmd.longValue());
     obj.Add("type", (long)type.longValue());
     obj.Add("price", price);
     obj.Add("sl", sl);
     obj.Add("tp", tp);
     obj.Add("symbol", symbol);
     obj.Add("volume", volume);
     obj.Add("ie_deviation", ie_deviation);
     obj.Add("order", order);
     obj.Add("comment", comment);
     obj.Add("expiration", expiration);
     return obj;
 }
Exemplo n.º 40
0
 public static ChartLastCommand createChartLastCommand(string symbol, PERIOD_CODE period, long? start, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("info", (new ChartLastInfoRecord(symbol, period, start)).toJSONObject());
     return new ChartLastCommand(args, prettyPrint);
 }
Exemplo n.º 41
0
 public static ChartLastCommand createChartLastCommand(ChartLastInfoRecord info, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("info", info.toJSONObject());
     return new ChartLastCommand(args, prettyPrint);
 }
Exemplo n.º 42
0
        public static TickPricesCommand createTickPricesCommand(LinkedList<string> symbols, long? timestamp, bool prettyPrint)
        {
            JSONObject args = new JSONObject();
            JSONArray arr = new JSONArray();
            foreach (string symbol in symbols)
            {
                arr.Add(symbol);
            }

            args.Add("symbols", arr);
            args.Add("timestamp", timestamp);
            return new TickPricesCommand(args, prettyPrint);
        }
Exemplo n.º 43
0
 {
     public void GET(string key, RequestInfo info)
Exemplo n.º 44
0
 public void subscribePrice(String symbol)
 {
     JSONObject ob = new JSONObject();
     ob.Add("command", "getTickPrices");
     ob.Add("symbol", symbol);
     ob.Add("streamSessionId", streamingSessionId);
     writeMessage(ob.ToString());
 }
Exemplo n.º 45
0
 public void subscribeTrades()
 {
     JSONObject ob = new JSONObject();
     ob.Add("command", "getTrades");
     ob.Add("streamSessionId", streamingSessionId);
     writeMessage(ob.ToString());
 }
Exemplo n.º 46
0
 public override string toJSONString()
 {
     JSONObject obj = new JSONObject();
     obj.Add("command", this.commandName);
     return obj.ToString();
 }
        public ActionResult Create()
        {
            int contactId = -1;
            ViewModels.Tasks.CreateTaskViewModel viewModel;
            Common.Models.Matters.Matter matter;
            List<ViewModels.Account.UsersViewModel> userList;
            List<ViewModels.Contacts.ContactViewModel> employeeContactList;
            Newtonsoft.Json.Linq.JArray taskTemplates;

            userList = new List<ViewModels.Account.UsersViewModel>();
            employeeContactList = new List<ViewModels.Contacts.ContactViewModel>();
            
            dynamic profile = ProfileBase.Create(Membership.GetUser().UserName);
            if (profile.ContactId != null && !string.IsNullOrEmpty(profile.ContactId))
                contactId = int.Parse(profile.ContactId);

            using (IDbConnection conn = Data.Database.Instance.GetConnection())
            {
                Data.Account.Users.List(conn, false).ForEach(x =>
                {
                    userList.Add(Mapper.Map<ViewModels.Account.UsersViewModel>(x));
                });

                Data.Contacts.Contact.ListEmployeesOnly(conn, false).ForEach(x =>
                {
                    employeeContactList.Add(Mapper.Map<ViewModels.Contacts.ContactViewModel>(x));
                });

                viewModel = new ViewModels.Tasks.CreateTaskViewModel();
                viewModel.TaskTemplates = new List<ViewModels.Tasks.TaskTemplateViewModel>();
                taskTemplates = new Newtonsoft.Json.Linq.JArray();
                Data.Tasks.TaskTemplate.List(conn, false).ForEach(x =>
                {
                    viewModel.TaskTemplates.Add(Mapper.Map<ViewModels.Tasks.TaskTemplateViewModel>(x));
                    Newtonsoft.Json.Linq.JObject template = new Newtonsoft.Json.Linq.JObject();
                    template.Add(new Newtonsoft.Json.Linq.JProperty("Id", x.Id.Value));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("TaskTemplateTitle", x.TaskTemplateTitle));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("Title", x.Title));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("Description", x.Description));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("ProjectedStart", DTProp(x.ProjectedStart)));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("DueDate", DTProp(x.DueDate)));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("ProjectedEnd", DTProp(x.ProjectedEnd)));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("ActualEnd", DTProp(x.ActualEnd)));
                    template.Add(new Newtonsoft.Json.Linq.JProperty("Active", x.Active));
                    taskTemplates.Add(template);
                });

                if (contactId > 0)
                {
                    viewModel.TaskContact = new ViewModels.Tasks.TaskAssignedContactViewModel()
                    {
                        Contact = new ViewModels.Contacts.ContactViewModel()
                        {
                            Id = contactId
                        }
                    };
                }

                matter = Data.Matters.Matter.Get(Guid.Parse(Request["MatterId"]), conn, false);
            }

            ViewBag.Matter = matter;
            ViewBag.UserList = userList;
            ViewBag.EmployeeContactList = employeeContactList;
            ViewBag.TemplateJson = taskTemplates.ToString();

            return View(new ViewModels.Tasks.CreateTaskViewModel()
            {
                TaskTemplates = viewModel.TaskTemplates,               
                TaskContact = new ViewModels.Tasks.TaskAssignedContactViewModel()
                {
                    AssignmentType = ViewModels.AssignmentTypeViewModel.Direct,
                    Contact = viewModel.TaskContact.Contact
                }
            });
        }
Exemplo n.º 48
0
 public static TradeTransactionStatusCommand createTradeTransactionStatusCommand(long? requestId, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("requestId", requestId);
     return new TradeTransactionStatusCommand(args, prettyPrint);
 }
Exemplo n.º 49
0
 public static SymbolCommand createSymbolCommand(string symbol, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("symbol", symbol);
     return new SymbolCommand(args, prettyPrint);
 }
Exemplo n.º 50
0
 public static TradeRecordsCommand createTradeRecordsCommand(LinkedList<long?> orders, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     JSONArray arr = new JSONArray();
     foreach (long? order in orders)
     {
         arr.Add(order);
     }
     args.Add("orders", arr);
     return new TradeRecordsCommand(args, prettyPrint);
 }
Exemplo n.º 51
0
 public void unsubscribePrice(String symbol)
 {
     JSONObject ob = new JSONObject();
     ob.Add("command", "stopTickPrices");
     ob.Add("symbol", symbol);
     writeMessage(ob.ToString());
 }
Exemplo n.º 52
0
 public static TradesHistoryCommand createTradesHistoryCommand(long? start, long? end, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("start", start);
     args.Add("end", end);
     return new TradesHistoryCommand(args, prettyPrint);
 }
Exemplo n.º 53
0
 public static TradesCommand createTradesCommand(bool openedOnly, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("openedOnly", openedOnly);
     return new TradesCommand(args, prettyPrint);
 }
Exemplo n.º 54
0
        private string GetValidMask(CustomFieldType customFieldType, String mask)
        {
            var resultMask = new Newtonsoft.Json.Linq.JObject();
            if (String.IsNullOrEmpty(mask) ||
                (customFieldType != CustomFieldType.TextField && customFieldType != CustomFieldType.TextArea && customFieldType != CustomFieldType.SelectBox))
            {
                return String.Empty;
            }

            try
            {
                var maskObj = Newtonsoft.Json.Linq.JToken.Parse(mask);
                if (customFieldType == CustomFieldType.TextField)
                {
                    var size = maskObj.Value<int>("size");
                    if (size == 0)
                    {
                        resultMask.Add("size", 1);
                    }
                    else if (size > Global.MaxCustomFieldSize)
                    {
                        resultMask.Add("size", Global.MaxCustomFieldSize);
                    }
                    else
                    {
                        resultMask.Add("size", size);
                    }
                }
                if (customFieldType == CustomFieldType.TextArea)
                {
                    var rows = maskObj.Value<int>("rows");
                    var cols = maskObj.Value<int>("cols");

                    if (rows == 0)
                    {
                        resultMask.Add("rows", 1);
                    }
                    else if (rows > Global.MaxCustomFieldRows)
                    {
                        resultMask.Add("rows", Global.MaxCustomFieldRows);
                    }
                    else
                    {
                        resultMask.Add("rows", rows);
                    }

                    if (cols == 0)
                    {
                        resultMask.Add("cols", 1);
                    }
                    else if (cols > Global.MaxCustomFieldCols)
                    {
                        resultMask.Add("cols", Global.MaxCustomFieldCols);
                    }
                    else
                    {
                        resultMask.Add("cols", cols);
                    }
                }
                if (customFieldType == CustomFieldType.SelectBox)
                {
                    if (maskObj is Newtonsoft.Json.Linq.JArray)
                    {
                        return mask;
                    }
                    else
                    {
                        throw new ArgumentException("Mask is not valid");
                    }
                }
            }
            catch (Exception ex)
            {
                if (customFieldType == CustomFieldType.TextField)
                {
                    resultMask.Add("size", Global.DefaultCustomFieldSize);
                }
                if (customFieldType == CustomFieldType.TextArea)
                {
                    resultMask.Add("rows", Global.DefaultCustomFieldRows);
                    resultMask.Add("cols", Global.DefaultCustomFieldCols);
                }
                if (customFieldType == CustomFieldType.SelectBox)
                {
                    throw ex;
                }
            }
            return JsonConvert.SerializeObject(resultMask);
        }
Exemplo n.º 55
0
 public static TradeTransactionCommand createTradeTransactionCommand(TradeTransInfoRecord tradeTransInfo, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("tradeTransInfo", tradeTransInfo.toJSONObject());
     return new TradeTransactionCommand(args, prettyPrint);
 }
Exemplo n.º 56
0
        private Newtonsoft.Json.Linq.JObject parseStruct(OEIShared.IO.GFF.GFFStruct gffStruct)
        {
            var j = new Newtonsoft.Json.Linq.JObject();

            foreach (OEIShared.IO.GFF.GFFField field in gffStruct.Fields.Values)
                j.Add(field.StringLabel, parseField(field));

            return j;
        }
Exemplo n.º 57
0
        public void Deploy()
        {
            Console.WriteLine("");
            Console.WriteLine("Deploying JSON");

            Console.WriteLine("Loading Module directory " + sModulePath + "...");
            DirectoryResourceRepository directoryResourceRepository = new DirectoryResourceRepository(sModulePath);

            ContentManager contentManager = new ContentManager(sClientPath, sServerPath);
            NWN2ResourceManager manager = new NWN2ResourceManager();

            contentManager.ServerContentItemScanning += (name, status, bBegin) =>
            {
                if (!bBegin)
                    Console.Write(" -> Staging (" + status.ToString() + ")");
                else
                    Console.Write("\nScanning: " + name);
            };

            contentManager.InitializeModule(directoryResourceRepository);
            contentManager.ResetAllResourcesToDefaultServer();
            contentManager.ResetScanResults();

            checked
            {
                manager.AddRepository(directoryResourceRepository);

                string sModuleName = Path.GetFileNameWithoutExtension(sModulePath);
                string sTlkPath = "";

                foreach (DownloadableResource d in contentManager.GetDownloadableResources())
                {
                    switch (d.Type)
                    {
                        case DownloadableResource.FileType.Hak:
                            string hakPath = sHomePath + "\\hak\\" + d.Name;
                            Console.WriteLine("Adding Hak: " + d.Name);
                            if (File.Exists(hakPath))
                                manager.AddRepository(new ERFResourceRepository(hakPath));
                            else
                                Console.WriteLine("ERROR - Hak file not found in " + hakPath);
                            break;

                        case DownloadableResource.FileType.Tlk:
                            sTlkPath = sHomePath + "\\tlk\\" + d.Name;
                            if (File.Exists(sTlkPath))
                                Console.WriteLine("Found TLK: " + d.Name);
                            else
                                Console.WriteLine("ERROR - Tlk not found in " + sTlkPath);
                            break;
                    }
                }

                KeyValuePair<String, ushort>[] resourceTypes = { new KeyValuePair<String, ushort>("creature", ResUTC),
                                                               new KeyValuePair<String, ushort>("door", ResUTD),
                                                               new KeyValuePair<String, ushort>("encounter", ResUTE),
                                                               new KeyValuePair<String, ushort>("item", ResUTI),
                                                               new KeyValuePair<String, ushort>("store", ResUTM),
                                                               new KeyValuePair<String, ushort>("placeable", ResUTP),
                                                               new KeyValuePair<String, ushort>("tree", ResUTR),
                                                               new KeyValuePair<String, ushort>("sound", ResUTS),
                                                               new KeyValuePair<String, ushort>("trigger", ResUTT),
                                                               new KeyValuePair<String, ushort>("waypoint", ResUTW),
                                                               new KeyValuePair<String, ushort>("light", ResULT),
                                                               new KeyValuePair<String, ushort>("prefab", ResPFB) };

                //ushort[] resourceTypes = { ResUTC, ResUTD, ResUTE, ResUTI, ResUTM, ResUTP, ResUTR, ResUTS, ResUTT, ResUTW, ResULT, ResPFB };

                var json = new Newtonsoft.Json.Linq.JObject();

                foreach (KeyValuePair<String, ushort> rType in resourceTypes)
                {
                    var jsonArray = new Newtonsoft.Json.Linq.JArray();

                    foreach (IResourceEntry resource in manager.FindEntriesByType(rType.Value))
                    {
                        Console.WriteLine(rType.Key + ": " + resource.FullName);

                        var gff = new OEIShared.IO.GFF.GFFFile(resource.GetStream(false));

                        if (gff != null)
                        {
                            Newtonsoft.Json.Linq.JObject jsonData = null;

                            jsonData = new Newtonsoft.Json.Linq.JObject(parseGFF(gff));
                            //Console.WriteLine(jsonData);
                            /*
                            switch (rType.Value)
                            {
                                case ResUTC:
                                    var creature = new NWN2Toolset.NWN2.Data.Blueprints.NWN2CreatureBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(creature);
                                    break;
                                case ResUTD:
                                    var door = new NWN2Toolset.NWN2.Data.Blueprints.NWN2DoorBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(door);
                                    break;
                                case ResUTE:
                                    var encounter = new NWN2Toolset.NWN2.Data.Blueprints.NWN2EncounterBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(encounter);
                                    break;
                                case ResUTI:
                                    var item = new NWN2Toolset.NWN2.Data.Blueprints.NWN2ItemBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(item);
                                    break;
                                case ResUTM:
                                    var store = new NWN2Toolset.NWN2.Data.Blueprints.NWN2StoreBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(store);
                                    break;
                                case ResUTP:
                                    var placeable = new NWN2Toolset.NWN2.Data.Blueprints.NWN2PlaceableBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(placeable);
                                    break;
                                case ResUTR:
                                    var tree = new NWN2Toolset.NWN2.Data.Blueprints.NWN2TreeBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(tree);
                                    break;
                                case ResUTS:
                                    var sound = new NWN2Toolset.NWN2.Data.Blueprints.NWN2SoundBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(sound);
                                    break;
                                case ResUTT:
                                    var trigger = new NWN2Toolset.NWN2.Data.Blueprints.NWN2TriggerBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(trigger);
                                    break;
                                case ResUTW:
                                    var waypoint = new NWN2Toolset.NWN2.Data.Blueprints.NWN2WaypointBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(waypoint);
                                    break;
                                case ResULT:
                                    var light = new NWN2Toolset.NWN2.Data.Blueprints.NWN2LightBlueprint(gff.TopLevelStruct);
                                    jsonData = new Newtonsoft.Json.Linq.JObject(light);
                                    break;
                                case ResPFB:
                                    //blueprint = new NWN2Toolset.NWN2.Data.Blueprints.NWN2BlueprintSet(gff.TopLevelStruct);
                                    break;
                                default:
                                    break;
                            }
                            */
                            if (jsonData != null) jsonArray.Add(jsonData);
                        }
                    }

                    if (jsonArray.Count > 0) json.Add(rType.Key,jsonArray);
                }

                Console.WriteLine("");
                Console.WriteLine("Staging JSON Complete.");
                Console.WriteLine("");
                Console.WriteLine(json);

                System.IO.File.WriteAllText(@".\nwn2.json", json.ToString());
            }
        }
        private VirtualMachine SetAzureVMDiagnosticsExtensionC(VirtualMachine selectedVM, string storageAccountName, string storageAccountKey)
        {
            System.Xml.XmlDocument xpublicConfig = null;

            var extensionName = AEMExtensionConstants.WADExtensionDefaultName[this.OSType];

            var extTemp = this._Helper.GetExtension(selectedVM,
                AEMExtensionConstants.WADExtensionType[this.OSType], AEMExtensionConstants.WADExtensionPublisher[OSType]);
            object publicConf = null;
            if (extTemp != null)
            {
                publicConf = extTemp.Settings;
                extensionName = extTemp.Name;
            }

            if (publicConf != null)
            {
                var jpublicConf = publicConf as Newtonsoft.Json.Linq.JObject;
                if (jpublicConf == null)
                {
                    throw new ArgumentException();
                }

                var base64 = jpublicConf["xmlCfg"] as Newtonsoft.Json.Linq.JValue;
                if (base64 == null)
                {
                    throw new ArgumentException();
                }

                System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
                xDoc.LoadXml(Encoding.UTF8.GetString(System.Convert.FromBase64String(base64.Value.ToString())));

                if (xDoc.SelectSingleNode("/WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters") != null)
                {
                    xDoc.SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration").Attributes["overallQuotaInMB"].Value = "4096";
                    xDoc.SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters").Attributes["scheduledTransferPeriod"].Value = "PT1M";

                    xpublicConfig = xDoc;
                }
            }

            if (xpublicConfig == null)
            {
                xpublicConfig = new System.Xml.XmlDocument();
                xpublicConfig.LoadXml(AEMExtensionConstants.WADConfigXML);
            }

            foreach (var perfCounter in AEMExtensionConstants.PerformanceCounters[OSType])
            {
                var currentCounter = xpublicConfig.
                            SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters/PerformanceCounterConfiguration[@counterSpecifier = '" + perfCounter.counterSpecifier + "']");
                if (currentCounter == null)
                {
                    var node = xpublicConfig.CreateElement("PerformanceCounterConfiguration");
                    xpublicConfig.SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters").AppendChild(node);
                    node.SetAttribute("counterSpecifier", perfCounter.counterSpecifier);
                    node.SetAttribute("sampleRate", perfCounter.sampleRate);
                }
            }

            var endpoint = this._Helper.GetCoreEndpoint(storageAccountName);
            endpoint = "https://" + endpoint;

            Newtonsoft.Json.Linq.JObject jPublicConfig = new Newtonsoft.Json.Linq.JObject();
            jPublicConfig.Add("xmlCfg", new Newtonsoft.Json.Linq.JValue(System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(xpublicConfig.InnerXml))));

            Newtonsoft.Json.Linq.JObject jPrivateConfig = new Newtonsoft.Json.Linq.JObject();
            jPrivateConfig.Add("storageAccountName", new Newtonsoft.Json.Linq.JValue(storageAccountName));
            jPrivateConfig.Add("storageAccountKey", new Newtonsoft.Json.Linq.JValue(storageAccountKey));
            jPrivateConfig.Add("storageAccountEndPoint", new Newtonsoft.Json.Linq.JValue(endpoint));

            WriteVerbose("Installing WAD extension");
            VirtualMachineExtension vmExtParameters = new VirtualMachineExtension();

            vmExtParameters.Publisher = AEMExtensionConstants.WADExtensionPublisher[this.OSType];
            vmExtParameters.VirtualMachineExtensionType = AEMExtensionConstants.WADExtensionType[this.OSType];
            vmExtParameters.TypeHandlerVersion = AEMExtensionConstants.WADExtensionVersion[this.OSType];
            vmExtParameters.Settings = jPublicConfig;
            vmExtParameters.ProtectedSettings = jPrivateConfig;
            vmExtParameters.Location = selectedVM.Location;

            this.VirtualMachineExtensionClient.CreateOrUpdate(ResourceGroupName, selectedVM.Name, extensionName, vmExtParameters);

            return this.ComputeClient.ComputeManagementClient.VirtualMachines.Get(ResourceGroupName, selectedVM.Name);
        }
Exemplo n.º 59
0
 public static TradeTransactionCommand createTradeTransactionCommand(TRADE_OPERATION_CODE cmd, TRADE_TRANSACTION_TYPE type, double? price, double? sl, double? tp, string symbol, double? volume, long? ie_deviation, long? order, string comment, long? expiration, bool prettyPrint)
 {
     JSONObject args = new JSONObject();
     args.Add("tradeTransInfo", (new TradeTransInfoRecord(cmd, type, price, sl, tp, symbol, volume, ie_deviation, order, comment, expiration)).toJSONObject());
     return new TradeTransactionCommand(args, prettyPrint);
 }
Exemplo n.º 60
-1
 public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
 {
     var exception = value as System.Exception;
     if (exception != null)
     {
         var resolver = serializer.ContractResolver as Newtonsoft.Json.Serialization.DefaultContractResolver ?? _defaultContractResolver;
 
         var jObject = new Newtonsoft.Json.Linq.JObject();
         jObject.Add(resolver.GetResolvedPropertyName("discriminator"), exception.GetType().Name);
         jObject.Add(resolver.GetResolvedPropertyName("Message"), exception.Message);
         jObject.Add(resolver.GetResolvedPropertyName("StackTrace"), _hideStackTrace ? "HIDDEN" : exception.StackTrace);
         jObject.Add(resolver.GetResolvedPropertyName("Source"), exception.Source);
         jObject.Add(resolver.GetResolvedPropertyName("InnerException"),
             exception.InnerException != null ? Newtonsoft.Json.Linq.JToken.FromObject(exception.InnerException, serializer) : null);
 
         foreach (var property in GetExceptionProperties(value.GetType()))
         {
             var propertyValue = property.Key.GetValue(exception);
             if (propertyValue != null)
             {
                 jObject.AddFirst(new Newtonsoft.Json.Linq.JProperty(resolver.GetResolvedPropertyName(property.Value),
                     Newtonsoft.Json.Linq.JToken.FromObject(propertyValue, serializer)));
             }
         }
 
         value = jObject;
     }
 
     serializer.Serialize(writer, value);
 }