Ejemplo n.º 1
0
        public void StateInvoke(RuntimeState state)
        {
            InvokeArgs args      = (InvokeArgs)state.arg;
            var        value     = args.value;
            var        arguments = args.arguments;
            var        thisObj   = args.thisObject;


            if (state.calleeReturned)
            {
                _jsValueArrayPool.ReturnArray((JsValue[])state.local);
                Return(state.calleeReturnValue);
                return;
            }


            var callable = value as ICallable ?? ExceptionHelper.ThrowArgumentException <ICallable>("Can only invoke functions");

            state.local = _jsValueArrayPool.RentArray(arguments.Length);
            for (int i = 0; i < arguments.Length; ++i)
            {
                ((JsValue[])state.local)[i] = JsValue.FromObject(this, arguments[i]);
            }

            if (callable is ScriptFunctionInstance)
            {
                Call((callable as ScriptFunctionInstance).CallState, new CallArgs(JsValue.FromObject(this, thisObj), (JsValue[])state.local));
                return;
            }
            else
            {
                Return(null);
                return;
            }
        }
Ejemplo n.º 2
0
        // Token: 0x06000F88 RID: 3976 RVA: 0x0005C2C0 File Offset: 0x0005A4C0
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            if (mailboxSession == null)
            {
                return;
            }
            try
            {
                ExDateTime now = ExDateTime.Now;
                if (!mailboxSession.Capabilities.CanHaveUserConfigurationManager)
                {
                    TopNAssistant.Tracer.TraceDebug <TopNAssistant, IExchangePrincipal>((long)this.GetHashCode(), "{0}: Skipping mailbox {1} for TopN because it can't have user configuration manager. Possibly an alternate mailbox.", this, mailboxSession.MailboxOwner);
                }
                else
                {
                    MailboxScanner mailboxScanner = new MailboxScanner(mailboxSession, this);
                    mailboxScanner.ProcessMailbox();
                    ExDateTime now2 = ExDateTime.Now;
                    TopNPerf.TimeToProcessLastMailbox.RawValue = (long)(now2 - now).TotalMilliseconds;
                    TopNPerf.NumberOfMailboxesProcessed.Increment();
                }
            }
            catch (StoragePermanentException innerException)
            {
                throw new SkipException(innerException);
            }
            catch (StorageTransientException innerException2)
            {
                throw new TransientMailboxException(innerException2);
            }
        }
Ejemplo n.º 3
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            int threadId = args.GetInt32();

            hub.DebugService.Continue(threadId);
            return(Task.FromResult <object>(null));
        }
        /// <summary>
        /// Method called by the framework to begin an Invoke operation asynchronously. Overrides
        /// should not call the base method.
        /// </summary>
        /// <param name="invokeArgs">The arguments to the Invoke operation.</param>
        /// <param name="callback">The callback to invoke when the invocation has been completed.</param>
        /// <param name="userState">Optional user state associated with this operation.</param>
        /// <returns>
        /// An asynchronous result that identifies this invocation.
        /// </returns>
        protected override async Task <InvokeCompletedResult> InvokeAsyncCore(InvokeArgs invokeArgs, CancellationToken cancellationToken)
        {
            var response = await ExecuteRequestAsync(invokeArgs.OperationName, invokeArgs.HasSideEffects, invokeArgs.Parameters, queryOptions : null, cancellationToken : cancellationToken)
                           .ConfigureAwait(false);

            IEnumerable <ValidationResult> validationErrors = null;
            object returnValue = null;

            try
            {
                returnValue = await ReadResponseAsync(response, invokeArgs.OperationName, invokeArgs.ReturnType)
                              .ConfigureAwait(false);
            }
            catch (FaultException <DomainServiceFault> fe)
            {
                if (fe.Detail.OperationErrors != null)
                {
                    validationErrors = fe.Detail.GetValidationErrors();
                }
                else
                {
                    throw GetExceptionFromServiceFault(fe.Detail);
                }
            }

            return(new InvokeCompletedResult(returnValue, validationErrors ?? Enumerable.Empty <ValidationResult>()));
        }
Ejemplo n.º 5
0
        // Token: 0x06001517 RID: 5399 RVA: 0x00078898 File Offset: 0x00076A98
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            mailboxSession.Mailbox.Load(GroupMailboxAssistantType.ExtendedProperties);
            if (mailboxSession.MailboxOwner.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox)
            {
                GroupMailboxAssistant.Tracer.TraceError((long)this.GetHashCode(), "ActivityId : {0} ; Mailbox : TypeDetail {1} , SmtpAddress {2}, ExchangeGuid {3} cannot be processed by GroupMailboxAssistant, Parameters {4}", new object[]
                {
                    invokeArgs.ActivityId,
                    mailboxSession.MailboxOwner.RecipientTypeDetails,
                    mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                    mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid,
                    invokeArgs.Parameters
                });
                customDataToLog.Add(new KeyValuePair <string, object>("GroupMailboxAssistantInfo", "Mailbox cannot be processed by GroupMailboxAssistant"));
                return;
            }
            this.UpdateGroupMailboxMembership(mailboxSession);
            IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(false, ConsistencyMode.FullyConsistent);
            ADUser            adUser             = adrecipientSession.FindADUserByObjectId(mailboxSession.MailboxOwner.ObjectId);

            this.UploadDefaultPhoto(adrecipientSession, adUser, invokeArgs, customDataToLog);
            this.PublishExchangeResourcesToAAD(adrecipientSession, adUser, invokeArgs, customDataToLog);
        }
Ejemplo n.º 6
0
        private Task <InvokeCompletedResult> BeginInvokeRequest(CancellationToken cancellationToken = default)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("msg", "foo");

            InvokeArgs invokeArgs = new InvokeArgs("Echo", typeof(string), parameters, true /*hasSideEffects*/);
            var        result     = this.DomainClient.InvokeAsync(invokeArgs, cancellationToken)
                                    .ContinueWith(task =>
            {
                try
                {
                    InvokeCompletedResult res   = task.GetAwaiter().GetResult();
                    this.InvokeCompletedResults = res;
                    return(res);
                }
                catch (Exception ex)
                {
                    this.Error = ex;
                    throw;
                }
            }
                                                  , TaskContinuationOptions.NotOnCanceled);

            this.AssertInProgress(result);
            return(result);
        }
Ejemplo n.º 7
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var staged = await StagedService.LoadStagedAsync(onlyModelsAndFolders : false); //TODO:暂重新加载

            hub.PendingChanges = staged.Items;
            if (hub.PendingChanges == null || hub.PendingChanges.Length == 0)
            {
                return(null);
            }

            var res = new List <ChangedInfo>();

            for (int i = 0; i < hub.PendingChanges.Length; i++)
            {
                //TODO:其他类型处理
                if (hub.PendingChanges[i] is ModelBase model)
                {
                    res.Add(new ChangedInfo {
                        ModelType = model.ModelType.ToString(), ModelID = model.Name
                    });
                }
                else if (hub.PendingChanges[i] is ModelFolder folder)
                {
                    res.Add(new ChangedInfo {
                        ModelType = ModelType.Folder.ToString(), ModelID = folder.TargetModelType.ToString()
                    });
                }
            }
            return(res);
        }
Ejemplo n.º 8
0
        // Token: 0x0600151A RID: 5402 RVA: 0x00078B44 File Offset: 0x00076D44
        private void UploadDefaultPhoto(IRecipientSession adSession, ADUser adUser, InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            if (!GroupMailboxDefaultPhotoUploader.IsFlightEnabled(mailboxSession))
            {
                return;
            }
            try
            {
                new GroupMailboxDefaultPhotoUploader(adSession, mailboxSession, adUser).UploadIfOutdated();
            }
            catch (LocalizedException ex)
            {
                GroupMailboxAssistant.Tracer.TraceError((long)this.GetHashCode(), "ActivityId : {0} ; Mailbox : TypeDetail {1} , SmtpAddress {2}, ExchangeGuid {3} cannot upload default photo for group, Parameters {4}. Exception: {5}", new object[]
                {
                    invokeArgs.ActivityId,
                    mailboxSession.MailboxOwner.RecipientTypeDetails,
                    mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                    mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid,
                    invokeArgs.Parameters,
                    ex
                });
                customDataToLog.Add(new KeyValuePair <string, object>("GroupMailboxDefaultPhotoUploader", string.Format("A photo can not be auto-generated for Group {0}. Exception: {1}", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, ex)));
            }
        }
Ejemplo n.º 9
0
        public void ReadObject(BinSerializer bs)
        {
            Source      = (InvokeSource)bs.ReadByte();
            ContentType = (InvokeProtocol)bs.ReadByte();
            WaitHandle  = new IntPtr(bs.ReadInt64());
            SourceMsgId = bs.ReadInt32();
            Service     = bs.ReadString();
            //注意统一转换为RoutedSession
            if (bs.ReadBoolean())
            {
                ulong id     = bs.ReadUInt64();
                int   levels = bs.ReadInt32();
                var   path   = new TreeNodePath(levels);
                for (int i = 0; i < levels; i++)
                {
                    path[i] = new TreeNodeInfo {
                        ID = bs.ReadGuid(), Text = bs.ReadString()
                    };
                }
                Guid?empID      = null;
                bool isExternal = bs.ReadBoolean();
                if (!isExternal)
                {
                    empID = bs.ReadGuid();
                }
                string tag = bs.ReadString();
                Session = new RoutedSession(id, path, empID, tag);
            }
            var args = new InvokeArgs();

            args.ReadObject(bs);
            Args = args; //Don't use Args.ReadObject(bs)
        }
Ejemplo n.º 10
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            int    type    = args.GetInt32();
            string modelId = args.GetString();

            if (type == 1)
            {
                var modelNode = hub.DesignTree.FindModelNode(ModelType.Service, ulong.Parse(modelId));
                if (modelNode == null)
                {
                    throw new Exception($"Cannot find ServiceModel: {modelId}");
                }

                var quickFixes = new List <QuickFix>();

                var document      = hub.TypeSystem.Workspace.CurrentSolution.GetDocument(modelNode.RoslynDocumentId);
                var semanticModel = document.GetSemanticModelAsync().Result;
                IEnumerable <Diagnostic> diagnostics = semanticModel.GetDiagnostics();

                return(Task.FromResult <object>(diagnostics.Select(MakeQuickFix).ToArray()));
            }
            else
            {
                throw ExceptionHelper.NotImplemented();
            }
        }
Ejemplo n.º 11
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            int    selectedNodeType = args.GetInt32();
            string selectedNodeId   = args.GetString();
            var    deleteNode       = hub.DesignTree.FindNode((DesignNodeType)selectedNodeType, selectedNodeId);

            if (deleteNode == null)
            {
                throw new Exception("Delete target not exists.");
            }
            if (!(deleteNode is ModelNode || deleteNode is ApplicationNode ||
                  deleteNode.NodeType == DesignNodeType.FolderNode && deleteNode.Nodes.Count == 0))
            {
                throw new Exception("Can not delete it.");
            }

            DesignNode rootNode = null;

            if (deleteNode is ModelNode modelNode)
            {
                rootNode = await DeleteModelNode(hub, modelNode);
            }
            else if (deleteNode is ApplicationNode appNode)
            {
                await DeleteApplicationNode(hub, appNode);
            }
            else
            {
                throw ExceptionHelper.NotImplemented(); //rootNode = DeleteFolderNode(hub, deleteNode);
            }
            //注意:返回rootNode.ID用于前端重新刷新模型根节点
            return(rootNode == null ? string.Empty : rootNode.ID);
        }
Ejemplo n.º 12
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var modelID = args.GetString(); // eg: sys.CustomerListView
            var sr      = modelID.Split('.');
            var app     = hub.DesignTree.FindApplicationNodeByName(sr[0]);
            var node    = hub.DesignTree.FindModelNodeByName(app.Model.Id, ModelType.View, sr[1]);

            if (node == null)
            {
                throw new Exception("Cannot found view node: " + modelID);
            }

            var modelNode = node as ModelNode;

            if (modelNode == null)
            {
                throw new Exception("Cannot found view model: " + modelID);
            }

            string runtimeCode = null;

            if (modelNode.IsCheckoutByMe)
            {
                runtimeCode = await StagedService.LoadViewRuntimeCode(modelNode.Model.Id);
            }
            if (string.IsNullOrEmpty(runtimeCode))
            {
                runtimeCode = await Store.ModelStore.LoadViewAssemblyAsync(modelID);
            }

            return(runtimeCode);
        }
Ejemplo n.º 13
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            //TODO:先判断DataStoreRootNode有没有被当前用户签出

            // 获取接收到的参数
            var storeType     = (DataStoreKind)args.GetInt32();
            var storeProvider = args.GetString();
            var storeName     = args.GetString();

            // 验证类名称的合法性
            if (string.IsNullOrEmpty(storeName))
            {
                throw new Exception("DataStore name can not be null");
            }
            if (!CodeHelper.IsValidIdentifier(storeName) || storeName == "Default")
            {
                throw new Exception("DataStore name invalid");
            }
            // TODO: 验证名称是否已存在

            // 开始新建存储节点
            var model = new DataStoreModel(storeType, storeProvider, storeName);
            //添加节点至模型树并绑定签出信息
            var node = hub.DesignTree.StoreRootNode.AddModel(model, hub);

            // 保存至本地
            await node.SaveAsync();

            // 新建RoslynDocument
            hub.TypeSystem.CreateStoreDocument(node);

            return(node);
        }
 // Token: 0x060011B2 RID: 4530 RVA: 0x0006791C File Offset: 0x00065B1C
 protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
 {
     StoreMaintenanceAssistant.MaintenanceMailboxData maintenanceMailboxData = invokeArgs.MailboxData as StoreMaintenanceAssistant.MaintenanceMailboxData;
     try
     {
         TimeBasedAssistant.TrackAdminRpcCalls(base.DatabaseInfo, "Client=Maintenance", delegate(ExRpcAdmin rpcAdmin)
         {
             rpcAdmin.ExecuteTask(this.DatabaseInfo.Guid, maintenanceMailboxData.MaintenanceId, maintenanceMailboxData.MailboxNumber);
             if (maintenanceMailboxData.MailboxNumber == 0)
             {
                 customDataToLog.Add(new KeyValuePair <string, object>("DatabaseMaintenance", maintenanceMailboxData.MaintenanceId.ToString()));
                 return;
             }
             customDataToLog.Add(new KeyValuePair <string, object>("MailboxMaintenance", maintenanceMailboxData.MaintenanceId.ToString()));
             customDataToLog.Add(new KeyValuePair <string, object>("Mailbox", maintenanceMailboxData.MailboxGuid.ToString()));
         });
     }
     catch (MapiRetryableException innerException)
     {
         throw new SkipException(innerException);
     }
     catch (MapiPermanentException innerException2)
     {
         throw new SkipException(innerException2);
     }
 }
Ejemplo n.º 15
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            string modelId = args.GetString();

            ModelNode[] modelNodes;
            if (string.IsNullOrEmpty(modelId)) //空表示所有模型用于初次加载
            {
                modelNodes = hub.DesignTree.FindNodesByType(ModelType.Entity);
            }
            else //指定标识用于更新
            {
                ulong id   = ulong.Parse(modelId);
                var   node = hub.DesignTree.FindModelNode(ModelType.Entity, id);
                modelNodes = new ModelNode[] { node };
            }

            List <TypeScriptDeclare> list = new List <TypeScriptDeclare>();

            foreach (var node in modelNodes)
            {
                list.Add(new TypeScriptDeclare
                {
                    Name    = $"{node.AppNode.Model.Name}.Entities.{node.Model.Name}",
                    Declare = BuildDeclare(node, hub)
                });
            }

            return(Task.FromResult <object>(list));
        }
Ejemplo n.º 16
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var modelID     = args.GetString();
            var routeEnable = args.GetBoolean();
            var routeParent = args.GetString();
            var routePath   = args.GetString();

            if (routeEnable && !string.IsNullOrEmpty(routeParent) && string.IsNullOrEmpty(routePath))
            {
                throw new InvalidOperationException("Assign RouteParent must set RoutePath");
            }
            //TODO:判断路径有效性,以及是否重复

            var modelNode = hub.DesignTree.FindModelNode(ModelType.View, ulong.Parse(modelID));

            if (modelNode == null)
            {
                throw new Exception($"Cannot find view model node: {modelID}");
            }

            var viewModel = (ViewModel)modelNode.Model;

            viewModel.Flag        = routeEnable == true ? ViewModelFlag.ListInRouter : ViewModelFlag.None;
            viewModel.RouteParent = routeParent;
            viewModel.RoutePath   = routePath;

            return(Task.FromResult <object>(true));
        }
Ejemplo n.º 17
0
        public async ValueTask <AnyValue> InvokeAsync(string servicePath, InvokeArgs args)
        {
            var firstDot = servicePath.IndexOf('.');
            var lastDot  = servicePath.LastIndexOf('.');

            if (firstDot == lastDot)
            {
                throw new ArgumentException(nameof(servicePath));
            }
            var service = servicePath.Substring(0, lastDot);
            var method  = servicePath.AsMemory(lastDot + 1);

            var instance = await services.TryGetAsync(service);

            if (instance == null) //TODO:判断系统服务,是则转发至主进程
            {
                throw new Exception($"Cannot find service:{service}");
            }

            var stopWatch = System.Diagnostics.Stopwatch.StartNew();
            var res       = await instance.InvokeAsync(method, args).ConfigureAwait(false);

            stopWatch.Stop();
            var metricReq = new MetricRequire(servicePath, stopWatch.Elapsed.TotalSeconds);

            Channel.SendMessage(ref metricReq); //TODO:考虑调试子进程不发送,另考虑合并优化发送Metric

            return(res);
        }
Ejemplo n.º 18
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var nodeType = (DesignNodeType)args.GetInt32();
            var modelID  = args.GetString();

            //Log.Debug($"nodeType={nodeType} modelId={modelID}");

            if (nodeType == DesignNodeType.ServiceModelNode)
            {
                var modelNode = hub.DesignTree.FindModelNode(ModelType.Service, ulong.Parse(modelID));
                if (modelNode != null) //可能已被删除了,即由删除节点引发的关闭设计器
                {
                    var fileName = $"{modelNode.AppNode.Model.Name}.Services.{modelNode.Model.Name}.cs";
                    var document = hub.TypeSystem.Workspace.GetOpenedDocumentByName(fileName);
                    if (document != null)
                    {
                        hub.TypeSystem.Workspace.CloseDocument(document.Id);
                    }
                }
            }
            else if (nodeType == DesignNodeType.WorkflowModelNode)
            {
                throw ExceptionHelper.NotImplemented();
                //var sr = modelID.Split('.');
                //var modelNode = hub.DesignTree.FindModelNode(ModelType.Workflow, sr[0], sr[1]);
                //hub.WorkflowDesignService.CloseWorkflowModel(modelNode);
            }
            return(Task.FromResult <object>(null));
        }
Ejemplo n.º 19
0
 protected override IAsyncResult BeginInvokeCore(InvokeArgs invokeArgs, AsyncCallback callback, object userState)
 {
     var returnData = Invoke(invokeArgs.OperationName, invokeArgs.Parameters);
     var asyncResult = new LocalAsyncResult(callback, userState, returnData);
     _syncContext.Post(o => ((LocalAsyncResult)o).Complete(), asyncResult);
     return asyncResult;
 }
Ejemplo n.º 20
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var modelID     = args.GetString();
            var methodName  = args.GetString();
            var methodArgs  = args.GetString();
            var breakpoints = args.GetString();

            //先编译服务模型,将编译结果保存至当前会话的调试目录内
            var debugFolder = Path.Combine(Runtime.RuntimeContext.Current.AppPath, "debug", hub.Session.SessionID.ToString());

            if (Directory.Exists(debugFolder))
            {
                Directory.Delete(debugFolder, true);
            }
            Directory.CreateDirectory(debugFolder);

            var serviceNode = hub.DesignTree.FindModelNode(ModelType.Service, ulong.Parse(modelID));
            await PublishService.CompileServiceAsync(hub, (ServiceModel)serviceNode.Model, debugFolder);

            //释放第三方组件库 TODO:暂简单实现
            var debugLibPath = Path.Combine(debugFolder, "lib");
            await Store.ModelStore.ExtractAppAssemblies(serviceNode.AppNode.Model.Name, debugLibPath);

            //启动调试进程
            var appName = serviceNode.AppNode.Model.Name;

            hub.DebugService.DebugSourcePath = $"{appName}.Services.{serviceNode.Model.Name}.cs";
            hub.DebugService.StartDebugger($"{appName}.{serviceNode.Model.Name}.{methodName}", methodArgs, breakpoints);

            return(null);
        }
Ejemplo n.º 21
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            // 获取接收到的参数
            string appName = args.GetString();
            //string localizedName = args.GetObject() as string;

            var node = hub.DesignTree.FindApplicationNodeByName(appName);

            if (node != null)
            {
                throw new Exception("Application has existed.");
            }
            if (System.Text.Encoding.UTF8.GetByteCount(appName) > 8)
            {
                throw new Exception("Application name too long");
            }
            var appRootNode = hub.DesignTree.AppRootNode;
            var appModel    = new ApplicationModel("appbox", appName); //TODO:fix owner
            var appNode     = new ApplicationNode(hub.DesignTree, appModel);

            appRootNode.Nodes.Add(appNode);
            // 直接创建并保存
            await Store.ModelStore.CreateApplicationAsync(appModel);

            return(new NewNodeResult
            {
                ParentNodeType = (int)appRootNode.NodeType,
                ParentNodeID = appRootNode.ID,
                NewNode = appNode
            });
        }
Ejemplo n.º 22
0
        // Token: 0x06000B47 RID: 2887 RVA: 0x000487EC File Offset: 0x000469EC
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            if (mailboxSession == null)
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceError((long)this.GetHashCode(), "invokeArgs.StoreSession has to be an MailboxSession; it cannot be be null or PublicFolderSession.");
                throw new ArgumentNullException("mailboxSession");
            }
            Guid mailboxGuid = mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid;

            if (!mailboxSession.Capabilities.CanHaveJunkEmailRule)
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Skipping mailbox {0} (GUID: {1}) because it cannot have a junk e-mail rule.  Possibly an alternate mailbox.", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxGuid);
                try
                {
                    MailboxTagging.TagFinishedProcessing(mailboxSession);
                }
                catch (StoragePermanentException arg)
                {
                    JunkEmailOptionsCommiterAssistant.Tracer.TraceError <string, Guid, StoragePermanentException>((long)this.GetHashCode(), "Failed at tagging mailbox {0} (GUID: {1}).  Exception: {2}", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxGuid, arg);
                }
                return;
            }
            try
            {
                JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Updating safe/block lists of mailbox {0} (GUID: {1})", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxGuid);
                this.UpdateSafeLists(mailboxSession);
                JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Update of mailbox {0} (GUID: {1}) was successful", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxGuid);
                try
                {
                    MailboxTagging.TagFinishedProcessing(mailboxSession);
                }
                catch (StoragePermanentException arg2)
                {
                    JunkEmailOptionsCommiterAssistant.Tracer.TraceError <string, Guid, StoragePermanentException>((long)this.GetHashCode(), "Failed at tagging mailbox {0} (GUID: {1}).  Exception: {2}", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxGuid, arg2);
                }
            }
            catch (TransientException exception)
            {
                this.HandleExceptionAtUpdatingSafeList(exception, true, mailboxSession);
            }
            catch (JunkEmailValidationException exception2)
            {
                this.HandleExceptionAtUpdatingSafeList(exception2, false, mailboxSession);
            }
            catch (DataSourceOperationException exception3)
            {
                this.HandleExceptionAtUpdatingSafeList(exception3, false, mailboxSession);
            }
            catch (StoragePermanentException exception4)
            {
                this.HandleExceptionAtUpdatingSafeList(exception4, false, mailboxSession);
            }
            catch (DataValidationException exception5)
            {
                this.HandleExceptionAtUpdatingSafeList(exception5, false, mailboxSession);
            }
        }
Ejemplo n.º 23
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            string fileName = args.GetString();
            string tempFile = args.GetString();
            string appName  = args.GetString();

            if (string.IsNullOrEmpty(appName))
            {
                throw new ArgumentException("必须指明App");
            }

            //找到对应的ApplicationNode
            var appNode = hub.DesignTree.FindApplicationNodeByName(appName);

            if (appNode == null)
            {
                throw new Exception("未能找到应用节点: " + appName);
            }

            //判断组件类型
            AssemblyPlatform platform = AssemblyPlatform.Common;
            var ext = Path.GetExtension(fileName);

            if (ext == "so")
            {
                platform = AssemblyPlatform.Linux;
            }
            else if (ext == "dylib")
            {
                platform = AssemblyPlatform.OSX;
            }
            else if (!IsDotNetAssembly(tempFile))
            {
                platform = AssemblyPlatform.Windows;
            }

            //压缩组件
            using var dllStream = new MemoryStream(1024);
            using var cs        = new BrotliStream(dllStream, CompressionMode.Compress, true);
            using var fs        = File.OpenRead(tempFile);
            await fs.CopyToAsync(cs);

            await cs.FlushAsync();

            var asmData = dllStream.ToArray();

            //保存组件
            var asmName = $"{appName}.{fileName}";
            await Store.ModelStore.UpsertAppAssemblyAsync(asmName, asmData, platform);

            //TODO:*****
            // 1. 通知所有DesignHub.TypeSystem更新MetadataReference缓存,并更新相关项目引用
            //TypeSystem.RemoveMetadataReference(fileName, appID);
            // 2. 如果相应的AppContainer已启动,通知其移除所有引用该第三方组件的服务实例缓存,使其自动重新加载
            // 3. 如果集群模式,通知集群其他节点做上述1,2操作

            return(platform == AssemblyPlatform.Common ? true : false); //返回true表示.net 组件可引用, false表示native不可直接引用
        }
 // Token: 0x0600159F RID: 5535 RVA: 0x0007A754 File Offset: 0x00078954
 protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
 {
     this.TraceDebugExecuting(ExTraceGlobals.ProbeTimeBasedAssistantTracer.IsTraceEnabled(TraceType.DebugTrace) ? MethodBase.GetCurrentMethod().Name : string.Empty);
     if (ExTraceGlobals.ProbeTimeBasedAssistantTracer.IsTraceEnabled(TraceType.DebugTrace))
     {
         ExTraceGlobals.ProbeTimeBasedAssistantTracer.TraceDebug <ProbeTimeBasedAssistant, Guid>((long)this.GetHashCode(), "{0} is starting to process mailbox with GUID {1}", this, invokeArgs.MailboxData.MailboxGuid);
     }
     customDataToLog.Add(new KeyValuePair <string, object>("ProbeTimeBasedAssistant", invokeArgs.MailboxData.MailboxGuid));
 }
Ejemplo n.º 25
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var appName = args.GetString();
            var path    = args.GetString();

            var app = await RuntimeContext.Current.GetApplicationModelAsync(appName);

            return(await Store.BlobStore.ListAsync(app.StoreId, path));
        }
        // Token: 0x06000E48 RID: 3656 RVA: 0x00055A2C File Offset: 0x00053C2C
        protected override void InvokeInternal(InvokeArgs invokeArgs, List <KeyValuePair <string, object> > customDataToLog)
        {
            MailboxSession mailboxSession = invokeArgs.StoreSession as MailboxSession;

            if (mailboxSession == null)
            {
                return;
            }
            ADUser aduser = SharingPolicyAssistant.GetADUser(mailboxSession.MailboxOwner, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));

            if (aduser == null)
            {
                return;
            }
            if (ADRecipient.IsSystemMailbox(aduser.RecipientTypeDetails))
            {
                SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal, RecipientTypeDetails>((long)this.GetHashCode(), "{0}: Skipping the mailbox processing as it is a system mailbox. RecipientTypeDetails {1}.", mailboxSession.MailboxOwner, aduser.RecipientTypeDetails);
                return;
            }
            SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Begin process mailbox", mailboxSession.MailboxOwner);
            SharingPolicyCache sharingPolicyCache = SharingPolicyCache.Get(aduser);
            bool flag = false;

            if (sharingPolicyCache != null)
            {
                if (!this.IsMailboxNeedingPolicyUpdate(mailboxSession, sharingPolicyCache))
                {
                    return;
                }
                flag = this.ApplyPolicy(mailboxSession, sharingPolicyCache.Policy);
            }
            if (flag)
            {
                SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Storing applied policy to mailbox table.", mailboxSession.MailboxOwner);
                SharingPolicyAssistant.UpdateMailboxData(mailboxSession.Mailbox, (aduser.SharingPolicy == null && !sharingPolicyCache.BelongsToDehydratedContainer) ? SharingPolicyCache.DynamicDefaultPolicy.ObjectGuid.ToByteArray() : sharingPolicyCache.Policy.Id.ObjectGuid.ToByteArray(), sharingPolicyCache.Hash);
            }
            else
            {
                SharingPolicyAssistant.Tracer.TraceWarning <IExchangePrincipal>(0L, "{0}: Unable to find sharing policy for this mailbox.", mailboxSession.MailboxOwner);
                ExDateTime?exDateTime = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.LastSharingPolicyAppliedTime) as ExDateTime?;
                byte[]     array      = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.LastSharingPolicyAppliedHash) as byte[];
                if (exDateTime == null || array != null)
                {
                    SharingPolicyAssistant.UpdateMailboxData(mailboxSession.Mailbox, null, null);
                }
                else
                {
                    TimeSpan retryTimeSpan = ExDateTime.UtcNow.Subtract(exDateTime.Value);
                    if (ExDateTime.UtcNow.Subtract(exDateTime.Value) > SharingPolicyAssistant.RetryThresholdLimit)
                    {
                        SharingPolicyAssistant.SubmitInformationalWatson(mailboxSession.MailboxOwner, retryTimeSpan);
                        SharingPolicyAssistant.UpdateMailboxData(mailboxSession.Mailbox, null, null);
                    }
                }
            }
            SharingPolicyAssistant.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: End process mailbox", mailboxSession.MailboxOwner);
        }
 // Token: 0x06001476 RID: 5238 RVA: 0x000762B8 File Offset: 0x000744B8
 private static string GetDiagnosticsText(InvokeArgs args)
 {
     return(string.Format(CultureInfo.InvariantCulture, "{{ Mailbox Display Name:{0}; Mailbox Owner:{1}; Activity Id:{2}; }}", new object[]
     {
         args.MailboxData.DisplayName,
         (args.StoreSession != null && args.StoreSession.MailboxOwner != null) ? args.StoreSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString() : null,
         args.ActivityId
     }));
 }
Ejemplo n.º 28
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var modelID = args.GetString();
            var array   = args.GetObjectArray();
            var newDeps = array != null?array.Cast <string>().ToArray() : new string[0];

            var modelNode = hub.DesignTree.FindModelNode(ModelType.Service, ulong.Parse(modelID));

            if (modelNode == null)
            {
                throw new Exception("Can't find service model node");
            }

            var model   = (ServiceModel)modelNode.Model;
            var appName = modelNode.AppNode.Model.Name;

            //开始比对
            //bool hasChanged = false;
            if (model.HasReference)
            {
                //先处理移除的
                for (int i = model.References.Count - 1; i >= 0; i--)
                {
                    if (!newDeps.Contains(model.References[i]))
                    {
                        hub.TypeSystem.RemoveServiceReference(modelNode.ServiceProjectId, appName, model.References[i]);
                        model.References.RemoveAt(i);
                        //hasChanged = true;
                    }
                }
                //再处理新增的
                for (int i = 0; i < newDeps.Length; i++)
                {
                    if (!model.References.Contains(newDeps[i]))
                    {
                        hub.TypeSystem.AddServiceReference(modelNode.ServiceProjectId, appName, newDeps[i]);
                        model.References.Add(newDeps[i]);
                        //hasChanged = true;
                    }
                }
            }
            else if (newDeps.Length > 0)
            {
                for (int i = 0; i < newDeps.Length; i++)
                {
                    hub.TypeSystem.AddServiceReference(modelNode.ServiceProjectId, appName, newDeps[i]);
                    model.References.Add(newDeps[i]);
                }
                //hasChanged = true;
            }

            //if (hasChanged)
            //    await modelNode.SaveAsync(null);

            return(Task.FromResult((object)null));
        }
        /// <summary>
        /// Initializes a new <see cref="WebDomainClientAsyncResult&lt;TContract&gt;"/> instance used for Invoke operations.
        /// </summary>
        /// <param name="invokeArgs">The arguments to the Invoke operation.</param>
        /// <param name="callback">Optional <see cref="AsyncCallback"/> to invoke upon completion.</param>
        /// <param name="asyncState">Optional user state information that will be passed to the <paramref name="callback"/>.</param>
        /// <exception cref="ArgumentNullException">if <paramref name="domainClient"/> is null.</exception>
        /// <exception cref="ArgumentNullException">if <paramref name="endOperationMethod"/> is null.</exception>
        private WebApiDomainClientAsyncResult(WebApiDomainClient domainClient, InvokeArgs invokeArgs, AsyncCallback callback, object asyncState)
            : base(domainClient, invokeArgs, callback, asyncState)
        {
            // base class validates domainClient
            if (invokeArgs == null)
                throw new ArgumentNullException("invokeArgs");

            _interfaceType = domainClient.ServiceInterfaceType;
            _operationName = invokeArgs.OperationName;
        }
Ejemplo n.º 30
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var refType = (ModelReferenceType)args.GetInt32();
            var modelID = args.GetString();
            var oldName = args.GetString();
            var newName = args.GetString();

            return(await RefactoringService.RenameAsync(hub, refType,
                                                        ulong.Parse(modelID), oldName, newName));
        }
Ejemplo n.º 31
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var modelID = args.GetString();
            var line    = args.GetInt32() - 1;
            var column  = args.GetInt32() - 1;

            var modelNode = hub.DesignTree.FindModelNode(ModelType.Service, ulong.Parse(modelID));

            if (modelNode == null)
            {
                throw new Exception("Can't find service model node");
            }

            //定位服务入口方法
            var doc           = hub.TypeSystem.Workspace.CurrentSolution.GetDocument(modelNode.RoslynDocumentId);
            var semanticModel = await doc.GetSemanticModelAsync();

            var sourceText = await doc.GetTextAsync();

            var position = sourceText.Lines.GetPosition(new LinePosition(line, column));
            var symbol   = await SymbolFinder.FindSymbolAtPositionAsync(semanticModel, position, hub.TypeSystem.Workspace);

            if (symbol == null)
            {
                throw new Exception("Can't find service method");
            }
            if (symbol.Kind != SymbolKind.Method)
            {
                throw new Exception("Not a method");
            }
            if (symbol.ContainingType.ToString() != string.Format("{0}.ServiceLogic.{1}", modelNode.AppNode.ID, modelNode.Model.Name))
            {
                throw new Exception("Not a service method");
            }
            if (symbol.DeclaredAccessibility.ToString() != "Public")
            {
                throw new Exception("Not a service method");
            }

            IMethodSymbol method = symbol as IMethodSymbol;
            var           sb     = new StringBuilder("{\"Name\":\"");

            sb.Append(method.Name);
            sb.Append("\", \"Args\":[");
            for (int i = 0; i < method.Parameters.Length; i++)
            {
                sb.AppendFormat("{{\"Name\":\"{0}\",\"Type\":\"{1}\"}}", method.Parameters[i].Name, method.Parameters[i].Type);
                if (i != method.Parameters.Length - 1)
                {
                    sb.Append(",");
                }
            }
            sb.Append("]}");
            return(sb.ToString());
        }
Ejemplo n.º 32
0
        public async Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var nodeType = (DesignNodeType)args.GetInt32();
            var nodeID   = args.GetString();

            var node = hub.DesignTree.FindNode(nodeType, nodeID);

            if (node == null)
            {
                throw new Exception($"Can't find DesignNode: {nodeID}");
            }

            var modelNode = node as ModelNode;

            if (modelNode != null)
            {
                var  curVersion = modelNode.Model.Version;
                bool checkoutOk = await modelNode.Checkout();

                if (!checkoutOk)
                {
                    throw new Exception($"Can't checkout ModelNode: {nodeID}");
                }
                if (curVersion != modelNode.Model.Version)
                {
                    return(true); //返回True表示模型已变更,用于前端刷新
                }
            }
            else if (node.NodeType == DesignNodeType.ModelRootNode)
            {
                bool checkoutOk = await node.Checkout();

                if (!checkoutOk)
                {
                    throw new Exception("Can't checkout ModelRootNode");
                }
                return(true); //TODO:暂返回需要更新
            }
            else if (node.NodeType == DesignNodeType.DataStoreNode)
            {
                bool checkoutOk = await node.Checkout();

                if (!checkoutOk)
                {
                    throw new Exception("Can't checkout DataStoreNode");
                }
                return(false);
            }
            else
            {
                throw new Exception("无法签出此类型的节点");
            }

            return(false);
        }
Ejemplo n.º 33
0
        private void InvokeFunction(InvokeArgs args)
        {
            if (m_Thread != null && m_Thread.IsAlive)
                throw new ApiInvokeException("An asynchronous call is already being performed");

            State = EditState.Working;
            m_Thread = new Thread(InvokerThread);
            m_Thread.Start(args);
        }
 /// <summary>
 /// Creates a new <see cref="WebDomainClientAsyncResult&lt;TContract&gt;"/> used for Invoke operations.
 /// </summary>
 /// <param name="domainClient">The <see cref="WebDomainClient&lt;TContract&gt;"/> associated with this result.</param>
 /// 
 /// <param name="endOperationMethod">The method that completes an asynchronous operation.</param>
 /// <param name="invokeArgs">The arguments to the Invoke operation.</param>
 /// <param name="callback">The <see cref="AsyncCallback"/> to invoke upon completion.</param>
 /// <param name="asyncState">Optional user state information that will be passed to the <paramref name="callback"/>.</param>
 /// <returns>A <see cref="WebDomainClientAsyncResult&lt;TContract&gt;"/> used for Invoke operations</returns>
 public static WebApiDomainClientAsyncResult CreateInvokeResult(WebApiDomainClient domainClient, InvokeArgs invokeArgs, AsyncCallback callback, object asyncState)
 {
     return new WebApiDomainClientAsyncResult(domainClient, invokeArgs, callback, asyncState);
 }
        /// <summary>
        /// Method called by the framework to begin an Invoke operation asynchronously. Overrides
        /// should not call the base method.
        /// </summary>
        /// <param name="invokeArgs">The arguments to the Invoke operation.</param>
        /// <param name="callback">The callback to invoke when the invocation has been completed.</param>
        /// <param name="userState">Optional user state associated with this operation.</param>
        /// <returns>
        /// An asynchronous result that identifies this invocation.
        /// </returns>
        protected override IAsyncResult BeginInvokeCore(InvokeArgs invokeArgs, AsyncCallback callback, object userState)
        {
            var result = WebApiDomainClientAsyncResult.CreateInvokeResult(this, invokeArgs, callback, userState);

            return BeginWebRequest(result, invokeArgs.HasSideEffects, invokeArgs.Parameters, queryOptions: null);
        }