Exemple #1
0
        /// <summary>
        /// 标记信息为已读
        /// </summary>
        /// <param name="Ids">准备要标记为已读的信息主键</param>
        /// <returns></returns>
        public OperationResult MarkRead(params Guid[] Ids)
        {
            int count = 0;

            InformationRepository.UnitOfWork.BeginTransaction();
            foreach (var id in Ids)
            {
                var result = InformationRepository.TrackEntities.FirstOrDefault(m => m.Id == id);
                if (result == null)
                {
                    throw new Exception($"id:主键为{id}的用户提示信息不存在");
                }
                result.IsReaded = true;
                count          += InformationRepository.Update(result);
            }
            InformationRepository.UnitOfWork.Commit();
            if (count > 0)
            {
                return(new OperationResult(OperationResultType.Success, $"{count}条信息已被标记为已读!"));
            }
            else
            {
                return(new OperationResult());
            }
        }
        public static void MoneyTransfer(UserData userFrom, UserData userTo, decimal budget)
        {
            var infoRepo    = new InformationRepository(withPlan: false);
            var historyRepo = new HistoryCashRepository();

            var nameFirst = string.Format("{0} {1}({2})", userFrom.FirstName, userFrom.LastName, userFrom.NickName);
            var nameLast  = string.Format("{0} {1}({2})", userTo.FirstName, userTo.LastName, userTo.NickName);

            var information = new Information()
            {
                UserData   = userFrom.Code,
                DateAction = Constants.TotalMilliseconds,
                Info       = string.Format(Constants.Transfer, budget, nameFirst, nameLast)
            };

            infoRepo.InsertData(information);
            information.UserData = userTo.Code;
            infoRepo.InsertData(information);

            var historyCash = new HistoryCash();

            historyCash.Name       = string.Format(Constants.Transfer, budget, nameFirst, nameLast);
            historyCash.DateAction = Constants.TotalMilliseconds;

            historyCash.Cash     = budget;
            historyCash.UserCode = userTo.Code;
            historyRepo.InsertData(historyCash);

            historyCash.Cash     = -budget;
            historyCash.UserCode = userFrom.Code;
            historyRepo.InsertData(historyCash);
        }
Exemple #3
0
        /// <summary>
        /// 设置分控警报信息
        /// </summary>
        /// <param name="repack">主机注册包</param>
        /// <param name="index">警报类型序号</param>
        /// <param name="subnum">分控编号</param>
        /// <returns></returns>
        private int SetSubAlert(string repack, int index, int subnum)
        {
            int row = 0;
            // 获取目标主机信息
            var host = HostRepository.Entities.FirstOrDefault(m => m.RegPackage == repack);
            // 获取警报类型字典信息(超压 Index = 1)
            var ditem = DataItemDetailRepository.Entities.FirstOrDefault(m => m.QueryCoding == "InformationType" && m.Index == index);

            if (host != null && ditem != null)
            {
                // 获取管理该组织机构的用户信息
                var user_orgs = UserOrganizeMapRepository.Entities.Where(m => m.Organize_Id == host.Organize_Id).ToList();
                var sub       = SubControlRepository.Entities.FirstOrDefault(m => m.LigthPoleOne.Host_Id == host.Id && m.SubNum == subnum);
                if (user_orgs != null && sub != null)
                {
                    foreach (var user in user_orgs)
                    {
                        row += InformationRepository.Insert(new Information
                        {
                            CreatedTime       = DateTime.Now,
                            DataItemDetail_Id = ditem.Id,
                            IsReaded          = false,
                            ObjectId          = sub.Id,
                            Organize_Id       = host.Organize_Id,
                            TypeIndex         = ditem.Index,
                            TypeName          = ditem.FullName,
                            UserLogin_Id      = user.UserLogin_Id
                        });
                    }
                }
            }

            return(row);
        }
        public void Start_With_A_Simple_Note()
        {
            //Connect to elastic
            var connection = new ConnectionSettingProvider();
            var elastic    = new ElasticClient(connection.Get().DefaultIndex("es.info"));

            //wire up information repository and the attacher
            var attacher = new AttachmentProcessor();
            var infoRepo = new InformationRepository(
                elastic, attacher,
                new ItemMetadataProvider(new MetadataRepository(elastic)));

            //create a Note
            var note = new Note
            {
                ItemId   = new Guid("3d9da9e7-5362-4432-b2f8-1da21bc5e17b"),
                NoteBody = "Hello Elastic{ON} 2017 from information!"
            };
            //Let's timestamp it
            var timeStamp = new TimeStamper
            {
                Created   = DateTime.UtcNow,
                CreatedBy = "doug"
            };

            //hook note and timestamp together
            attacher.Attach(timeStamp, note);

            //save the items
            infoRepo.Save(note);
            infoRepo.Save(timeStamp);
        }
        private static void SaveInfoForFlight(Plan plan, Flight flight, string message)
        {
            var infoRepo = new InformationRepository(true);

            var codes = new List <int>();

            codes.Add(flight.OwnerCode);
            if (!codes.Contains(plan.OwnerCode))
            {
                codes.Add(plan.OwnerCode);
            }
            if (!codes.Contains(plan.ExecutorCode))
            {
                codes.Add(plan.ExecutorCode);
            }

            foreach (var code in codes)
            {
                var information = new Information()
                {
                    UserData   = code,
                    DateAction = Constants.TotalMilliseconds,
                    Info       = string.Format(message, plan.Name, flight.Comment),
                    PlanCode   = plan.Code
                };
                infoRepo.InsertData(information);
            }
        }
        public DataService()
        {
            switch (Device.RuntimePlatform)
            {
            case Device.Android:
                databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), databaseName);
                break;

            case Device.iOS:
                SQLitePCL.Batteries_V2.Init();
                databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "..", "Library", databaseName);
                break;

            default:
                break;
            }

            Database = new SQLiteConnection(databasePath);
            Database.CreateTable <Minute>();
            Database.CreateTable <MinuteImage>();
            Database.CreateTable <Topic>();
            Database.CreateTable <Information>();
            Database.CreateTable <Person>();

            MinuteRepository      = new MinuteRepository(Database);
            MinuteImageRepository = new MinuteImageRepository(Database);
            TopicRepository       = new TopicRepository(Database);
            InformationRepository = new InformationRepository(Database);
            PersonRepository      = new PersonRepository(Database);
        }
Exemple #7
0
        public static List <Information> GetHistoryInformation()
        {
            var user = UserSession.Current.User;

            if (user != null)
            {
                var infoRepo = new InformationRepository(1, (int)Constants.InformationAction.Select);
                return(infoRepo.List);
            }
            throw new NotImplementedException();
        }
        public void CreateParentChildGroups()
        {
            var connection      = new ConnectionSettingProvider();
            var metadataElastic = new ElasticClient(
                connection.Get()
                .DefaultIndex("es.info.metadata"));

            var attachmentProcessor = new AttachmentProcessor();

            var metadataRepo = new MetadataRepository(metadataElastic);
            var metadataInfo = new InformationRepository(metadataElastic, attachmentProcessor, new ItemMetadataProvider(metadataRepo));


            var childGroup1 = new ChildGroup
            {
                SortOrder = 1,
                Title     = "child 1"
            };

            var childGroup2 = new ChildGroup
            {
                SortOrder = 2,
                Title     = "child 2"
            };

            var grandChild = new ChildGroup
            {
                SortOrder = 1,
                Title     = "grandchild"
            };

            var rootGroup = new RootGroup
            {
                Title = "root"
            };

            attachmentProcessor.Attach(childGroup1, rootGroup);
            attachmentProcessor.Attach(childGroup2, rootGroup);
            attachmentProcessor.Attach(grandChild, childGroup1);

            attachmentProcessor.Attach(grandChild, rootGroup);
            attachmentProcessor.Attach(childGroup1, rootGroup);
            attachmentProcessor.Attach(childGroup2, rootGroup);

            metadataInfo.Save(rootGroup);
            metadataInfo.Save(childGroup1);
            metadataInfo.Save(childGroup2);
            metadataInfo.Save(grandChild);
        }
Exemple #9
0
        /// <summary>
        /// 删除指定的用户提示信息
        /// </summary>
        /// <param name="Ids">要删除的信息主键集合</param>
        /// <returns></returns>
        public OperationResult DeleteInformation(params Guid[] Ids)
        {
            int count = 0;

            foreach (var id in Ids)
            {
                count += InformationRepository.DeleteDirect(id);
            }
            if (count > 0)
            {
                return(new OperationResult(OperationResultType.Success, $"{count}条信息已被删除!"));
            }
            else
            {
                return(new OperationResult());
            }
        }
Exemple #10
0
        public DataService()
        {
            SetDbPath();

            Database = new SQLiteConnection(databasePath);
            Database.CreateTable <Minute>();
            Database.CreateTable <MinuteImage>();
            Database.CreateTable <Topic>();
            Database.CreateTable <Information>();
            Database.CreateTable <Person>();

            MinuteRepository      = new MinuteRepository(Database);
            MinuteImageRepository = new MinuteImageRepository(Database);
            TopicRepository       = new TopicRepository(Database);
            InformationRepository = new InformationRepository(Database);
            PersonRepository      = new PersonRepository(Database);
        }
        public void Create_Index_Color_Metadata()
        {
            var connection = new ConnectionSettingProvider();
            var elastic    = new ElasticClient(
                connection.Get().DefaultIndex("es.info.metadata"));

            var attacher = new AttachmentProcessor();
            var infoRepo = new InformationRepository(
                elastic, attacher,
                new ItemMetadataProvider(new MetadataRepository(elastic)));

            var label = new Label {
                Title  = "SearchConfig.IndexColor",
                ItemId = new Guid("c985d59f-6298-437b-a886-3255da8291be")
            };
            var labelDescription = new Note {
                NoteBody = "Index colors allow a seperate indices.  These are denoted 'Red' or 'Blue'."
            };

            attacher.Attach(labelDescription, label);

            var value1 = new Value
            {
                Title  = "Red",
                ItemId = new Guid("c4caf9c3-3b75-46c1-b8c2-96f48fbe2f04")
            };

            //values and labels are cross attached
            attacher.Attach(value1, label);

            var value2 = new Value {
                Title = "Blue"
            };

            attacher.Attach(value2, label);

            //Commit changes
            infoRepo.Save(label);
            infoRepo.Save(value1);
            infoRepo.Save(value2);
            infoRepo.Save(labelDescription);
        }
        public void Create_Host_Index_Cluster_Metadata()
        {
            var connection = new ConnectionSettingProvider();
            var elastic    = new ElasticClient(
                connection.Get().DefaultIndex("es.info.metadata"));

            var attacher = new AttachmentProcessor();
            var infoRepo = new InformationRepository(
                elastic, attacher,
                new ItemMetadataProvider(new MetadataRepository(elastic)));

            var label = new Label {
                Title  = "SearchConfig.HostElasticCluster",
                ItemId = new Guid("c0271af8-32b3-4098-9f60-76e2ac48841f")
            };

            var labelDescription = new Note {
                NoteBody = "Elastic hosts name formats to allow connections to the elastic cluster."
            };

            attacher.Attach(labelDescription, label);

            var value1 = new Value {
                Title = "elasticindexV2_{0}_es.com"
            };

            attacher.Attach(value1, label);

            var value2 = new Value
            {
                Title  = "elasticindexV5_{0}_es.com",
                ItemId = new Guid("8820432d-1b28-4f1c-bb70-9a1d0d4972fd")
            };

            attacher.Attach(value2, label);

            //Commit changes
            infoRepo.Save(label);
            infoRepo.Save(value1);
            infoRepo.Save(value2);
            infoRepo.Save(labelDescription);
        }
        public void Create_Index_Language_Metadata()
        {
            var connection = new ConnectionSettingProvider();
            var elastic    = new ElasticClient(
                connection.Get().DefaultIndex("es.info.metadata"));

            var attacher     = new AttachmentProcessor();
            var metadataRepo = new MetadataRepository(elastic);
            var infoRepo     = new InformationRepository(elastic, attacher, new ItemMetadataProvider(metadataRepo));

            var label = new Label {
                Title  = "SearchConfig.Language",
                ItemId = new Guid("e12dd9e4-db07-4c3f-8e02-b1c0c4dd8022")
            };

            var labelDescription = new Note {
                NoteBody = "Metadata language."
            };

            attacher.Attach(labelDescription, label);

            var value1 = new Value
            {
                Title  = "en",
                ItemId = new Guid("de7932b9-a0b6-4f2f-ac45-0315ea841d65")
            };

            attacher.Attach(value1, label);

            var value2 = new Value {
                Title = "es"
            };

            attacher.Attach(value2, label);

            //Commit changes
            infoRepo.Save(label);
            infoRepo.Save(value1);
            infoRepo.Save(value2);
            infoRepo.Save(labelDescription);
        }
        public static void AddUserToFamily(Family family, string userName)
        {
            var infoRepo = new InformationRepository(withPlan: false);

            var users = family.Users;

            if (users == null)
            {
                return;
            }
            foreach (var user in users)
            {
                var information = new Information()
                {
                    UserData   = user.Code,
                    DateAction = Constants.TotalMilliseconds,
                    Info       = string.Format(Constants.AddNewUser, userName)
                };
                infoRepo.InsertData(information);
            }
        }
Exemple #15
0
        /// <summary>
        /// 设置主机警报信息
        /// </summary>
        /// <param name="repack">主机注册包</param>
        /// <param name="index">警报类型序号</param>
        /// <returns></returns>
        private int SetHostAlert(string repack, int index)
        {
            int row = 0;
            // 获取目标主机信息
            var host = HostRepository.Entities.FirstOrDefault(m => m.RegPackage == repack);

            if (index == 0)
            {   //主机断线时更新主机在线状态
                HostRealTimeData hostReal = HostRealTimeDataRepository.TrackEntities.FirstOrDefault(m => m.Host_Id == host.Id);
                hostReal.IsOnline = false;
                HostRealTimeDataRepository.Update(hostReal);
            }
            // 获取警报类型字典信息(超压 Index = 1)
            var ditem = DataItemDetailRepository.Entities.FirstOrDefault(m => m.QueryCoding == "InformationType" && m.Index == index);

            if (host != null && ditem != null)
            {
                // 获取管理该组织机构的用户信息
                var user_orgs = UserOrganizeMapRepository.Entities.Where(m => m.Organize_Id == host.Organize_Id).ToList();
                if (user_orgs != null)
                {
                    foreach (var user in user_orgs)
                    {
                        row += InformationRepository.Insert(new Information
                        {
                            CreatedTime       = DateTime.Now,
                            DataItemDetail_Id = ditem.Id,
                            IsReaded          = false,
                            ObjectId          = host.Id,
                            Organize_Id       = host.Organize_Id,
                            TypeIndex         = ditem.Index,
                            TypeName          = ditem.FullName,
                            UserLogin_Id      = user.UserLogin_Id
                        });
                    }
                }
            }
            return(row);
        }
        public static void BudgetReplenishment(UserData user, decimal budget)
        {
            var infoRepo    = new InformationRepository(withPlan: false);
            var historyRepo = new HistoryCashRepository();

            var information = new Information()
            {
                UserData   = user.Code,
                DateAction = Constants.TotalMilliseconds,
                Info       = string.Format(Constants.BudgetReplenishment, budget)
            };

            infoRepo.InsertData(information);

            var historyCash = new HistoryCash();

            historyCash.Cash       = budget;
            historyCash.Name       = string.Format(Constants.BudgetReplenishment, budget);
            historyCash.DateAction = Constants.TotalMilliseconds;
            historyCash.UserCode   = user.Code;
            historyRepo.InsertData(historyCash);
        }
        public void Get_Search_Index_Object_Graph()
        {
            var connection = new ConnectionSettingProvider();
            var elastic    = new ElasticClient(
                connection.Get()
                .DefaultIndex("gbs.info*"));
            var metadataRepo = new MetadataRepository(elastic);

            var infoRepo = new InformationRepository(elastic, new AttachmentProcessor(), new ItemMetadataProvider(metadataRepo));

            var result = infoRepo.GetItemWithAttachments(
                new Guid("62169a15-d2a1-4741-a8c4-c9d4f7f08f7c"),
                new [] {
                typeof(SearchIndex),
                typeof(Site)
            }, true);

            var temp = "testing";

            result = infoRepo.GetItemWithAttachments(
                new Guid("62169a15-d2a1-4741-a8c4-c9d4f7f08f7c"),
                new[] { typeof(SearchIndex), typeof(Site) }, true);
        }
        private static void SaveInfoForPlan(Plan plan, int family, string message)
        {
            var infoRepo = new InformationRepository(true);

            if (family > Constants.DEFAULT_CODE)
            {
                var userRepo = new UserRepository((int)Constants.UserAction.Family);
                var users    = userRepo.GetList(family);
                if (users == null)
                {
                    return;
                }
                foreach (var user in users)
                {
                    var information = new Information()
                    {
                        UserData   = user.Code,
                        DateAction = Constants.TotalMilliseconds,
                        Info       = string.Format(message, plan.Name),
                        PlanCode   = plan.Code
                    };
                    infoRepo.InsertData(information);
                }
            }
            else
            {
                var information = new Information()
                {
                    UserData   = plan.OwnerCode,
                    DateAction = Constants.TotalMilliseconds,
                    Info       = string.Format(message, plan.Name),
                    PlanCode   = plan.Code
                };
                infoRepo.InsertData(information);
            }
        }
 public InformationService(InformationRepository informationRepository)
 {
     this.informationRepository = informationRepository;
 }
Exemple #20
0
 /// <summary>Initializes a new instance of the <see cref="ServiceAdapter" /> class.</summary>
 /// <param name="guiCallback">Interface through which the adapter will talk to the GUI.</param>
 public ServiceAdapter(IGuiCallback guiCallback)
 {
     this._guiCallback  = guiCallback;
     this._subscription = new SubscriptionRepository(this);
     this._information  = new InformationRepository(this);
 }
        public void Create_SearchConfig_Index_MetadataGroup()
        {
            //connect to elastic
            var connection = new ConnectionSettingProvider();
            var elastic    = new ElasticClient(
                connection.Get().DefaultIndex("es.info.metadata"));

            //wire up repositories and attacher
            var attacher     = new AttachmentProcessor();
            var metadataRepo = new MetadataRepository(elastic);
            var infoRepo     = new InformationRepository(elastic, attacher, new ItemMetadataProvider(metadataRepo));

            //simple metadata lookup
            var metadataLookup = metadataRepo.GetLabelValues();
            var metadataValues = metadataRepo.GetValues();
            var metadataLabels = metadataRepo.GetLabels();

            //first start with the group
            var group = new Group
            {
                Title         = "Site Search Index Connection Settings",
                GroupFunction = "SearchIndex",
                GroupOwner    = "SearchConfig",
                ItemId        = new Guid("9c60f30c-edc4-4a30-b583-9bc9b9b82eda")
            };

            //we are going to use three labels (host, color, language)
            var hostLabel = metadataLabels.First(x => x
                                                 .ItemId == new Guid("c0271af8-32b3-4098-9f60-76e2ac48841f"));
            var colorLabel = metadataLabels.First(x => x
                                                  .ItemId == new Guid("c985d59f-6298-437b-a886-3255da8291be"));
            var langLabel = metadataLabels.First(x => x
                                                 .ItemId == new Guid("e12dd9e4-db07-4c3f-8e02-b1c0c4dd8022"));

            //create the host group member and create object graph
            var hostMember = new GroupMember
            {
                ExclusionFlag = false,
                Title         = "Elastic Cluster Hosts"
            };

            attacher.Attach(hostMember, group);
            attacher.Attach(hostLabel, group);
            attacher.Attach(hostLabel, hostMember);

            //Attach values to group for each Label
            foreach (var valueId in metadataLookup.Where(x => x
                                                         .LabelId == hostLabel.ItemId).Select(x => x.ValueId))
            {
                var value = metadataValues.FirstOrDefault(x => x.ItemId == valueId);
                attacher.Attach(value, group);
                infoRepo.Save(value);
            }

            //color group member
            var colorMember = new GroupMember
            {
                ExclusionFlag = false,
                Title         = "Search Index Color"
            };

            attacher.Attach(colorMember, group);
            attacher.Attach(colorLabel, group);
            attacher.Attach(colorLabel, colorMember);
            foreach (var valueId in metadataLookup.Where(x => x
                                                         .LabelId == colorLabel.ItemId).Select(x => x.ValueId))
            {
                var value = metadataValues.FirstOrDefault(x => x.ItemId == valueId);
                attacher.Attach(value, group);
                infoRepo.Save(value);
            }

            //language group member
            var langMember = new GroupMember
            {
                ExclusionFlag = false,
                Title         = "Search Index Language"
            };

            attacher.Attach(langMember, group);
            attacher.Attach(langLabel, group);
            attacher.Attach(langLabel, langMember);
            foreach (var valueId in metadataLookup.Where(x => x
                                                         .LabelId == langLabel.ItemId).Select(x => x.ValueId))
            {
                var value = metadataValues.FirstOrDefault(x => x.ItemId == valueId);
                attacher.Attach(value, group);
                infoRepo.Save(value);
            }

            //save everything that was touched
            infoRepo.Save(group);
            infoRepo.Save(hostMember);
            infoRepo.Save(hostLabel);
            infoRepo.Save(colorMember);
            infoRepo.Save(colorLabel);
            infoRepo.Save(langMember);
            infoRepo.Save(langLabel);
        }
        public void Add_Site_With_SearchIndex()
        {
            var connection = new ConnectionSettingProvider();

            //Working across indices
            var searchConfigElastic = new ElasticClient(
                connection.Get()
                .DefaultIndex("es.info.searchconfig"));

            var metadataElastic = new ElasticClient(
                connection.Get()
                .DefaultIndex("es.info.metadata"));

            var attachmentProcessor = new AttachmentProcessor();
            var tagger               = new InformationClassifier();
            var metadataRepo         = new MetadataRepository(metadataElastic);
            var itemMetadataProvider = new ItemMetadataProvider(metadataRepo);

            var searchConfigInfo = new InformationRepository(searchConfigElastic, attachmentProcessor, itemMetadataProvider);
            var metadataInfo     = new InformationRepository(metadataElastic, attachmentProcessor, itemMetadataProvider);

            //Get metadata values defined for the group
            var groupValues = metadataInfo.GetItemWithAttachments(
                new Guid("9c60f30c-edc4-4a30-b583-9bc9b9b82eda"),
                new[] { typeof(Value) });


            //Define a site
            var site = new Site {
                ItemId = new Guid("c667e190-6177-4248-9bbf-dd27633c6ed5"),
                Title  = "informationcentral.com",
                IsNew  = true
            };

            searchConfigInfo.Save(site);

            //Get the desired metadata values for the index
            // Cluster A , English, Red
            var indexHost = groupValues.First(x =>
                                              x.ItemId == new Guid("8820432d-1b28-4f1c-bb70-9a1d0d4972fd"));
            var indexLanguage = groupValues.First(x =>
                                                  x.ItemId == new Guid("de7932b9-a0b6-4f2f-ac45-0315ea841d65"));
            var indexColor = groupValues.First(x =>
                                               x.ItemId == new Guid("c4caf9c3-3b75-46c1-b8c2-96f48fbe2f04"));

            //Define a search index for the site
            var index = new SearchIndex {
                ItemId     = new Guid("62169a15-d2a1-4741-a8c4-c9d4f7f08f7c"),
                Title      = "IA Red Cluster A",
                IndexAlias = string.Format("xxx.site.{0}.{1}.{2}",
                                           indexLanguage.Title.ToLower(),
                                           site.ItemId,
                                           indexColor.Title.ToLower())
            };

            tagger.Tag(index, (Value)indexHost);
            tagger.Tag(index, (Value)indexLanguage);
            tagger.Tag(index, (Value)indexColor);

            //Attach index to site and metadata values
            attachmentProcessor.Attach(site, index);

            //Save the site and search index
            searchConfigInfo.Save(site);
            searchConfigInfo.Save(index);
        }
Exemple #23
0
        public static void DeleteInformation()
        {
            var repo = new InformationRepository(0, (int)Constants.InformationAction.Delete, empty: true);

            repo.DeleteInformationData();
        }