Ejemplo n.º 1
0
        public bool SaveSetting(CSetting setting)
        {
            var dbFactory = new OrmLiteConnectionFactory(
                GetConnectionString(),
                MySqlDialectProvider.Instance);

            using (var db = dbFactory.Open())
            {
                return(db.Save <CSetting>(setting));
            }
        }
Ejemplo n.º 2
0
 public void SetFunctionUsers(string functionName, List <CUser> userList)
 {
     if (functionName != "XmlSettingFilePath")
     {
         m_Dba.DeleteAllPrivelegeForFunciton(functionName);
         List <CPrivilege> lstPrivilege = new List <CPrivilege>();
         CFunction         tmpFunc      = m_Dba.GetFunctionByName(functionName);
         foreach (CUser tmpUser in userList)
         {
             lstPrivilege.Add(new CPrivilege()
             {
                 CFunctionId = tmpFunc.Id, CUserId = tmpUser.Id
             });
         }
         m_Dba.SaveAllPrivelege(lstPrivilege);
     }
     else
     {
         CSetting tmpSetting = m_Setting.GetXmlSettingFilePath();
         if (tmpSetting != null)
         {
             List <string> lstUserID        = new List <string>();
             string        tmpDirectoryName = (new System.IO.FileInfo(tmpSetting.Value)).DirectoryName;
             GetDirectorySecurity(tmpDirectoryName,
                                  FileSystemRights.FullControl,
                                  AccessControlType.Allow,
                                  ref lstUserID);
             // add new fullcontrol access permision
             foreach (CUser tmpUser in userList)
             {
                 if (!lstUserID.Exists(tmp => tmp == tmpUser.Id))
                 {
                     AddDirectorySecurity(tmpDirectoryName,
                                          "SF\\" + tmpUser.Id,
                                          FileSystemRights.FullControl,
                                          AccessControlType.Allow);
                 }
             }
             // remove useless fullcontrol access permision
             foreach (string tmpUserId in lstUserID)
             {
                 if (!userList.Exists(tmp => tmp.Id == tmpUserId))
                 {
                     RemoveDirectorySecurity(tmpDirectoryName,
                                             "SF\\" + tmpUserId,
                                             FileSystemRights.FullControl,
                                             AccessControlType.Allow);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        public static FileVersionInfo GetCEVersion()
        {
            CSetting root = CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath);

            if (root != null)
            {
                string          edito64bitPath = root.GetValueString() + CApplicationSettings.Instance.GetValue(ESettingsStrings.SB64bitRelativePath).GetValueString();
                FileVersionInfo ceInfo         = FileVersionInfo.GetVersionInfo(edito64bitPath);

                return(ceInfo);
            }

            return(null);
        }
Ejemplo n.º 4
0
        public void ValidateRootPath()
        {
            CSetting setting = CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath) as CSetting;

            if (!CApplicationSettings.Instance.IsRootValid((string)setting.Value))
            {
                HintRootFolderValid(DemandUserSetRoot());
            }
            else
            {
                HintRootFolderValid(true);
            }


            //ValidateGameFolder();
        }
Ejemplo n.º 5
0
 public bool IsUserHasPriviledge(CUser user, string functionName)
 {
     if (functionName != "XmlSettingFilePath")
     {
         return(m_Dba.IsPrivilegeExist(functionName, user.Id));
     }
     else
     {
         CSetting      tmpSetting       = m_Setting.GetXmlSettingFilePath();
         string        tmpDirectoryName = (new System.IO.FileInfo(tmpSetting.Value)).DirectoryName;
         List <string> lstAuthUserID    = new List <string>();
         GetDirectorySecurity(tmpDirectoryName,
                              FileSystemRights.FullControl,
                              AccessControlType.Allow,
                              ref lstAuthUserID);
         return(lstAuthUserID.Exists(userId => userId == user.Id));
     }
 }
Ejemplo n.º 6
0
        public List <CUser> GetFunctionUsers(string functionName, bool flag)
        {
            List <CUser> result = new List <CUser>();

            if (functionName != "XmlSettingFilePath")
            {
                result = m_Dba.GetUsetListForFunction(functionName, flag);
            }
            else
            {
                CSetting tmpSetting = m_Setting.GetXmlSettingFilePath();
                if (tmpSetting != null)
                {
                    List <CUser>  lstUser          = m_Dba.GetUserList();
                    List <string> lstUserID        = new List <string>();
                    string        tmpDirectoryName = (new System.IO.FileInfo(tmpSetting.Value)).DirectoryName;
                    GetDirectorySecurity(tmpDirectoryName,
                                         FileSystemRights.FullControl,
                                         AccessControlType.Allow,
                                         ref lstUserID);
                    if (flag)
                    {
                        result = (from CUser tmp in lstUser
                                  where lstUserID.Exists(id => id == tmp.Id)
                                  select tmp).ToList();
                    }
                    else
                    {
                        result = (from CUser tmp in lstUser
                                  where !lstUserID.Exists(id => id == tmp.Id)
                                  select tmp).ToList();
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        private CSalesDetail AddItemToCart(int iItemMasterID, decimal dQty)
        {
            CSalesDetail sd = new CSalesDetail();
            MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);
            CItemMaster im = new CItemMaster(iItemMasterID, conn);
            //masuk ke dalam cart
            if (im.Name != "")
            {
                ApplicationSession.idx += 1;
                int flg = (int)CSalesDetail.EFlagStatus.TRANS_ITEM;
                sd = new CSalesDetail(ApplicationSession.idx, im.ID, im.Code, im.Name, im.ItemGroupName, dQty, im.Price, im.UnitSymbol, 
                                     "", "", 0, ApplicationSession.StoreID, ApplicationSession.OutletID, flg, ApplicationSession.ChairNo);

                //Master.MyProperty = ApplicationSession.QtyCart;
                List<CPromo> lstPromo = CItemMaster.ListOfItemPromos(conn, ApplicationSession.SalesType.ID, iItemMasterID, im.ItemGroupID,
                                                                     ApplicationSession.StoreID, ApplicationSession.OutletID, CSetting.GetFlagOfToday());

                //auto promo:
                IEnumerable<CPromo> lstAuto = lstPromo.Where(promo => promo.IsAutoPromo());
                if (lstAuto.ToList().Count > 0)
                {
                    List<CMiniItem> lst = sd.ApplyListOfItemPromo(lstAuto.ToList());
                    foreach (CMiniItem item in lst)
                    {
                        if (item.Name == "item")
                        {
                            ApplicationSession.idx += 1;
                            CSalesDetail child = new CSalesDetail(ApplicationSession.idx, item.ID, "promo", item.Name, "", item.Qty, item.UnitPrice, 
                                                                  "", "", "", 0, ApplicationSession.StoreID, ApplicationSession.OutletID, 0, "");
                            sd.Children.Add(child);
                        }
                    }
                }

                //manual promo:
                IEnumerable<CPromo> lstManual = lstPromo.Where(promo => promo.IsAutoPromo() == false);
                if (lstManual.ToList().Count > 0)
                {
                    //show promos & add it to sd.children
                }

                ApplicationSession.SalesMaster.CollectionSalesDetail().Add(sd);
            }
            return sd;
        }
Ejemplo n.º 8
0
        protected void SalesType_Clicked(object sender, EventArgs e)
        {
            HtmlAnchor a = (HtmlAnchor)sender;
            //ListViewItem item0 = (ListViewItem)a.Parent.Parent;
            HiddenField hf0 = (HiddenField)a.FindControl("hf_STobject");
            CSalesType  st  = JsonConvert.DeserializeObject <CSalesType>(hf0.Value);

            if (!st.isEmpty)
            {
                MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);
                st.FetchListOfOrderPromos(conn, ApplicationSession.StoreID, ApplicationSession.OutletID, CSetting.GetFlagOfToday());
                ApplicationSession.SalesType = st;
                if (st.IsCatering())
                {
                    Response.Redirect("CategoryPage.aspx");
                }
                else
                {
                    if (st.IsType(CSalesType.EFlagType.TYPE_DINEIN))
                    {
                        //CreateOrder:
                        //>>input: CoverAmt & TableNo

                        CSalesMaster sm = new CSalesMaster();
                        sm.CreateNewSales(ApplicationSession.StoreID, ApplicationSession.OutletID, ApplicationSession.SalesType.ID,
                                          1, "", 0, (int)CSalesMaster.EFlagStatus.STATUS_ORDER, 0, "", "", 0, "", true);

                        if (sm.InsertRecord(conn))
                        {
                            string str = "MainMenu.aspx?qr=010101&sm=" + sm.ID.ToString();
                            Response.Redirect(str);

                            //System.Drawing.Bitmap imgQR = CMain.CreateQRCode(str);
                            //Response.ContentType = "Image/jpeg";
                            //imgQR.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

                            //imgQR.Save(Server.MapPath("~/images/QRcode.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);

                            //imgQRcode.ImageUrl = "~/images/QRcode.jpg";
                            //aOrderNo.InnerText = str;
                            //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalConfirmed", "$(document).ready(function () {$('#ModalConfirmed').modal();});", true);
                            //Master.DisplayModalMessageBox("testing...");
                        }
                    }
                    else
                    {
                        Response.Redirect("ItemGroupPage.aspx");
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void ImportTrackingList(string sFilePath, EFileRoot root)
        {
            Reset(root, false);

            LoadFileTrackingList(sFilePath, root);

            FileInfo trackingFileInfo = new FileInfo(sFilePath);

            string        sTrackingDir     = trackingFileInfo.DirectoryName;
            string        sDestinationRoot = "";
            List <string> importList;

            switch (root)
            {
            case EFileRoot.eFR_CERoot:
            {
                sDestinationRoot = CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString();
                importList       = m_trackedCERootFiles;
            } break;

            case EFileRoot.eFR_GameFolder:
            {
                sDestinationRoot = CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString();
                importList       = m_trackedGameFolderFiles;
            } break;

            default:
                throw new Exception("Invalid value for EFileRoot");
            }

            CSetting verboseImport  = CApplicationSettings.Instance.GetValue(ESettingsStrings.VerboseImportExport);
            bool     bVerboseImport = verboseImport.GetValueBool();


            foreach (string relativePath in importList)
            {
                string sDestinationPath = sDestinationRoot + relativePath;
                string sSourcePath      = sTrackingDir + relativePath;

                FileInfo sourceFile = new FileInfo(sSourcePath);
                FileInfo targetFile = new FileInfo(sDestinationPath);


                int compareResult = sourceFile.LastWriteTime.CompareTo(targetFile.LastWriteTime);

                if (compareResult > 0)
                {
                    try
                    {
                        // Using CopyFile here too in case of large files
                        // DONE_TODO: see if this gets troublesome if file already exists
                        // Using custom function instead
                        CProcessUtils.CopyFile(sSourcePath, sDestinationPath, true);
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (compareResult == 0)
                {
                    string message = String.Format("Source file {1} is not different " +
                                                   "from destination file {0}, skipping import for it", sDestinationPath,
                                                   sSourcePath);                                             // LOCALIZE
                    if (bVerboseImport)
                    {
                        CUserInteractionUtils.ShowInfoMessageBox(message);
                    }

                    message = String.Format("Source file {1} is not different " +
                                            "from destination file {0}, skipping import for it", sDestinationPath,
                                            sSourcePath);                                                    // DONOTLOCALIZE
                    // Always log to file...
                    CLogfile.Instance.LogWarning("[Source tracker]" + message);
                }
                else
                {
                    string message = String.Format("Destination file {0} is more recent than " +
                                                   "source file {1}, skipping import for it", sDestinationPath,
                                                   sSourcePath);                                             // LOCALIZE
                    if (bVerboseImport)
                    {
                        CUserInteractionUtils.ShowInfoMessageBox(message);
                    }
                    message = String.Format("Destination file {0} is more recent than " +
                                            "source file {1}, skipping import for it", sDestinationPath,
                                            sSourcePath);                                                     // DONOTLOCALIZE
                    // Always log to file...
                    CLogfile.Instance.LogWarning("[Source tracker]" + message);
                }
            }


            string sLastImportFiles    = CApplicationSettings.Instance.GetValue(ESettingsStrings.LastImportFiles).GetValueString();
            string sNewLastImportFiles = "";

            char[] splitter = { ';' };

            string[] singleFiles = sLastImportFiles.Split(splitter, StringSplitOptions.RemoveEmptyEntries);

            // If there are two files then look for the obsolete one

            foreach (string lastSave in singleFiles)
            {
                if (lastSave != m_sCurrentTrackingList)
                {
                    sNewLastImportFiles += lastSave + ";";
                }
            }


            m_sCurrentTrackingList = sFilePath;
            sNewLastImportFiles   += sFilePath;

            CApplicationSettings.Instance.SetValue(new CSetting(ESettingsStrings.LastImportFiles,
                                                                sNewLastImportFiles));
        }
Ejemplo n.º 10
0
 public void SaveXmlSettingFilePath(CSetting setting)
 {
     m_Dba.SaveSetting(setting);
 }