Ejemplo n.º 1
0
 public TargetConnectionInfo GetTargetInfo()
 {
     if (TargetConnectionType == TargetConnectionType.ConfigFile)
     {
         var parts = TargetConnection.Split('@');
         if (parts.Length == 2)
         {
             return new TargetConnectionInfo()
                    {
                        ConnectionName = parts[0], Filename = parts[1]
                    }
         }
         ;
         throw new InvalidOperationException($@"The TargetConnection property is not well-formed for retrieving a filename: {TargetConnection}");
     }
     throw new InvalidOperationException($"TargetConnectionType must be set to {nameof(TargetConnectionType.ConfigFile)}");
 }
Ejemplo n.º 2
0
        private bool IsIntraPoolMigration(KeyValuePair <string, VmMapping> mapping)
        {
            VM vm = xenConnection.Resolve(new XenRef <VM>(mapping.Key));

            if (vm.resident_on == mapping.Value.XenRef)
            {
                return(true);
            }

            Pool pool = Helpers.GetPool(vm.Connection);

            if (mapping.Value.XenRef is XenRef <Pool> )
            {
                Pool targetPool = TargetConnection.Resolve(mapping.Value.XenRef as XenRef <Pool>);
                if (pool == targetPool)
                {
                    return(true);
                }
            }

            Host host = xenConnection.Resolve(vm.resident_on) ?? Helpers.GetMaster(xenConnection);

            if (mapping.Value.XenRef is XenRef <Host> )
            {
                Host targetHost = TargetConnection.Resolve(mapping.Value.XenRef as XenRef <Host>);
                Pool targetPool = Helpers.GetPool(targetHost.Connection);

                // 2 stand alone hosts
                if (pool == null && targetPool == null)
                {
                    if (targetHost == host)
                    {
                        return(true);
                    }

                    return(false);
                }

                if (pool == targetPool)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public void OnClientPacket(int id, PacketBuffer buf)
        {
            switch (proxyState)
            {
            case ProxyState.Handshake:
                if (id == 0x00)
                {
                    HandleP00Handshake(buf.AsPacket <C00PacketHandshake>());
                }
                break;

            case ProxyState.Login:
                if (id == 0x00)
                {
                    HandleP00Login(buf.AsPacket <C00PacketLogin>());
                }
                break;

            case ProxyState.Status:
                if (id == 0x00)
                {
                    HandleP00StatusRequest();
                }
                else if (id == 0x01)
                {
                    HandleP01StatusPing(buf.AsPacket <SC01StatusPing>());
                }
                break;

            case ProxyState.Established:
                foreach (var proc in parent.PacketProcessors)
                {
                    var e = new PacketEvent(this, id, buf);
                    proc.ProcessClientPacket(e);
                    buf = e.Buffer;
                    if (e.Cancelled)
                    {
                        return;
                    }
                }
                TargetConnection.SendPacket(id, buf);
                break;
            }
        }
Ejemplo n.º 4
0
        public static int OpenOsaiCom()
        {
            m_TC        = new TargetConnection();
            m_TC.Server = new Cndex();
            String ip_str = "http://192.168.0.2:8080/";

            if (m_TC.Server.OpenSession_C(ip_str, out m_TC.Session, out ErrClass, out ErrNum) == 0)
            {
                return(0);
            }
            return(0);

            if (m_TC.Server.BootPhaseEnquiry_C(m_TC.Session, out Phase, out ErrClass, out ErrNum) == 0)
            {
                return(0);
            }
            OpenFlag = true;
            return(1);
        }
Ejemplo n.º 5
0
        protected override void FinishWizard()
        {
            if (!AllVMsAvailable(m_vmMappings, xenConnection))
            {
                base.FinishWizard();
                return;
            }

            foreach (KeyValuePair <string, VmMapping> pair in m_vmMappings)
            {
                VM vm = xenConnection.Resolve(new XenRef <VM>(pair.Key));

                Host target = TargetConnection.Resolve(m_vmMappings[pair.Key].XenRef as XenRef <Host>);

                //if a pool has been selected but no specific homeserver Key is the pool opaque ref
                if (target == null)
                {
                    Pool targetPool = TargetConnection.Resolve(m_vmMappings[pair.Key].XenRef as XenRef <Pool>);

                    if (targetPool == null)
                    {
                        ShowErrorMessageBox(Messages.CPM_WIZARD_ERROR_TARGET_DISCONNECTED);
                        base.FinishWizard();
                        return;
                    }

                    target = TargetConnection.Resolve(targetPool.master);
                }

                if (target == null)
                {
                    throw new ApplicationException("Cannot resolve the target host");
                }

                new VMCrossPoolMigrateAction(vm, target, SelectedTransferNetwork, pair.Value).RunAsync();
            }

            base.FinishWizard();
        }
        private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List <object> targetRefs, IStorageResource resource, ref List <ToStringWrapper <SR> > commonSRs)
        {
            var cb = new DataGridViewComboBoxCell {
                FlatStyle = FlatStyle.Flat
            };

            foreach (var pbd in TargetConnection.Cache.PBDs)
            {
                if (pbd.SR == null)
                {
                    continue;
                }

                var sr = TargetConnection.Resolve(pbd.SR);
                if (sr == null || sr.IsDetached() || !sr.Show(XenAdminConfigManager.Provider.ShowHiddenVMs))
                {
                    continue;
                }

                if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid)
                {
                    continue;
                }
                if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid)
                {
                    continue;
                }

                bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef);

                if ((sr.shared || srOnHost) &&
                    (!IsExtraSpaceNeeded(resource.SR, sr) ||
                     resource.TryCalcRequiredDiskCapacity(out ulong capacity) && (ulong)sr.FreeSpace() > capacity &&
                     SrsAreSuitable(resource.SR, sr)))
                {
                    var count = (from ToStringWrapper <SR> existingItem in cb.Items
                                 where existingItem.item.opaque_ref == sr.opaque_ref
                                 select existingItem).Count();
                    if (count > 0)
                    {
                        continue;                         //iterating through pbds
                    }
                    var newItem = new ToStringWrapper <SR>(sr, GetSRDropDownItemDisplayString);
                    cb.Items.Add(newItem);

                    if (SR.IsDefaultSr(sr))
                    {
                        cb.Value = newItem;
                    }

                    //store items to populate the m_comboBoxSr

                    if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef))))
                    {
                        var num = (from ToStringWrapper <SR> existingItem in commonSRs
                                   where existingItem.item.opaque_ref == sr.opaque_ref
                                   select existingItem).Count();
                        if (num <= 0)
                        {
                            commonSRs.Add(newItem);
                        }
                    }
                }
            }
            return(cb);
        }
Ejemplo n.º 7
0
        protected override void FinishWizard()
        {
            if (!AllVMsAvailable(m_vmMappings, xenConnection))
            {
                base.FinishWizard();
                return;
            }

            if (wizardMode == WizardMode.Copy && m_pageCopyMode.IntraPoolCopySelected)
            {
                if (m_pageIntraPoolCopy.CloneVM)
                {
                    new VMCloneAction(m_pageIntraPoolCopy.TheVM, m_pageIntraPoolCopy.NewVmName, m_pageIntraPoolCopy.NewVMmDescription).RunAsync();
                }

                else if (m_pageIntraPoolCopy.SelectedSR != null)
                {
                    new VMCopyAction(m_pageIntraPoolCopy.TheVM, m_pageIntraPoolCopy.TheVM.GetStorageHost(false),
                                     m_pageIntraPoolCopy.SelectedSR, m_pageIntraPoolCopy.NewVmName, m_pageIntraPoolCopy.NewVMmDescription).RunAsync();
                }

                base.FinishWizard();
                return;
            }

            foreach (KeyValuePair <string, VmMapping> pair in m_vmMappings)
            {
                VM vm = xenConnection.Resolve(new XenRef <VM>(pair.Key));

                Host target = TargetConnection.Resolve(m_vmMappings[pair.Key].XenRef as XenRef <Host>);

                //if a pool has been selected but no specific homeserver Key is the pool opaque ref
                if (target == null)
                {
                    Pool targetPool = TargetConnection.Resolve(m_vmMappings[pair.Key].XenRef as XenRef <Pool>);

                    if (targetPool == null)
                    {
                        ShowErrorMessageBox(Messages.CPM_WIZARD_ERROR_TARGET_DISCONNECTED);
                        base.FinishWizard();
                        return;
                    }

                    target = TargetConnection.Resolve(targetPool.master);
                }

                if (target == null)
                {
                    throw new ApplicationException("Cannot resolve the target host");
                }

                if (wizardMode == WizardMode.Move && IsIntraPoolMove(pair))
                {
                    new VMMoveAction(vm, pair.Value.Storage, target).RunAsync();
                }
                else
                {
                    new VMCrossPoolMigrateAction(vm, target, SelectedTransferNetwork, pair.Value, wizardMode == WizardMode.Copy).RunAsync();
                }
            }

            base.FinishWizard();
        }
        private static bool LoadAcceptedDomain(ExSearchResultEntry entry, Connection sourceConnection, TargetConnection targetConnection, object state)
        {
            EhfConfigTargetConnection ehfConfigTargetConnection = (EhfConfigTargetConnection)targetConnection;

            if (!EhfSynchronizer.LoadFullEntry(entry, EhfDomainSynchronizer.AcceptedDomainAllAttributes, ehfConfigTargetConnection))
            {
                return(false);
            }
            if (!EhfDomainSynchronizer.ValidateDomainName(entry, ehfConfigTargetConnection.DiagSession))
            {
                return(false);
            }
            string configUnitDN = null;

            if (!EhfDomainSynchronizer.TryGetConfigUnit(entry, ehfConfigTargetConnection.DiagSession, out configUnitDN))
            {
                return(false);
            }
            EhfCompanyIdentity ehfCompanyIdentity;

            if (!ehfConfigTargetConnection.TryGetEhfCompanyIdentity(configUnitDN, "ignoring the object", out ehfCompanyIdentity))
            {
                return(false);
            }
            EhfDomainSynchronizer.AddAttributeToChangeEntry(entry, "msExchTenantPerimeterSettingsOrgID", ehfCompanyIdentity.EhfCompanyId.ToString());
            EhfDomainSynchronizer.AddAttributeToChangeEntry(entry, "msEdgeSyncEhfCompanyGuid", ehfCompanyIdentity.EhfCompanyGuid.ToString());
            return(true);
        }
Ejemplo n.º 9
0
        protected override void FinishWizard()
        {
            if (!AllVMsAvailable(m_vmMappings, xenConnection))
            {
                base.FinishWizard();
                return;
            }

            if (wizardMode == WizardMode.Copy && m_pageCopyMode.IntraPoolCopySelected)
            {
                if (m_pageIntraPoolCopy.CloneVM)
                {
                    new VMCloneAction(m_pageIntraPoolCopy.TheVM, m_pageIntraPoolCopy.NewVmName, m_pageIntraPoolCopy.NewVMmDescription).RunAsync();
                }

                else if (m_pageIntraPoolCopy.SelectedSR != null)
                {
                    new VMCopyAction(m_pageIntraPoolCopy.TheVM, m_pageIntraPoolCopy.TheVM.GetStorageHost(false),
                                     m_pageIntraPoolCopy.SelectedSR, m_pageIntraPoolCopy.NewVmName, m_pageIntraPoolCopy.NewVMmDescription).RunAsync();
                }

                base.FinishWizard();
                return;
            }

            foreach (KeyValuePair <string, VmMapping> pair in m_vmMappings)
            {
                VM vm = xenConnection.Resolve(new XenRef <VM>(pair.Key));

                Host target = TargetConnection.Resolve(m_vmMappings[pair.Key].XenRef as XenRef <Host>);

                //if a pool has been selected but no specific homeserver Key is the pool opaque ref
                if (target == null)
                {
                    Pool targetPool = TargetConnection.Resolve(m_vmMappings[pair.Key].XenRef as XenRef <Pool>);

                    if (targetPool == null)
                    {
                        ShowErrorMessageBox(Messages.CPM_WIZARD_ERROR_TARGET_DISCONNECTED);
                        base.FinishWizard();
                        return;
                    }

                    target = TargetConnection.Resolve(targetPool.master);
                }

                if (target == null)
                {
                    throw new ApplicationException("Cannot resolve the target host");
                }

                if (wizardMode == WizardMode.Move && IsIntraPoolMove(pair))
                {
                    new VMMoveAction(vm, pair.Value.Storage, target).RunAsync();
                }
                else
                {
                    var isCopy        = wizardMode == WizardMode.Copy;
                    var migrateAction =
                        new VMCrossPoolMigrateAction(vm, target, SelectedTransferNetwork, pair.Value, isCopy, m_pageDestination.IsMigrateEncryption());

                    if (_resumeAfterMigrate)
                    {
                        var title            = VMCrossPoolMigrateAction.GetTitle(vm, target, isCopy);
                        var startDescription = isCopy ? Messages.ACTION_VM_COPYING: Messages.ACTION_VM_MIGRATING;
                        var endDescription   = isCopy ? Messages.ACTION_VM_COPIED: Messages.ACTION_VM_MIGRATED;

                        var actions = new List <AsyncAction>()
                        {
                            migrateAction,
                            new ResumeAndStartVMsAction(vm.Connection, target, new List <VM> {
                                vm
                            }, new List <VM>(), null, null)
                        };

                        new MultipleAction(vm.Connection, title, startDescription, endDescription,
                                           actions, true, false, true).RunAsync();
                    }
                    else
                    {
                        migrateAction.RunAsync();
                    }
                }
            }

            base.FinishWizard();
        }
Ejemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            m_TC        = new TargetConnection();
            m_TC.Server = new Cndex();
            String ip_str = "http://192.168.0.2:8080/";

            if (m_TC.Server.OpenSession_C(ip_str, out m_TC.Session, out ErrClass, out ErrNum) == 0)
            {
                MessageBox.Show("连接通信失败");
            }
            if (m_TC.Server.BootPhaseEnquiry_C(m_TC.Session, out Phase, out ErrClass, out ErrNum) == 0)
            {
                MessageBox.Show("初始化引导程序失败");
            }
            #region "读写操作"
            double[] OutDou = new double[1] {
                1.0
            };
            double[] InDou = { 0, 0 };
            if (m_TC.Server.WriteVarDouble_C(m_TC.Session, CndexLinkDotNet.Cndex.MD_CODE, 0, 100, 1, OutDou, out ErrClass, out ErrNum) == 0)
            {
                MessageBox.Show("写入double有误");
            }
            if (m_TC.Server.ReadVarDouble_C(m_TC.Session, CndexLinkDotNet.Cndex.MD_CODE, 0, 100, 3, InDou, out ErrClass, out ErrNum) == 0)
            {
                MessageBox.Show("读取double有误");
            }
            for (int i = 0; i < 1; i++)
            {
                Console.WriteLine("写入{0}", OutDou[i].ToString());
                Console.WriteLine("读取{0},长度{1}", InDou[i].ToString(), InDou.Length);
            }
            String text = "hell World";
            if (m_TC.Server.WriteVarText_C(m_TC.Session,
                                           CndexLinkDotNet.Cndex.SC_CODE,
                                           1,
                                           11,
                                           (short)text.Length,
                                           text,
                                           out ErrClass,
                                           out ErrNum) == 0)
            {
                MessageBox.Show("写入文本错误");
            }
            String Intext = "";
            if (m_TC.Server.ReadVarText_C(m_TC.Session, CndexLinkDotNet.Cndex.SC_CODE, 1, 14, 10, out Intext, out ErrClass, out ErrNum) > 0)
            {
                Console.WriteLine("读取到的文本信息{0}", Intext);
            }
            Int16[] InBuffer = { 0 };
            if (m_TC.Server.WriteVarWordBit_C(m_TC.Session, CndexLinkDotNet.Cndex.M_CODE, 0, 160, 0, 1, out ErrClass, out ErrNum) == 0)
            {
                MessageBox.Show("写位失败");
            }
            if (m_TC.Server.ReadVarWord_C(m_TC.Session, Cndex.M_CODE, 0, 160, 1, InBuffer, out ErrClass, out ErrNum) > 0)
            {
                Console.WriteLine("读取位{0}", InBuffer[0]);
            }
            #endregion
            #region "读写速度"
            //StringBuilder tm = new StringBuilder();
            //double[] readtext = new double[3];
            //double[] writeTetx = new double[3] { 1.0, 2.0, 3.0 };
            ////DateTime oldtime = DateTime.Now;
            ////    for (int i = 0; i < 100; i++)
            ////    {
            ////        //wriken 测试读取的速率 double 写入数据有问题
            ////         if (m_TC.Server.WriteVarDouble_C(m_TC.Session, CndexLinkDotNet.Cndex.MD_CODE, 0, 100, 1, writeTetx, out ErrClass, out ErrNum) == 0)
            ////            MessageBox.Show("写入double有误");
            ////        if (m_TC.Server.ReadVarDouble_C(m_TC.Session, CndexLinkDotNet.Cndex.MD_CODE, 0, 100, 3, readtext, out ErrClass, out ErrNum) == 0)
            ////            MessageBox.Show("读取double有误");
            ////    }
            ////    DateTime newtime = DateTime.Now;
            ////    long testtime = (long)(newtime.Ticks - oldtime.Ticks);
            ////TimeSpan ts = new TimeSpan(testtime);
            ////Console.WriteLine("double的读写的速度{0}秒", ts.TotalSeconds);
            ////DateTime oldtime = DateTime.Now;
            //DateTime oldtime = DateTime.Now;
            //for (int i = 0; i < 100; i++)
            //{
            //    if (m_TC.Server.WriteVarWordBit_C(m_TC.Session, CndexLinkDotNet.Cndex.M_CODE, 0, 150, 0, 1, out ErrClass, out ErrNum) == 0)
            //        MessageBox.Show("写位失败");
            //    if (m_TC.Server.ReadVarWord_C(m_TC.Session, Cndex.M_CODE, 0, 150, 1, InBuffer, out ErrClass, out ErrNum) == 0)
            //        MessageBox.Show("读取失败");
            //}
            //DateTime newtime = DateTime.Now;
            //long testtime = (long)(newtime.Ticks - oldtime.Ticks);
            //TimeSpan ts = new TimeSpan(testtime);
            //Console.WriteLine("double的读写的速度{0}秒", ts.TotalSeconds);

            //DateTime oldtime = DateTime.Now;
            //for (int i = 0; i < 100; i++)
            //{
            //    if (m_TC.Server.WriteVarText_C(m_TC.Session,
            //                                   CndexLinkDotNet.Cndex.SC_CODE,
            //                                   1,
            //                                   11,
            //                                  (short)text.Length,
            //                                   text,
            //                                   out ErrClass,
            //                                   out ErrNum) == 0)
            //        MessageBox.Show("写入文本错误");
            //    if (m_TC.Server.ReadVarText_C(m_TC.Session, CndexLinkDotNet.Cndex.SC_CODE, 1, 14, 10, out Intext, out ErrClass, out ErrNum) == 0)
            //        MessageBox.Show("读取文本错误");
            //}
            //DateTime newtime = DateTime.Now;
            //long testtime = (long)(newtime.Ticks - oldtime.Ticks);
            //TimeSpan ts = new TimeSpan(testtime);
            //Console.WriteLine("double的读写的速度{0}秒", ts.TotalSeconds);
            #endregion
            #region "文件操作"
            //if (m_TC.Server.LogFSTransferFileW_C(null, "C:\\Users\\ykweng\\Desktop\\1.txt", "IP.192.168.0.2", "PROGRAMS\\OPEN20_QVIDEO\\Bitmap\\1.txt", out ErrClass, out ErrNum) > 0)
            //    MessageBox.Show("文件传输成功");
            //  Cndex.SECURITY_LEVEL_C Level = 0;
            //if (m_TC.Server.LogFSGetSecurityLevel_C(m_TC.Session, out Level, out ErrClass, out ErrNum) == 0)
            //MessageBox.Show("获取文件加密级别失效");
            //Int16 FileNames;
            //if(m_TC.Server.LogFSLongFileNames_C(m_TC.Session,out FileNames,out ErrClass,out ErrNum)==0)
            //    MessageBox.Show("获取文件名失效");
            //Int16 HideDriver = 0;
            //Int16 UserDriver = 0;
            //if(m_TC.Server.LogFSGetNumDrive_C(m_TC.Session,out HideDriver,out UserDriver,out ErrClass,out ErrNum)==0)
            //    MessageBox.Show("获取驱动器个数失效");
            //Console.WriteLine("获取隐藏驱动器{0}使用的驱动器{1}", HideDriver,UserDriver);
            //  string DriveName = "PROGRAMS";
            // string DriveParh = string.Empty;
            //if (m_TC.Server.LogFSGetDrivePath_C(m_TC.Session,DriveName,out DriveParh,))
            #endregion
            #region "其他工具"
            short RecordNum = 1;
            //读取系统表信息
            //if (m_TC.Server.GetAxisTabRecord_C(m_TC.Session, 1, out AxisRecord, out ErrClass, out ErrNum) == 0)
            //    //     Console.WriteLine("读取轴表中的记录{0}", AxisRecord);
            //    MessageBox.Show("错误类" + ErrClass.ToString() + "错误码" + ErrNum.ToString());

            //if (m_TC.Server.GetToolTabRecord_C(m_TC.Session, RecordNum, out ToolRecord, out ErrClass, out ErrNum) == 0)
            //    //Console.WriteLine("读取工具表中的记录{0}",ToolRecord);
            //    MessageBox.Show("错误类" + ErrClass.ToString() + "错误码" + ErrNum.ToString());

            //if (m_TC.Server.GetOffsetTabRecord_C(m_TC.Session, RecordNum, out OffsetRecord, out ErrClass, out ErrNum)== 0)
            //    MessageBox.Show("错误类" + ErrClass.ToString() + "错误码" + ErrNum.ToString());
            //if (m_TC.Server.GetUserTabRecord_C(m_TC.Session, RecordNum, out UserRecord, out ErrClass, out ErrNum) == 0)
            //    MessageBox.Show("错误类" + ErrClass.ToString() + "错误码" + ErrNum.ToString());
            //if ( m_TC.Server.SetAxisTabRecord_C(m_TC.Session, RecordNum, ref AxisRecord, out ErrClass, out ErrNum)>0)
            //        Console.WriteLine("读取轴表中的记录{0}", AxisRecord);
            //if(m_TC.Server.SetToolTabRecord_C(m_TC.Session, RecordNum, ref ToolRecord, out ErrClass, out ErrNum)>0)
            //    Console.WriteLine("读取工具表中的记录{0}",ToolRecord);
            //m_TC.Server.SetOffsetTabRecord_C(m_TC.Session, RecordNum, ref OffsetRecord, out ErrClass, out ErrNum);

            //m_TC.Server.SetUserTabRecord_C(m_TC.Session, RecordNum, ref UserRecord, out ErrClass, out ErrNum);


            #endregion
        }
        private static FilterResult LoadAndFilter(ExSearchResultEntry entry, Connection sourceConnection, TargetConnection targetConnection)
        {
            if (entry.DistinguishedName.EndsWith(MserveSynchronizationProvider.rootDomainLostAndFoundContainerDN, StringComparison.OrdinalIgnoreCase))
            {
                return(FilterResult.Skip);
            }
            ExSearchResultEntry exSearchResultEntry = sourceConnection.ReadObjectEntry(entry.DistinguishedName, MserveSynchronizationProvider.RequiredAttributes);

            if (exSearchResultEntry == null)
            {
                return(FilterResult.Skip);
            }
            RecipientTypeDetails recipientTypeDetails = RecipientTypeDetails.None;
            DirectoryAttribute   directoryAttribute   = null;

            if (exSearchResultEntry.Attributes.TryGetValue("msExchRecipientTypeDetails", out directoryAttribute) && directoryAttribute != null && directoryAttribute.Count > 0)
            {
                try
                {
                    recipientTypeDetails = (RecipientTypeDetails)Enum.Parse(typeof(RecipientTypeDetails), directoryAttribute[0] as string, true);
                }
                catch (ArgumentException)
                {
                }
                catch (OverflowException)
                {
                }
            }
            if (recipientTypeDetails == RecipientTypeDetails.MailboxPlan || recipientTypeDetails == RecipientTypeDetails.RoleGroup)
            {
                return(FilterResult.Skip);
            }
            if (!entry.Attributes.ContainsKey("msExchExternalSyncState") && exSearchResultEntry.Attributes.ContainsKey("msExchExternalSyncState"))
            {
                entry.Attributes.Add("msExchExternalSyncState", exSearchResultEntry.Attributes["msExchExternalSyncState"]);
            }
            if (entry.Attributes.ContainsKey("msExchTransportRecipientSettingsFlags"))
            {
                if (!entry.Attributes.ContainsKey("proxyAddresses") && exSearchResultEntry.Attributes.ContainsKey("proxyAddresses"))
                {
                    entry.Attributes.Add("proxyAddresses", exSearchResultEntry.Attributes["proxyAddresses"]);
                }
                if (!entry.Attributes.ContainsKey("msExchSignupAddresses") && exSearchResultEntry.Attributes.ContainsKey("msExchSignupAddresses"))
                {
                    entry.Attributes.Add("msExchSignupAddresses", exSearchResultEntry.Attributes["msExchSignupAddresses"]);
                }
                if (!entry.Attributes.ContainsKey("msExchUMAddresses") && exSearchResultEntry.Attributes.ContainsKey("msExchUMAddresses"))
                {
                    entry.Attributes.Add("msExchUMAddresses", exSearchResultEntry.Attributes["msExchUMAddresses"]);
                }
                if (!entry.Attributes.ContainsKey("msExchArchiveGUID") && exSearchResultEntry.Attributes.ContainsKey("msExchArchiveGUID"))
                {
                    entry.Attributes.Add("msExchArchiveGUID", exSearchResultEntry.Attributes["msExchArchiveGUID"]);
                }
            }
            if (exSearchResultEntry.Attributes.ContainsKey("msExchTransportRecipientSettingsFlags"))
            {
                entry.Attributes["msExchTransportRecipientSettingsFlags"] = exSearchResultEntry.Attributes["msExchTransportRecipientSettingsFlags"];
            }
            if (exSearchResultEntry.Attributes.ContainsKey("msExchCU"))
            {
                entry.Attributes["msExchCU"] = exSearchResultEntry.Attributes["msExchCU"];
            }
            if (exSearchResultEntry.Attributes.ContainsKey("mailNickname"))
            {
                entry.Attributes["mailNickname"] = exSearchResultEntry.Attributes["mailNickname"];
            }
            if (exSearchResultEntry.Attributes.ContainsKey("msExchHomeServerName"))
            {
                entry.Attributes["msExchHomeServerName"] = exSearchResultEntry.Attributes["msExchHomeServerName"];
            }
            bool flag = false;
            int  num;

            if (entry.Attributes.ContainsKey("msExchTransportRecipientSettingsFlags") && entry.Attributes["msExchTransportRecipientSettingsFlags"].Count != 0 && int.TryParse((string)entry.Attributes["msExchTransportRecipientSettingsFlags"][0], NumberStyles.Number, CultureInfo.InvariantCulture, out num) && (num & 8) != 0)
            {
                bool flag2 = (num & 64) != 0;
                foreach (string text in MserveSynchronizationProvider.AddressAttributeNames)
                {
                    if (text.Equals("msExchArchiveGUID"))
                    {
                        if (!flag2)
                        {
                            entry.Attributes["msExchArchiveGUID"] = new DirectoryAttribute("msExchArchiveGUID", MserveSynchronizationProvider.EmptyList);
                        }
                    }
                    else if (entry.Attributes.ContainsKey(text))
                    {
                        DirectoryAttribute directoryAttribute2 = entry.Attributes[text];
                        entry.Attributes[text] = new DirectoryAttribute(directoryAttribute2.Name, MserveSynchronizationProvider.EmptyList);
                        flag = text.Equals("proxyAddresses", StringComparison.OrdinalIgnoreCase);
                    }
                }
            }
            if (!flag)
            {
                MserveTargetConnection mserveTargetConnection = targetConnection as MserveTargetConnection;
                if (targetConnection == null)
                {
                    throw new InvalidOperationException("targetConnection is not the type of MserveTargetConnection");
                }
                mserveTargetConnection.FilterSmtpProxyAddressesBasedOnTenantSetting(entry, recipientTypeDetails);
            }
            return(FilterResult.None);
        }
 private static bool PreDecorate(ExSearchResultEntry entry, Connection sourceConnection, TargetConnection targetConnection, object state)
 {
     if (!entry.IsDeleted)
     {
         foreach (string text in MserveSynchronizationProvider.AddressAttributeNames)
         {
             if (entry.Attributes.ContainsKey(text))
             {
                 DirectoryAttribute directoryAttribute = entry.Attributes[text];
                 if (text.Equals("msExchArchiveGUID", StringComparison.OrdinalIgnoreCase))
                 {
                     if (entry.Attributes.ContainsKey("msExchArchiveGUID"))
                     {
                         DirectoryAttribute value = null;
                         if (MserveSynchronizationProvider.TryTransformAchiveGuidToSmtpAddress(directoryAttribute, out value))
                         {
                             entry.Attributes["ArchiveAddress"] = value;
                         }
                         else
                         {
                             entry.Attributes["ArchiveAddress"] = new DirectoryAttribute("ArchiveAddress", MserveSynchronizationProvider.EmptyList);
                         }
                     }
                     entry.Attributes.Remove("msExchArchiveGUID");
                 }
                 else
                 {
                     List <string> list = new List <string>();
                     for (int j = 0; j < directoryAttribute.Count; j++)
                     {
                         string text2 = directoryAttribute[j] as string;
                         if (text2.StartsWith("smtp:", StringComparison.OrdinalIgnoreCase) || text2.StartsWith("meum:", StringComparison.OrdinalIgnoreCase))
                         {
                             list.Add(text2);
                         }
                     }
                     entry.Attributes[text] = new DirectoryAttribute(directoryAttribute.Name, list.ToArray());
                 }
             }
         }
     }
     else
     {
         Dictionary <string, DirectoryAttribute> dictionary = sourceConnection.ReadObjectAttribute(entry.DistinguishedName, true, new string[]
         {
             "msExchExternalSyncState"
         });
         foreach (string key in dictionary.Keys)
         {
             entry.Attributes.Add(key, dictionary[key]);
         }
     }
     return(true);
 }
Ejemplo n.º 13
0
		private void HandleRebootTargetPCButtonClicked(object sender, MouseEventArgs args)
		{
			TargetConnection.RebootTargetPC();
		}
Ejemplo n.º 14
0
        private DataGridViewComboBoxCell FillGridComboBox(object xenRef, List <object> targetRefs, IStorageResource resource, ref List <ToStringWrapper <SR> > commonSRs)
        {
            var cb = new DataGridViewComboBoxCell {
                FlatStyle = FlatStyle.Flat
            };

            foreach (var pbd in TargetConnection.Cache.PBDs)
            {
                if (pbd.SR == null)
                {
                    continue;
                }

                var sr = TargetConnection.Resolve(pbd.SR);
                if (sr == null || sr.IsDetached)
                {
                    continue;
                }

                if ((sr.content_type.ToLower() == "iso" || sr.type.ToLower() == "iso") && !resource.SRTypeInvalid)
                {
                    continue;
                }
                if (sr.content_type.ToLower() != "iso" && resource.SRTypeInvalid)
                {
                    continue;
                }

                bool srOnHost = pbd.host != null && pbd.host.Equals(xenRef);

                if ((sr.shared || srOnHost) && (ulong)sr.FreeSpace > resource.RequiredDiskCapacity && SrIsSuitable(sr))
                {
                    var count = (from ToStringWrapper <SR> existingItem in cb.Items
                                 where existingItem.item.opaque_ref == sr.opaque_ref
                                 select existingItem).Count();
                    if (count > 0)
                    {
                        continue;                         //iterating through pbds
                    }
                    var newItem = new ToStringWrapper <SR>(sr, GetSRDropDownItemDisplayString);
                    cb.Items.Add(newItem);

                    if (SR.IsDefaultSr(sr))
                    {
                        cb.Value = newItem;
                    }

                    //store items to populate the m_comboBoxSr
                    //note that at this point the m_totalSpaceRequired is not the final value yet,
                    //but we can add the check to get a smaller list

                    if ((sr.shared || (targetRefs.Count == 1 && srOnHost && targetRefs[0].Equals(xenRef))))
                    {
                        var num = (from ToStringWrapper <SR> existingItem in commonSRs
                                   where existingItem.item.opaque_ref == sr.opaque_ref
                                   select existingItem).Count();
                        if (num <= 0)
                        {
                            commonSRs.Add(newItem);
                        }
                    }
                }
            }
            return(cb);
        }
Ejemplo n.º 15
0
        protected override void BeginProcessing()
        {
            DbTransaction transaction = null;

            try
            {
                if ((TargetTable == null && TargetSql == null) || (TargetTable != null && TargetSql != null))
                {
                    throw new ArgumentException("Specify either one of TargetTable or TargetSql");
                }

                bool timeoutGiven = MyInvocation.BoundParameters.ContainsKey("Timeout");

                var connection = TargetConnection.Connection;

                transaction = connection.BeginTransaction();

                using (var selectCmd = SourceConnection.Connection.CreateCommand())
                {
                    selectCmd.CommandText = SourceSql;

                    if (timeoutGiven)
                    {
                        selectCmd.CommandTimeout = Timeout;
                    }

                    Helpers.SetParameters(selectCmd, SourceParameters);

                    using (var reader = selectCmd.ExecuteReader())
                    {
                        string[] paramNames = null;

                        while (reader.Read())
                        {
                            if (paramNames == null)
                            {
                                paramNames = new string[reader.FieldCount];
                                for (var i = 0; i < reader.FieldCount; ++i)
                                {
                                    paramNames[i] = reader.GetName(i);
                                }
                            }

                            using (var insertCmd = TargetConnection.Connection.CreateCommand())
                            {
                                insertCmd.Transaction = transaction;

                                if (TargetSql == null)
                                {
                                    var factory = Helpers.GetDbProviderFactory(connection);
                                    using (var builder = factory.CreateCommandBuilder())
                                    {
                                        var columns = string.Join(", ", paramNames.Select(p => builder.QuoteIdentifier(p)));
                                        var paras   = "@" + string.Join(", @", paramNames);
                                        TargetSql = $"insert into {TargetTable} ({columns}) values ({paras})";
                                    }
                                }

                                insertCmd.CommandText = TargetSql;

                                for (var i = 0; i < reader.FieldCount; ++i)
                                {
                                    var param = insertCmd.CreateParameter();
                                    param.ParameterName = paramNames[i];
                                    param.Value         = reader.GetValue(i);
                                    insertCmd.Parameters.Add(param);
                                }

                                if (timeoutGiven)
                                {
                                    insertCmd.CommandTimeout = Timeout;
                                }

                                insertCmd.ExecuteNonQuery();
                            }
                        }
                    }
                }

                transaction.Commit();
            }
            catch (Exception e)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }

                WriteError(new ErrorRecord(e, "", ErrorCategory.NotSpecified, null));
            }
            finally
            {
                SourceConnection.Close();
                TargetConnection.Close();
            }
        }
Ejemplo n.º 16
0
        private static bool LoadAdminGroups(ExSearchResultEntry entry, Connection sourceConnection, TargetConnection targetConnection, object state)
        {
            EhfRecipientTargetConnection ehfRecipientTargetConnection = (EhfRecipientTargetConnection)targetConnection;

            return(ehfRecipientTargetConnection.AdminAccountSynchronizer.FilterOrLoadFullEntry(entry));
        }
Ejemplo n.º 17
0
 private static bool LoadPerimeterSettings(ExSearchResultEntry entry, Connection sourceConnection, TargetConnection targetConnection, object state)
 {
     return(EhfSynchronizer.LoadFullEntry(entry, EhfCompanySynchronizer.PerimeterSettingsAllAttributes, (EhfTargetConnection)targetConnection));
 }