Ejemplo n.º 1
0
 protected internal override void FillToContext(string baseUrl, RequestBase context)
 {
     if (_contextAction != null)
     {
         _contextAction(this.ContextData, baseUrl, context);
     }
 }
Ejemplo n.º 2
0
 protected internal override void FillToWebRequest(WebRequest request, RequestBase context)
 {
     if (_requestAction != null)
     {
         _requestAction(this.ContextData, request, context);
     }
 }
Ejemplo n.º 3
0
		/// <summary>
		///   Deletes collection from account.
		/// </summary>
		/// <param name="collectionId"> id of collection to remove </param>
		/// <returns> </returns>
		public bool Delete(int collectionId)
		{
			var reqObj = new RequestBase<CollectionRequest>
			             {
			             	Method = "collection.delete",
			             	Parameters = new CollectionRequest
			             	             {
			             	             	CollectionID = collectionId
			             	             }
			             };

			return CallSaploApi<SuccessResponse>(reqObj).Success;
		}
Ejemplo n.º 4
0
		/// <summary>
		///   Get specfic Collection.
		/// </summary>
		/// <param name="collectionId"> ID of collection to fetch </param>
		public Collection Get(int collectionId)
		{
			var reqObj = new RequestBase<CollectionRequest>
			             {
			             	Method = "collection.get",
			             	Parameters = new CollectionRequest
			             	             {
			             	             	CollectionID = collectionId
			             	             }
			             };

			return CallSaploApi<Collection>(reqObj);
		}
Ejemplo n.º 5
0
		/// <summary>
		///   Permanently deletes an group.
		/// </summary>
		/// <param name="groupId"> id of group to delete </param>
		/// <returns> </returns>
		public bool Delete(int groupId)
		{
			var reqObj = new RequestBase<GroupRequest>
			             {
			             	Method = "group.create",
			             	Parameters = new GroupRequest
			             	             {
			             	             	GroupID = groupId
			             	             }
			             };

			return CallSaploApi<SuccessResponse>(reqObj).Success;
		}
Ejemplo n.º 6
0
        public ResponseBase ProcessMessage(RequestBase request)
        {
            // TODO: very bad temporary code!
            if (request.GetType().IsAssignableFrom(typeof (EchoRequest)))
            {
                return _buildAgent.GenerateEcho(request as EchoRequest);
            }
            else if (request.GetType().IsAssignableFrom(typeof (BuildAgentPropertiesRequest)))
            {
                return _buildAgent.GetBuildAgentProperties();
            }

            return null;
        }
Ejemplo n.º 7
0
		/// <summary>
		/// Create a new collection.
		/// </summary>
		/// <param name="name">name of the collection</param>
		/// <param name="language">language to use in the collection, (only swedish and english are supported)</param>
		/// <param name="description">short text describing the content of the collection</param>
		/// <returns></returns>
		public Collection Create(string name, string language, string description)
		{
			var reqObj = new RequestBase<CollectionCreateRequest>
			             {
			             	Method = "collection.create",
			             	Parameters = new CollectionCreateRequest
			             	             {
			             	             	Name = name,
			             	             	Language = language,
			             	             	Description = description
			             	             }
			             };

			return CallSaploApi<Collection>(reqObj);
		}
Ejemplo n.º 8
0
		/// <summary>
		///   Adds an text to an group.
		/// </summary>
		/// <param name="groupId"> id of target group </param>
		/// <param name="collectionId"> id of collection containing text </param>
		/// <param name="textId"> id of text to add </param>
		/// <returns> </returns>
		public bool AddText(int groupId, int collectionId, int textId)
		{
			var reqObj = new RequestBase<GroupTextCreateRequest>
			             {
			             	Method = "group.addTexts",
			             	Parameters = new GroupTextCreateRequest
			             	             {
			             	             	CollectionID = collectionId,
			             	             	GroupID = groupId,
			             	             	TextID = textId
			             	             }
			             };

			return CallSaploApi<SuccessResponse>(reqObj).Success;
		}
Ejemplo n.º 9
0
		/// <summary>
		///   Creates a new group.
		/// </summary>
		/// <param name="name"> name for the group </param>
		/// <param name="language"> language for this group (swedish and english are the only languages supported) </param>
		/// <param name="description"> a short description of this group </param>
		/// <returns> </returns>
		public Group Create(string name, string language, string description)
		{
			var reqObj = new RequestBase<GroupCreateRequest>
			             {
			             	Method = "group.create",
			             	Parameters = new GroupCreateRequest
			             	             {
			             	             	Name = name,
			             	             	Description = description,
			             	             	Language = language
			             	             }
			             };

			return CallSaploApi<Group>(reqObj);
		}
Ejemplo n.º 10
0
		/// <summary>
		///   Add tag to text entity.
		/// </summary>
		/// <param name="tag"> the tag string </param>
		/// <param name="collectionId"> id of collection </param>
		/// <param name="textId"> id of text entity </param>
		/// <param name="category"> category for tag </param>
		/// <param name="relevance"> tags relevance, a number between 0 and 1 </param>
		/// <returns> </returns>
		public Tag AddTag(string tag, int collectionId, int textId, TagCategoryType? category = null, decimal? relevance = null)
		{
			var reqObj = new RequestBase<AddTagRequest>
			             {
			             	Method = "text.addTag",
			             	Parameters = new AddTagRequest
			             	             {
			             	             	Category = category,
			             	             	CollectionID = collectionId,
			             	             	ExternalTextID = null,
			             	             	Relevance = relevance,
			             	             	Tag = tag,
			             	             	TextID = textId
			             	             }
			             };

			return CallSaploApi<Tag>(reqObj);
		}
		public SignalREventRaisedFromClientEventArgs(string eventName, RequestBase request, IConnectionContext context)
		{
			Contract.Requires(eventName != null);
			Contract.Requires(request != null);
			Contract.Requires(context != null);

			if (eventName == null) throw new ArgumentNullException("eventName");
			if (request == null) throw new ArgumentNullException("request");
			if (context == null) throw new ArgumentNullException("context");

			Contract.Ensures(this.EventName != null);
			Contract.Ensures(this.Request != null);
			Contract.Ensures(this.Context != null);

			this.EventName = eventName;
			this.Request = request;
			this.Context = context;
		}
Ejemplo n.º 12
0
		/// <summary>
		///   Creates a new text entity.
		/// </summary>
		/// <param name="collectionId"> id of collection to put the entity </param>
		/// <param name="body"> the content of entity </param>
		/// <param name="headline"> headline for entity </param>
		/// <param name="url"> url to original "article" </param>
		/// <param name="externalId"> custom external id </param>
		/// <param name="publishdate"> publishdate of original "article" </param>
		/// <returns> </returns>
		public Text Create(int collectionId, string body, string headline = null, string url = null, string externalId = null, DateTime? publishdate = null)
		{
			var reqObj = new RequestBase<TextCreateRequest>
			             {
			             	Method = "text.create",
			             	Parameters = new TextCreateRequest
			             	             {
			             	             	CollectionID = collectionId,
			             	             	Body = body,
			             	             	Headline = headline,
			             	             	ExternalTextID = externalId,
			             	             	PublishDate = publishdate,
			             	             	Url = url
			             	             }
			             };

			return CallSaploApi<Text>(reqObj);
		}
Ejemplo n.º 13
0
 private ResponseBase SendMessage(RequestBase request)
 {
     ResponseBase response;
     try
     {
         response = _innerChannel.Client.ProcessMessage(request);
     }
     catch (EndpointNotFoundException)
     {
         response = new ResponseBase();
         response.AddErrorMessage("Can't connect to buildagent.");
     }
     catch (Exception ex)
     {
         response = new ResponseBase();
         response.AddErrorMessage(ex.Message);
     }
     return response;
 }
Ejemplo n.º 14
0
		/// <summary>
		///   Returns account information for authenticated account.
		/// </summary>
		/// <returns> </returns>
		public Account GetAccount()
		{
			var reqObj = new RequestBase<object>("account.get", new object());

			string result = QuerySaplo(Serialize(reqObj), AuthenticateIfNeeded());
			var responseObj = Deserialize<Account>(result);
			return ValidateResult(responseObj) ? responseObj.Result : null;
		}
Ejemplo n.º 15
0
 public ResponseData(RequestBase request, WebException exception)
 {
     this.Request = request;
     HasResult    = false;
     ReadExceptionResponse(exception);
 }
Ejemplo n.º 16
0
        public ResponseBase CheckImageCache(RequestBase request)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            string downloadLocation = string.Empty;

            // what kind of request is it?
            switch (request)
            {
            case ChampionRequest c:     // check if each unique string isnt null
                if (string.IsNullOrEmpty(c.ChampionName))
                {
                    throw new ArgumentNullException(nameof(request));
                }

                downloadLocation = Path.Combine(CachePath, "champs", $"{c.ChampionName}.png");
                break;

            case ItemRequest i:
                if (string.IsNullOrEmpty(i.ItemID))
                {
                    throw new ArgumentNullException(nameof(request));
                }

                downloadLocation = Path.Combine(CachePath, "items", $"{i.ItemID}.png");
                break;

            case MapRequest m:
                if (string.IsNullOrEmpty(m.MapID))
                {
                    throw new ArgumentNullException(nameof(request));
                }

                downloadLocation = Path.Combine(CachePath, "maps", $"{m.MapID}.png");
                break;

            case RuneRequest r:
                if (string.IsNullOrEmpty(r.TargetPath))
                {
                    throw new ArgumentNullException(nameof(request));
                }

                downloadLocation = Path.Combine(CachePath, "runes", $"{r.RuneKey}.png");
                break;

            default:
                throw new NotSupportedException($"unsupported request type: {request.GetType()}");
            }

            // Create the response item
            ResponseBase response = new ResponseBase
            {
                Request = request
            };

            // Does the file already exist in that location?
            if (!File.Exists(downloadLocation))
            {
                // _log.Information($"Cache miss on {downloadLocation}");
                response.IsFaulted = true;
                response.Exception = new FileNotFoundException("Cache miss", downloadLocation);
                return(response);
            }

            response.ResponsePath = downloadLocation;
            response.IsFaulted    = false;
            response.FromCache    = true;
            return(response);
        }
Ejemplo n.º 17
0
 public override StandardRequestBase ToStandard(RequestBase request)
 {
     return(new StandardRequest {
         Id = "RequestId"
     });
 }
Ejemplo n.º 18
0
 private void DebugRawResponse(RequestBase request)
 {
     AddDebug("RAW Result from PAYNL");
     AddDebug(request.RawResponse);
 }
Ejemplo n.º 19
0
		/// <summary>
		///   Updates properies of an group. null value for any property will leave property unmodified.
		/// </summary>
		/// <param name="groupId"> id of group to update properties on </param>
		/// <param name="name"> new name of group </param>
		/// <param name="description"> short decribing text for group </param>
		/// <param name="language"> language for group </param>
		/// <returns> </returns>
		public Group Update(int groupId, string name, string description, string language)
		{
			var reqObj = new RequestBase<GroupModifyRequest>
			             {
			             	Method = "group.update",
			             	Parameters = new GroupModifyRequest
			             	             {
			             	             	GroupID = groupId,
			             	             	Name = name,
			             	             	Description = description,
			             	             	Language = language
			             	             }
			             };

			return CallSaploApi<Group>(reqObj);
		}
Ejemplo n.º 20
0
		/// <summary>
		///   Lists all texts within an group.
		/// </summary>
		/// <param name="groupId"> id of group </param>
		/// <returns> </returns>
		public GroupText[] ListTexts(int groupId)
		{
			var reqObj = new RequestBase<GroupRequest>
			             {
			             	Method = "group.listTexts",
			             	Parameters = new GroupRequest
			             	             {
			             	             	GroupID = groupId
			             	             }
			             };

			return CallSaploApi<GroupTextsResponse>(reqObj).Texts;
		}
Ejemplo n.º 21
0
        internal bool SendOTPCustomer(RequestBase request)
        {
            var response = _dbHelper.SendOTP(request.UserId, request.MemberId);

            return(response);
        }
Ejemplo n.º 22
0
        internal bool SendOTP(RequestBase request)
        {
            var response = _dbHelper.SendOTP(request.UserId);

            return(response);
        }
Ejemplo n.º 23
0
 internal bool ValidateRequest(RequestBase request)
 {
     return(true);
     //return _dbHelper.ValidateRequest(request);
 }
Ejemplo n.º 24
0
 public NotificationsDto GetNotifications(RequestBase request)
 {
     return(_dbHelper.GetNotifications(Convert.ToInt64(request.MemberId)));
 }
Ejemplo n.º 25
0
 public MemberModel GetAccountDetails(RequestBase request)
 {
     return(_dbHelper.GetMemberDetailsById(Convert.ToInt64(request.MemberId)));
 }
Ejemplo n.º 26
0
        void ReportToTreeView(ESPDataBase instance, TreeNodeCollection targetNodes, LogWriter writer, bool appendRoot)
        {
            targetNodes.Clear();

            Type   instanceType     = instance.GetType();
            string targetObjectType = instanceType.FullName;

            TreeNode             rootNode = null;
            TreeNodeInstanceBind nodeBind = null;

            if (appendRoot)
            {
                rootNode            = new TreeNode(targetObjectType);
                rootNode.Name       = targetObjectType;
                rootNode.ImageIndex = rootNode.SelectedImageIndex = (int)DataSpecTester.ImageListIcon.Class;

                nodeBind = new TreeNodeInstanceBind
                {
                    IsFirstNode = true,
                    IsArrayItem = false,
                    IsESPData   = true,
                    NodeItem    = instance,
                    StoreIndex  = 0,
                    NodeType    = instanceType,
                    StoreLength = instance.GetContentLength()
                };
                rootNode.Tag = nodeBind;
                targetNodes.Add(rootNode);
            }

            ObjectTransferOrderAttribute[] configs = new ObjectTransferOrderAttribute[0];
            PropertyInfo[] transPropertys          = SpecUtil.GetTransferProperties(instance.GetType(), out configs);

            PropertyInfo lastProperty = null;

            for (int m = 0, n = transPropertys.Length; m < n; m++)
            {
                PropertyInfo pInfo = transPropertys[m];

                #region 依据属性依次绑定

                TreeNode propertyNode = new TreeNode(string.Format("{0} [{1}]", pInfo.Name, pInfo.PropertyType));
                propertyNode.Name       = pInfo.Name;
                propertyNode.ImageIndex = propertyNode.SelectedImageIndex = (int)DataSpecTester.ImageListIcon.Property;

                if (configs[m].Conditional)
                {
                    propertyNode.Text = propertyNode.Text + " *";
                }

                object propertyVal = pInfo.GetValue(instance, null);

                if (appendRoot && rootNode != null)
                {
                    rootNode.Nodes.Add(propertyNode);
                }
                else
                {
                    targetNodes.Add(propertyNode);
                }

                //if (propertyVal == null) continue;

                nodeBind = new TreeNodeInstanceBind
                {
                    IsFirstNode = lastProperty == null,
                    IsArrayItem = false,
                    IsESPData   = false,
                    NodeItem    = propertyVal,
                    NodeType    = pInfo.PropertyType,
                    StoreIndex  = GetTreeNodeStoreIndex(propertyNode),
                    StoreLength = 0  //TODO
                };

                if (pInfo.PropertyType.IsSubclassOf(typeof(ESPDataBase)))
                {
                    ESPDataBase subInstance = (ESPDataBase)propertyVal;
                    nodeBind.IsESPData      = true;
                    propertyNode.ImageIndex = propertyNode.SelectedImageIndex = (int)DataSpecTester.ImageListIcon.Class;
                    propertyNode.Tag        = nodeBind;
                    if (subInstance != null)
                    {
                        //递归子级属性
                        nodeBind.StoreLength = subInstance.GetContentLength();
                        ReportToTreeView(subInstance, propertyNode.Nodes, writer, false);
                    }
                }
                else
                {
                    if (pInfo.PropertyType.IsEnum)
                    {
                        nodeBind.StoreLength = SpecUtil.GetCLRTypeByteLength(pInfo.PropertyType);

                        propertyNode.ImageIndex = propertyNode.SelectedImageIndex = (int)DataSpecTester.ImageListIcon.Enum;
                        propertyNode.Text       = string.Format("{0} [{1}({2})]", pInfo.Name, pInfo.PropertyType, Enum.GetUnderlyingType(pInfo.PropertyType));
                        if (configs[m].Conditional)
                        {
                            propertyNode.Text = propertyNode.Text + " *";
                        }
                        propertyNode.Tag = nodeBind;
                    }
                    else if (pInfo.PropertyType.IsArray)
                    {
                        Type elementType = pInfo.PropertyType.GetElementType();
                        nodeBind.SubType = elementType;
                        propertyNode.Tag = nodeBind;

                        if (elementType.IsSubclassOf(typeof(ESPDataBase)))
                        {
                            #region 封装对象数组
                            ESPDataBase[] subItems = (ESPDataBase[])propertyVal;
                            if (subItems != null)
                            {
                                long totalLength = 0, currentLength = 0;
                                for (int p = 0, q = subItems.Length; p < q; p++)
                                {
                                    currentLength = subItems[p].GetContentLength();
                                    totalLength  += currentLength;

                                    TreeNode subPropertyNode = new TreeNode();
                                    subPropertyNode.Name = subItems[p].GetType().FullName + "[" + p + "]";
                                    subPropertyNode.Text = subItems[p].GetType().FullName + "[" + p + "]";

                                    propertyNode.Nodes.Add(subPropertyNode);

                                    subPropertyNode.ImageIndex = subPropertyNode.SelectedImageIndex = (int)DataSpecTester.ImageListIcon.Class;
                                    subPropertyNode.Tag        = new TreeNodeInstanceBind
                                    {
                                        IsFirstNode = p == 0,
                                        IsArrayItem = true,
                                        IsESPData   = true,
                                        NodeItem    = subItems[p],
                                        SubType     = null,
                                        NodeType    = elementType,
                                        StoreIndex  = GetTreeNodeStoreIndex(subPropertyNode),
                                        StoreLength = currentLength
                                    };



                                    ReportToTreeView(subItems[p], subPropertyNode.Nodes, writer, false);
                                }
                                nodeBind.StoreLength = totalLength;
                            }
                            #endregion
                        }
                        else
                        {
                            #region 字节数组
                            if (propertyVal == null)
                            {
                                propertyVal = new byte[0];
                            }
                            if (elementType.Equals(typeof(byte)))
                            {
                                nodeBind.StoreLength = ((byte[])propertyVal).LongLength;

                                if (nodeBind.StoreLength > 0 && (instanceType.Equals(typeof(NetworkSwitchRequest)) ||
                                                                 instanceType.Equals(typeof(NetworkSwitchResponse)))
                                    )
                                {
                                    propertyNode.ImageIndex = propertyNode.SelectedImageIndex = (int)DataSpecTester.ImageListIcon.Class;

                                    if (instanceType.Equals(typeof(NetworkSwitchRequest)))
                                    {
                                        #region NetworkSwitchRequest
                                        RequestBase subRequest = ((NetworkSwitchRequest)instance).GetSubRequest();
                                        if (subRequest != null)
                                        {
                                            propertyNode.Text = string.Format("{0} [{1}({2})]", pInfo.Name, pInfo.PropertyType, subRequest.GetType());

                                            nodeBind.IsESPData = true;
                                            nodeBind.SubType   = subRequest.GetType();

                                            ReportToTreeView(subRequest, propertyNode.Nodes, writer, false);
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        //nodeBind.NodeItem
                                        #region  NetworkSwitchResponse
                                        object currentReqObj = ExchangeGet("Plug_Current_Request");
                                        if (currentReqObj != null)
                                        {
                                            //Trace.WriteLine("NetworkSwitchResponse of " + currentReqObj.GetType());
                                            RequestBase currentRequest = currentReqObj as RequestBase;
                                            if (currentReqObj.GetType().Equals(typeof(NetworkSwitchRequest)))
                                            {
                                                currentRequest = ((NetworkSwitchRequest)currentReqObj).GetSubRequest();
                                            }

                                            if (currentRequest != null)
                                            {
                                                ESPDataBase subResponse = ((NetworkSwitchResponse)instance).GetSubResponse(currentRequest);

                                                nodeBind.IsESPData = true;
                                                nodeBind.SubType   = subResponse.GetType();

                                                propertyNode.Text = string.Format("{0} [{1}({2})]", pInfo.Name, pInfo.PropertyType, nodeBind.SubType);

                                                ReportToTreeView(subResponse, propertyNode.Nodes, writer, false);
                                            }
                                        }
                                        #endregion
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        nodeBind.StoreLength = SpecUtil.GetCLRTypeByteLength(pInfo.PropertyType);
                        propertyNode.Tag     = nodeBind;
                    }
                }

                #endregion

                lastProperty = pInfo;
            }

            if (appendRoot && rootNode != null)
            {
                rootNode.Expand();
            }
        }
 public OthersListResponse(RequestBase request, UniSpyLib.Abstraction.BaseClass.ResultBase result) : base(request, result)
 {
 }
Ejemplo n.º 28
0
		/// <summary>
		///   Authenticate for access token.
		/// </summary>
		/// <param name="api_key"> api key </param>
		/// <param name="secret_key"> secret key </param>
		/// <returns> </returns>
		public string Authenticate(string api_key, string secret_key)
		{
			var requestObj = new RequestBase<AuthenicateRequest>
			                 {
			                 	Method = "auth.accessToken",
			                 	Parameters = new AuthenicateRequest
			                 	             {
			                 	             	APIKey = api_key,
			                 	             	SecretKey = secret_key
			                 	             }
			                 };
			string resultString = QuerySaplo(Serialize(requestObj), null);
			var response = Deserialize<AuthenticateResponse>(resultString);

			return ValidateResult(response) ? response.Result.AccessToken : null;
		}
Ejemplo n.º 29
0
		/// <summary>
		///   Fetches a group.
		/// </summary>
		/// <param name="groupId"> id of group to fetch </param>
		/// <returns> </returns>
		public Group Get(int groupId)
		{
			var reqObj = new RequestBase<GroupRequest>
			             {
			             	Method = "group.get",
			             	Parameters = new GroupRequest
			             	             {
			             	             	GroupID = groupId
			             	             }
			             };

			return CallSaploApi<Group>(reqObj);
		}
Ejemplo n.º 30
0
        public AcHeadListDto GetAgentAccountHeads(RequestBase request)
        {
            var response = _dbHelper.GetAgentAccountHeads(request);

            return(response);
        }
Ejemplo n.º 31
0
		/// <summary>
		///   Get all realted texts for this group and collection.
		/// </summary>
		/// <param name="groupId"> id of group </param>
		/// <param name="collectionId"> id of collection </param>
		/// <param name="wait"> the timeout limit, max 60s </param>
		/// <param name="limit"> maximum number of returning results, default is 5 and max is 50 </param>
		/// <returns> </returns>
		public RelatedText[] RelatedText(int groupId, int collectionId, int? wait = null, int? limit = null)
		{
			var reqObj = new RequestBase<GroupRelatedTextsRequest>
			             {
			             	Method = "group.relatedTexts",
			             	Parameters = new GroupRelatedTextsRequest
			             	             {
			             	             	CollectionScope = new[] {collectionId},
			             	             	GroupID = groupId,
			             	             	Limit = limit,
			             	             	Wait = wait
			             	             }
			             };

			return CallSaploApi<RelatedTextsResponse>(reqObj).RelatedTexts;
		}
Ejemplo n.º 32
0
        internal List <CustomerDetDto> GetCollectionAcList(RequestBase request)
        {
            var collectionAcList = _dbHelper.GetCollectionAcList(request);

            return(collectionAcList);
        }
Ejemplo n.º 33
0
 private void Response(RequestBase requestBase)
 {
     Client.Instance.Proxy.Response(requestBase);
 }
Ejemplo n.º 34
0
 internal AgentProfile GetAgentAccountDetails(RequestBase request)
 {
     return(_dbHelper.GetAgentAccountDetails(request));
 }
 public ServerMainListResponse(RequestBase request, ResultBase result) : base(request, result)
 {
 }
Ejemplo n.º 36
0
 public LoginRemoteAuthResponse(RequestBase request, ResultBase result) : base(request, result)
 {
 }
Ejemplo n.º 37
0
        public Object[] RequestCalibrationAbort()
        {
            RequestBase<ResponseBase> ca = new RequestBase<ResponseBase>();
            ca.Category = Protocol.CATEGORY_CALIBRATION;
            ca.Request = Protocol.CALIBRATION_REQUEST_ABORT;

            Request(ca);

            return ca.AsyncLock;
        }
Ejemplo n.º 38
0
 public ResponseBase ProcessMessage(RequestBase request)
 {
     if (_testProcess != null) return _testProcess(request);
     return defaultProcess();
 }
Ejemplo n.º 39
0
 public Response(RequestBase request) : base(request)
 {
 }
Ejemplo n.º 40
0
 public ResponseData(RequestBase request, String message)
 {
     HasResult    = true;
     this.Request = request;
     this.Value   = message;
 }
Ejemplo n.º 41
0
        public void RequestCalibrationClear()
        {
            RequestBase<ResponseBase> cc = new RequestBase<ResponseBase>();
            cc.Category = Protocol.CATEGORY_CALIBRATION;
            cc.Request = Protocol.CALIBRATION_REQUEST_CLEAR;

            Request(cc);
        }
Ejemplo n.º 42
0
 public TResponse SendRequest <TResponse>(RequestBase <TResponse> request) where TResponse : ResponseBase
 {
     EnsureValidChannel();
     return((TResponse)_channel.SendRequest(request));
 }
Ejemplo n.º 43
0
        public void Test()
        {
            Parallel.For(0, 100, i =>
            {
                DateTime dt = SysTimeRecord.Get(i.ToString());
                SysTimeRecord.Set(i.ToString(), dt == DateTime.MinValue ? DateTime.Now.AddDays(-i) : dt.AddHours(1));
            });

            for (int i = 0; i < 100; i++)
            {
                DateTime dt = SysTimeRecord.Get(i.ToString());
                SysTimeRecord.Set(i.ToString(), dt == DateTime.MinValue ? DateTime.Now.AddDays(i) : dt.AddHours(-1));
            }
            RedisTest.Test();


            AsyncWorker<int> aw = new AsyncWorker<int>(3, Console.WriteLine);
            for (int i = 0; i < 100; i++)
            {
                aw.AddItem(i);
            }
            aw.StopAndWait();


            Thread.Sleep(10000000);

            Parallel.Invoke(
                () => ExecCrawler(1),
                () => ExecCrawler(2),
                () => ExecCrawler(3),
                () => ExecCrawler(4),
                () => ExecCrawler(5)
                );



            HttpCore hc = new HttpCore();
            hc.SetUrl("http://ac168.info/bt/thread.php?fid=16&page={0}", 2);
            var res = hc.GetHtml();
            var tres = res.SelectNodes("//*[@id='ajaxtable']/tbody[1]/tr[@class='tr3 t_one']");

            HtmlNode node = tres[10];
            var an = node.SelectSingleNode("/td[2]/h3/a");

            string aHref = "http://ac168.info/bt/" + an.Attributes["href"].Value;
            string aText = an.InnerHtml;


            hc.SetUrl(aHref);
            res = hc.GetHtml();
            tres = res.SelectNodes("//*[@id='read_tpc']/img");

            string imgUrl = tres[0].Attributes["src"].Value;

            HttpCore hcImg = new HttpCore();
            hcImg.SetUrl(imgUrl);
            hcImg.CurrentHttpItem.ResultType = ResultType.Byte;
            //得到HTML代码
            HttpResult result = hcImg.CurrentHttpHelper.GetHtml(hcImg.CurrentHttpItem);
            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //表示访问成功,具体的大家就参考HttpStatusCode类
            }
            //表示StatusCode的文字说明与描述
            string statusCodeDescription = result.StatusDescription;
            //把得到的Byte转成图片
            Image img = result.ResultByte.ByteArrayToImage();
            img.Save("f://imgs/" + imgUrl.Split('/').Last());
            Console.WriteLine(tres);
            Console.ReadLine();
            RequestBase rb = new RequestBase();
            rb.BindLocalCache("intc", s => GetSourceCacheInt(s[0].TryChangeType(0)), 3);
            rb.BindLocalCache("person", s => GetSourceCachePerson(), null);

            Stopwatch st0 = new Stopwatch();
            st0.Start();
            rb.BindLocalCache("ps", s => GetSourceCacheListPerson(), null);
            st0.Stop();
            Console.WriteLine("实例化1千万个对象,耗时【{0}】毫秒", st0.ElapsedMilliseconds);

            Stopwatch st1 = new Stopwatch();
            st1.Start();
            for (int i = 0; i < 10000000; i++)
            {
                rb.BindLocalCache("ps", s => GetSourceCacheListPerson(), null);
            }
            st1.Stop();
            Console.WriteLine("绑定1千万次本地缓存,耗时【{0}】毫秒", st1.ElapsedMilliseconds);

            var t1 = rb.GetLocalCache("intc");
            var t2 = rb.GetLocalCache("person");
            var t3 = rb.GetLocalCache<Person>("person");
            var t4 = rb.LocalCache.person;
            var t5 = rb.LocalCache.intc;

            Stopwatch st = new Stopwatch();
            st.Start();
            for (int i = 0; i < 10000000; i++)
            {
                var t = rb.LocalCache.ps;
                var tt = rb.GetLocalCache<List<Person>>("ps");
            }
            st.Stop();
            Console.WriteLine("读取2千万次本地缓存,耗时【{0}】毫秒", st.ElapsedMilliseconds);
        }
Ejemplo n.º 44
0
        public void Write(RequestBase request)
        {
            var serializedRequest = SerializeRequest(request);

            _destination.Write(serializedRequest);
        }
Ejemplo n.º 45
0
		/// <summary>
		///   Invalidates token.
		/// </summary>
		/// <returns> </returns>
		public bool InvalidateToken()
		{
			var requestObj = new RequestBase<object>("auth.invalidateToken", new object());

			string result = QuerySaplo(Serialize(requestObj), AuthenticateIfNeeded());
			var responseObj = Deserialize<SuccessResponse>(result);

			return ValidateResult(responseObj) && responseObj.Result.Success;
		}
 private void SetBaseHeaders(RequestBase request)
 {
     request.SetAuthentication(_clientId.ToString(), _clientKey);
 }
Ejemplo n.º 47
0
        public static DataListResponse<RegionModel> GetLayoutRegionsResponse(IRepository repository, Guid layoutId, RequestBase<DataOptions> request)
        {
            request.Data.SetDefaultOrder("RegionIdentifier");

            return GetLayoutRegionsQuery(repository, layoutId).ToDataListResponse(request);
        }
Ejemplo n.º 48
0
 public static DataListResponse<OptionModel> GetWidgetOptionsResponse(IRepository repository, Guid widgetId, RequestBase<DataOptions> request)
 {
     return GetWidgetOptionsQuery(repository, widgetId).ToDataListResponse(request);
 }
Ejemplo n.º 49
0
		/// <summary>
		///   Lists all groups that belongs to account
		/// </summary>
		/// <returns> </returns>
		public Group[] List()
		{
			var reqObj = new RequestBase<object>("group.list", new object());
			return CallSaploApi<GroupsResponse>(reqObj).Groups;
		}
Ejemplo n.º 50
0
        /// <summary>
        /// 根据XML信息填充实实体
        /// </summary>
        /// <typeparam name="T">MessageBase为基类的类型,Response和Request都可以</typeparam>
        /// <param name="entity">实体</param>
        /// <param name="doc">XML</param>
        public static void FillEntityWithXml <T>(this T entity, XDocument doc) where T : /*MessageBase*/ class, new()
        {
            entity = entity ?? new T();
            var root = doc.Root;

            var props = entity.GetType().GetProperties();

            foreach (var prop in props)
            {
                var propName = prop.Name;
                if (root.Element(propName) != null)
                {
                    switch (prop.PropertyType.Name)
                    {
                    //case "String":
                    //    goto default;
                    case "DateTime":
                    case "DateTimeOffset":
                    case "Int32":
                    case "Int32[]":     //增加int[]
                    case "Int64":
                    case "Int64[]":     //增加long[]
                    case "Double":
                    case "Nullable`1":  //可为空对象
                        EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value);
                        break;

                    case "Boolean":
                        if (propName == "FuncFlag")
                        {
                            EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value == "1");
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    //以下为枚举类型
                    case "ContactChangeType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "RequestMsgType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "ResponseMsgType":     //Response适用
                                                //已设为只读
                                                //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "ThirdPartyInfo":     //ThirdPartyInfo适用
                                               //已设为只读
                                               //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "Event":
                        //已设为只读
                        //prop.SetValue(entity, EventHelper.GetEventType(root.Element(propName).Value), null);
                        break;

                    //以下为实体类型
                    case "List`1":                                 //List<T>类型,ResponseMessageNews适用
                        var genericArguments = prop.PropertyType.GetGenericArguments();
                        if (genericArguments[0].Name == "Article") //ResponseMessageNews适用
                        {
                            //文章下属节点item
                            List <Article> articles = new List <Article>();
                            foreach (var item in root.Element(propName).Elements("item"))
                            {
                                var article = new Article();
                                FillEntityWithXml(article, new XDocument(item));
                                articles.Add(article);
                            }
                            prop.SetValue(entity, articles, null);
                        }
                        else if (genericArguments[0].Name == "MpNewsArticle")
                        {
                            List <MpNewsArticle> mpNewsArticles = new List <MpNewsArticle>();
                            foreach (var item in root.Elements(propName))
                            {
                                var mpNewsArticle = new MpNewsArticle();
                                FillEntityWithXml(mpNewsArticle, new XDocument(item));
                                mpNewsArticles.Add(mpNewsArticle);
                            }
                            prop.SetValue(entity, mpNewsArticles, null);
                        }
                        else if (genericArguments[0].Name == "PicItem")
                        {
                            List <PicItem> picItems = new List <PicItem>();
                            foreach (var item in root.Elements(propName).Elements("item"))
                            {
                                var    picItem   = new PicItem();
                                var    picMd5Sum = item.Element("PicMd5Sum").Value;
                                Md5Sum md5Sum    = new Md5Sum()
                                {
                                    PicMd5Sum = picMd5Sum
                                };
                                picItem.item = md5Sum;
                                picItems.Add(picItem);
                            }
                            prop.SetValue(entity, picItems, null);
                        }
                        break;

                    case "Image":     //ResponseMessageImage适用
                        Image image = new Image();
                        FillEntityWithXml(image, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, image, null);
                        break;

                    case "Voice":     //ResponseMessageVoice适用
                        Voice voice = new Voice();
                        FillEntityWithXml(voice, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, voice, null);
                        break;

                    case "Video":     //ResponseMessageVideo适用
                        Video video = new Video();
                        FillEntityWithXml(video, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, video, null);
                        break;

                    case "ScanCodeInfo":     //扫码事件中的ScanCodeInfo适用
                        ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
                        FillEntityWithXml(scanCodeInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, scanCodeInfo, null);
                        break;

                    case "SendLocationInfo":     //弹出地理位置选择器的事件推送中的SendLocationInfo适用
                        SendLocationInfo sendLocationInfo = new SendLocationInfo();
                        FillEntityWithXml(sendLocationInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendLocationInfo, null);
                        break;

                    case "SendPicsInfo":     //系统拍照发图中的SendPicsInfo适用
                        SendPicsInfo sendPicsInfo = new SendPicsInfo();
                        FillEntityWithXml(sendPicsInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendPicsInfo, null);
                        break;

                    case "BatchJobInfo":     //异步任务完成事件推送BatchJob
                        BatchJobInfo batchJobInfo = new BatchJobInfo();
                        FillEntityWithXml(batchJobInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, batchJobInfo, null);
                        break;

                    case "AgentType":
                    {
                        AgentType tp;
                        if (Enum.TryParse(root.Element(propName).Value, out tp))
                        {
                            prop.SetValue(entity, tp, null);
                        }
                        break;
                    }

                    case "Receiver":
                    {
                        Receiver receiver = new Receiver();
                        FillEntityWithXml(receiver, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, receiver, null);
                        break;
                    }

                    default:
                        prop.SetValue(entity, root.Element(propName).Value, null);
                        break;
                    }
                }
                else if (prop.PropertyType.Name == "List`1")//客服回调特殊处理
                {
                    var genericArguments = prop.PropertyType.GetGenericArguments();
                    if (genericArguments[0].Name == "RequestBase")
                    {
                        List <RequestBase> items = new List <RequestBase>();
                        foreach (var item in root.Elements("Item"))
                        {
                            RequestBase reqItem    = null;
                            var         msgTypeEle = item.Element("MsgType");
                            if (msgTypeEle != null)
                            {
                                RequestMsgType type         = RequestMsgType.Unknown;
                                var            parseSuccess = false;
                                parseSuccess = Enum.TryParse(msgTypeEle.Value, true, out type);
                                if (parseSuccess)
                                {
                                    switch (type)
                                    {
                                    case RequestMsgType.Event:
                                    {
                                        reqItem = new RequestEvent();
                                        break;
                                    }

                                    case RequestMsgType.File:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageFile();
                                        break;
                                    }

                                    case RequestMsgType.Image:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageImage();
                                        break;
                                    }

                                    case RequestMsgType.Link:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageLink();
                                        break;
                                    }

                                    case RequestMsgType.Location:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageLocation();
                                        break;
                                    }

                                    case RequestMsgType.Text:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageText();

                                        break;
                                    }

                                    case RequestMsgType.Voice:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageVoice();
                                        break;
                                    }
                                    }
                                }
                            }
                            if (reqItem != null)
                            {
                                FillEntityWithXml(reqItem, new XDocument(item));
                                items.Add(reqItem);
                            }
                        }
                        prop.SetValue(entity, items, null);
                    }
                }
            }
        }
Ejemplo n.º 51
0
		/// <summary>
		///   Fetches all groups related to the supplied groupId.
		/// </summary>
		/// <param name="groupId"> id of group to find related groups for </param>
		/// <param name="groupScope"> scope to search within, if not specified we use all groups </param>
		/// <param name="wait"> timeout time for query, max 60s </param>
		/// <returns> </returns>
		public RelatedGroup[] RelatedGroups(int groupId, int[] groupScope = null, int? wait = null)
		{
			var reqObj = new RequestBase<GroupRelatedGroupsRequest>
			             {
			             	Method = "group.relatedGroups",
			             	Parameters = new GroupRelatedGroupsRequest
			             	             {
			             	             	GroupID = groupId,
			             	             	GroupScope = groupScope,
			             	             	Wait = wait
			             	             }
			             };

			return CallSaploApi<RelatedGroupsResponse>(reqObj).RelatedGroups;
		}
Ejemplo n.º 52
0
 public NicksResponse(RequestBase request, UniSpyLib.Abstraction.BaseClass.ResultBase result) : base(request, result)
 {
 }
Ejemplo n.º 53
0
		/// <summary>
		///   Resets group, removes all texts.
		/// </summary>
		/// <param name="groupId"> id of group </param>
		/// <returns> </returns>
		public bool Reset(int groupId)
		{
			var reqObj = new RequestBase<GroupRequest>
			             {
			             	Method = "group.reset",
			             	Parameters = new GroupRequest
			             	             {
			             	             	GroupID = groupId
			             	             }
			             };

			return CallSaploApi<object>(reqObj) != null;
		}
Ejemplo n.º 54
0
 public InitResponse(RequestBase request, ResultBase result) : base(request, result)
 {
 }
Ejemplo n.º 55
0
        public async Task <StatusData <GeneralKvPair <int, List <long> > > > UpsertRule(RequestBase request, SystemDbStatus dbMode, SystemSession session)
        {
            var result = new StatusData <GeneralKvPair <int, List <long> > >();

            if (dbMode == SystemDbStatus.Inserted)
            {
                var req = request as RuleAddRequest;

                var ruleRequest = new Kauwa.Inbox {
                    UserId = request.UserId, FolderId = req.FolderId, InboxRules = new List <InboxRule> {
                        new InboxRule {
                            TypeUserSelection = (int)req.Rule.UserSelection, RuleTypeUser = (int)req.Rule.RuleTypeUser, ContactList = req.Rule.ContactList, GroupList = req.Rule.GroupList, RuleTypeSubject = (int)req.Rule.RuleTypeSubject, Subject = req.Rule.Subject, ApplyOnOldMessage = req.Rule.ApplyOnOldMessage
                        }
                    }
                };

                var response = await Task.Factory.StartNew(() => Client.InboxRuleService.createInboxRules(ruleRequest, session.GetSession())).ConfigureAwait(false);

                result.Status = (SystemDbStatus)response.DbStatusCode;

                result.Data = new GeneralKvPair <int, List <long> >
                {
                    Id    = response.FolderId,
                    Value = response.InboxRules != null?response.InboxRules.Select(x => x.RuleId).ToList() : null
                };

                result.SubStatus = response.DbSubStatusCode;
                result.Message   = response.DbStatusMsg;
                return(result);
            }
            else
            {
                var req = request as RuleUpdateRequest;

                var ruleRequest = new Kauwa.Inbox {
                    UserId = request.UserId, FolderId = req.FolderId, InboxRules = new List <InboxRule> {
                        new InboxRule {
                            RuleId = req.MessageRuleId, TypeUserSelection = (int)req.Rule.UserSelection, RuleTypeUser = (int)req.Rule.RuleTypeUser, ContactList = req.Rule.ContactList, GroupList = req.Rule.GroupList, RuleTypeSubject = (int)req.Rule.RuleTypeSubject, Subject = req.Rule.Subject, ApplyOnOldMessage = req.Rule.ApplyOnOldMessage
                        }
                    }
                };

                result = (await Task.Factory.StartNew(() => Client.InboxRuleService.updateInboxRules(ruleRequest, session.GetSession())).ConfigureAwait(false)).GetStatusData <GeneralKvPair <int, List <long> > >();
                return(result);
            }
        }
Ejemplo n.º 56
0
        public ViewDetailVideoDTO GetDetailVideo(RequestBase request)
        {
            try
            {
                ///check valid video
                //var isvalid = IoC.Get<IAPIKeyBusiness>().CheckVaildVideo(request.Id);

                //if (!isvalid) return null;


                var searchListRequest = _Service.Videos.List("snippet,ContentDetails,Statistics");
                searchListRequest.Id = request.Id;

                var searchListResponse = searchListRequest.Execute();
                if (searchListResponse.Items == null || searchListResponse.Items.Count <= 0)
                {
                    return(null);
                }

                var row   = searchListResponse.Items[0];
                var video = new VideoDTO()
                {
                    videoId      = request.Id,
                    title        = row.Snippet.Title,
                    imgUrl       = row.Snippet.Thumbnails.High.Url,
                    chanelId     = row.Snippet.ChannelId,
                    chanelTitle  = row.Snippet.ChannelTitle,
                    description  = row.Snippet.Description,
                    tags         = row.Snippet.Tags,
                    publishDated = row.Snippet.PublishedAt,
                    duration     = row.ContentDetails.Duration,
                    viewcount    = row.Statistics.ViewCount,
                    dislikecount = string.Format("{0:n0}", row.Statistics.DislikeCount),
                    likecount    = string.Format("{0:n0}", row.Statistics.LikeCount),
                    height       = row.Snippet.Thumbnails.High.Height,
                    width        = row.Snippet.Thumbnails.High.Width,
                };
                ///lay video lien quan
                var related = VideoRelated(request.Id);
                /// lay thong tin kenh
                var channel = GetChannelInfo(video.chanelId);


                var data = new ViewDetailVideoDTO()
                {
                    Video         = video,
                    channel       = channel,
                    VideoRelateds = related,
                    //IsValid = isvalid,
                };

                return(data);
            }
            catch (Google.GoogleApiException ex)
            {
                log.Error("GetDetailVideo ex: " + ex);
                log.Info("key use: " + CommonKey.KeyActive);

                if (ex.HttpStatusCode != System.Net.HttpStatusCode.BadRequest)
                {
                    _keyservice.SetOverLimit();
                    _keyservice.GetDefaultKey();

                    InitService();
                    var result = GetDetailVideo(request);
                    return(result);
                }
                else
                {
                    return(null);
                }
            }
        }
 private void SetBaseFields(RequestBase request)
 {
     request.LanguageCode    = _languageCode;
     request.ApplicationName = _applicationName;
 }
Ejemplo n.º 58
0
 protected override bool IsValidSessionToken(RequestBase request)
 {
     return(request.SessionToken != null && request.SessionToken.Equals(ConfigurationManager.AppSettings["ServiceSessionToken"]));
 }
 public static DataListResponse<OptionValueModel> GetPageContentOptionsResponse(IRepository repository, Guid pageContentId, RequestBase<DataOptions> request, IOptionService optionService)
 {
     return GetPageContentOptionsQuery(repository, pageContentId, optionService).ToDataListResponse(request);
 }
 private void SetBaseUri(RequestBase request)
 {
     request.BaseUri = _uri;
 }