Example #1
0
        public void Load()
        {
            CfgVersion ver = CfgVersionBll.GetFirstCfg();

            if (ver != null)
            {
                _verInDb = ver.Version.Value;
            }

            lstOrgsByDb     = OrgBll.GetAllOrgInfo();
            lstGroupsByDb   = GroupBll.GetAllGroupInfo();
            lstProjectsByDb = ProjectBll.GetAllProject();
            lstCardsByDb    = CardWithCommDevBll.GetAllDevList();

            MakeMemCard(_loadFlag);
            MakeMemProject(_loadFlag);
            MakeMemGroup(_loadFlag);
            MakeMemOrg(_loadFlag);

            MakeMemCommByClientSn(_loadFlag);

            MakeCardRef();
            MakeProjectRef();
            MakeGroupRef();
            MakeOrgRef();

            lstOrgsByDb.Clear();
            lstGroupsByDb.Clear();
            lstProjectsByDb.Clear();
            lstCardsByDb.Clear();
        }
        public string GetAllCards(string strJsonParam)
        {
            string             strError;
            RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name,
                                                                           strJsonParam, out strError);

            if (reqinfo == null)
            {
                return(strError);
            }

            List <GasCardWithCommInfo> lsts = CardWithCommDevBll.GetAllDevList();

            if (lsts == null)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginNameOrPassword));
            }

            // 成功返回成功标志及新增加的ID
            JsonResutlModelString result = new JsonResutlModelString()
            {
                ErrorDesc = "success",
                Info      = JsonStrObjConver.Obj2JsonStr(lsts, typeof(List <GasCardWithCommInfo>)),
                Status    = true,
                StatusInt = 1
            };

            return(JsonStrObjConver.Obj2JsonStr(result, typeof(JsonResutlModelString)));
        }
        public string DelADevById(string strJsonParam)
        {
            string             strError;
            RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name,
                                                                           strJsonParam, out strError);

            if (reqinfo == null)
            {
                return(strError);
            }

            int id = 0;

            int.TryParse(reqinfo.Info, out id);

            if (id <= 0)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError));
            }

            bool bResult = CardWithCommDevBll.DelDev(id);

            if (!bResult)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginNameOrPassword));
            }

            // 成功返回成功标志及新增加的ID
            JsonResutlModelString result = new JsonResutlModelString()
            {
                ErrorDesc = "success",
                Info      = id.ToString(),
                Status    = true,
                StatusInt = 1
            };

            return(JsonStrObjConver.Obj2JsonStr(result, typeof(JsonResutlModelString)));
        }
        public string UpdateADev(string strJsonParam)
        {
            string             strError;
            RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name,
                                                                           strJsonParam, out strError);

            if (reqinfo == null)
            {
                return(strError);
            }

            GasCardWithCommInfo mod = JsonStrObjConver.JsonStr2Obj(reqinfo.Info, typeof(GasCardWithCommInfo))
                                      as GasCardWithCommInfo;

            if (mod == null)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError));
            }

            bool bResult = CardWithCommDevBll.UpdateDev(mod, out strError);

            if (!bResult)
            {
                return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginNameOrPassword));
            }

            // 成功返回成功标志及新增加的ID
            JsonResutlModelString result = new JsonResutlModelString()
            {
                ErrorDesc = "success",
                Info      = mod.Id.ToString(),
                Status    = true,
                StatusInt = 1
            };

            return(JsonStrObjConver.Obj2JsonStr(result, typeof(JsonResutlModelString)));
        }
        private void InsertNewCard(DataTable dwCard)
        {
            foreach (DataRow row in dwCard.Rows)
            {
                string strId          = row["Index"].ToString();
                string strName        = row["CardName"].ToString();
                string strPass        = row["CardPassword"].ToString();
                string strSn          = row["CardSn"].ToString();
                string strMod         = row["CardModel"].ToString();
                string strIsDoub      = row["IsDouble"].ToString();
                string strPointCount  = row["PointCount"].ToString();
                string strRefProject  = row["RefProject"].ToString();
                string strScreenCount = row["ScreenCount"].ToString();

                if (CardWithCommDevBll.IsNameExist(strName))
                {
                    continue;
                }

                if (CardWithCommDevBll.IsSnExise(strSn))
                {
                    continue;
                }

                int iPointIdx    = 0;
                int iScreenCount = 0;
                int.TryParse(strPointCount, out iPointIdx);
                int.TryParse(strScreenCount, out iScreenCount);
                //MemCfgInfo.MemProjectInfo prj = GlareSysDataCenter.MemCfgInfo.MemDbMgr.Get().GetMemProjectByName(strRefProject);
                //if (prj == null)
                //{ continue; }
                int iProjectID = DataLoader.GetProjectIDByProjectName(strRefProject);
                if (!string.IsNullOrWhiteSpace(iProjectID.ToString()))
                {
                    int iGroupID = DataLoader.GetGroupIDByProjectID(iProjectID);
                    int iOrgID   = DataLoader.GetOrgIDByProjectID(iProjectID);
                    GlareSysEfDbAndModels.GasCardWithCommInfo card = new GlareSysEfDbAndModels.GasCardWithCommInfo()
                    {
                        Address           = "",
                        BEnable           = 1,
                        CardBrightness    = 9,
                        CardContext       = "",
                        CardIsDouble      = strIsDoub == "1" ? 1 : 0,
                        CardModel         = strMod,
                        CardNumberCount   = GetDigNumByModel(strMod),
                        CardPointCount    = iPointIdx,
                        CardScreenCount   = iScreenCount,
                        CityId            = "",
                        Comment           = "",
                        CommServerSn      = strSn,
                        CommExtConnInfo   = "",
                        CommSerialBaud    = 0,
                        CommSerialDataBit = 0,
                        CommSerialParity  = 0,
                        CommSerialPort    = "",
                        CommSerialStopBit = 0,
                        CommServerIp      = "",
                        CommServerPort    = 0,
                        CommTimeoutMs     = 2000,
                        CommType          = 0,
                        CreateDt          = DateTime.Now,
                        DefName           = strName,
                        DefPassword       = strPass,
                        GroupId           = iGroupID,
                        Id           = 0,
                        IsDel        = 0,
                        OrgId        = iOrgID,
                        Password     = strPass,
                        PosLatitude  = "",
                        PosLongitude = "",
                        ProjectId    = iProjectID,
                        ProtocolType = 1,
                        ScreenNams   = "1#-2#-3#-4#-5#-6#",
                        Name         = strName,
                        UpdateDt     = DateTime.Now
                    };
                    string strError;
                    CardWithCommDevBll.AddDev(ref card, out strError);
                }
            }
        }
Example #6
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string strScrName = textBoxScreenName1.Text + "-"
                                + textBoxScreenName2.Text + "-"
                                + textBoxScreenName3.Text + "-"
                                + textBoxScreenName4.Text + "-"
                                + textBoxScreenName5.Text + "-"
                                + textBoxScreenName6.Text + "-"
                                + textBoxScreenName7.Text + "-"
                                + textBoxScreenName8.Text + "-"
                                + textBoxScreenName9.Text + "-"
                                + textBoxScreenName10.Text + "-"
                                + textBoxScreenName11.Text + "-"
                                + textBoxScreenName12.Text;

            GasCardWithCommInfo mod = new GasCardWithCommInfo()
            {
                Id                = 0,
                Name              = textBoxName.Text,
                Address           = "1",
                CardModel         = comboBoxCardModeType.SelectedText,
                CardIsDouble      = 1,
                CardBrightness    = 1,
                CardPointCount    = comboBoxPointIndex.SelectedIndex,
                CardNumberCount   = comboBoxNumCount.SelectedIndex + 1,
                CardScreenCount   = comboBoxScreenCount.SelectedIndex + 1,
                ProjectId         = (int)comboBoxProject.SelectedValue,
                GroupId           = (int)comboBoxGroup.SelectedValue,
                OrgId             = (int)comboBoxOrg.SelectedValue,
                CardContext       = "888888-888888-888888-888888-888888-888888-888888-888888-888888-888888-888888-888888",
                ScreenNams        = strScrName,
                CreateDt          = DateTime.Now,
                UpdateDt          = DateTime.Now,
                BEnable           = 1,
                CityId            = "0",
                Comment           = "",
                CommExtConnInfo   = "",
                CommSerialBaud    = 0,
                CommSerialDataBit = 0,
                CommSerialParity  = 0,
                CommSerialPort    = "0",
                CommSerialStopBit = 0,
                CommServerIp      = "",
                CommServerPort    = 0,
                CommServerSn      = textBoxConnSn.Text,
                CommTimeoutMs     = 2000,
                CommType          = 1,
                DefName           = textBoxName.Text,
                DefPassword       = textBoxPassword.Text,
                IsDel             = 0,
                Password          = textBoxPassword.Text,
                PosLatitude       = "0",
                PosLongitude      = "0",
                ProtocolType      = 0,
            };
            string strMsg;

            if (!CardWithCommDevBll.AddDev(ref mod, out strMsg))
            {
                MessageBox.Show(strMsg);
                DialogResult = DialogResult.None;
            }
        }