Exemple #1
0
        public JsonResult GetCodeState(string id)
        {
            THC_CodeTypeLib.CodeGenState codeState;
            try
            {
                THC_CodeTypeLib.CodeGenProxy codeProxy = (THC_CodeTypeLib.CodeGenProxy)
                                                         Activator.GetObject(typeof(THC_CodeTypeLib.CodeGenProxy),
                                                                             "tcp://127.0.0.1:8000/RemoteCodeGen");
                codeState = codeProxy.GetCondeGenState(id);
            }
            catch (Exception ex)
            {
                codeState          = new THC_CodeTypeLib.CodeGenState();
                codeState.HasError = true;
                codeState.State    = ex.ToString();
            }
            string retJson = Newtonsoft.Json.JsonConvert.SerializeObject(codeState);

            return(Json(retJson, "application/json", JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public JsonResult GenerateCode(string key)
        {
            Error.Error error = null;

            WebHTCBackEnd.Models.Events.THC_EventCodeGen objCodeGen = new Models.Events.THC_EventCodeGen();
            DataTable codegenData = objCodeGen.queryEventCodeGenByKey(key, out error);

            string retJson;

            if (error != null)
            {
                retJson = Newtonsoft.Json.JsonConvert.SerializeObject(error);
            }
            else
            {
                //if (codegenData.Rows.Count == 1)
                {
                    string strEventKey  = codegenData.Rows[0]["AE001"].ToString();
                    string strEventName = codegenData.Rows[0]["AE003"].ToString();
                    int    iQRBit       = int.Parse(codegenData.Rows[0]["AE010"].ToString());
                    int    iSerialBit   = int.Parse(codegenData.Rows[0]["AE011"].ToString());
                    int    iLen         = int.Parse(codegenData.Rows[0]["AE018"].ToString());
                    int    iTotalQty    = int.Parse(codegenData.Rows[0]["EQCH007"].ToString());
                    int    iSerial      = int.Parse(codegenData.Rows[0]["AE017"].ToString()) + 1;


                    THC_CodeTypeLib.CodeGenProxy codeProxy = (THC_CodeTypeLib.CodeGenProxy)
                                                             Activator.GetObject(typeof(THC_CodeTypeLib.CodeGenProxy),
                                                                                 "tcp://127.0.0.1:8000/RemoteCodeGen");
                    string strId = codeProxy.CodeGenerate(strEventName, strEventKey, key, iLen, iSerialBit, iQRBit, iTotalQty, iSerial);

                    retJson = string.Format("[{{ \"STATE\" : \"{0}\", \"ID\" : \"{1}\" }}]",
                                            "RUN", strId);
                }
            }

            return(Json(retJson, "application/json", JsonRequestBehavior.AllowGet));
        }