コード例 #1
1
ファイル: TSResponse.cs プロジェクト: pepipe/ISEL
 public TSResponse(XmlElement element)
 {
     type = (ResponseType)Enum.Parse(typeof(ResponseType), element.GetAttribute("type"), false);
     XmlNodeList l = element.GetElementsByTagName("tuple");
     id = element.GetAttribute("id");
     tuples = new Tuple[l.Count];
     for (int i = 0; i < l.Count; i++)
     {
         XmlElement elTuple = (XmlElement)l[i];
         tuples[i] = new Tuple(elTuple);
     }
 }
コード例 #2
0
		protected void OnBtnSendClicked (object sender, EventArgs e)
		{
			Response = ResponseType.Accept;
			this.UserDescription = textview1.Buffer.Text;
			this.HideAll ();
			Send (ex, sv);
		}
コード例 #3
0
ファイル: HttpWorker.cs プロジェクト: evest/Netling
        public HttpWorker(Uri uri, HttpMethod httpMethod = HttpMethod.Get, Dictionary<string, string> headers = null, byte[] data = null)
        {
            _buffer = new byte[8192];
            _bufferIndex = 0;
            _read = 0;
            _responseType = ResponseType.Unknown;
            _uri = uri;
            IPAddress ip;
            var headersString = string.Empty;
            var contentLength = data != null ? data.Length : 0;

            if (headers != null && headers.Any())
                headersString = string.Concat(headers.Select(h => "\r\n" + h.Key.Trim() + ": " + h.Value.Trim()));

            if (_uri.HostNameType == UriHostNameType.Dns)
            {
                var host = Dns.GetHostEntry(_uri.Host);
                ip = host.AddressList.First(i => i.AddressFamily == AddressFamily.InterNetwork);
            }
            else
            {
                ip = IPAddress.Parse(_uri.Host);
            }

            _endPoint = new IPEndPoint(ip, _uri.Port);
            _request = Encoding.UTF8.GetBytes($"{httpMethod.ToString().ToUpper()} {_uri.PathAndQuery} HTTP/1.1\r\nAccept-Encoding: gzip, deflate, sdch\r\nHost: {_uri.Host}\r\nContent-Length: {contentLength}{headersString}\r\n\r\n");

            if (data == null)
                return;

            var tmpRequest = new byte[_request.Length + data.Length];
            Buffer.BlockCopy(_request, 0, tmpRequest, 0, _request.Length);
            Buffer.BlockCopy(data, 0, tmpRequest, _request.Length, data.Length);
            _request = tmpRequest;
        }
コード例 #4
0
ファイル: ResponseEvent.cs プロジェクト: Zeghs/ZeroSystem
		/// <summary>
		///   建構子
		/// </summary>
		/// <param name="tradeOrder">訂單資訊</param>
		/// <param name="symbolId">商品代號</param>
		/// <param name="type">回報類型</param>
		/// <param name="openTrades">開倉交易單列表</param>
		/// <param name="closeTrades">已平倉交易單列表</param>
		public ResponseEvent(ITradeOrder tradeOrder, string symbolId, ResponseType type, TradeList<ITrade> openTrades, List<ITrade> closeTrades) {
			__cTradeOrder = tradeOrder;
			__sSymbolId = symbolId;
			__cType = type;
			__cOpenTrades = openTrades;
			__cCloseTrades = closeTrades;
		}
コード例 #5
0
		/// <summary>
		/// Creates a new response object with the given XML representation.
		/// </summary>
		/// <param name="xml">XML representation of this response</param>
		public ResponseElement(XmlNode xml) : base(xml)
		{ 
			switch(xml.Name)
			{
				case "success":
					type = ResponseType.Success;
					break;
				case "failure":
					type = ResponseType.Failure;
					break;
				case "stream:error":
					type = ResponseType.StreamError;
					break;
				case "starttls":
					type = ResponseType.StartTls;
					break;
				case "proceed":
					type = ResponseType.ProceedTls;
					break;
				case "challenge":
					type = ResponseType.SaslChallenge;
					break;
				case "response":
					type = ResponseType.SaslResponse;
					break;
				default:
					throw new OpenXMPPException("An unknown response element was received.");
			}
		}
コード例 #6
0
ファイル: About.cs プロジェクト: mtanski/drapes
        protected override void OnResponse(ResponseType response_id)
        {
            base.OnResponse (response_id);

            if (response_id == ResponseType.Cancel)
                this.Destroy();
        }
コード例 #7
0
        public static object Service(this Uri url, RequestType requestType, ResponseType responseType, out int resultCode, string outputFilename, IDictionary<string, string> formData) {
            object result = null;
            resultCode = -1;

            var webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.Proxy = GetProxy();

            webRequest.CookieContainer = Cookies.GetCookieContainer();

            switch (requestType) {
                case RequestType.POST:
                    webRequest.Method = "POST";
                    webRequest.ContentType = "application/x-www-form-urlencoded";

                    var encodedFormData = Encoding.UTF8.GetBytes(GetFormData(formData).ToString());
                    using (var requestStream = webRequest.GetRequestStream()) {
                        requestStream.Write(encodedFormData, 0, encodedFormData.Length);
                    }
                    break;
                case RequestType.GET:
                    webRequest.Method = "GET";
                    if (formData != null) {
                        var ub = new UriBuilder(url) {
                            Query = GetFormData(formData).ToString()
                        };
                        url = ub.Uri;
                    }
                    break;
            }

            try {
                if (credentialCache != null) {
                    webRequest.Credentials = credentialCache;
                    webRequest.PreAuthenticate = true;
                }
                var webResponse = webRequest.GetResponse();

                if (!KeepCookiesClean) {
                    Cookies.AddCookies(webRequest.CookieContainer.GetCookies(webResponse.ResponseUri));
                }

                switch (responseType) {
                    case ResponseType.String:
                        result = GetStringResponse(webResponse);
                        resultCode = 200;
                        break;
                    case ResponseType.Binary:
                        result = GetBinaryResponse(webResponse);
                        resultCode = 200;
                        break;
                    case ResponseType.File:
                        result = GetBinaryFileResponse(webResponse, outputFilename);
                        resultCode = 200;
                        break;
                }
            } catch {
                resultCode = 0;
            }
            return result;
        }
コード例 #8
0
 private void OnLoginResponse(ResponseType responseType, JToken responseData, string callee) {
     if (responseType == ResponseType.Success) {
         authenticationToken = responseData.Value<string>("token");
         if (OnLoggedIn != null) {
             OnLoggedIn();
         }
     } else if (responseType == ResponseType.ClientError) {
         if (OnLoginFailed != null) {
             OnLoginFailed("Could not reach the server. Please try again later.");
         }
     } else {
         JToken fieldToken = responseData["non_field_errors"];
         if (fieldToken == null || !fieldToken.HasValues) {
             if (OnLoginFailed != null) {
                 OnLoginFailed("Login failed: unknown error.");
             }
         } else {
             string errors = "";
             JToken[] fieldValidationErrors = fieldToken.Values().ToArray();
             foreach (JToken validationError in fieldValidationErrors) {
                 errors += validationError.Value<string>();
             }
             if (OnLoginFailed != null) {
                 OnLoginFailed("Login failed: " + errors);
             }
         }
     }
 }
コード例 #9
0
ファイル: NetCommand.cs プロジェクト: Aaldert/IP2
 //RESPONSE
 public NetCommand(ResponseType response, int session)
 {
     Type = CommandType.RESPONSE;
     Session = session;
     Timestamp = Helper.Now;
     Response = response;
 }
コード例 #10
0
        /// <summary>
        /// Constructs an authorize url.
        /// </summary>
        public static string BuildAuthorizeUrl(
            string clientId, 
            string redirectUrl, 
            IEnumerable<string> scopes, 
            ResponseType responseType,
            DisplayType display,
            ThemeType theme,
            string locale,
            string state)
        {
            Debug.Assert(!string.IsNullOrEmpty(clientId));
            Debug.Assert(!string.IsNullOrEmpty(redirectUrl));
            Debug.Assert(!string.IsNullOrEmpty(locale));

            IDictionary<string, string> options = new Dictionary<string, string>();
            options[AuthConstants.ClientId] = clientId;
            options[AuthConstants.Callback] = redirectUrl;
            options[AuthConstants.Scope] = BuildScopeString(scopes);
            options[AuthConstants.ResponseType] = responseType.ToString().ToLowerInvariant();
            options[AuthConstants.Display] = display.ToString().ToLowerInvariant();
            options[AuthConstants.Locale] = locale;
            options[AuthConstants.ClientState] = EncodeAppRequestState(state);

            if (theme != ThemeType.None)
            {
                options[AuthConstants.Theme] = theme.ToString().ToLowerInvariant();
            }

            return BuildAuthUrl(AuthEndpointsInfo.AuthorizePath, options);
        }
コード例 #11
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="refId">A RefId</param>
 ///<param name="assessmentFormRefId">This RefId points to the assessment form of which the item is a part.</param>
 ///<param name="responseType">A value that indicates the response type for the item.</param>
 ///<param name="itemLabel">An item number or other identifier for the item.  It may be used to indicate the order or grouping of items.</param>
 ///
 public AssessmentItem( string refId, string assessmentFormRefId, ResponseType responseType, string itemLabel )
     : base(Adk.SifVersion, AssessmentDTD.ASSESSMENTITEM)
 {
     this.RefId = refId;
     this.AssessmentFormRefId = assessmentFormRefId;
     this.SetResponseType( responseType );
     this.ItemLabel = itemLabel;
 }
コード例 #12
0
        protected override void OnResponse(ResponseType response)
        {
            base.OnResponse (response);

            if (response == ResponseType.Help)
                Help.DisplayUriOnScreen ("ghelp:questar/preferences",
                    base.Dialog.Screen);
        }
コード例 #13
0
 protected override void OnResponse(ResponseType response)
 {
     if (response == ResponseType.Ok) {
         int timervalue = sleepHour.ValueAsInt * 60 + sleepMin.ValueAsInt;
         service.SleepTimerDuration = timervalue;
         service.SetSleepTimer (timervalue);
     }
 }
コード例 #14
0
        protected override void OnResponse (ResponseType response)
        {
            base.OnResponse (response);

            if (CurrentFolderUri != null) {
                LastFileChooserUri.Set (CurrentFolderUri);
            }
        }
コード例 #15
0
 protected Uri BuildAuthenticateUri(AuthenticationPermissions scope, ResponseType responseType)
 {
     var builder = new HttpUriBuilder(AuthenticationUrl);
     builder.AddQueryStringParameter("client_id", this.ClientId);
     builder.AddQueryStringParameter("response_type", responseType.ToString().ToLower());
     builder.AddQueryStringParameter("scope", scope.GetParameterValue());
     builder.AddQueryStringParameter("redirect_uri", RedirectUri);
     return builder.Build();
 }
コード例 #16
0
	/* Event members */

	#pragma warning disable 169		//Disables warning about handlers not being used

	protected override bool ProcessResponse (ResponseType response) {
		if (response == ResponseType.Ok) {
			if (dialog.Uri != null) {
				chosenUri = new Uri(dialog.Uri);
			}
			SetReturnValue(true);
		}
		return false;
	}
コード例 #17
0
ファイル: Response.cs プロジェクト: fiLLLip/RethinkDb.Driver
 private Response(long token, ResponseType responseType, JArray data, List<ResponseNote> responseNotes, Profile profile, Backtrace backtrace, ErrorType errorType)
 {
     this.Token = token;
     this.Type = responseType;
     this.Data = data;
     this.Notes = responseNotes;
     this.Profile = profile;
     this.Backtrace = backtrace;
     this.ErrorType = errorType;
 }
コード例 #18
0
ファイル: MessageBox.cs プロジェクト: JGunning/OpenAIM
 /// <summary>
 /// Creates a new message box
 /// </summary>
 /// <param name="parentWindow">Window this box belongs to</param>
 /// <param name="messageType">Type of box</param>
 /// <param name="buttons">Buttons</param>
 /// <param name="message">Value</param>
 /// <param name="title">Title</param>
 public MessageBox(Window parentWindow, MessageType messageType, ButtonsType buttons, string message, string title)
 {
     Message = new MessageDialog(parentWindow, DialogFlags.Modal, messageType, buttons, false, null);
     Message.WindowPosition = WindowPosition.Center;
     Message.Text = message;
     Message.Icon = Gdk.Pixbuf.LoadFromResource("Client.Resources.pigeon_clip_art_hight.ico");
     Message.Title = title;
     result = (ResponseType)Message.Run();
     Message.Destroy();
 }
コード例 #19
0
ファイル: RCATContext.cs プロジェクト: Mondego/rcat-gs
        public void Broadcast(dynamic data, string[] clients, ResponseType type, long timestamp)
        {
            ClientMessage cb = new ClientMessage();
            cb.clients = clients;
            cb.Data = data;
            cb.Type = type;
            cb.TimeStamp = timestamp;

            Send(Newtonsoft.Json.JsonConvert.SerializeObject(cb));
        }
コード例 #20
0
        public DimensionsDialog()
        {
            min = 1;
            max = 6000;

            width = 1000;
            height = 1000;
            aspectRatio = 1;

            response = ResponseType.None;
        }
コード例 #21
0
      public string GetRequestUrl(string requestUrl,double latitude,double longitude,ResponseType responseType)
      {
          if (_postArgumentList == null)
              _postArgumentList = new List<KeyValuePair<string, object>>();

          _postArgumentList.Add(new KeyValuePair<string,object>("lat",latitude));
          _postArgumentList.Add(new KeyValuePair<string, object>("long", longitude));
          _postArgumentList.Add(new KeyValuePair<string, object>("output", responseType.ToString().ToLower()));

          return requestUrl;
      }
コード例 #22
0
        public void the_LRAP1Attachment_is_submitted_to_the_AgentGateway(ResponseType responseType)
        {
            //Arrange
            A.CallTo(() => _fakeCommsService.Send(_command)).Returns(responseType);

            //Act
            _sut.Process(_command);

            //Assert
            A.CallTo(() => _fakeCommsService.Send(A<SubmitLrap1AttachmentCommand>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
        }
コード例 #23
0
ファイル: Game.cs プロジェクト: DSobscure/MonopolyOnlineGame
 public Game(int startMoney, List<Player> players)
 {
     this.response = ResponseType.NoResponse;
     this.die = new Die();
     this.gameOverFlag = false;
     this.players = players;
     foreach (Player player in players)
     {
         player.JoinGame(this, startMoney);
     }
     this.destinyDeck = new DestinyDeck();
     this.chanceDeck = new ChanceDeck();
     map = new Map(this);
     map.RegisterBlocks(new List<Block>(){
         // 1st street
         new StartBlock(map, 1000, players),
         new LandBlock(map, new Land(500, "Alpha")),
         new LandBlock(map, new Land(400, "Bravo")),
         new LandBlock(map, new Land(200, "Charlie")),
         new ChanceBlock(map, chanceDeck),
         new LandBlock(map, new Land(200, "Delta")),
         new LandBlock(map, new Land(400, "Echo")),
         new LandBlock(map, new Land(300, "Foxtrot")),
         // 2nd street
         new EmptyBlock(map),
         new LandBlock(map, new Land(100, "Golf")),
         new LandBlock(map, new Land(200, "Hotel")),
         new LandBlock(map, new Land(400, "India")),
         new DestinyBlock(map, destinyDeck),
         new LandBlock(map, new Land(300, "Juliet")),
         new LandBlock(map, new Land(400, "Kilo")),
         new LandBlock(map, new Land(700, "Lima")),
         // 3rd street
         new EmptyBlock(map),
         new LandBlock(map, new Land(500, "Mike")),
         new LandBlock(map, new Land(200, "November")),
         new LandBlock(map, new Land(300, "Oscar")),
         new ChanceBlock(map, chanceDeck),
         new LandBlock(map, new Land(200, "Papa")),
         new LandBlock(map, new Land(100, "Quebec")),
         new LandBlock(map, new Land(100, "Romeo")),
         // 4th street
         new EmptyBlock(map),
         new LandBlock(map, new Land(200, "Sierra")),
         new LandBlock(map, new Land(400, "Tango")),
         new LandBlock(map, new Land(600, "Uniform")),
         new DestinyBlock(map, destinyDeck),
         new LandBlock(map, new Land(300, "Victor")),
         new LandBlock(map, new Land(500, "Whiskey")),
         new LandBlock(map, new Land(800, "X-ray"))
     });
 }
コード例 #24
0
        public string GetAuthorizeUrl(ResponseType response = ResponseType.Code)
        {
            Dictionary<string, object> config = new Dictionary<string, object>()
            {
                {"client_id",ClientID},
                {"redirect_uri",CallbackUrl},
                {"response_type",response.ToString().ToLower()},
            };
            UriBuilder builder = new UriBuilder(AuthorizeUrl);
            builder.Query = Utility.BuildQueryString(config);

            return builder.ToString();
        }
コード例 #25
0
        public void the_response_is_returned(ResponseType expectedResponseType)
        {
            // Arrange
            var sut = new RequestSender();
            var requestGenerator = new RequestGenerator();
            var request = requestGenerator.Lrap1Request(expectedResponseType);

            // Act
            var lrapResponse = sut.Send(request, "LRUsername001", "BGPassword001");

            // Assert
            Assert.Equal(expectedResponseType, lrapResponse.ResponseType);
        }
コード例 #26
0
        public List<KeyValuePair<string, string>> CreateAuthorizatioUriParams(ResponseType responseType)
        {
            var responseTypeString = ParamValueAttributeHelper.GetParamValueOfEnumAttribute<ResponseType>(responseType);

            List<KeyValuePair<string, string>> authParams = new List<KeyValuePair<string, string>>()
                {
                    new KeyValuePair<string, string>("response_type", responseTypeString),
                     new KeyValuePair<string, string>("redirect_uri", RedirectUri),
                     new KeyValuePair<string, string>("client_id", ClientId)
                };

            return authParams;
        }
        public string GetWeChatOauthUrl(string requestUrl, string appId, ResponseType responseType, string redirectUrl, 
            string scope = "post_timeline", string state="")
        {
            requestUrl += "oauth";      

            Dictionary<string,object> mergeArgumentDic=new Dictionary<string,object>();
            mergeArgumentDic.Add("appid", appId);
            mergeArgumentDic.Add("response_type", responseType.ToString().ToLower());
            mergeArgumentDic.Add("redirect_uri", redirectUrl);

            mergeArgumentDic.Add("scope", scope);
            mergeArgumentDic.Add("state", state);
            return  base.MergeRequestArgument(requestUrl,mergeArgumentDic);
        }
コード例 #28
0
        public ModernDialog(string title, Window owner)
            : base(title)
        {
            this.WidthRequest = 350;
            this.HeightRequest = 180;
            this.ShowMinimize = false;
            this.WindowPosition = WindowPosition.None;
            this.KeepAbove = true;
            this.Modal = true;
            _response = ResponseType.None;

            if (owner != null)
            {
                int root_x, root_y;
                owner.GetPosition(out root_x, out root_y);
                this.Move(root_x + (owner.WidthRequest / 2) - (this.WidthRequest / 2),
                          root_y + (owner.HeightRequest / 2) - (this.HeightRequest / 2));
            }

            this.text = new global::Gtk.TextView();
            this.text.WrapMode = Gtk.WrapMode.Word;
            this.text.CanFocus = true;
            this.text.Editable = false;
            this.text.WidthRequest = (int)(this.WidthRequest * 0.8);
            this.GridMain.Add(this.text);
            global::Gtk.Fixed.FixedChild w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[this.text]));
            w2.X = 50;
            w2.Y = 70;

            this.btn1 = new Button();
            this.btn1.Clicked += btn1_Clicked;
            this.btn1.WidthRequest = 100;
            this.btn1.HeightRequest = 30;
            this.GridMain.Add(this.btn1);
            w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[btn1]));
            w2.X = 75;
            w2.Y = 120;

            this.btn2 = new Button();
            this.btn2.Clicked += btn2_Clicked;
            this.btn2.WidthRequest = 100;
            this.btn2.HeightRequest = 30;
            this.GridMain.Add(this.btn2);
            w2 = ((global::Gtk.Fixed.FixedChild)(this.GridMain[btn2]));
            w2.X = 175;
            w2.Y = 120;

            this.ShowObjects();
        }
コード例 #29
0
        /// <summary>
        /// Ferme la session ouverte dans le menu LoginWindow
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        protected void OnCloseSessionsClicked(object sender, EventArgs e)
        {
            MessageDialog md = new MessageDialog (this, DialogFlags.Modal, MessageType.Question,
                                   ButtonsType.YesNo, "Êtes-vous sûr de vouloir fermer la session");
            ResponseType rt = new ResponseType ();
            rt = (ResponseType)md.Run ();

            if (rt.ToString () == "Yes") {
                md.Destroy ();
                this.Destroy ();
                LoginWindow lw = new LoginWindow ();
                lw.Show ();
            } else {
                md.Destroy ();
            }
        }
コード例 #30
0
 public ResponseInXML(XmlNode xnResponseNode)
 {
     switch (xnResponseNode.Attributes["type"].Value)
     {
         case "json":
             this.type = ResponseType.JSON;
             rootParam = new ResponseParam(xnResponseNode.SelectSingleNode("item"));
             break;
         case "raw":
             this.type = ResponseType.RAW;
             break;
         default:
             this.type = ResponseType.DEFAULT;
             break;
     }
 }
コード例 #31
0
ファイル: EsbService.cs プロジェクト: RENSting/cnf.esb
 public RawResponse(IRestResponse response, string requestUrl)
 {
     _requestUrl = requestUrl;
     _response   = response;
     _type       = ResponseType.RestSharpResponse;
 }
コード例 #32
0
        private void readType(ResponseType expectedType)
        {
            var type = _reader.ReadTypeChar();

            SAssert.ResponseType(expectedType, type, _reader);
        }
コード例 #33
0
ファイル: ResultInfo.cs プロジェクト: Gojice/Boffalow
 public override string ToString()
 {
     return($"{ResponseType.ToString()}: {Message}.");
 }
コード例 #34
0
        protected override void OnResponse(ResponseType response)
        {
            //int w = -1, h = -1;
            //dialog.GetSize (out w, out h);
            //Console.WriteLine ("w = {0}, h = {1}", w, h);

            QueryNode node = builder.QueryNode;

            if (node == null)
            {
                //Console.WriteLine ("Editor query is null");
            }
            else
            {
                //Console.WriteLine ("Editor query is: {0}", node.ToXml (BansheeQuery.FieldSet, true));
            }

            if (response == ResponseType.Ok)
            {
                string            name           = PlaylistName;
                QueryNode         condition_tree = Condition;
                QueryLimit        limit          = Limit;
                QueryOrder        order          = Order;
                IntegerQueryValue limit_value    = LimitValue;

                ThreadAssist.Spawn(delegate {
                    //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number);
                    if (playlist == null)
                    {
                        playlist = new SmartPlaylistSource(name, primary_source);

                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder    = order;
                        playlist.Limit         = limit;
                        playlist.LimitValue    = limit_value;

                        playlist.Save();
                        primary_source.AddChildSource(playlist);
                        playlist.RefreshAndReload();
                        //SmartPlaylistCore.Instance.StartTimer (playlist);
                    }
                    else
                    {
                        playlist.ConditionTree = condition_tree;
                        playlist.QueryOrder    = order;
                        playlist.LimitValue    = limit_value;
                        playlist.Limit         = limit;

                        playlist.Name = name;
                        playlist.Save();
                        playlist.RefreshAndReload();

                        /*if (playlist.TimeDependent)
                         *  SmartPlaylistCore.Instance.StartTimer (playlist);
                         * else
                         *  SmartPlaylistCore.Instance.StopTimer ();*/

                        //playlist.ListenToPlaylists ();
                        //SmartPlaylistCore.Instance.SortPlaylists ();
                    }
                });
            }

            currently_editing = null;
        }
コード例 #35
0
 public ResultInfo(ResponseType responseType, string errorMessage)
 {
     ResponseType = responseType;
     Message      = errorMessage;
     HandleMessages(errorMessage);
 }
コード例 #36
0
ファイル: Uploader.cs プロジェクト: luandev/ShareX
 protected string SendRequest(HttpMethod method, string url, Dictionary <string, string> args = null, NameValueCollection headers = null,
                              CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
 {
     return(SendRequest(method, url, (Stream)null, null, args, headers, cookies, responseType));
 }
コード例 #37
0
 public WebResponseContent OK(ResponseType responseType)
 {
     return(Set(responseType, true));
 }
コード例 #38
0
ファイル: Uploader.cs プロジェクト: McoreD/ShareX.Wpf
        protected UploadResult UploadData(Stream dataStream, string url, string fileName, string fileFormName = "file", Dictionary <string, string> arguments = null,
                                          NameValueCollection headers = null, CookieCollection cookies         = null, ResponseType responseType = ResponseType.Text, HttpMethod method = HttpMethod.POST,
                                          string requestContentType   = "multipart/form-data", string metadata = null)
        {
            UploadResult result = new UploadResult();

            IsUploading         = true;
            StopUploadRequested = false;

            try
            {
                string boundary = CreateBoundary();

                byte[] bytesArguments = MakeInputContent(boundary, arguments, false);
                byte[] bytesDataOpen;
                byte[] bytesDataDatafile = { };

                if (metadata != null)
                {
                    bytesDataOpen     = MakeFileInputContentOpen(boundary, fileFormName, fileName, metadata);
                    bytesDataDatafile = MakeFileInputContentOpen(boundary, fileFormName, fileName, null);
                }
                else
                {
                    bytesDataOpen = MakeFileInputContentOpen(boundary, fileFormName, fileName);
                }

                byte[] bytesDataClose = MakeFileInputContentClose(boundary);

                long           contentLength = bytesArguments.Length + bytesDataOpen.Length + bytesDataDatafile.Length + dataStream.Length + bytesDataClose.Length;
                HttpWebRequest request       = PrepareDataWebRequest(url, boundary, contentLength, requestContentType, cookies, headers, method);

                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(bytesArguments, 0, bytesArguments.Length);
                    requestStream.Write(bytesDataOpen, 0, bytesDataOpen.Length);
                    requestStream.Write(bytesDataDatafile, 0, bytesDataDatafile.Length);
                    if (!TransferData(dataStream, requestStream))
                    {
                        return(null);
                    }
                    requestStream.Write(bytesDataClose, 0, bytesDataClose.Length);
                }

                result.Response  = ResponseToString(request.GetResponse(), responseType);
                result.IsSuccess = true;
            }
            catch (Exception e)
            {
                if (!StopUploadRequested)
                {
                    if (WebExceptionThrow && e is WebException)
                    {
                        throw;
                    }

                    string response = AddWebError(e);

                    if (WebExceptionReturnResponse && e is WebException)
                    {
                        result.Response = response;
                    }
                }
            }
            finally
            {
                currentRequest = null;
                IsUploading    = false;
            }

            return(result);
        }
コード例 #39
0
ファイル: EsbService.cs プロジェクト: RENSting/cnf.esb
 public RawResponse(WebResponse response, string requestUrl)
 {
     _requestUrl = requestUrl;
     _response   = response;
     _type       = ResponseType.WebResponse;
 }
コード例 #40
0
 /// <summary>
 /// Initialises a new instance of the <see cref="BadRequestException"/> class.
 /// </summary>
 /// <param name="caasOperationResponse">
 /// The caa operation response.
 /// </param>
 /// <param name="uri">
 /// The uri.
 /// </param>
 public BadRequestException(ResponseType caasOperationResponse, Uri uri)
     : base(ComputeApiError.BadRequest, caasOperationResponse, uri)
 {
 }
コード例 #41
0
ファイル: TicketList.cs プロジェクト: pauloalcobia/logicPOS
        //Payments and SplitAccount (Shared for Both Actions)
        void _buttonKeyPayments_Clicked(object sender, EventArgs e)
        {
            TouchButtonIconWithText button = (sender as TouchButtonIconWithText);

            try
            {
                //Used when we pay without FinishOrder, to Skip print Ticket
                bool printTicket = false;

                //Request Finish Open Ticket
                if (_listStoreModelTotalItemsTicketListMode > 0)
                {
                    ResponseType dialogResponse = Utils.ShowMessageTouch(_sourceWindow, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.OkCancel, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_dialog_message_dialog"), resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_request_close_open_ticket"));
                    if (dialogResponse != ResponseType.Ok)
                    {
                        return;
                    }
                    ;
                }
                ;

                //Get Reference to current OrderMain
                OrderMain orderMain = GlobalFramework.SessionApp.OrdersMain[GlobalFramework.SessionApp.CurrentOrderMainOid];

                //Finish Order, if Has Ticket Details
                if (orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails.Lines.Count > 0)
                {
                    //Before Use FrameworkCall
                    orderMain.FinishOrder(GlobalFramework.SessionXpo, printTicket);
                    //TODO: Continue to implement FrameworkCall here
                    //DocumentOrderTicket documentOrderTicket = orderMain.FinishOrder(GlobalFramework.SessionXpo, printTicket);
                    //if (printTicket) FrameworkCalls.PrintTableTicket(_sourceWindow, GlobalFramework.LoggedTerminal.Printer, GlobalFramework.LoggedTerminal.TemplateTicket, orderMain, documentOrderTicket.Oid);

                    //Reset TicketList TotalItems Counter
                    _listStoreModelTotalItemsTicketListMode = 0;
                }

                //Always Change to OrderMain ListMode before Update Model
                _listMode = TicketListMode.OrderMain;

                //Update Model and Gui
                UpdateModel();
                UpdateOrderStatusBar();
                UpdateTicketListOrderButtons();

                //Initialize ArticleBag to Send to Payment Dialog
                ArticleBag articleBag = ArticleBag.TicketOrderToArticleBag(orderMain);

                // Shared Referencesfor Dialog
                PosBaseDialog dialog = null;

                // Get Dialog Reference
                if (button.Name.Equals("touchButtonPosTicketPadPayments_Green"))
                {
                    dialog = new PosPaymentsDialog(_sourceWindow, DialogFlags.DestroyWithParent, articleBag);
                }
                else
                if (button.Name.Equals("touchButtonPosTicketPadSplitAccount_Green"))
                {
                    dialog = new PosSplitPaymentsDialog(_sourceWindow, DialogFlags.DestroyWithParent, _articleBag, this);
                }

                // Shared code to call Both Dialogs
                ResponseType response = (ResponseType)dialog.Run();

                if (response == ResponseType.Ok)
                {
                    //Update Cleaned TreeView Model
                    UpdateModel();
                    UpdateOrderStatusBar();
                    UpdateTicketListOrderButtons();
                    //IMPORTANT & REQUIRED: Assign Current Order Details from New CurrentTicketId, ELSE we cant add items to OrderMain
                    CurrentOrderDetails = orderMain.OrderTickets[orderMain.CurrentTicketId].OrderDetails;
                    //Valid Result Destroy Dialog
                    dialog.Destroy();
                }
                ;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }
        }
コード例 #42
0
 public BaseResponse(ResponseType responseType, bool checksumValid)
 {
     this.ResponseType  = responseType;
     this.ChecksumValid = checksumValid;
 }
コード例 #43
0
ファイル: Extentions.cs プロジェクト: Lokukarawita/YifyLib
 public static Uri ToRequestUri(this RequestUriHelper reqType, string baseUri, ResponseType respt)
 {
     return(RequestUriHelper.GetUri(new Uri(baseUri, UriKind.Relative), respt, reqType));
 }
コード例 #44
0
ファイル: Uploader.cs プロジェクト: McoreD/ShareX.Wpf
 protected string SendRequestStream(string url, Stream stream, string contentType, NameValueCollection headers = null,
                                    CookieCollection cookies = null, HttpMethod method = HttpMethod.POST, ResponseType responseType = ResponseType.Text)
 {
     using (HttpWebResponse response = GetResponse(url, stream, null, contentType, headers, cookies, method))
     {
         return(ResponseToString(response, responseType));
     }
 }
コード例 #45
0
ファイル: Extentions.cs プロジェクト: Lokukarawita/YifyLib
 public static Uri ToRequestUri(this RequestUriHelper reqType, Uri baseUri, ResponseType respt)
 {
     return(RequestUriHelper.GetUri(baseUri, respt, reqType));
 }
コード例 #46
0
ファイル: Uploader.cs プロジェクト: luandev/ShareX
        protected UploadResult SendRequestFileRange(string url, Stream data, string fileName, long contentPosition = 0, long contentLength = -1,
                                                    Dictionary <string, string> args = null, NameValueCollection headers = null, CookieCollection cookies = null, ResponseType responseType = ResponseType.Text,
                                                    HttpMethod method = HttpMethod.PUT)
        {
            UploadResult result = new UploadResult();

            IsUploading         = true;
            StopUploadRequested = false;

            try
            {
                url = URLHelpers.CreateQuery(url, args);

                if (contentLength == -1)
                {
                    contentLength = data.Length;
                }
                contentLength = Math.Min(contentLength, data.Length - contentPosition);

                string contentType = Helpers.GetMimeType(fileName);

                if (headers == null)
                {
                    headers = new NameValueCollection();
                }
                long startByte  = contentPosition;
                long endByte    = startByte + contentLength - 1;
                long dataLength = data.Length;
                headers.Add("Content-Range", $"bytes {startByte}-{endByte}/{dataLength}");

                HttpWebRequest request = CreateWebRequest(method, url, headers, cookies, contentType, contentLength);

                using (Stream requestStream = request.GetRequestStream())
                {
                    if (!TransferData(data, requestStream, contentPosition, contentLength))
                    {
                        return(null);
                    }
                }

                using (WebResponse response = request.GetResponse())
                {
                    result.Response = ResponseToString(response, responseType);
                }

                result.IsSuccess = true;
            }
            catch (Exception e)
            {
                if (!StopUploadRequested)
                {
                    string response = AddWebError(e, url);

                    if (ReturnResponseOnError && e is WebException)
                    {
                        result.Response = response;
                    }
                }
            }
            finally
            {
                currentRequest = null;
                IsUploading    = false;

                if (VerboseLogs && !string.IsNullOrEmpty(VerboseLogsPath))
                {
                    WriteVerboseLog(url, args, headers, result.Response);
                }
            }

            return(result);
        }
コード例 #47
0
 public WebResponseContent Error(ResponseType responseType)
 {
     return(Set(responseType, false));
 }
コード例 #48
0
        public static void Initialize(IApplicationContext context)
        {
            if (!context.EnsureCreated())
            {
                return; //db was already created or error occurred
            }
            var confirmed = new UserStatusType
            {
                Name        = "Confirmed",
                Description = "The user has confirmed their email is active and is ready for opportunities.",
                CanApply    = true
            };
            var userStatusTypes = new List <UserStatusType>
            {
                new UserStatusType
                {
                    Name        = "Submitted",
                    Description = "The user has signed up and needs to confirm their email is active and receiving messages from the system."
                },
                confirmed,
                new UserStatusType
                {
                    Name        = "Banned",
                    Description = "The user has been banned from any opportunities."
                }
            };

            context.UserStatusTypes.AddRange(userStatusTypes);
            context.SaveChanges();

            //add user
            var robsmitha = new User
            {
                GitHubLogin      = "******",
                UserStatusTypeID = confirmed.ID
            };

            context.Users.Add(robsmitha);
            context.SaveChanges();

            //add company
            var gitCandidates = new Company
            {
                GitHubLogin = "******"
            };

            context.Companies.Add(gitCandidates);
            context.SaveChanges();

            #region Response types
            var textResponse = new ResponseType
            {
                Name        = "TextResponse",
                Description = "A write in response question that renders a text input field.",
                Input       = "text"
            };
            var numberResponse = new ResponseType
            {
                Name        = "NumberResponse",
                Description = "A write in response question that renders a number input field.",
                Input       = "number"
            };
            var yesNo = new ResponseType
            {
                Name        = "YesNo",
                Description = "A yes/no question that renders two yes/mp radio buttons.",
                Input       = "radio"
            };
            context.ResponseTypes.Add(yesNo);
            context.ResponseTypes.Add(numberResponse);
            context.ResponseTypes.Add(textResponse);
            context.SaveChanges();
            #endregion

            #region Validation rules
            var isRequired = new ValidationRule
            {
                Name        = "Is Required",
                Description = "The field in requierd",
                Key         = "isRequired"
            };
            var minLength = new ValidationRule
            {
                Name        = "Minimum Length",
                Description = "The field has a minimum length",
                Key         = "minLength"
            };
            var maxLength = new ValidationRule
            {
                Name        = "Maximum Length",
                Description = "The field has a maximum length",
                Key         = "maxLength"
            };
            context.ValidationRules.Add(isRequired);
            context.ValidationRules.Add(minLength);
            context.ValidationRules.Add(maxLength);
            context.SaveChanges();
            #endregion

            #region Yes/No test question
            var yesNoQ = new Question
            {
                Label          = "Are you authorized to work in the U.S.?",
                CompanyID      = gitCandidates.ID,
                ResponseTypeID = yesNo.ID
            };
            context.Questions.Add(yesNoQ);
            context.SaveChanges();
            var yesNoQYes = new QuestionResponse
            {
                Answer       = "Yes",
                QuestionID   = yesNoQ.ID,
                DisplayOrder = 1
            };
            var yesNoQNo = new QuestionResponse
            {
                Answer       = "No",
                QuestionID   = yesNoQ.ID,
                DisplayOrder = 2
            };
            context.QuestionResponses.Add(yesNoQYes);
            context.QuestionResponses.Add(yesNoQNo);
            context.SaveChanges();

            var yesNoQValidationIsRequired = new QuestionValidation
            {
                QuestionID       = yesNoQ.ID,
                ValidationRuleID = isRequired.ID,
            };
            context.QuestionValidations.Add(yesNoQValidationIsRequired);
            context.SaveChanges();
            #endregion

            #region Write in test question
            var numberResponseQ = new Question
            {
                Label          = "How many years have you professionaly developed software?",
                CompanyID      = gitCandidates.ID,
                ResponseTypeID = numberResponse.ID,
                Placeholder    = "Years of experience",
                Minimum        = 0,
                Maximum        = 99
            };
            context.Questions.Add(numberResponseQ);
            context.SaveChanges();

            var numberResponseQValidationIsRequired = new QuestionValidation
            {
                QuestionID          = numberResponseQ.ID,
                ValidationRuleID    = isRequired.ID,
                ValidationRuleValue = "true"
            };
            var numberResponseQValidationMaxLength = new QuestionValidation
            {
                QuestionID          = numberResponseQ.ID,
                ValidationRuleID    = maxLength.ID,
                ValidationRuleValue = "2"
            };
            context.QuestionValidations.Add(numberResponseQValidationIsRequired);
            context.QuestionValidations.Add(numberResponseQValidationMaxLength);
            context.SaveChanges();

            #endregion

            #region Add jobs
            var jobApplicationStatusTypes = new List <JobApplicationStatusType>
            {
                new JobApplicationStatusType
                {
                    Name                = "Submitted",
                    Description         = "The application has been submitted.",
                    IsActiveApplication = true
                },
                new JobApplicationStatusType
                {
                    Name                = "Under Review",
                    Description         = "The application is under review.",
                    IsActiveApplication = true
                },
                new JobApplicationStatusType
                {
                    Name                = "Under Consideration",
                    Description         = "The application is under review by the company.",
                    IsActiveApplication = true
                },
                new JobApplicationStatusType
                {
                    Name                = "Scheduling Interview",
                    Description         = "The an interview is being schedules.",
                    IsActiveApplication = true
                },
                new JobApplicationStatusType
                {
                    Name        = "No Longer Under Consideration",
                    Description = "The application is no longer being reviewed."
                },
                new JobApplicationStatusType
                {
                    Name        = "Withdrawn",
                    Description = "The application has been withdrawn by the user."
                }
            };
            context.JobApplicationStatusTypes.AddRange(jobApplicationStatusTypes);
            context.SaveChanges();

            var intern = new SeniorityLevel
            {
                Name        = "Intern",
                Description = "Internship level"
            };
            var entry = new SeniorityLevel
            {
                Name        = "Entry",
                Description = "Entry level"
            };
            var midLvl = new SeniorityLevel
            {
                Name        = "Mid-level",
                Description = "Middle level"
            };
            var seniorLvl = new SeniorityLevel
            {
                Name        = "Senior",
                Description = "Senior level"
            };
            var lead = new SeniorityLevel
            {
                Name        = "Lead",
                Description = "Senior level"
            };
            var architect = new SeniorityLevel
            {
                Name        = "Architect",
                Description = "Architect level"
            };
            context.SeniorityLevels.AddRange(new [] { intern, entry, midLvl, seniorLvl, lead, architect });
            var fullTime = new JobType
            {
                Name        = "Full-time",
                Description = "Full-time"
            };
            var partTime = new JobType
            {
                Name        = "Part-time",
                Description = "Part-time"
            };
            var contract = new JobType
            {
                Name        = "Contract",
                Description = "Contract"
            };
            context.JobTypes.AddRange(new[] { fullTime, partTime, contract });
            context.SaveChanges();

            var postHTML  = "<h4 id=&quot;summary&quot;>Job Summary</h4> <p>We develop a .NET software application implements a Domain Driven Design (DDD) pattern to help solve enterprise level problems.</p><p>We're looking for talented engineers to join our team.</p><strong>If this job sounds like you apply today!</strong>";
            var fullstack = new Job
            {
                Name             = "Full Stack Engineer",
                Description      = "A .NET MVC frontend and MSSQL backend",
                CompanyID        = gitCandidates.ID,
                UserID           = robsmitha.ID,
                PostAt           = DateTime.Now.AddMinutes(5),
                PostHTML         = postHTML,
                AllowRemote      = false,
                TeamSize         = "10-50 People",
                MinSalary        = 90000,
                MaxSalary        = 120000,
                Travel           = "No",
                SeniorityLevelID = midLvl.ID,
                JobTypeID        = fullTime.ID,
            };
            var frontend = new Job
            {
                Name             = "Front End Engineer",
                Description      = "A frontend in ReactJS with Bootstrap4.",
                CompanyID        = gitCandidates.ID,
                PostAt           = DateTime.Now.AddDays(-2),
                UserID           = robsmitha.ID,
                PostHTML         = postHTML,
                AllowRemote      = true,
                TeamSize         = "1-10 People",
                MinSalary        = 70000,
                MaxSalary        = 86000,
                Travel           = "No",
                SeniorityLevelID = entry.ID,
                JobTypeID        = partTime.ID,
            };
            var senior = new Job
            {
                Name             = "Senior Software Architect",
                Description      = "Senior Architect Angular frontend and CockroachDB backend",
                CompanyID        = gitCandidates.ID,
                PostAt           = DateTime.Now.AddDays(-4),
                UserID           = robsmitha.ID,
                PostHTML         = postHTML,
                AllowRemote      = false,
                TeamSize         = "50-100 People",
                MinSalary        = 75000,
                MaxSalary        = 96000,
                Travel           = "No",
                SeniorityLevelID = seniorLvl.ID,
                JobTypeID        = fullTime.ID,
            };
            var cloud = new Job
            {
                Name             = "Cloud Engineer",
                Description      = "Create and manage CI/CD pipelines and infrastructure.",
                CompanyID        = gitCandidates.ID,
                PostAt           = DateTime.Now.AddDays(-8),
                UserID           = robsmitha.ID,
                PostHTML         = postHTML,
                AllowRemote      = false,
                TeamSize         = "50-100 People",
                MinSalary        = 65000,
                MaxSalary        = 86000,
                Travel           = "No",
                SeniorityLevelID = lead.ID,
                JobTypeID        = fullTime.ID,
            };
            var jobs = new List <Job>
            {
                fullstack, frontend, senior, cloud
            };
            context.Jobs.AddRange(jobs);
            context.SaveChanges();


            var frontendLocations = new List <JobLocation>
            {
                new JobLocation
                {
                    City = "Tampa",
                    StateAbbreviation = "FL",
                    Latitude          = 27.950575,
                    Longitude         = -82.457176,
                    JobID             = frontend.ID
                },
                new JobLocation
                {
                    City = "Tallahassee",
                    StateAbbreviation = "FL",
                    Latitude          = 30.455000,
                    Longitude         = -84.253334,
                    JobID             = frontend.ID
                },
            };

            var cloudLocations = new List <JobLocation>
            {
                new JobLocation
                {
                    City = "Tallahassee",
                    StateAbbreviation = "FL",
                    Latitude          = 30.455000,
                    Longitude         = -84.253334,
                    JobID             = cloud.ID
                },
                new JobLocation
                {
                    City = "New York",
                    StateAbbreviation = "NY",
                    Latitude          = 40.712776,
                    Longitude         = -74.005974,
                    JobID             = cloud.ID
                },
            };

            var jobLocations = new List <JobLocation>
            {
                new JobLocation
                {
                    City = "Beverly Hills",
                    StateAbbreviation = "CA",
                    Latitude          = 34.077200,
                    Longitude         = -118.422450,
                    JobID             = fullstack.ID
                },
                new JobLocation
                {
                    City = "Redmond",
                    StateAbbreviation = "WA",
                    Latitude          = 47.751076,
                    Longitude         = -120.740135,
                    JobID             = senior.ID
                }
            };

            jobLocations.AddRange(frontendLocations);
            jobLocations.AddRange(cloudLocations);
            context.JobLocations.AddRange(jobLocations);
            foreach (var job in jobs)
            {
                context.JobApplicationQuestions.AddRange(new[] {
                    new JobApplicationQuestion
                    {
                        JobID        = job.ID,
                        QuestionID   = yesNoQ.ID,
                        DisplayOrder = 1,
                    },
                    new JobApplicationQuestion
                    {
                        JobID        = job.ID,
                        QuestionID   = numberResponseQ.ID,
                        DisplayOrder = 2
                    }
                });
                context.JobBenefits.AddRange(new[] {
                    new JobBenefit
                    {
                        JobID       = job.ID,
                        Name        = "Exciting open source projects",
                        Description = "We don’t work on dull and boring projects. Ever."
                    },
                    new JobBenefit
                    {
                        JobID       = job.ID,
                        Name        = "Flexible working hours",
                        Description = "Possibility for remote work, home office, and flexible hours during the day."
                    },
                    new JobBenefit
                    {
                        JobID       = job.ID,
                        Name        = "Learning and development",
                        Description = "Subsidized conferences, classes, and events."
                    },
                    new JobBenefit
                    {
                        JobID       = job.ID,
                        Name        = "Health & vision insurance",
                        Description = "Health and vision insurance."
                    }
                });
                context.JobRequirements.AddRange(new[] {
                    new JobRequirement
                    {
                        JobID       = job.ID,
                        Name        = "Programming experience",
                        Description = "We are looking for people who are familiar with or want to learn .NET quickly'",
                    },
                    new JobRequirement
                    {
                        JobID       = job.ID,
                        Name        = "Flexibility",
                        Description = "A quick learner who can and wants to switch between programming languages depending on project requirements."
                    },
                    new JobRequirement
                    {
                        JobID       = job.ID,
                        Name        = "Problem solver",
                        Description = "We appreciate people who work smart – and hard."
                    }
                });
                context.JobResponsibilities.AddRange(new[] {
                    new JobResponsibility
                    {
                        JobID       = job.ID,
                        Name        = "Design and build",
                        Description = "Design and implement new features and enhance existing functionalities according to business specifications.",
                    },
                    new JobResponsibility
                    {
                        JobID       = job.ID,
                        Name        = "Ownership",
                        Description = "Participate in the whole sprint process for product development."
                    },
                    new JobResponsibility
                    {
                        JobID       = job.ID,
                        Name        = "Coding standards",
                        Description = "Ensure that your code meets software development and quality standards and fits into the continuous release process."
                    }
                });
                context.JobMethods.AddRange(new[] {
                    new JobMethod
                    {
                        JobID       = job.ID,
                        Name        = "Agile software development",
                        Description = "We are agile software developers.",
                    },
                    new JobMethod
                    {
                        JobID       = job.ID,
                        Name        = "SCRUM lifecycles",
                        Description = "We iterate SCRUM lifecycles to develop our software."
                    },
                    new JobMethod
                    {
                        JobID       = job.ID,
                        Name        = "CI/CD",
                        Description = "Continuous integration and deployment."
                    }
                });
            }

            var cSharp = new Skill
            {
                Name        = "C#",
                Description = "C# progamming language"
            };
            var javaScript = new Skill
            {
                Name        = "JavaScript",
                Description = "JavaScript progamming language"
            };
            var sfrontend = new Skill
            {
                Name        = "Frontend",
                Description = "Frontend development"
            };
            var sbackend = new Skill
            {
                Name        = "Backend",
                Description = "Backend development"
            };
            var html = new Skill
            {
                Name        = "HTML",
                Description = "HTML"
            };
            var css = new Skill
            {
                Name        = "CSS",
                Description = "CSS"
            };
            context.Skills.AddRange(new List <Skill>
            {
                cSharp,
                javaScript,
                sfrontend,
                sbackend,
                html,
                css,
            });
            context.SaveChanges();

            context.JobSkills.AddRange(new []
            {
                //frontend
                new JobSkill
                {
                    JobID   = frontend.ID,
                    SkillID = html.ID
                },
                new JobSkill
                {
                    JobID   = frontend.ID,
                    SkillID = css.ID
                },
                new JobSkill
                {
                    JobID   = frontend.ID,
                    SkillID = sfrontend.ID
                },
                //sr developer
                new JobSkill
                {
                    JobID   = senior.ID,
                    SkillID = sbackend.ID
                },
                new JobSkill
                {
                    JobID   = senior.ID,
                    SkillID = cSharp.ID
                },
                new JobSkill
                {
                    JobID   = senior.ID,
                    SkillID = javaScript.ID
                },
                //cloud
                new JobSkill
                {
                    JobID   = cloud.ID,
                    SkillID = sbackend.ID
                },
                new JobSkill
                {
                    JobID   = cloud.ID,
                    SkillID = cSharp.ID
                },
                //full stack
                new JobSkill
                {
                    JobID   = fullstack.ID,
                    SkillID = html.ID
                },
                new JobSkill
                {
                    JobID   = fullstack.ID,
                    SkillID = css.ID
                },
                new JobSkill
                {
                    JobID   = fullstack.ID,
                    SkillID = sfrontend.ID
                },
                new JobSkill
                {
                    JobID   = fullstack.ID,
                    SkillID = sbackend.ID
                },
                new JobSkill
                {
                    JobID   = fullstack.ID,
                    SkillID = cSharp.ID
                },
                new JobSkill
                {
                    JobID   = fullstack.ID,
                    SkillID = javaScript.ID
                },
            });



            context.SaveChanges();
            #endregion
        }
コード例 #49
0
 /// <summary/>
 public ImportChargesResponse(ResponseType config, ImportProtocolType[] importProtocol)
     : base(config, importProtocol)
 {
 }
コード例 #50
0
 public VoiceDevicesEventArgs(ResponseType type, int rcode, int scode, string text, string current, List <string> avail) :
     base(type, rcode, scode, text)
 {
     m_CurrentDevice = current;
     m_Available     = avail;
 }
コード例 #51
0
ファイル: XQApi.cs プロジェクト: heerheer/Native.XQ
 /// <summary>
 /// 处理群申请
 /// </summary>
 /// <param name="robotQQ"></param>
 /// <param name="type"></param>
 /// <param name="qq"></param>
 /// <param name="group"></param>
 /// <param name="seq"></param>
 /// <param name="rtype"></param>
 /// <param name="msg"></param>
 public void HanldeGroupEvent(string robotQQ, int type, string qq, string group, string seq, ResponseType rtype, string msg = "")
 {
     XQDLL.Api_HandleGroupEvent(robotQQ, type, qq, group, seq, (int)rtype, msg);
 }
コード例 #52
0
ファイル: Uploader.cs プロジェクト: luandev/ShareX
        protected UploadResult SendRequestFile(string url, Stream data, string fileName, string fileFormName = "file", Dictionary <string, string> args = null,
                                               NameValueCollection headers = null, CookieCollection cookies                = null, ResponseType responseType = ResponseType.Text, HttpMethod method = HttpMethod.POST,
                                               string contentType          = ContentTypeMultipartFormData, string metadata = null)
        {
            UploadResult result = new UploadResult();

            IsUploading         = true;
            StopUploadRequested = false;

            try
            {
                string boundary = CreateBoundary();
                contentType += "; boundary=" + boundary;

                byte[] bytesArguments = MakeInputContent(boundary, args, false);
                byte[] bytesDataOpen;
                byte[] bytesDataDatafile = { };

                if (metadata != null)
                {
                    bytesDataOpen     = MakeFileInputContentOpen(boundary, fileFormName, fileName, metadata);
                    bytesDataDatafile = MakeFileInputContentOpen(boundary, fileFormName, fileName, null);
                }
                else
                {
                    bytesDataOpen = MakeFileInputContentOpen(boundary, fileFormName, fileName);
                }

                byte[] bytesDataClose = MakeFileInputContentClose(boundary);

                long contentLength = bytesArguments.Length + bytesDataOpen.Length + bytesDataDatafile.Length + data.Length + bytesDataClose.Length;

                HttpWebRequest request = CreateWebRequest(method, url, headers, cookies, contentType, contentLength);

                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(bytesArguments, 0, bytesArguments.Length);
                    requestStream.Write(bytesDataOpen, 0, bytesDataOpen.Length);
                    requestStream.Write(bytesDataDatafile, 0, bytesDataDatafile.Length);
                    if (!TransferData(data, requestStream))
                    {
                        return(null);
                    }
                    requestStream.Write(bytesDataClose, 0, bytesDataClose.Length);
                }

                using (WebResponse response = request.GetResponse())
                {
                    result.Response = ResponseToString(response, responseType);
                }

                result.IsSuccess = true;
            }
            catch (Exception e)
            {
                if (!StopUploadRequested)
                {
                    string response = AddWebError(e, url);

                    if (ReturnResponseOnError && e is WebException)
                    {
                        result.Response = response;
                    }
                }
            }
            finally
            {
                currentRequest = null;
                IsUploading    = false;

                if (VerboseLogs && !string.IsNullOrEmpty(VerboseLogsPath))
                {
                    WriteVerboseLog(url, args, headers, result.Response);
                }
            }

            return(result);
        }
コード例 #53
0
ファイル: XQApi.cs プロジェクト: heerheer/Native.XQ
 /// <summary>
 /// 处理好友申请
 /// </summary>
 /// <param name="robotQQ"></param>
 /// <param name="qq"></param>
 /// <param name="rtype"></param>
 /// <param name="msg"></param>
 public void HanldeFriendEvent(string robotQQ, string qq, ResponseType rtype, string msg = "")
 {
     XQDLL.Api_HandleFriendEvent(robotQQ, qq, (int)rtype, msg);
 }
コード例 #54
0
 public Response(ResponseType type) : this(string.Empty, type)
 {
 }
コード例 #55
0
 /// <summary>
 /// Build authentication link.
 /// </summary>
 /// <param name="instagramOAuthUri">The instagram o authentication URI.</param>
 /// <param name="clientId">The client identifier.</param>
 /// <param name="callbackUri">The callback URI.</param>
 /// <param name="scopes">The scopes.</param>
 /// <param name="responseType">Type of the response.</param>
 /// <returns>The authentication uri</returns>
 private static string BuildAuthUri(string instagramOAuthUri, string clientId, string callbackUri, ResponseType responseType, string scopes)
 {
     return(string.Format("{0}?client_id={1}&redirect_uri={2}&response_type={3}&scope={4}", new object[] {
         instagramOAuthUri.ToLower(),
         clientId.ToLower(),
         callbackUri,
         responseType.ToString().ToLower(),
         scopes.ToLower()
     }));
 }
コード例 #56
0
        private SamlBodyResponse ProcessResponse(SamlBodyResponse samlBodyRes, XmlDocument xml, XmlReader reader)
        {
            // desserializar xml para ResponseType
            XmlSerializer serializer = new XmlSerializer(typeof(ResponseType));
            ResponseType  response   = (ResponseType)serializer.Deserialize(reader);

            // verificar validade temporal:
            int validTimeFrame = 5;

            if (Math.Abs(response.IssueInstant.Subtract(DateTime.UtcNow).TotalMinutes) > validTimeFrame)
            {
                return(AddResponseError(samlBodyRes, "SAML Response fora do intervalo de validade - validade da resposta: " + response.IssueInstant));
            }

            samlBodyRes.RelayState = Encoding.UTF8.GetString(Convert.FromBase64String(samlBodyRes.RelayState));

            if ("urn:oasis:names:tc:SAML:2.0:status:Success".Equals(response.Status.StatusCode.Value))
            {
                AssertionType assertion = new AssertionType();
                for (int i = 0; i < response.Items.Length; i++)
                {
                    if (response.Items[i].GetType() == typeof(AssertionType))
                    {
                        assertion = (AssertionType)response.Items[i];
                        break;
                    }
                }

                // validade da asserção:
                DateTime now   = DateTime.UtcNow;
                TimeSpan tSpan = new TimeSpan(0, 0, 150); // 2,5 minutos
                if (now < assertion.Conditions.NotBefore.Subtract(tSpan) || now >= assertion.Conditions.NotOnOrAfter.Add(tSpan))
                {
                    // Asserção inválida
                    return(AddResponseError(samlBodyRes, "Asserções temporalmente inválidas."));
                }

                AttributeStatementType attrStatement = new AttributeStatementType();

                for (int i = 0; i < assertion.Items.Length; i++)
                {
                    if (assertion.Items[i].GetType() == typeof(AttributeStatementType))
                    {
                        attrStatement = (AttributeStatementType)assertion.Items[i];
                        break;
                    }
                }

                foreach (object obj in attrStatement.Items)
                {
                    AttributeType attr = (AttributeType)obj;

                    samlBodyRes.IdentityAttributes = new Dictionary <string, string>();

                    if (attr.AnyAttr != null)
                    {
                        for (int i = 0; i < attr.AnyAttr.Length; i++)
                        {
                            XmlAttribute xa = attr.AnyAttr[i];
                            if (xa.LocalName.Equals("AttributeStatus") && xa.Value.Equals("Available"))
                            {
                                if (attr.AttributeValue != null && attr.AttributeValue.Length > 0)
                                {
                                    foreach (var itemAttr in attr.AttributeValue)
                                    {
                                        samlBodyRes.IdentityAttributes.Add((string)attr.Name, (string)attr.AttributeValue[0]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                //bad result
                if (response.Status.StatusMessage.Equals("urn:oasis:names:tc:SAML:2.0:status:AuthnFailed (User has canceled the process of obtaining attributes)."))
                {
                    return(AddResponseError(samlBodyRes, "Autenticação não autorizada pelo utilizador"));
                }

                return(AddResponseError(samlBodyRes, "urn:oasis:names:tc:SAML:2.0:status:" + response.Status.StatusCode.Value));
            }

            samlBodyRes.Success = true;
            samlBodyRes.Action  = Enums.SamlResponseAction.Login;

            var strCipher = new StringCipher();

            System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("pt-PT");

            var tokenDateValid = DateTime.UtcNow.AddSeconds(TokenTimeValueConfig).ToString(cultureinfo);

            samlBodyRes.AuthToken = strCipher.Encrypt($"{samlBodyRes.IdentityAttributes.FirstOrDefault().Value}%{tokenDateValid}");

            return(samlBodyRes);
        }
コード例 #57
0
 protected override void OnResponse(ResponseType resp)
 {
     base.OnResponse(resp);
     DetachWidgets();
 }
コード例 #58
0
        /// <summary>
        /// Authentications the link.
        /// </summary>
        /// <param name="instagramOAuthUri">The instagram o authentication URI.</param>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="callbackUri">The callback URI.</param>
        /// <param name="scopes">The scopes.</param>
        /// <param name="responseType">Type of the response.</param>
        /// <returns>The authentication url</returns>
        public static string AuthLink(string instagramOAuthUri, string clientId, string callbackUri, List <Scope> scopes, ResponseType responseType = ResponseType.Token)
        {
            var scopesForUri = BuildScopeForUri(scopes);

            return(BuildAuthUri(instagramOAuthUri, clientId, callbackUri, responseType, scopesForUri));
        }
コード例 #59
0
 void CompleteModal(ResponseType answer)
 {
     mIsCompleted = true;
     mAnswer      = answer;
 }
コード例 #60
0
    public int ImportFromFile(PhotoStore store, string path)
    {
        this.store = store;
        this.CreateDialog("import_dialog");

        this.Dialog.TransientFor   = main_window;
        this.Dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;
        this.Dialog.Response      += HandleDialogResponse;

        AllowFinish = false;

        this.Dialog.DefaultResponse = ResponseType.Ok;

        //import_folder_entry.Activated += HandleEntryActivate;
        recurse_check.Toggled += HandleRecurseToggled;
        copy_check.Toggled    += HandleRecurseToggled;

        menu = new SourceMenu(this);
        source_option_menu.Menu = menu;

        collection              = new FSpot.PhotoList(new Photo [0]);
        tray                    = new FSpot.ScalingIconView(collection);
        tray.Selection.Changed += HandleTraySelectionChanged;
        icon_scrolled.SetSizeRequest(200, 200);
        icon_scrolled.Add(tray);
        //icon_scrolled.Visible = false;
        tray.DisplayTags = false;
        tray.Show();

        photo_view = new FSpot.PhotoImageView(collection);
        photo_scrolled.Add(photo_view);
        photo_scrolled.SetSizeRequest(200, 200);
        photo_view.Show();

        //FSpot.Global.ModifyColors (frame_eventbox);
        FSpot.Global.ModifyColors(photo_scrolled);
        FSpot.Global.ModifyColors(photo_view);

        photo_view.Pixbuf = PixbufUtils.LoadFromAssembly("f-spot-48.png");
        photo_view.Fit    = true;

        tag_entry = new FSpot.Widgets.TagEntry(MainWindow.Toplevel.Database.Tags, false);
        tag_entry.UpdateFromTagNames(new string [] {});
        tagentry_box.Add(tag_entry);

        tag_entry.Show();

        this.Dialog.Show();
        //source_option_menu.Changed += HandleSourceChanged;
        if (path != null)
        {
            SetImportPath(path);
            int i = menu.FindItemPosition(path);

            if (i > 0)
            {
                source_option_menu.SetHistory((uint)i);
            }
            else if (Directory.Exists(path))
            {
                SourceItem path_item = new SourceItem(new VfsSource(path));
                menu.Prepend(path_item);
                path_item.ShowAll();
                SetImportPath(path);
                source_option_menu.SetHistory(0);
            }
            idle_start.Start();
        }

        ResponseType response = (ResponseType)this.Dialog.Run();

        while (response == ResponseType.Ok)
        {
            try {
                if (Directory.Exists(this.ImportPath))
                {
                    break;
                }
            } catch (System.Exception e) {
                System.Console.WriteLine(e);
                break;
            }

            HigMessageDialog md = new HigMessageDialog(this.Dialog,
                                                       DialogFlags.DestroyWithParent,
                                                       MessageType.Error,
                                                       ButtonsType.Ok,
                                                       Catalog.GetString("Directory does not exist."),
                                                       String.Format(Catalog.GetString("The directory you selected \"{0}\" does not exist.  " +
                                                                                       "Please choose a different directory"), this.ImportPath));

            md.Run();
            md.Destroy();

            response = (Gtk.ResponseType) this.Dialog.Run();
        }

        if (response == ResponseType.Ok)
        {
            this.UpdateTagStore(tag_entry.GetTypedTagNames());
            this.Finish();

            if (tags_selected != null && tags_selected.Count > 0)
            {
                for (int i = 0; i < collection.Count; i++)
                {
                    Photo p = collection [i] as Photo;

                    if (p == null)
                    {
                        continue;
                    }

                    p.AddTag((Tag [])tags_selected.ToArray(typeof(Tag)));
                    store.Commit(p);
                }
            }

            this.Dialog.Destroy();
            return(collection.Count);
        }
        else
        {
            this.Cancel();
            //this.Dialog.Destroy();
            return(0);
        }
    }