public HttpResponseMessage RunFile(UpdateFileDTO submitted)
        {
            try
            {
                string realfilename = HostingEnvironment.MapPath(submitted.Filename);

                File.WriteAllText(realfilename, submitted.Content);

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                string dsFileName = Path.ChangeExtension(realfilename, ".datasource");
                if (File.Exists(dsFileName))
                {
                    string[] lines = File.ReadAllLines(dsFileName);
                    foreach (var item in lines)
                    {
                        string[] par = item.Split('=');
                        parameters.Add(par[0], par[1]);
                    }
                }
                parameters.Add("templatefile", submitted.Filename);
                string Output = WidgetTokenProvider.ExecuteWidget(parameters);

                return(Request.CreateResponse(HttpStatusCode.OK, Output));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, ex.Message));
            }
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (Request.QueryString["template"] != null)
            {
                Template = Request.QueryString["template"];
            }
            if (Request.QueryString["mode"] != null)
            {
                Mode = Request.QueryString["mode"];
            }
            if (!Page.IsPostBack)
            {
                try
                {
                    string realfilename = HostingEnvironment.MapPath(Template);
                    Dictionary <string, string> parameters = new Dictionary <string, string>();
                    string dsFileName = Path.ChangeExtension(realfilename, ".datasource");
                    if (File.Exists(dsFileName))
                    {
                        string[] lines = File.ReadAllLines(dsFileName);
                        foreach (var item in lines)
                        {
                            string[] par = item.Split(new char[] { '=' }, 2);
                            parameters.Add(par[0], par[1]);
                        }
                    }
                    if (Mode != "data")
                    {
                        parameters.Add("templatefile", Template);
                    }

                    if (Mode == "widget")
                    {
                        string Output = "{{widget ";
                        foreach (var item in parameters)
                        {
                            Output += item.Key + "=\"" + item.Value + "\" ";
                        }
                        Output       += "}}";
                        lContent.Text = Output;

                        hlThis.NavigateUrl = Request.RawUrl.Replace("&mode=widget", "");
                        hlThis.Text        = hlThis.NavigateUrl;
                        //hlThis.Visible = true;
                    }
                    else
                    {
                        lContent.Text = WidgetTokenProvider.ExecuteWidget(parameters);
                    }
                }
                catch (Exception ex)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Template + "/" + ex.Message, ModuleMessage.ModuleMessageType.RedError);
                }
            }
        }