コード例 #1
0
ファイル: Resource.cs プロジェクト: ReneSchwarzer/WebExpress
        /// <summary>
        /// Prüft, ob ein Parameter vorhanden ist
        /// </summary>
        /// <param name="name">Der Name des Parameters</param>
        /// <returns>true wenn Parameter vorhanden ist, false sonst</returns>
        public bool HasParam(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(false);
            }

            if (Params.ContainsKey(name.ToLower()))
            {
                return(true);
            }

            if (Request.HasParam(name))
            {
                return(true);
            }

            // alternativ Parameter aus der Session ermitteln
            var session = Session?.GetProperty <SessionPropertyParameter>();

            if (session != null && session.Params != null && session.Params.ContainsKey(name.ToLower()))
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
ファイル: DropData.cs プロジェクト: FukigenDEV/Project-C
        public override void DELETE()
        {
            //Get required fields
            if (!Params.ContainsKey("table"))
            {
                Response.Send("Missing params", HttpStatusCode.BadRequest);
                return;
            }
            if (!JSON.TryGetValue <JArray>("RowIDs", out JToken RowIDs))
            {
                Response.Send("Missing fields", HttpStatusCode.BadRequest);
                return;
            }

            //Check if all specified table exist
            GenericDataTable Table = GenericDataTable.GetTableByName(Connection, Params["table"][0]);

            if (Table == null)
            {
                Response.Send("No such table", HttpStatusCode.NotFound);
                return;
            }

            List <int> IDs = (((JArray)RowIDs).Where(ID => ID.Type == JTokenType.Integer).Select(ID => (int)ID)).ToList();

            Table.Delete(IDs);
            Response.Send(HttpStatusCode.OK);
        }
コード例 #3
0
ファイル: Resource.cs プロジェクト: ReneSchwarzer/WebExpress
        /// <summary>
        /// Fügt ein Parameter hinzu.
        /// </summary>
        /// <param name="param">Der Parameter</param>
        /// <param name="scope">Der Gültigkeitsbereich des Parameters</param>
        public void AddParam(Parameter param)
        {
            var key = param.Key.ToLower();

            if (param.Scope != ParameterScope.Session)
            {
                if (!Params.ContainsKey(key))
                {
                    Params.Add(key, param);
                }
                else
                {
                    Params[key] = param;
                }

                return;
            }

            //// alternativ Parameter in Session speichern
            //var session = Session.GetProperty<SessionPropertyParameter>();
            //if (session != null && session.Params != null && session.Params.ContainsKey(key))
            //{
            //    session.Params[key] = param;
            //}
            //else
            //{
            //    session.Params[key] = param;
            //}
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        public override DialogResult Show(Form parent = null, bool setup = false)
        {
            if (fm == null)
            {
                fm                 = new RotateForm(this);
                fm.host            = Host;
                fm.Text            = DisplayName;
                fm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                fm.MaximizeBox     = false;
                fm.MinimizeBox     = false;
                fm.ShowIcon        = false;
                fm.ShowInTaskbar   = false;
                fm.StartPosition   = FormStartPosition.CenterParent;

                if (Params.Count == 0)
                {
                    InitParams();
                }

                if (Params.ContainsKey("Mode"))
                {
                    fm.SetMode("Mode", Params["Mode"]);
                }
                if (Params.ContainsKey("Angle"))
                {
                    fm.SetAngle("Angle", Params["Angle"]);
                }
                if (Params.ContainsKey("KeepSize"))
                {
                    fm.SetKeepSize("KeepSize", Params["KeepSize"]);
                }

                Translate(fm);
            }
            var result = fm.ShowDialog();

            if (result == DialogResult.OK)
            {
                _success = true;

                Params["Mode"]     = fm.GetMode("Mode");
                Params["Angle"]    = fm.GetAngle("Angle");
                Params["KeepSize"] = fm.GetKeepSize("KeepSize");

                if (!setup)
                {
                    ImgDst = Apply(ImgSrc);
                }
            }
            else
            {
                _success = false;
            }
            if (fm != null)
            {
                fm.Dispose();
                fm = null;
            }
            return(result);
        }
コード例 #5
0
        private string MarkAnswer()
        {
            int topicId = -1;
            int forumId = -1;
            int replyId = -1;

            if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"]))
            {
                topicId = int.Parse(Params["topicid"].ToString());
            }
            if (Params.ContainsKey("replyid") && SimulateIsNumeric.IsNumeric(Params["replyid"]))
            {
                replyId = int.Parse(Params["replyid"].ToString());
            }
            if (topicId > 0 & UserId > 0)
            {
                TopicsController tc = new TopicsController();
                TopicInfo        t  = tc.Topics_Get(PortalId, ModuleId, topicId);
                Data.ForumsDB    db = new Data.ForumsDB();
                forumId = db.Forum_GetByTopicId(topicId);
                ForumController fc = new ForumController();
                Forum           f  = fc.Forums_Get(forumId, this.UserId, true);
                if ((this.UserId == t.Author.AuthorId && !t.IsLocked) || Permissions.HasAccess(f.Security.ModEdit, ForumUser.UserRoles))
                {
                    DataProvider.Instance().Reply_UpdateStatus(PortalId, ModuleId, topicId, replyId, UserId, 1, Permissions.HasAccess(f.Security.ModEdit, ForumUser.UserRoles));
                }
                return(BuildOutput(string.Empty, OutputCodes.Success, true));
            }
            else
            {
                return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
            }
        }
コード例 #6
0
        public override void DELETE()
        {
            // Get required fields
            if (!Params.ContainsKey("name"))
            {
                Response.Send("Missing params", HttpStatusCode.BadRequest);
                return;
            }
            string Name = Params["name"][0];

            //Don't allow users to delete the Administrators and All Users departments.
            if (Name == "Administrators" || Name == "All Users")
            {
                Response.Send("Cannot delete system department", HttpStatusCode.Forbidden);
                return;
            }

            //Check if the specified department exists. If it doesn't, send a 404 Not Found
            Department department = Department.GetByName(Connection, Name);

            if (department == null)
            {
                Response.Send("No such department", HttpStatusCode.NotFound);
                return;
            }

            Connection.Delete(department);
            Response.Send("Department successfully deleted", StatusCode: HttpStatusCode.OK);
        }
コード例 #7
0
        private void FilterSave()
        {
            FilterInfo filter = new FilterInfo();

            filter.FilterId = -1;
            filter.ModuleId = ModuleId;
            filter.PortalId = PortalId;
            if (Params.ContainsKey("FilterId"))
            {
                filter.FilterId = Convert.ToInt32(Params["FilterId"]);
            }
            if (Params.ContainsKey("Find"))
            {
                filter.Find = Params["Find"].ToString();
            }
            if (Params.ContainsKey("Replacement"))
            {
                filter.Replace = Params["Replacement"].ToString();
            }
            if (Params.ContainsKey("FilterType"))
            {
                filter.FilterType = Params["FilterType"].ToString();
            }

            FilterController fc = new FilterController();

            filter = fc.Filter_Save(filter);
        }
コード例 #8
0
        private void RankSave()
        {
            RewardInfo rank = new RewardInfo();

            rank.RankId   = -1;
            rank.ModuleId = ModuleId;
            rank.PortalId = PortalId;
            if (Params.ContainsKey("RankId"))
            {
                rank.RankId = Convert.ToInt32(Params["RankId"]);
            }
            if (Params.ContainsKey("RankName"))
            {
                rank.RankName = Params["RankName"].ToString();
            }
            if (Params.ContainsKey("MinPosts"))
            {
                rank.MinPosts = Convert.ToInt32(Params["MinPosts"]);
            }
            if (Params.ContainsKey("MaxPosts"))
            {
                rank.MaxPosts = Convert.ToInt32(Params["MaxPosts"]);
            }
            if (Params.ContainsKey("Display"))
            {
                rank.Display = Params["Display"].ToString();
            }
            RewardController rc = new RewardController();

            rank = rc.Reward_Save(rank);
        }
コード例 #9
0
ファイル: AbstractTag.cs プロジェクト: helloNice/AirGame
        /*
         * 验证此句脚本的语法, 是否包含必须项
         */
        public void CheckVital()
        {
            bool          hasError    = false;
            List <string> errorParams = new List <string>();

            foreach (string key in _vitalParams)
            {
                if (!Params.ContainsKey(key))
                {
                    errorParams.Add(key);
                    hasError = true;
                }
            }

            if (!hasError)
            {
                return;
            }

            //log the error key
            StringBuilder line = new StringBuilder("[");

            line.Append(_tagInfo.TagName);

            foreach (KeyValuePair <string, string> i in _tagInfo.Params)
            {
                line.Append(" ");
                line.AppendFormat("{0}={0}", i.Key, i.Value);
            }
            Debug.LogFormat("line:{0} {1}\nERROR: Do not contain vital param", LineInScript, line);
            foreach (string p in errorParams)
            {
                Debug.LogFormat("Miss Param:{0}\n", p);
            }
        }
コード例 #10
0
        /// <summary>
        /// Endpoint for retrieving user notes
        /// </summary>
        public override void GET()
        {
            // Get required fields
            if (!Params.ContainsKey("title"))
            {
                Response.Send("Missing params", HttpStatusCode.BadRequest);
                return;
            }

            //Check if the title parameter exists. If it doesn't, return all notes.
            if (Params["title"][0].Length == 0)
            {
                List <Note> notes = Note.GetAllNotes(Connection);
                Response.Send(JsonConvert.SerializeObject(notes), HttpStatusCode.OK);
                return;
            }

            // Check if the specified note exists. If it doesn't, send a 404 Not Found
            Note note = Note.GetNoteByTitle(Connection, Params["title"][0]);

            if (note == null)
            {
                Response.Send("No such note", HttpStatusCode.NotFound);
                return;
            }

            // Build and send response
            JObject JSON = JObject.FromObject(note);

            Response.Send(JSON.ToString(Formatting.None), HttpStatusCode.OK);
        }
コード例 #11
0
        public override void GET()
        {
            // Get required fields
            if (!Params.ContainsKey("name"))
            {
                Response.Send("Missing params", HttpStatusCode.BadRequest);
                return;
            }

            if (string.IsNullOrEmpty(Params["name"][0]))
            {
                List <Company> companies = Company.GetAllCompanies(Connection);
                Response.Send(JsonConvert.SerializeObject(companies), HttpStatusCode.OK);

                return;
            }

            // Check if the specified company exists. If it doesn't, send a 404 Not Found
            Company company = Company.GetCompanyByName(Connection, Params["name"][0]);

            if (company == null)
            {
                Response.Send("No such company", HttpStatusCode.NotFound);
                return;
            }

            // Build and send response
            JObject JSON = JObject.FromObject(company);

            Response.Send(JSON.ToString(Formatting.None), HttpStatusCode.OK);
        }
コード例 #12
0
        public override void PATCH()
        {
            // Get required fields
            if (!Params.ContainsKey("name"))
            {
                Response.Send("Missing params", HttpStatusCode.BadRequest);
                return;
            }

            // Check if the specified department exists. If it doesn't, send a 404 Not Found
            Department department = Department.GetByName(Connection, Params["name"][0]);

            if (department == null)
            {
                Response.Send("No such department", HttpStatusCode.NotFound);
                return;
            }

            // Change name if necessary
            if (JSON.TryGetValue <string>("newName", out JToken newName))
            {
                department.Name = (string)newName;
            }

            // Change description if necessary
            if (JSON.TryGetValue <string>("newDescription", out JToken newDescription))
            {
                department.Description = (string)newDescription;
            }

            // Update DB row
            Connection.Update <Department>(department);
            Response.Send("Department has successfully been edited.", StatusCode: HttpStatusCode.OK);
        }
コード例 #13
0
ファイル: Backup.cs プロジェクト: FukigenDEV/Project-C
        public override void GET()
        {
            if (Params.ContainsKey("name"))
            {
                string Name = Params["name"][0];

                //Check if the specified file exists
                //If the name contains a dot, return a NotFound to prevent path traversal.
                if (Name.Contains('.') || !File.Exists(BackupDir + "\\" + Name + ".zip"))
                {
                    Response.Send(HttpStatusCode.NotFound);
                    return;
                }
                Response.AppendHeader("Content-disposition", "attachment; filename=" + Name + ".zip");
                Response.Send(File.ReadAllBytes(BackupDir + "\\" + Name + ".zip"), HttpStatusCode.OK, "application/zip");
            }
            else
            {
                //No backup name was specified, so send
                List <FileInfo> BackupFiles = new List <FileInfo>(new DirectoryInfo(BackupDir).GetFiles());
                JArray          Names       = new JArray();
                foreach (FileInfo File in BackupFiles)
                {
                    Names.Add(Path.GetFileNameWithoutExtension(File.Name));
                }
                Response.Send(Names.ToString(), HttpStatusCode.OK, "application/json");
            }
        }
コード例 #14
0
ファイル: Resource.cs プロジェクト: ReneSchwarzer/WebExpress
        /// <summary>
        /// Liefert ein Parameter anhand seines Namens
        /// </summary>
        /// <param name="name">Der Name des Parameters</param>
        /// <returns>Der Wert</returns>
        public Parameter GetParam(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(null);
            }

            if (Params.ContainsKey(name.ToLower()))
            {
                return(Params[name.ToLower()]);
            }

            if (Request.HasParam(name))
            {
                var value = Request.GetParam(name);
                return(value);
            }

            if (Session == null)
            {
                return(null);
            }

            // alternativ Parameter aus der Session ermitteln
            var session = Session.GetProperty <SessionPropertyParameter>();

            if (session != null && session.Params != null && session.Params.ContainsKey(name.ToLower()))
            {
                return(session.Params[name.ToLower()]);
            }

            return(null);
        }
コード例 #15
0
        private string MoveTopic()
        {
            int topicId       = -1;
            int forumId       = -1;
            int targetForumId = -1;

            if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"]))
            {
                topicId = int.Parse(Params["topicid"].ToString());
            }
            if (Params.ContainsKey("forumid") && SimulateIsNumeric.IsNumeric(Params["forumid"]))
            {
                targetForumId = int.Parse(Params["forumid"].ToString());
            }
            if (topicId > 0)
            {
                TopicsController tc = new TopicsController();
                TopicInfo        t  = tc.Topics_Get(PortalId, ModuleId, topicId);
                Data.ForumsDB    db = new Data.ForumsDB();
                forumId = db.Forum_GetByTopicId(topicId);
                ForumController fc = new ForumController();
                Forum           f  = fc.Forums_Get(forumId, this.UserId, true);
                if (f != null)
                {
                    if (Permissions.HasPerm(f.Security.ModMove, ForumUser.UserRoles))
                    {
                        tc.Topics_Move(PortalId, ModuleId, targetForumId, topicId);
                        DataCache.ClearAllCache(ModuleId, TabId);
                        return(BuildOutput(string.Empty, OutputCodes.Success, true));
                    }
                }
            }
            return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
        }
コード例 #16
0
            public object[] generateInvokeArray(List <ParameterInfo> pdefs)
            {
                var result = new object[pdefs.Count];

                for (int i = 0; i < pdefs.Count; i++)
                {
                    var pdef = pdefs[i];

                    if (Params.ContainsKey(pdef.Name))
                    {
                        try {
                            result[i] = Convert.ChangeType(Params[pdef.Name], pdef.ParameterType);
                        } catch (Exception) {
                            result[i] = null;
                        }
                    }
                    else
                    {
                        if (pdef.HasDefaultValue)
                        {
                            result[i] = pdef.DefaultValue;
                        }
                        else
                        {
                            result[i] = null;
                        }
                    }
                }

                return(result);
            }
コード例 #17
0
        private string DeleteTopic()
        {
            int topicId = -1;
            int forumId = -1;

            if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"]))
            {
                topicId = int.Parse(Params["topicid"].ToString());
            }
            if (topicId > 0)
            {
                TopicsController tc = new TopicsController();
                TopicInfo        t  = tc.Topics_Get(PortalId, ModuleId, topicId);
                Data.ForumsDB    db = new Data.ForumsDB();
                forumId = db.Forum_GetByTopicId(topicId);
                ForumController fc = new ForumController();
                Forum           f  = fc.Forums_Get(forumId, this.UserId, true);
                if (f != null)
                {
                    if (Permissions.HasPerm(f.Security.ModDelete, ForumUser.UserRoles) || (t.Author.AuthorId == this.UserId && Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles)))
                    {
                        tc.Topics_Delete(PortalId, ModuleId, forumId, topicId, MainSettings.DeleteBehavior);
                        return(BuildOutput(string.Empty, OutputCodes.Success, true));
                    }
                }
            }
            return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
        }
コード例 #18
0
        private string SubscribeTopic()
        {
            if (UserId <= 0)
            {
                return(BuildOutput(string.Empty, OutputCodes.AuthenticationFailed, true));
            }
            int iStatus = 0;
            SubscriptionController sc = new SubscriptionController();
            int forumId = -1;
            int topicId = -1;

            if (Params.ContainsKey("forumid") && SimulateIsNumeric.IsNumeric(Params["forumid"]))
            {
                forumId = int.Parse(Params["forumid"].ToString());
            }
            if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"]))
            {
                topicId = int.Parse(Params["topicid"].ToString());
            }
            iStatus = sc.Subscription_Update(PortalId, ModuleId, forumId, topicId, 1, this.UserId, ForumUser.UserRoles);
            if (iStatus == 1)
            {
                return(BuildOutput("{\"subscribed\":true,\"text\":\"" + Utilities.JSON.EscapeJsonString(Utilities.GetSharedResource("[RESX:TopicSubscribe:TRUE]")) + "\"}", OutputCodes.Success, true, true));
            }
            else
            {
                return(BuildOutput("{\"subscribed\":false,\"text\":\"" + Utilities.JSON.EscapeJsonString(Utilities.GetSharedResource("[RESX:TopicSubscribe:FALSE]")) + "\"}", OutputCodes.Success, true, true));
            }
        }
コード例 #19
0
ファイル: UrlParser.cs プロジェクト: Xammondxxx/PriceGrabber
        public void AddParam(string key, string val)
        {
            if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(val))
            {
                return;
            }
            if (Params == null)
            {
                Params = new Dictionary <string, string>();
            }
            if (Params.ContainsKey(key))
            {
                Params[key] = val;
            }
            else
            {
                Params.Add(key, val);
            }

            Query = string.Empty;
            var mq = string.Empty;

            foreach (var p in Params)
            {
                Query = Query + (string.IsNullOrEmpty(Query) ? "" : "&") + p.Key + "=" + p.Value;
                if (p.Key.ToLower() == "entryid")
                {
                    mq = mq + p.Key + "=" + p.Value;
                }
            }
            AbsoluteUrl = Url + (string.IsNullOrEmpty(Query) ? "" : "?") + Query;
            MetricUrl   = Url + (string.IsNullOrEmpty(mq) ? "" : "?") + mq;
        }
コード例 #20
0
        public override Image Apply(Image image)
        {
            GetParams(fm);

            if (!(image is Image))
            {
                return(image);
            }

            Rectangle region = new Rectangle(0, 0, ImgSrc.Width, ImgSrc.Height);

            if (Params.ContainsKey("CropRegion"))
            {
                region = (Rectangle)Params["CropRegion"].Value;
            }

            if (Params.ContainsKey("CropSide"))
            {
                var side = (SideType)Params["CropSide"].Value;
                region = Rectangle.Round(AddinUtils.AdjustRegion(region, ImgSrc, side));
            }

            if (region.Width > 0 && region.Height > 0)
            {
                Accord.Imaging.Filters.Crop filter = new Accord.Imaging.Filters.Crop(region);
                Bitmap dst = filter.Apply(AddinUtils.CloneImage(ImgSrc) as Bitmap);
                AddinUtils.CloneExif(ImgSrc, dst);
                return(dst);
            }
            else
            {
                return(ImgSrc);
            }
        }
コード例 #21
0
ファイル: ApiBase.cs プロジェクト: lonelyong/Payment
 /// <summary>
 /// 获取指定名称的参数值
 /// </summary>
 /// <returns></returns>
 public string GetParamValue(string name)
 {
     if (Params.ContainsKey(name))
     {
         return(Params[name]);
     }
     return(null);
 }
コード例 #22
0
 public string GetParam(string key)
 {
     if (Params.ContainsKey(key))
     {
         return(Params[key].AsString());
     }
     return(string.Empty);
 }
コード例 #23
0
        public override void GET()
        {
            //Get required fields
            List <User> Users = new List <User>();

            if (Params.ContainsKey("email"))
            {
                //Get all user objects
                foreach (string Email in Params["email"])
                {
                    if (Email == "CurrentUser")
                    {
                        Users.Add(RequestUser);
                        continue;
                    }
                    if (RequestUserLevel < PermLevel.Manager)
                    {
                        Response.Send(HttpStatusCode.Forbidden);
                        return;
                    }
                    User Acc = User.GetUserByEmail(Connection, Email);
                    if (Acc != null)
                    {
                        Users.Add(Acc);
                    }
                }

                //If email is missing, assume all users
            }
            else
            {
                if (RequestUserLevel < PermLevel.Manager)
                {
                    Response.Send(HttpStatusCode.Forbidden);
                    return;
                }
                Users = User.GetAllUsers(Connection);
            }

            //Convert to JSON and add permissionlevels
            List <Department> Departments = Department.GetAllDepartments(Connection);
            JArray            JSON        = JArray.FromObject(Users);

            foreach (JObject Entry in JSON)
            {
                Entry.Remove("PasswordHash");                 //Security
                JObject PermissionInfo = new JObject();
                foreach (Department Dept in Departments)
                {
                    PermissionInfo.Add(Dept.Name, User.GetPermissionLevel(Connection, (int)Entry["ID"], Dept.ID).ToString());
                }

                Entry.Add("Permissions", PermissionInfo);
            }

            //Send response
            Response.Send(JSON);
        }
コード例 #24
0
 public object Set(string name, object value)
 {
     if (Params.ContainsKey(name))
     {
         return(null);
     }
     Params.Add(name, value);
     return(Params[name]);
 }
コード例 #25
0
        private string DeletePost()
        {
            int replyId = -1;
            int TopicId = -1;

            if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"]))
            {
                TopicId = int.Parse(Params["topicid"].ToString());
            }
            if (Params.ContainsKey("replyid") && SimulateIsNumeric.IsNumeric(Params["replyid"]))
            {
                replyId = int.Parse(Params["replyid"].ToString());
            }
            int forumId = -1;

            Data.ForumsDB db = new Data.ForumsDB();
            forumId = db.Forum_GetByTopicId(TopicId);
            ForumController fc = new ForumController();
            Forum           f  = fc.Forums_Get(forumId, this.UserId, true);

            if (TopicId > 0 & replyId < 1)
            {
                TopicsController tc = new TopicsController();
                TopicInfo        ti = tc.Topics_Get(PortalId, ModuleId, TopicId);

                if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ti.Content.AuthorId == UserId && ti.IsLocked == false))
                {
                    DataProvider.Instance().Topics_Delete(forumId, TopicId, MainSettings.DeleteBehavior);
                    string journalKey = string.Format("{0}:{1}", forumId.ToString(), TopicId.ToString());
                    JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey);
                }
                else
                {
                    return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
                }
            }
            else
            {
                ReplyController rc = new ReplyController();
                ReplyInfo       ri = rc.Reply_Get(PortalId, ModuleId, TopicId, replyId);
                if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ri.Content.AuthorId == UserId))
                {
                    DataProvider.Instance().Reply_Delete(forumId, TopicId, replyId, MainSettings.DeleteBehavior);
                    string journalKey = string.Format("{0}:{1}:{2}", forumId.ToString(), TopicId.ToString(), replyId.ToString());
                    JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey);
                }
                else
                {
                    return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
                }
            }
            string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);

            DataCache.CacheClearPrefix(cachekey);
            return(BuildOutput(TopicId + "|" + replyId, OutputCodes.Success, true));
        }
コード例 #26
0
        protected override async Task <CommandResult> ExecuteImplementation()
        {
            //Session.Stream(new JObject("Waiting\n"));
            double seconds = double.MaxValue;

            if (Params.ContainsKey("seconds"))
            {
                seconds = Params.Get <double>("seconds");
                if (seconds < 0)
                {
                    return(CommandResult.Fail("Parameter 'seconds' must not be negative."));
                }
                if (seconds <= 1)
                {
                    await Task.Delay(TimeSpan.FromSeconds(seconds)).ConfigureAwait(false);

                    return(CommandResult.Success("Done."));
                }
            }
            else
            {
                StreamProgressIndeterminate("Waiting indefinitely");
            }
            int i = 0;

            //int j = 0;
            while (CancellationToken.IsCancellationRequested == false && i < seconds)
            {
                try
                {
                    await Task.Delay(TimeSpan.FromSeconds(1), CancellationToken).ConfigureAwait(false);
                }
                catch (Exception) { /*ignore*/ }
                if (CancellationToken.IsCancellationRequested)
                {
                    return(CommandResult.Success("Cancelled."));
                }
                //if (j > 9)
                //{
                //    j = 0;
                //    //Session.Stream("\n");
                //}
                //j++;
                i++;
                Stream(new JObject()
                {
                    { "value", i }
                });
                if (Params.ContainsKey("seconds"))
                {
                    StreamProgress("Waiting ...", i, (int)seconds);
                }
            }
            StreamProgressComplete();
            return(CommandResult.Success("Done."));
        }
コード例 #27
0
        public override void PATCH()
        {
            // Get required fields
            if (!Params.ContainsKey("name"))
            {
                Response.Send("Missing params", HttpStatusCode.BadRequest);
                return;
            }

            //Check if the specified company exists. If it doesn't, send a 404 Not Found
            Company company = Company.GetCompanyByName(Connection, Params["name"][0]);

            if (company == null)
            {
                Response.Send("No such company", HttpStatusCode.NotFound);
                return;
            }

            // Change necessary fields
            if (JSON.TryGetValue <string>("newName", out JToken newName))
            {
                company.Name = (string)newName;
            }
            if (JSON.TryGetValue <string>("newStreet", out JToken newStreet))
            {
                company.Street = (string)newStreet;
            }
            if (JSON.TryGetValue <int>("newHouseNumber", out JToken newHouseNumber))
            {
                company.HouseNumber = (int)newHouseNumber;
            }
            if (JSON.TryGetValue <string>("newPostCode", out JToken newPostCode))
            {
                company.PostCode = (string)newPostCode;
            }
            if (JSON.TryGetValue <string>("newCity", out JToken newCity))
            {
                company.City = (string)newCity;
            }
            if (JSON.TryGetValue <string>("newCountry", out JToken newCountry))
            {
                company.Country = (string)newCountry;
            }
            if (JSON.TryGetValue <string>("newPhoneNumber", out JToken newPhoneNumber))
            {
                company.PhoneNumber = (string)newPhoneNumber;
            }
            if (JSON.TryGetValue <string>("newEmail", out JToken newEmail))
            {
                company.Email = (string)newEmail;
            }

            // Update DB row
            Connection.Update <Company>(company);
            Response.Send("Company has successfully been edited.", StatusCode: HttpStatusCode.OK);
        }
コード例 #28
0
        public string GetParamUser()
        {
            var key = UserWorklogReportFields.PARAM_USER;

            if (Params.ContainsKey(key))
            {
                return(Params[key]);
            }
            throw new ArgumentException("param user is required");
        }
コード例 #29
0
ファイル: EchoCommand.cs プロジェクト: henon/OSMP
        protected override async Task <CommandResult> ExecuteImplementation()
        {
            var result = new CommandResult();

            if (Params.ContainsKey("token"))
            {
                result.Data["token"] = Params["token"];
            }
            return(result);
        }
コード例 #30
0
 public List <KeyValuePair <string, int> > GetRewards()
 {
     if (Params.ContainsKey("Rewards"))
     {
         List <KeyValuePair <string, int> > rewards = JsonConvert.DeserializeObject <List <KeyValuePair <string, int> > >(Params["Rewards"]);
         return(rewards);
     }
     else
     {
         return(null);
     }
 }