partial void DeleteHelpDesk_Task(HelpDesk_Task instance);
 partial void InsertHelpDesk_Task(HelpDesk_Task instance);
 partial void UpdateHelpDesk_Task(HelpDesk_Task instance);
Esempio n. 4
0
        private int SaveNewTicketForm()
        {
            HelpDeskDALDataContext objHelpDeskDALDataContext = new HelpDeskDALDataContext();

            // Save Task
            HelpDesk_Task objHelpDesk_Task = new HelpDesk_Task();

            objHelpDesk_Task.Status = "New";
            objHelpDesk_Task.CreatedDate = DateTime.Now;
            objHelpDesk_Task.Description = txtDescription.Text;
            objHelpDesk_Task.PortalID = PortalId;
            objHelpDesk_Task.Priority = ddlPriority.SelectedValue;
            objHelpDesk_Task.RequesterPhone = txtPhone.Text;
            objHelpDesk_Task.AssignedRoleID = -1;
            objHelpDesk_Task.TicketPassword = GetRandomPassword();

            if (Convert.ToInt32(txtUserID.Text) == -1)
            {
                // User not logged in
                objHelpDesk_Task.RequesterEmail = txtEmail.Text;
                objHelpDesk_Task.RequesterName = txtName.Text;
                objHelpDesk_Task.RequesterUserID = -1;
            }
            else
            {
                // User logged in
                objHelpDesk_Task.RequesterUserID = Convert.ToInt32(txtUserID.Text);
                objHelpDesk_Task.RequesterName = //UserController.GetUser(PortalId, Convert.ToInt32(txtUserID.Text), false).DisplayName;
					UserController.GetUserById(PortalId, Convert.ToInt32(txtUserID.Text)).DisplayName;
            }

            if (txtDueDate.Text.Trim().Length > 1)
            {
                objHelpDesk_Task.DueDate = Convert.ToDateTime(txtDueDate.Text.Trim());
            }

            // If Admin panel is visible this is an admin
            // Save the Status and Assignment
            if (pnlAdminTicketStatus.Visible == true)
            {
                objHelpDesk_Task.AssignedRoleID = Convert.ToInt32(ddlAssignedAdmin.SelectedValue);
                objHelpDesk_Task.Status = ddlStatusAdmin.SelectedValue;
            }

            objHelpDeskDALDataContext.HelpDesk_Tasks.InsertOnSubmit(objHelpDesk_Task);
            objHelpDeskDALDataContext.SubmitChanges();

            // Save Task Details
            HelpDesk_TaskDetail objHelpDesk_TaskDetail = new HelpDesk_TaskDetail();

            if ((txtDetails.Text.Trim().Length > 0) || (TicketFileUpload.HasFile))
            {
                objHelpDesk_TaskDetail.TaskID = objHelpDesk_Task.TaskID;
                objHelpDesk_TaskDetail.Description = txtDetails.Text;
                objHelpDesk_TaskDetail.DetailType = "Comment-Visible";
                objHelpDesk_TaskDetail.InsertDate = DateTime.Now;

                if (Convert.ToInt32(txtUserID.Text) == -1)
                {
                    // User not logged in
                    objHelpDesk_TaskDetail.UserID = -1;
                }
                else
                {
                    // User logged in
                    objHelpDesk_TaskDetail.UserID = Convert.ToInt32(txtUserID.Text);
                }

                objHelpDeskDALDataContext.HelpDesk_TaskDetails.InsertOnSubmit(objHelpDesk_TaskDetail);
                objHelpDeskDALDataContext.SubmitChanges();

                // Upload the File
                if (TicketFileUpload.HasFile)
                {
                    UploadFile(objHelpDesk_TaskDetail.DetailID);
                    // Insert Log
					Log.InsertLog(objHelpDesk_Task.TaskID, UserId, String.Format(Localization.GetString("UploadedFile.Text", LocalResourceFile), GetUserName(), TicketFileUpload.FileName));
                }
            }

            // Insert Log
			Log.InsertLog(objHelpDesk_Task.TaskID, UserId, String.Format(Localization.GetString("CreatedTicket.Text", LocalResourceFile), GetUserName()));

            return objHelpDesk_Task.TaskID;
        }