Esempio n. 1
0
        public async Task <ActionResult> LiveVideoPlay(string MediaServerId, string MainId)
        {
            string apiUrl = GlobalContext.SystemConfig.MediaServerUrl + "/MediaServer/StreamLive?mediaServerId=" + MediaServerId + "&mainId=" + MainId;
            string result = HttpMethods.Get(apiUrl);

            return(Json(result));
        }
        public async Task <ActionResult> SipDeviceList()
        {
            List <ZtreeInfo> sipdevicelist = new List <ZtreeInfo>();
            //获取deciveID
            var deciveidList = await sTD_Stream_CameraBLL.GetDeciveIdList();

            if (deciveidList != null || deciveidList.Count() > 0)
            {
                foreach (var item in deciveidList)
                {
                    string           result   = HttpMethods.Get(GlobalContext.SystemConfig.MediaServerUrl + "/SipGate/GetSipDeviceList?cameraDeviceLable=" + item.CameraDeviceLable);
                    List <SipDevice> sipdlist = JsonConvert.DeserializeObject <List <SipDevice> >(result);
                    if (sipdlist.Count() > 0)
                    {
                        ZtreeInfo ztree = new ZtreeInfo();
                        ztree.pId  = 0;
                        ztree.id   = long.Parse(sipdlist[0].crC32);
                        ztree.name = sipdlist[0].deviceId;
                        sipdevicelist.Add(ztree);
                    }
                }
            }

            TData <List <ZtreeInfo> > obj = new TData <List <ZtreeInfo> >();

            obj.Data  = sipdevicelist;
            obj.Tag   = 1;
            obj.Total = sipdevicelist.Count;
            return(Json(obj));
        }
Esempio n. 3
0
        /// <summary>
        /// 下载验证码
        /// </summary>
        public static bool DownloadImage()
        {
            HttpResponseResult ResponseResult = HttpMethods.Get(UrlDefine.LoginUrl, new System.Net.CookieContainer(), Encoding.UTF8);

            if (ResponseResult.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string[] str       = ResponseResult.ContentData.ToString().Split(';');
                string   ImageCode = str[1].Substring(str[1].IndexOf("\"") + 1, str[1].Length - str[1].IndexOf("\"") - 2);
                UrlDefine.Tickets    = ImageCode;
                CommonDefine.Cookies = HttpMethods.getCookie(UrlDefine.RootUrl);
                ResponseResult       = HttpMethods.GetFile(UrlDefine.LoginUrlWithToken + ImageCode, "Check.jpg", new System.Net.CookieContainer());
                if (ResponseResult.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    LogWriter.Write("下载微信登录二维码成功...", LogPathDefine.WeChatLogPath);
                    return(true);
                }
                else
                {
                    LogWriter.Write("获取微信登录二维码失败...", LogPathDefine.WeChatErrorLogPath);
                    LogWriter.Write(string.Format("当前返回状态码是{0},返回信息是{1}", ResponseResult.StatusCode.ToString(), ResponseResult.ReturnMsg), LogPathDefine.WeChatErrorLogPath);
                    return(false);
                }
            }
            else
            {
                //请求出现问题
                LogWriter.Write("访问微信登官网失败...", LogPathDefine.WeChatErrorLogPath);
                LogWriter.Write(string.Format("当前返回状态码是{0},返回信息是{1}", ResponseResult.StatusCode.ToString(), ResponseResult.ReturnMsg), LogPathDefine.WeChatErrorLogPath);
                return(false);
            }
        }
        public async Task <ActionResult> SipDeviceDetailList(SipDeviceManagerParam param)
        {
            string            channelid  = param.deviceID;
            string            deviceid   = param.parentID;
            string            sipstatue  = param.sipCameraStatus;
            List <CameraItem> cameraitem = new List <CameraItem>();
            string            result     = HttpMethods.Get(GlobalContext.SystemConfig.MediaServerUrl + "/SipGate/GetSipDeviceList?cameraDeviceLable=" + deviceid);
            List <SipDevice>  sipdlist   = JsonConvert.DeserializeObject <List <SipDevice> >(result);

            Cameraexlist[] cml = new Cameraexlist[] { };
            if (sipdlist.Count() > 0)
            {
                cml = sipdlist[0].cameraExList;
                if (!string.IsNullOrEmpty(sipstatue))
                {
                    switch (sipstatue)
                    {
                    case "1":
                        cml = sipdlist[0].cameraExList.Where(t => t.sipCameraStatus.Equals("RealVideo")).ToArray();
                        break;

                    case "0":
                        cml = sipdlist[0].cameraExList.Where(t => t.sipCameraStatus.Equals("Idle")).ToArray();
                        break;

                    default:
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(channelid))
                {
                    cml = cml.Where(t => t.camera.deviceID.Equals(channelid)).ToArray();
                }
                if (!string.IsNullOrEmpty(deviceid))
                {
                    cml = cml.Where(t => t.camera.parentID.Equals(deviceid)).ToArray();
                }
                foreach (var item in cml)
                {
                    item.camera.sipCameraStatus      = item.sipCameraStatus;
                    item.camera.streamId             = item.streamId;
                    item.camera.mediaServerId        = item.mediaServerId;
                    item.camera.pushStreamSocketType = item.pushStreamSocketType;
                    item.camera.streamServerIp       = item.streamServerIp;
                    item.camera.streamServerPort     = item.streamServerPort;
                    cameraitem.Add(item.camera);
                }
            }

            TData <List <CameraItem> > obj = new TData <List <CameraItem> >();

            obj.Data  = cameraitem;
            obj.Tag   = 1;
            obj.Total = cameraitem.Count;
            return(Json(obj));
        }
Esempio n. 5
0
        /// <summary>
        /// 刷新联系人
        /// </summary>
        public static void RefreshContacts()
        {
            string             ContentList   = HttpMethods.Get(UrlDefine.GetContactUrl(CommonDefine.LoginResult.pass_ticket, CommonDefine.LoginResult.skey), CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString();
            ContactsListEntity ContactsLists = JsonConvert.DeserializeObject <ContactsListEntity>(ContentList);

            if (ContactsLists != CommonDefine.ContactsList)//联系人有更新,关键是看数量增加还是减少的
            {
                CommonDefine.ContactsList = ContactsLists;
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 获取配置数据
 /// </summary>
 /// <param name="configInfoList">配置信息列表</param>
 /// <returns></returns>
 public List <ConfigInfoDataModel> GetConfigData(List <ConfigInfoModel> configInfoList)
 {
     try
     {
         List <ConfigInfoDataModel> list = new List <ConfigInfoDataModel>();
         foreach (var item in configInfoList)
         {
             ConfigInfoDataModel configInfoDataModel = new ConfigInfoDataModel();
             configInfoDataModel.id        = item.id;
             configInfoDataModel.modelType = item.modelType;
             configInfoDataModel.type      = item.type;
             configInfoDataModel.data      = null;
             configInfoDataModel.dataType  = item.dataType;
             if (item.type == "1")
             {
                 DataTable dt = databaseLinkIBLL.FindTable(item.dbId, item.sql);
                 if (dt.Rows.Count > 0)
                 {
                     configInfoDataModel.data = dt;
                 }
             }
             else
             {
                 var          result       = HttpMethods.Get(item.url);
                 ResParameter resParameter = result.ToObject <ResParameter>();
                 if (resParameter != null)
                 {
                     if (resParameter.code.ToString() == "success")
                     {
                         configInfoDataModel.data = resParameter.data;
                     }
                 }
             }
             list.Add(configInfoDataModel);
         }
         return(list);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 获取心跳
        /// </summary>
        /// <param name="SyncKey"></param>
        public static void KeepHeart(string SyncKey)
        {
            Random ran      = new Random();
            string HeartUrl = UrlDefine.HeartUrl + "r=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + MethodsHelper.GetThreeNumber() +
                              "&skey=" + CommonDefine.LoginResult.skey
                              + "&sid=" + CommonDefine.LoginResult.wxsid
                              + "&uin=" + CommonDefine.LoginResult.wxuin
                              + "&deviceid=e9128931905052" + ((int)ran.Next(0, 9)).ToString() + ((int)(ran.Next(0, 8) + 1)).ToString() + "&synckey=" + SyncKey + "&_=" + DateTimeToosHelper.GetUnixTimeSpan().ToString() + MethodsHelper.GetThreeNumber();

            LogWriter.Write(SyncKey, @"SyncKey.log");
            string HeartList = string.Empty;

            try
            {
                HeartList = HttpMethods.Get(HeartUrl, CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString();
            }
            catch (Exception ex)
            {
                // HeartList = HttpMethods.Get(HeartUrl, CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString();
            }
            if (!string.IsNullOrWhiteSpace(HeartList))
            {
                LogWriter.Write(HeartList.ToString());
                if (HeartList.ToString() != "window.synccheck={retcode:\"0\",selector:\"0\"}")
                {
                    //   Thread.CurrentThread.Abort();
                    Console.WriteLine(HeartList.ToString());
                    GetMsg(CommonDefine.SyncKey);
                    CommonDefine.GetMsgSyncKey = GetSyncKey();// 理论上此处不需要赋值,如果收发消息出现问题,放开次注释
                }
                else if (HeartList.ToString() != "window.synccheck={retcode:\"0\",selector:\"7\"}")
                {
                    // GetMsgSyncKey = GetSyncKey();
                }
                Console.WriteLine(HeartList.ToString());
                Console.WriteLine("thK's while is breaked!" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"));
            }
            else
            {
                // GetMsgSyncKey = GetSyncKey();
            }
            return;
        }
Esempio n. 8
0
 /// <summary>
 /// 根据接口路径获取接口数据(仅限get方法)
 /// </summary>
 /// <param name="path">接口路径</param>
 /// <returns></returns>
 public object GetApiData(string path)
 {
     try
     {
         var          data         = new object();
         var          result       = HttpMethods.Get(path);
         ResParameter resParameter = result.ToObject <ResParameter>();
         if (resParameter != null)
         {
             if (resParameter.code.ToString() == "success")
             {
                 data = resParameter.data;
             }
             else
             {
                 data = "";
             }
         }
         else
         {
             data = "";
         }
         return(data);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 任务执行方法
        /// </summary>
        /// <param name="keyValue">任务进程主键</param>
        /// <returns></returns>
        private bool _Execute(string keyValue)
        {
            bool   isOk = true;
            string msg  = "执行成功";

            TSProcessEntity tSProcessEntity = null;
            TSSchemeEntity  tSSchemeEntity  = null;

            // 获取一个任务进程
            try
            {
                tSProcessEntity = tSProcessIBLL.GetProcessEntity(keyValue);
            }
            catch (Exception ex)
            {
                isOk = false;
                msg  = "获取任务进程异常:" + ex.Message;
            }

            if (tSProcessEntity != null && tSProcessEntity.F_State != 1 && tSProcessEntity.F_State != 2)
            {
                return(true);
            }

            // 获取对应的任务模板
            if (isOk)
            {
                try
                {
                    tSSchemeEntity = tSSchemeIBLL.GetSchemeEntity(tSProcessEntity.F_SchemeId);
                }
                catch (Exception ex)
                {
                    isOk = false;
                    msg  = "获取任务模板异常:" + ex.Message;
                }
            }

            bool flag = false;

            // 执行任务
            if (isOk)
            {
                try
                {
                    TSSchemeModel tSSchemeModel = tSSchemeEntity.F_Scheme.ToObject <TSSchemeModel>();
                    switch (tSSchemeModel.methodType)
                    {
                    case 1:    // sql
                        databaseLinkIBLL.ExecuteBySql(tSSchemeModel.dbId, tSSchemeModel.strSql);
                        break;

                    case 2:    // 存储过程
                        databaseLinkIBLL.ExecuteByProc(tSSchemeModel.dbId, tSSchemeModel.procName);
                        break;

                    case 3:    // 接口
                        if (tSSchemeModel.urlType == "1")
                        {
                            HttpMethods.Get(tSSchemeModel.url);
                        }
                        else
                        {
                            HttpMethods.Post(tSSchemeModel.url);
                        }
                        break;

                    case 4:    // 依赖注入
                        if (!string.IsNullOrEmpty(tSSchemeModel.iocName) && UnityIocHelper.TsInstance.IsResolve <ITsMethod>(tSSchemeModel.iocName))
                        {
                            ITsMethod iTsMethod = UnityIocHelper.TsInstance.GetService <ITsMethod>(tSSchemeModel.iocName);
                            iTsMethod.Execute();
                        }
                        break;
                    }

                    if (tSSchemeModel.executeType == 1)
                    {
                        flag = true;
                    }
                }
                catch (Exception ex)
                {
                    isOk = false;
                    msg  = "执行方法出错:" + ex.Message;
                }
            }

            try
            {
                // 新增一条任务日志
                TSLogEntity logEntity = new TSLogEntity()
                {
                    F_ExecuteResult = isOk ? 1 : 2,
                    F_Des           = msg,
                    F_ProcessId     = keyValue
                };
                logEntity.Create();
                tSLogIBLL.SaveEntity("", logEntity);

                if (tSProcessEntity.F_State == 1)
                {
                    tSProcessEntity.F_State = 2;
                    if (flag)
                    {
                        tSProcessEntity.F_State = 4;
                    }

                    tSProcessIBLL.SaveEntity(tSProcessEntity.F_Id, tSProcessEntity);
                }
            }
            catch (Exception)
            {
            }


            return(isOk);
        }
Esempio n. 10
0
        /// <summary>
        /// 登录
        /// </summary>
        public static void Login()
        {
            string str = string.Empty;

            HttpMethods.ContentType = "application/json;charset=utf-8";
            while (true)
            {
                if (!str.Contains("200"))
                {
                    HttpResponseResult ResponseResult = HttpMethods.Get(UrlDefine.WaitingUrl(UrlDefine.Tickets), CommonDefine.Cookies, Encoding.UTF8);
                    str = ResponseResult.ContentData.ToString();
                    Console.WriteLine("当前返回值是:" + str);
                    if (str.Contains("201"))
                    {
                        //扫码登录中
                        string[] base64 = str.Split(',');
                        CommonDefine.Base64 = base64[1];
                        byte[] arr = Convert.FromBase64String(CommonDefine.Base64.Replace("'", "").Replace(";", "").Trim());
                        File.WriteAllBytes(Environment.CurrentDirectory + "\\User.jpg", arr);
                        MemoryStream ms = new MemoryStream(arr);
                        BitmapImage  bi = new BitmapImage();
                        bi.BeginInit();
                        bi.StreamSource = ms;// new FileStream();
                        bi.EndInit();
                        CommonDefine.UserImage = bi;
                        CommonMethodCallBackHandlers.OnLoginScranQRCodeCompleted(Environment.CurrentDirectory + "\\User.jpg");
                    }
                }
                if (str.Contains("200"))
                {
                    //扫码登录完成
                    LogWriter.Write("扫码登录成功...", LogPathDefine.WeChatLogPath);
                    string[] strs = str.Split(';');
                    UrlDefine.LoginUrls = strs[1].Substring(strs[1].IndexOf("=\"") + 2, strs[1].Length - strs[1].IndexOf("=\"") - 3);
                    string XmlList = HttpMethods.Get(UrlDefine.LoginUrls, CommonDefine.Cookies, Encoding.UTF8, true).ContentData.ToString();
                    CommonDefine.GetCookieDictionary = HttpMethods.SetCookieDictionary;
                    CommonDefine.LoginResult         = XMLHelper.DESerializer <LoginResultEntity>(XmlList);
                    //此处可用于二次点击登录
                    LogWriter.Write(CommonDefine.LoginResult.wxuin, Environment.CurrentDirectory + "\\Data\\data.dat");
                    Random            r   = new Random();
                    BaseRequestEntity Bre = new BaseRequestEntity()
                    {
                        Uin = CommonDefine.LoginResult.wxuin, Sid = CommonDefine.LoginResult.wxsid, Skey = CommonDefine.LoginResult.skey, DeviceID = MethodsHelper.GetDeviceId()
                    };
                    BaseRequestSubmitEntity le = new BaseRequestSubmitEntity()
                    {
                        BaseRequest = Bre
                    };
                    string postdata   = JsonConvert.SerializeObject(le);
                    string MySelfList = HttpMethods.PostData(UrlDefine.GetLoginId + CommonDefine.LoginResult.pass_ticket, postdata, CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString();
                    LogWriter.Write(string.Format("获取个人信息{0}...", MySelfList), LogPathDefine.WeChatLogPath);
                    CommonDefine.BaseContact = JsonConvert.DeserializeObject <BaseContactEntity>(MySelfList);
                    string ContentList = HttpMethods.Get(UrlDefine.GetContactUrl(CommonDefine.LoginResult.pass_ticket, CommonDefine.LoginResult.skey), CommonDefine.Cookies, Encoding.UTF8).ContentData.ToString();
                    CommonDefine.ContactsList = JsonConvert.DeserializeObject <ContactsListEntity>(ContentList);
                    LogWriter.Write(string.Format("获取联系人信息{0}...", ContentList), LogPathDefine.WeChatLogPath);
                    new Task(() => { GetGroupContactsMethod(CommonDefine.ContactsList.MemberList); }).Start();
                    new Task(() =>
                    {
                        CommonDefine.ContactsList.MemberList.ForEach((p) =>
                        {
                            p.DownloadImage();
                        });
                    }).Start();
                    CommonMethodCallBackHandlers.OnLoginCompleted(true);
                    break;
                }
                Thread.Sleep(5000);
            }
        }