我没有从字符串中获取价值。
例如:
public static void ticket(string ticketName) // ticketName = "testTicket"
{
string abc = ticketName; // result : abc null
}
有人可以帮助我,但我被困在它上将近2天
这是真实的代码
namespace FirstOutlookAddIn
{ public partial class lblSubject:Form { Outlook._Explorer currentExplorer = null;
private string Conversation_ID;
private string subject;
private string senderName;
private string senderEmail;
private string incident;
private DateTime creationDate;
public lblSubject()
{
InitializeComponent();
Outlook.Application myAPP = new Outlook.Application();
}
private void button3_Click(object sender, EventArgs e)
{
Outlook.Application myAPP = new Outlook.Application();
Outlook.MAPIFolder selectedFolder =
myAPP.Application.ActiveExplorer().CurrentFolder;
String expMessage = "Your current folder is "
+ selectedFolder.Name + ".\n";
String itemMessage = "Item is unknown.";
try
{
if (myAPP.Application.ActiveExplorer().Selection.Count > 0)
{
Object selObject = myAPP.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem =
(selObject as Outlook.MailItem);
itemMessage = "The item is an e-mail message : Entery ID:"+ mailItem.EntryID+ " Conversation ID" + mailItem.ConversationID;
Conversation_ID = mailItem.ConversationID;
//mailItem.Display(false);
// Grab the Body
//txtBody.Text = mailItem.Body;
rIncident.Text = mailItem.Body;
incident = mailItem.Body;
senderName = mailItem.SenderName;
senderEmail = mailItem.SenderEmailAddress;
creationDate = mailItem.CreationTime;
Conversation_ID = mailItem.ConversationID;
// Sender Name
lblSenderName.Text = mailItem.SenderName;
// Sender Email
lblSenderEmail.Text = mailItem.SenderEmailAddress;
// Creation date
lblCreationdate.Text = mailItem.CreationTime.ToString();
}
}
private void lblSubject_Load(object sender, EventArgs e)
{
cboUsers.DataSource = Requetes.userliste();
cboPriority.DataSource = Requetes.priorityliste();
}
private void btnCreateTicket_Click(object sender, EventArgs e)
{
string userNom = cboUsers.SelectedItem.ToString();
string priorityNom = cboPriority.SelectedItem.ToString();
string convoID = Conversation_ID;
Requetes.saveTicket(userNom, priorityNom, subject,
senderName, senderEmail, incident, convoID, creationDate);
}
}
}
// Requete Class
名称空间FirstOutlookAddIn { public static class Requetes { private static TicketingDBEntities6 ticketDB = new TicketingDBEntities6(); private static DateTime now = DateTime.Now;
//Recover User ID
public static void saveTicket(string userNom2, string priority, string subject,
string senderName, string email, string incident, string conversationID, DateTime mailCreateTime)
{
User u = ticketDB.User.Single(user1 => user1.User_Nom == userNom2);
int userIdenti = u.User_Id;
Priority p = ticketDB.Priority.Single(pr => pr.Priority_Name == priority);
int priorityID = p.Priority_Id;
Ticket t = new Ticket();
t.Ticket_Body = incident;
t.Ticket_ConversationID = conversationID;
t.Ticket_SenderEmail = email;
t.Ticket_SentDate = mailCreateTime;
t.Ticket_Priority = p.Priority_Id;
ObjectSet<Ticket> insert = ticketDB.Ticket;
insert.AddObject(t);
ticketDB.SaveChanges();
// Ticket ticket = ticketDB.Ticket.Single(ti => ti.Ticket_ConversationID == conversationID);
string getConvoID;
string getSenderEmail;
getSenderEmail = email;
DateTime dt = mailCreateTime;
getConvoID = conversationID;
var Users = (from uc in ticketDB.Ticket
where uc.Ticket_ConversationID == getConvoID
select uc
);
int abc = Users.Count();
Ticket_User tu = new Ticket_User();
tu.Ticket_User_Ticket_Id = ticket.Ticket_Id;
tu.Ticket_User_User_id = u.User_Id;
ObjectSet<Ticket_User> insert_Ticket_User = ticketDB.Ticket_User;
insert_Ticket_User.AddObject(tu);
ticketDB.SaveChanges();
}
}
}
问题与Classrequete
有关例如
if conversationID = "FFF1614651616fssd";t.Ticket_ConversationID = conversationID; // in debuget it shows conversationID is equal to "FF.....ssd" but t.Ticket_ConversationID is null
:(((((((
`
希望有人可以帮助我。很抱歉这里的代码太多了
答案 0 :(得分:0)
我猜你试图调用ticket()方法,但是你没有将参数传递给ticket(“testTicket”),或者当你试图调用ticket(value)时,你的变量可能没有从源代码获得价值,我我很确定。一切都很直接。
尝试遵循它:
public void SomeEvent()
{
string value = "testTicket";
ticket(value);
}
public static void ticket(string ticketName) // ticketName = "testTicket"
{
string abc = ticketName; // result : abc null
}
祝你好运。