示例#1
0
        private IReadOnlyDictionary <string, ICacheParameter> LocalizeCacheParameters(ITemplateInfo template,
                                                                                      ILocalizationLocator localizationInfo)
        {
            if (localizationInfo == null || localizationInfo.ParameterSymbols == null)
            {
                return(template.CacheParameters);
            }

            IReadOnlyDictionary <string, ICacheParameter> cacheParameters = template.CacheParameters;
            IReadOnlyDictionary <string, IParameterSymbolLocalizationModel> parameterSymbols = localizationInfo.ParameterSymbols;
            Dictionary <string, ICacheParameter> dictionary = new Dictionary <string, ICacheParameter>();

            foreach (KeyValuePair <string, ICacheParameter> item in cacheParameters)
            {
                if (parameterSymbols.TryGetValue(item.Key, out IParameterSymbolLocalizationModel value))
                {
                    ICacheParameter value2 = new CacheParameter
                    {
                        DataType     = item.Value.DataType,
                        DefaultValue = item.Value.DefaultValue,
                        Description  = value.Description ?? item.Value.Description
                    };
                    dictionary.Add(item.Key, value2);
                }
                else
                {
                    dictionary.Add(item.Key, item.Value);
                }
            }

            return(dictionary);
        }
示例#2
0
        private IReadOnlyDictionary <string, ICacheParameter> LocalizeCacheParameters(ITemplateInfo template, ILocalizationLocator localizationInfo)
        {
            if (localizationInfo == null || localizationInfo.ParameterSymbols == null)
            {
                return(template.CacheParameters);
            }

            IReadOnlyDictionary <string, ICacheParameter> templateCacheParameters = template.CacheParameters;
            IReadOnlyDictionary <string, IParameterSymbolLocalizationModel> localizedParameterSymbols = localizationInfo.ParameterSymbols;


            Dictionary <string, ICacheParameter> localizedCacheParams = new Dictionary <string, ICacheParameter>();

            foreach (KeyValuePair <string, ICacheParameter> templateParam in templateCacheParameters)
            {
                if (localizedParameterSymbols.TryGetValue(templateParam.Key, out IParameterSymbolLocalizationModel localizationForParam))
                {   // there is loc info for this symbol
                    ICacheParameter localizedParam = new CacheParameter
                    {
                        DataType     = templateParam.Value.DataType,
                        DefaultValue = templateParam.Value.DefaultValue,
                        Description  = localizationForParam.Description ?? templateParam.Value.Description
                    };

                    localizedCacheParams.Add(templateParam.Key, localizedParam);
                }
                else
                {
                    localizedCacheParams.Add(templateParam.Key, templateParam.Value);
                }
            }

            return(localizedCacheParams);
        }
示例#3
0
        public List <string> searchbyname(string name)
        {
            CacheCommand cc;

            idlist.Clear();
            List <string> anamelist = new List <string>();

            try
            {
                cc = new CacheCommand("Select AID, ANAME from ADBK WHERE ANAME %startswith ?", adbksrc.conn);
                CacheParameter cp = new CacheParameter("Name", CacheDbType.NVarChar);
                cp.Value = name;
                cc.Parameters.Add(cp);
                CacheDataReader reader = cc.ExecuteReader();

                while (reader.Read())
                {
                    string id    = reader[reader.GetOrdinal("AID")].ToString();
                    string aname = reader[reader.GetOrdinal("ANAME")].ToString();
                    anamelist.Add(aname);
                    idlist.Add(id);
                }
                return(anamelist);
            }
            catch (Exception err)
            {
                MessageBox.Show("searchbynameエラー " + err.Message);
                return(anamelist);
            }
            //return anamelist;
        }
示例#4
0
        static void Main(string[] args)
        {
            CacheConnection CacheConnect = new CacheConnection();

            CacheConnect.ConnectionString = "Server=192.168.1.10;Port=5641;User=_SYSTEM;Password=SYS;Namespace=company2;Pooling=false;";
            CacheConnect.Open();

            //Lock Query List Example
            Console.WriteLine("Lock Query List Example");
            CacheDataAdapter cadpt    = new CacheDataAdapter();
            DataSet          ds       = new DataSet();
            CacheCommand     cmdCache = new CacheCommand("%SYS.LockQuery_List", CacheConnect);

            cmdCache.CommandType = CommandType.StoredProcedure;
            cadpt.SelectCommand  = cmdCache;
            cadpt.Fill(ds, "Locks");
            bool   locked = false;
            int    id     = 13395;
            string table  = "Invoice";

            foreach (DataRow row in ds.Tables["Locks"].Rows) //loop through locks
            {
                Console.WriteLine(row["LockString"]);
                if (row["LockString"].Equals("^oo" + table + "D(" + id + ")")) //depends on class storage definition data location
                {
                    locked = true;
                    break;
                }
            }
            if (locked)
            {
                Console.WriteLine("Record is locked");
            }
            else
            {
                Console.WriteLine("Record is unlocked");
            }
            Console.WriteLine();
            //Process Query Example
            Console.WriteLine("Process Query Example");
            CacheCommand cmdCache2 = new CacheCommand("%SYS.ProcessQuery_CONTROLPANEL", CacheConnect);

            cmdCache2.CommandType = CommandType.StoredProcedure;
            CacheParameter JNparam = new CacheParameter("JobNumber", CacheDbType.Int);

            JNparam.Value = 1;
            cmdCache2.Parameters.Add(JNparam);
            cadpt.SelectCommand = cmdCache2;
            cadpt.Fill(ds, "Processes");
            foreach (DataRow row in ds.Tables["Processes"].Rows) //loop through processes
            {
                Console.WriteLine("Job Number: " + row["Job#"] + ", Namespace: " + row["Nspace"]);
            }
        }
 public void AddCache <TResult>(string key, Func <TDataContext, StructQueryParameters, TResult> func)
 {
     lock (_lock)
     {
         Cache[key] = new CacheParameter <TResult>
         {
             Func          = func,
             LastExecution = DateTime.Now,
         };
         ClearCache();
     }
 }
            public CacheParameter <TResult> GetCache <TResult>(string key)
            {
                CacheParameter <TResult> cache = null;

                lock (_lock)
                {
                    if (Cache.ContainsKey(key))
                    {
                        cache = (CacheParameter <TResult>)Cache[key];
                    }
                    ClearCache();
                }
                return(cache);
            }
示例#7
0
        public void searchbyid(string id)
        {
            CacheCommand    cc;
            CacheDataReader cr;

            try
            {
                cc = new CacheCommand("Select AID, ACITY, ANAME, ABTHDAY, ASTREET , APHHOME , APHWORK, AAGE, AZIP from ADBK WHERE AID = ?", adbksrc.conn);

                CacheParameter cp = new CacheParameter("id", CacheDbType.NVarChar);
                cp.Value = id;
                cc.Parameters.Add(cp);
                cr = cc.ExecuteReader();
                updatedatamodel(cr);
            }
            catch (Exception err)
            {
                MessageBox.Show("seachbyid エラー " + err.Message);
            }
        }
示例#8
0
        public List <string> searchbyname(string name)
        {
            idlist.Clear();
            List <string>  anamelist = new List <string>();
            CacheCommand   cc        = User.ADBK.ByName(adbksrc.conn);
            CacheParameter cp        = new CacheParameter("Name", CacheDbType.NVarChar);

            cp.Value = name;
            cc.Parameters.Add(cp);

            CacheDataReader reader = cc.ExecuteReader();

            while (reader.Read())
            {
                string id    = reader[reader.GetOrdinal("AID")].ToString();
                string aname = reader[reader.GetOrdinal("ANAME")].ToString();
                anamelist.Add(aname);
                idlist.Add(id);
            }
            return(anamelist);
        }
示例#9
0
        public Boolean delete(string id)
        {
            CacheCommand cc;

            if (MessageBox.Show("削除しますか", "削除", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    cc = new CacheCommand("DELETE FROM ADBK WHERE AID = ?", adbksrc.conn);
                    CacheParameter cp = new CacheParameter("id", CacheDbType.NVarChar);
                    cp.Value = id;
                    cc.Parameters.Add(cp);
                    cc.ExecuteNonQuery();
                    return(true);
                }
                catch (Exception err)
                {
                    MessageBox.Show("削除エラー" + err.Message);
                    return(false);
                }
            }
            return(false);
        }
示例#10
0
        public TemplateInfo(JObject entry)
        {
            ConfigMountPointId = Guid.Parse(entry.ToString(nameof(ConfigMountPointId)));
            Author             = entry.ToString(nameof(Author));
            JArray classificationsArray = entry.Get <JArray>(nameof(Classifications));

            List <string> classifications = new List <string>();

            Classifications = classifications;
            //using (Timing.Over("Read classifications"))
            foreach (JToken item in classificationsArray)
            {
                classifications.Add(item.ToString());
            }

            DefaultName   = entry.ToString(nameof(DefaultName));
            Description   = entry.ToString(nameof(Description));
            Identity      = entry.ToString(nameof(Identity));
            GeneratorId   = Guid.Parse(entry.ToString(nameof(GeneratorId)));
            GroupIdentity = entry.ToString(nameof(GroupIdentity));
            Name          = entry.ToString(nameof(Name));
            ShortName     = entry.ToString(nameof(ShortName));

            // parse the cached tags
            Dictionary <string, ICacheTag> tags = new Dictionary <string, ICacheTag>();
            JObject tagsObject = entry.Get <JObject>(nameof(Tags));

            foreach (JProperty item in tagsObject.Properties())
            {
                Dictionary <string, string> choicesAndDescriptions = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                JObject cdToken = item.Value.Get <JObject>(nameof(ICacheTag.ChoicesAndDescriptions));
                foreach (JProperty cdPair in cdToken.Properties())
                {
                    choicesAndDescriptions.Add(cdPair.Name.ToString(), cdPair.Value.ToString());
                }

                ICacheTag cacheTag = new CacheTag(
                    item.Value.ToString(nameof(ICacheTag.Description)),
                    choicesAndDescriptions,
                    item.Value.ToString(nameof(ICacheTag.DefaultValue)));
                tags.Add(item.Name.ToString(), cacheTag);
            }
            Tags = tags;

            // parse the cached params
            JObject cacheParamsObject = entry.Get <JObject>(nameof(CacheParameters));
            Dictionary <string, ICacheParameter> cacheParams = new Dictionary <string, ICacheParameter>();

            foreach (JProperty item in cacheParamsObject.Properties())
            {
                ICacheParameter param = new CacheParameter
                {
                    DataType     = item.Value.ToString(nameof(ICacheParameter.DataType)),
                    DefaultValue = item.Value.ToString(nameof(ICacheParameter.DefaultValue)),
                    Description  = item.Value.ToString(nameof(ICacheParameter.Description))
                };

                cacheParams[item.Name.ToString()] = param;
            }
            CacheParameters = cacheParams;

            ConfigPlace = entry.ToString(nameof(ConfigPlace));
            LocaleConfigMountPointId = Guid.Parse(entry.ToString(nameof(LocaleConfigMountPointId)));
            LocaleConfigPlace        = entry.ToString(nameof(LocaleConfigPlace));

            HostConfigMountPointId = Guid.Parse(entry.ToString(nameof(HostConfigMountPointId)));
            HostConfigPlace        = entry.ToString(nameof(HostConfigPlace));
        }
示例#11
0
        public static TemplateInfo FromJObject(JObject entry)
        {
            TemplateInfo info = new TemplateInfo();

            info.ConfigMountPointId = Guid.Parse(entry.ToString(nameof(TemplateInfo.ConfigMountPointId)));
            info.Author             = entry.ToString(nameof(TemplateInfo.Author));
            JArray classificationsArray = entry.Get <JArray>(nameof(TemplateInfo.Classifications));

            List <string> classifications = new List <string>();

            info.Classifications = classifications;
            //using (Timing.Over("Read classifications"))
            foreach (JToken item in classificationsArray)
            {
                classifications.Add(item.ToString());
            }

            info.DefaultName   = entry.ToString(nameof(TemplateInfo.DefaultName));
            info.Description   = entry.ToString(nameof(TemplateInfo.Description));
            info.Identity      = entry.ToString(nameof(TemplateInfo.Identity));
            info.GeneratorId   = Guid.Parse(entry.ToString(nameof(TemplateInfo.GeneratorId)));
            info.GroupIdentity = entry.ToString(nameof(TemplateInfo.GroupIdentity));
            info.Precedence    = entry.ToInt32(nameof(TemplateInfo.Precedence));
            info.Name          = entry.ToString(nameof(TemplateInfo.Name));
            info.ShortName     = entry.ToString(nameof(TemplateInfo.ShortName));

            // parse the cached tags
            Dictionary <string, ICacheTag> tags = new Dictionary <string, ICacheTag>();
            JObject tagsObject = entry.Get <JObject>(nameof(TemplateInfo.Tags));

            if (tagsObject != null)
            {
                foreach (JProperty item in tagsObject.Properties())
                {
                    Dictionary <string, string> choicesAndDescriptions = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                    JObject cdToken = item.Value.Get <JObject>(nameof(ICacheTag.ChoicesAndDescriptions));
                    foreach (JProperty cdPair in cdToken.Properties())
                    {
                        choicesAndDescriptions.Add(cdPair.Name.ToString(), cdPair.Value.ToString());
                    }

                    ICacheTag cacheTag = new CacheTag(
                        item.Value.ToString(nameof(ICacheTag.Description)),
                        choicesAndDescriptions,
                        item.Value.ToString(nameof(ICacheTag.DefaultValue)));
                    tags.Add(item.Name.ToString(), cacheTag);
                }
            }
            info.Tags = tags;

            // parse the cached params
            JObject cacheParamsObject = entry.Get <JObject>(nameof(TemplateInfo.CacheParameters));
            Dictionary <string, ICacheParameter> cacheParams = new Dictionary <string, ICacheParameter>();

            if (cacheParamsObject != null)
            {
                foreach (JProperty item in cacheParamsObject.Properties())
                {
                    ICacheParameter param = new CacheParameter
                    {
                        DataType     = item.Value.ToString(nameof(ICacheParameter.DataType)),
                        DefaultValue = item.Value.ToString(nameof(ICacheParameter.DefaultValue)),
                        Description  = item.Value.ToString(nameof(ICacheParameter.Description))
                    };

                    cacheParams[item.Name.ToString()] = param;
                }
            }
            info.CacheParameters = cacheParams;

            info.ConfigPlace = entry.ToString(nameof(TemplateInfo.ConfigPlace));
            info.LocaleConfigMountPointId = Guid.Parse(entry.ToString(nameof(TemplateInfo.LocaleConfigMountPointId)));
            info.LocaleConfigPlace        = entry.ToString(nameof(TemplateInfo.LocaleConfigPlace));

            info.HostConfigMountPointId = Guid.Parse(entry.ToString(nameof(TemplateInfo.HostConfigMountPointId)));
            info.HostConfigPlace        = entry.ToString(nameof(TemplateInfo.HostConfigPlace));

            return(info);
        }
示例#12
0
        public void save(string id)
        {
            CacheCommand     cc;
            CacheParameter   cp;
            CacheTransaction ctx;

            try
            {
                ctx = adbksrc.conn.BeginTransaction(IsolationLevel.ReadCommitted);

                if (newflag == true)
                {
                    cc = new CacheCommand("INSERT INTO ADBK (ANAME,ASTREET,APHHOME,APHWORK,AZIP,ABTHDAY) VALUES(?,?,?,?,?,?)", adbksrc.conn, ctx);

                    cp       = new CacheParameter("Name", CacheDbType.NVarChar);
                    cp.Value = Name;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("Street", CacheDbType.NVarChar);
                    cp.Value = Street;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("HomePhone", CacheDbType.NVarChar);
                    cp.Value = HomePhone;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("WorkPhone", CacheDbType.NVarChar);
                    cp.Value = WorkPhone;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("ZipCode", CacheDbType.NVarChar);
                    cp.Value = ZipCode;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("Dob", CacheDbType.Date);
                    cp.Value = dob.ToString().Split(' ')[0].ToString();
                    cc.Parameters.Add(cp);
                }
                else
                {
                    cc = new CacheCommand("UPDATE ADBK SET ANAME = ?,ASTREET = ?,APHHOME = ?,APHWORK = ?,AZIP = ?,ABTHDAY = ? WHERE AID = ?", adbksrc.conn, ctx);

                    cp       = new CacheParameter("Name", CacheDbType.NVarChar);
                    cp.Value = Name;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("Street", CacheDbType.NVarChar);
                    cp.Value = Street;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("HomePhone", CacheDbType.NVarChar);
                    cp.Value = HomePhone;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("WorkPhone", CacheDbType.NVarChar);
                    cp.Value = WorkPhone;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("ZipCode", CacheDbType.NVarChar);
                    cp.Value = ZipCode;
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("Dob", CacheDbType.Date);
                    cp.Value = dob.ToString().Split(' ')[0].ToString();
                    cc.Parameters.Add(cp);
                    cp       = new CacheParameter("id", CacheDbType.NVarChar);
                    cp.Value = id;
                    cc.Parameters.Add(cp);
                }

                cc.ExecuteNonQuery();

                if (newflag == true)
                {
                    //cc = new CacheCommand("SELECT MAX(AID) FROM ADBK", adbksrc.conn,ctx);
                    cc = new CacheCommand("SELECT LAST_IDENTITY() FROM ADBK", adbksrc.conn, ctx);
                    CacheDataReader reader = cc.ExecuteReader();

                    while (reader.Read())
                    {
                        string aid = reader[0].ToString();
                        id = aid;

                        cc = new CacheCommand("Select AID, ACITY, ANAME, ABTHDAY, ASTREET , APHHOME , APHWORK, AAGE, AZIP from ADBK WHERE AID = ?", adbksrc.conn, ctx);

                        CacheParameter cp2 = new CacheParameter("id", CacheDbType.NVarChar);
                        cp2.Value = aid;
                        cc.Parameters.Add(cp2);
                        CacheDataReader cr = cc.ExecuteReader();
                        updatedatamodel(cr);
                    }
                }

                ctx.Commit();
            }
            catch (Exception err)
            {
                MessageBox.Show("保存エラー " + err.Message);
            }
        }
示例#13
0
        public void AddResult(ClsPostResult result)
        {
            try
            {
                //Add Log
                AddLog(result.appId, "AddOrder", "RemoteIP:" + result.remoteIP + ";" + result.orderId);

                //Check if result exist
                Cmd = new CacheCommand("DELETE  from  Results.Results where orderId= '" + result.orderId + "' and OrderCode = '" + result.orderCode + "'", GetConnection());
                //dt.Load(Cmd.ExecuteReader());
                Cmd.ExecuteNonQuery();

                //if (dt.Rows.Count == 0)
                //{

                string strQuery = "INSERT Results.Results(FileName,Client,OrderCode,OrderId,ResultBinaryStream,ResultType,ResultName,ResultDate,Flag , NormalRange ,Units ,ResultText , locationId  )" +
                                  " VALUES(@FileName,@Client,@OrderCode,@OrderId,@ResultBinaryStream ,@ResultType,@ResultName,@ResultDate , @Flag , @NormalRange ,@Units , @ResultText , @locationId )";
                Cmd = new CacheCommand(strQuery, GetConnection());
                //}
                //else
                //{
                //    string strQuery = "UPDATE Results.Results SET FileName = @FileName, Client=@Client ,ResultBinaryStream = @ResultBinaryStream, ResultType=@ResultType,ResultName=@ResultName,ResultDate=@ResultDate,Flag=@Flag , NormalRange=@NormalRange , Units=@Units, ResultText=@ResultText " +
                //   " Where OrderId = @OrderId and OrderCode=@OrderCode";

                //    Cmd = new CacheCommand(strQuery, GetConnection());

                //}

                Cmd.Parameters.Add("@locationId", result.locationId);

                Cmd.Parameters.Add("@Flag", result.resultFlag);
                Cmd.Parameters.Add("@NormalRange", result.normalRange);
                Cmd.Parameters.Add("@Units", result.resultUnits);

                Cmd.Parameters.Add("@Client", result.clientId);
                Cmd.Parameters.Add("@OrderCode", result.orderCode);
                Cmd.Parameters.Add("@OrderId", result.orderId);
                Cmd.Parameters.Add("@ResultType", result.resultType);
                Cmd.Parameters.Add("@ResultName", result.resultName);
                Cmd.Parameters.Add("@ResultDate", DateTime.Now.ToString("yyyyMMdd HH:mm:ss"));
                Cmd.Parameters.Add("@ResultText", result.resultText);


                // Now insert two files from disk as streams
                // Open binary file and read into byte[]

                Cmd.Parameters.Add("@FileName", result.fileName);

                //FileStream fbs = new System.IO.FileStream("test.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
                //int filebLen = (int)fbs.Length;
                //byte[] filebData = new byte[file
                //fbs.Read(filebData, 0, (int)filebLen);
                //fbs.Close();


                //Cmd.Parameters.Add()
                CacheParameter para = new CacheParameter("@ResultBinaryStream", result.resultBinaryStream);
                para.Size = result.resultBinaryStream.Length;
                Cmd.Parameters.Add(para);

                Cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                if (e.Message.Contains("ClientIndex"))
                {
                    throw new Exception("Result for order Id: " + result.orderId + " and order code:" + result.orderCode + " exists in the system.");
                }
                else
                {
                    throw e;
                }
            }
            finally
            {
                CacheConnect.Close();
            }
        }