コード例 #1
0
        private void SaveRequire()
        {
            //����Buyer
            if (Request.Form["email"] != null &&
                Request.Form["uname"] != null &&
                Request.Form["ugender"] != null &&
                Request.Form["utitle"] != null &&
                Request.Form["comName"] != null &&
                Request.Form["comIndustry"] != null &&
                Request.Form["comNature"] != null &&
                Request.Form["comEmployee"] != null &&
                Request.Form["comLocation"] != null &&
                Request.Form["comAddress"] != null &&
                Request.Form["comPhone"] != null)
            {
                string buyerGuid = Request.Form["buyerId"]==null?"":Request.Form["buyerId"].Trim();
                bool isPublic = Request.Form["isPublic"] == null ? false : (Request.Form["isPublic"].Trim() == "1" ? true : false);

                if (String.IsNullOrEmpty(buyerGuid) && Company.IsExistsEmail(Request.Form["email"].Trim()))
                {
                    Response.Write("existEmail");
                    return;
                }

                if (String.IsNullOrEmpty(buyerGuid))
                {
                    buyerGuid = Util.NewGuid;
                }

                Buyer buyer = new Buyer();
                buyer.InviteUserId = GetInviteUserId;
                buyer.Email = Request.Form["email"].Trim();
                buyer.Name = Request.Form["uname"].Trim();
                buyer.Gender = Convert.ToChar(Request.Form["ugender"].Trim());
                buyer.Title = Request.Form["utitle"].Trim();
                buyer.CompanyName = Request.Form["comName"].Trim();
                buyer.Industry = Request.Form["comIndustry"].Trim();
                buyer.Nature = Request.Form["comNature"].Trim();

                try
                {
                    buyer.Employees[0] = Convert.ToInt32(Request.Form["comEmployee"].Split(',')[0]);
                    buyer.Employees[1] = Convert.ToInt32(Request.Form["comEmployee"].Split(',')[1]);
                }
                catch
                {
                    //
                }

                buyer.ZIP = Request.Form["comLocation"].Trim();
                buyer.Address = Request.Form["comAddress"].Trim();
                buyer.PhoneNumber = Request.Form["comPhone"].Trim();
                buyer.Website = Request.Form["comWebsite"] != null ? Request.Form["comWebsite"].Trim() : "";

                int buyerId = buyer.Save(buyerGuid);

                if (buyerId > 0)
                {
                    //���¿ͻ�Email��Cookie
                    Util.WriteCookie("KEBIBI_BUYER_EMAIL", buyer.Email, 360);

                    //����Buyer Cookie
                    buyer.WriteCookie(360);

                    //����Lead
                    Lead lead = new Lead(LeadGuid, CurrentLeadInfo.Category, buyerId);
                    lead.Area = CurrentLeadInfo.Area;
                    lead.IndustryRequire = CurrentLeadInfo.IndustryRequired;
                    lead.NatrueRequire = CurrentLeadInfo.Nature;

                    lead.PublicStatus = isPublic ? (short)1 : (short)0;

                    if (lead.Save())
                    {
                        //�ƶ���ʱ�����ļ�
                        CurrentLeadInfo.Move(GeneralConfig.AppDataPath + "\\leads\\" + lead.Category + "\\" + DateTime.Now.ToString("yyyyMM")+"\\");

                        //�����ʼ�֪ͨ
                        MailTempItem mailTemp = MailTemplates.GetTemplate("buyer_require_over_email");
                        string[] args = new string[] {
                            buyer.CompanyName,
                            lead.Id.ToString(),
                            lead.Datetime.ToShortDateString(),
                            lead.Category,
                            lead.CategoryName,
                            CurrentLeadInfo.ToHtmlListForBuyer2("<p>{0}��{1}</p>")
                        };

                        SmtpMail sm = SmtpMail.Instance;
                        sm.AddRecipient(new string[] { buyer.Email });
                        sm.Html = mailTemp.Html;
                        sm.Subject = String.Format(mailTemp.Subject, args);
                        sm.Body = String.Format(mailTemp.Body, args);

                        bool snd = sm.Send();

                        //ɾ����ʱLead Guid��Cookie
                        Util.RemoveCookie(QuestionaryHandler._COOKIE_NAME);

                        //���浱ǰLead��ID��Cookie
                        Util.WriteCookie("KEBIBI_REQUIRE_INFO", CrypticString.Encrypt("id="+lead.Id.ToString()+"&guid="+lead.Guid+"&date="+lead.Datetime.ToShortDateString()+"&email="+buyer.Email+"&zip="+buyer.ZIP+"&zipName="+buyer.ZIPName+"&category="+lead.Category+"&categoryName="+lead.CategoryName,true));

                        Response.Write("true");
                        return;
                    }
                }
            }

            Response.Write("false");
        }