private int SetCallCurrentCommunity(dtoBaseForPaper call)
        {
            dtoCallCommunityContext context = ServiceCall.GetCallCommunityContext(call, View.Portalname);

            View.SetContainerName(context.CommunityName, context.CallName);
            View.IdCallCommunity = context.IdCommunity;
            return(context.IdCommunity);
            //int idCommunity = 0;
            //Community currentCommunity = CurrentManager.GetCommunity(this.UserContext.CurrentCommunityID);
            //Community community = null;
            //if (call != null)
            //    idCommunity = (call.IsPortal) ? 0 : (call.Community != null) ? call.Community.Id : 0;


            //community = CurrentManager.GetCommunity(idCommunity);
            //if (community != null)
            //    View.SetContainerName(community.Name, (call != null) ? call.Name : "");
            //else if (currentCommunity != null && !call.IsPortal )
            //{
            //    idCommunity = this.UserContext.CurrentCommunityID;
            //    View.SetContainerName(currentCommunity.Name, (call != null) ? call.Name : "");
            //}
            //else
            //{
            //    idCommunity = 0;
            //    View.SetContainerName(View.Portalname, (call != null) ? call.Name : "");
            //}
            //View.IdCallCommunity = idCommunity;
            //return idCommunity;
        }
Пример #2
0
 public static CommandReply AsCommandReply(this ServiceCall self, ICodec codec)
 {
     return(new CommandReply {
         Type = ReplyType.ServiceInvoked,
         ReplyData = codec.Encode(self)
     });
 }
Пример #3
0
 public ResolvedHandler(ServiceCall objCall, IRepository repository, IUnitOfWork unitOfWork, IUserStore <AppUser> userStore, AppUser loginUser, ILogger <ServiceCallManager> logger)
 {
     _call       = objCall;
     _repository = repository;
     _unitOfWork = unitOfWork;
     _logger     = logger;
 }
Пример #4
0
        /// <summary>
        /// Make GET call to receive Project Spaces for current signed in user.
        /// Assigns spaces to this.UserSpaces.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <string> GetSpaces(Action <bool> onComplete)
        {
            var uriString = WebServices.Instance.MotiveUrl + "/api/account/projectSpaces";
            var call      = new ServiceCall(new Uri(uriString));

            Action <AuthenticatorCallStatus> onCompleteWrapper = (status) =>
            {
                var success = (status == AuthenticatorCallStatus.Success);

                if (success)
                {
                    UserSpaces.Clear();

                    var spacesWrapper = JsonHelper.GetReader(call.ResponseText).Deserialize <GetSpacesModel>();
                    if (spacesWrapper != null)
                    {
                        UserSpaces.AddRange(spacesWrapper.Spaces);
                    }
                }

                if (onComplete != null)
                {
                    onComplete(success);
                }
            };

            MotiveAuthenticator.Instance.MakeUserCall(call, onCompleteWrapper);

            return(null);
        }
Пример #5
0
        public void ServiceCallCanceled()
        {
            var continueWith = 0;

            _serviceCall.ContinueWith(serviceCall =>
            {
                Assert.AreEqual(_serviceCall, serviceCall);
                Assert.IsTrue(serviceCall.IsCanceled);
                continueWith++;
            });
            Assert.AreEqual(0, continueWith);
            _serviceCall.Cancel();
            Assert.AreEqual(1, continueWith);
            Assert.IsFalse(_serviceCall.IsCompleted);
            Assert.IsTrue(_serviceCall.IsCanceled);
            Assert.IsFalse(_serviceCall.IsFaulted);
            Assert.IsNull(_serviceCall.Result);
            Assert.IsNull(_serviceCall.Exception);

            // Check copy state.
            var copy = new ServiceCall();

            copy.CopyState(_serviceCall);
            Assert.IsFalse(copy.IsCompleted);
            Assert.IsTrue(copy.IsCanceled);
            Assert.IsFalse(copy.IsFaulted);
            Assert.IsNull(copy.Result);
            Assert.IsNull(copy.Exception);
        }
Пример #6
0
        public String GetFileName(String filename, long idCommittee)
        {
            String   result         = filename;
            DateTime data           = DateTime.Now;
            String   commissionName = (idCommittee > 0) ? Service.GetCommitteeName(idCommittee) : "";
            String   callName       = ServiceCall.GetCallName(View.IdCall);

            if (!String.IsNullOrEmpty(commissionName))
            {
                commissionName = commissionName.Trim();
            }
            if (idCommittee > 0 && !String.IsNullOrEmpty(commissionName) && commissionName.Length > 30)
            {
                commissionName = Service.GetCommitteeDisplayOrder(idCommittee).ToString();
            }

            if (idCommittee > 0)
            {
                result = String.Format(filename, commissionName, data.Year, ((data.Month < 10) ? "0" : "") + data.Month.ToString(), ((data.Day < 10) ? "0" : "") + data.Day.ToString());
            }
            else
            {
                result = String.Format(filename, callName, data.Year, ((data.Month < 10) ? "0" : "") + data.Month.ToString(), ((data.Day < 10) ? "0" : "") + data.Day.ToString());
            }

            return(lm.Comol.Core.DomainModel.Helpers.Export.ExportBaseHelper.HtmlCheckFileName(result));
        }
    protected void ServiceCallsGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        int         scID = Convert.ToInt32(ServiceCallsArchiveGV.SelectedRow.Cells[1].Text);
        ServiceCall sc   = new ServiceCall();

        dt = sc.GetServiceCallPopupMissingDetails(scID);

        //Set the Popup details
        if (dt.Rows.Count > 0)
        {
            ServiceCallID.Text         = scID.ToString();
            ServiceCallDateOpened.Text = ((DateTime)dt.Rows[0].ItemArray[1]).ToString("MM/dd/yyyy");
            DateTime ExpirationDate = (DateTime)dt.Rows[0].ItemArray[2];
            ServiceCallExpirationDate.Text = ExpirationDate.ToString("MM/dd/yyyy");
            if (DateTime.Now > ExpirationDate) // Warranty expired
            {
                ServiceCallExpirationDate.Style.Add("border", "2px solid #DB0F0F");
            }
            else // Product is in warranty
            {
                ServiceCallExpirationDate.Style.Add("border", "2px solid #00B800");
            }

            ServiceCallProblemDesc.Text = dt.Rows[0].ItemArray[3].ToString();
            ServiceCallUrgent.Checked   = Convert.ToBoolean(dt.Rows[0].ItemArray[4]);
            ServiceCallFirstName.Text   = dt.Rows[0].ItemArray[5].ToString();
            ServiceCallLastName.Text    = dt.Rows[0].ItemArray[6].ToString();
            ServiceCallPhone.Text       = dt.Rows[0].ItemArray[7].ToString();
            ServiceCallMobile.Text      = dt.Rows[0].ItemArray[8].ToString();
            ServiceCallAddress.Text     = dt.Rows[0].ItemArray[9].ToString();
            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallModalServiceCalls", "ActivateModal('ModalServiceCalls');", true);
        }
    }
Пример #8
0
        /// <summary>
        /// 生成服务调用声明
        /// <remarks>用于本地存在目标服务代理的调用声明,支持多态参数</remarks>
        /// </summary>
        /// <param name="serviceType">目标服务类型</param>
        /// <param name="methodName">目标方法名</param>
        /// <param name="arguments">参数组</param>
        /// <returns></returns>
        public ServiceCall GenerateServiceCall(Type serviceType, string methodName, params Tuple <string, Type, object>[] arguments)
        {
            ServiceInfo service = this.ServiceTable.Services.FirstOrDefault(o =>
                                                                            o.Type != null && o.Type.Equals(serviceType));

            if (service == null)
            {
                throw new ServiceException(string.Format(
                                               "当前服务节点不存在类型为{0}的服务配置信息"
                                               , serviceType.FullName));
            }

            var call = new ServiceCall()
            {
                TargetMethod = methodName, Identity = this.Configuration.ID
            };

            if (arguments != null)
            {
                var args = new List <ServiceCallArgument>();
                //多态序列化
                arguments.ToList().ForEach(o =>
                                           args.Add(new ServiceCallArgument(o.V1, this._serializer.Serialize(o.V3, o.V2))));
                call.ArgumentCollection = args.ToArray();
            }
            //根据负载算法选取适合的服务配置
            call.Target = this.Resolve <ILoadBalancingHelper>().GetServiceConfig(service
                                                                                 , call.TargetMethod
                                                                                 , call.ArgumentCollection);
            return(call);
        }
        private void LoadSections(BaseForPaper call, dtoSubmissionRevision subRev, Boolean allowAdmin)
        {
            if (call.Type == CallForPaperType.CallForBids)
            {
                List <dtoCallSubmissionFile>  requiredFiles = ServiceCall.GetRequiredFiles(call, subRev.Type.Id, subRev.Id);
                Dictionary <long, FieldError> filesError    = ServiceCall.GetSubmissionRequiredFileErrors(subRev.Id);
                if (requiredFiles != null && requiredFiles.Count > 0 && filesError != null)
                {
                    requiredFiles.ForEach(f => f.SetError(filesError));
                }
                View.LoadRequiredFiles(requiredFiles);
            }

            List <dtoCallSection <dtoSubmissionValueField> > sections = ServiceCall.GetSubmissionFields(call, subRev.Type.Id, subRev.Id, View.IdRevision);
            Dictionary <long, FieldError> fieldsError = ServiceCall.GetSubmissionFieldErrors(subRev.Id, View.IdRevision);

            if (sections != null && sections.Count > 0 && fieldsError != null)
            {
                sections.ForEach(s => s.Fields.ForEach(f => f.SetError(fieldsError)));
            }
            View.LoadSections(sections);
            View.InitializeExportControl(
                (subRev.Owner != null && UserContext.CurrentUserID == subRev.Owner.Id),
                (subRev.Owner != null) ? subRev.Owner.Id : 0,
                call.Id,
                subRev.Id,
                View.IdRevision,
                View.IdCallModule,
                View.IdCallCommunity,
                View.CallType,
                subRev.Type.Id,
                subRev.Status == SubmissionStatus.draft);
        }
Пример #10
0
        private void LoadFiles(dtoRevision revision, long idSubmission, List <lm.Comol.Core.DomainModel.Helpers.Export.ExportFileType> loadTypes)
        {
            List <ExportFileType> types = null;

            if (loadTypes != null && loadTypes.Count > 0)
            {
                types = loadTypes;
                if (loadTypes.Contains(ExportFileType.zip) && !ServiceCall.SubmissionWithUploadedFile(idSubmission, revision.Id))
                {
                    types.Add(ExportFileType.zip);
                }
            }
            else
            {
                types = new List <ExportFileType>();
                if (ServiceCall.SubmissionWithUploadedFile(idSubmission, revision.Id))
                {
                    types.Add(ExportFileType.zip);
                }
                //types.Add(ExportFileType.rtf);
                types.Add(ExportFileType.pdf);
            }

            View.LoadFiles(revision.SubmissionFiles(), types);
        }
        private ServiceRequest CreateServiceRequest(ServiceCall request)
        {
            ServiceRequest serviceRequest = new ServiceRequest();

            #region authentications

            ServiceRequest.Authentications authentications = new ServiceRequest.Authentications();
            authentications.Key           = StaticStringVariables.Key;
            authentications.Source        = StaticStringVariables.Source;
            serviceRequest.Authentication = authentications;

            #endregion authentications

            #region objects

            ServiceRequest.Objects objects = new ServiceRequest.Objects();
            objects.EndorsNo      = request.EndorsNo;
            objects.ProductNo     = request.ProductNo;
            objects.ProposalNo    = Convert.ToInt64(request.ProposalNo);
            objects.RenewalNo     = request.RenewalNo;
            serviceRequest.Object = objects;

            #endregion objects

            return(serviceRequest);
        }
Пример #12
0
        public IEnumerable <Viewing_Service_Calls> GetServiceCallsBetweenDate(ServiceCall serviceCall)
        {
            using (var ctx = new SystemCompanyEntities())
            {
                // var query3 =

                return(ctx.Viewing_Service_Calls.Where(
                           t => t.dateOpenCalls > serviceCall.dateOpenCalls && t.dateOpenCalls < DateTime.Now).ToList());
                //  return  ctx.ServiceCalls.Include("Company").Include("Priority").Where(
                //     t => t.dateOpenCalls > serviceCall.dateOpenCalls && t.dateOpenCalls < DateTime.Now).ToList();

                //.Select
                //        (item => new
                //        {
                //            companyName = item.Company.companyName,
                //            dateOpenCalls = item.dateOpenCalls.Value,
                //            discriptions = item.discriptions,
                //            TypePriority = item.Priority.TypePriority,
                //            idCallsServices = item.idCallsServices,
                //            idCompany = item.idCompany,
                //            idPriority = item.idPriority
                //        }
                //        ).ToList();
                //  var query = mDB.ServiceCalls.Where(t => t.dateOpenCalls > serviceCall.dateOpenCalls && t.dateOpenCalls < DateTime.Now).ToList();
                //return query3.Select(item => new ServiceCall
                //{
                //    idCompany = item.idCompany,
                //    dateOpenCalls = item.dateOpenCalls,
                //    discriptions = item.discriptions,
                //    idCallsServices = item.idCallsServices,
                //    idPriority = item.idPriority
                //}).ToList();
            }
        }
Пример #13
0
        public void HelloWorldTest_CyclesThroughWholeProgram()
        {
            new HeavyTestRunner(_logger).RunServerAndBrowserAndExecute(
                MagicsForTests.ClientSideFlows.HelloWorld, (assertX, server, browser) => {
                assertX.DialogIsVisibleInBrowser("Hello there");

                browser
                .FindElementByXPath(XPathBuilder.Dialog("Hello there").InBody("/input[@type='text']"))
                .SendKeys(someName);

                assertX.NoServiceCallsMadeOnServer();

                browser
                .FindElementByXPath(XPathBuilder.Dialog("Hello there").HasEnabledButtonAction("OK"))
                .Click();

                assertX.DialogIsVisibleInBrowser("Server reply");

                assertX.InvocationsMadeOnServerAre(x => x.ResType == ResourceType.RegularPostService, () => {
                    var onBefore   = FilterInvocation.OfMethod((IHelloWorldService x) => x.SayHello(someName));
                    var actualCall = ServiceCall.OfMethod((IHelloWorldService x) => x.SayHello(someName));
                    var onAfter    = FilterInvocation.ExpectOnConnectionAfterFor(onBefore);

                    return(new CsChoice <ServiceCall, FilterInvocation>[] { onBefore, actualCall, onAfter });
                });

                assertX.MatchesXPathInBrowser(
                    XPathBuilder
                    .Dialog("Server reply")
                    .HasReadOnlyLabel($"Hello {someName}. How are you?"));
            });
        }
Пример #14
0
        public void ShouldStoreParameterTypeOfMethod()
        {
            var @class      = new Class(typeof(TestServiceForServiceCallTest));
            var serviceCall = new ServiceCall(new TestServiceForServiceCallTest(), @class.GetMethod("Method").MethodInfo);

            Assert.AreEqual("System.String", serviceCall.ParameterTypes[0]);
        }
Пример #15
0
        public async Task NonRecoverableHttpError()
        {
            SetChannelWithTimeSpan(TimeSpan.Zero);

            // Enqueue some log and and do not complete it
            var call = new ServiceCall();

            _mockIngestion
            .Setup(ingestion => ingestion.Call(
                       It.IsAny <string>(),
                       It.IsAny <Guid>(),
                       It.IsAny <IList <Log> >()))
            .Returns((string appSecret, Guid installId, IList <Log> logs) => call);
            await _channel.EnqueueAsync(new TestLog());

            VerifySendingLog(1);

            // Next one will fail
            SetupIngestionCallFail(new NonRecoverableIngestionException());
            await _channel.EnqueueAsync(new TestLog());

            VerifySendingLog(1);

            // Wait up to 20 seconds for suspend to finish
            VerifyChannelDisable(TimeSpan.FromSeconds(10));
            _mockIngestion.Verify(ingestion => ingestion.Close(), Times.Never);
            VerifyFailedToSendLog(2);

            // The first call is canceled
            await Assert.ThrowsExceptionAsync <TaskCanceledException>(() => call.ToTask());
        }
        /// <summary>
        ///     This method is responsible for the try catch logic of all calls to the web api.
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="call"></param>
        /// <param name="methodName"></param>
        /// <returns></returns>
        public virtual TResult Invoke <TResult>(ServiceCall <TResult> call, string methodName)
        {
            try
            {
                var watch = Stopwatch.StartNew();

                var result = call();

                watch.Stop();
                Logger.InfoFormat("RestApi.{0} Call Success - ElaspedTime: {1} ms", methodName,
                                  watch.ElapsedMilliseconds);

                return(result);
            }
            catch (NotSupportedException nse)
            {
                Logger.FatalFormat("RestApi.{0} Call Failed - Exception: {1}", methodName, nse);
                throw new ApplicationException(
                          string.Format(Errors.WS_Unavailable, HttpUtility.HtmlEncode(methodName)),
                          nse);
            }
            catch (ApplicationException ae)
            {
                Logger.FatalFormat("RestApi.{0} Call Failed - Exception: {1}", methodName, ae);
                throw;
            }
            catch (Exception e)
            {
                Logger.FatalFormat("RestApi.{0} Call Failed - Exception: {1}", methodName, e);
                throw new ApplicationException(
                          string.Format(Errors.WS_Unavailable, HttpUtility.HtmlEncode(methodName)), e);
            }
        }
        private void LoadItems(long idCall, EvaluationType type, Int32 idCommunity, dtoEvaluationsFilters filters, int pageIndex, int pageSize)
        {
            if (type == EvaluationType.Dss)
            {
                InitializeDssInfo(idCall);
            }
            else
            {
                View.HideDssWarning();
            }

            bool isAdvance = ServiceCall.CallIsAdvanced(idCall);

            List <dtoEvaluationSummaryItem> items =
                isAdvance ?
                ServiceCall.GetEvaluationsList(idCall, View.IdCallAdvCommission, type, filters, View.AnonymousDisplayname, View.UnknownDisplayname) :
                Service.GetEvaluationsList(idCall, type, filters, View.AnonymousDisplayname, View.UnknownDisplayname, true);



            PagerBase pager = new PagerBase();

            pager.PageSize = pageSize;

            if (pageSize == 0)
            {
                pageSize = 50;
            }
            pager.Count     = (int)items.Count - 1;
            pager.PageIndex = pageIndex;// Me.View.CurrentPageIndex
            View.Pager      = pager;

            View.CurrentOrderBy   = filters.OrderBy;
            View.CurrentFilterBy  = filters.Status;
            View.CurrentAscending = filters.Ascending;
            View.PageSize         = pageSize;

            View.AllowExportCurrent = (items != null && items.Any() && items.Skip(pageIndex * pageSize).Take(pageSize).Any());
            if (pager.Count < 0)
            {
                View.DisplayNoEvaluationsFound();
            }
            else
            {
                List <long> committees = Service.GetIdCommittees(idCall);
                if (committees.Count == 1)
                {
                    View.DisplayLinkToSingleCommittee(committees.FirstOrDefault());
                }
                View.LoadEvaluations(items.Skip(pageIndex * pageSize).Take(pageSize).ToList(), committees.Count);
            }
            View.SendUserAction(View.IdCallCommunity, View.IdCallModule, ModuleCallForPaper.ActionType.ViewEvaluationsSummary);


            if (isAdvance)
            {
                bool cancloseAdvance = ServiceCall.CommissionCanClose(View.IdCallAdvCommission);
                View.ShowCloseCommission(cancloseAdvance);
            }
        }
Пример #18
0
        private void SetSkinDetails(Int32 idUser, long idCall)
        {
            Language   language = CurrentManager.GetDefaultLanguage();
            litePerson person   = GetCurrentUser(ref idUser);

            View.IdUserSubmitter = idUser;
            if (language != null)
            {
                View.DefaultLanguageCode = language.Code;
            }
            if (idUser == UserContext.CurrentUserID || person == null || UserContext.CurrentUserID == 0)
            {
                View.UserLanguageCode = UserContext.Language.Code;
            }
            else if (person != null)
            {
                language = CurrentManager.GetLanguage(person.LanguageID);
                if (language != null)
                {
                    View.UserLanguageCode = language.Code;
                }
                else
                {
                    View.UserLanguageCode = UserContext.Language.Code;
                }
            }
            else
            {
                View.UserLanguageCode = UserContext.Language.Code;
            }

            View.SkinDetails = ServiceCall.GetUserExternalContext(idCall, GetCurrentUser(ref idUser));
        }
Пример #19
0
        public void ShouldStoreParameterTypeOfMethod()
        {
            var type        = typeof(TestServiceForServiceCallTest);
            var serviceCall = new ServiceCall(new TestServiceForServiceCallTest(), type.GetMethod("Method"));

            Assert.That(serviceCall.ParameterTypes[0], Is.EqualTo("System.String"));
        }
Пример #20
0
        public virtual void MoniterServices(List <Service> services, ServiceCall call)
        {
            var service = services.FirstOrDefault(s => s.Id == call.ServiceId);

            if (service != null)
            {
                if (service.Outage && service.StartTime < DateTime.Now && service.EndTime > DateTime.Now)
                {
                    _logger.LogInformation("Service outage for service {service} ", service.Id);
                }
                else
                {
                    try
                    {
                        var client = new TcpClient(service.Host, service.Port);

                        NetworkStream stream = client.GetStream();

                        byte[] bytes     = new byte[1024];
                        int    bytesRead = stream.Read(bytes, 0, bytes.Length);

                        var response = Encoding.ASCII.GetString(bytes, 0, bytesRead);
                        _logger.LogInformation("Response from service {service} to caller {caller} - {response}", service.Id, call.Id, response);
                        client.Close();
                        //TODO:  send notification to the caller using INotification methods
                    }
                    catch (Exception ex)
                    {
                        _logger.LogInformation("Service error {error}", ex.Message);
                    }
                }
            }
        }
Пример #21
0
    public int InsertServiceCallExistingProject(ServiceCall sc, int CustomerID, int ProjectID)
    {
        DBservices dbs         = new DBservices();
        int        RowAffected = dbs.InsertServiceCallExistingProject(sc, CustomerID, ProjectID);

        return(RowAffected);
    }
Пример #22
0
        /// <summary>
        /// 生成服务调用声明
        /// <remarks>本地可无需存在目标服务的代理,不支持多态</remarks>
        /// </summary>
        /// <param name="serviceTypeName">目标服务类型全名</param>
        /// <param name="methodName">目标方法名</param>
        /// <param name="arguments">参数组</param>
        /// <returns></returns>
        public ServiceCall GenerateServiceCall(string serviceTypeName, string methodName, IDictionary <string, object> arguments)
        {
            ServiceInfo service = this.ServiceTable.Services.FirstOrDefault(o =>
                                                                            o.Name.Equals(serviceTypeName, StringComparison.InvariantCultureIgnoreCase));

            if (service == null)
            {
                throw new ServiceException(string.Format(
                                               "当前服务节点不存在类型为{0}的服务配置信息"
                                               , serviceTypeName));
            }

            var call = new ServiceCall()
            {
                TargetMethod = methodName, Identity = this.Configuration.ID
            };

            if (arguments != null)
            {
                var args = new List <ServiceCallArgument>();
                arguments.ToList().ForEach(o => args.Add(new ServiceCallArgument(o.Key, this._serializer.Serialize(o.Value))));
                call.ArgumentCollection = args.ToArray();
            }
            //根据负载算法选取适合的服务配置
            call.Target = this.Resolve <ILoadBalancingHelper>().GetServiceConfig(service
                                                                                 , call.TargetMethod
                                                                                 , call.ArgumentCollection);
            return(call);
        }
Пример #23
0
        public void InitView()
        {
            Boolean isAnonymousUser = UserContext.isAnonymous;
            long    idCall          = View.PreloadIdCall;
            Int32   idUser          = UserContext.CurrentUserID;

            lm.Comol.Modules.CallForPapers.Domain.CallForPaperType type = ServiceCall.GetCallType(idCall);
            int idModule = (type == CallForPaperType.CallForBids) ? ServiceCall.ServiceModuleID() : ServiceRequest.ServiceModuleID();

            dtoCall call = (type == CallForPaperType.CallForBids) ? ServiceCall.GetDtoCall(idCall) : null;

            if (call != null)
            {
                View.SetContainerName(call.Name, call.EndEvaluationOn);
            }


            if (call.AdvacedEvaluation)
            {
                View.RedirectToAdvance(call.Id);
            }


            int idCommunity = GetCurrentCommunity(call);

            View.IdCall          = idCall;
            View.IdCallModule    = idModule;
            View.IdCallCommunity = idCommunity;
            View.CallType        = type;

            ModuleCallForPaper module     = ServiceCall.CallForPaperServicePermission(idUser, idCommunity);
            Boolean            allowAdmin = ((module.ManageCallForPapers || module.Administration || ((module.CreateCallForPaper || module.EditCallForPaper) && call.Owner.Id == idUser)));

            View.SetActionUrl((allowAdmin) ? CallStandardAction.Manage : CallStandardAction.List, RootObject.ViewCalls(idCall, type, ((allowAdmin) ? CallStandardAction.Manage : CallStandardAction.List), idCommunity, View.PreloadView));

            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout(RootObject.CommitteesSummary(idCall, idCommunity, View.PreloadView, View.PreloadIdSubmitterType, View.PreloadFilterBy, View.PreloadOrderBy, View.PreloadAscending, View.PreloadPageIndex, View.PreloadPageSize, View.GetItemEncoded(View.PreloadSearchForName)));
            }
            else if (call == null)
            {
                View.DisplayUnknownCall(idCommunity, idModule, idCall);
            }
            else if (type == CallForPaperType.RequestForMembership)
            {
                View.DisplayEvaluationUnavailable();
            }
            else if (allowAdmin)
            {
                View.CurrentEvaluationType = call.EvaluationType;
                if (call.EvaluationType == EvaluationType.Dss)
                {
                    View.CallUseFuzzy = Service.CallUseFuzzy(idCall);
                }
                View.AllowExportAll = Service.HasEvaluations(idCall);
                View.DisplayEvaluationInfo(call.EndEvaluationOn);
                InitializeView(idCall, call.EvaluationType, idCommunity, View.PreloadFilters);
            }
        }
        public async Task <IDataResult <ServiceResponse> > SendServiceCall(ServiceCall request)
        {
            try
            {
                var serviceResponse = new ServiceResponse();
                var serviceRequest  = CreateServiceRequest(request);
                var serializeData   = JsonConvert.SerializeObject(serviceRequest);

                //API request atımı
                if (!string.IsNullOrWhiteSpace(serializeData))
                {
                    HttpWebRequest req = HttpWebRequest.Create(StaticStringVariables.APIURL) as HttpWebRequest;
                    req.Method      = StaticStringVariables.Method;
                    req.ContentType = StaticStringVariables.ContentType;

                    using (var streamWriter = new StreamWriter(req.GetRequestStream()))
                    {
                        streamWriter.Write(serializeData);
                        streamWriter.Flush();
                        streamWriter.Close();
                    }

                    //API isteğinden sonra değeri setleyelim
                    var dbData = await _unitOfWork.ServiceRequestResponse.AddAsync(new ServiceRequestResponse
                    {
                        EndorsNo    = request.EndorsNo,
                        ProposalNo  = request.ProposalNo,
                        ProductNo   = request.ProductNo,
                        RenewalNo   = request.RenewalNo,
                        RequestJson = serializeData,
                        Status      = (int)EntityStatus.Active
                    });

                    await _unitOfWork.SaveChangesAsync();

                    //Response Yanıtımızı Manupile Edelim
                    using (HttpWebResponse webResponse = req.GetResponse() as HttpWebResponse)
                    {
                        using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
                        {
                            var results = reader.ReadToEnd();
                            dbData.ResponseJson = results;
                            await _unitOfWork.SaveChangesAsync();

                            serviceResponse = JsonConvert.DeserializeObject <ServiceResponse>(results);
                        }
                    }
                    return(new DataResult <ServiceResponse>(Common.ComplexTypes.ResultStatus.Success, serviceResponse));
                }
                else
                {
                    return(new DataResult <ServiceResponse>(Common.ComplexTypes.ResultStatus.Error, "Servis Çağrımında Hata", null));
                }
            }
            catch (Exception ex)
            {
                return(new DataResult <ServiceResponse>(Common.ComplexTypes.ResultStatus.Error, "Exception", null, new Exception(ex.Message)));
            }
        }
        private void LoadSubmission(dtoBaseForPaper call, dtoSubmissionRevision subRev, int idUser, Boolean allowAdmin)
        {
            if (!allowAdmin)
            {
                switch (call.Type)
                {
                case CallForPaperType.CallForBids:
                    dtoCall dtoC = ServiceCall.GetDtoCall(call.Id);
                    View.LoadCallInfo(dtoC);
                    break;

                case CallForPaperType.RequestForMembership:
                    dtoRequest dtoR = ServiceRequest.GetDtoRequest(call.Id);
                    View.LoadCallInfo(dtoR);
                    break;
                }
                View.LoadAttachments(ServiceCall.GetAvailableCallAttachments(call.Id, subRev.Type.Id));
            }
            View.IdSubmitterType = (subRev == null) ? 0 : subRev.Type.Id;
            String owner       = "";
            String submittedBy = "";

            if (subRev.Owner == null || subRev.Owner.TypeID == (int)UserTypeStandard.Guest)
            {
                owner = View.AnonymousOwnerName;
            }
            else
            {
                owner = subRev.Owner.SurnameAndName;
            }

            if (subRev.SubmittedBy == null || subRev.SubmittedBy.TypeID == (int)UserTypeStandard.Guest)
            {
                submittedBy = View.AnonymousOwnerName;
            }
            else
            {
                submittedBy = subRev.SubmittedBy.SurnameAndName;
            }

            if (subRev.Deleted != BaseStatusDeleted.None)
            {
                View.LoadSubmissionInfo(subRev.Type.Name, owner, SubmissionStatus.deleted);
            }
            else if (!subRev.SubmittedOn.HasValue)
            {
                View.LoadSubmissionInfo(subRev.Type.Name, owner, subRev.Status);
            }
            else if (subRev.IdPerson == subRev.IdSubmittedBy)
            {
                View.LoadSubmissionInfo(subRev.Type.Name, owner, subRev.Status, subRev.SubmittedOn.Value);
            }
            else
            {
                View.LoadSubmissionInfo(subRev.Type.Name, owner, subRev.Status, subRev.SubmittedOn.Value, submittedBy);
            }

            LoadSections(call, subRev, allowAdmin);
        }
Пример #26
0
        /// <summary>
        /// 执行服务调用
        /// <remarks>自动根据服务位置进行调用</remarks>
        /// </summary>
        /// <param name="call">调用声明</param>
        /// <param name="returnType">期望的返回值类型</param>
        /// <returns></returns>
        /// <exception cref="ServiceException"></exception>
        public object Invoke(ServiceCall call, Type returnType)
        {
            Type type;

            return(this.IsLocal(call.Target.HostUri)
                ? this.InvokeLocal(call, out type)
                : this._serializer.Deserialize(returnType, this.InvokeRemote(call)));
        }
Пример #27
0
 public AssignedHandler(ServiceCall objCall, IRepository repository, IUnitOfWork unitOfWork, IFeatureModule featureModule, IUserStore <AppUser> userStore, AppUser loginUser, ILogger <ServiceCallManager> logger)
 {
     _call          = objCall;
     _repository    = repository;
     _unitOfWork    = unitOfWork;
     _featureModule = featureModule;
     _logger        = logger;
 }
 public void Update(ServiceCall entity)
 {
     using (var context = _contextCreator())
     {
         _repository = new ConnectedRepository <ServiceCall>(context);
         _repository.Update(entity);
     }
 }
Пример #29
0
        /// <summary>
        /// 执行服务调用,返回序列化结果
        /// </summary>
        /// <param name="call">调用声明</param>
        /// <returns></returns>
        public string InvokeSerialized(ServiceCall call)
        {
            Type returnType;

            return(this.IsLocal(call.Target.HostUri)
                ? this._serializer.Serialize(this.InvokeLocal(call, out returnType), returnType)
                : this.InvokeRemote(call));
        }
 public async Task UpdateAsync(ServiceCall entity)
 {
     using (var context = _contextCreator())
     {
         _repository = new ConnectedRepository <ServiceCall>(context);
         await _repository.UpdateAsync(entity);
     }
 }
Пример #31
0
        public void InvokingAExistingServiceShouldReturnStatus()
        {
            var callInPreviousRun = new ServiceCall(new TestService(), @class.GetMethod("Method").MethodInfo);
            executionHistory.Add(callInPreviousRun);
            callInPreviousRun.ReturnValue = string.Empty;

            LastServiceCallStatus callStatus = serviceExecution.Invoking(new TestService(), @class.GetMethod("Method").MethodInfo);
            Assert.AreEqual(1, executionHistory.ServiceCalls.Count);
            Assert.AreNotEqual(null, callStatus);
            Assert.AreNotEqual(null, callStatus.ReturnValue);
        }
Пример #32
0
 public void Handle(ServiceCall call, Type returnType, Action<object> callback)
 {
     if (this._bus == null)
         throw new InvalidOperationException("未初始化NServiceBus");
     if (callback != null)
         this._bus
             .Send<RequestMessage>(m => m.Request = call)
             .Register<ErrorCode>(o => callback(this._serializer.Deserialize(returnType, this.GetResult())));
     else
         this._bus.Send<RequestMessage>(m => m.Request = call);
 }
Пример #33
0
        public void InvokingAExistingServiceShouldReturnStatus()
        {
            var callInPreviousRun = new ServiceCall(new TestService(), type.GetMethod("Method"));
            executionHistory.Add(callInPreviousRun);
            callInPreviousRun.ReturnValue = string.Empty;

            var callStatus = serviceExecution.Invoking(new TestService(), type.GetMethod("Method"));
            Assert.That(executionHistory.ServiceCalls, Has.Count.EqualTo(1));
            Assert.That(callStatus, Is.Not.Null);
            Assert.That(callStatus.ReturnValue, Is.Not.Null);
        }
 public override void Post(SendOrPostCallback d, object state)
 {
     ComPlusActivityTrace.Trace(TraceEventType.Verbose, 0x50015, "TraceCodeComIntegrationEnteringActivity");
     ServiceCall pIServiceCall = new ServiceCall(d, state);
     if (this.postSynchronous)
     {
         this.activity.SynchronousCall(pIServiceCall);
     }
     else
     {
         this.activity.AsynchronousCall(pIServiceCall);
     }
     ComPlusActivityTrace.Trace(TraceEventType.Verbose, 0x50017, "TraceCodeComIntegrationLeftActivity");
 }
Пример #35
0
 public void NotifyWithRedirect(Environment env, string message, string buttonText,
     int redirectSeconds, string redirectUrl, ServiceCall followUp)
 {
     env.Data = new List<object>();
     env.Data.Add(new Notification(message, buttonText));
     env.State = State.Notification;
     SessionInfo sinfo = env.Session;
     if (sinfo.Sid != null && m_Sessions.Contains(sinfo.Sid))
     {
         sinfo.Notify.FollowUp = followUp;
         sinfo.Notify.RedirectUrl = redirectUrl; // used in WifiScriptFace.GetRefresh()
         sinfo.Notify.RedirectDelay = redirectSeconds;
         m_Sessions.Update(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
         env.Session = sinfo;
     }
 }
Пример #36
0
        private static void AssignAddress(ServiceCall serviceCall)
        {
            if(serviceCall != null && String.IsNullOrEmpty(serviceCall.Address))
            {
                serviceCall.Address = ConfigurationManager.AppSettings["ServiceCloud.EndpointAddress." + serviceCall.Name];

                if(String.IsNullOrEmpty(serviceCall.Address))
                {
                    throw new Exception("Cannot find EndpointAddress for " + serviceCall.Name);
                }

                if (serviceCall.Services != null && serviceCall.Services.Length > 0)
                {
                    serviceCall.Services.ToList().ForEach(AssignAddress);
                }
            }
        }
Пример #37
0
 /// <summary>
 /// 执行服务调用
 /// </summary>
 /// <returns>返回结果的JSON</returns>
 public virtual string Invoke(ServiceCall call)
 {
     try
     {
         return this._endpoint.InvokeSerialized(call);
     }
     catch (Exception e)
     {
         if (e is ServiceException)
         {
             this._log.Warn("服务调用发生异常", e);
             throw e;
         }
         this._log.Error("服务调用发生异常", e);
         throw new ServiceException(e.Message, e);
     }
 }
 public void Notify(IEnvironment env, string message, string buttonText, ServiceCall followUp)
 {
     NotifyWithRedirect(env, message, buttonText, -1, string.Empty, followUp);
 }
 public void NotifyOK(IEnvironment env, string message, ServiceCall followUp)
 {
     Notify(env, message, _("OK", (Environment)env), followUp);
 }
 /// <summary>
 /// 服务地址路由,可重写此方法以完成服务路由
 /// </summary>
 /// <param name="service">服务信息</param>
 /// <param name="call">调用信息</param>
 /// <returns></returns>
 protected virtual ServiceConfig Routing(ServiceInfo service, ServiceCall call)
 {
     return this._loadBalancingHelper.GetServiceConfig(service, call.TargetMethod, call.ArgumentCollection);
 }
Пример #41
0
 public void ShouldStoreParameterTypeOfMethod()
 {
     var @class = new Class(typeof(TestServiceForServiceCallTest));
     var serviceCall = new ServiceCall(new TestServiceForServiceCallTest(), @class.GetMethod("Method").MethodInfo);
     Assert.AreEqual("System.String", serviceCall.ParameterTypes[0]);
 }
Пример #42
0
 public void Handle(ServiceCall call)
 {
     this.Handle(call, typeof(object), null);
 }
Пример #43
0
 public virtual void Add(ServiceCall serviceCall)
 {
     ServiceCalls.Add(serviceCall);
 }
Пример #44
0
 public override void Add(ServiceCall serviceCall)
 {
 }
Пример #45
0
 /// <summary>
 /// 异步执行服务调用
 /// </summary>
 /// <param name="call"></param>
 public virtual void InvokeAsync(ServiceCall call)
 {
     try
     {
         this._endpoint.InvokeAsync(call);
     }
     catch (Exception e)
     {
         if (e is ServiceException) throw e;
         throw new ServiceException(e.Message, e);
     }
 }
Пример #46
0
 public string Invoke(ServiceCall call)
 {
     return this.GetFacade(call.Target.HostUri).Invoke(call);
 }
Пример #47
0
 public override ServiceCalls FindCalls(ServiceCall match)
 {
     return new ServiceCalls();
 }
Пример #48
0
 public virtual ServiceCalls FindCalls(ServiceCall match)
 {
     return ServiceCalls.Matching(match);
 }
Пример #49
0
 public void SendAnAsyncCall(Uri uri, ServiceCall call)
 {
     this.GetFacade(uri).InvokeAsync(call);
 }
Пример #50
0
 public void ShouldStoreParameterTypeOfMethod()
 {
     var type = typeof(TestServiceForServiceCallTest);
     var serviceCall = new ServiceCall(new TestServiceForServiceCallTest(), type.GetMethod("Method"));
     Assert.That(serviceCall.ParameterTypes[0], Is.EqualTo("System.String"));
 }
 private ServiceCall ParseCall(ServiceInfo service, IInvocation invocation)
 {
     var call = new ServiceCall()
     {
         TargetMethod = invocation.Method.Name,
         Identity = this._endpoint.Configuration.ID
     };
     //填充参数
     var i = -1;
     var parameters = invocation.Method.GetParameters();
     var args = new List<ServiceCallArgument>();
     invocation.Arguments.ToList().ForEach(o =>
     {
         i++;
         args.Add(new ServiceCallArgument(parameters[i].Name
             , this._serializer.Serialize(o, parameters[i].ParameterType)));//多态序列化
     });
     call.ArgumentCollection = args.ToArray();
     //根据负载算法选取适合的服务配置
     call.Target = this.Routing(service, call);
     return call;
 }