示例#1
0
    private bool checkFolderNameGrants(string type, string sId)
    {
        bool res = true;

        if (this.TypeParamRequired)
        {
            int id = 0;
            int.TryParse(sId, out id);

            if (string.IsNullOrEmpty(type))
                return false;

            if (id == 0 && type != "temp")
                return false;

            switch (type)
            {
                case "items":
                    {
                        var man = new ItemsManager<Item, ItemsFilter>(true, true);
                        var item = man.GetByKey(id);
                        if (item.Id == 0) res = false;
                    }
                    break;

                case "categories":
                    {
                        var man = new CategoriesManager(true, true);
                        var item = man.GetByKey(id);
                        if (item.Id == 0) res = false;
                    }
                    break;

                case "sections":
                    {
                        var man = new SectionsManager(true, true);
                        var item = man.GetByKey(id);
                        if (item.Id == 0) res = false;
                    }
                    break;

                case "temp":
                    res = this.AllowTemporaryFiles && sId == Utility._SessionID();
                    break;

                default:
                    res = false;
                    break;
            }
        }

        return res;
    }
示例#2
0
    private void changeThreadStatus(int threadId, string statusCommand)
    {
        LblOk.Text = "";
        LblErr.Text = "";
        bool sendMessageToUserInserted = false;
        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            string previousStatus = "";
            string nextStatus = "";

            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>();
            o1 = man.GetByKey(threadId);  //precarico i campi esistenti e nn gestiti dal form

            try { previousStatus = Enum.GetName(typeof(TicketItem.TicketStatusEnum), o1.Status); }
            catch { }

            switch (statusCommand)
            {
                case "close":
                    o1.Status =  (int)TicketItem.TicketStatusEnum.Closed;
                    sendMessageToUserInserted = true;
                    break;
                case "open":
                    o1.Status =  (int)TicketItem.TicketStatusEnum.Open;
                    break;
                case "working":
                    o1.Status = (int)TicketItem.TicketStatusEnum.WorkInProgress;
                    sendMessageToUserInserted = true;
                    break;
                case "lock":
                    o1.Status =  (int)TicketItem.TicketStatusEnum.Locked;
                    break;
                default:
                    break;
            }
            man.Update(o1);

            try { nextStatus = Enum.GetName(typeof(TicketItem.TicketStatusEnum), o1.Status); }
            catch { }

            previousStatus = base.GetLabel(previousStatus, previousStatus);
            nextStatus = base.GetLabel(nextStatus, nextStatus);

            sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", "status changed from "+ previousStatus +" to "+ nextStatus);
            sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", "status changed from " + previousStatus + " to " + nextStatus);
            if (sendMessageToUserInserted && !o1.UserInserted.Equals(o1.UserAssigned))
                sendMessage(o1.UserInserted, o1, "MessageTicketTitle", "MessageTicketDescription", "status changed from " + previousStatus + " to " + nextStatus);

            loadThread(threadId);
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#3
0
    private void deleteRow(int recordId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            var man = new ItemsManager<TicketItem, TicketItemFilter>(true, true);
            var obj = man.GetByKey(recordId);
            sendMessage(obj.UserAssigned, obj, "MessageTicketTitle", "MessageTicketDescription", "ticket deleted");
            sendMessage(filterSystemMessagesManager(obj.CategoryId), obj, "MessageTicketTitle", "MessageTicketDescription", "ticket deleted");

            man.DeleteById(recordId);
            loadGrid();
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#4
0
    private void changeCustomer(int threadId, int customerId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>(true, true);
            o1 = man.GetByKey(threadId);  //precarico i campi esistenti e nn gestiti dal form
            o1.CustomerId = customerId;
            man.Update(o1);

            loadThread(threadId);
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#5
0
    private void changeAssignedUser(int threadId, string userAssigned)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            if (!PgnUserCurrent.IsAuthenticated)
                throw new Exception("user not authenticated");

            string previousUser = "";
            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>(true, true);
            o1 = man.GetByKey(threadId);  //precarico i campi esistenti e nn gestiti dal form
            previousUser = o1.UserAssigned;
            o1.UserAssigned = userAssigned;
            man.Update(o1);

            sendMessage(previousUser, o1, "MessageTicketTitle", "MessageTicketDescription", "user assigned changed from " + previousUser + " to " + userAssigned);
            sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", "user assigned changed from " + previousUser + " to " + userAssigned);
            sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", "user assigned changed from " + previousUser + " to " + userAssigned);

            loadThread(threadId);
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#6
0
    private void setTemplate(int templateId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            var o1 = new Item();
            var man = new ItemsManager<Item, ItemsFilter>(true, false);
            o1 = man.GetByKey(templateId);  //precarico i campi esistenti e nn gestiti dal form
            if (o1.Id > 0)
                TxtDescription.Text = o1.Description;
            else
                TxtDescription.Text = "";
        }
        catch (Exception e)
        {
            LblErr.Text = e.Message;
        }
    }
示例#7
0
 private void setFlag(int recordId, bool value, string flagName)
 {
     try
     {
         var man = new ItemsManager<TicketItem, TicketItemFilter>(true, true);
         var o1 = man.GetByKey(recordId);
         switch (flagName.ToLower())
         {
             case "flagged":
                 o1.Flagged = value;
                 sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", "flag changed");
                 sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", "flag changed");
                 break;
             default:
                 break;
         }
         man.Update(o1);
     }
     catch (Exception e1)
     {
         LblErr.Text = Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString();
     }
     finally { }
 }
示例#8
0
    private bool saveForm(bool saveAndClose)
    {
        bool res = false;
        LblErr.Text = "";
        LblOk.Text = "";
        string extraMessage = "";
        bool sendMessageToUserInserted = false;

        try
        {
            var o1 = new TicketItem();
            var man = new ItemsManager<TicketItem, TicketItemFilter>();
            if (CurrentId == 0)
            {
                form2obj(o1);

                if (o1.IsThreadRoot)
                {
                    string role2Add = "";
                    if (Roles.IsUserInRole(SUPPORT_USER_ROLE))
                        role2Add = PgnUserCurrent.Current.UserName;  //role as username

                    o1.ReadAccessType = MenuAccesstype.Registered;
                    o1.ReadRolenames.Add(SUPPORT_OPERATOR_ROLE);
                    o1.ReadRolenames.Add(role2Add);
                    //o1.ReadRolenames.Add(SUPPORT_MANAGER_ROLE);
                }

                o1 = man.Insert(o1);
                if (!o1.IsThreadRoot)
                {
                    var root = new TicketItem();
                    root = man.GetByKey(o1.ThreadId);
                    man.Update(root);   //update dateUpdated
                    extraMessage = "new answer inserted";
                }
                else
                    extraMessage = "new ticket inserted";

                //copy temp attachments in item folder
                new FilesGallery("~/Public/Files/items/", o1.Id.ToString()).MoveTempFiles();

                loadGrid();
            }
            else
            {
                o1 = man.GetByKey(CurrentId);
                form2obj(o1);
                man.Update(o1);
                extraMessage = "ticket updated";
            }

            if (saveAndClose)
            {
                changeThreadStatus(o1.ThreadId, "close");
                extraMessage = "ticket closed";
            }

            sendMessage(o1.UserAssigned, o1, "MessageTicketTitle", "MessageTicketDescription", extraMessage);
            sendMessage(filterSystemMessagesManager(o1.CategoryId), o1, "MessageTicketTitle", "MessageTicketDescription", extraMessage);

            if (ChkSendEmailToUserInserted.Visible == false)
                sendMessageToUserInserted = true;
            else
                sendMessageToUserInserted = ChkSendEmailToUserInserted.Checked;

            if (sendMessageToUserInserted && !o1.UserInserted.Equals(o1.UserAssigned))
                sendMessage(o1.UserInserted, o1, "MessageTicketTitle", "MessageTicketDescription", extraMessage);

            loadThread(o1.ThreadId);
            LblOk.Text = Utility.GetLabel("RECORD_SAVED_MSG");
            res = true;
        }
        catch (CustomException e1)
        {
            LblErr.Text = e1.CustomMessage;
        }
        catch (Exception e1)
        {
            LblErr.Text = Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString();
        }
        finally
        {
        }
        return res;
    }