예제 #1
0
 public static void RemoveState(StorageKey key)
 {
     if (_userSettings.Contains(key.ToString()))
     {
         _userSettings.Remove(key.ToString());
     }
 }
예제 #2
0
 public static T LoadState <T>(StorageKey key) where T : class
 {
     if (_userSettings.Contains(key.ToString()))
     {
         return((T)_userSettings[key.ToString()]);
     }
     return(default(T));
 }
예제 #3
0
 public static T LoadState <T>(StorageKey key, T defaultValue) where T : class
 {
     if (_userSettings.Contains(key.ToString()))
     {
         var o = _userSettings[key.ToString()];
         return((T)o);
     }
     return(defaultValue);
 }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="requestedKey"></param>
        /// <returns></returns>
        private string GetRequestedKeyName(StorageKey requestedKey)
        {
            string requestedKeyName = requestedKey.ToString().ToUpper();

            requestedKeyName = requestedKeyName.Replace('-', '_');

            return(requestedKeyName);
        }
예제 #5
0
 public T Get <T>(StorageKey key)
 {
     try
     {
         return(_helper.Read(key.ToString(), default(T)));
     }
     catch (Exception)
     {
         return(default(T));
     }
 }
예제 #6
0
        public async Task <bool> SetObject(StorageKey key, Object obj)
        {
            try
            {
                string json = JsonConvert.SerializeObject(obj);
                Application.Current.Properties[key.ToString()] = json;
                await Application.Current.SavePropertiesAsync();

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
예제 #7
0
 public T GetObject <T>(StorageKey key)
 {
     try
     {
         if (Application.Current.Properties.ContainsKey(key.ToString()))
         {
             T obj = JsonConvert.DeserializeObject <T>(Application.Current.Properties[key.ToString()].ToString());
             return(obj);
         }
         else
         {
             return(default(T));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(default(T));
     }
 }
예제 #8
0
        public override void RenderWebPart(HtmlTextWriter writer)
        {
            writer.Write("<!-- Begin SharePresence DesignWebPart - {0} {1} -->", DesignType, DesignStyle);

            if (TemplateDef != null)
            {
                TemplateDef.AddClientOptions(new List <ClientOption> {
                    new ClientString(DesignType + "_DesignOptions_", DesignStyle)
                }, false);

                string data = string.Empty;
                try
                {
                    GetListItems(out data);
                    if (!string.IsNullOrEmpty(data))
                    {
                        TemplateDef.Render(data, writer);
                    }
                    else
                    {
                        HttpApplication application = HttpContext.Current.ApplicationInstance;
                        if (application.User.Identity.IsAuthenticated)
                        {
                            writer.Write("No DataSource and or Style configured. ");

                            if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                            {
                                writer.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\"> Configure </a>", StorageKey.ToString()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    writer.Write(ex.Message);
                    SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
                }
            }
            else
            {
                HttpApplication application = HttpContext.Current.ApplicationInstance;
                if (application.User.Identity.IsAuthenticated)
                {
                    if (error != null)
                    {
                        writer.Write(error.Message + ":" + error.InnerException.Message);
                    }
                    else
                    {
                        writer.Write("No DataSource and or Style configured. ");

                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            writer.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\"> Configure </a>", StorageKey.ToString()));
                        }
                    }
                }
            }

            writer.Write("<!-- End SharePresence DesignWebPart - {0} {1} -->", DesignType, DesignStyle);

            if (inEditMode)
            {
                base.RenderWebPart(writer);
            }
        }
예제 #9
0
 public void Remove(StorageKey key)
 {
     _helper.Remove(key.ToString());
 }
예제 #10
0
 public void Set <T>(StorageKey key, T value)
 {
     _helper.Write(key.ToString(), value);
 }
예제 #11
0
        public override void RenderWebPart(HtmlTextWriter writer)
        {
            string        output  = string.Empty;
            StringBuilder builder = new StringBuilder();

            using (var baseWriter = new HtmlTextWriter(new StringWriter(builder, CultureInfo.InvariantCulture)))
            {
                bool configure = false;
                baseWriter.Write("<!-- Begin SharePresence FormWebPart - {0} {1} -->", FormType, FormStyle);

                if (TemplateDef != null)
                {
                    List <TemplateArgument> args = new List <TemplateArgument>();
                    //var args = new XsltArgumentList();
                    if (!string.IsNullOrEmpty(FormTitle))
                    {
                        args.Add(new TemplateArgument("FormName", FormTitle));
                    }

                    if (!string.IsNullOrEmpty(FormDesciption))
                    {
                        args.Add(new TemplateArgument("FormDescription", FormDesciption));
                        //args.AddParam("FormDescription", "", FormDesciption);
                    }
                    TemplateDef.AddTemplateArguments(args, false);

                    //TemplateDef.TemplateArguments.ForEach(a => args.AddParam(a.Name, "", a.Value));

                    TemplateDef.AddClientOptions(new List <ClientOption> {
                        new ClientString(FormType + "_FormOptions_", FormStyle)
                    }, false);

                    string data = string.Empty;
                    try
                    {
                        GetListItems(out data);
                        if (!string.IsNullOrEmpty(data))
                        {
                            StringBuilder templatebuilder = new StringBuilder();
                            using (var templateWriter = new HtmlTextWriter(new StringWriter(templatebuilder, CultureInfo.InvariantCulture)))
                            {
                                TemplateDef.Render(data, templateWriter);
                            }

                            //Add Template for Canvas Render
                            contenttemplate.innerHtml = templatebuilder.ToString();

                            //formpanel.Triggers.Add(contenttemplate.canvas as UpdatePanelTrigger);
                            formpanel.RenderControl(baseWriter);
                        }
                        else
                        {
                            HttpApplication application = HttpContext.Current.ApplicationInstance;
                            if (application.User.Identity.IsAuthenticated)
                            {
                                baseWriter.Write("No DataSource and or Style configured. ");

                                if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                                {
                                    baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\" style=\"cursor: hand;\" >Configure</a>", StorageKey.ToString()));
                                    configure = true;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        baseWriter.Write(ex.Message);

                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\" style=\"cursor: hand;\" >Configure</a>", StorageKey.ToString()));
                            configure = true;
                        }
                    }
                }
                else
                {
                    HttpApplication application = HttpContext.Current.ApplicationInstance;
                    if (application.User.Identity.IsAuthenticated)
                    {
                        baseWriter.Write("No DataSource and or Style configured. ");

                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\">Configure</a>", StorageKey.ToString()));
                            configure = true;
                        }
                    }
                }

                baseWriter.Write("<!-- End SharePresence FormWebPart - {0} {1} -->", FormType, FormStyle);

                if (inEditMode)
                {
                    if (!configure)
                    {
                        if (SPContext.Current.FormContext.FormMode == Microsoft.SharePoint.WebControls.SPControlMode.Edit)
                        {
                            baseWriter.Write(String.Format(" <a onclick=\"ShowToolPane2Wrapper('Edit',this,'{0}');return false;\">Configure</a>", StorageKey.ToString()));
                        }
                    }

                    menuControls.RenderControl(baseWriter);
                    //base.RenderWebPart(baseWriter);
                }

                output = builder.ToString();
            }

            writer.Write(output);
        }
예제 #12
0
 public static void SaveState(StorageKey key, object value)
 {
     _userSettings[key.ToString()] = value;
 }
예제 #13
0
 private string CreateKey(StorageKey key) => key.Key.StartsWith(_options.Prefix) ? key.ToString() : $"{_options.Prefix}:{key}".ToLower();