Beispiel #1
0
        /// <summary>
        /// 偏好菜单点击时
        /// </summary>
        private void Prefer_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem selectedItem = e.Source as MenuItem;

            Prefer prefer = (Prefer)Enum.Parse(typeof(Prefer), selectedItem.Header.ToString());

            PostDetail temp = this.Detail;

            temp.prefer = prefer;
            this.Detail = temp;

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

            foreach (var pd in ((this.Parent as Grid).Parent as PostInfoWindow).postInfoControl.tabControl.ItemsSource.Cast <PostDetail>())
            {
                temp        = pd;
                temp.prefer = prefer;
                list.Add(temp);
            }

            int selectedIndex = ((this.Parent as Grid).Parent as PostInfoWindow).postInfoControl.tabControl.SelectedIndex;

            ((this.Parent as Grid).Parent as PostInfoWindow).postInfoControl.tabControl.ItemsSource   = list;
            ((this.Parent as Grid).Parent as PostInfoWindow).postInfoControl.tabControl.SelectedIndex = selectedIndex;

            BLL.Preference.UpdatePrefer(Mode.Posts, this.Detail.file_md5, prefer);
        }
Beispiel #2
0
 public Requester(Uri baseUrl)
 {
     BaseUrl = baseUrl;
     UseFormatParameter = false;
     PreferredFormat = ResourceFormat.Xml;
     Timeout = 100 * 1000;       // Default timeout is 100 seconds            
     Prefer = Rest.Prefer.ReturnRepresentation;
 }
Beispiel #3
0
 public Requester(Uri baseUrl)
 {
     BaseUrl            = baseUrl;
     UseFormatParameter = false;
     PreferredFormat    = ResourceFormat.Xml;
     Timeout            = 100 * 1000; // Default timeout is 100 seconds
     Prefer             = Rest.Prefer.ReturnRepresentation;
 }
        protected bool PreferGetBool(string key, string trueValue = "true", bool defaultValue = true)
        {
            if (Prefer == null || !Prefer.ContainsKey(key))
            {
                return(defaultValue);
            }

            return(Prefer[key].Equals(trueValue, StringComparison.InvariantCultureIgnoreCase));
        }
        protected string PreferGet(string key, string defaultValue = null)
        {
            if (Prefer == null || !Prefer.ContainsKey(key))
            {
                return(defaultValue);
            }

            return(Prefer[key]);
        }
Beispiel #6
0
        private static void UpdatePrefer(ref List <PostDetail> list)
        {
            Prefer prefer = Preference.GetMD5Prefer(Mode.Posts, list[0].file_md5);

            for (int x = 0; x < list.Count; x++)
            {
                PostDetail pd = list[x];
                pd.prefer = prefer;
                list[x]   = pd;
            }
        }
Beispiel #7
0
        private void PreferCheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            List <Prefer> preferList = new List <Prefer>(this.PreferSelected);
            Prefer        selected   = (Prefer)Enum.Parse(typeof(Prefer), (sender as CheckBox).Content.ToString());

            if (preferList.Contains(selected))
            {
                preferList.Remove(selected);
            }

            this.PreferSelected = preferList.ToArray();
        }
        protected void PreferSet(string key, string value)
        {
            if (Prefer == null)
            {
                Prefer = new Dictionary <string, string>();
            }

            if (!Prefer.ContainsKey(key))
            {
                Prefer.Add(key, value);
            }
            else
            {
                Prefer[key] = value;
            }
        }
        public static HttpWebRequest ToHttpRequest(this Bundle.BundleEntryComponent entry, 
            Prefer bodyPreference, ResourceFormat format, bool useFormatParameter, out byte[] body)
        {
            System.Diagnostics.Debug.WriteLine("{0}: {1}", entry.Request.Method, entry.Request.Url);

            var interaction = entry.Request;
            body = null;

            if (entry.Resource != null && !(interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT))
                throw Error.InvalidOperation("Cannot have a body on an Http " + interaction.Method.ToString());

            var location = new RestUrl(interaction.Url);

            if (useFormatParameter)
                location.AddParam(HttpUtil.RESTPARAM_FORMAT, Hl7.Fhir.Rest.ContentType.BuildFormatParam(format));

            var request = (HttpWebRequest)HttpWebRequest.Create(location.Uri);
            request.Method = interaction.Method.ToString();
            setAgent(request, ".NET FhirClient for FHIR " + Model.ModelInfo.Version);

            if (!useFormatParameter)
                request.Accept = Hl7.Fhir.Rest.ContentType.BuildContentType(format, forBundle: false);

            if (interaction.IfMatch != null) request.Headers["If-Match"] = interaction.IfMatch;
            if (interaction.IfNoneMatch != null) request.Headers["If-None-Match"] = interaction.IfNoneMatch;
#if PORTABLE45
            if (interaction.IfModifiedSince != null) request.Headers["If-Modified-Since"] = interaction.IfModifiedSince.Value.UtcDateTime.ToString();
#else
            if (interaction.IfModifiedSince != null) request.IfModifiedSince = interaction.IfModifiedSince.Value.UtcDateTime;
#endif
            if (interaction.IfNoneExist != null) request.Headers["If-None-Exist"] = interaction.IfNoneExist;

            if (interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT)
            {
                if (bodyPreference == Prefer.ReturnMinimal)
                    request.Headers["Prefer"] = bodyPreference == Prefer.ReturnMinimal ? "return=minimal" : "return=representation";
            }

            if (entry.Resource != null) setBodyAndContentType(request, entry.Resource, format, out body);

            return request;
        }
Beispiel #10
0
        public void DeletePrefer(string pin, string user)
        {
            Prefer prefer = new Prefer
            {
                Id_pin  = getPinByName(pin),
                Id_user = getUserByName(user)
            };
            var id_prefer = from c in DataBase.Prefers.getAll() where c.Id_user == prefer.Id_user && c.Id_pin == prefer.Id_pin select c.Id;

            int id_pin = 0;

            foreach (int i in id_prefer)
            {
                id_pin = i;
            }
            if (id_pin != 0)
            {
                DataBase.Prefers.Delete(id_pin);
            }
        }
Beispiel #11
0
        public void AddPrefer(string title, string user)
        {
            Prefer prefer = new Prefer
            {
                Id_pin  = getPinByName(title),
                Id_user = getUserByName(user)
            };
            var id_prefer = from c in DataBase.Prefers.getAll() where c.Id_user == prefer.Id_user && c.Id_pin == prefer.Id_pin select c.Id;

            int id_pin = 0;

            foreach (int i in id_prefer)
            {
                id_pin = i;
            }

            if (id_pin == 0)
            {
                DataBase.Prefers.Create(prefer);
            }
        }
Beispiel #12
0
        /// <summary>
        /// 更新偏好信息
        /// </summary>
        /// <param name="mode">模式</param>
        /// <param name="file_md5">图片MD5</param>
        /// <param name="prefer"></param>
        /// <returns></returns>
        public static int UpdatePrefer(Mode mode, string file_md5, Prefer prefer)
        {
            string commandText = string.Empty;
            List <SQLiteParameter> paramList = new List <SQLiteParameter>();

            if (prefer == Prefer.Normal)
            {
                commandText = string.Format("DELETE FROM {0} WHERE file_md5 = @file_md5", mode.ToString());
                paramList.Add(new SQLiteParameter("@file_md5", file_md5));
            }
            else
            {
                commandText = string.Format("DELETE FROM {0} WHERE file_md5 = @file_md5;INSERT INTO {0} VALUES (@file_md5,@prefer)", mode.ToString());
                paramList.Add(new SQLiteParameter("@file_md5", file_md5));
                paramList.Add(new SQLiteParameter("@prefer", prefer.ToString("d")));
            }

            SQLiteCommand command = SQLiteHelper.CreateCommand(DBConn.prefer, commandText, paramList.ToArray());

            return(SQLiteHelper.ExecuteNonQuery(command));
        }
        public static HttpWebRequest ToHttpRequest(this Bundle.BundleEntryComponent entry, Prefer bodyPreference, ResourceFormat format, bool useFormatParameter)
        {
            System.Diagnostics.Debug.WriteLine("{0}: {1}", entry.Transaction.Method, entry.Transaction.Url);

            var interaction = entry.Transaction;

            if (entry.Resource != null && !(interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT))
            {
                throw Error.InvalidOperation("Cannot have a body on an Http " + interaction.Method.ToString());
            }

            var location = new RestUrl(interaction.Url);

            if (useFormatParameter)
            {
                location.AddParam(HttpUtil.RESTPARAM_FORMAT, Hl7.Fhir.Rest.ContentType.BuildFormatParam(format));
            }

            var request = (HttpWebRequest)HttpWebRequest.Create(location.Uri);

            request.Method = interaction.Method.ToString();
            setAgent(request, ".NET FhirClient for FHIR " + Model.ModelInfo.Version);

            if (!useFormatParameter)
            {
                request.Accept = Hl7.Fhir.Rest.ContentType.BuildContentType(format, forBundle: false);
            }

            if (interaction.IfMatch != null)
            {
                request.Headers["If-Match"] = interaction.IfMatch;
            }
            if (interaction.IfNoneMatch != null)
            {
                request.Headers["If-None-Match"] = interaction.IfNoneMatch;
            }
#if (PORTABLE45 || NETCOREAPP1_1)
            if (interaction.IfModifiedSince != null)
            {
                request.Headers["If-Modified-Since"] = interaction.IfModifiedSince.Value.UtcDateTime.ToString();
            }
#else
            if (interaction.IfModifiedSince != null)
            {
                request.IfModifiedSince = interaction.IfModifiedSince.Value.UtcDateTime;
            }
#endif
            if (interaction.IfNoneExist != null)
            {
                request.Headers["If-None-Exist"] = interaction.IfNoneExist;
            }

            if (interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT)
            {
                if (bodyPreference == Prefer.ReturnMinimal)
                {
                    request.Headers["Prefer"] = bodyPreference == Prefer.ReturnMinimal ? "return=minimal" : "return=representation";
                }
            }

            if (entry.Resource != null)
            {
                setBodyAndContentType(request, entry.Resource, format);
            }

            return(request);
        }
Beispiel #14
0
 public Profile GetProfile(Prefer prefer, [ScopedService] SocialAppGraphQLContext context)
 {
     return(context.Profiles.FirstOrDefault(p => p.PreferId == p.PreferId));
 }
        public static HttpWebRequest ToHttpRequest(this Bundle.EntryComponent entry,
                                                   Prefer bodyPreference, ResourceFormat format, bool useFormatParameter, bool CompressRequestBody, out byte[] body)
        {
            System.Diagnostics.Debug.WriteLine("{0}: {1}", entry.Request.Method, entry.Request.Url);

            var interaction = entry.Request;

            body = null;

            if (entry.Resource != null && !(interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT))
            {
                throw Error.InvalidOperation("Cannot have a body on an Http " + interaction.Method.ToString());
            }

            var location = new RestUrl(interaction.Url);

            if (useFormatParameter)
            {
                location.AddParam(HttpUtil.RESTPARAM_FORMAT, Hl7.Fhir.Rest.ContentType.BuildFormatParam(format));
            }

            var request = (HttpWebRequest)HttpWebRequest.Create(location.Uri);

            request.Method = interaction.Method.ToString();
            setAgent(request, ".NET FhirClient for FHIR " + Model.ModelInfo.Version);

            if (!useFormatParameter)
            {
                request.Accept = Hl7.Fhir.Rest.ContentType.BuildContentType(format, forBundle: false);
            }

            if (interaction.IfMatch != null)
            {
                request.Headers["If-Match"] = interaction.IfMatch;
            }
            if (interaction.IfNoneMatch != null)
            {
                request.Headers["If-None-Match"] = interaction.IfNoneMatch;
            }
#if DOTNETFW
            if (interaction.IfModifiedSince != null)
            {
                request.IfModifiedSince = interaction.IfModifiedSince.Value.UtcDateTime;
            }
#else
            if (interaction.IfModifiedSince != null)
            {
                request.Headers["If-Modified-Since"] = interaction.IfModifiedSince.Value.UtcDateTime.ToString();
            }
#endif
            if (interaction.IfNoneExist != null)
            {
                request.Headers["If-None-Exist"] = interaction.IfNoneExist;
            }

            if (interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT)
            {
                request.Headers["Prefer"] = bodyPreference == Prefer.ReturnMinimal ? "return=minimal" : "return=representation";
            }

            if (entry.Resource != null)
            {
                setBodyAndContentType(request, entry.Resource, format, CompressRequestBody, out body);
            }
            // PCL doesn't support setting the length (and in this case will be empty anyway)
#if DOTNETFW
            else
            {
                request.ContentLength = 0;
            }
#endif
            return(request);
        }
Beispiel #16
0
 /// <summary>
 /// 更新偏好信息
 /// </summary>
 /// <param name="mode">模式</param>
 /// <param name="file_md5">图片MD5</param>
 /// <param name="prefer"></param>
 /// <returns></returns>
 public static int UpdatePrefer(Mode mode, string file_md5, Prefer prefer)
 {
     return(DAL.Preference.UpdatePrefer(mode, file_md5, prefer));
 }
        public static HttpWebRequest ToHttpRequest(this Bundle.EntryComponent entry, Uri baseUrl,
                                                   Prefer bodyPreference, ResourceFormat format, bool useFormatParameter, bool CompressRequestBody, out byte[] body)
        {
            System.Diagnostics.Debug.WriteLine("{0}: {1}", entry.Request.Method, entry.Request.Url);

            var interaction = entry.Request;

            body = null;

            if (entry.Resource != null && !(interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT))
            {
                throw Error.InvalidOperation("Cannot have a body on an Http " + interaction.Method.ToString());
            }

            // Create an absolute uri when the interaction.Url is relative.
            var uri = new Uri(interaction.Url, UriKind.RelativeOrAbsolute);

            if (!uri.IsAbsoluteUri)
            {
                uri = HttpUtil.MakeAbsoluteToBase(uri, baseUrl);
            }
            var location = new RestUrl(uri);

            if (useFormatParameter)
            {
                location.AddParam(HttpUtil.RESTPARAM_FORMAT, Hl7.Fhir.Rest.ContentType.BuildFormatParam(format));
            }

            var request = (HttpWebRequest)HttpWebRequest.Create(location.Uri);

            request.Method = interaction.Method.ToString();
            setAgent(request, ".NET FhirClient for FHIR " + Model.ModelInfo.Version);

            if (!useFormatParameter)
            {
                request.Accept = Hl7.Fhir.Rest.ContentType.BuildContentType(format, forBundle: false);
            }

            if (interaction.IfMatch != null)
            {
                request.Headers["If-Match"] = interaction.IfMatch;
            }
            if (interaction.IfNoneMatch != null)
            {
                request.Headers["If-None-Match"] = interaction.IfNoneMatch;
            }
#if NETSTANDARD1_1
            if (interaction.IfModifiedSince != null)
            {
                request.Headers["If-Modified-Since"] = interaction.IfModifiedSince.Value.UtcDateTime.ToString();
            }
#else
            if (interaction.IfModifiedSince != null)
            {
                request.IfModifiedSince = interaction.IfModifiedSince.Value.UtcDateTime;
            }
#endif
            if (interaction.IfNoneExist != null)
            {
                request.Headers["If-None-Exist"] = interaction.IfNoneExist;
            }

            if (interaction.Method == Bundle.HTTPVerb.POST || interaction.Method == Bundle.HTTPVerb.PUT)
            {
                request.Headers["Prefer"] = bodyPreference == Prefer.ReturnMinimal ? "return=minimal" : "return=representation";
            }

            if (entry.Resource != null)
            {
                bool searchUsingPost =
                    interaction.Method == Bundle.HTTPVerb.POST &&
                    (entry.HasAnnotation <TransactionBuilder.InteractionType>() &&
                     entry.Annotation <TransactionBuilder.InteractionType>() == TransactionBuilder.InteractionType.Search) &&
                    entry.Resource is Parameters;

                setBodyAndContentType(request, entry.Resource, format, CompressRequestBody, searchUsingPost, out body);
            }
            // PCL doesn't support setting the length (and in this case will be empty anyway)
#if !NETSTANDARD1_1
            else
            {
                request.ContentLength = 0;
            }
#endif
            return(request);
        }