示例#1
0
        public override string Execute(InfoBase json)
        {
            bool   connect = false;
            string xml     = string.Empty;

            try
            {
                //组建参数字典
                Dictionary <string, string> Para = new Dictionary <string, string>();
                //Para.Add("key", ShareData.QAkye);
                //Para.Add("info", json.Contents);
                //Para.Add("userid", ShareData.QAuserid);

                string     path    = RequestPath.CreatePathApi("/turing/turing/turing");
                RpArticles newList = HTMLHelper.Get <RpArticles>(path, Para, ref connect, ShareData.baiduapikey);
                if (newList.code == "200" && newList != null)
                {
                    newList.xmlmsg = json;
                    xml            = new replyImageText().ReplyExecute(newList);
                }
            }
            catch (Exception ex)
            {
                TracingHelper.Error(ex, typeof(DeepQA), ex.Message);
            }
            return(xml);
        }
示例#2
0
        public override string Execute(InfoBase json)
        {
            bool   connect = false;
            string xml     = string.Empty;

            try
            {
                //组建参数字典
                Dictionary <string, string> Para = new Dictionary <string, string>();
                Para.Add("num", "4");
                Para.Add("rand", "1");

                string     path    = RequestPath.CreatePathApi("/txapi/weixin/wxhot");
                RpArticles newList = HTMLHelper.Get <RpArticles>(path, Para, ref connect, ShareData.baiduapikey);
                if (newList.code == "200" && newList != null)
                {
                    newList.xmlmsg = json;
                    xml            = new replyImageText().ReplyExecute(newList);
                }
            }
            catch (Exception ex)
            {
                TracingHelper.Error(ex, typeof(TouTiao), ex.Message);
            }
            return(xml);
        }
        private void ConfigureSharedProperties(InfoBase infoBase, ConfigObject config)
        {
            // 3.1.8.0 = 15794563-ccec-41f6-a83c-ec5f7b9a5bc1 - идентификатор коллекции общих реквизитов
            Guid collectionUuid = config.GetUuid(new int[] { 3, 1, 8, 0 });

            if (collectionUuid == new Guid("15794563-ccec-41f6-a83c-ec5f7b9a5bc1"))
            {
                // количество объектов в коллекции
                int count = config.GetInt32(new int[] { 3, 1, 8, 1 });
                if (count == 0)
                {
                    return;
                }

                // 3.1.8 - коллекция общих реквизитов
                ConfigObject collection = config.GetObject(new int[] { 3, 1, 8 });

                int            offset = 2;
                SharedProperty property;
                for (int i = 0; i < count; i++)
                {
                    property = new SharedProperty()
                    {
                        FileName = collection.GetUuid(new int[] { i + offset })
                    };
                    ConfigureSharedProperty(property, infoBase);
                    infoBase.SharedProperties.Add(property.FileName, property);
                }
            }
        }
示例#4
0
 bool IMetadataCache.TryGet(out InfoBase infoBase)
 {
     using (_lock.ReadLock())
     {
         return(_cache.TryGetValue(CACHE_KEY, out infoBase));
     }
 }
示例#5
0
 public KickArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, UserInfo user, string message)
     : base(sender, receiver, "KICK")
 {
     this.channel = channel;
     this.user = user;
     this.message = message;
 }
示例#6
0
        public void AttachDatabase(string serverName, InfoBase infoBase)
        {
            // TODO: make UseServer and UseDatabase methods independent of file existence !
            if (infoBase == null)
            {
                throw new ArgumentNullException(nameof(infoBase));
            }
            if (string.IsNullOrWhiteSpace(serverName))
            {
                throw new ArgumentNullException(nameof(serverName));
            }

            DatabaseServer server = Settings.Servers.Where(s => s.Name == serverName).FirstOrDefault();

            if (server == null)
            {
                server = new DatabaseServer()
                {
                    Name = serverName
                };
                Settings.Servers.Add(server);
            }

            InfoBase database = server.Databases.Where(db => db.Name == infoBase.Name).FirstOrDefault();

            if (database != null)
            {
                throw new InvalidOperationException(nameof(infoBase));
            }

            server.Databases.Add(database);
        }
示例#7
0
        void m_CubeBrowser_SelectedItemChanged(object sender, ItemEventArgs e)
        {
            var      info_Node = m_CubeBrowser.SelectedNode as InfoBaseTreeNode;
            InfoBase info      = info_Node != null ? info_Node.Info : null;

            Raise_SelectedItemChanged(info);
        }
示例#8
0
        public InfoBase GetMetadata(string ProgID, SQLConnectionDialogNotification settings, string tempDirectory)
        {
            Type    comType          = Type.GetTypeFromProgID(ProgID, true); // V83.COMConnector
            dynamic connector        = Activator.CreateInstance(comType);
            string  connectionString = GetConnectionString(settings);
            dynamic session          = connector.Connect(connectionString);

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ConfigurationWriter.epf");
            string temp = Path.Combine(tempDirectory, "ConfigurationWriter.epf");

            File.Copy(path, temp, true);
            dynamic processor = session.ExternalDataProcessors.Create(temp);
            string  output    = Path.Combine(tempDirectory, "configuration.xml");

            processor.Write(output);
            File.Delete(temp);

            Marshal.ReleaseComObject(processor); processor = null;
            Marshal.ReleaseComObject(session); session     = null;
            Marshal.ReleaseComObject(connector); connector = null;

            InfoBase infoBase = new InfoBase();

            this.Load(output, infoBase);
            File.Delete(output);
            return(infoBase);
        }
        private void ConfigureCompoundTypes(InfoBase infoBase, ConfigObject config)
        {
            // 3.1.23.0 = c045099e-13b9-4fb6-9d50-fca00202971e - идентификатор коллекции определяемых типов
            Guid collectionUuid = config.GetUuid(new int[] { 3, 1, 23, 0 });

            if (collectionUuid == new Guid("c045099e-13b9-4fb6-9d50-fca00202971e"))
            {
                // 3.1.23.1 - количество объектов в коллекции
                int count = config.GetInt32(new int[] { 3, 1, 23, 1 });
                if (count == 0)
                {
                    return;
                }

                // 3.1.23 - коллекция определяемых типов
                ConfigObject collection = config.GetObject(new int[] { 3, 1, 23 });

                // 3.1.23.N - идентификаторы файлов определяемых типов
                int          offset = 2;
                CompoundType compound;
                for (int i = 0; i < count; i++)
                {
                    compound = new CompoundType()
                    {
                        FileName = collection.GetUuid(new int[] { i + offset })
                    };
                    ConfigureCompoundType(compound, infoBase);
                    infoBase.CompoundTypes.Add(compound.Uuid, compound);
                }
            }
        }
示例#10
0
        private void ProcessEntry(InfoBase infoBase, Guid uuid, string token, int code)
        {
            if (token == MetadataTokens.Fld || token == MetadataTokens.LineNo)
            {
                _ = infoBase.Properties.TryAdd(uuid, Configurator.CreateProperty(uuid, token, code));
                return;
            }

            Type type = Configurator.GetTypeByToken(token);

            if (type == null)
            {
                return;               // unsupported type of metadata object
            }
            ApplicationObject metaObject = Configurator.CreateObject(uuid, token, code);

            if (metaObject == null)
            {
                return;                     // unsupported type of metadata object
            }
            if (token == MetadataTokens.VT)
            {
                _ = infoBase.TableParts.TryAdd(uuid, metaObject);
                return;
            }

            if (!infoBase.AllTypes.TryGetValue(type, out Dictionary <Guid, ApplicationObject> collection))
            {
                return; // unsupported collection of metadata objects
            }
            _ = collection.TryAdd(uuid, metaObject);
        }
示例#11
0
        public Entity GetEntityInfo(InfoBase infoBase, string namespaceName, string entityName)
        {
            Entity info = null;

            IPersistentContext context = MetadataPersistentContext.Current;
            QueryService       service = new QueryService(context.ConnectionString);
            StringBuilder      sql     = new StringBuilder();

            sql.AppendLine("WITH namespaces([key], [owner], [name]) AS");
            sql.AppendLine("(");
            sql.Append("SELECT [key], [owner], [name] FROM [metadata].[namespaces] WHERE [owner] = '");
            sql.Append(infoBase.Identity.ToString());
            sql.AppendLine("'");
            sql.AppendLine("UNION ALL");
            sql.AppendLine("SELECT n.[key], n.[owner], n.[name] FROM [metadata].[namespaces] AS n");
            sql.AppendLine("INNER JOIN namespaces AS anchor ON anchor.[key] = n.[owner]");
            sql.AppendLine(")");
            sql.AppendLine("SELECT e.[key], e.[name] FROM [metadata].[entities] AS e");
            sql.AppendLine("INNER JOIN namespaces AS n");
            sql.Append("ON e.[namespace] = n.[key] AND n.[name] = N'");
            sql.Append(namespaceName);
            sql.Append("' AND e.[name] = N'");
            sql.Append(entityName);
            sql.Append("' AND e.[owner] = '00000000-0000-0000-0000-000000000000';");
            foreach (dynamic item in service.Execute(sql.ToString()))
            {
                info = context.Factory.New <Entity>((Guid)item.key);
            }
            return(info);
        }
示例#12
0
        private void AddMetadata()
        {
            SQLConnectionDialogNotification appInfo = GetConnectionInfo();

            if (appInfo == null)
            {
                return;
            }
            SQLConnectionDialogNotification sqlInfo = GetConnectionInfo();

            if (sqlInfo == null)
            {
                return;
            }
            string temp = GetCatalogPath();

            if (string.IsNullOrEmpty(temp))
            {
                return;
            }

            XMLMetadataAdapter adapter  = new XMLMetadataAdapter();
            string             progID   = "V83.COMConnector";
            InfoBase           infoBase = adapter.GetMetadata(progID, appInfo, temp);

            ImportSQLMetadata(infoBase, sqlInfo);

            MetadataTreeViewModel.InfoBases.Add(infoBase);

            MetadataService service = new MetadataService();

            service.Save(infoBase);
            infoBase.OnPropertyChanged("State");
        }
示例#13
0
 public KickArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, UserInfo user, string message)
     : base(sender, receiver, "KICK")
 {
     Channel = channel;
     User    = user;
     Message = message;
 }
示例#14
0
        private static void GenerateSettingsFiles(string ms, string pg, string d, string u, string p, FileInfo o)
        {
            IMetadataService metadataService = new MetadataService();

            if (!string.IsNullOrWhiteSpace(ms))
            {
                metadataService.UseDatabaseProvider(DatabaseProviders.SQLServer);
                metadataService.ConfigureConnectionString(ms, d, u, p);
            }
            else
            {
                metadataService.UseDatabaseProvider(DatabaseProviders.PostgreSQL);
                metadataService.ConfigureConnectionString(pg, d, u, p);
            }

            InfoBase infoBase = metadataService.LoadInfoBase();

            MessageConsumerSettings consumerSettings = CreateConsumerSettings(infoBase, metadataService);
            MessageProducerSettings producerSettings = CreateProducerSettings(infoBase, metadataService);

            string consumerPath = Path.Combine(o.FullName, CONSUMER_SETTINGS_FILE_NAME);
            string producerPath = Path.Combine(o.FullName, PRODUCER_SETTINGS_FILE_NAME);

            SaveConsumerSettings(consumerPath, consumerSettings);
            SaveProducerSettings(producerPath, producerSettings);
        }
 public void SetCurrentInfoBase(object model)
 {
     if (model is InfoBase)
     {
         _CurrentInfoBase = (InfoBase)model;
     }
     else if (model is Namespace)
     {
         _CurrentInfoBase = GetInfoBase((Namespace)model);
     }
     else if (model is Entity)
     {
         _CurrentInfoBase = GetInfoBase(((Entity)model).Namespace);
     }
     else if (model is Property)
     {
         _CurrentInfoBase = GetInfoBase(((Property)model).Entity.Namespace);
     }
     else if (model is Field)
     {
         _CurrentInfoBase = GetInfoBase(((Field)model).Table.Entity.Namespace);
     }
     else
     {
         _CurrentInfoBase = null;
     }
 }
示例#16
0
        private bool OpenSQLConnectionPopup(InfoBase infoBase)
        {
            bool cancel = false;
            SQLConnectionDialogNotification notification = new SQLConnectionDialogNotification()
            {
                Title    = CONST_ModuleDialogsTitle,
                Server   = infoBase.Server,
                Database = infoBase.Database,
                UserName = "",
                Password = ""
            };

            this.SQLConnectionPopupRequest.Raise(notification, response =>
            {
                if (!response.Confirmed)
                {
                    cancel = true;
                }
                else
                {
                    this.ImportSQLMetadata(infoBase, response);
                }
            });
            return(cancel);
        }
        private void AddMetadataObjects(List <MetadataNodeViewModel> root, IMetadataService service)
        {
            InfoBase     metadata     = service.GetSystemInfoBase();
            MetadataNode metadataNode = new MetadataNode(metadata);

            metadataNode.Children = new List <MetadataNode>();
            MetadataNodeViewModel metadataVM = new MetadataNodeViewModel(null, metadataNode);

            metadataVM.Children = new ObservableCollection <MetadataNodeViewModel>();

            foreach (Namespace ns in metadata.Namespaces)
            {
                MetadataNode child = new MetadataNode(ns);
                child.Children = new List <MetadataNode>();
                metadataNode.Children.Add(child);
                MetadataNodeViewModel childVM = new MetadataNodeViewModel(metadataVM, child);
                childVM.Children = new ObservableCollection <MetadataNodeViewModel>();
                metadataVM.Children.Add(childVM);

                foreach (Entity entity in ns.Entities)
                {
                    MetadataNode grandchild = new MetadataNode(entity);
                    child.Children.Add(grandchild);
                    MetadataNodeViewModel grandchildVM = new MetadataNodeViewModel(childVM, grandchild);
                    childVM.Children.Add(grandchildVM);
                }
            }
            root.Add(metadataVM);
        }
        public void KillEntity(object model)
        {
            Entity entity = model as Entity;

            if (entity == null)
            {
                throw new ArgumentNullException("model");
            }

            bool cancel = true;

            Z.Confirm(new Confirmation
            {
                Title   = "Z-Metadata",
                Content = $"Сущность \"{entity.Name}\" и все её\nподчинённые объекты будут удалены.\n\nПродолжить ?"
            },
                      c => { cancel = !c.Confirmed; });

            if (cancel)
            {
                return;
            }

            try
            {
                TransactionOptions options = new TransactionOptions()
                {
                    IsolationLevel = IsolationLevel.ReadCommitted
                };
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew, options))
                {
                    dataService.Kill(entity);
                    scope.Complete();
                }
                if (entity.Owner != null)
                {
                    entity.Owner.NestedEntities.Remove(entity);
                    entity.Owner.OnPropertyChanged("NestedEntities");
                }
                else
                {
                    InfoBase ib = this.InfoBases.Where(i => i == entity.InfoBase).FirstOrDefault();
                    if (ib != null)
                    {
                        Namespace owner = FindObservableNamespace(ib, entity.Namespace);
                        if (owner != null)
                        {
                            owner.ObservableEntities.Remove(entity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Z.Notify(new Notification {
                    Title = "Z-Metadata", Content = Z.GetErrorText(ex)
                });
            }
        }
示例#19
0
 public void Load(string connectionString, InfoBase infoBase)
 {
     this.ConnectionString = connectionString;
     foreach (Namespace currentNamespace in infoBase.Namespaces)
     {
         GetSQLMetadata(currentNamespace);
     }
 }
 private void MainMenuKillClicked(InfoBase infoBase)
 {
     if (infoBase == null)
     {
         throw new ArgumentNullException("infoBase");
     }
     dataService.Kill(infoBase);
 }
示例#21
0
 public AreaItemWrapper(InfoBase info)
 {
     Caption = info.Caption;
     foreach (PropertyInfo prop in info.CustomProperties)
     {
         this.CustomProperties.Add(prop);
     }
 }
示例#22
0
 public void Load(string connectionString, InfoBase infoBase)
 {
     this.ConnectionString = connectionString;
     foreach (BaseObject bo in infoBase.BaseObjects)
     {
         GetSQLMetadata(bo);
     }
 }
示例#23
0
        public InfoBase GetSystemInfoBase()
        {
            QueryService service  = new QueryService(MetadataPersistentContext.Current.ConnectionString);
            string       sql      = "SELECT [key] FROM [metadata].[infobases] WHERE [key] = CAST(0x00000000000000000000000000000000 AS uniqueidentifier);";
            Guid         key      = (Guid)service.ExecuteScalar(sql);
            InfoBase     infoBase = new InfoBase(key, PersistentState.Virtual);

            return(infoBase);
        }
        protected void Raise_SelectedItemChanged(InfoBase info)
        {
            EventHandler <ItemEventArgs> handler = SelectedItemChanged;

            if (handler != null)
            {
                handler(this, new ItemEventArgs(info));
            }
        }
示例#25
0
        private static void SaveApplicationObjectToFile(string filePath, IMetadataService metadataService, string metadataName)
        {
            string[] names = metadataName.Split('.');
            if (names.Length != 2)
            {
                return;
            }
            string typeName   = names[0];
            string objectName = names[1];

            ApplicationObject metaObject = null;
            Dictionary <Guid, ApplicationObject> collection = null;
            InfoBase infoBase = metadataService.LoadInfoBase();

            if (typeName == "Справочник")
            {
                collection = infoBase.Catalogs;
            }
            else if (typeName == "Документ")
            {
                collection = infoBase.Documents;
            }
            else if (typeName == "ПланОбмена")
            {
                collection = infoBase.Publications;
            }
            else if (typeName == "РегистрСведений")
            {
                collection = infoBase.InformationRegisters;
            }
            else if (typeName == "РегистрНакопления")
            {
                collection = infoBase.AccumulationRegisters;
            }
            if (collection == null)
            {
                return;
            }

            metaObject = collection.Values.Where(o => o.Name == objectName).FirstOrDefault();
            if (metaObject == null)
            {
                return;
            }

            byte[] fileData = metadataService.ReadBytes(metaObject.FileName.ToString());
            if (fileData == null)
            {
                return;
            }

            using (StreamReader reader = metadataService.CreateReader(fileData))
                using (StreamWriter writer = new StreamWriter(filePath, false, Encoding.UTF8))
                {
                    writer.Write(reader.ReadToEnd());
                }
        }
 private void MainMenuSaveClicked(InfoBase infoBase)
 {
     if (infoBase == null)
     {
         throw new ArgumentNullException("infoBase");
     }
     dataService.Save(infoBase);
     //MetadataTreeViewModel.CurrentInfoBase.OnPropertyChanged("State");
     infoBase.OnPropertyChanged("State");
 }
示例#27
0
        /// <summary>
        /// を取得します。
        /// </summary>
        public override object ProvideValue(IServiceProvider service)
        {
            if (string.IsNullOrEmpty(DirectoryPath))
            {
                throw new InvalidOperationException(
                          "ディレクトリパスが設定されていません。");
            }

            return(InfoBase.ReadInfoDirectory <ImageSetInfo>(DirectoryPath));
        }
        public InfoBaseTreeNode(InfoBase info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            m_Info = info;
            Text   = info.Caption;
        }
        public void KillInfoBase(object model)
        {
            _CurrentInfoBase = (InfoBase)model;
            MainMenuViewModel viewModel = this.GetMetadataModuleMainMenu();

            if (viewModel == null)
            {
                return;
            }
            viewModel.KillMetadataCommand.Execute(model);
        }
示例#30
0
        private void OnOpenMetadata(object args)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter          = "Файлы XML(*.xml)|*.xml" + "|Все файлы (*.*)|*.* ";
            dialog.CheckFileExists = true;
            dialog.Multiselect     = false;
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (MetadataTreeViewModel == null)
            {
                return;
            }
            try
            {
                InfoBase infoBase = new InfoBase();
                (new XMLMetadataAdapter()).Load(dialog.FileName, infoBase);

                bool cancel = true;

                Confirmation confirmation = new Confirmation
                {
                    Title   = CONST_ModuleDialogsTitle,
                    Content = "Загрузить метаданные SQL Server ?"
                };
                Z.Confirm(confirmation, c => { cancel = !c.Confirmed; });

                if (cancel)
                {
                    MetadataTreeViewModel.InfoBases.Add(infoBase);
                    return;
                }

                cancel = OpenSQLConnectionPopup(infoBase);
                if (cancel)
                {
                    Z.Notify(new Notification {
                        Title = CONST_ModuleDialogsTitle, Content = "Действие отменено пользователем."
                    });
                }
                else
                {
                    MetadataTreeViewModel.InfoBases.Add(infoBase);
                }
            }
            catch (Exception ex)
            {
                Z.Notify(new Notification {
                    Title = CONST_ModuleDialogsTitle, Content = GetErrorText(ex)
                });
            }
        }
示例#31
0
        public static InfoBase createIB(DettaglioQuoteProdotto dqp, UserProfile user, int i)
        {
            InfoBase ib = new InfoBase();

            ib.Canale             = CANALE.WEB;
            ib.CodiceApplicazione = "UL001P";
            ib.Compagnia          = "1";
            ib.Device             = DEVICE.WEB;
            ib.CodiceProdotto     = "000156";
            ib.StringInfo         = XmlManager.ParsificazioneXmlCasa(dqp.XmlResponse, user, "1", i);
            return(ib);
        }
示例#32
0
 public InviteArgument(UserInfo sender, InfoBase receiver, UserInfo invited, ChannelInfo channel)
     : base(sender, receiver, "INVITE")
 {
     this.invited = invited;
     this.channel = channel;
 }
 public PrivateMessageArgument(UserInfo sender, InfoBase receiver, string target, string message)
     : base(sender, receiver, "PRIVMSG")
 {
     Target = target;
     Message = message;
 }
示例#34
0
 public PingArgument(InfoBase receiver)
     : base(null, receiver, "PING")
 {
 }
示例#35
0
 public AwayArgument(UserInfo sender, InfoBase receiver, string awayMessage)
     : base(sender, receiver, "AWAY")
 {
     this.awayMessage = awayMessage;
 }
示例#36
0
 public JoinArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel)
     : base(sender, receiver, "JOIN")
 {
     Channel = channel;
 }
示例#37
0
 public TopicArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string newTopic)
     : base(sender, receiver, "TOPIC")
 {
     Channel = channel;
     NewTopic = newTopic;
 }
示例#38
0
 public NickArgument(UserInfo sender, InfoBase receiver, string newNick)
     : base(sender, receiver, "NICK")
 {
     this.newNick = newNick;
 }
示例#39
0
 public QuitArgument(UserInfo sender, InfoBase receiver, string message)
     : base(sender, receiver, "QUIT")
 {
     Message = message;
 }
示例#40
0
 public CommandArgument(UserInfo sender, InfoBase receiver, string name)
 {
     Name = name;
     Sender = sender;
     Receiver = receiver;
 }
示例#41
0
 public NoticeArgument(InfoBase receiver, string target, string message)
     : base(null, receiver, "NOTICE")
 {
     this.target = target;
     this.message = message;
 }
示例#42
0
 public NoticeArgument(UserInfo sender, InfoBase receiver, string target, string message)
     : base(sender, receiver, "NOTICE")
 {
     this.target = target;
     this.message = message;
 }
示例#43
0
 public ModeArgument(UserInfo sender, InfoBase receiver, string target, string modeString)
     : base(sender, receiver, "MODE")
 {
     Target = target;
     ModeString = modeString;
 }
示例#44
0
 public KnockArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string message)
     : base(sender, receiver, "KNOCK")
 {
     this.channel = channel;
     this.message = message;
 }
示例#45
0
 public PartArgument(UserInfo sender, InfoBase receiver, ChannelInfo channel, string message)
     : base(sender, receiver, "PART")
 {
     Channel = channel;
     Message = message;
 }
示例#46
0
 public PongArgument(InfoBase receiver, string parameter)
     : base(null, receiver, "PONG")
 {
     this.parameter = parameter;
 }
示例#47
0
 public CommandArgument(UserInfo sender, InfoBase receiver, string name)
 {
     this.name = name;
     this.sender = sender;
     this.receiver = receiver;
 }