Пример #1
0
        public ActionResult InfoPanel_Create(ViewModel_InfoPanel infoPanel, string id)
        {
            if (infoPanel != null && ModelState.IsValid)
            {
                // Random Encrpty Key
                ZMClass zmc = new ZMClass();

                string sIPRowid = Guid.NewGuid().ToString();
                string sKey     = sIPRowid.Substring(0, 16);

                // 用自key產生加密key
                byte[] bKey = zmc.AESEncrypt(sKey, sKey);
                sKey = Convert.ToBase64String(bKey).Substring(0, 16);
                byte[] bCipher = zmc.AESEncrypt(sIPRowid, sKey);
                string sCipher = Convert.ToBase64String(bCipher);

                var target = new InfoPanel();
                target.IPRowid      = sIPRowid;
                target.IPHospRowid  = id;
                target.IPName       = infoPanel.IPName;
                target.IPDisplaySeq = infoPanel.IPDisplaySeq;
                target.IPCBDCode    = infoPanel.IPCBDCode;
                target.IPKey        = sKey;
                target.IPCipher     = "obid=" + sCipher;

                db_opdboard.InfoPanel.Add(target);
                db_opdboard.SaveChanges();

                infoPanel.IPRowid = target.IPRowid;
            }

            return(Json(new[] { infoPanel }.ToDataSourceResult(new DataSourceRequest(), ModelState)));
        }