Exemple #1
0
        public string To_XML()
        {
            var ret = "<disk type='" + Device_Type.ToString() + "' device='" + Device_Device_Type.ToString() + "' ";

            if (Snapshot_Type != Snapshot_Types._default)
            {
                ret += "snapshot='" + Snapshot_Type.ToString().Replace("_", "") + "'";
            }
            ret += ">";
            ret += "<driver type='" + Driver_Type.ToString() + "' cache='" + Driver_Cache_Type.ToString().Replace("_", "") + "' />";
            ret += Source.To_XML();

            ret += "<target dev='";
            if (Device_Bus_Type == Disk_Bus_Types.virtio)
            {
                ret += "vd";
            }
            else if (Device_Bus_Type == Disk_Bus_Types.scsi)
            {
                ret += "sd";
            }
            else
            {
                ret += "sd";
            }
            ret += Letter + "' bus='" + Device_Bus_Type.ToString() + "' />";

            if (ReadOnly)
            {
                ret += "<readonly/>";
            }
            ret += "</disk>";
            return(ret);
        }
        private void deletedevicetype(HttpContext context)
        {
            string     IDs    = context.Request.Params["IDList"];
            List <int> IDList = JsonConvert.DeserializeObject <List <int> >(IDs);
            var        list   = Device_Type.GetChildDevice_Types(IDList);

            if (list.Length > 0)
            {
                context.Response.Write("{\"status\":true,\"success\":false}");
                return;
            }
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    string cmdtext = "delete from [Device_Type] where ID in (" + string.Join(",", IDList.ToArray()) + ");";
                    List <SqlParameter> parameters = new List <SqlParameter>();
                    helper.Execute(cmdtext, CommandType.Text, parameters);
                    helper.Commit();
                    context.Response.Write("{\"status\":true,\"success\":true}");
                }
                catch (Exception ex)
                {
                    Utility.LogHelper.WriteError(ModelName, "命令: deletedevicetype", ex);
                    helper.Rollback();
                    context.Response.Write("{\"status\":false}");
                }
            }
        }
 public Device_Type[] GetTypeList()
 {
     if (mTypeList.Length == 0)
     {
         mTypeList = Device_Type.GetDevice_Types().ToArray();
     }
     return(mTypeList);
 }
        private void savedevicetype(HttpContext context)
        {
            int ID       = WebUtil.GetIntValue(context, "ID");
            int ParentID = WebUtil.GetIntValue(context, "ParentID");

            Foresight.DataAccess.Device_Type devicetype = null;
            if (ID > 0)
            {
                devicetype = Foresight.DataAccess.Device_Type.GetDevice_Type(ID);
            }
            if (devicetype == null)
            {
                devicetype         = new Device_Type();
                devicetype.AddTime = DateTime.Now;
            }
            else
            {
                ParentID = devicetype.ParentID;
            }
            Foresight.DataAccess.Device_Type parenttype = null;
            if (ParentID > 0)
            {
                parenttype = Foresight.DataAccess.Device_Type.GetDevice_Type(ParentID);
            }
            if (parenttype != null)
            {
                int type_level = parenttype.TypeLevel > 0 ? parenttype.TypeLevel : 1;
                devicetype.ParentID  = parenttype.ID;
                devicetype.TypeLevel = parenttype.TypeLevel + 1;
            }
            else
            {
                devicetype.ParentID  = 0;
                devicetype.TypeLevel = 1;
            }
            devicetype.Code           = getServerValue(context, "tdCode");
            devicetype.DeviceTypeName = getServerValue(context, "tdDeviceTypeName");
            devicetype.Description    = getServerValue(context, "tdDescription");
            devicetype.Save();
            WebUtil.WriteJson(context, new { status = true, ID = devicetype.ID });
        }
Exemple #5
0
        private void btnEnumerate_Click(object sender, EventArgs e)
        {
            UInt32    devices_count;
            DL_STATUS status;
            string    status_msg;
            HND_AIS   hnd_device;
            UInt32    Device_Type, Device_ID, Device_FW_VER, Device_CommSpeed,
                      Device_isOpened, Device_Status, System_Status;
            string Device_Serial, Device_FTDI_Serial;

            // Shuld be a warning before close all opened devices
            gridView.Rows.Clear();
            try
            {
                devices_count = ais_readers.AIS_List_UpdateAndGetCount();
                Helper.AppendText(tbLog, "Listed devices succesfully enumerated. ", Color.Green);
                Helper.AppendText(tbLog, "Number of attached devices is: ", Color.Navy);
                Helper.AppendText(tbLog, "" + devices_count + "\n", Color.Black);
                Helper.SetStatusOk(statusLabel);

                if (isAnyDeviceAttached = (devices_count > 0))
                {
                    for (int i = 0; i < devices_count; i++)
                    {
                        try
                        {
                            status = ais_readers.AIS_List_GetInformation(
                                out hnd_device,         // assigned Handle
                                out Device_Serial,      // device serial number
                                out Device_Type,        // device type
                                out Device_ID,          // device identification number (master)
                                out Device_FW_VER,      // version of firmware
                                out Device_CommSpeed,   // communication speed
                                out Device_FTDI_Serial, // FTDI COM port identification
                                out Device_isOpened,    // is Device opened
                                out Device_Status,      // actual device status
                                out System_Status       // actual system status
                                );
                            if (status != DL_STATUS.DL_OK)
                            {
                                status_msg = ais_readers.status2str(status);
                                throw new Exception("AIS status: " + status_msg);
                            }
                            else
                            {
                                string[] new_row = new string[] { (i + 1).ToString(), hnd_device.ToString(), Device_Serial,
                                                                  Device_Type.ToString(), Device_ID.ToString(), Device_FW_VER.ToString(),
                                                                  Device_CommSpeed.ToString(), Device_FTDI_Serial, Device_isOpened.ToString(),
                                                                  Device_Status.ToString(), System_Status.ToString() };
                                gridView.Rows.Add(new_row);
                            }
                        }
                        catch (Exception exception)
                        {
                            Helper.AppendText(tbLog, "Warning: ", Color.Purple);
                            Helper.AppendText(tbLog, exception.Message + "\n", Color.Purple);
                            Helper.SetStatusWarning(statusLabel);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Helper.AppendText(tbLog, exception.Message + "\n", Color.Red);
                Helper.SetStatusErr(statusLabel);
            }
        }
Exemple #6
0
        /// <summary>
        /// 推送消息或通知给指定的标签
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="msg_type">否 取值如下:0:消息;1:通知。默认为0 </param>
        /// <param name="msg">是   消息内容,json格式 </param>
        /// <param name="msg_expires">否  0~604800(86400*7),默认为5小时(18000秒) 消息过期时间,单位为秒 </param>
        /// <param name="deploy_status">否  取值为:1:开发状态;2:生产状态; 若不指定,则默认设置为生产状态。 设置iOS应用的部署状态,仅iOS应用推送时使用 </param>
        /// <param name="send_time">否  指定的实际发送时间,必须在当前时间60s以外,1年以内 定时推送,用于指定的实际发送时间 </param>
        /// <param name="apikey">必须!应用的api key,用于标识应用,</param>
        /// <param name="timestamp">必须!用户发起请求时的unix时间戳。本次请求签名的有效时间为该时间戳向后10分钟</param>
        /// <param name="expires">用户指定本次请求签名的失效时间。格式为unix时间戳形式,用于防止 replay 型攻击。为保证防止 replay攻击算法的正确有效,请保证客户端系统时间正确</param>
        /// <param name="device_type">当一个应用同时支持多个设备平台类型(比如:Android和iOS),请务必设置该参数。其余情况可不设置</param>
        public PushOptions(string tag, uint?msg_type, string msg, uint?msg_expires, uint?deploy_status, uint?send_time, string apikey, uint?timestamp, uint?expires, Device_Type device_type)
        {
            this.type = 1;
            this.tag  = tag;

            this.msg_type      = msg_type;
            this.msg           = msg;
            this.msg_expires   = msg_expires;
            this.deploy_status = deploy_status;
            this.send_time     = send_time;

            this.apikey      = apikey;
            this.timestamp   = timestamp;
            this.expires     = expires;
            this.device_type = (uint)device_type;
        }
Exemple #7
0
 /// <summary>
 /// 推送到单台设备的消息参数
 /// </summary>
 /// <param name="channel_id">必须!唯一对应一台设备 ,为端上初始化channel成功之后返回的channel_id  </param>
 /// <param name="msg_type">消息类型,取值如下:0:消息;1:通知。默认为0</param>
 /// <param name="msg">消息内容,json格式</param>
 /// <param name="msg_expires">相对于当前时间的消息过期时间,单位为秒,0~604800(86400*7),默认为5小时(18000秒)</param>
 /// <param name="deploy_status">取值为:1:开发状态;2:生产状态; 若不指定,则默认设置为生产状态。</param>
 /// <param name="apikey">必须!应用的api key,用于标识应用,</param>
 /// <param name="timestamp">必须!用户发起请求时的unix时间戳。本次请求签名的有效时间为该时间戳向后10分钟</param>
 /// <param name="expires">非必须   用户指定本次请求签名的失效时间。格式为unix时间戳形式,用于防止 replay 型攻击。为保证防止 replay攻击算法的正确有效,请保证客户端系统时间正确</param>
 /// <param name="device_type">非必须   当一个应用同时支持多个设备平台类型(比如:Android和iOS),请务必设置该参数。其余情况可不设置</param>
 public PushOptions(string channel_id, uint?msg_type, string msg, uint?deploy_status, string apikey, uint?timestamp, uint?expires, Device_Type device_type)
 {
     this.channel_id    = channel_id;
     this.msg_type      = msg_type;
     this.msg           = msg;
     this.msg_expires   = msg_expires;
     this.deploy_status = deploy_status;
     this.apikey        = apikey;
     this.timestamp     = timestamp;
     this.expires       = expires;
     this.device_type   = (uint)device_type;
 }