Пример #1
0
        public void SyncLinkmanInfo()
        {
            var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            var linkmanUpdateTime = DateTime.MinValue;
            if (!string.IsNullOrEmpty(config.AppSettings.Settings["LinkmanUpdateTime"].Value))
            {
                linkmanUpdateTime = DateTime.Parse(config.AppSettings.Settings["LinkmanUpdateTime"].Value);
            }

            var linkmen = new List<LinkmanDTO>();
            var connectionString = ConfigurationManager.ConnectionStrings["OracleNC"].ToString();
            var conn = new OracleConnection(connectionString); //进行连接
            try
            {
                conn.Open(); //打开指定的连接
                var com = conn.CreateCommand();
                com.CommandText = "select * from v_jdxt_lxr t where t.TS > '" +
                                  linkmanUpdateTime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                ;
                var odr = com.ExecuteReader();
                while (odr.Read()) //读取数据,如果返回为false的话,就说明到记录集的尾部了
                {
                    var linkman = new LinkmanDTO
                    {
                        CustCode = odr["CUSTCODE"].ToString(), //odr.GetOracleString(0).ToString(),
                        Department = odr["CUSTNAME"].ToString(), //odr.GetOracleString(1).ToString(),
                        Name = odr["LINKMAN1"].ToString(), //odr.GetOracleString(2).ToString(),
                        UpdateDate = DateTime.Parse(odr["TS"].ToString()),
                    };
                    if (linkman.UpdateDate.CompareTo(linkmanUpdateTime) > 0)
                    {
                        linkmanUpdateTime = linkman.UpdateDate;
                    }
                    linkmen.Add(linkman);
                }
                odr.Close(); //关闭reader.这是一定要写的
            }
            catch
            {
                //如果发生异常,则提示出错
            }
            finally
            {
                conn.Close(); //关闭打开的连接
            }
            _supplierAppService.SyncLinkmanInfo(linkmen);
            config.AppSettings.Settings["LinkmanUpdateTime"].Value = linkmanUpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
            config.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
        }
Пример #2
0
        public void ModifyLinkman(LinkmanDTO linkman)
        {
            Linkman updateLinkman = _linkmanRepository.Get(linkman.LinkmanId); //获取需要更新的对象。

            //更新。
            updateLinkman.Name = linkman.Name;
            updateLinkman.IsDefault = linkman.IsDefault;
            updateLinkman.TelePhone = linkman.TelePhone;
            updateLinkman.Mobile = linkman.Mobile;
            updateLinkman.Fax = linkman.Fax;
            updateLinkman.Email = linkman.Email;
            updateLinkman.SetSourceId(linkman.SourceId);
            updateLinkman.Address = new Address(null, null, linkman.Address, null);
            _linkmanRepository.Modify(updateLinkman);
        }
Пример #3
0
 public void DeleteLinkman(LinkmanDTO linkman)
 {
     Linkman deletedLinkman = _linkmanRepository.Get(linkman.LinkmanId); //获取需要更新的对象。
     _linkmanRepository.Remove(deletedLinkman); //删除联系人。
 }
Пример #4
0
 public void InsertLinkman(LinkmanDTO linkman)
 {
     Linkman newLinkman = LinkmanFactory.CreateLinkman(linkman.Name, linkman.IsDefault, linkman.TelePhone,
         linkman.Mobile,
         linkman.Fax, linkman.Email, linkman.Department, new Address(null, null, linkman.Address, null),
         linkman.SourceId, linkman.CustCode, DateTime.Now);
     _linkmanRepository.Add(newLinkman);
 }