示例#1
0
        /// <summary>
        /// 施工单操作编码
        /// </summary>
        /// <param name="schedule"></param>
        /// <param name="buff"></param>
        public static void EncodeScheHandler(ZdflCount.Models.Schedules schedule, enumCommandType command, out byte[] buff)
        {
            byte[] content = new byte[1024];
            int    locIdx = 0, tempLen = 2;

            //机器码
            byte[] machineBytes = ConvertHelper.Int16ToBytes(schedule.MachineId, true);
            Array.Copy(machineBytes, content, tempLen);
            locIdx += tempLen;
            //施工单编号
            byte[] numberBytes = Encoding.ASCII.GetBytes(schedule.Number);
            tempLen           = numberBytes.Length;
            content[locIdx++] = (byte)tempLen;
            Array.Copy(numberBytes, 0, content, locIdx, tempLen);
            locIdx += tempLen;

            NormalDataStruct data = new NormalDataStruct()
            {
                Code       = command,
                contentLen = locIdx,
                Content    = content
            };

            EncodeData(data, out buff);
        }
示例#2
0
        private static interfaceClientHanlder GetHandlerByCommand(enumCommandType type)
        {
            interfaceClientHanlder typeResult = null;

            switch (type)
            {
            case enumCommandType.UP_HEART_SEND: typeResult = new ClientHandlerHeartBreak(); break;

            case enumCommandType.UP_PRODUCT_SEND: typeResult = new ClientHanlderProductInfo(); break;

            case enumCommandType.UP_DEVICE_SETTING_SEND: typeResult = new ClientHandlerDeviceSetting(); break;

            case enumCommandType.UP_DEVICE_REPORT_SEND: typeResult = new ClientHandlerDeviceReport(); break;

            case enumCommandType.UP_DEVICE_CALL_MATERIAL_SEND: typeResult = new ClientHandlerDeviceCallMaterial(); break;

            case enumCommandType.UP_DEVICE_STARTEND_SEND: typeResult = new ClientHandlerDeviceStartEnd(); break;

            case enumCommandType.DOWN_SHEDULE_RESP: typeResult = new ClientHandlerDownScheduleResp(); break;

            case enumCommandType.DOWN_SHEDULE_CLOSE_RESP: typeResult = new ClientHandlerDownScheCloseResp(); break;

            case enumCommandType.DOWN_SHEDULE_DISCARD_RESP: typeResult = new ClientHandlerDownScheDiscardResp(); break;

            default: break;    //typeResult = new ClientHandlerNoneDefault();
            }
            return(typeResult);
        }
示例#3
0
 /// <summary>
 /// 服务器返回结果编码
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="byteResp"></param>
 /// <param name="buff"></param>
 public static void EncodeServerResp(enumCommandType cmd, byte[] byteResp, out byte[] buff)
 {
     NetStructure.NormalDataStruct data = new NetStructure.NormalDataStruct()
     {
         Code          = cmd,
         FactoryNumber = FACTORY_NORMAL,
         contentLen    = byteResp.Length,
         Content       = byteResp
     };
     EncodeData(data, out buff);
 }
示例#4
0
        public void LoadFromCommand(ICommand cmd, string curPage, string curPageGroup, string caption, Image icon, enumCommandType cmdType, string resourceID, string parent)
        {
            Init();

            // 不重复加载
            if (m_DictResource.ContainsKey(resourceID))
            {
                return;
            }

            // BarItem
            object barItem = null;

            try
            {
                barItem = CreateControl(cmd, caption, icon);
            }
            catch (Exception exp)
            {
                SendMessage(string.Format("从命令{0}创建控件时出错,信息:{1};将跳过此命令。", cmd.Name, exp.ToString(), exp.ToString()));
            }

            if (barItem == null)
            {
                return;
            }

            // 记录资源
            m_DictResource.Add(resourceID, barItem);

            // 如果找到父资源,则从父资源加载
            if (parent != null && barItem is BarItem)
            {
                if (!m_DictResource.ContainsKey(parent))
                {
                    if (this.CommandInfoFinder != null)
                    {
                        LoadFromCommandInfo(this.CommandInfoFinder(parent));
                    }
                }
                if (m_DictResource.ContainsKey(parent) && m_DictResource[parent] is BarSubItem)
                {
                    (m_DictResource[parent] as BarSubItem).AddItem(barItem as BarItem);
                    return;
                }
            }

            // ****** 快速访问工具栏命令 ********
            if (cmdType == enumCommandType.Quick && barItem is BarItem)
            {
                this.Ribbon.Toolbar.ItemLinks.Add(barItem as BarItem);
            }
            // ****** 开始工具栏命令 ********
            else if (cmdType == enumCommandType.Menu && barItem is BarItem)
            {
                if (this.MainMenu != null)
                {
                    this.MainMenu.ItemLinks.Add(barItem as BarItem);
                }
            }
            // ****** 状态栏命令 ********
            else if (cmdType == enumCommandType.Status && barItem is BarItem)
            {
                this.Ribbon.StatusBar.ItemLinks.Insert(0, barItem as BarItem);
            }
            // ****** 右上角 ********
            else if (cmdType == enumCommandType.PageHead && barItem is BarItem)
            {
                this.Ribbon.PageHeaderItemLinks.Add(barItem as BarItem);
            }
            else  // ****** 普通工具栏命令 ********
            {
                // Page
                if (!m_DictPage.ContainsKey(curPage))
                {
                    RibbonPage newPage = new RibbonPage(curPage);
                    Ribbon.Pages.Add(newPage);

                    m_DictPage.Add(curPage, newPage);
                }
                // PageGroup
                string groupKey = curPage + "." + curPageGroup;
                if (!m_DictPageGroup.ContainsKey(groupKey))
                {
                    RibbonPageGroup rpgNew = new RibbonPageGroup(curPageGroup);
                    m_DictPage[curPage].Groups.Add(rpgNew);

                    m_DictPageGroup.Add(groupKey, rpgNew);
                }
                if (barItem is BarItem)
                {
                    m_DictPageGroup[groupKey].ItemLinks.Add(barItem as BarItem);

                    if (barItem is BarSubItem)
                    {
                        AddSubItem(barItem as BarSubItem);
                    }
                }
                else if (barItem is Control)
                {
                    Ribbon.Controls.Add(barItem as Control);
                }
            }
        }
示例#5
0
        public void LoadFromCommand(ICommand cmd, string curPage, string curPageGroup, string caption, Image icon, enumCommandType cmdType,string resourceID,string parent)
        {
            Init();

            // 不重复加载
            if (m_DictResource.ContainsKey(resourceID))
                return;

            // BarItem
            object barItem = null;
            try
            {
                barItem = CreateControl(cmd, caption, icon);
            }
            catch (Exception exp)
            {
                SendMessage(string.Format("从命令{0}创建控件时出错,信息:{1};将跳过此命令。", cmd.Name, exp.ToString(), exp.ToString()));
            }

            if (barItem == null)
                return;

            // 记录资源
            m_DictResource.Add(resourceID, barItem);

            // 如果找到父资源,则从父资源加载
            if (parent != null && barItem is BarItem)
            {
                if (!m_DictResource.ContainsKey(parent))
                {
                    if (this.CommandInfoFinder != null)
                        LoadFromCommandInfo(this.CommandInfoFinder(parent));
                }
                if (m_DictResource.ContainsKey(parent) && m_DictResource[parent] is BarSubItem)
                {
                    (m_DictResource[parent] as BarSubItem).AddItem(barItem as BarItem);
                    return;
                }
            }

            // ****** 快速访问工具栏命令 ********
            if ( cmdType == enumCommandType.Quick && barItem is BarItem)
            {
                this.Ribbon.Toolbar.ItemLinks.Add(barItem as BarItem);
            }
            // ****** 开始工具栏命令 ********
            else if (cmdType == enumCommandType.Menu && barItem is BarItem)
            {
                if (this.MainMenu != null)
                    this.MainMenu.ItemLinks.Add(barItem as BarItem);
            }
            // ****** 状态栏命令 ********
            else if (cmdType == enumCommandType.Status && barItem is BarItem)
            {
                this.Ribbon.StatusBar.ItemLinks.Insert(0,barItem as BarItem);
            }
            // ****** 右上角 ********
            else if (cmdType == enumCommandType.PageHead && barItem is BarItem)
            {
                this.Ribbon.PageHeaderItemLinks.Add(barItem as BarItem);
            }
            else  // ****** 普通工具栏命令 ********
            {
                // Page
                if (!m_DictPage.ContainsKey(curPage))
                {

                    RibbonPage newPage = new RibbonPage(curPage);
                    Ribbon.Pages.Add(newPage);

                    m_DictPage.Add(curPage, newPage);
                }
                // PageGroup
                string groupKey = curPage + "." + curPageGroup;
                if (!m_DictPageGroup.ContainsKey(groupKey))
                {

                    RibbonPageGroup rpgNew = new RibbonPageGroup(curPageGroup);
                    m_DictPage[curPage].Groups.Add(rpgNew);

                    m_DictPageGroup.Add(groupKey, rpgNew);
                }
                if (barItem is BarItem)
                {
                    m_DictPageGroup[groupKey].ItemLinks.Add(barItem as BarItem);

                    if (barItem is BarSubItem)
                        AddSubItem(barItem as BarSubItem);

                }
                else if (barItem is Control)
                {
                    Ribbon.Controls.Add(barItem as Control);
                }
            }
        }