Example #1
0
        //For Search Grid
        public List <INVStoreTrans> GetTransactionInfoForSearch(string _TransactionType)
        {
            using (_context)
            {
                var AllData = (from t in _context.INV_StoreTrans
                               where t.TransactionCategory == "ISU" & t.TransactionType == _TransactionType

                               join r in _context.INV_StoreTransRequest on t.TransactionID equals r.TransactionID into ReqInfo
                               from r in ReqInfo.DefaultIfEmpty()

                               from tf in _context.SYS_Store.Where(x => (x.StoreID).ToString() == t.TransactionFrom).DefaultIfEmpty()
                               from tt in _context.SYS_Store.Where(x => (x.StoreID).ToString() == t.TransactionTo).DefaultIfEmpty()

                               orderby t.TransactionID descending
                               select new INVStoreTrans
                {
                    TransactionID = t.TransactionID,
                    TransactionNo = t.TransactionNo,
                    TransactionDateTemp = (t.TransactionDate),
                    TransactionFrom = (tf == null ? null : tf.StoreName),
                    TransactionTo = (tt == null ? null : tt.StoreName),
                    RecordStatus = (t.RecordStatus),
                    ReqFromDateTemp = (r.ReqFromDate),
                    ReqToDateTemp = (r.ReqToDate),
                    RequisitionNo = r.RequestNo
                }).ToList();

                return(AllData);
            }
        }
Example #2
0
        private void SendBTN_Click(object sender, EventArgs e)
        {
            ReqInfo     package        = new ReqInfo();
            RegistryKey processor_name = Registry.LocalMachine.OpenSubKey(@"Hardware\Description\System\CentralProcessor\0", RegistryKeyPermissionCheck.ReadSubTree);

            if (processor_name != null)
            {
                if (processor_name.GetValue("ProcessorNameString") != null)
                {
                    package.CPU = Convert.ToString((processor_name.GetValue("ProcessorNameString")));
                }
            }
            package.DateofReq   = DateTime.Now.ToString("MM/dd/yyyy HH:mm");
            package.Header      = ProblemHeader.Text;
            package.probleminfo = ProblemText.Text;
            package.OS          = getOSInfo() + '/' + Environment.OSVersion;
            //package.currentuser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            package.currentuser = Environment.UserName;
            package.pcname      = Environment.MachineName;
            //string json = JsonConvert.SerializeObject(package);
            string json = string.Format("{{\"CPU\": \"{0}\", \"OS\": \"{1}\", \"DateofReq\": \"{2}\", \"Header\": \"{3}\", \"probleminfo\": \"{4}\", \"currentuser\": \"{5}\", \"pcname\": \"{6}\"}}"
                                        , package.CPU, package.OS, package.DateofReq, package.Header, package.probleminfo, package.currentuser, package.pcname);
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:59735/api/values/add"); // сюда нужно будет вставить адрес апи сервера, принимающего запрос

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            //var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            MessageBox.Show("Ваш запрос принят в обработку. Диалоговое окно закроется автоматически.(отключил закрытие, чтобы можно было посмотреть на результат.)", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            ProblemText.Text = json;
            //this.Close();
        }
Example #3
0
        public static Task Process(IDictionary <string, object> env)
        {
            if (_aspunloading)
            {
                return(Task.FromResult <bool>(true));
            }
            if (_appHost == null)
            {
                lock (_lckCreateHost)
                {
                    if (_appHost == null)
                    {
                        CreateAspApplicationHost();
                    }
                }
            }
            if (_appHost == null)
            {
                return(null);
            }
            int            reqid = CreateId();
            ReqInfo        info  = new ReqInfo(env);
            AspRequestData data  = new AspRequestData(reqid, env);

            _tasks[reqid] = info;
            RealProcess(data);
            return(info.RequestWorkTask.Task);
        }
Example #4
0
        /// <summary>
        /// 判断加载
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        bool CheckLoad(ReqInfo req)
        {
            string key = CUtils.GetUDKey(req.url);

            if (downloadings.ContainsKey(key))
            {
                return(true);
            }

            var freedownload = GetFree();

            if (freedownload != null)
            {
                int    index = req.index;
                Uri    url   = new Uri(hosts[index] + req.url);
                string path  = outputPath + req.saveName;
//                Debug.LogFormat(" begin load {0} ,save path ={1}", url.AbsoluteUri, path);
                freedownload.isFree = false;
                FileHelper.CheckCreateFilePathDirectory(path);//检测存储文件夹是否存在
                freedownload.DownloadFileAsync(url, path, req);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
    private void GameInfo(string menuName)
    {
        var gameInfo = new ReqInfo {
        };

        client.Send(gameInfo);
        Log("Sending info req => " + ObjectDumper.Dump(gameInfo));
    }
Example #6
0
        void OnFileDown(ReqInfo req, bool isError)
        {
            req.isError = isError;
            queue.Add(req);

            if (downloadings.Count == 0 && loadQueue.Count == 0)
            {
                isAllDone = true;
            }
        }
Example #7
0
        private static void RequestEnd(int id, bool iskeep)
        {
            ReqInfo info = null;

            if (_tasks.TryRemove(id, out info))
            {
                if (iskeep)
                {
                    info.RequestWorkTask.SetResult(true);
                }
                else
                {
                    info.RequestWorkTask.SetCanceled();
                }
            }
        }
Example #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        /// <param name="path"></param>
        public void Load(string url, string path)
        {
            string key = CUtils.GetUDKey(url);

            if (downloadings.ContainsKey(key))
            {
                return;
            }

            var req = new ReqInfo();

            req.url      = url;
            req.saveName = path;//CUtils.GetFileName (url);
            req.index    = 0;

            Load(req);
        }
Example #9
0
        void OnDownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            WebDownload webd = (WebDownload)sender;

            webd.isFree = true;
            ReqInfo req = (ReqInfo)e.UserState;

            string key = CUtils.GetUDKey(req.url);

            downloadings.Remove(key);

            if (e.Error == null)
            { //success
#if UNITY_EDITOR
                // Debug.LogFormat("OnDownloadFileCompleted {0}", req.url);
#endif
                OnFileDown(req, true);
            }
            else
            {
                if (req.index < hosts.Length - 1)
                {
                    req.index++;
#if UNITY_EDITOR
                    Debug.LogFormat("reload {0}  save path = {1} index = {2} ", req.url, req.saveName, req.index);
#endif
                    Load(req);
                }
                else
                {
#if UNITY_EDITOR
                    Debug.LogWarningFormat("{0} req.index={1}hosts.Length{2} \r\n {3}", req.url, req.index, hosts.Length, e.Error);
#endif
                    string path = CUtils.PathCombine(outputPath, req.saveName);
                    File.Delete(path);
                    OnFileDown(req, false);
                }
            }
        }
        public void AddBySazFile(string path)
        {
            path = "sfAutoResponseTemplates/" + path;
            path = Path.Combine(path, "raw");
            var files = Directory.GetFiles(path, "*_c.txt");

            foreach (var file in files)
            {
                var fileName = Path.GetFileName(file);
                var m        = _rexReqNo.Match(fileName);
                if (!m.Success)
                {
                    throw new InvalidDataException("无效文件名:" + fileName);
                }
                var reqNo = m.Value;

                var methodLine = GetFirstLine(file);
                m = _rexReqUrl.Match(methodLine);
                if (!m.Success)
                {
                    throw new InvalidDataException($"无效文件行:fileName={fileName}, line={methodLine}");
                }

                var reqMethod   = m.Groups[1].Value;
                var reqUrl      = m.Groups[2].Value;
                var rspFilePath = Path.Combine(Path.GetDirectoryName(file), $"{reqNo}_s.txt");
                var reqInfo     = new ReqInfo()
                {
                    Method           = reqMethod,
                    Url              = reqUrl,
                    ResponseFilePath = rspFilePath
                };

                var reqKey = reqMethod + reqUrl;
                _hookUrls[reqKey] = reqInfo;
            }
            MessageBox.Show($"新增{files.Length}条规则");
        }
Example #11
0
        void OnDownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            WebDownload webd = (WebDownload)sender;

            webd.isFree = true;
            ReqInfo req = (ReqInfo)e.UserState;

            string key = CUtils.GetUDKey(req.url);

            downloadings.Remove(key);

            if (e.Error == null)
            { //success
#if UNITY_EDITOR
                Debug.LogFormat("OnDownloadFileCompleted {0}", req.url);
#endif
                OnFileDown(req.url, true);
            }
            else
            {
                //#if UNITY_EDITOR
                Debug.LogWarning(e.Error);
                //#endif
                if (req.index < hosts.Length - 1)
                {
                    req.index++;
#if UNITY_EDITOR
                    Debug.LogFormat("reload {0}  save path = {1} ", req.url, req.saveName);
#endif
                    Load(req);
                }
                else
                {
                    OnFileDown(req.url, false);
                }
            }
        }
Example #12
0
        /// <summary>
        /// 往input 流 读入
        /// </summary>
        /// <param name="id"></param>
        /// <param name="buffer"></param>
        /// <param name="offset"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private static int Read(int id, byte[] buffer, int offset, int size)
        {
            ReqInfo info = _tasks[id];

            return(info.ReadStream.Read(buffer, offset, size));
        }
Example #13
0
 /// <summary>
 /// 加入加载队列
 /// </summary>
 /// <param name="req"></param>
 void Load(ReqInfo req)
 {
     loadQueue.Add(req);
 }
Example #14
0
        public void Load(string url, string path)
        {
            string key = CUtils.GetUDKey("", url);
            if (downloadings.ContainsKey(key))
                return;

            var req = new ReqInfo();
            req.url = url;
            req.saveName = path;//CUtils.GetFileName (url);
            req.index = 0;

            if (GetFree() != null)
            {
                downloadings.Add(key, req);
                BeginLoad(req);
            }
            else
            {
                if (waiting.ContainsKey(key))
                    waiting[key] = req;
                else
                    waiting.Add(key, req);
            }
        }
Example #15
0
 /// <summary>
 /// 加入加载队列
 /// </summary>
 /// <param name="req"></param>
 void Load(ReqInfo req)
 {
     loadQueue.Add(req);
 }
Example #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="url"></param>
        /// <param name="path"></param>
        public void Load(string url, string path, object args)
        {
            string key = CUtils.GetUDKey(url);
            if (downloadings.ContainsKey(key))
                return;

            var req = new ReqInfo();
            req.url = url;
            req.saveName = path;//CUtils.GetFileName (url);
            req.index = 0;
            req.args = args;

            Load(req);
        }
Example #17
0
        void BeginLoad(ReqInfo req)
        {
            int index = req.index;
            if (index == errorHostIndex)
            {
                int newIndex = index + 1;
                if (newIndex < hosts.Length)
                {
                    req.index = newIndex;
                    index = newIndex;
                }
                else
                {
                    index = 0;
                    req.index = 0;
                }
            }

            Uri url = new Uri(hosts[index] + req.url);
            string path = outputPath + req.saveName;
            //			Debug.LogFormat (" begin load {0} ,save path ={1}", url.AbsoluteUri, path);
            var freedownload = GetFree();
            freedownload.isFree = false;
            freedownload.DownloadFileAsync(url, path, req);
        }
Example #18
0
        /// <summary>
        /// 判断加载
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        bool CheckLoad(ReqInfo req)
        {
            string key = CUtils.GetUDKey(req.url);

            if (downloadings.ContainsKey(key)) return true;

            var freedownload = GetFree();
            if (freedownload != null)
            {
                int index = req.index;
                Uri url = new Uri(CUtils.PathCombine(hosts[index], req.url));
                string path = CUtils.PathCombine(outputPath, req.saveName);
            #if UNITY_EDITOR
                Debug.LogFormat(" begin load {0} ,save path ={1} ,index ={2}", url.AbsoluteUri, path, index);
            #endif
                freedownload.isFree = false;
                FileHelper.CheckCreateFilePathDirectory(path);//检测存储文件夹是否存在
                freedownload.DownloadFileAsync(url, path, req);
                return true;
            }
            else
            {
                return false;
            }
        }
Example #19
0
        /// <summary>
        /// 往out 流 写入
        /// </summary>
        /// <param name="id"></param>
        /// <param name="buffer"></param>
        /// <param name="offset"></param>
        /// <param name="size"></param>
        private static void Write(int id, byte[] buffer, int offset, int size)
        {
            ReqInfo info = _tasks[id];

            info.WriteStream.Write(buffer, offset, size);
        }
Example #20
0
        void OnFileDown(ReqInfo req, bool isError)
        {
            req.isError = isError;
            queue.Add(req);

            if (downloadings.Count == 0 && loadQueue.Count == 0)
            {
                isAllDone = true;
            }
        }
Example #21
0
        /// <summary>
        /// 写Response Header
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="value"></param>
        private static void WriteHeader(int id, string name, string value)
        {
            ReqInfo info = _tasks[id];

            info.ResponseHeader[name] = new string[] { value };
        }