private void Send_Email_Release(int cg_code) { var url = getUrl(); var campaign = CT_Campaign.SingleOrDefault(cg_code); var approveUser = Get_ApproveUser((int)campaign.CG_Code, (int)campaign.CG_Type, (int)campaign.CG_Cat, 1); var send = Get_Send((int)campaign.CG_Created_By, approveUser.User_Code); string title = Resources.CRMTREEResource.cmp_app_request_title; string content = string.Format(Resources.CRMTREEResource.cmp_app_request_content, approveUser.User_Name, send.From_Name, campaign.CG_Code, url ); //System.Environment.NewLine string supportMailAccont = ConfigurationManager.AppSettings["suppotMailAccount"]; string suppotMailPwd = ConfigurationManager.AppSettings["suppotMailPwd"]; string mailServer = ConfigurationManager.AppSettings["mailServer"]; string displayName = ConfigurationManager.AppSettings["displayName"]; Mail.SendMail(supportMailAccont, suppotMailPwd, new List <string>(new string[] { send.EL_To }), new List <string>(new string[] { send.EL_From }), null, title, supportMailAccont, displayName, mailServer, content); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var Q_CG_Code = Request.QueryString["CG_Code"]; int CG_Code = 0; if (null != Q_CG_Code) { try { CG_Code = Convert.ToInt32(Q_CG_Code.ToString()); } catch (Exception) { } } if (CG_Code > 0) { var campaign = CT_Campaign.SingleOrDefault(CG_Code); if (null != campaign) { if (campaign.CG_Status.HasValue && campaign.CG_Status == 5) { Response.Redirect("/manage/campaign/CampaignApprove.aspx?CT=" + campaign.CG_Type + "&CG_Code=" + campaign.CG_Code); } } } } }
private void Send_Email_Reject(int cg_code) { var url = getUrl(); var campaign = CT_Campaign.SingleOrDefault(cg_code); var approveUser = Get_ApproveUser((int)campaign.CG_Code, (int)campaign.CG_Type, (int)campaign.CG_Cat, 1); var next_user = 0; if (null != approveUser) { next_user = approveUser.User_Code; } var send = Get_Send((int)campaign.CG_Created_By, next_user); string title = Resources.CRMTREEResource.cmp_app_rejected_title; string content = string.Format(Resources.CRMTREEResource.cmp_app_rejected_content, send.From_Name, UserSession.User.AU_Name, //approveUser.User_Name, campaign.CG_Code, url ); //System.Environment.NewLine campaign.CG_Status = 0; var cols = new string[] { "CG_Status" }; campaign.Update(cols); string supportMailAccont = ConfigurationManager.AppSettings["suppotMailAccount"]; string suppotMailPwd = ConfigurationManager.AppSettings["suppotMailPwd"]; string mailServer = ConfigurationManager.AppSettings["mailServer"]; string displayName = ConfigurationManager.AppSettings["displayName"]; Mail.SendMail(supportMailAccont, suppotMailPwd, new List <string>(new string[] { send.EL_From }), null, null, title, supportMailAccont, displayName, mailServer, content); }
private void Set_Status(dynamic data) { var bRelease = false; var s_campaign = JsonConvert.SerializeObject(data.campaign); CT_Campaign campaign = JsonConvert.DeserializeObject <CT_Campaign>(s_campaign); if (campaign.CG_Code > 0) { campaign.CG_Update_dt = DateTime.Now; campaign.CG_Updated_By = UserSession.User.AU_Code; var cols = new string[] { "CG_Status", "CG_Update_dt", "CG_Updated_By" }; campaign.Update(cols); bRelease = true; } Response.Write(JsonConvert.SerializeObject(new { isOK = bRelease })); }
private void Save_Camp_Methods(dynamic data, int cg_code, DBCRMTree db) { var s_campaign = JsonConvert.SerializeObject(data.campaign); CT_Campaign campaign = JsonConvert.DeserializeObject <CT_Campaign>(s_campaign); var s_smvs = JsonConvert.SerializeObject(data.camp_methods.changes); List <CT_Camp_Method> cms = JsonConvert.DeserializeObject <List <CT_Camp_Method> >(s_smvs); var file_guid = Guid.NewGuid().ToString(); byte index = 1; db.Execute("DELETE FROM CT_Camp_Methods WHERE CM_CG_Code = @0", cg_code); foreach (var cm in cms) { var CM_Filename = cm.CM_Filename; if (campaign.EX_T.HasValue && campaign.EX_T.Value == 1) { if (cm.CM_CG_Code > 0 && CM_Filename != cm.CM_Filename_Temp) { var fNames = CM_Filename.Split('.').ToList(); var extendName = "." + fNames[fNames.Count - 1]; cm.CM_Filename = file_guid + extendName; } } cm.CM_Contact_Index = index; cm.CM_CG_Code = cg_code; cm.Insert(); if (cm.EX_IsParamValue.HasValue && cm.EX_IsParamValue.Value && !string.IsNullOrWhiteSpace(cm.EX_ParamValue)) { Save_Param_Value_Method(cm.EX_ParamValue, cg_code, index, db); } Save_Camp_Files(CM_Filename, cm.CM_Filename_Temp, file_guid, campaign.EX_T); index++; } }
private int Save_CampaignInfo(dynamic data) { var s_campaign = JsonConvert.SerializeObject(data.campaign); CT_Campaign campaign = JsonConvert.DeserializeObject <CT_Campaign>(s_campaign); int cg_code = campaign.CG_Code; if (campaign.CG_Act_S_Dt.HasValue) { try { campaign.CG_Act_E_Dt = campaign.CG_Act_S_Dt.Value.AddDays(campaign.Ex_CG_Act_E_Dt.Value); campaign.CG_Start_Dt = campaign.CG_Act_S_Dt.Value.AddDays(-campaign.Ex_CG_Start_Dt.Value); campaign.CG_End_Dt = campaign.CG_Act_S_Dt.Value.AddDays(campaign.Ex_CG_End_Dt.Value - campaign.Ex_CG_Start_Dt.Value); } catch (Exception) { } } if (campaign.CG_Code > 0) { campaign.CG_Update_dt = DateTime.Now; campaign.CG_Updated_By = UserSession.User.AU_Code; if (!campaign.CG_Status.HasValue) { campaign.CG_Status = 0; } var cols = new string[] { "CG_Title", "CG_Share", "CG_Desc", "CG_RP_Code", "CG_Method", "CG_Whom", "CG_Mess_Type", "CG_EG_Code", "CG_RSVP", "CG_Max_Persons", "CG_Responsible", "CG_Tools", "CG_Budget", "CG_Start_Dt", "CG_End_Dt", "CG_Act_S_Dt", "CG_Act_E_Dt", //"CG_Filename", "CG_Update_dt", "CG_Updated_By", "CG_Status", "CG_OEMPay" //,"CG_Type" }; campaign.Update(cols); } else { campaign.CG_UType = (byte)UserSession.User.UG_UType; campaign.CG_AD_OM_Code = (int)UserSession.DealerEmpl.DE_AD_OM_Code; campaign.CG_Update_dt = DateTime.Now; campaign.CG_Created_By = UserSession.User.AU_Code; campaign.CG_Active_Tag = 1; campaign.CG_Status = 0; if (campaign.CG_Cat == null || campaign.CG_Cat == 0) { campaign.CG_Cat = 1; } if (campaign.EX_T.HasValue) { if (campaign.EX_T.Value == 1) { campaign.CG_Status = 0; } if (campaign.EX_T.Value == 2) { campaign.CG_Template = true; } } cg_code = (int)campaign.Insert(); } if (campaign.CG_Status == 5) { CT_Auth_Activity aa = new CT_Auth_Activity(); aa.AA_CG_Code = cg_code; aa.AA_AU_Code = UserSession.User.AU_Code; aa.AA_Update_dt = DateTime.Now; aa.AA_Type = 0; aa.Insert(); Send_Email_Release(cg_code); } //BL_CRMhandle blCRM=new BL_CRMhandle(); //blCRM.LoadCustomerizeVinToDB(campaign,cg_code); return(cg_code); }
/// <summary> /// 获得客户信息 /// </summary> /// <param name="data"></param> private void Get_Campaign(dynamic data) { dynamic o = new ExpandoObject(); o.AU_Code = UserSession.User.AU_Code; int CG_Code = (int)data.CG_Code; if (CG_Code > 0) { var campaign = CT_Campaign.SingleOrDefault(CG_Code); if (null == campaign) { throw new Exception(Interna ? "Campaign does not exist!" : "活动不存在!"); } if (campaign.CG_Act_S_Dt.HasValue) { long D = 864000000000; try { long Ex_CG_Act_E_Dt = campaign.CG_Act_E_Dt.Value.ToFileTime() - campaign.CG_Act_S_Dt.Value.ToFileTime(); campaign.Ex_CG_Act_E_Dt = (int)(Ex_CG_Act_E_Dt / D); long Ex_CG_Start_Dt = campaign.CG_Act_S_Dt.Value.ToFileTime() - campaign.CG_Start_Dt.Value.ToFileTime(); campaign.Ex_CG_Start_Dt = (int)(Ex_CG_Start_Dt / D); long Ex_CG_End_Dt = campaign.CG_End_Dt.Value.ToFileTime() - campaign.CG_Act_S_Dt.Value.ToFileTime(); campaign.Ex_CG_End_Dt = (int)(Ex_CG_End_Dt / D) + campaign.Ex_CG_Start_Dt; } catch (Exception) { } } o.campaign = campaign; var db = DBCRMTree.GetInstance(); o.sm_values = db.Query <dynamic>(string.Format(@"SELECT [SMV_PSM_Code] ,[SMV_Type] ,[SMV_CG_Code] ,[SMV_Days] ,[SMV_Val] ,{0} as SMV_PSM_Code_Text ,{1} as PSM_Val_Type FROM [CT_SM_Values] INNER JOIN CT_Succ_Matrix ON PSM_Code = SMV_PSM_Code AND SMV_CG_Code = @0", Interna ? "[PSM_Desc_EN]" : "[PSM_Desc_CN]", Interna ? "[PSM_Val_Type_EN]" : "[PSM_Val_Type_CN]" ), CG_Code); o.methods = db.Query <dynamic>(string.Format(@" SELECT CM_CG_Code , CM_Contact_Index , CM_Method , LEFT(CM_Method_Text,LEN(CM_Method_Text)-1) CM_Method_Text, CM_RP_Code , CM_RP_Code_Text , CM_Filename, CM_Filename as CM_Filename_Temp FROM ( SELECT CM_CG_Code ,CM_Contact_Index ,CM_Method ,(SELECT {0}+',' FROM dbo.words WHERE p_id IN(4059, 4064, 4068) AND value IN(SELECT * from dbo.f_split(CM_Method,',')) FOR XML PATH('') ) AS CM_Method_Text ,CM_RP_Code ,dbo.F_Format_Paramters_Method( CM_RP_Code ,CM_CG_Code ,CM_Contact_Index ,@1 ,@2 ,@3 ) AS CM_RP_Code_Text ,CM_Filename FROM CT_Camp_Methods WHERE CM_CG_Code=@0 )t order by CM_RP_Code,CM_Contact_Index", Interna ? "text_en" : "text_cn", Interna ? "RP_Name_EN" : "RP_Name_CN" ), CG_Code, UserSession.User.UG_UType, UserSession.DealerEmpl.DE_AD_OM_Code, Interna); if (!campaign.CG_Status.HasValue) { campaign.CG_Status = 0; } campaign.EX_CG_Status = db.ExecuteScalar <string>(string.Format( "select {0} from words where p_id=4044 and value=@0" , Interna ? "[text_en]" : "[text_cn]" ), campaign.CG_Status); if (campaign.CG_Status.HasValue && campaign.CG_Status.Value >= 5) { campaign.EX_Approve = 2; var approve = Get_ApproveUser(campaign.CG_Code, (int)campaign.CG_Type, (int)campaign.CG_Cat, 1); if (null != approve && approve.User_Code == UserSession.User.AU_Code) { campaign.EX_Approve = 1; } } } Response.Write(JsonConvert.SerializeObject(o)); }
private void Save_Activities(dynamic data) { //var ug_code = this.UserSession.AU_UG_Code; //if (ug_code != 28 && ug_code != 40) //{ // throw new Exception(Interna ? "Without the permission!" : "无此权限!"); //} var db = DBCRMTree.GetInstance(); try { using (var tran = db.GetTransaction()) { var s_activity = JsonConvert.SerializeObject(data.activity); EX_CT_Auth_Activities activity = JsonConvert.DeserializeObject <EX_CT_Auth_Activities>(s_activity); CT_Auth_Activity aa = new CT_Auth_Activity(); aa.AA_AT_Code = activity.EX_AT_Code; aa.AA_CG_Code = activity.EX_CG_Code; aa.AA_AU_Code = UserSession.User.AU_Code; aa.AA_Update_dt = DateTime.Now; if (activity.EX_State == 0) { aa.AA_Type = 200; } if (activity.EX_State == 1) { if (string.IsNullOrWhiteSpace(activity.EX_Remark)) { aa.AA_Type = 100; } else { aa.AA_Type = 101; } } var id = (int)aa.Insert(); if (!string.IsNullOrWhiteSpace(activity.EX_Remark)) { CT_Auth_Note an = new CT_Auth_Note(); an.AAN_AA_Code = id; an.AAN_Notes = activity.EX_Remark; an.Insert(); } if (activity.EX_State == 0) { CT_Campaign campaign = new CT_Campaign(); campaign.CG_Code = activity.EX_CG_Code; campaign.CG_Status = 0; campaign.CG_Update_dt = DateTime.Now; campaign.CG_Updated_By = UserSession.User.AU_Code; var cols = new string[] { "CG_Status", "CG_Update_dt", "CG_Updated_By" }; campaign.Update(cols); } if (activity.EX_State == 0) { Send_Email_Reject(activity.EX_CG_Code); } else { Send_Email_Approve(activity.EX_CG_Code); } tran.Complete(); } Response.Write(JsonConvert.SerializeObject(new { isOK = true })); } catch (Exception ex) { db.AbortTransaction(); Response.Write(JsonConvert.SerializeObject(new { isOK = false, msg = ex.Message })); } }
private void Send_Email_Approve(int cg_code) { var url = getUrl(); var campaign = CT_Campaign.SingleOrDefault(cg_code); var approveUser = Get_ApproveUser((int)campaign.CG_Code, (int)campaign.CG_Type, (int)campaign.CG_Cat, 1); string title = string.Empty; string title2 = string.Empty; string content = string.Empty; string supportMailAccont = ConfigurationManager.AppSettings["suppotMailAccount"]; string suppotMailPwd = ConfigurationManager.AppSettings["suppotMailPwd"]; string mailServer = ConfigurationManager.AppSettings["mailServer"]; string displayName = ConfigurationManager.AppSettings["displayName"]; EX_Approve send = new EX_Approve(); title = Resources.CRMTREEResource.cmp_app_approved_title; var next_user = 0; if (null != approveUser) { next_user = approveUser.User_Code; } if (next_user == 0) { send = Get_Send((int)campaign.CG_Created_By, next_user); title = Resources.CRMTREEResource.cmp_app_appr_Ready_title; CT_Campaign cmp = new CT_Campaign(); cmp.CG_Code = cg_code; cmp.CG_Status = 10; cmp.CG_Update_dt = DateTime.Now; cmp.CG_Updated_By = UserSession.User.AU_Code; var cols = new string[] { "CG_Status" }; cmp.Update(cols); } else { send = Get_Send((int)campaign.CG_Created_By, next_user); title2 = Resources.CRMTREEResource.cmp_app_request_title; content = string.Format(Resources.CRMTREEResource.cmp_app_request_content, approveUser.User_Name, send.From_Name, campaign.CG_Code, url ); //System.Environment.NewLine Mail.SendMail(supportMailAccont, suppotMailPwd, new List <string>(new string[] { send.EL_To }), new List <string>(new string[] { send.EL_From }), null, title2, supportMailAccont, displayName, mailServer, content); } content = string.Format(Resources.CRMTREEResource.cmp_app_approved_content, send.From_Name, UserSession.User.AU_Name, //approveUser.User_Name, campaign.CG_Code, url ); //System.Environment.NewLine Mail.SendMail(supportMailAccont, suppotMailPwd, new List <string>(new string[] { send.EL_From }), null, null, title, supportMailAccont, displayName, mailServer, content); }