Exemple #1
0
        /// <summary>
        /// 1、数据连接失败;2、用户信息没有找到;3、组织架构为空
        /// </summary>
        /// <returns></returns>
        private int CreateDataByDs(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("正在获取指定用户信息");
                ds_user userInfo = LibHelper.GetUserInfoByPoliceCode(GetTextBoxValue(txtPoliceCode));

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

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

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

                ds_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}创建执法记录仪操作日志信息", i));
                        count += LibHelper.AddCameraLog(
                            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}创建采集工作站操作日志信息", i));
                        count += LibHelper.AddStationLog(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            GetTextBoxValue(txtClientCode),
                            userInfo,
                            userOrgInfo,
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }

                    if (GetCheckValue(cbMediaLog))
                    {
                        index++;
                        SetMsg(string.Format("正在为{0}创建采集工作站媒体数据信息", i));
                        count += LibHelper.AddMediaLog(
                            startTime,
                            endTime,
                            Convert.ToInt32(GetTextBoxValue(txtDayNum)),
                            i.ToString(),
                            userInfo,
                            userOrgInfo,
                            deviceInfos,
                            orgList,
                            GetTextBoxValue(txtVideo),
                            GetTextBoxValue(txtAudio),
                            GetTextBoxValue(txtImage),
                            GetTextBoxValue(txtCollectDir),
                            index, OneNum,
                            OneSleep,
                            CountProgess
                            );
                    }
                }

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