示例#1
0
        public bool InsertEmailAdvice(We7.Model.Core.PanelContext data)
        {
            Advice advice = new Advice();

            advice.OwnID = Security.CurrentAccountID;
            //advice.TypeID = GetAdviceTypeID(data.ModelName);
            //advice.ID = GetValue<string>(data, "ID");
            advice.Title      = GetValue <string>(data, "Title");
            advice.UserID     = GetValue <string>(data, "UserID");
            advice.Content    = GetValue <string>(data, "Content");
            advice.CreateDate = DateTime.Now;
            advice.Updated    = DateTime.Now;

            advice.Name    = GetValue <string>(data, "Name");
            advice.Email   = GetValue <string>(data, "Email");
            advice.Address = GetValue <string>(data, "Address");
            advice.Phone   = GetValue <string>(data, "Phone");
            advice.Fax     = GetValue <string>(data, "Fax");

            advice.State = (int)AdviceState.WaitAccept;
            advice.SN    = AdviceHelper.CreateArticleSN();
            int isshow;

            Int32.TryParse(GetValue <string>(data, "IsShow"), out isshow);
            string stateStr = StateMgr.StateProcess(advice.EnumState, EnumLibrary.Business.AdviceDisplay, isshow);

            advice.IsShow    = isshow;
            advice.EnumState = stateStr;
            advice.Display1  = GetValue <string>(data, "Display1");
            advice.Display2  = GetValue <string>(data, "Display2");
            advice.Display3  = GetValue <string>(data, "Display3");
            if (advice.SN < 100000)
            {
                advice.SN = advice.SN + 100000;
            }
            advice.MyQueryPwd = We7Helper.CreateNewID().Substring(1, 8);

            //下面是添加模型信息
            string config, schema;

            advice.ModelXml    = GetModelDataXml(data, advice.ModelXml, out schema, out config);//获取模型数据
            advice.ModelConfig = config;
            advice.ModelName   = data.ModelName;
            advice.ModelSchema = schema;
            advice.TypeID      = GetValue <string>(data, "TypeID");
            if (String.IsNullOrEmpty(advice.TypeID))
            {
                AdviceType type = AdviceTypeHelper.GetAdviceTypeByModelName(data.ModelName);
                if (type != null)
                {
                    advice.TypeID = type.ID;
                }
            }

            AdviceHelper.AddAdvice(advice);

            SetValue(data, "ID", advice.ID);
            try
            {
                AdviceHelper.SendNotifyMail(advice.ID);
            }
            catch { }
            finally { }
            return(true);
        }