Ejemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool Result = true;
            DB_Talk.BLL.m_PRIClock bll = new DB_Talk.BLL.m_PRIClock();
            List<DB_Talk.Model.m_PRIClock> lst = new List<DB_Talk.Model.m_PRIClock>();

            try
            {
                lst = getModel();
            }
            catch (Exception ex)
            {
                CommControl.MessageBoxEx.MessageBoxEx.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            try
            {
                foreach (DB_Talk.Model.m_PRIClock model in lst)
                {
                    if (Tools.MBoxOperate.SetPriClock(model))
                        bll.Update(model);
                    else
                    {
                        Result = false;
                        CommControl.MessageBoxEx.MessageBoxEx.Show("设置时钟源【" + model.i_Level + "】失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                if (Result)
                    CommControl.MessageBoxEx.MessageBoxEx.Show("设置时钟源成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);


                LoadData();
            }
            catch(Exception ex)
            {
                CommControl.Tools.WriteLog.AppendErrorLog(ex);
            }
        }
        //恢复出厂设置时清空数据库
        private void ClearDB()
        {
            //路由
            new DB_Talk.BLL.m_Route().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_RouteGroup().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_RouteRule().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            //中继
            new DB_Talk.BLL.m_SAPPoint().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_SIPInterface().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));

            new DB_Talk.BLL.m_PRIChannel().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_PRIInterface().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_PRISigLink().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));

            //号码规则
            new DB_Talk.BLL.m_CalinglSourceRule().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_CalledRule().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            new DB_Talk.BLL.m_CallingSource().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));

            //box
            DB_Talk.Model.m_Box model = new DB_Talk.Model.m_Box();
            model.ID = Global.Params.BoxID;
            model.i_DispatchNumber = 0;
            model.i_EmergencyNumber = 0;
            model.vc_NumberHead = "";
            model.i_NumberLen = 0;
            model.i_Flag = 1;
            new DB_Talk.BLL.m_Box().Update(model);

            //删除所有号码
            new DB_Talk.BLL.m_Member().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
            //new DB_Talk.BLL.m_Member().Delete(" i_Flag=0 and BoxID='" + Global.Params.BoxID + "' and i_IsDispatch=1");
            //删除组成员
            new DB_Talk.BLL.m_GroupMembers().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));

            //删除组,常用人员组不删除
            new DB_Talk.BLL.m_Group().Delete(string.Format(" BoxID='{0}' and vc_Name!='{1}'",
                Global.Params.BoxID, Global.Params.gruopNormalName));

            //删除部门信息,zhj说要删除的,多个站点时删除会有问题
            new DB_Talk.BLL.m_Departments().Delete("");

            //清日志,zhj说要删除的,多个站点时删除会有问题
           // new DB_Talk.BLL.Data_SystemLog().Delete("boxid=" + Global.Params.BoxID);
            new DB_Talk.BLL.Data_Alarm().Delete("boxid=" + Global.Params.BoxID);
            new DB_Talk.BLL.Data_DispatchLog().Delete("boxid=" + Global.Params.BoxID);

            //时钟源恢复为默认值
            DB_Talk.BLL.m_PRIClock BLL = new DB_Talk.BLL.m_PRIClock();
            List<DB_Talk.Model.m_PRIClock> lst = BLL.GetModelList(
                          string.Format(" i_Flag=0 and BoxID='{0}' ", Global.Params.BoxID));
            foreach (DB_Talk.Model.m_PRIClock modelClock in lst)
            {
                modelClock.i_Type = MBoxSDK.ConfigSDK.EnumPriClockType.内部.GetHashCode();
                modelClock.i_Port = 0;
                BLL.Update(modelClock);
            }
        }