protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["SmoId"] == null)
     {
         _smoId = Guid.Empty;
     }
     else
     {
         _smoId = Guid.Parse(Request.QueryString["SmoId"]);
     }
     pdpDetailControl.BindParentList += BindParentList;
     pdpDetailControl.EnabledPdpGrid += EnablePdpGrid;
     if (!IsPostBack)
     {
         UtilsHelper.SetMenuButtonsEnable(SelectedPdp != null, menuPanel, menu1);
         pdpDetailControl.LoadPdps(_smoId, pdpsGridView);
     }
 }
Example #2
0
        public ActionResult LoadArea4dhtmlxTree(string userId)
        {
            int tempUserId = UtilsHelper.Decrypt2Int(userId);
            IList <ParamItemModel> ownList = ServiceProvider.SalesService.GetSaleOwnAreaByUserId(tempUserId);// Utils.LoginUser.saleAreaList;

            if (LoginHelper.IsSuperAdmin)
            {
                ownList = Global.Business.ServiceProvider.ParamService.GetByCode(GlobalConstants.SysParamType.SaleAreaCode).itemsList;
            }

            ContentResult cr = new ContentResult();

            cr.ContentType     = "text/xml";
            cr.ContentEncoding = Encoding.UTF8;
            cr.Content         = ServiceProvider.SalesService.GetOwnSaleAreadhtmlxTree(ownList);

            return(cr);
        }
 /// <summary>
 /// The assign control values from workstation.
 /// </summary>
 /// <param name="row">
 /// The row.
 /// </param>
 public void AssignControlValuesFromWorkstation(WorkstationGridRow row)
 {
     tbName.Text         = row.Name;
     readerName.Value    = row.UecReaderName;
     readerSmcName.Value = row.SmardCardReaderName;
     //comboReaderName.Text = row.UecReaderName;
     if (row.UecCerticateType == null || row.UecCerticateType == (int)CryptographyType.GOST)
     {
         rblCrypto.SelectedValue = "GOST";
     }
     else
     {
         rblCrypto.SelectedValue = "RSA";
     }
     uTerminalGOST.LoadedEarlierText        = UtilsHelper.GetLoadedSertificateText(TypeSertificate.TerminalGOST, row.SertificateUecs);
     uTerminalRSA.LoadedEarlierText         = UtilsHelper.GetLoadedSertificateText(TypeSertificate.TerminalRSA, row.SertificateUecs);
     uPrivateTerminalGOST.LoadedEarlierText = UtilsHelper.GetLoadedSertificateText(TypeSertificate.PrivateTerminalGOST, row.SertificateUecs);
 }
Example #4
0
        /// <summary>
        /// 刷新服务器
        /// </summary>
        private void refreshConnectionList()
        {
            List <Connection> connList = UtilsHelper.GetConnectionList();

            foreach (Connection conn in connList)
            {
                Connection tempconn = _ConnectList.Find(delegate(Connection connin) { return(conn.ID.ToString().Equals(connin.ID.ToString())); });
                if (null == tempconn)
                {
                    TreeNode nnode = new TreeNode(conn.Name, 0, 0);
                    nnode.ContextMenuStrip = contextMenuStripDatabase;
                    nnode.Tag = conn.ID.ToString();
                    Treeview.Nodes[0].Nodes.Add(nnode);
                }
            }

            _ConnectList = connList;
        }
Example #5
0
        public List <Backup> Get()
        {
            List <Backup> backups = new List <Backup>();

            string path = ConfigurationManager.AppSettings["BACKUP_PATH"];

            UtilsHelper.CreateDirectory(path);

            DirectoryInfo Dir = new DirectoryInfo(path);

            FileInfo[] FileList = Dir.GetFiles("*.bkp", SearchOption.AllDirectories);
            foreach (FileInfo backupFile in FileList)
            {
                backups.Add(new Backup(backupFile.Name, backupFile.FullName, backupFile.Length, backupFile.CreationTime));
            }

            return(backups);
        }
Example #6
0
        public string GetUserList(string orgId)
        {
            orgId = UtilsHelper.Decrypt(orgId);
            IList <UserModel> userList = ServiceProvider.UserService.GetListByOrgId(Convert.ToInt32(orgId));
            IList <Hashtable> userRole = ServiceProvider.UserService.GetAllUserRole();

            StringBuilder sb       = new StringBuilder();
            StringBuilder roleName = new StringBuilder();
            int           count    = 0;

            sb.Append("{\"data\":[");
            foreach (var user in userList)
            {
                roleName.Clear();
                IEnumerable <Hashtable> where = userRole.Where(ur => int.Equals(ur["UserId"], user.UserId));
                foreach (var role in where)
                {
                    roleName.AppendFormat("{0}{1}", role["RoleName"], count == 0 ? "" : "<br/>");
                    count += 1;
                }


                sb.AppendFormat("[\"<a href='#' onclick='fnNewWindow({6});return false;'>角色设置</a><br/>"
                                //+ "<a href='#' onclick='fnConfirmWithoutF5('确定重置账户【{0}】密码?','/SysManage/User/ResetPWD?userId={8}');return false;'>重置密码</a>"
                                + "<a href='#' onclick='fnUpdateUser({7});return false;'>编辑资料</a><br/>"
                                + "<a href='#' onclick='fnResetPWD({7});return false;'>重置密码</a><br/>"
                                + "<a href='#' onclick='fnOpenCloseUser({8});return false;'>禁用启用</a><br/>"
                                + "<a href='#' onclick='fnDeleteUser({9});return false;'>删除用户</a><br/>"
                                + "<a href='#' onclick='fnSaleManageDeptWindow({9});return false;'>管理部门</a><br/>"
                                //+ "<a href='#' onclick='fnTestLogin({12});return false;'>登录验证</a>"
                                + "\",\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\""
                                + "],", user.UserName,
                                //user.Sex ? "男" : "女", user.JobNo, user.DepartName, user.Duty, user.IsEnabled == 0 ? "启用" : "禁用",
                                //user.EmployeeState == 0 ? "在职" : "离职", roleName, user.UserId, user.UserId, user.UserId, user.UserId, user.UserId);
                                user.JobNo, user.DepartName, user.Duty,
                                roleName, user.UserId, user.UserId, user.UserId, user.UserId, user.UserId);
            }
            if (userList.Count > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]}");
            return(sb.ToString());
        }
Example #7
0
        /// <summary>
        /// Create a new recording
        /// </summary>
        /// <param name="info">The TimerInfo</param>
        /// <param name="cancellationToken">The cancellationToken</param>
        /// <returns></returns>
        public async Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken)
        {
            //_logger.Info(string.Format("[VDR] Start CreateTimer Async for ChannelId: {0} & Name: {1}", info.ChannelId, info.Name));
            _logger.Info("[VDR] Start CreateTimer Async for ChannelId NOT IMPLIMENTED");
            throw new NotImplementedException();

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/ScheduleService/Record?sid={1}", baseUrl, Sid)
            };

            var timerSettings = await GetDefaultScheduleSettings(cancellationToken).ConfigureAwait(false);

            timerSettings.allChannels = false;
            timerSettings.ChannelOID  = int.Parse(info.ChannelId, _usCulture);

            if (!string.IsNullOrEmpty(info.ProgramId))
            {
                timerSettings.epgeventOID = int.Parse(info.ProgramId, _usCulture);
            }

            timerSettings.post_padding_min = info.PostPaddingSeconds / 60;
            timerSettings.pre_padding_min  = info.PrePaddingSeconds / 60;

            var postContent = _jsonSerializer.SerializeToString(timerSettings);

            UtilsHelper.DebugInformation(_logger, string.Format("[VDR] TimerSettings CreateTimer: {0} for ChannelId: {1} & Name: {2}", postContent, info.ChannelId, info.Name));

            options.RequestContent     = postContent;
            options.RequestContentType = "application/json";

            try
            {
                await _httpClient.Post(options).ConfigureAwait((false));
            }
            catch (HttpException ex)
            {
                _logger.Error(string.Format("[VDR] CreateTimer async with exception: {0}", ex.Message));
                throw new LiveTvConflictException();
            }
        }
Example #8
0
        /// <summary>
        /// Update the series Timer
        /// </summary>
        /// <param name="info">The series program info</param>
        /// <param name="cancellationToken">The CancellationToken</param>
        /// <returns></returns>
        public async Task UpdateSeriesTimerAsync(SeriesTimerInfo info, CancellationToken cancellationToken)
        {
            _logger.LogInformation(string.Format("[NextPvr] Start UpdateSeriesTimer Async for ChannelId: {0} & Name: {1}", info.ChannelId, info.Name));
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/ScheduleService/UpdateRecurr?sid={1}", baseUrl, Sid),
                DecompressionMethod = CompressionMethod.None
            };

            var timerSettings = await GetDefaultScheduleSettings(cancellationToken).ConfigureAwait(false);

            timerSettings.recurrOID           = int.Parse(info.Id);
            timerSettings.post_padding_min    = info.PostPaddingSeconds / 60;
            timerSettings.pre_padding_min     = info.PrePaddingSeconds / 60;
            timerSettings.allChannels         = info.RecordAnyChannel;
            timerSettings.onlyNew             = info.RecordNewOnly;
            timerSettings.recurringName       = info.Name;
            timerSettings.recordAnyTimeslot   = info.RecordAnyTime;
            timerSettings.keep_all_days       = true;
            timerSettings.days_to_keep        = 0;
            timerSettings.extend_end_time_min = 0;

            var postContent = _jsonSerializer.SerializeToString(timerSettings);

            UtilsHelper.DebugInformation(_logger, string.Format("[NextPvr] TimerSettings UpdateSeriesTimer: {0} for ChannelId: {1} & Name: {2}", postContent, info.ChannelId, info.Name));

            options.RequestContent     = postContent;
            options.RequestContentType = "application/json";

            try
            {
                await _httpClient.Post(options).ConfigureAwait((false));
            }
            catch (HttpException ex)
            {
                _logger.LogError(string.Format("[NextPvr] UpdateSeries async with exception: {0}", ex.Message));
                throw new LiveTvConflictException();
            }
        }
        /// <summary>
        /// Send api request to scatter
        /// </summary>
        /// <typeparam name="TRequest">Request type param</typeparam>
        /// <typeparam name="TReturn">Return type param</typeparam>
        /// <param name="request">Request object</param>
        /// <param name="timeout">set response timeout that overrides the default one</param>
        /// <returns></returns>
        public async Task <TReturn> SendApiRequest <TRequest, TReturn>(Request <TRequest> request, int?timeout = null)
        {
            if (request.type == "identityFromPermissions" && !Paired)
            {
                return(default(TReturn));
            }

            await Pair();

            if (!Paired)
            {
                throw new Exception("The user did not allow this app to connect to their Scatter");
            }

            var tcs = new TaskCompletionSource <object>();

            do
            {
                request.id = UtilsHelper.RandomNumber(24);
            }while (OpenTasks.ContainsKey(request.id));

            request.appkey = StorageProvider.GetAppkey();
            request.nonce  = StorageProvider.GetNonce() ?? "";

            var nextNonce = UtilsHelper.RandomNumberBytes();

            request.nextNonce = UtilsHelper.ByteArrayToHexString(Sha256Manager.GetHash(nextNonce));
            StorageProvider.SetNonce(UtilsHelper.ByteArrayToHexString(nextNonce));

            OpenTasks.Add(request.id, new OpenTask()
            {
                PromiseTask     = tcs,
                TaskRequestTime = DateTime.Now,
                TaskTimeoutMS   = timeout.HasValue ? timeout.Value : TimeoutMS
            });

            await SockIO.EmitAsync("api", new RequestWrapper()
            {
                data   = request,
                plugin = AppName
            });

            return(BuildApiResponse <TReturn>(await tcs.Task));
        }
        public void AnalysisTrade(TraceDataSocket receiveData)
        {
            Dictionary <string, string> dic = GetPairs(receiveData.ch);
            //取data索引为0,为最新一条
            int      len = receiveData.tick.data.Length - 1;
            DateTime dt  = UtilsHelper.GetTime(long.Parse(receiveData.tick.data[len].
                                                          datumTs.ToString().Substring(0, 10)));
            var obj = new
            {
                CurrencyName    = dic[CRRENCY_NAME],
                TransactionDate = dt.ToString("yyyy-MM-dd HH:mm:ss:ff"),
                Amount          = receiveData.tick.data[len].amount,
                Price           = receiveData.tick.data[len].price,
                Direction       = receiveData.tick.data[0].direction
            };
            string json = JsonConvert.SerializeObject(obj);

            RedisHelper.SetAsync(obj.CurrencyName, json, timeOut);
        }
Example #11
0
        public ActionResult Detail(string contactId)
        {
            IList <Global.Common.Models.ParamModel> paramList = Global.Business.ServiceProvider.ParamService.GetAll();
            ContactModel model = ServiceProvider.ContactService.GetById(UtilsHelper.Decrypt2Int(contactId));

            //事项分类
            Global.Common.Models.ParamModel caseType = paramList.SingleOrDefault(m => m.ParamCode.Equals(Constants.SysParamType.ContactCaseType));
            ParamItemModel item = caseType.itemsList.SingleOrDefault(p => p.ParamItemValue.Equals(model.CaseType.ToString()));

            ViewBag.CaseType = item.ParamItemName;
            IList <BusinessAttachmentModel> businessAttachList = ServiceProvider.BusinessAttachmentService.GetByBusinessTypeAndId(Constants.AttachmentBusinessType.联络单.GetHashCode(), model.ContactId);

            if (businessAttachList.Count > 0 && businessAttachList.First() != null)
            {
                ViewBag.FileId   = UtilsHelper.Encrypt(businessAttachList.First().FileId.ToString());
                ViewBag.FileName = businessAttachList.First().FileName;
            }
            return(View(model));
        }
Example #12
0
        private bool canEdit(EDirType dirtype)
        {
            bool editable = true;

            if (dirtype == EDirType.StreamingAssetsPath ||
                dirtype == EDirType.DataPath)
            {
                var platform = UtilsHelper.GetPlatform();
                if (platform == EPlatform.Mac || platform == EPlatform.Windows)
                {
                    editable = true;
                }
                else
                {
                    editable = false;
                }
            }
            return(editable);
        }
Example #13
0
        /// <summary>
        /// 完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            button1.Enabled = true;

            panelbtns.Enabled = true;

            sysconfigModel.Namespace = txtNamaspace.Text;

            UtilsHelper.WriteNamespace(txtNamaspace.Text);

            if (_noneWorkCount == 0)
            {
                MessageBox.Show("代码导出操作已完成!");
            }
            else
            {
                MessageBox.Show($"代码导出操作已完成,但其中有{_noneWorkCount}张表因无任何主键未能生成代码");
            }
        }
Example #14
0
        /// <summary>
        /// Returns a list of files which are used by the OpenVPN Service.
        /// </summary>
        /// <returns></returns>
        public static List <string> LocateOpenVPNServiceConfigs()
        {
            List <string> files = new List <string>();

            if (!CanUseService())
            {
                return(files);
            }

            try
            {
                UtilsHelper.GetConfigFiles(
                    new DirectoryInfo(UtilsHelper.LocateOpenVPNServiceDir()),
                    files, Helper.LocateOpenVPNServiceFileExt(), true);
            }
            catch (DirectoryNotFoundException)
            { }
            return(files);
        }
Example #15
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BatchForm_Load(object sender, EventArgs e)
        {
            try
            {
                sysconfigModel = UtilsHelper.GetSysconfigModel();

                txtNamaspace.Text = sysconfigModel.Namespace;

                var index = connectionModel.Name.IndexOf("[");

                if (index < 0)
                {
                    index = connectionModel.Name.IndexOf("(");
                }

                llServer.Text       = connectionModel.Name.Substring(0, index);
                llDatabaseName.Text = DatabaseName;
                txtPath.Text        = sysconfigModel.BatchDirectoryPath;


                DataTable tablesDT = null;

                dbObject = DBObjectHelper.GetDBObject(ConnectionModel);

                tablesDT = dbObject.GetTables(DatabaseName);

                DataRow[] drs = tablesDT.Select("", "name asc");

                if (null != drs && drs.Length > 0)
                {
                    foreach (DataRow dr in drs)
                    {
                        lbleft.Items.Add(dr[0]);
                        tableview.Add(dr[0].ToString(), false);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"");
                this.Close();
            }
        }
Example #16
0
        public ClientKeys GetClientKeys(Stream stream, IJsonSerializer json, ILogger <LiveTvService> logger)
        {
            try
            {
                var root = json.DeserializeFromStream <ClientKeys>(stream);

                if (root.sid != null && root.salt != null)
                {
                    UtilsHelper.DebugInformation(logger, string.Format("[NextPVR] ClientKeys: {0}", json.SerializeToString(root)));
                    return(root);
                }
                logger.LogError("[NextPVR] Failed to validate the ClientKeys from NextPVR.");
                throw new Exception("Failed to load the ClientKeys from NextPVR.");
            }
            catch
            {
                logger.LogError("Check NextPVR Version 5");
                throw new UnauthorizedAccessException("Check NextPVR Version");
            }
        }
Example #17
0
        /// <summary>
        /// 保存实体数据.
        /// </summary>
        public void Save(InstrumentCertificationModel model, HttpFileCollectionBase Files)
        {
            if (Files.Count > 0 && Files[0].ContentLength > 0)
            {
                string          targetPath = WebUtils.GetSettingsValue("InstrumentCertificationPath");
                string          targetFile = string.Format(@"{0}/{1}{2}", targetPath, StrUtils.GetUniqueFileName(null), Path.GetExtension(Files[0].FileName));
                AttachmentModel attModel   = UtilsHelper.FileUpload(Files[0], targetFile, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));
                attModel.FileType = (int)UtilConstants.AttachmentType.仪器周检证书;
                attModel.UserId   = LoginHelper.LoginUser.UserId;
                attModel.UserName = LoginHelper.LoginUser.UserName;
                if (model.LogId != 0)//重新上传删除原来文件
                {
                    Global.Business.ServiceProvider.AttachmentService.DeleteById(model.FileId);
                }
                Global.Business.ServiceProvider.AttachmentService.Save(attModel);
                model.FileId = attModel.FileId;//新文件位置
                //model.FileVirtualPath = WebUtils.GetSettingsValue("WebFileServer")+targetFile;
            }
            if (model.LogId == 0)
            {
                model.CreateUser = LoginHelper.LoginUser.UserName;
                model.ItemCode   = Guid.NewGuid().ToString();
                DBProvider.InstrumentCertificationDAO.Add(model);
            }
            else
            {
                DBProvider.InstrumentCertificationDAO.Update(model);
            }
            //找出仪器下到期日期最大并且当前日期在有效期之内同时完成周检的证书记录并更新
            UpdateCertificationAndState(model.InstrumentId);
            //更新上次修改人和修改时间
            Instrument.Common.Models.InstrumentModel instrumentModel = new Instrument.Common.Models.InstrumentModel();
            instrumentModel.InstrumentId   = model.InstrumentId;
            instrumentModel.LastUpdateUser = LoginHelper.LoginUser.UserName;
            ServiceProvider.InstrumentService.UpdateLastUpdateInfo(instrumentModel);

            if (LoginHelper.LoginUserAuthorize.Contains("/Instrument/SynInstrument".ToLower()))
            {
                ServiceProvider.InstrumentService.BeginSynInstrument(model.InstrumentId);
            }
        }
Example #18
0
        public ActionResult DocumentList()
        {
            //文件分类
            IList <ParamModel>    list         = Global.Business.ServiceProvider.ParamService.GetAll();
            ParamModel            paramModel   = list.SingleOrDefault(p => p.ParamCode == Constants.SysParamType.DocumentType);
            IList <DocumentModel> documentList = ServiceProvider.DocumentService.GetAll();
            StringBuilder         sb           = new StringBuilder();
            StringBuilder         operate      = new StringBuilder();

            sb.Append("[");
            foreach (var document in documentList)
            {
                sb.Append("[");
                if (LoginHelper.LoginUserAuthorize.Contains("/Document/Details".ToLower()))
                {
                    operate.Append("<a href='#' onclick='fnUpdateDocument({0});return false;'>编 辑</a>&nbsp;&nbsp;&nbsp;");
                }
                if (LoginHelper.LoginUserAuthorize.Contains("/Document/Delete".ToLower()))
                {
                    operate.Append("<a href='#' onclick='fnDeleteDocument({0},{1});return false;'>删 除</a>&nbsp;&nbsp;&nbsp;");
                }
                if (LoginHelper.LoginUserAuthorize.Contains("作业指导书-关联仪器".ToLower()))
                {
                    operate.Append("<a href='#' onclick='fnRelateDocument({0});return false;'>关联仪器</a>&nbsp;&nbsp;&nbsp;");
                }
                sb.AppendFormat("\"" + operate + "\"", document.DocumentId, UtilsHelper.Encrypt(document.FileId.ToString()));
                operate.Clear();
                sb.AppendFormat(",\"<a href='#' id='{0}' onclick='fnDownFile(this);return false;'>{1}</a>\"", UtilsHelper.Encrypt(document.FileId.ToString()), document.FileName);
                sb.AppendFormat(",\"{0}\"", paramModel.itemsList.SingleOrDefault(p => p.ParamItemValue == document.DocCategory.ToString()).ParamItemName);
                sb.AppendFormat(",\"{0:d}\"", document.CreateDate);
                sb.AppendFormat(",\"{0}\"", document.Remark);
                sb.Append("],");
            }
            if (documentList.Count > 0)
            {
                sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]");
            ViewBag.documentData = sb.ToString();
            return(View(new DocumentModel()));
        }
Example #19
0
        public ActionResult UploadBusinessAttachment(int businessType, string businessKeyId, string businessNumber, FormCollection collection)
        {
            BusinessAttachmentModel model = new BusinessAttachmentModel();

            try
            {
                //是否需要自动解压缩
                bool isExtract = collection["isExtract"] == null ? false : true;

                model.BusinessType  = businessType;
                model.BusinessKeyId = UtilsHelper.Decrypt2Int(businessKeyId);
                model.UserName      = LoginHelper.LoginUser.UserName;
                //获取后缀名
                string Extension = System.IO.Path.GetExtension(Request.Files[0].FileName).ToLower();
                if (isExtract)
                {
                    switch (Extension)
                    {
                    case ".zip":
                    case ".bz":
                    case ".gz":
                        ServiceProvider.BusinessAttachmentService.UploadBusinessAttachmentbyExtract(businessNumber, model, Request.Files);
                        break;

                    default:
                        ServiceProvider.BusinessAttachmentService.UploadBusinessAttachment(businessNumber, model, Request.Files);
                        break;
                    }
                }
                else
                {
                    ServiceProvider.BusinessAttachmentService.UploadBusinessAttachment(businessNumber, model, Request.Files);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(Content(ex.Message + "_-1"));
            }
            return(Content("OK_" + model.FileId));
        }
Example #20
0
        /// <summary>
        /// 记录日志列表
        /// </summary>
        /// <returns></returns>
        public ActionResult RecordLog(int FKType)
        {
            string URL = Request.RawUrl;
            //截取参数(参数中含有特殊字符)
            int    index    = URL.IndexOf('?') + 1;
            string paramstr = URL.Substring(index, URL.Length - index);
            //先用&将参数分组
            var pramas = paramstr.Split('&');
            //再用=号将参数分组
            var pramas2 = pramas[0].Split('=');
            //解密
            int FKvalueInt = 0;

            if (!string.IsNullOrEmpty(pramas2[1]))
            {
                FKvalueInt = UtilsHelper.Decrypt2Int(pramas2[1]);
            }
            ViewBag.FKValue = pramas2[1];
            ViewBag.FKType  = FKType;
            return(View("RecordLog"));
        }
Example #21
0
        public ActionResult LoadOrgJavascript(string userId)
        {
            //userId = UtilsHelper.Decrypt(userId);

            StringBuilder    js         = new StringBuilder();
            IList <OrgModel> checkedOrg = ServiceProvider.SalesService.GetSaleManageDepartByUserId(int.Parse(userId));

            if (checkedOrg != null)
            {
                foreach (OrgModel item in checkedOrg)
                {
                    IEnumerable <OrgModel> parentOrg = checkedOrg.Where(org => org.OrgCode.IndexOf(item.OrgCode) == 0 && org.OrgCode != item.OrgCode);
                    //当前组织仅仅为叶节点时
                    if (parentOrg.Count() == 0)
                    {
                        js.AppendFormat("tree.setCheck('{0}',1);{1}", UtilsHelper.Encrypt(item.OrgId.ToString()), Environment.NewLine);
                    }
                }
            }
            return(JavaScript(js.ToString()));
        }
Example #22
0
 //保存仪器照片
 public void SaveInstrumentPic(HttpFileCollectionBase Files, int instrumentId)
 {
     if (Files["InstrumentPic"] != null)
     {
         //保存仪器图片
         string          targetPath = WebUtils.GetSettingsValue("InstrumentPicFilePath");
         string          targetFile = string.Format(@"{0}/{1}{2}", targetPath, StrUtils.GetUniqueFileName(null), Path.GetExtension(Files["InstrumentPic"].FileName));
         AttachmentModel attModel   = UtilsHelper.FileUpload(Files["InstrumentPic"], targetFile, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));
         attModel.FileType = (int)Instrument.Common.Constants.AttachmentBusinessType.仪器照片;
         attModel.UserId   = LoginHelper.LoginUser.UserId;
         attModel.UserName = LoginHelper.LoginUser.UserName;
         Global.Business.ServiceProvider.AttachmentService.Save(attModel);
         BusinessAttachmentModel businessAttachmentModel = new BusinessAttachmentModel();
         businessAttachmentModel.BusinessKeyId = instrumentId;
         businessAttachmentModel.BusinessType  = attModel.FileType;
         businessAttachmentModel.UserName      = LoginHelper.LoginUser.UserName;
         businessAttachmentModel.FileName      = attModel.FileName;
         businessAttachmentModel.FileId        = attModel.FileId;
         Instrument.Business.ServiceProvider.BusinessAttachmentService.Save(businessAttachmentModel);
     }
 }
Example #23
0
        /// <summary>
        /// 上传业务附件
        /// </summary>
        /// <param name="businessNumber"></param>
        /// <param name="model"></param>
        /// <param name="Files"></param>
        public void UploadBusinessAttachment(string businessNumber, BusinessAttachmentModel model, HttpFileCollectionBase Files)
        {
            AttachmentModel attachment = new AttachmentModel();
            string          targetDir  = GetByBusinessTypeAndId((Constants.AttachmentBusinessType)model.BusinessType, businessNumber);


            //默认随机名
            string fileName = Guid.NewGuid().ToString();

            string targetFile = string.Format(@"{0}{1}{2}", targetDir, fileName, System.IO.Path.GetExtension(Files[0].FileName));

            //原始记录上传操作
            attachment = UtilsHelper.FileUpload(Files[0].InputStream, Files[0].FileName, targetFile, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));

            //入库
            Global.Business.ServiceProvider.AttachmentService.Save(attachment);
            model.FileId   = attachment.FileId;
            model.FileName = attachment.FileName;

            Save(model);
        }
Example #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="port"></param>
        /// <param name="penddingConnNum">Number of pending connections</param>
        public void Start(int port = 8086, int penddingConnNum = 5)
        {
            if (mRunning)
            {
                return;
            }
            mRunning = true;

            init(port);
            WWWCache.Instance.Load("www.zip", () =>
            {
                mServer.Start(penddingConnNum);
                Debug.Log("http server running on port:" + port);

                Broadcast.Instance.Init();
                Broadcast.Instance.Tick(UtilsHelper.GetPlatform() + ":" + Network.player.ipAddress + ":" + port.ToString(), 1f);
            },
                                   () =>
            {
            }, psw);
        }
Example #25
0
    public async Task <ClientKeys> GetClientKeys(Stream stream, ILogger <LiveTvService> logger)
    {
        try
        {
            var root = await JsonSerializer.DeserializeAsync <ClientKeys>(stream, _jsonOptions).ConfigureAwait(false);

            if (root.Sid != null && root.Salt != null)
            {
                UtilsHelper.DebugInformation(logger, $"[NextPVR] ClientKeys: {JsonSerializer.Serialize(root, _jsonOptions)}");
                return(root);
            }

            logger.LogError("[NextPVR] Failed to validate the ClientKeys from NextPVR");
            throw new JsonException("Failed to load the ClientKeys from NextPVR.");
        }
        catch
        {
            logger.LogError("Check NextPVR Version 5");
            throw new UnauthorizedAccessException("Check NextPVR Version");
        }
    }
Example #26
0
        public ActionResult Save(DocumentModel documentModel, FormCollection collection)
        {
            ParamModel documentTypeModel = Global.Business.ServiceProvider.ParamService.GetAll().SingleOrDefault(S => S.ParamCode == Constants.SysParamType.DocumentType);

            if (Request.Files.Count > 0)//有文件上传(新增或修改)
            {
                HttpPostedFileBase fileData = Request.Files[0];
                if (null != fileData && 0 != fileData.ContentLength)
                {
                    string url             = WebUtils.GetSettingsValue("InstrumentDocumentFilePath") + @"/" + StrUtils.GetUniqueFileName(null) + System.IO.Path.GetExtension(Request.Files[0].FileName);
                    var    AttachmentModel = UtilsHelper.FileUpload(Request.Files[0], url, (UtilConstants.ServerType)Convert.ToInt32(WebUtils.GetSettingsValue("WebFileType") == null ? "1" : WebUtils.GetSettingsValue("WebFileType")));
                    Global.Business.ServiceProvider.AttachmentService.Save(AttachmentModel);
                    documentModel.FileId      = AttachmentModel.FileId;
                    documentModel.FileName    = fileData.FileName;
                    documentModel.DocCategory = int.Parse(documentTypeModel.itemsList.SingleOrDefault(S => S.ParamItemName == collection["DocCategory"]).ParamItemValue);
                    documentModel.Remark      = collection["Remark"];
                    documentModel.CreateDate  = System.DateTime.Now;
                    documentModel.Creator     = LoginHelper.LoginUser.UserName;
                    ServiceProvider.DocumentService.Save(documentModel);
                    return(Content("OK"));
                }
                else
                {
                    return(Content("体系文件无效!"));
                }
            }
            else if (documentModel.DocumentId != 0)//修改
            {
                documentModel.DocCategory = int.Parse(documentTypeModel.itemsList.SingleOrDefault(S => S.ParamItemName == collection["DocCategory"]).ParamItemValue);
                documentModel.Remark      = collection["Remark"];
                documentModel.CreateDate  = System.DateTime.Now;
                documentModel.Creator     = LoginHelper.LoginUser.UserName;
                ServiceProvider.DocumentService.Save(documentModel);
                return(Content("OK"));
            }//新增
            else
            {
                return(Content("体系文件无效!"));
            }
        }
Example #27
0
        /// <summary>
        /// Update a single Timer
        /// </summary>
        /// <param name="info">The program info</param>
        /// <param name="cancellationToken">The CancellationToken</param>
        /// <returns></returns>
        public async Task UpdateTimerAsync(TimerInfo info, CancellationToken cancellationToken)
        {
            _logger.LogInformation(string.Format("[NextPvr] Start UpdateTimer Async for ChannelId: {0} & Name: {1}", info.ChannelId, info.Name));
            await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);

            var baseUrl = Plugin.Instance.Configuration.WebServiceUrl;

            var options = new HttpRequestOptions
            {
                CancellationToken = cancellationToken,
                Url = string.Format("{0}/public/ScheduleService/UpdateRec?sid={1}", baseUrl, Sid),
                DecompressionMethod = CompressionMethod.None
            };

            var timerSettings = await GetDefaultScheduleSettings(cancellationToken).ConfigureAwait(false);

            timerSettings.scheduleOID      = int.Parse(info.Id);
            timerSettings.post_padding_min = info.PostPaddingSeconds / 60;
            timerSettings.pre_padding_min  = info.PrePaddingSeconds / 60;

            var postContent = _jsonSerializer.SerializeToString(timerSettings);

            UtilsHelper.DebugInformation(_logger, string.Format("[NextPvr] TimerSettings UpdateTimer: {0} for ChannelId: {1} & Name: {2}", postContent, info.ChannelId, info.Name));

            options.RequestContent     = postContent;
            options.RequestContentType = "application/json";

            try
            {
                await _httpClient.Post(options).ConfigureAwait((false));

                LastRecordingChange = DateTimeOffset.UtcNow;
            }
            catch (HttpException ex)
            {
                LastRecordingChange = DateTimeOffset.UtcNow;
                _logger.LogError(string.Format("[NextPvr] UpdateTimer Async with exception: {0}", ex.Message));
                throw new LiveTvConflictException();
            }
        }
Example #28
0
        /// <summary>
        /// Try to detect openvpn binary and configuration directory.
        /// </summary>
        public void Detect()
        {
            // reset pathes
            string oldVPNBin = Properties.Settings.Default.vpnbin;

            Properties.Settings.Default.vpnbin  = "";
            Properties.Settings.Default.vpnconf = "";
            Properties.Settings.Default.Save();

            // locate vpn
            string vpnbin = UtilsHelper.LocateOpenVPN();

            if (vpnbin == null)
            {
                return;
            }
            else
            {
                Properties.Settings.Default.vpnbin = vpnbin;
                WarnServiceChange(vpnbin, oldVPNBin);
            }

            Properties.Settings.Default.Save();

            // try to locate configuration
            string vpnconf = UtilsHelper.LocateOpenVPNConfigDir(vpnbin);

            // vpn config was not found, abort
            if (vpnconf == null)
            {
                return;
            }
            // vpn config was found, save path
            else
            {
                Properties.Settings.Default.vpnconf = vpnconf;
            }

            Properties.Settings.Default.Save();
        }
        public ActionResult ReadCert(string Id)
        {
            int certId = UtilsHelper.Decrypt2Int(Id);

            Global.Common.Models.AttachmentModel model = Global.Business.ServiceProvider.AttachmentService.GetById(certId);
            string tempPath      = "/tempFile/";
            string tempFileName  = string.Format("{0}.swf", Guid.NewGuid().ToString());
            string webFileServer = WebUtils.GetSettingsValue("WebFileServer");
            string userId        = WebUtils.GetSettingsValue("WebFileServerUser");
            string pwd           = WebUtils.GetSettingsValue("WebFileServerPwd");
            string oldFileSwf    = model.FileVirtualPath.Replace(".pdf", ".swf");

            try
            {
                if (!UtilsHelper.IsExistInFSServer(webFileServer, oldFileSwf, userId, pwd))
                {
                    if (UtilsHelper.IsExistInFSServer(webFileServer, model.FileVirtualPath, userId, pwd))
                    {
                        Stream swfStream  = UtilsHelper.FileDownload(model.FileAccessPrefix, model.FileVirtualPath, UtilConstants.ServerType.WebFileService);
                        string pdfFilestr = CommonUtils.GetPhysicsPath(string.Format("{0}{1}.pdf", tempPath, Guid.NewGuid()));
                        ToolsLib.FileService.NormalFile.SaveInfoToFile(swfStream, pdfFilestr);
                        string swfSourceFile = UtilsHelper.PdfToSwf(pdfFilestr, tempFileName);
                        model.FileVirtualPath = string.Format("{0}{1}", tempPath, Path.GetFileName(swfSourceFile));
                        UtilsHelper.FileUpload(model.FileAccessPrefix, swfSourceFile, oldFileSwf, UtilConstants.ServerType.WebFileService);
                    }
                }
                else
                {
                    Stream swfStream  = UtilsHelper.FileDownload(model.FileAccessPrefix, oldFileSwf, UtilConstants.ServerType.WebFileService);
                    string swfFilestr = CommonUtils.GetPhysicsPath(string.Format("{0}{1}", tempPath, tempFileName));
                    ToolsLib.FileService.NormalFile.SaveInfoToFile(swfStream, swfFilestr);
                    model.FileVirtualPath = string.Format("{0}{1}", tempPath, tempFileName);
                }
            }
            catch (Exception e)
            {
                return(Content("浏览的文件已经顺坏或者加密"));
            }
            return(RedirectToAction("ReadPdf", "SysManage/Common", new { filePath = model.FileVirtualPath }));
        }
Example #30
0
        public IActionResult Post(Cliente cliente)
        {
            try
            {
                using (var db = new ZupContext())
                {
                    cliente.Senha = UtilsHelper.CriptografaSenha(cliente.Senha);
                    db.Cliente.Add(cliente);
                    db.SaveChanges();
                }

                return(Ok());
            }
            catch (Exception er)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ErroModel()
                {
                    Mensagem = er.Message,
                    StackTrace = er.StackTrace
                }));
            }
        }