Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    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 }));
        }
    }