Пример #1
0
        public DbNameMap Clone()
        {
            /*
             * DbNameMap result = new DbNameMap();
             *
             * foreach( DictionaryEntry entry in this)
             * {
             *  // int i =0;
             *
             *
             *  DbNameMapItem olditem = (DbNameMapItem)this[entry.Key];
             *
             *  DbNameMapItem newitem = new DbNameMapItem();
             *
             *  newitem.strOrigin = olditem.strOrigin;
             *  newitem.strStyle = olditem.strStyle;
             *  newitem.strTarget = olditem.strTarget;
             *
             *  result.Add(entry.Key, newitem);
             * }
             */
            DbNameMap result = new DbNameMap();

            for (int i = 0; i < this.m_list.Count; i++)
            {
                DbNameMapItem olditem = (DbNameMapItem)this.m_list[i];

                string strError = "";
                if (result.NewItem(olditem.Origin, olditem.Target, olditem.Style, out strError) == null)
                {
                    throw new Exception(strError);
                }
            }
            return(result);
        }
Пример #2
0
        // 询问无法匹配的源路径如何处理
        // return:
        //      -1  出错
        //		0	cancel全部处理
        //		1	已经选择处理办法
        public static int AskNotMatchOriginBox(
            IWin32Window owner,
            ApplicationInfo ap,
            ServerCollection Servers,
            RmsChannelCollection Channels,
            string strComment,
            string strSelectedLongPath,
            string strOrigin,
            DbNameMap map)
        {
            DbNameMapItemDlg dlg = new DbNameMapItemDlg();

            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.Servers   = Servers;
            dlg.Channels  = Channels;
            dlg.Comment   = strComment;
            dlg.AskMode   = AskMode.AskNotMatchOrigin;
            dlg.Origin    = strOrigin;
            dlg.Target    = strSelectedLongPath;
            dlg.WriteMode = "append";

            dlg.Text = "请指定映射关系";

            if (ap != null)
            {
                ap.LinkFormState(dlg, "AskNotMatchOriginBox_state");
            }
            dlg.ShowDialog(owner);
            if (ap != null)
            {
                ap.UnlinkFormState(dlg);
            }

            if (dlg.DialogResult != DialogResult.OK)
            {
                return(0);       // cancel
            }
            string strError = "";

            if (map.NewItem(dlg.Origin, dlg.Target,
                            dlg.WriteMode,
                            0, // 插入最前面
                            out strError) == null)
            {
                MessageBox.Show(owner, strError);
                return(-1);
            }

            return(1);
        }
Пример #3
0
        // 构造map对象。
        // parameters:
        //		strDbPaths	分号间隔的路径。将创建为Origin和Target相同的overwrite事项。
        //					格式为 dbpathorigin-dbpathtarget|style;...
        //					可以省略为dbpath1;dbpath2;... 每个path既当origin也当target用
        public static DbNameMap Build(string strDbPaths,
                                      out string strError)
        {
            strError = "";
            DbNameMap map = new DbNameMap();

            string[] aPath = strDbPaths.Split(new char[] { ';' });

            for (int i = 0; i < aPath.Length; i++)
            {
                string strLine = aPath[i].Trim();
                if (strLine == "")
                {
                    continue;
                }
                string strOrigin = "";
                string strTarget = "";
                string strStyle  = "";

                int nRet = strLine.IndexOf("|");
                if (nRet == -1)
                {
                    strStyle = "overwrite";
                }
                else
                {
                    strStyle = strLine.Substring(nRet + 1).Trim().ToLower();
                    strLine  = strLine.Substring(0, nRet).Trim();
                }

                nRet = strLine.IndexOf("-");
                if (nRet == -1)
                {
                    strOrigin = strLine;
                    strTarget = strLine;
                }
                else
                {
                    strOrigin = strLine.Substring(0, nRet).Trim();
                    strTarget = strLine.Substring(nRet + 1).Trim();
                }

                if (map.NewItem(strOrigin, strTarget, strStyle, out strError) == null)
                {
                    return(null);
                }
            }

            return(map);
        }
Пример #4
0
        private void button_OK_Click(object sender, System.EventArgs e)
        {
            string strTarget = "";
            string strStyle  = "";

            if (radioButton_skip.Checked == true)
            {
                strStyle = "skip";
            }

            if (radioButton_append.Checked == true)
            {
                if (this.textBox_appendDbName.Text == "")
                {
                    MessageBox.Show(this, "在选择了追加方式的情况下,必须选择目标库...");
                    return;
                }
                strTarget = this.textBox_appendDbName.Text;
                strStyle  = "append";
            }

            if (radioButton_overwrite.Checked == true)
            {
                if (this.textBox_overwriteDbName.Text == "")
                {
                    MessageBox.Show(this, "在选择了覆盖方式的情况下,必须选择目标库...");
                    return;
                }
                strTarget = this.textBox_overwriteDbName.Text;
                strStyle  = "overwrite";
            }

            // 如果要仅仅当次起作用,需要深复制Map,以便对话框调主使用后自动丢弃
            if (checkBox_notAskWhenSameOrigin.Checked == false)
            {
                this.Map = this.Map.Clone();
            }

            string strError = "";

            if (Map.NewItem(Origin, strTarget, strStyle, out strError) == null)
            {
                MessageBox.Show(this, strError);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #5
0
        // 构造map对象。
        // parameters:
        //		strDbPaths	分号间隔的路径。将创建为Origin和Target相同的overwrite事项。
        //					格式为 dbpathorigin-dbpathtarget|style;...
        //					可以省略为dbpath1;dbpath2;... 每个path既当origin也当target用
        public static DbNameMap Build(string strDbPaths,
            out string strError)
        {
            strError = "";
            DbNameMap map = new DbNameMap();

            string[] aPath = strDbPaths.Split(new char[] { ';' });

            for (int i = 0; i < aPath.Length; i++)
            {
                string strLine = aPath[i].Trim();
                if (strLine == "")
                    continue;
                string strOrigin = "";
                string strTarget = "";
                string strStyle = "";

                int nRet = strLine.IndexOf("|");
                if (nRet == -1)
                    strStyle = "overwrite";
                else
                {
                    strStyle = strLine.Substring(nRet + 1).Trim().ToLower();
                    strLine = strLine.Substring(0, nRet).Trim();
                }

                nRet = strLine.IndexOf("-");
                if (nRet == -1)
                {
                    strOrigin = strLine;
                    strTarget = strLine;
                }
                else
                {
                    strOrigin = strLine.Substring(0, nRet).Trim();
                    strTarget = strLine.Substring(nRet + 1).Trim();
                }

                if (map.NewItem(strOrigin, strTarget, strStyle, out strError) == null)
                    return null;
            }

            return map;
        }
Пример #6
0
        public DbNameMap Clone()
        {
            /*
            DbNameMap result = new DbNameMap();

            foreach( DictionaryEntry entry in this)
            {
                // int i =0;
				

                DbNameMapItem olditem = (DbNameMapItem)this[entry.Key];

                DbNameMapItem newitem = new DbNameMapItem();

                newitem.strOrigin = olditem.strOrigin;
                newitem.strStyle = olditem.strStyle;
                newitem.strTarget = olditem.strTarget;

                result.Add(entry.Key, newitem);
            }
            */
            DbNameMap result = new DbNameMap();

            for (int i = 0; i < this.m_list.Count; i++)
            {
                DbNameMapItem olditem = (DbNameMapItem)this.m_list[i];

                string strError = "";
                if (result.NewItem(olditem.Origin, olditem.Target, olditem.Style, out strError) == null)
                    throw new Exception(strError);
            }
            return result;
        }
Пример #7
0
        // 询问无法匹配的源路径如何处理
        // return:
        //      -1  出错
        //		0	cancel全部处理
        //		1	已经选择处理办法
        public static int AskNotMatchOriginBox(
            IWin32Window owner,
            ApplicationInfo ap,
            ServerCollection Servers,
            RmsChannelCollection Channels,
            string strComment,
            string strSelectedLongPath,
            string strOrigin,
            DbNameMap map)
        {
            DbNameMapItemDlg dlg = new DbNameMapItemDlg();
            dlg.Font = GuiUtil.GetDefaultFont();

            dlg.Servers = Servers;
            dlg.Channels = Channels;
            dlg.Comment = strComment;
            dlg.AskMode = AskMode.AskNotMatchOrigin;
            dlg.Origin = strOrigin;
            dlg.Target = strSelectedLongPath;
            dlg.WriteMode = "append";

            dlg.Text = "请指定映射关系";

            if (ap != null)
                ap.LinkFormState(dlg, "AskNotMatchOriginBox_state");
            dlg.ShowDialog(owner);
            if (ap != null)
                ap.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
                return 0;	// cancel

            string strError = "";
            if (map.NewItem(dlg.Origin, dlg.Target,
                dlg.WriteMode,
                0, // 插入最前面
                out strError) == null)
            {
                MessageBox.Show(owner, strError);
                return -1;
            }

            return 1;
        }
Пример #8
0
		// 询问空源路径如何处理
		// return:
        //      -1  出错
		//		0	cancel全部处理
		//		1	已经选择处理办法
		public static int AskNullOriginBox(
			IWin32Window owner,
			ApplicationInfo ap,
			string strComment,
			SearchPanel searchpanel,
			DbNameMap map)
		{
			DbNameMapItemDlg dlg = new DbNameMapItemDlg();
            dlg.Font = GuiUtil.GetDefaultFont();

			dlg.Comment = strComment;
			dlg.AskMode = AskMode.AskNullOrigin;
			dlg.SearchPanel = searchpanel;
			dlg.Origin = "{null}";
			dlg.Target = "";
			dlg.WriteMode = "append";

			dlg.Text = "请指定映射关系";

			if (ap != null)
				ap.LinkFormState(dlg, "AskNotMatchOriginBox_state");
			dlg.ShowDialog(owner);
			if (ap != null)
				ap.UnlinkFormState(dlg);


			if (dlg.DialogResult != DialogResult.OK)
				return 0;	// cancel

            string strError = "";
            if (map.NewItem(dlg.Origin, dlg.Target, dlg.WriteMode,
                0,// 插入最前面
                out strError) == null)
            {
                MessageBox.Show(owner, strError);
                return -1;
            }

			return 1;
		}