Ejemplo n.º 1
0
 public static CommandQueueData ToViewData(this CommandQueue node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node == null)
     {
         return(null);
     }
     return(new CommandQueueData()
     {
         Id = node.Id,
         //MeterActionId = node.MeterActionId,
         CommandType = node.CommandType,
         CommandTime = node.CommandTime,
         SendCount = node.SendCount,
         SendSource = node.SendSource,
         CommandValue = node.CommandValue,
         IsReply = node.IsReply,
         ReplyTime = node.ReplyTime,
         ReplyValue = node.ReplyValue,
         CommandNum = node.CommandNum,
         CommandGroup = node.CommandGroup,
         GatewayIpAddress = node.GatewayIpAddress,
         Rs485Addr = node.Rs485Addr,
         Port = node.Port,
         isSucc = node.isSucc,
         isErr = node.isErr,
         Priority = node.Priority,
     });
 }
Ejemplo n.º 2
0
        //public static MaintenanceData ToViewData(this Maintenance node, CategoryDictionary suffix = CategoryDictionary.None)
        //{
        //    if (node == null)
        //        return null;
        //    return new MaintenanceData()
        //    {
        //        Id = node.Id,
        //        MaintenanceCategoryId = node.MaintenanceCategoryId,
        //        StateId = node.StateId,
        //        UserId = node.UserId,
        //        Title = node.Title,
        //        Content = node.Content,
        //        Picture = node.Picture,
        //        ObjectCategoryId = node.ObjectCategoryId,
        //        OperateObjectId = node.OperateObjectId,
        //        CreateDate = node.CreateDate,
        //        Comment = node.Comment,
        //        Rating = node.Rating,
        //        OperatorDiscription = node.OperatorDiscription
        //        //User = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) && node.User != null ? node.User.ToViewData() : null,
        //        //MaintenanceCategory = node.MaintenanceCategory.ToViewData(),
        //        //State = node.MaintenanceState.ToViewData(),
        //        //ObjectCategory = node.MaintenanceObjectCategory.ToViewData()

        //    };
        //}

        //public static IList<MaintenanceData> ToViewList(this IQueryable<Maintenance> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        //{
        //    if (nodes == null)
        //        return null;
        //    var nodeList = nodes.ToList();
        //    //var results = nodes.ToList().Select(x => x.ToViewData(suffix)).ToList();
        //    var results = nodeList.Select(node => new MaintenanceData()
        //    {
        //        Id = node.Id,
        //        MaintenanceCategoryId = node.MaintenanceCategoryId,
        //        StateId = node.StateId,
        //        UserId = node.UserId,
        //        Title = node.Title,
        //        Content = node.Content,
        //        Picture = node.Picture,
        //        ObjectCategoryId = node.ObjectCategoryId,
        //        OperateObjectId = node.OperateObjectId,
        //        CreateDate = node.CreateDate,
        //        Comment = node.Comment,
        //        Rating = node.Rating,
        //        OperatorDiscription = node.OperatorDiscription,

        //    }).ToList();

        //    return results;
        //}

        //public static Maintenance ToModel(this MaintenanceData node)
        //{
        //    return new Maintenance()
        //    {
        //        Id = node.Id,
        //        MaintenanceCategoryId = node.MaintenanceCategoryId,
        //        StateId = node.StateId,
        //        UserId = node.UserId,
        //        Title = node.Title,
        //        Content = node.Content,
        //        Picture = node.Picture,
        //        ObjectCategoryId = node.ObjectCategoryId,
        //        OperateObjectId = node.OperateObjectId,
        //        CreateDate = node.CreateDate,
        //        Comment = node.Comment,
        //        Rating = node.Rating,
        //        OperatorDiscription = node.OperatorDiscription,

        //    };
        //}
        #endregion

        #region Maintenance
        public static MaintenanceData ToViewData(this Maintenance node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            UserBLL     userBLL     = new UserBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (node == null)
            {
                return(null);
            }
            return(new MaintenanceData()
            {
                Id = node.Id,
                MaintenanceCategoryId = node.MaintenanceCategoryId,
                StateId = node.StateId,
                UserId = node.UserId,
                BuildingId = node.BuildingId,
                ApproverId = node.ApproverId,
                OperatorId = node.OperatorId,
                Title = node.Title,
                Content = node.Content,
                PictureId = node.PictureId,
                CreateDate = node.CreateDate,
                Rating = node.Rating,
                MaintenanceTime = node.MaintenanceTime,
                PurchasingId = node.PurchasingId,
                PictureUrl = node.PictureUrl,
                User = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) ? node.User.ToViewData() : null,         // node.User == null ? userBLL.Find(node.UserId).ToViewData() : node.User.ToViewData(),
                Approver = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) ? node.Approver.ToViewData() : null, //node.ApproverId != null ? node.Approver == null ? userBLL.Find(node.ApproverId).ToViewData() : node.Approver.ToViewData() : null,
                Operator = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) ? node.Operator.ToViewData() : null, //node.OperatorId != null ? node.Operator == null ? userBLL.Find(node.OperatorId).ToViewData() : node.Operator.ToViewData() : null,
                //State = node.State.ToViewData(),
                StateName = DictionaryCache.Get()[(int)node.StateId].ChineseName,
                BuildingName = buildingBLL.Find(node.BuildingId).Name,
            });
        }
Ejemplo n.º 3
0
        public static UserShortData ToShortViewData(this User node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            var results = new UserShortData()
            {
                Id             = node.Id,
                OrganizationId = node.OrganizationId,
                Email          = node.Email,
                EmailConfirmed = node.EmailConfirmed,
                //PasswordHash = node.PasswordHash,
                //SecurityStamp = node.SecurityStamp,
                PhoneNumber          = node.PhoneNumber,
                PhoneNumberConfirmed = node.PhoneNumberConfirmed,
                TwoFactorEnabled     = node.TwoFactorEnabled,
                LockoutEndDateUtc    = node.LockoutEndDateUtc,
                LockoutEnabled       = node.LockoutEnabled,
                AccessFailedCount    = node.AccessFailedCount,
                UserName             = node.UserName,
                FullName             = node.FullName,
                IdentityNo           = node.IdentityNo,
                IsResignOrGraduate   = node.IsResignOrGraduate,
                IsRightInfo          = node.IsRightInfo,
                ForeignId            = node.ForeignId,
                EnrollDate           = node.EnrollDate,
            };

            return(results);
        }
Ejemplo n.º 4
0
        public static OrganizationShortData ToShortViewData(this Organization node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new OrganizationShortData()
            {
                Id            = node.Id,
                ParentId      = node.ParentId,
                TreeId        = node.TreeId,
                Rank          = node.Rank,
                Name          = node.Name,
                AliasName     = node.AliasName,
                Initial       = node.Initial,
                Type          = node.Type,
                ManagerCount  = node.ManagerCount,
                CustomerCount = node.CustomerCount,
                ProvinceId    = node.ProvinceId,
                CityId        = node.CityId,
                DistrictId    = node.DistrictId,
                Enable        = node.Enable,
                Description   = node.Description
            };

            return(model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据配置创建用户账户,缴费角色
        /// </summary>
        /// <param name="monitoringConfig"></param>
        /// <param name="node"></param>
        public void CreateAcountByConfig(MonitoringConfig node)
        {
            //定价或补贴需要缴费账户
            if (node.ConfigTypeId == DictionaryCache.MonitoringConfigTypePrice.Id || node.ConfigTypeId == DictionaryCache.MonitoringConfigTypeSubsidy.Id)
            {
                //是否已经存在缴费账户
                int count = 0;

                //为当前对象开启缴费账户
                CategoryDictionary category = CategoryDictionary.Building;
                if (node.TargetTypeId == DictionaryCache.ConfigToOrg.Id)
                {
                    category = CategoryDictionary.Organization;
                    count    = userBLL.Count(o => o.Roles.Any(c => c.Id == RoleCache.PayMentRoleId) && o.Organizations.Any(c => c.Id == node.TargetId));
                }
                else
                {
                    count = userBLL.Count(o => o.Roles.Any(c => c.Id == RoleCache.PayMentRoleId) && o.Buildings.Any(c => c.Id == node.TargetId));
                }
                if (count > 0)
                {
                    return;
                }

                string error = "";
                List <UserAccountData> userAccounts;
                CreateAccounts(category, true, new List <string> {
                    node.TargetId + ""
                }, out error, out userAccounts);
            }
        }
Ejemplo n.º 6
0
        public IHttpActionResult GetByCategory(CategoryDictionary category, string id, [FromUri] CategoryDictionary suffix = CategoryDictionary.None)
        {
            var list = new List <Parameter>();
            var _id  = 0;

            int.TryParse(id, out _id);
            switch (category)
            {
            case CategoryDictionary.Meter:
                list = meterBLL.Filter(x => x.Id == _id).SelectMany(x => x.Brand.Parameters).ToList();
                break;

            case CategoryDictionary.Brand:
                list = brandBLL.Filter(x => x.Id == _id).SelectMany(x => x.Parameters).ToList();
                break;

            case CategoryDictionary.Manager:
            case CategoryDictionary.User:
            case CategoryDictionary.Role:
            case CategoryDictionary.Building:
            case CategoryDictionary.BuidlingCategory:
            case CategoryDictionary.MeterType:
            case CategoryDictionary.Organization:
            case CategoryDictionary.Parameter:
            case CategoryDictionary.Permission:
            case CategoryDictionary.EnergyCategory:
            case CategoryDictionary.BuildingType:
            case CategoryDictionary.Org:
            default:
                return(BadRequest("系统不支持此功能"));

                break;
            }
            return(Ok(list.Select(x => x.ToViewData(suffix))));
        }
Ejemplo n.º 7
0
        public JsonResult Edit(CategoryViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            rmodel = CheckName(model.Id, model.CategoryName, model.CategoryType);
            if (!rmodel.isSuccess)
            {
                return(Json(rmodel));
            }

            CategoryDictionary data = cdService.Get(model.Id);

            data.Name   = model.CategoryName;
            data.Type   = model.CategoryType;
            data.Parent = model.ParentId;

            bool isSuccess = cdService.Update(data);

            if (!isSuccess)
            {
                rmodel.message = "操作失败";
            }
            rmodel.isSuccess = isSuccess;

            return(Json(rmodel));
        }
Ejemplo n.º 8
0
        public JsonResult Add(CategoryViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            rmodel = CheckName(model.Id, model.CategoryName, model.CategoryType);
            if (!rmodel.isSuccess)
            {
                return(Json(rmodel));
            }

            CategoryDictionary downModel = new CategoryDictionary()
            {
                Name   = model.CategoryName,
                Parent = model.ParentId,
                State  = PublishState.Upper,
                Type   = model.CategoryType,
                UserId = GetAccount().Id
            };

            bool isSuccess = cdService.Add(downModel);

            if (!isSuccess)
            {
                rmodel.message = "操作失败";
            }
            rmodel.isSuccess = isSuccess;

            return(Json(rmodel));
        }
Ejemplo n.º 9
0
        public static MomentaryValueData ToViewData(this MomentaryValue node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            //var RatioParameterList = new List<int>() { 60004, 60005, 60006, 60007, 60008, 60009, 60010, 60011, 60012, 60019, 60020, 60021, 60022 };
            var RatioParameterList = DictionaryCache.RatioParameterList;
            var model = new MomentaryValueData()
            {
                Id            = node.Id,
                MeterId       = node.MeterId,
                ParameterId   = node.ParameterId,
                ParameterName = node.Parameter == null ? "" : node.Parameter.Type.ChineseName,
                ParameterType = node.Parameter == null ? 0 : node.Parameter.TypeId,
                Value         = node.Meter == null ? node.Value : (RatioParameterList.Contains(node.Parameter == null ? 0 : node.Parameter.TypeId) ? node.Value * node.Meter.Rate : node.Value),
                Time          = node.Time,
                Unit          = node.Parameter == null ? "" : node.Parameter.Unit,
                OriginalValue = node.Value
                                //Parameter = node.Parameter.ToViewData()
            };

            if ((suffix & CategoryDictionary.Parameter) == CategoryDictionary.Parameter)
            {
                model.Parameter = node.Parameter.ToViewData();
            }
            if ((suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter)
            {
                model.Meter = node.Meter.ToViewData();
            }

            return(model);
        }
Ejemplo n.º 10
0
        public static IList <GroupData> ToViewList(this IQueryable <Group> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            UserBLL userBLL = new UserBLL();

            if (nodes == null)
            {
                return(null);
            }
            var nodeList = nodes.ToList();
            var results  = nodeList.Select(node => new GroupData()
            {
                Id              = node.Id,
                GroupTypeId     = node.GroupTypeId,
                Name            = node.Name,
                Description     = node.Description,
                Enable          = node.Enable,
                RegeneratorId   = node.RegeneratorId,
                RegeneratorName = node.RegeneratorName,
                UpdatingTime    = node.UpdatingTime,
                GroupTypeName   = node.GroupType == null ? DictionaryCache.Get()[node.GroupTypeId].ChineseName : node.GroupType.ChineseName,
                Regenerator     = (suffix & CategoryDictionary.User) == CategoryDictionary.User ? (node.Regenerator == null ? userBLL.Find(node.RegeneratorId).ToViewData() : node.Regenerator.ToViewData()) : null,
            }).ToList();

            return(results);
        }
Ejemplo n.º 11
0
 public static FeedbackData ToViewData(this Feedback node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node == null)
     {
         return(null);
     }
     return(new FeedbackData()
     {
         Id = node.Id,
         UserId = node.UserId,
         TypeId = node.TypeId,
         Description = node.Description,
         CreateTime = node.CreateTime,
         HandleUserId = node.HandleUserId,
         HandleTime = node.HandleTime,
         HandleReply = node.HandleReply,
         Rating = node.Rating,
         Comment = node.Comment,
         StateId = node.StateId,
         StateName = DictionaryCache.Get()[node.StateId].ChineseName,
         TypeName = DictionaryCache.Get()[node.TypeId].ChineseName,
         IsDeleted = node.IsDeleted,
         User = ((suffix & CategoryDictionary.User) == CategoryDictionary.User) && node.HandleUser != null?node.User.ToViewData() : null,
                    HandleUser = ((suffix & CategoryDictionary.Manager) == CategoryDictionary.Manager) && node.HandleUser != null?node.HandleUser.ToViewData() : null,
                                     State = node.State.ToViewData()
     });
 }
Ejemplo n.º 12
0
        public static PurchaseData ToViewData(this Purchase node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            UserBLL        userBLL        = new UserBLL();
            MaintenanceBLL maintenanceBLL = new MaintenanceBLL();

            if (node == null)
            {
                return(null);
            }
            return(new PurchaseData()
            {
                Id = node.Id,
                MaintenanceId = node.MaintenanceId,
                CurrentOperatorId = node.CurrentOperatorId,
                ApproverId = node.ApproverId,
                MaterialName = node.MaterialName,
                MaterialNum = node.MaterialNum,
                MaterialPrice = node.MaterialPrice,
                Description = node.Description,
                IsAdopt = node.IsAdopt,
                CreateDate = node.CreateDate,
                ApplyDate = node.ApplyDate,
                Approver = node.ApproverId != null ? node.Approver == null?userBLL.Find(node.ApproverId).ToViewData() : node.Approver.ToViewData() : null,
                               CurrentOperator = node.CurrentOperatorId != null ? node.CurrentOperator == null?userBLL.Find(node.CurrentOperatorId).ToViewData() : node.CurrentOperator.ToViewData() : null,
                                                     //Maintenance = node.MaintenanceId != null ? node.Maintenance == null ? maintenanceBLL.Find(node.MaintenanceId).ToViewData() : node.Maintenance.ToViewData() : null,
            });
        }
Ejemplo n.º 13
0
        public static MessageData ToShortViewData(this Message node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new MessageData()
            {
                Id                    = node.Id,
                MessageTypeId         = node.MessageTypeId,
                CreateDate            = node.CreateDate,
                EndDate               = node.EndDate,
                MessageSourceTypeId   = node.MessageSourceTypeId,
                SrcId                 = node.SrcId,
                Subject               = node.Subject,
                Body                  = node.Body,
                Url                   = node.Url,
                ActiveDate            = node.ActiveDate,
                IsDeleted             = node.IsDeleted,
                NotActiveDate         = node.NotActiveDate,
                AlertLevelId          = node.AlertLevelId, //告警等级
                MessageTypeName       = node.MessageType == null?DictionaryCache.Get()[node.MessageTypeId].ChineseName : node.MessageType.ChineseName,
                MessageSourceTypeName = node.MessageSourceType == null?DictionaryCache.Get()[node.MessageSourceTypeId].ChineseName : node.MessageSourceType.ChineseName,
            };

            return(model);
        }
Ejemplo n.º 14
0
        public static UserData ToViewData(this User node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var results = new UserData()
            {
                Id             = node.Id,
                OrganizationId = node.OrganizationId,
                Email          = node.Email,
                EmailConfirmed = node.EmailConfirmed,
                //PasswordHash = node.PasswordHash,
                //SecurityStamp = node.SecurityStamp,
                PhoneNumber          = node.PhoneNumber,
                PhoneNumberConfirmed = node.PhoneNumberConfirmed,
                TwoFactorEnabled     = node.TwoFactorEnabled,
                LockoutEndDateUtc    = node.LockoutEndDateUtc,
                LockoutEnabled       = node.LockoutEnabled,
                AccessFailedCount    = node.AccessFailedCount,
                UserName             = node.UserName,
                FullName             = node.FullName,
                IdentityNo           = node.IdentityNo,
                IsResignOrGraduate   = node.IsResignOrGraduate,
                IsRightInfo          = node.IsRightInfo,
                ForeignId            = node.ForeignId,
                EnrollDate           = node.EnrollDate,
                StaffNo       = node.StaffNo,
                QQ            = node.QQ,
                WeChat        = node.WeChat,
                UserType      = node.UserType,
                Gender        = node.Gender ?? true,
                Organizations = ((suffix & CategoryDictionary.Organization) == CategoryDictionary.Organization) ? node.Organizations.ToList().Select(x => x.ToViewData()).ToList() : null,
                Buildings     = ((suffix & CategoryDictionary.Building) == CategoryDictionary.Building) ? node.Buildings.ToList().Select(x => x.ToViewData()).ToList() : null,
                Roles         = ((suffix & CategoryDictionary.Role) == CategoryDictionary.Role) ? node.Roles.ToList().Select(x => x.ToViewData()).ToList() : null
            };

            if ((suffix & CategoryDictionary.Org) == CategoryDictionary.Org)
            {
                OrganizationBLL OrganizationBLL = new BLL.OrganizationBLL();
                results.Org = (results.OrganizationId != null && (suffix & CategoryDictionary.Org) == CategoryDictionary.Org) ? OrganizationBLL.Find(results.OrganizationId).ToViewData() : null;
            }

            if ((suffix & CategoryDictionary.Account) == CategoryDictionary.Account)
            {
                UserAccountBLL userAccountBLL = new UserAccountBLL();
                results.Account = userAccountBLL.Filter(o => o.UserId == node.Id && o.Enable == true).ToViewList();
            }

            if ((suffix & CategoryDictionary.UserType) == CategoryDictionary.UserType)
            {
                if (results.UserType != null)
                {
                    DictionaryBLL dictBLL = new DictionaryBLL();
                    results.UserTypeName = dictBLL.Find(results.UserType).ChineseName;
                }
            }

            return(results);
        }
Ejemplo n.º 15
0
 public static RatedParameterData ToViewData(this RatedParameter node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node == null)
     {
         return(null);
     }
     return(new RatedParameterData()
     {
         Id = node.Id,
         RatedParameterTypeId = node.RatedParameterTypeId,
         BrandId = node.BrandId,
         ParameterId = node.ParameterId,
         Description = node.Description,
         MinValue = node.MinValue,
         MaxValue = node.MaxValue,
         Code = node.Code,
         SettingTime = node.SettingTime,
         PPF = node.PPF,
         RPF = node.RPF,
         PPFMax = node.PPFMax,
         PPFMin = node.PPFMin,
         RPFMax = node.RPFMax,
         RPFMin = node.RPFMin,
         Parameter = (suffix & CategoryDictionary.Parameter) == CategoryDictionary.Parameter ? node.Parameter.ToViewData() : null
     });
 }
Ejemplo n.º 16
0
        public static IList <ExtensionFieldData> ToViewList(this IQueryable <ExtensionField> nodes, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (nodes == null)
            {
                return(null);
            }
            var nodeList = nodes.ToList();
            var results  = nodeList.Select(node => new ExtensionFieldData()
            {
                Id          = node.Id,
                Database    = node.Database,
                Schema      = node.Schema,
                Table       = node.Table,
                Column      = node.Column,
                JoinId      = node.JoinId,
                StartTime   = node.StartTime,
                FinishTime  = node.FinishTime,
                Value       = node.Value,
                ValueType   = node.ValueType,
                ChineseName = node.ChineseName,
                EnglishName = node.EnglishName,
                Enable      = node.Enable,
                Description = node.Description
            }).ToList();

            if (nodeList != null && nodeList.Count() > 0)
            {
                var tableName           = nodeList[0].Table;
                CategoryDictionary dict = (CategoryDictionary)Enum.Parse(typeof(CategoryDictionary), tableName);
                if ((suffix & dict) == dict)
                {
                    var type = Type.GetType("WxPay2017.API.BLL." + tableName + "BLL");
                    var bll  = Activator.CreateInstance(type);
                    if (bll != null)
                    {
                        foreach (var model in results)
                        {
                            try
                            {
                                model.RelatedObject = type.GetMethod("Find", new Type[] { typeof(object[]) }).Invoke(bll, new object[1] {
                                    new object[] { model.JoinId }
                                });
                                var type2 = Type.GetType("WxPay2017.API.BLL." + tableName + "Extension");
                                System.Reflection.Assembly assm = System.Reflection.Assembly.Load("DAL");
                                Type typeModel = assm.GetType("" + tableName);
                                model.RelatedObject = type2.GetMethod("ToViewData", new Type[] { typeModel, typeof(CategoryDictionary) }).Invoke(model.RelatedObject, new object[2] {
                                    model.RelatedObject, CategoryDictionary.None
                                });
                            }
                            catch
                            {
                                model.RelatedObject = null;
                            }
                        }
                    }
                }
            }
            return(results);
        }
Ejemplo n.º 17
0
 public static RoleData ToViewData(this Role node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     return(new RoleData()
     {
         Id = node.Id,
         Name = node.Name
     });
 }
Ejemplo n.º 18
0
        public async Task <IHttpActionResult> PostImport(CategoryDictionary suffix = CategoryDictionary.Brand)
        {
            var user = await this.User.Identity.GetUser();

            // 检查是否是 multipart/form-data
            if (!Request.Content.IsMimeMultipartContent("form-data"))
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var guid = Guid.NewGuid();
            var path = HostingEnvironment.MapPath(string.Format("/template/{0}/{1}", user.Id, guid));

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // 设置上传目录
            var provider = new MultipartFormDataStreamProvider(path);
            // 接收数据,并保存文件

            var task = await Request.Content.ReadAsMultipartAsync(provider).ContinueWith <IHttpActionResult>(t =>
            {
                var fileInfo = new List <FileInfoData>();
                foreach (var i in provider.FileData)
                {
                    var filename = i.Headers.ContentDisposition.FileName.Trim('"');
                    var info     = new FileInfo(i.LocalFileName);
                    info.CopyTo(Path.Combine(path, filename), true);
                    try
                    {
                        var ds = BLL.Extensions.GetExcelDataSet(Path.Combine(path, filename));
                        BLL.Extensions.ImportBatchBasicData(ds, suffix);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    fileInfo.Add(new FileInfoData(filename, Path.Combine(path, filename), info.Length / 1024));
                    info.Delete();
                }

                //var fileInfo = provider.FileData.Select(i =>
                //{
                //    var filename = i.Headers.ContentDisposition.FileName.Trim('"');
                //    var info = new FileInfo(i.LocalFileName);
                //    info.CopyTo(Path.Combine(path, filename), true);
                //    info.Delete();
                //    return new FileDesc(filename, Path.Combine(path, filename), info.Length / 1024);
                //});

                return(Ok(fileInfo));
            });

            return(Ok(new { success = guid.ToString(), token = guid.ToString() }));
        }
Ejemplo n.º 19
0
 public static BuildingData ToViewData(this BuildingFullInfo node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node != null)
     {
         var model = new BuildingData()
         {
             Id       = node.Id,
             ParentId = node.ParentId,
             Parent   = (suffix & CategoryDictionary.Parent) == CategoryDictionary.Parent && node.ParentId.HasValue ? new BuildingData
             {
                 Id                 = (int)node.ParentId,
                 OrganizationId     = node.ParentOrganizationId,
                 BuildingCategoryId = node.BuildingCategoryId,
                 GbCode             = node.ParentGbCode,
                 Name               = node.ParentName,
                 AliasName          = node.ParentAliasName,
                 Type               = node.ParentType == null ? -1 : (int)node.ParentType,
             } : null,
             HasChildren        = node.HasChildren == null ? 0 : (int)node.HasChildren,
             OrganizationId     = node.OrganizationId,
             BuildingCategoryId = node.BuildingCategoryId,
             CoordinateMapId    = node.CoordinateMapId,
             Coordinate2dId     = node.Coordinate2dId,
             TreeId             = node.TreeId,
             Coordinate3dId     = node.Coordinate3dId,
             GbCode             = node.GbCode,
             Name             = node.Name,
             AliasName        = node.AliasName,
             Initial          = node.Initial,
             Type             = node.Type,
             ManagerCount     = node.ManagerCount,
             CustomerCount    = node.CustomerCount,
             TotalArea        = node.TotalArea,
             WorkingArea      = node.WorkingArea,
             LivingArea       = node.LivingArea,
             ReceptionArea    = node.ReceptionArea,
             Enable           = node.BuildingEnable,
             Description      = node.Description,
             UpFloor          = node.UpFloor,
             Year             = node.Year,
             Sort             = node.Sort,
             MaxCustomerCount = node.MaxCustomerCount,
             Purpose          = node.Purpose
         };
         if ((suffix & CategoryDictionary.ExtensionField) == CategoryDictionary.ExtensionField)
         {
             var ctx = new EmpContext();
             model.ExtensionFields = ctx.ExtensionFields.Where(x => x.Table == "Building" && x.JoinId == node.Id).ToViewList();
         }
         return(model);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 20
0
        static private CategoryDictionary _AddPlatform(byte platformValue)
        {
            CategoryDictionary categories;

            if (!_commandTree.TryGetValue(platformValue, out categories))
            {
                _commandTree[platformValue] = categories = new CategoryDictionary();
            }
            return(categories);
        }
Ejemplo n.º 21
0
        public bool Add(CategoryDictionary categoryInfo)
        {
            //参数验证
            if (categoryInfo == null)
            {
                ErrorMsg = ErrorCode.ParameterNull;
                return(false);
            }

            return(_categoryDictionaryProvider.Add(categoryInfo));
        }
Ejemplo n.º 22
0
        public static void RemoveWatch(string user, int target, CategoryDictionary type)
        {
            try
            {
                if (string.IsNullOrEmpty(user))
                {
                    return;
                }
                var notifier = GlobalHost.ConnectionManager.GetHubContext <MyHub>();

                //var onlines = MyHub.CurrClients.Keys;
                var isonline = MyHub.IsOnline(user);
                if (!isonline)
                {
                    if (CurrObservers.ContainsKey(user))
                    {
                        CurrObservers.Remove(user);
                    }
                    return;
                }
                else
                {
                    if (CurrObservers.ContainsKey(user))
                    {
                        CurrObservers[user] = CurrObservers[user].Where(x => !(x.TargetId == target && x.TargetType == type)).ToList();
                        if (CurrObservers[user].Count == 0)
                        {
                            CurrObservers.Remove(user);
                        }
                    }
                    //else
                    //{
                    //    CurrObservers.Add(user, new List<string>() { meter });
                    //}
                }

                if (timer != null)
                {
                    //如果需要监测的用户为启动,则启动监控程序
                    if (CurrObservers.Keys.Count == 0)
                    {
                        timer.Dispose();
                    }
                    //timer = new Timer(2000);
                    //timer.Elapsed += new ElapsedEventHandler(DispatchTask);
                    //timer.Enabled = true;
                    //timer.AutoReset = true;
                }
            }
            catch (Exception ex)
            {
                MyConsole.log(ex, "移除设备监测异常");
            }
        }
Ejemplo n.º 23
0
        public IHttpActionResult GetParameter(int id, [FromUri] CategoryDictionary suffix = CategoryDictionary.None)
        {
            Parameter parameter = paramBLL.Find(id);

            if (parameter == null)
            {
                return(NotFound());
            }

            return(Ok(parameter.ToViewData(suffix)));
        }
Ejemplo n.º 24
0
        public IHttpActionResult GetBrand(int id, [FromUri] CategoryDictionary suffix = CategoryDictionary.None)
        {
            Brand brand = brandBLL.Find(id);

            if (brand == null)
            {
                return(NotFound());
            }

            return(Ok(brand.ToViewData(suffix)));
        }
Ejemplo n.º 25
0
        static private CommandCollection _AddCategory(byte platformValue, byte categoryValue)
        {
            CategoryDictionary categories = _AddPlatform(platformValue);
            CommandCollection  commands;

            if (!categories.TryGetValue(categoryValue, out commands))
            {
                categories[categoryValue] = commands = new CommandCollection();
            }
            return(commands);
        }
Ejemplo n.º 26
0
        public static SettingData ToViewData(this Setting node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new SettingData()
            {
                AppID                         = node.AppID,
                Data                          = node.Data,
                Title                         = node.Title,
                Weather                       = node.Weather,
                ElectricityPrice              = node.ElectricityPrice,
                WaterPrice                    = node.WaterPrice,
                WaterPrePay                   = node.WaterPrePay,
                ElectricityPrePay             = node.ElectricityPrePay,
                ProjectType                   = node.ProjectType,
                IPAddress                     = node.IPAddress,
                AdministrativeCode            = node.AdministrativeCode,
                ConfigIds                     = node.ConfigIds,
                Regex                         = node.Regex,
                HeatPrice                     = node.HeatPrice,
                FirstSemesterBeginTime        = node.FirstSemesterBeginTime,
                FirstSemesterEndTime          = node.FirstSemesterEndTime,
                SecondSemesterBeginTime       = node.SecondSemesterBeginTime,
                SecondSemesterEndTime         = node.SecondSemesterEndTime,
                NotGiveSubsidieMonth          = node.NotGiveSubsidieMonth,
                AliPayAddress                 = node.AliPayAddress,
                SMSAppkey                     = node.SMSAppkey,
                SMSSenderName                 = node.SMSSenderName,
                SMSSecret                     = node.SMSSecret,
                SMSTemplateId                 = node.SMSTemplateId,
                BalancedetectionMaxdifference = node.BalancedetectionMaxdifference,
                WarningAmount                 = node.WarningAmount,
                JpushAppkey                   = node.JpushAppkey,
                BillStartTime                 = node.BillStartTime,
                JpushSecret                   = node.JpushSecret,
                SmtpEnableSsl                 = node.SmtpEnableSsl,
                SmtpPort                      = node.SmtpPort,
                SmtpPwd                       = node.SmtpPwd,
                SmtpPwdCheckEnable            = node.SmtpPwdCheckEnable,
                SmtpServer                    = node.SmtpServer,
                SmtpUser                      = node.SmtpUser,
                IsNeedPwdForUpdate            = node.IsNeedPwdForUpdate,
                UpdatePwd                     = node.UpdatePwd,
                CampusPowerLimit              = node.CampusPowerLimit,
                BuidlingPowerLimit            = node.BuidlingPowerLimit,
                StopChargingTime              = node.StopChargingTime
            };

            return(model);
        }
Ejemplo n.º 27
0
 public static SceneModeConfigData ToViewData(this SceneModeConfig node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node == null)
     {
         return(null);
     }
     return(new SceneModeConfigData()
     {
         Id = node.Id,
         SceneModeId = node.SceneModeId,
         ConfigId = node.ConfigId,
     });
 }
Ejemplo n.º 28
0
 public static ParameterData ToViewData(this Parameter node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node == null)
     {
         return(null);
     }
     return(new ParameterData()
     {
         Id = node.Id,
         BrandId = node.BrandId,
         DictionaryId = node.TypeId,
         Unit = node.Unit
     });
 }
Ejemplo n.º 29
0
        public CategoryDictionary Get(int id)
        {
            //参数验证
            if (id < 1)
            {
                ErrorMsg = ErrorCode.ParameterNull;
                return(null);
            }

            //数据获取
            CategoryDictionary categoryInfo = _categoryDictionaryProvider.Get(id);

            return(categoryInfo);
        }
Ejemplo n.º 30
0
 public static SceneModeData ToViewData(this SceneMode node, CategoryDictionary suffix = CategoryDictionary.None)
 {
     if (node == null)
     {
         return(null);
     }
     return(new SceneModeData()
     {
         Id = node.Id,
         ConfigTypeId = node.ConfigTypeId,
         Name = node.Name,
         Description = node.Description,
     });
 }