private void RemoveDomain(int tenant, string user, int domainId)
        {
            try
            {
                var serverDal  = new ServerDal(tenant);
                var serverData = serverDal.GetTenantServer();

                if ((ServerType)serverData.type != ServerType.Postfix)
                {
                    return;
                }

                var mailserverfactory = new PostfixFactory();

                var setup = new ServerSetup
                            .Builder(serverData.id, tenant, user)
                            .SetConnectionString(serverData.connection_string)
                            .SetLogger(_log)
                            .Build();

                var mailServer = mailserverfactory.CreateServer(setup);

                var domain = mailServer.GetWebDomain(domainId, mailserverfactory);
                mailServer.DeleteWebDomain(domain, mailserverfactory);
            }
            catch (Exception ex)
            {
                _log.Error("RemoveDomain(tenant={0}, user=\"{1}\", domainId={2}) Exception: \r\n {3} \r\n",
                           tenant, user, domainId, ex.ToString());
            }
        }
        private void RemoveDomain(int tenant, string user, int domainId)
        {
            var serverDal  = new ServerDal(tenant);
            var serverData = serverDal.GetTenantServer();

            if ((ServerType)serverData.type != ServerType.Postfix)
            {
                return;
            }

            var mailserverfactory = new PostfixFactory();

            var setup = new ServerSetup
                        .Builder(serverData.id, tenant, user)
                        .SetConnectionString(serverData.connection_string)
                        .SetLogger(_log)
                        .Build();

            var mailServer = mailserverfactory.CreateServer(setup);

            var domain = mailServer.GetWebDomain(domainId, mailserverfactory);

            mailServer.DeleteWebDomain(domain, mailserverfactory);
        }
示例#3
0
        private void DownloadData()
        {
            try
            {
                using (TransactionScopeManager TM = new TransactionScopeManager())
                {
                    OrderDal orderDal = new OrderDal();
                    orderDal.TransactionScopeManager = TM;

                    if (orderDal.FindUnsortCount() == true)
                    {
                        if (DialogResult.Cancel == MessageBox.Show("还有未分拣的数据,您确定要重新下载数据吗?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                        {
                            return;
                        }
                    }

                    ChannelDal channelDal = new ChannelDal();
                    ServerDal  serverDal  = new ServerDal();

                    DataTable table = serverDal.FindBatch();
                    if (table.Rows.Count != 0)
                    {
                        string batchsortid = table.Rows[0]["batch_no"].ToString();
                        orderDal.DeleteExportData();//删除贴标机数据(未实现删除哪些表)


                        //AutomationContext.Write(plcServiceName, O_StockIn_Task_Info, data);
                        //下载烟道表
                        table = serverDal.FindChannel(batchsortid);
                        channelDal.InsertChannel(table);
                        System.Threading.Thread.Sleep(100);
                        //下载订单主表
                        table = serverDal.FindOrderMaster(batchsortid);
                        orderDal.InsertMaster(table);
                        System.Threading.Thread.Sleep(100);
                        //下载订单明细表
                        table = serverDal.FindOrderDetail(batchsortid);
                        orderDal.InsertOrderDetail(table);


                        //下载手工补货订单明细表
                        table = serverDal.FindHandleSupply(batchsortid);
                        orderDal.InsertHandleSupply(table);


                        //更新批次状态(下载完成)
                        serverDal.UpdateBatchStatus(batchsortid);
                        MessageBox.Show("数据下载完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        //Context.ProcessDispatcher.WriteToProcess("LEDProcess", "NewData", null);
                        //Context.ProcessDispatcher.WriteToProcess("CreatePackAndPrintDataProcess", "NewData", null);
                        //Context.ProcessDispatcher.WriteToProcess("CurrentOrderProcess", "CurrentOrderA", new int[] { -1 });
                        //Context.ProcessDispatcher.WriteToProcess("monitorView", "ProgressState", new ProgressState());
                    }
                    else
                    {
                        MessageBox.Show("没有需要分拣的订单数据。", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("下载数据失败!原因:" + e.Message);
            }
        }
示例#4
0
        private void RemoveTeamlabMailbox(MailBox mailbox)
        {
            if (mailbox == null)
            {
                throw new ArgumentNullException("mailbox");
            }

            if (!mailbox.IsTeamlab)
            {
                return;
            }

            try
            {
                var serverDal = new ServerDal(mailbox.TenantId);

                var serverData = serverDal.GetTenantServer();

                if ((ServerType)serverData.type != ServerType.Postfix)
                {
                    throw new NotSupportedException();
                }

                var mailserverfactory = new PostfixFactory();

                var limits = new ServerLimits.Builder()
                             .SetMailboxMaxCountPerUser(2)
                             .Build();

                var dnsPresets = new DnsPresets.Builder()
                                 .SetMx(serverData.mx_record, 0)
                                 .SetSpfValue("Spf")
                                 .SetDkimSelector("Dkim")
                                 .SetDomainCheckPrefix("DomainCheck")
                                 .Build();

                var setup = new ServerSetup
                            .Builder(serverData.id, mailbox.TenantId, mailbox.UserId)
                            .SetConnectionString(serverData.connection_string)
                            .SetLogger(_log)
                            .SetServerLimits(limits)
                            .SetDnsPresets(dnsPresets)
                            .Build();

                var mailServer = mailserverfactory.CreateServer(setup);

                var tlMailbox = mailServer.GetMailbox(mailbox.MailBoxId, mailserverfactory);

                if (tlMailbox == null)
                {
                    return;
                }

                var groups = mailServer.GetMailGroups(mailserverfactory);

                var groupsContainsMailbox = groups.Where(g => g.InAddresses.Contains(tlMailbox.Address))
                                            .Select(g => g);

                foreach (var mailGroup in groupsContainsMailbox)
                {
                    if (mailGroup.InAddresses.Count == 1)
                    {
                        mailServer.DeleteMailGroup(mailGroup.Id, mailserverfactory);
                    }
                    else
                    {
                        mailGroup.RemoveMember(tlMailbox.Address.Id);
                    }
                }

                mailServer.DeleteMailbox(tlMailbox);
            }
            catch (Exception ex)
            {
                _log.Error("RemoveTeamlabMailbox(mailboxId = {0}) Failure\r\nException: {1}", mailbox.MailBoxId,
                           ex.ToString());
            }
        }