Example #1
0
        public void BatchImport()
        {
            BllFireBox    bll  = new BllFireBox();
            ModJsonResult json = new ModJsonResult();
            ModFireBox    t    = new ModFireBox();

            try
            {
                string GroupName   = DateTimeHelper.DateTimeToUnixTimestamp(DateTime.Now).ToString();//时间戳进行分组
                int    CountNum    = int.Parse(Request["CountNum"].ToString());
                int    resultCount = 0;
                for (int i = 0; i < CountNum; i++)
                {
                    resultCount++;
                    t.Id             = Guid.NewGuid().ToString();
                    t.Name           = "";                 //
                    t.Address        = "";                 //
                    t.Status         = (int)StatusEnum.禁用;
                    t.Img            = QrCode(t.Id + "X"); //箱子二维码最后大写X
                    t.QrCode         = t.Id;
                    t.SysId          = CurrentMaster.Cid;
                    t.EquipmentCount = 0;
                    if (!string.IsNullOrEmpty(Request["CompanyId"]))
                    {
                        if (Request["CompanyId"].ToString().Trim() != "0")
                        {
                            //单位管理员创建的设备.
                            t.SysId = Request["CompanyId"].ToString();
                        }
                    }
                    t.CreateTime = DateTime.Now;     //创建时间
                    t.CreaterId  = CurrentMaster.Id; //创建人编号
                    int result = bll.Insert(t);
                }
                if (resultCount <= 0)
                {
                    json.success = false;
                    json.msg     = "生成失败,请稍后再操作!";
                    LogInsert(OperationTypeEnum.操作, "批量箱子二维码", "生成失败.");
                }
                else
                {
                    LogInsert(OperationTypeEnum.操作, "批量箱子二维码", "生成成功.");
                }
            }
            catch (Exception ex)
            {
                LogInsert(OperationTypeEnum.异常, "批量箱子二维码", "操作异常信息:" + ex);
            }
            WriteJsonToPage(json.ToString());
        }
Example #2
0
        public void SaveData(ModFireBox t)
        {
            BllFireBox    bll  = new BllFireBox();
            ModJsonResult json = new ModJsonResult();

            try
            {
                if (!string.IsNullOrEmpty(Request["modify"])) //修改
                {
                    ModFireBox model = bll.LoadData(t.Id);
                    model.Name    = t.Name;
                    model.Address = t.Address;
                    if (t.Name != "" && t.Address != "")
                    {
                        model.Status = (int)StatusEnum.正常;
                    }
                    int result = bll.Update(model);
                    if (result <= 0)
                    {
                        json.success = false;
                        json.msg     = "修改失败,请稍后再操作!";
                        LogInsert(OperationTypeEnum.操作, "设备位置修改", "位置修改失败.");
                    }
                    else
                    {
                        LogInsert(OperationTypeEnum.操作, "设备位置修改", "位置修改成功.");
                    }
                }
                else
                {
                    //string QrCodeNum = t.Id + "X";
                    //Regex reg = new Regex("[-]+");
                    //QrCodeNum = reg.Replace(QrCodeNum, "");
                    t.Id             = Guid.NewGuid().ToString();
                    t.Status         = (int)StatusEnum.正常;
                    t.Img            = QrCode(t.Id + "X");//箱子二维码最后大写X
                    t.QrCode         = t.Id;
                    t.SysId          = CurrentMaster.Cid;
                    t.EquipmentCount = 0;
                    if (!string.IsNullOrEmpty(Request["CompanyId"]))
                    {
                        if (Request["CompanyId"].ToString().Trim() != "0")
                        {
                            //单位管理员创建的设备.
                            t.SysId = Request["CompanyId"].ToString();
                        }
                    }
                    t.CreateTime = DateTime.Now;     //创建时间
                    t.CreaterId  = CurrentMaster.Id; //创建人编号
                    int result = bll.Insert(t);

                    if (result <= 0)
                    {
                        json.success = false;
                        json.msg     = "生成失败,请稍后再操作!";
                        LogInsert(OperationTypeEnum.操作, "设备位置添加", "生成失败.");
                    }
                    else
                    {
                        LogInsert(OperationTypeEnum.操作, "设备位置添加", "生成成功.");
                    }
                }
            }
            catch (Exception ex)
            {
                LogInsert(OperationTypeEnum.异常, "设备位置添加", "操作异常信息:" + ex);
            }
            WriteJsonToPage(json.ToString());
        }