Esempio n. 1
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            String cUrl = Config.GetAppSettings(AppConfig.WEB_URL) + "api/rest.ashx";
            Dictionary <String, String> vParmList = new Dictionary <string, string>();

            vParmList.Add("action_type", "WFJB");
            vParmList.Add("action_method", "GTWS");
            vParmList.Add("open_id", CameraID);
            //vParmList.Add("org_id", ApplicationEvent.UserInfo.ORG_ID);
            vParmList.Add("address", txtAddress.Text);
            vParmList.Add("content", txtContent.Text);
            String[] FileList = new string[1];
            FileList[0] = PHOTO_FILENAME;

            HttpUtil     vTool  = new HttpUtil();
            string       cValue = vTool.HttpPost(cUrl, vParmList, FileList);
            ActiveResult vret   = ActiveResult.Valid(AppConfig.FAILURE);

            if (!String.IsNullOrEmpty(cValue))
            {
                vret = JsonLib.ToObject <ActiveResult>(cValue);
            }

            if (vret.result == AppConfig.SUCCESS)
            {
                MessageBox.Show("数据保存成功!");
                this.Close();
            }
            else
            {
                MessageBox.Show("数据保存失败,稍后请重试!");
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Pull()
        {
            // Identify calling client. If now allowed, return RPC failure.
            string?clientID = auth.GetClientID(Request);

            if (clientID == null)
            {
                return(Unauthorized());
            }
            // Read request body (if any). We do not use a [FromBody] parameter, because
            // we want to explicitly use our JsonLib for deserializing (and not overwrite the
            // user's selected default ASP.NET Core JSON serializer)
            RpcCommandResult?lastResult = null;

            using (var reader = new StreamReader(Request.Body)) {
                var body = await reader.ReadToEndAsync();

                if (body.Length > 0)
                {
                    lastResult = JsonLib.FromJson <RpcCommandResult>(body);
                }
            }
            // Report result and query next method
            return(Ok(await RpcServerEngine.Instance.OnClientPull(clientID, lastResult)));
        }
Esempio n. 3
0
        /// <summary>
        /// Call this method after enqueuing the command to wait for the result of its execution.
        /// The returned task finishes when the call was either successfully executed and
        /// acknowledged, or failed (e.g. because of a timeout).
        /// The result is stored in the given command itself. If successful, the return value
        /// is also returned, otherwise an <see cref="RpcException"/> is thrown.
        /// </summary>
        public async Task <T> WaitForResult <T>()
        {
            try {
                // Wait for result until timeout
                await Task.WhenAny(runningTask.Task, Task.Delay(TimeoutMs ?? defaultTimeoutMs));

                // Timeout?
                if (false == IsFinished())
                {
                    throw new RpcException(new RpcFailure(RpcFailureType.Timeout, "Timeout"));
                }
                // Failed? Then throw RPC exception
                var result = GetResult();
                if (result.Failure is RpcFailure failure)
                {
                    throw new RpcException(failure);
                }
                // Return JSON-encoded result (or null for void return type)
                if (result.ResultJson is string json)
                {
                    return(JsonLib.FromJson <T>(json));
                }
                else
                {
                    return(default !);
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckLogin();
        LoginUserInfo vUserInfo = getLoginUserInfo();

        DBConfig vConf = new DBConfig();

        ORG_ID = vUserInfo.ORG_ID;
        cHOST  = vConf.getOrgKey(ORG_ID, "GTWS_HOST");
        cPORT  = vConf.getOrgKey(ORG_ID, "GTWS_PORT");
        cUSER  = vConf.getOrgKey(ORG_ID, "GTWS_USER");
        cPASS  = vConf.getOrgKey(ORG_ID, "GTWS_PASS");
        XT_CAMERA_Dao dao = new XT_CAMERA_Dao();

        DataTable CountyList = dao.QueryData("DISTINCT ORG_ID,COUNTY", "ORG_ID LIKE '" + AppManager.getAreaHeader(ORG_ID) + "%'", " ORDER BY ORG_ID");
        List <Dictionary <String, string> > KeyList = new List <Dictionary <string, string> >();

        DataTable VillageList = dao.QueryData("DISTINCT VILLAGE_ID,VILLAGE,ORG_ID", "ORG_ID LIKE '" + AppManager.getAreaHeader(ORG_ID) + "%'", " ORDER BY ORG_ID");

        List <string> ORG_LIST = new List <string>();

        for (int i = 0; i < CountyList.Rows.Count; i++)
        {
            String cID     = StringEx.getString(CountyList, i, "ORG_ID");
            String cCOUNTY = StringEx.getString(CountyList, i, "COUNTY");
            Dictionary <string, string> vo = new Dictionary <string, string>();
            vo.Add("id", cID);
            vo.Add("name", cCOUNTY);
            vo.Add("value", cID);
            vo.Add("pid", "0");
            vo.Add("isParent", "true");
            KeyList.Add(vo);
        }
        ROOT_LIST = JsonLib.ToJSON(KeyList);
    }
Esempio n. 5
0
        public async Task <IActionResult> Push()
        {
            // Identify calling client. If now allowed, return RPC failure.
            string?clientID = auth.GetClientID(Request);

            if (clientID == null)
            {
                return(Unauthorized());
            }
            // Read request body (if any). We do not use a [FromBody] parameter, because
            // we want to explicitly use our JsonLib for deserializing (and not overwrite the
            // user's selected default ASP.NET Core JSON serializer)
            try {
                using (var reader = new StreamReader(Request.Body)) {
                    var body = await reader.ReadToEndAsync();

                    if (body.Length > 0)
                    {
                        // Run command and return the result
                        var command = JsonLib.FromJson <RpcCommand>(body);
                        return(Ok(await RpcServerEngine.Instance.OnClientPush(clientID, command, runner)));
                    }
                }
            }
            catch { // Can happen when the client cancelled the request
            }
            // Command missing
            return(BadRequest());
        }
Esempio n. 6
0
        public static DataTable QueryData(String vSQL)
        {
            String cWebUrl = INIConfig.ReadString("Config", "WEB_URL");
            String cUrl    = "http://" + cWebUrl + "/api/rest.ashx";

            try
            {
                String cActionType   = "SQLDB";
                String cActionMethod = "QueryData";
                cUrl = cUrl + "?action_type=" + cActionType + "&action_method=" + cActionMethod;
                HttpUtil vPost = new HttpUtil();
                Dictionary <String, String> vData = new Dictionary <string, string>();
                vData.Add("SQL", vSQL);
                String       cStr = vPost.HttpPost(cUrl, vData);
                ActiveResult vret = JsonLib.ToObject <ActiveResult>(cStr);
                if (vret.result == AppConfig.SUCCESS)
                {
                    cStr = StringEx.getString(vret.info);
                    DataTable dtRows = JsonLib.ToObject <DataTable>(cStr);
                    return(dtRows);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 7
0
 public void SendMSG(String cSender, String cAccept, ActiveMQ_Message vMessage)
 {
     try
     {
         //通过工厂建立连接
         using (IConnection vActiveMQ = factory.CreateConnection())
         {
             //通过连接创建Session会话
             using (ISession session = vActiveMQ.CreateSession())
             {
                 //通过会话创建生产者,方法里面new出来的是MQ中的Queue
                 IMessageProducer prod = session.CreateProducer(new Apache.NMS.ActiveMQ.Commands.ActiveMQQueue("MQ" + cAccept));
                 //创建一个发送的消息对象
                 ITextMessage message = prod.CreateTextMessage();
                 //给这个对象赋实际的消息
                 message.Text = JsonLib.ToJSON(vMessage);
                 //设置消息对象的属性,这个很重要哦,是Queue的过滤条件,也是P2P消息的唯一指定属性
                 //message.Properties.SetString("filter", "demo");
                 //生产者把消息发送出去,几个枚举参数MsgDeliveryMode是否长链,MsgPriority消息优先级别,发送最小单位,当然还有其他重载
                 prod.Send(message, MsgDeliveryMode.NonPersistent, MsgPriority.Normal, TimeSpan.MinValue);
             }
         }
     }
     catch (Exception ex)
     {
         log4net.WriteLogFile(ex.Message);
     }
 }
Esempio n. 8
0
        public Dictionary <string, string> TestSetup(string testSettingsPath)
        {
            var value = "{\r\n\t\"SETUP\": {\r\n\t\t\r\n\t\t// START DONT CHANGE THE KEY BELOW\r\n\t\t\"ENVIRONMENT\": \"UAT\",\r\n\t\t//Available - LOCAL,SAUCE\r\n\t\t\"RUN_TEST\": \"LOCAL\",\r\n\t\t\"BROWSER\": \"CHROME\",\r\n\t\t\"VERSION\": \"45\",\r\n\t\t\"OS\": \"WINDOWS 7\",\r\n\t\t\"DEVICENAME\": \"\",\r\n\t\t\"DEVICEORIENTATION\": \"\",\r\n\t\t\"USERNAME_SAUCE\": \"aadhithbose\",\r\n\t\t\"ACCESS_KEY_SAUCE\": \"1cc813ac-bec2-4dd8-9e9e-a239ec2e7c2c\",\r\n\t\t\"WAIT_SEC\": \"180\",\r\n\t\t\"TIMEOUT_MIN\": \"3\",\r\n\t\t\"BATCH_FILE_DIRECTORY\": \"C:/TESTSUITE\",\r\n\t\t\"TEMP_FOLDER\": \"C:/TEMP_FOLDER\",\r\n\t\t\"MS_BUILD_PATH\": \"C:/PROGRAM FILES (X86)/MSBUILD/14.0/BIN/MSBUILD.EXE\",\r\n\t\t\"SOLUTION_NAME\": \"Parallel.Test.Framework.sln\",\r\n\t\t\"NUNIT_PATH\": \"/PACKAGES/NUNIT.CONSOLERUNNER.3.8.0/TOOLS\"\r\n\t\t// STOP DONT CHANGE THE KEY ABOVE\r\n\t\t// Can Create any other Key / Value Below\r\n\t}\r\n}\r\n";

            Create_TestSettingsFileIfItDidntExists(testSettingsPath, value);
            var data = new Dictionary <string, string>();

            try
            {
                var jsonLib  = new JsonLib();
                var o        = jsonLib.JObject(testSettingsPath);
                var testData = o.SelectToken("$.SETUP");
                var abc      = testData.ToObject <Dictionary <string, string> >();
                Console.WriteLine(@"Test Settings>>Setup Data Count" + abc.Count);
                foreach (var pair in abc)
                {
                    //Console.WriteLine(pair.Key + "" + pair.Value);
                    data.Add(pair.Key, pair.Value);
                }

                return(data);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error in Reading from TestSettings.json file" + e);
            }

            return(data);
        }
Esempio n. 9
0
        /// <summary>
        /// 执行SQL语句
        /// </summary>
        public void ExecSQL()
        {
            List <String>   sqls = new List <string>();
            List <Object[]> objs = new List <Object[]>();

            for (int i = 1; i < 1000; i++)
            {
                String cSQL  = StringEx.getString(request["SQL_" + i]);
                String cPARM = StringEx.getString(request["PARM_" + i]);
                if (!String.IsNullOrWhiteSpace(cSQL))
                {
                    sqls.Add(cSQL);
                    log4net.WriteLogFile("SQL--" + cSQL, LogType.DEBUG);
                    if (!String.IsNullOrWhiteSpace(cPARM))
                    {
                        Object[] parmList = JsonLib.ToObject <Object[]>(cPARM);
                        log4net.WriteLogFile("PARM--" + cPARM, LogType.DEBUG);
                        objs.Add(parmList);
                    }
                    else
                    {
                        objs.Add(null);
                    }
                }
                else
                {
                    break;
                }
            }
            ActiveResult vret  = ActiveResult.Valid(AppConfig.FAILURE);
            int          iCode = DbManager.ExecSQL(sqls, objs);

            vret = ActiveResult.Valid(iCode);
            response.Write(vret.toJSONString());
        }
Esempio n. 10
0
        public string ToJsonString()
        {
            string data = string.Empty;

            data = JsonLib.stringify(this);
            return(data);
        }
Esempio n. 11
0
        public Dictionary <string, string> ReadEnvironmentFromJson(string envJsonPath, string envName)
        {
            var value = "{\r\n\t\"TestEnv\": [{\r\n\t\t\t\"EnvName\": \"qa\",\r\n\t\t\t\"EnvDetails\": [{\r\n\t\t\t\t\"DbConnStr\": \"Data Source=sql02;User id=aadhi;Password=Secret;\",\r\n\t\t\t\t\"FrontEnd2\":\"https://www.google.com/\",\r\n\t\t\t\t\"BackEndTest\": \"https://fasteningcode.local/backend\"\r\n\t\t\t}]\r\n\t\t},\r\n\t\t{\r\n\t\t\t\"EnvName\": \"UAT\",\r\n\t\t\t\"EnvDetails\": [{\r\n\t\t\t\t\"FrontEnd\": \"http://fasteningcode.com/\",\r\n\t\t\t\t\"FrontEnd2\":\"https://www.google.com/\",\r\n\t\t\t\t\"DbConnUnsecured\": \"Data Source=sql03;User id=Aadhi;Password=Secret; Initial Catalog = Catalog8055;\"\r\n\t\t\t}]\r\n\t\t}\r\n\t]\r\n}";

            Create_TestSettingsFileIfItDidntExists(envJsonPath, value);

            var data = new Dictionary <string, string>();

            var jsonLib         = new JsonLib();
            var o               = jsonLib.JObject(envJsonPath);
            var testCaseDetails = o.SelectToken("$.TestEnv[?(@.EnvName == '" + envName + "')]");
            var testData        = testCaseDetails.SelectToken("$.EnvDetails");
            var abc             = testData.ToList();

            foreach (var a in abc)
            {
                //Console.WriteLine(a.Type);
                if (a.Type == JTokenType.Object)
                {
                    var obj = a.ToObject <Dictionary <string, string> >();
                    foreach (var pair in obj)
                    {
                        data.Add(pair.Key, pair.Value);
                    }
                }
            }
            return(data);
        }
Esempio n. 12
0
        /// <summary>
        /// Polls the next command to execute locally from the server. The result of the
        /// last executed command must be given, if there is one. The returned Task may block
        /// some time, because the server uses the long polling technique to reduce network traffic.
        /// If the server can not be reached, an exception is thrown (because the last result
        /// has to be transmitted again).
        /// </summary>
        private async Task <RpcCommand?> PullFromServer(RpcCommandResult?lastResult)
        {
            // Long polling. The server returns null after the long polling time.
            var bodyJson = lastResult != null?JsonLib.ToJson(lastResult) : null;

            var httpResponse = await httpPull.PostAsync(clientConfig.ServerUrl + "/pull",
                                                        bodyJson != null?new StringContent(bodyJson, Encoding.UTF8, "application/json") : null);

            if (httpResponse.IsSuccessStatusCode)
            {
                // Last result was received. The server responded with the next command or null,
                // if there is currently none.
                if (httpResponse.Content.Headers.ContentLength > 0)
                {
                    return(JsonLib.FromJson <RpcCommand>(await httpResponse.Content.ReadAsStringAsync()));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                // Remote exception.
                throw new Exception("Server responded with status code " + httpResponse.StatusCode);
            }
        }
Esempio n. 13
0
 public void EnqueueCommand(string clientID, RpcCommand command)
 {
     lock (syncLock) {
         var dir = GetDirectory(clientID);
         // Apply strategy
         var strategy = command.RetryStrategy;
         if (strategy == null || strategy == RpcRetryStrategy.None)
         {
             // No retry strategy chosen. This method should not have been called at all. Do nothing.
             return;
         }
         else if (strategy == RpcRetryStrategy.RetryWhenOnline)
         {
             // No preparation needed; just enqueue this command
         }
         else if (strategy == RpcRetryStrategy.RetryNewestWhenOnline)
         {
             // Remove all preceding commands of this type
             foreach (var file in GetFilesByCommandName(clientID, command.MethodName))
             {
                 file.Delete();
             }
         }
         var filename = command.ID + "-" + command.MethodName;
         File.WriteAllText(Path.Combine(dir.FullName, filename), JsonLib.ToJson(command));
     }
 }
Esempio n. 14
0
        public static int ExecSQL(List <String> sqlList, List <Object[]> parmList)
        {
            String cWebUrl = INIConfig.ReadString("Config", "WEB_URL");
            String cUrl    = "http://" + cWebUrl + "/api/rest.ashx";

            try
            {
                String cActionType   = "SQLDB";
                String cActionMethod = "ExecSQL";
                cUrl = cUrl + "?action_type=" + cActionType + "&action_method=" + cActionMethod;
                HttpUtil vPost = new HttpUtil();
                Dictionary <String, String> vData = new Dictionary <string, string>();
                for (int i = 0; i < sqlList.Count; i++)
                {
                    String vSQL = sqlList[i];
                    vData.Add("SQL_" + (i + 1), vSQL);
                    if (parmList != null)
                    {
                        String cParm = JsonLib.ToJSON(parmList[i]);
                        vData.Add("PARM_" + (i + 1), cParm);
                    }
                }
                String       cStr = vPost.HttpPost(cUrl, vData);
                ActiveResult vret = JsonLib.ToObject <ActiveResult>(cStr);
                return(vret.result);
            }
            catch (Exception ex)
            {
                return(AppConfig.FAILURE);
            }
        }
Esempio n. 15
0
 public async Task SayHelloToClient(Greeting greeting)
 {
     Console.WriteLine("Hello " + greeting.Name + "!");
     if (greeting.MoreData is SampleData moreData)
     {
         Console.WriteLine("More information for you: " + JsonLib.ToJson(moreData));
     }
 }
Esempio n. 16
0
        void onConsumerListener(IMessage message)
        {
            ITextMessage msg = (ITextMessage)message;

            //异步调用下,否则无法回归主线程
            log4net.WriteLogFile(msg.Text);
            String           cStr     = msg.Text;
            ActiveMQ_Message vMessage = JsonLib.ToObject <ActiveMQ_Message>(cStr);

            Change(vMessage);
        }
Esempio n. 17
0
 public static List <ExportObject> Explain(String cStr)
 {
     try
     {
         return(JsonLib.ToObject <List <ExportObject> >(cStr));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Esempio n. 18
0
 public void DequeueCommand(string clientID, ulong commandID)
 {
     lock (syncLock) {
         if (GetLatestFile(clientID) is FileInfo file)
         {
             var command = JsonLib.FromJson <RpcCommand>(File.ReadAllText(file.FullName));
             if (command.ID == commandID)
             {
                 file.Delete();
             }
         }
     }
 }
Esempio n. 19
0
        public List <Rectangle> FindRectangle(String cREC_ID)
        {
            List <Rectangle> KeyList = new List <Rectangle>();
            DataTable        dtRows  = DbManager.QueryData("SELECT POINT_LIST FROM XT_IMG_LIST WHERE ALARM_FLAG=1 AND REC_ID='" + cREC_ID + "'");

            for (int i = 0; i < dtRows.Rows.Count; i++)
            {
                String    cPOINT_LIST = StringEx.getString(dtRows, i, "POINT_LIST");
                Rectangle rf          = JsonLib.ToObject <Rectangle>(cPOINT_LIST);
                KeyList.Add(rf);
            }
            return(KeyList);
        }
Esempio n. 20
0
 public RpcCommand?PeekCommand(string clientID)
 {
     lock (syncLock) {
         if (GetLatestFile(clientID) is FileInfo file)
         {
             return(JsonLib.FromJson <RpcCommand>(File.ReadAllText(file.FullName)));
         }
         else
         {
             return(null);
         }
     }
 }
Esempio n. 21
0
 /// <summary>
 /// Creates a new encoded RPC command, using the given method name and parameters.
 /// The parameters must be JSON-encodable objects.
 /// </summary>
 private RpcCommand(string methodName, params object[] methodParameters)
 {
     lock (syncLock) {
         loop++;
         if (loop > 999)
         {
             loop = 0;
         }
         ID = ((ulong)CoreUtils.TimeNow()) * 1000 + loop;
     }
     MethodName       = methodName;
     MethodParameters = methodParameters.Select(it => JsonLib.ToJson(it)).ToList();
 }
Esempio n. 22
0
        public static String Pack(String cTABLE_ID, DataTable dtRows, String cRootDir, String cSYSID)
        {
            List <ExportObject> arKeys        = new List <ExportObject>();
            DataTable           dtFieldConfig = DbManager.QueryData("SELECT FIELD_NAME,ISKEY FROM S_ETL_FIELD WHERE TABLE_ID='" + cTABLE_ID + "'");

            for (int j = 0; (dtRows != null) && (j < dtRows.Rows.Count); j++)
            {
                ExportObject vo = new ExportObject();
                vo.TABLE_ID = cTABLE_ID;
                vo.SYS_ID   = cSYSID;
                String cKEY_ID = StringEx.getString(dtRows, 0, "ID").ToUpper();
                for (int k = 0; (dtFieldConfig != null) && (k < dtFieldConfig.Rows.Count); k++)
                {
                    String cFieldName  = StringEx.getString(dtFieldConfig, k, "FIELD_NAME").ToUpper();
                    String cFieldValue = StringEx.getString(dtRows, j, cFieldName);
                    vo.AddFieldValue(cFieldName, Base64.StrToBase64(cFieldValue));
                }
                String cFileID_List = StringEx.getString(dtRows, 0, "FILES_ID").ToUpper();
                if (cFileID_List.Length > 0)
                {
                    String[] File_List = cFileID_List.Split(',');
                    cFileID_List = "";
                    for (int i = 0; i < File_List.Length; i++)
                    {
                        if (cFileID_List == "")
                        {
                            cFileID_List = "'" + File_List[i] + "'";
                        }
                        else
                        {
                            cFileID_List = cFileID_List + "," + "'" + File_List[i] + "'";
                        }
                    }

                    DataTable dtFiles = DbManager.QueryData("SELECT ID,TEXT,URL FROM S_UPLOAD WHERE ID in (" + cFileID_List + ")");
                    for (int k = 0; (dtFiles != null) && (k < dtFiles.Rows.Count); k++)
                    {
                        String cID       = StringEx.getString(dtFiles, k, "ID").ToUpper();
                        String cText     = StringEx.getString(dtFiles, k, "TEXT").ToUpper();
                        String cUrl      = StringEx.getString(dtFiles, k, "URL").ToUpper();
                        String cFileName = cRootDir + cUrl.Replace("/", "\\");
                        if (File.Exists(cFileName))
                        {
                            vo.AddFileValue(cID, cText, cUrl, Base64.StrToBase64(cFileName));
                        }
                    }
                }
                arKeys.Add(vo);
            }
            return(JsonLib.ToJSON(arKeys));
        }
Esempio n. 23
0
 public static Boolean RedrawImage(String cFileName, String cRect)
 {
     try
     {
         Image<Bgr, byte> vImage = new Image<Bgr, byte>(cFileName);
         Rectangle vRect = JsonLib.ToObject<Rectangle>(cRect);
         CvInvoke.Rectangle(vImage, vRect, new MCvScalar(255, 0, 0), 2);
         vImage.Save(cFileName);
         return true;
     }
     catch (Exception ex)
     {
         log4net.WriteLogFile(ex.Message);
         return false;
     }
 }
Esempio n. 24
0
        public void BusinessflowReportTest()
        {
            string BusinessFlowReportFile = GingerTestHelper.TestResources.GetTestResourcesFile(@"Reports\BusinessFlow.txt");

            try
            {
                BusinessFlowReport BFR = (BusinessFlowReport)JsonLib.LoadObjFromJSonFile(BusinessFlowReportFile, typeof(BusinessFlowReport));
                Assert.AreEqual("Failed", BFR.RunStatus);
                Assert.AreEqual(float.Parse("36.279", CultureInfo.InvariantCulture), BFR.ElapsedSecs.Value);
            }

            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }
Esempio n. 25
0
        public void ActivityReportTest()
        {
            string ActivityReportFile = GingerTestHelper.TestResources.GetTestResourcesFile(@"Reports\Activity.txt");

            try
            {
                ActivityReport AR = (ActivityReport)JsonLib.LoadObjFromJSonFile(ActivityReportFile, typeof(ActivityReport));
                Assert.AreEqual("Passed", AR.RunStatus);
                Assert.AreEqual(2044, AR.Elapsed);
            }

            catch (Exception Ex)
            {
                Assert.Fail(Ex.Message);
            }
        }
Esempio n. 26
0
        public void Child()
        {
            String cKeyID = StringEx.getString(request["ID"]);
            String cVKey, cVName;
            List <Dictionary <string, string> > arKeys = new List <Dictionary <string, string> >();
            int       iTypeID = StringEx.getInt(cKeyID);
            DataTable dtRows  = null;

            if (cKeyID.Length == 6)
            {
                dtRows = dao.QueryData("DISTINCT VILLAGE_ID AS ID, VILLAGE AS TEXT", " (ORG_ID='" + cKeyID + "') ", " order by VILLAGE ");
            }
            else
            {
                dtRows = dao.QueryData("ID, DEVICE_ID, ADDR AS TEXT", " (VILLAGE_ID='" + cKeyID + "') ", " order by ADDR ");
            }

            for (int i = 0; i < dtRows.Rows.Count; i++)
            {
                cVKey  = StringEx.getString(dtRows, i, "ID");
                cVName = StringEx.getString(dtRows, i, "TEXT");
                Dictionary <string, string> vo = new Dictionary <string, string>();
                vo.Add("id", cVKey);
                vo.Add("text", cVName);
                vo.Add("name", cVName);
                vo.Add("pid", cKeyID);
                vo.Add("value", cVKey);
                if (cKeyID.Length == 6)
                {
                    vo.Add("isParent", "true");
                    vo.Add("device_id", "");
                }
                else
                {
                    vo.Add("isParent", "false");
                    vo.Add("device_id", StringEx.getString(dtRows, i, "DEVICE_ID"));
                }
                arKeys.Add(vo);
            }

            // response.Write(cStart + JsonLib.toJSONString(arKeys) + cFinish);
            response.Write(JsonLib.ToJSON(arKeys));
        }
Esempio n. 27
0
        public void QueryData()
        {
            ActiveResult vret = ActiveResult.Valid(AppConfig.FAILURE);
            String       sql  = StringEx.getString(request["SQL"]);

            log4net.WriteLogFile("SQL:" + sql, LogType.DEBUG);
            if (String.IsNullOrWhiteSpace(sql))
            {
                vret = ActiveResult.Valid("SQL语句不能为空!");
            }
            else
            {
                DataTable dtRows = DbManager.QueryData(sql);
                String    cStr   = JsonLib.ToJSON(dtRows);
                vret = ActiveResult.returnObject(cStr);
            }

            response.Write(vret.toJSONString());
        }
Esempio n. 28
0
        public static DBResult Query(String cFileList, String cTableName, String cWhereParm, String cOrderBy, int iPageNo, int iPageSize)
        {
            String cWebUrl = INIConfig.ReadString("Config", "WEB_URL");
            String cUrl    = "http://" + cWebUrl + "/api/rest.ashx";

            try
            {
                String cActionType   = "SQLDB";
                String cActionMethod = "Query";
                cUrl = cUrl + "?action_type=" + cActionType + "&action_method=" + cActionMethod;
                HttpUtil vPost = new HttpUtil();
                Dictionary <String, String> vData = new Dictionary <string, string>();
                vData.Add("FILELIST", cFileList);
                vData.Add("TABLENAME", cTableName);
                vData.Add("WHEREPARM", cWhereParm);
                vData.Add("ORDERBY", cOrderBy);
                vData.Add("PAGENO", StringEx.getString(iPageNo));
                vData.Add("PAGESIZE", StringEx.getString(iPageSize));

                String       cStr = vPost.HttpPost(cUrl, vData);
                ActiveResult vret = JsonLib.ToObject <ActiveResult>(cStr);
                if (vret.result == AppConfig.SUCCESS)
                {
                    cStr = StringEx.getString(vret.info);
                    DataTable dtRows = JsonLib.ToObject <DataTable>(cStr);
                    DBResult  rs     = new DBResult();
                    rs.dtrows    = dtRows;
                    rs.ROW_COUNT = vret.total;
                    return(rs);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckLogin();
        ID = StringEx.getString(Request.QueryString["ID"]);
        LoginUserInfo    vUserInfo = getLoginUserInfo();
        String           cUSER_ID  = vUserInfo.USER_ID;
        String           cORG_ID   = vUserInfo.ORG_ID;
        String           cDayTime  = StringEx.getString(DateUtils.getDayTimeNum());
        String           cKeyID    = cUSER_ID + "@" + cORG_ID + "@" + cDayTime + "@" + ID;
        String           cKeyMD    = Base64.StrToBase64(cKeyID);
        ActiveMQ_Message vMessage  = new ActiveMQ_Message();

        vMessage.CMD_ID = ActiveMQ_MessageType.VIDEO_LIVE;
        Dictionary <string, string> voConf = new Dictionary <string, string>();

        voConf.Add("ID", ID);
        voConf.Add("ORG_ID", cORG_ID);
        voConf.Add("USER_ID", cUSER_ID);
        voConf.Add("DAYTIME", cDayTime);
        ID = cKeyMD;
        vMessage.MESSAGE = JsonLib.ToJSON(voConf);
        //ActiveMQ_Producer.SendMessage(cORG_ID, cUSER_ID, vMessage);
    }
        public void FetchTestData(string testSource, string testCaseId, string testDataNo)
        {
            TestData = new Dictionary <string, string>();
            var jsonLib         = new JsonLib();
            var o               = jsonLib.JObject(testSource);
            var testCaseDetails = o.SelectToken("$.TestCases[?(@.TestCaseId == '" + testCaseId + "')]");
            var testDataDetails = testCaseDetails.SelectToken("$.TestRow[?(@.RowNumber == '" + testDataNo + "')]");
            var testData        = testDataDetails.SelectToken("$.TestData");

            var abc = testData.ToList();

            foreach (var a in abc)
            {
                //Console.WriteLine(a.Type);
                if (a.Type == JTokenType.Object)
                {
                    var obj = a.ToObject <Dictionary <string, string> >();
                    foreach (var pair in obj)
                    {
                        TestData.Add(pair.Key, pair.Value);
                    }
                }
            }
        }