protected override String DoIt() { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), _C_Lead_ID, Get_Trx()); if (!(R_InterestArea_ID > 0)) { return(Msg.GetMsg(GetCtx(), "NoInterestAreaIsSelected")); } if (lead.GetC_BPartner_ID() != 0) { VAdvantage.Model.X_R_ContactInterest customer = new VAdvantage.Model.X_R_ContactInterest(GetCtx(), 0, Get_Trx()); customer.SetR_InterestArea_ID(R_InterestArea_ID); customer.SetC_BPartner_ID(lead.GetC_BPartner_ID()); String query = "Select ad_user_id from ad_user where c_bpartner_id= " + lead.GetC_BPartner_ID(); int UserId = Util.GetValueOfInt(DB.ExecuteScalar(query)); customer.SetAD_User_ID(UserId); query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + lead.GetC_BPartner_ID(); int Id = Util.GetValueOfInt(DB.ExecuteScalar(query)); VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), Id, Get_Trx()); customer.SetC_BPartner_Location_ID(Id); customer.SetPhone(loc.GetPhone()); customer.SetFax(loc.GetFax()); VAdvantage.Model.X_AD_User us = new VAdvantage.Model.X_AD_User(GetCtx(), UserId, Get_Trx()); customer.SetC_Job_ID(us.GetC_Job_ID()); customer.SetSubscribeDate(DateTime.Today); query = "Select Email from ad_user where ad_user_id= " + UserId; String mail = Util.GetValueOfString(DB.ExecuteScalar(query)); customer.SetEMail(mail); if (!customer.Save()) { return(Msg.GetMsg(GetCtx(), "NotSubscribed")); } lead.SetR_InterestArea_ID(customer.GetR_InterestArea_ID()); if (lead.Save()) { } return(Msg.GetMsg(GetCtx(), "SubscribedDone")); } else if (lead.GetRef_BPartner_ID() != 0) { VAdvantage.Model.X_R_ContactInterest Prospect = new VAdvantage.Model.X_R_ContactInterest(GetCtx(), 0, Get_Trx()); Prospect.SetR_InterestArea_ID(R_InterestArea_ID); Prospect.SetC_BPartner_ID(lead.GetRef_BPartner_ID()); String query = "Select ad_user_id from ad_user where c_bpartner_id= " + lead.GetRef_BPartner_ID(); int UserId = Util.GetValueOfInt(DB.ExecuteScalar(query)); Prospect.SetAD_User_ID(UserId); query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + lead.GetRef_BPartner_ID(); int Id = Util.GetValueOfInt(DB.ExecuteScalar(query)); VAdvantage.Model.X_C_BPartner_Location loc = new VAdvantage.Model.X_C_BPartner_Location(GetCtx(), Id, Get_Trx()); Prospect.SetC_BPartner_Location_ID(Id); Prospect.SetPhone(loc.GetPhone()); Prospect.SetFax(loc.GetFax()); VAdvantage.Model.X_AD_User us = new VAdvantage.Model.X_AD_User(GetCtx(), UserId, Get_Trx()); Prospect.SetC_Job_ID(us.GetC_Job_ID()); Prospect.SetSubscribeDate(DateTime.Today); query = "Select Email from ad_user where ad_user_id= " + UserId; String mail = Util.GetValueOfString(DB.ExecuteScalar(query)); Prospect.SetEMail(mail); if (!Prospect.Save()) { return(Msg.GetMsg(GetCtx(), "NotSubscribed")); } lead.SetR_InterestArea_ID(Prospect.GetR_InterestArea_ID()); if (lead.Save()) { } return(Msg.GetMsg(GetCtx(), "SubscribedDone")); } else { VAdvantage.Model.X_vss_lead_interestarea Ilead = new VAdvantage.Model.X_vss_lead_interestarea(GetCtx(), 0, Get_Trx()); Ilead.SetC_Lead_ID(lead.GetC_Lead_ID()); Ilead.SetR_InterestArea_ID(R_InterestArea_ID); Ilead.SetAD_User_ID(lead.GetAD_User_ID()); Ilead.SetBPName(lead.GetBPName()); Ilead.SetEMail(lead.GetEMail()); Ilead.SetPhone(lead.GetPhone()); Ilead.SetFax(lead.GetFax()); Ilead.SetAddress1(lead.GetAddress1()); Ilead.SetAddress2(lead.GetAddress2()); Ilead.SetC_City_ID(lead.GetC_City_ID()); Ilead.SetCity(lead.GetCity()); Ilead.SetC_Region_ID(lead.GetC_Region_ID()); Ilead.SetRegionName(lead.GetRegionName()); Ilead.SetC_Country_ID(lead.GetC_Country_ID()); Ilead.SetPostal(lead.GetPostal()); Ilead.SetSubscribeDate(DateTime.Today); if (!Ilead.Save()) { return(Msg.GetMsg(GetCtx(), "NotSubscribed")); } lead.SetR_InterestArea_ID(Ilead.GetR_InterestArea_ID()); if (lead.Save()) { } return(Msg.GetMsg(GetCtx(), "SubscribedDone")); } }
protected override String DoIt() { string sql = "Select ad_table_id from ad_table where tablename='C_Lead'"; int leadTable_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql)); sql = "Select ad_table_id from ad_table where tablename='C_BPartner'"; int BPartnerTable_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql)); VAdvantage.Model.X_C_TargetList TList = new VAdvantage.Model.X_C_TargetList(GetCtx(), 0, null); if (Table_id == leadTable_ID)// C_Lead { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Record_ID, null); TList.Set_ValueNoCheck("C_MasterTargetList_ID", Campaign_id); // TList.SetC_MasterTargetList_ID(Campaign_id); TList.SetC_Lead_ID(Record_ID); TList.SetAddress1(lead.GetAddress1()); TList.SetAddress2(lead.GetAddress2()); TList.SetC_City_ID(lead.GetC_City_ID()); TList.SetCity(lead.GetCity()); TList.SetC_Region_ID(lead.GetC_Region_ID()); TList.SetRegionName(lead.GetRegionName()); TList.SetC_Country_ID(lead.GetC_Country_ID()); TList.SetPostal(lead.GetPostal()); if (TList.Save()) { return(Msg.GetMsg(GetCtx(), "TargetListCreate")); } return(Msg.GetMsg(GetCtx(), "TargetListNotCreate")); } if (Table_id == BPartnerTable_ID) // C_BPartner { string Query = "select isprospect from c_bpartner where c_bpartner_id=" + Record_ID; string P = Util.GetValueOfString(DB.ExecuteScalar(Query)); if (P == "Y") { // TList.SetC_MasterTargetList_ID(Campaign_id); TList.Set_ValueNoCheck("C_MasterTargetList_ID", Campaign_id); TList.SetRef_BPartner_ID(Record_ID); sql = "Select C_Location_id from c_bpartner_Location where c_bpartner_id=" + Record_ID; object locID = DB.ExecuteScalar(sql); TList.SetC_Location_ID(Util.GetValueOfInt(locID)); } else { Query = "select iscustomer from c_bpartner where c_bpartner_id=" + Record_ID; P = Util.GetValueOfString(DB.ExecuteScalar(Query)); if (P == "Y") { //TList.SetC_MasterTargetList_ID(Campaign_id); TList.Set_ValueNoCheck("C_MasterTargetList_ID", Campaign_id); TList.SetC_BPartner_ID(Record_ID); sql = "Select C_Location_id from c_bpartner_Location where c_bpartner_id=" + Record_ID; object locID = DB.ExecuteScalar(sql); TList.SetC_Location_ID(Util.GetValueOfInt(locID)); } else { return(Msg.GetMsg(GetCtx(), "TargetListNotCreate")); } } if (TList.Save()) { return(Msg.GetMsg(GetCtx(), "TargetListCreate")); } return(Msg.GetMsg(GetCtx(), "TargetListNotCreate")); } return(Msg.GetMsg(GetCtx(), "TargetListCreate")); }
protected override String DoIt() { string query = "Select C_CampaignTargetList_id from C_CampaignTargetList where C_Campaign_id=" + GetRecord_ID() + " and ad_client_id = " + GetCtx().GetAD_Client_ID(); IDataReader MainDr = DB.ExecuteReader(query, null, Get_Trx()); IDataReader dr = null; try { query = "Delete From C_InviteeList where C_Campaign_id=" + GetRecord_ID(); int value = DB.ExecuteQuery(query); while (MainDr.Read()) { query = "Delete From C_InviteeList where "; int id = Util.GetValueOfInt(MainDr[0]); VAdvantage.Model.X_C_CampaignTargetList MCapTarget = new VAdvantage.Model.X_C_CampaignTargetList(GetCtx(), id, null); if (MCapTarget.GetC_MasterTargetList_ID() != 0) { query = "Select C_BPartner_ID from C_TargetList where C_MasterTargetList_ID=" + MCapTarget.GetC_MasterTargetList_ID() + " and C_BPartner_ID is not null"; dr = DB.ExecuteReader(query, null, Get_Trx()); while (dr.Read()) { invitee(Util.GetValueOfInt(dr[0])); } dr.Close(); query = "Select Ref_BPartner_ID from C_TargetList where C_MasterTargetList_ID=" + MCapTarget.GetC_MasterTargetList_ID() + " and Ref_BPartner_ID is not null"; dr = DB.ExecuteReader(query, null, Get_Trx()); while (dr.Read()) { invitee(Util.GetValueOfInt(dr[0])); } dr.Close(); query = "Select C_Lead_ID from C_TargetList where C_MasterTargetList_ID=" + MCapTarget.GetC_MasterTargetList_ID() + " and C_Lead_ID is not null"; dr = DB.ExecuteReader(query, null, Get_Trx()); while (dr.Read()) { string sql = "Select C_InviteeList_id from C_InviteeList where C_Lead_id=" + Util.GetValueOfInt(dr[0]); object Leadid = DB.ExecuteScalar(sql, null, Get_Trx()); if (Util.GetValueOfInt(Leadid) == 0) { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Util.GetValueOfInt(dr[0]), Get_Trx()); if (lead.GetC_BPartner_ID() != 0) { invitee(lead.GetC_BPartner_ID()); } else if (lead.GetRef_BPartner_ID() != 0) { invitee(lead.GetRef_BPartner_ID()); } else if (lead.GetContactName() != null) { VAdvantage.Model.X_C_InviteeList Invt = new VAdvantage.Model.X_C_InviteeList(GetCtx(), 0, Get_Trx()); //Invt.SetC_TargetList_ID(Util.GetValueOfInt(dr[0])); Invt.SetC_Campaign_ID(GetRecord_ID()); Invt.SetName(lead.GetContactName()); Invt.SetEMail(lead.GetEMail()); Invt.SetPhone(lead.GetPhone()); Invt.SetC_Lead_ID(lead.GetC_Lead_ID()); Invt.SetAddress1(lead.GetAddress1()); Invt.SetAddress1(lead.GetAddress2()); Invt.SetC_City_ID(lead.GetC_City_ID()); Invt.SetCity(lead.GetCity()); Invt.SetC_Region_ID(lead.GetC_Region_ID()); Invt.SetRegionName(lead.GetRegionName()); Invt.SetC_Country_ID(lead.GetC_Country_ID()); Invt.SetPostal(lead.GetPostal()); // Invt.SetURL(url); if (!Invt.Save()) { Msg.GetMsg(GetCtx(), "InviteeCteationNotDone"); } string ID = Invt.GetC_InviteeList_ID().ToString(); string encrypt = FormsAuthentication.HashPasswordForStoringInConfigFile(ID, "SHA1"); string urlFinal = ""; urlFinal = url + "?" + encrypt; sql = "update c_inviteelist set url = '" + urlFinal + "' where c_inviteelist_id = " + Invt.GetC_InviteeList_ID(); int res = Util.GetValueOfInt(DB.ExecuteQuery(sql, null, Get_Trx())); //Random rand = new Random(); //String s = ""; //for (int i = 0; i < 9; i++) // s = String.Concat(s, rand.Next(10).ToString()); //string urlFinal = ""; //// urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString(); //urlFinal = url + "?" + s; ////string urlFinal = ""; ////urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString(); //Invt.SetURL(urlFinal); //if (!Invt.Save(Get_Trx())) //{ // Msg.GetMsg(GetCtx(), "InviteeCteationNotDone"); //} } } } dr.Close(); } if (MCapTarget.GetR_InterestArea_ID() != 0) { query = "Select C_BPartner_ID from R_ContactInterest where R_InterestArea_ID=" + MCapTarget.GetR_InterestArea_ID() + " and C_BPartner_ID is not null"; dr = DB.ExecuteReader(query, null, Get_Trx()); while (dr.Read()) { invitee(Util.GetValueOfInt(dr[0])); } dr.Close(); //query = "Select C_BPartner_ID from C_TargetList where R_InterestArea_ID=" + MCapTarget.GetR_InterestArea_ID(); //dr = DB.ExecuteReader(query); //while (dr.Read()) //{ // invitee(Util.GetValueOfInt(dr[0])); //} //dr.Close(); query = "Select C_Lead_ID from vss_lead_interestarea where R_InterestArea_ID=" + MCapTarget.GetR_InterestArea_ID() + " and C_Lead_ID is not null"; dr = DB.ExecuteReader(query, null, Get_Trx()); while (dr.Read()) { string sql = "Select C_InviteeList_id from C_InviteeList where C_Lead_id=" + Util.GetValueOfInt(dr[0]); object Leadid = DB.ExecuteScalar(sql, null, Get_Trx()); if (Util.GetValueOfInt(Leadid) == 0) { VAdvantage.Model.X_C_Lead lead = new VAdvantage.Model.X_C_Lead(GetCtx(), Util.GetValueOfInt(dr[0]), Get_Trx()); if (lead.GetC_BPartner_ID() != 0) { invitee(lead.GetC_BPartner_ID()); } else if (lead.GetRef_BPartner_ID() != 0) { invitee(lead.GetRef_BPartner_ID()); } else if (lead.GetContactName() != null) { VAdvantage.Model.X_C_InviteeList Invt = new VAdvantage.Model.X_C_InviteeList(GetCtx(), 0, Get_Trx()); //Invt.SetC_TargetList_ID(Util.GetValueOfInt(dr[0])); Invt.SetC_Campaign_ID(GetRecord_ID()); Invt.SetName(lead.GetContactName()); Invt.SetEMail(lead.GetEMail()); Invt.SetPhone(lead.GetPhone()); Invt.SetC_Lead_ID(lead.GetC_Lead_ID()); Invt.SetAddress1(lead.GetAddress1()); Invt.SetAddress1(lead.GetAddress2()); Invt.SetC_City_ID(lead.GetC_City_ID()); Invt.SetCity(lead.GetCity()); Invt.SetC_Region_ID(lead.GetC_Region_ID()); Invt.SetRegionName(lead.GetRegionName()); Invt.SetC_Country_ID(lead.GetC_Country_ID()); Invt.SetPostal(lead.GetPostal()); //Invt.SetURL(url); if (!Invt.Save(Get_Trx())) { Msg.GetMsg(GetCtx(), "InviteeCteationNotDone"); } string ID = Invt.GetC_InviteeList_ID().ToString(); string encrypt = FormsAuthentication.HashPasswordForStoringInConfigFile(ID, "SHA1"); string urlFinal = ""; urlFinal = url + "?" + encrypt; sql = "update c_inviteelist set url = '" + urlFinal + "' where c_inviteelist_id = " + Invt.GetC_InviteeList_ID(); int res = Util.GetValueOfInt(DB.ExecuteQuery(sql, null, Get_Trx())); //Random rand = new Random(); //String s = ""; //for (int i = 0; i < 9; i++) // s = String.Concat(s, rand.Next(10).ToString()); //string urlFinal = ""; //urlFinal = url + "?" + s; ////string urlFinal = ""; ////urlFinal = url + "?" + Invt.GetC_InviteeList_ID().ToString(); //Invt.SetURL(urlFinal); //if (!Invt.Save(Get_Trx())) //{ // Msg.GetMsg(GetCtx(), "InviteeCteationNotDone"); //} } } } dr.Close(); } } MainDr.Close(); } catch { if (MainDr != null) { MainDr.Close(); MainDr = null; } if (dr != null) { dr.Close(); dr = null; } } return(Msg.GetMsg(GetCtx(), "InviteeCteationDone")); }