Exemplo n.º 1
0
        /// <summary>
        /// 后台数据库插入
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        private int CreateDataByMc(DateTime startTime, DateTime endTime, int startCode, int endCode, int OneNum, int OneSleep)
        {
            try
            {
                SetProgess("0%");
                SetMsg("正在检查数据库连接");
                bool result = Common.CheckDataBaseExist();

                if (!result)
                {
                    return(1);
                }

                SetProgess("2%");
                SetMsg("正在获取指定用户信息");
                mc_user userInfo = LibHelper.GetUserInfoByPoliceCodeMC(GetTextBoxValue(txtPoliceCode));

                if (userInfo == null)
                {
                    return(2);
                }

                SetProgess("5%");
                SetMsg("正在获取组织架构信息");
                List <mc_organization> orgList = LibHelper.GetOrgInfosMC();
                if (orgList == null || orgList.Count == 0)
                {
                    return(3);
                }

                SetProgess("8%");
                SetMsg("正在获取设备信息");
                List <mc_device> deviceInfos = LibHelper.GetDeviceInfosMC(GetTextBoxValue(txtDeviceID));
                if (deviceInfos == null || deviceInfos.Count == 0)
                {
                    return(4);
                }

                mc_organization userOrgInfo = orgList.Find(p => p.org_id.Equals(userInfo.org_id));
                if (userOrgInfo == null)
                {
                    return(5);
                }

                int count = 0;
                int index = 0;
                for (int i = startCode; i <= endCode; i++)
                {
                    if (GetCheckValue(cbDeviceLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建WEB执法记录仪操作日志信息", i));
                        count += LibHelper.AddCameraLogByMc(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            GetTextBoxValue(txtDeviceCode),
                            userInfo,
                            orgList,
                            userOrgInfo,
                            deviceInfos,
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    if (GetCheckValue(cbStationLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建WEB采集站操作日志信息", i));
                        count += LibHelper.AddStationLogByMC(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            startCode.ToString(),
                            GetTextBoxValue(txtClientCode),
                            userInfo,
                            userOrgInfo,
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    if (GetCheckValue(cbMediaLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建WEB媒体数据信息", i));
                        count += LibHelper.AddMediaLogMC(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            userInfo,
                            userOrgInfo,
                            deviceInfos,
                            orgList,
                            GetTextBoxValue(txtVideo),
                            GetTextBoxValue(txtAudio),
                            GetTextBoxValue(txtImage),
                            GetTextBoxValue(txtCollectDir),
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }
                    //if (GetCheckValue(cbalarmLog))
                    //{
                    //    index++;
                    //    SetMsg("正在创建WEB告警信息");
                    //    count += LibHelper.AddAlarmlog(
                    //                                       startTime,
                    //                                       endTime,
                    //                                       Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                    //                                       GetTextBoxValue(txtAlarmCode),
                    //                                       index,
                    //                                       CountProgess
                    //                                       );
                    //}

                    if (GetCheckValue(cbManageLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建媒体数据信息", i));
                        count += LibHelper.AddManageCenterlog(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            userInfo,
                            userOrgInfo,
                            GetTextBoxValue(txtManageCode),
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    //if (GetCheckValue(cbStatusLog))
                    //{
                    //    index++;
                    //    SetMsg("正在创建WEB状态信息");
                    //    count += LibHelper.AddStatuslog(
                    //                                       startTime,
                    //                                       endTime,
                    //                                       Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                    //                                       index,
                    //                                       CountProgess
                    //                                       );
                    //}
                }

                SetProgess("100%");
                SetMsg("创建WEB模拟信息完成");
                return(count);
            }
            catch (Exception e)
            {
                error = e.Message;
                return(-1);
            }
        }